@autobest-ui/components 2.9.2 → 2.10.0-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 +6 -3
- package/esm/index.js +4 -2
- package/esm/input/Input.d.ts +13 -1
- package/esm/input/Input.js +64 -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/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 +6 -3
- package/lib/index.js +40 -2
- package/lib/input/Input.d.ts +13 -1
- package/lib/input/Input.js +64 -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/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
package/esm/affix/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AddListenerEventRemoveHandler, getOffsetAndSize } from '@autobest-ui/utils';
|
|
3
3
|
export interface GetFixedStateParams {
|
|
4
4
|
positionInfo: OffsetInfo;
|
|
5
5
|
scrollTop: number;
|
|
@@ -59,8 +59,8 @@ interface AffixStates {
|
|
|
59
59
|
declare type OffsetInfo = ReturnType<typeof getOffsetAndSize>;
|
|
60
60
|
declare class Affix extends React.Component<AffixProps, AffixStates> {
|
|
61
61
|
prefixCls: string;
|
|
62
|
-
scrollHandler:
|
|
63
|
-
resizeHandler:
|
|
62
|
+
scrollHandler: AddListenerEventRemoveHandler;
|
|
63
|
+
resizeHandler: AddListenerEventRemoveHandler;
|
|
64
64
|
isFixed: boolean;
|
|
65
65
|
wrapRef: React.RefObject<HTMLDivElement>;
|
|
66
66
|
customRef: React.RefObject<HTMLDivElement>;
|
package/esm/affix/index.js
CHANGED
|
@@ -153,11 +153,11 @@ var Affix = /** @class */function (_super) {
|
|
|
153
153
|
};
|
|
154
154
|
Affix.prototype.componentWillUnmount = function () {
|
|
155
155
|
if (this.scrollHandler) {
|
|
156
|
-
this.scrollHandler
|
|
156
|
+
this.scrollHandler();
|
|
157
157
|
this.scrollHandler = null;
|
|
158
158
|
}
|
|
159
159
|
if (this.resizeHandler) {
|
|
160
|
-
this.resizeHandler
|
|
160
|
+
this.resizeHandler();
|
|
161
161
|
this.resizeHandler = null;
|
|
162
162
|
}
|
|
163
163
|
};
|
package/esm/carousel/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
|
export interface CarouselProps {
|
|
4
4
|
children: React.ReactElement[] | React.ReactElement;
|
|
5
5
|
/**
|
|
@@ -74,7 +74,7 @@ declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
|
|
|
74
74
|
fadeEffect: boolean;
|
|
75
75
|
monitorWindowResize: boolean;
|
|
76
76
|
};
|
|
77
|
-
resizeHandler:
|
|
77
|
+
resizeHandler: AddListenerEventRemoveHandler | null;
|
|
78
78
|
constructor(props: any);
|
|
79
79
|
componentDidMount(): void;
|
|
80
80
|
componentDidUpdate(prevProps: CarouselProps): void;
|
package/esm/carousel/index.js
CHANGED
|
@@ -310,7 +310,7 @@ var Carousel = /** @class */function (_super) {
|
|
|
310
310
|
clearTimeout(this.autoplayTimer);
|
|
311
311
|
clearTimeout(this.fadeEffectTimer);
|
|
312
312
|
if (this.resizeHandler) {
|
|
313
|
-
this.resizeHandler
|
|
313
|
+
this.resizeHandler();
|
|
314
314
|
this.resizeHandler = null;
|
|
315
315
|
}
|
|
316
316
|
if (this.intersectionObserver) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { MouseEvent } from 'react';
|
|
2
|
+
export interface CheckboxProps {
|
|
3
|
+
children?: React.ReactChild | React.ReactChild[];
|
|
4
|
+
/**
|
|
5
|
+
* checked变化的回调函数, 参数 checked: boolean
|
|
6
|
+
*/
|
|
7
|
+
onChange: (checked: boolean, name?: string | number) => void;
|
|
8
|
+
/**
|
|
9
|
+
* 是否选中
|
|
10
|
+
*/
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 初始是否选中
|
|
14
|
+
*/
|
|
15
|
+
defaultChecked?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* checkbox样式
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
name?: string | number;
|
|
21
|
+
/**
|
|
22
|
+
* 勾选框尺寸,单位px
|
|
23
|
+
*/
|
|
24
|
+
size?: number;
|
|
25
|
+
/**
|
|
26
|
+
* 是否禁用
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 掉转文字和勾选框位置
|
|
31
|
+
*/
|
|
32
|
+
reverse?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 主题样式
|
|
35
|
+
* white为选中时白底红箭头
|
|
36
|
+
* blue为选中时蓝底白箭头
|
|
37
|
+
*/
|
|
38
|
+
theme?: 'white' | 'blue';
|
|
39
|
+
}
|
|
40
|
+
interface CheckboxState {
|
|
41
|
+
visible: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
44
|
+
static defaultProps: {
|
|
45
|
+
size: number;
|
|
46
|
+
disabled: boolean;
|
|
47
|
+
defaultChecked: boolean;
|
|
48
|
+
reverse: boolean;
|
|
49
|
+
theme: string;
|
|
50
|
+
};
|
|
51
|
+
constructor(props: any);
|
|
52
|
+
static getDerivedStateFromProps(nextProps: CheckboxProps, prevState: CheckboxState): {
|
|
53
|
+
visible: boolean;
|
|
54
|
+
};
|
|
55
|
+
onVisibleChange: () => void;
|
|
56
|
+
renderBox: () => JSX.Element;
|
|
57
|
+
onClick: (e: MouseEvent<HTMLLabelElement>) => void;
|
|
58
|
+
render(): JSX.Element;
|
|
59
|
+
}
|
|
60
|
+
export default Checkbox;
|
|
@@ -0,0 +1,120 @@
|
|
|
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 from 'react';
|
|
24
|
+
import classNames from 'classnames';
|
|
25
|
+
var cls = 'ab-checkbox';
|
|
26
|
+
var Checkbox = /** @class */function (_super) {
|
|
27
|
+
__extends(Checkbox, _super);
|
|
28
|
+
function Checkbox(props) {
|
|
29
|
+
var _this = _super.call(this, props) || this;
|
|
30
|
+
_this.onVisibleChange = function () {
|
|
31
|
+
var _a = _this.props,
|
|
32
|
+
disabled = _a.disabled,
|
|
33
|
+
onChange = _a.onChange,
|
|
34
|
+
name = _a.name;
|
|
35
|
+
if (disabled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var visible = !_this.state.visible;
|
|
39
|
+
if (!('checked' in _this.props)) {
|
|
40
|
+
_this.setState({
|
|
41
|
+
visible: visible
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
onChange(visible, name);
|
|
45
|
+
};
|
|
46
|
+
_this.renderBox = function () {
|
|
47
|
+
var _a;
|
|
48
|
+
var _b = _this.props,
|
|
49
|
+
className = _b.className,
|
|
50
|
+
disabled = _b.disabled,
|
|
51
|
+
size = _b.size,
|
|
52
|
+
theme = _b.theme;
|
|
53
|
+
var visible = _this.state.visible;
|
|
54
|
+
var innerStyle = {
|
|
55
|
+
width: "".concat(size, "px"),
|
|
56
|
+
height: "".concat(size, "px")
|
|
57
|
+
};
|
|
58
|
+
var iconStyle = {
|
|
59
|
+
width: "".concat(size * 6 / 16, "px"),
|
|
60
|
+
height: "".concat(size * 10 / 16, "px")
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
63
|
+
className: classNames(cls, className, "".concat(cls, "-").concat(theme), (_a = {}, _a["".concat(cls, "-checked")] = visible, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
64
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
65
|
+
className: "".concat(cls, "-input"),
|
|
66
|
+
type: "checkbox",
|
|
67
|
+
onChange: _this.onVisibleChange
|
|
68
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
69
|
+
className: "".concat(cls, "-inner"),
|
|
70
|
+
style: innerStyle
|
|
71
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
72
|
+
className: "".concat(cls, "-icon"),
|
|
73
|
+
style: iconStyle
|
|
74
|
+
})));
|
|
75
|
+
};
|
|
76
|
+
_this.onClick = function (e) {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
};
|
|
79
|
+
_this.state = {
|
|
80
|
+
visible: props.checked || props.defaultChecked
|
|
81
|
+
};
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
Checkbox.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
85
|
+
// 如果父级传了 checked 则更新 state
|
|
86
|
+
if ('checked' in nextProps && nextProps.checked !== prevState.visible) {
|
|
87
|
+
return {
|
|
88
|
+
visible: nextProps.checked
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
};
|
|
93
|
+
Checkbox.prototype.render = function () {
|
|
94
|
+
var _a;
|
|
95
|
+
var _b = this.props,
|
|
96
|
+
className = _b.className,
|
|
97
|
+
disabled = _b.disabled,
|
|
98
|
+
children = _b.children,
|
|
99
|
+
reverse = _b.reverse;
|
|
100
|
+
// 只渲染复选框
|
|
101
|
+
if (!children) {
|
|
102
|
+
return this.renderBox();
|
|
103
|
+
}
|
|
104
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
105
|
+
onClick: this.onClick,
|
|
106
|
+
className: classNames("".concat(cls, "-wrap"), className, (_a = {}, _a["".concat(cls, "-reverse")] = reverse, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
107
|
+
}, this.renderBox(), children ? /*#__PURE__*/React.createElement("span", {
|
|
108
|
+
className: "".concat(cls, "-content")
|
|
109
|
+
}, children) : null);
|
|
110
|
+
};
|
|
111
|
+
Checkbox.defaultProps = {
|
|
112
|
+
size: 16,
|
|
113
|
+
disabled: false,
|
|
114
|
+
defaultChecked: false,
|
|
115
|
+
reverse: false,
|
|
116
|
+
theme: 'white'
|
|
117
|
+
};
|
|
118
|
+
return Checkbox;
|
|
119
|
+
}(React.Component);
|
|
120
|
+
export default Checkbox;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CheckboxProps } from './Checkbox';
|
|
3
|
+
declare type CommonCheckboxProps = Partial<Pick<CheckboxProps, 'theme' | 'reverse' | 'disabled'>>;
|
|
4
|
+
export interface CheckboxGroupOptionItem extends CommonCheckboxProps {
|
|
5
|
+
name: string;
|
|
6
|
+
value?: string | number;
|
|
7
|
+
checked: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CheckboxGroupProps extends CommonCheckboxProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
onChange: (options: CheckboxGroupOptionItem[], name?: string) => void;
|
|
13
|
+
options: CheckboxGroupOptionItem[];
|
|
14
|
+
}
|
|
15
|
+
declare const CheckboxGroup: FC<CheckboxGroupProps>;
|
|
16
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 React from 'react';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { isEmptyArray, isUndef } from '@autobest-ui/utils';
|
|
16
|
+
import Checkbox from './Checkbox';
|
|
17
|
+
function getCheckboxProp(checkboxProp, checkboxGroupProp) {
|
|
18
|
+
return isUndef(checkboxProp) ? checkboxGroupProp : checkboxProp;
|
|
19
|
+
}
|
|
20
|
+
var cls = 'ab-checkbox';
|
|
21
|
+
var CheckboxGroup = function CheckboxGroup(_a) {
|
|
22
|
+
var onChange = _a.onChange,
|
|
23
|
+
groupName = _a.name,
|
|
24
|
+
options = _a.options,
|
|
25
|
+
className = _a.className,
|
|
26
|
+
disabled = _a.disabled,
|
|
27
|
+
reverse = _a.reverse,
|
|
28
|
+
theme = _a.theme;
|
|
29
|
+
if (isEmptyArray(options)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var onCheckboxChange = function onCheckboxChange(checked, name) {
|
|
33
|
+
var newOptions = options.map(function (item) {
|
|
34
|
+
if (item.name === name) {
|
|
35
|
+
return __assign(__assign({}, item), {
|
|
36
|
+
checked: checked
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return item;
|
|
40
|
+
});
|
|
41
|
+
onChange(newOptions, groupName);
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: classNames("".concat(cls, "-group"), className)
|
|
45
|
+
}, options.map(function (item) {
|
|
46
|
+
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
47
|
+
key: item.name,
|
|
48
|
+
name: item.name,
|
|
49
|
+
reverse: getCheckboxProp(item.reverse, reverse),
|
|
50
|
+
theme: getCheckboxProp(item.theme, theme),
|
|
51
|
+
disabled: getCheckboxProp(item.disabled, disabled),
|
|
52
|
+
checked: item.checked,
|
|
53
|
+
onChange: onCheckboxChange
|
|
54
|
+
}, item.name);
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
export default CheckboxGroup;
|
package/esm/checkbox/index.d.ts
CHANGED
|
@@ -1,52 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* checked变化的回调函数, 参数 checked: boolean
|
|
6
|
-
*/
|
|
7
|
-
onChange: (checked: boolean, name?: string | number) => void;
|
|
8
|
-
/**
|
|
9
|
-
* 是否选中
|
|
10
|
-
*/
|
|
11
|
-
checked?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* 初始是否选中
|
|
14
|
-
*/
|
|
15
|
-
defaultChecked?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* checkbox样式
|
|
18
|
-
*/
|
|
19
|
-
className?: string;
|
|
20
|
-
name?: string | number;
|
|
21
|
-
/**
|
|
22
|
-
* 勾选框尺寸,单位px
|
|
23
|
-
*/
|
|
24
|
-
size?: number;
|
|
25
|
-
/**
|
|
26
|
-
* 是否禁用
|
|
27
|
-
*/
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 掉转文字和勾选框位置
|
|
31
|
-
*/
|
|
32
|
-
reverse?: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface CheckboxState {
|
|
35
|
-
visible: boolean;
|
|
36
|
-
}
|
|
37
|
-
declare class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
38
|
-
static defaultProps: {
|
|
39
|
-
size: number;
|
|
40
|
-
disabled: boolean;
|
|
41
|
-
defaultChecked: boolean;
|
|
42
|
-
reverse: boolean;
|
|
43
|
-
};
|
|
44
|
-
constructor(props: any);
|
|
45
|
-
static getDerivedStateFromProps(nextProps: CheckboxProps, prevState: CheckboxState): {
|
|
46
|
-
visible: boolean;
|
|
47
|
-
};
|
|
48
|
-
onVisibleChange: () => void;
|
|
49
|
-
renderBox: () => JSX.Element;
|
|
50
|
-
render(): JSX.Element;
|
|
51
|
-
}
|
|
52
|
-
export default Checkbox;
|
|
1
|
+
export type { CheckboxProps } from './Checkbox';
|
|
2
|
+
export { default as Checkbox } from './Checkbox';
|
|
3
|
+
export type { CheckboxGroupProps, CheckboxGroupOptionItem } from './CheckboxGroup';
|
|
4
|
+
export { default as CheckboxGroup } from './CheckboxGroup';
|
package/esm/checkbox/index.js
CHANGED
|
@@ -1,114 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 from 'react';
|
|
24
|
-
import classNames from 'classnames';
|
|
25
|
-
var cls = 'ab-checkbox';
|
|
26
|
-
var Checkbox = /** @class */function (_super) {
|
|
27
|
-
__extends(Checkbox, _super);
|
|
28
|
-
function Checkbox(props) {
|
|
29
|
-
var _this = _super.call(this, props) || this;
|
|
30
|
-
_this.onVisibleChange = function () {
|
|
31
|
-
var _a = _this.props,
|
|
32
|
-
disabled = _a.disabled,
|
|
33
|
-
onChange = _a.onChange,
|
|
34
|
-
name = _a.name;
|
|
35
|
-
if (disabled) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
var visible = !_this.state.visible;
|
|
39
|
-
if (!('checked' in _this.props)) {
|
|
40
|
-
_this.setState({
|
|
41
|
-
visible: visible
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
onChange(visible, name);
|
|
45
|
-
};
|
|
46
|
-
_this.renderBox = function () {
|
|
47
|
-
var _a;
|
|
48
|
-
var _b = _this.props,
|
|
49
|
-
className = _b.className,
|
|
50
|
-
disabled = _b.disabled,
|
|
51
|
-
size = _b.size;
|
|
52
|
-
var visible = _this.state.visible;
|
|
53
|
-
var innerStyle = {
|
|
54
|
-
width: "".concat(size, "px"),
|
|
55
|
-
height: "".concat(size, "px")
|
|
56
|
-
};
|
|
57
|
-
var iconStyle = {
|
|
58
|
-
width: "".concat(size * 6 / 16, "px"),
|
|
59
|
-
height: "".concat(size * 10 / 16, "px")
|
|
60
|
-
};
|
|
61
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
62
|
-
className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-checked")] = visible, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
63
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
64
|
-
className: "".concat(cls, "-input"),
|
|
65
|
-
type: "checkbox",
|
|
66
|
-
onChange: _this.onVisibleChange
|
|
67
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
68
|
-
className: "".concat(cls, "-inner"),
|
|
69
|
-
style: innerStyle
|
|
70
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
71
|
-
className: "".concat(cls, "-icon"),
|
|
72
|
-
style: iconStyle
|
|
73
|
-
})));
|
|
74
|
-
};
|
|
75
|
-
_this.state = {
|
|
76
|
-
visible: props.checked || props.defaultChecked
|
|
77
|
-
};
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
Checkbox.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
81
|
-
// 如果父级传了 checked 则更新 state
|
|
82
|
-
if ('checked' in nextProps && nextProps.checked !== prevState.visible) {
|
|
83
|
-
return {
|
|
84
|
-
visible: nextProps.checked
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
};
|
|
89
|
-
Checkbox.prototype.render = function () {
|
|
90
|
-
var _a;
|
|
91
|
-
var _b = this.props,
|
|
92
|
-
className = _b.className,
|
|
93
|
-
disabled = _b.disabled,
|
|
94
|
-
children = _b.children,
|
|
95
|
-
reverse = _b.reverse;
|
|
96
|
-
// 只渲染复选框
|
|
97
|
-
if (!children) {
|
|
98
|
-
return this.renderBox();
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/React.createElement("label", {
|
|
101
|
-
className: classNames("".concat(cls, "-wrap"), className, (_a = {}, _a["".concat(cls, "-reverse")] = reverse, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
102
|
-
}, this.renderBox(), children ? /*#__PURE__*/React.createElement("span", {
|
|
103
|
-
className: "".concat(cls, "-content")
|
|
104
|
-
}, children) : null);
|
|
105
|
-
};
|
|
106
|
-
Checkbox.defaultProps = {
|
|
107
|
-
size: 16,
|
|
108
|
-
disabled: false,
|
|
109
|
-
defaultChecked: false,
|
|
110
|
-
reverse: false
|
|
111
|
-
};
|
|
112
|
-
return Checkbox;
|
|
113
|
-
}(React.Component);
|
|
114
|
-
export default Checkbox;
|
|
1
|
+
export { default as Checkbox } from './Checkbox';
|
|
2
|
+
export { default as CheckboxGroup } from './CheckboxGroup';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-checkbox{display:inline-block;position:relative;font-size:0;cursor:pointer}.ab-checkbox-input{position:absolute;opacity:0;margin:0;padding:0;width:100%;height:100%;cursor:pointer;z-index:2}.ab-checkbox-inner{display:inline-block;position:relative;width:.16rem;height:.16rem;transition:.3s;border:.02rem solid #b0b0b0;border-radius:.02rem;background-color:#fff}.ab-checkbox-icon{visibility:hidden;position:absolute;width:.06rem;height:.1rem;left:20%;top:40%;transform:rotate(45deg) scale(0) translate(-50%,-50%);transition:.2s;border:.02rem solid #e84040;border-top:none;border-left:none}.ab-checkbox.ab-checkbox-checked .ab-checkbox-icon{visibility:visible;transform:rotate(45deg) scale(1) translate(-50%,-50%)}.ab-checkbox.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-icon{border-color:#cecece}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-content{text-decoration:none}.ab-checkbox-wrap{display:inline-block;position:relative;cursor:pointer}.ab-checkbox-wrap .ab-checkbox{position:absolute;transform:translateY(-50%);top:50%;left:0}.ab-checkbox-wrap:hover .ab-checkbox-content{text-decoration:underline}.ab-checkbox-content{padding-left:.24rem;display:inline-block}.ab-checkbox-wrap.ab-checkbox-reverse .ab-checkbox{left:auto;right:0}.ab-checkbox-wrap.ab-checkbox-reverse .ab-checkbox-content{padding-left:0;padding-right:.24rem}.ab-checkbox-wrap.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox-wrap.ab-checkbox-disabled .ab-checkbox-content{text-decoration:none}
|
|
1
|
+
.ab-checkbox{display:inline-block;position:relative;font-size:0;cursor:pointer}.ab-checkbox-input{position:absolute;opacity:0;margin:0;padding:0;width:100%;height:100%;cursor:pointer;z-index:2}.ab-checkbox-white .ab-checkbox-icon{border-color:#e84040}.ab-checkbox-blue .ab-checkbox-icon{border-color:#fff}.ab-checkbox-blue .ab-checkbox-inner{transition:none}.ab-checkbox-blue.ab-checkbox-checked .ab-checkbox-inner{border:.01rem solid #0075ff;background-color:#0075ff}.ab-checkbox-inner{display:inline-block;position:relative;width:.16rem;height:.16rem;transition:.3s;border:.02rem solid #b0b0b0;border-radius:.02rem;background-color:#fff}.ab-checkbox-icon{visibility:hidden;position:absolute;width:.06rem;height:.1rem;left:20%;top:40%;transform:rotate(45deg) scale(0) translate(-50%,-50%);transition:.2s;border:.02rem solid #e84040;border-top:none;border-left:none}.ab-checkbox.ab-checkbox-checked .ab-checkbox-icon{visibility:visible;transform:rotate(45deg) scale(1) translate(-50%,-50%)}.ab-checkbox.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-icon{border-color:#cecece}.ab-checkbox.ab-checkbox-disabled .ab-checkbox-content{text-decoration:none}.ab-checkbox-wrap{display:inline-block;position:relative;cursor:pointer}.ab-checkbox-wrap .ab-checkbox{position:absolute;transform:translateY(-50%);top:50%;left:0}.ab-checkbox-wrap:hover .ab-checkbox-content{text-decoration:underline}.ab-checkbox-wrap:hover .ab-checkbox-blue+.ab-checkbox-content{text-decoration:none}.ab-checkbox-content{padding-left:.24rem;display:inline-block}.ab-checkbox-wrap.ab-checkbox-reverse .ab-checkbox{left:auto;right:0}.ab-checkbox-wrap.ab-checkbox-reverse .ab-checkbox-content{padding-left:0;padding-right:.24rem}.ab-checkbox-wrap.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox-wrap.ab-checkbox-disabled .ab-checkbox-content{text-decoration:none}.ab-checkbox-group{display:flex;flex-wrap:wrap}.ab-checkbox-group .ab-checkbox-wrap{margin-right:.15rem}
|
package/esm/ellipsis/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare type LessThan<N extends number, A extends any[] = []> = N extends A['length'] ? A[number] : LessThan<N, [...A, A['length']]>;
|
|
3
|
-
declare type NumericRange<F extends number, T extends number> = Exclude<T | LessThan<T>, LessThan<F>>;
|
|
4
|
-
export declare type EllipsisLinesType = NumericRange<1, 10>;
|
|
5
2
|
export interface EllipsisProps {
|
|
6
3
|
/**
|
|
7
4
|
* 需要显示的文本
|
|
@@ -18,11 +15,7 @@ export interface EllipsisProps {
|
|
|
18
15
|
/**
|
|
19
16
|
* 桌面端限制显示的行数,若不传值,则桌面端会不做行数限值,显示全
|
|
20
17
|
*/
|
|
21
|
-
lines?:
|
|
22
|
-
/**
|
|
23
|
-
* 移动端限制显示的行数,若不传值,则移动端会不做行数限值,显示全
|
|
24
|
-
*/
|
|
25
|
-
mobileLines?: EllipsisLinesType;
|
|
18
|
+
lines?: number;
|
|
26
19
|
/**
|
|
27
20
|
* title属性
|
|
28
21
|
*/
|
package/esm/ellipsis/index.js
CHANGED
|
@@ -15,34 +15,34 @@ import classNames from 'classnames';
|
|
|
15
15
|
import { isElement, isFragment } from 'react-is';
|
|
16
16
|
var cls = 'ab-ellipsis';
|
|
17
17
|
function Ellipsis(props) {
|
|
18
|
-
var _a, _b;
|
|
19
18
|
var children = props.children,
|
|
20
19
|
maxHeight = props.maxHeight,
|
|
21
20
|
className = props.className,
|
|
22
|
-
|
|
23
|
-
lines =
|
|
24
|
-
title = props.title
|
|
25
|
-
|
|
26
|
-
mobileLines = _d === void 0 ? 0 : _d;
|
|
27
|
-
var wrapCls = classNames(cls, className, (_a = {}, _a["".concat(cls, "-line").concat(lines)] = lines > 0, _a), (_b = {}, _b["".concat(cls, "-m-line").concat(mobileLines)] = mobileLines > 0, _b));
|
|
21
|
+
_a = props.lines,
|
|
22
|
+
lines = _a === void 0 ? 0 : _a,
|
|
23
|
+
title = props.title;
|
|
24
|
+
var wrapCls = classNames(cls, className);
|
|
28
25
|
var style = maxHeight ? {
|
|
29
26
|
maxHeight: maxHeight
|
|
30
27
|
} : null;
|
|
31
28
|
var titleParam = title ? {
|
|
32
29
|
title: title
|
|
33
30
|
} : null;
|
|
31
|
+
var lineStyle = lines > 0 ? {
|
|
32
|
+
'-webkit-line-clamp': "".concat(lines)
|
|
33
|
+
} : null;
|
|
34
34
|
// 当children是单个标签元素时(非文本元素),将直接在该标签上加上style, className,title属性
|
|
35
35
|
if (!isFragment(children) && isElement(children)) {
|
|
36
36
|
var child = children;
|
|
37
37
|
return /*#__PURE__*/React.cloneElement(child, __assign(__assign({}, titleParam), {
|
|
38
38
|
className: classNames(wrapCls, child.props.className),
|
|
39
|
-
style: __assign(__assign({}, style), child.props.style)
|
|
39
|
+
style: __assign(__assign(__assign({}, style), lineStyle), child.props.style)
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
return /*#__PURE__*/React.createElement("span", __assign({
|
|
43
43
|
className: wrapCls
|
|
44
44
|
}, titleParam, {
|
|
45
|
-
style: style
|
|
45
|
+
style: __assign(__assign({}, style), lineStyle)
|
|
46
46
|
}), children);
|
|
47
47
|
}
|
|
48
48
|
export default /*#__PURE__*/React.memo(Ellipsis);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-ellipsis{overflow:hidden;display:block;display:-webkit-box;-webkit-box-orient:vertical}
|
|
1
|
+
.ab-ellipsis{overflow:hidden;display:block;display:-webkit-box;-webkit-box-orient:vertical}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { AccordionProps } from './accordion';
|
|
2
2
|
export { default as Accordion } from './accordion';
|
|
3
|
-
export type { EllipsisProps
|
|
3
|
+
export type { EllipsisProps } from './ellipsis';
|
|
4
4
|
export { default as Ellipsis } from './ellipsis';
|
|
5
5
|
export type { AffixProps, GetFixedStateParams } from './affix';
|
|
6
6
|
export { default as Affix } from './affix';
|
|
@@ -34,8 +34,8 @@ export type { LazyImageProps } from './lazy-image';
|
|
|
34
34
|
export { default as LazyImage } from './lazy-image';
|
|
35
35
|
export type { LinkItemProps, LinkListProps, LinkItemSubInfoProps } from './link-list';
|
|
36
36
|
export { default as LinkList } from './link-list';
|
|
37
|
-
export type { CheckboxProps } from './checkbox';
|
|
38
|
-
export {
|
|
37
|
+
export type { CheckboxProps, CheckboxGroupProps } from './checkbox';
|
|
38
|
+
export { Checkbox, CheckboxGroup, CheckboxGroupOptionItem } from './checkbox';
|
|
39
39
|
export type { ScriptAttributes, ScriptProps } from './script';
|
|
40
40
|
export { default as Script } from './script';
|
|
41
41
|
export type { MessageProps, MessageConfig, MessageResult } from './message';
|
|
@@ -56,3 +56,6 @@ export type { LoadingIconProps } from './loading-icon';
|
|
|
56
56
|
export { default as LoadingIcon } from './loading-icon';
|
|
57
57
|
export type { TriggerProps, TriggerType, TriggerPlacement, ArrowStyleProps } from './trigger';
|
|
58
58
|
export { default as Trigger } from './trigger';
|
|
59
|
+
export { composeRef, supportRef, fillRef } from './trigger/ref';
|
|
60
|
+
export type { RadioProps, RadioGroupProps, RadioValue, RadioOptionItem } from './radio';
|
|
61
|
+
export { Radio, RadioGroup } from './radio';
|
package/esm/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { Input, TextArea } from './input';
|
|
|
16
16
|
export { default as InputNumber } from './input-number';
|
|
17
17
|
export { default as LazyImage } from './lazy-image';
|
|
18
18
|
export { default as LinkList } from './link-list';
|
|
19
|
-
export {
|
|
19
|
+
export { Checkbox, CheckboxGroup } from './checkbox';
|
|
20
20
|
export { default as Script } from './script';
|
|
21
21
|
export { default as message, Message } from './message';
|
|
22
22
|
export { default as Table } from './table';
|
|
@@ -26,4 +26,6 @@ export { default as Loading } from './loading';
|
|
|
26
26
|
export { default as LoadingContainer } from './loading-container';
|
|
27
27
|
export { default as LoadingBar } from './loading-bar';
|
|
28
28
|
export { default as LoadingIcon } from './loading-icon';
|
|
29
|
-
export { default as Trigger } from './trigger';
|
|
29
|
+
export { default as Trigger } from './trigger';
|
|
30
|
+
export { composeRef, supportRef, fillRef } from './trigger/ref';
|
|
31
|
+
export { Radio, RadioGroup } from './radio';
|
package/esm/input/Input.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AdornProps } from './Adorn';
|
|
3
3
|
export declare type InputValue = string | File | undefined;
|
|
4
|
-
export interface InputProps<T = InputValue> extends Omit<AdornProps, 'prefixCls' | 'children' | 'onBlur' | 'onFocus'>, Pick<React.InputHTMLAttributes<any>, 'placeholder' | 'style' | 'maxLength' | 'type' | 'accept'> {
|
|
4
|
+
export interface InputProps<T = InputValue> extends Omit<AdornProps, 'prefixCls' | 'children' | 'onBlur' | 'onFocus'>, Pick<React.InputHTMLAttributes<any>, 'placeholder' | 'style' | 'maxLength' | 'type' | 'accept' | 'title' | 'aria-label' | 'onKeyUp'> {
|
|
5
5
|
/**
|
|
6
6
|
* 输入框默认值,用于非受控组件,配合ref使用
|
|
7
7
|
*/
|
|
@@ -34,6 +34,11 @@ export interface InputProps<T = InputValue> extends Omit<AdornProps, 'prefixCls'
|
|
|
34
34
|
* 用户触发keydown时的回调,主要用于键盘监听
|
|
35
35
|
*/
|
|
36
36
|
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, name?: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 在网络慢时,组件已经渲染js文件还未加载,用户此时修改input框会不触发onChange事件
|
|
39
|
+
* 需要在组件加载后检测输入框内容,触发一次onChange
|
|
40
|
+
*/
|
|
41
|
+
checkValueOnMounted?: boolean;
|
|
37
42
|
}
|
|
38
43
|
interface InputStates {
|
|
39
44
|
value: string | undefined;
|
|
@@ -50,12 +55,19 @@ export declare class InputNotRef extends React.Component<InputPropsWithRef, Inpu
|
|
|
50
55
|
static defaultProps: {
|
|
51
56
|
defaultValue: string;
|
|
52
57
|
type: string;
|
|
58
|
+
checkValueOnMounted: boolean;
|
|
53
59
|
};
|
|
54
60
|
constructor(props: InputPropsWithRef);
|
|
55
61
|
static getDerivedStateFromProps(nextProps: InputPropsWithRef, prevStates: InputStates): InputStates;
|
|
56
62
|
componentDidMount(): void;
|
|
57
63
|
isFileUpload: () => boolean;
|
|
58
64
|
getFileInfo: (element: HTMLInputElement) => File;
|
|
65
|
+
/**
|
|
66
|
+
* 在触发了onChange的前提下,如果当前为失焦状态,则触发一次onBlur
|
|
67
|
+
* @param value
|
|
68
|
+
*/
|
|
69
|
+
onBlurOnMounted: (value: any) => void;
|
|
70
|
+
checkCurrentValue: () => void;
|
|
59
71
|
/**
|
|
60
72
|
* 修改value值的回调
|
|
61
73
|
* @param ev
|