@autobest-ui/components 2.9.0 → 2.9.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/checkbox/Checkbox.d.ts +60 -0
- package/esm/checkbox/Checkbox.js +120 -0
- package/esm/checkbox/CheckboxGroup.d.ts +15 -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 -6
- package/esm/ellipsis/index.js +9 -9
- package/esm/ellipsis/style/index.css +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/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.js +1 -0
- package/esm/table/style/index.css +1 -1
- package/lib/checkbox/Checkbox.d.ts +60 -0
- package/lib/checkbox/Checkbox.js +128 -0
- package/lib/checkbox/CheckboxGroup.d.ts +15 -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 -6
- package/lib/ellipsis/index.js +9 -9
- package/lib/ellipsis/style/index.css +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +8 -2
- 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.js +1 -0
- package/lib/table/style/index.css +1 -1
- package/package.json +2 -2
package/esm/table/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:1s linear infinite reverse loading}@keyframes loading{0%{transform:rotate(0)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}.ab-loading-container{position:relative}.ab-loading-container-active{user-select:none;pointer-events:none}.ab-loading-container-icon-box{position:absolute;background-color:rgba(255,255,255,.7);top:0;left:0;z-index:4;display:block;width:100%;height:100%}.ab-loading-container-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.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}.ab-table{overflow-x:auto}.ab-table-table{border-spacing:0;width:100%;table-layout:fixed;border-collapse:collapse}.ab-table-header{overflow:hidden}.ab-table-body{overflow:auto}.ab-table-checkbox{width:.32rem;text-align:center}.ab-table-checkbox-col{width:.32rem}.ab-table-point{cursor:pointer}.ab-table-title{display:flex;align-items:center;text-align:left}.ab-table-arrow{font-size:.16rem;color:#fff;padding:0 .05rem}
|
|
1
|
+
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:1s linear infinite reverse loading}@keyframes loading{0%{transform:rotate(0)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}.ab-loading-container{position:relative}.ab-loading-container-active{user-select:none;pointer-events:none}.ab-loading-container-icon-box{position:absolute;background-color:rgba(255,255,255,.7);top:0;left:0;z-index:4;display:block;width:100%;height:100%}.ab-loading-container-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.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}.ab-table{overflow-x:auto}.ab-table-table{border-spacing:0;width:100%;table-layout:fixed;border-collapse:collapse}.ab-table-header{overflow:hidden}.ab-table-body{overflow:auto}.ab-table-checkbox{width:.32rem;text-align:center}.ab-table-checkbox-col{width:.32rem}.ab-table-point{cursor:pointer}.ab-table-title{display:flex;align-items:center;text-align:left}.ab-table-arrow{font-size:.16rem;color:#fff;padding:0 .05rem}
|
|
@@ -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,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
11
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
12
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
13
|
+
__proto__: []
|
|
14
|
+
} instanceof Array && function (d, b) {
|
|
15
|
+
d.__proto__ = b;
|
|
16
|
+
} || function (d, b) {
|
|
17
|
+
for (var p in b) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return _extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
return function (d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
25
|
+
_extendStatics(d, b);
|
|
26
|
+
function __() {
|
|
27
|
+
this.constructor = d;
|
|
28
|
+
}
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
};
|
|
31
|
+
}();
|
|
32
|
+
var cls = 'ab-checkbox';
|
|
33
|
+
var Checkbox = /** @class */function (_super) {
|
|
34
|
+
__extends(Checkbox, _super);
|
|
35
|
+
function Checkbox(props) {
|
|
36
|
+
var _this = _super.call(this, props) || this;
|
|
37
|
+
_this.onVisibleChange = function () {
|
|
38
|
+
var _a = _this.props,
|
|
39
|
+
disabled = _a.disabled,
|
|
40
|
+
onChange = _a.onChange,
|
|
41
|
+
name = _a.name;
|
|
42
|
+
if (disabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var visible = !_this.state.visible;
|
|
46
|
+
if (!('checked' in _this.props)) {
|
|
47
|
+
_this.setState({
|
|
48
|
+
visible: visible
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
onChange(visible, name);
|
|
52
|
+
};
|
|
53
|
+
_this.renderBox = function () {
|
|
54
|
+
var _a;
|
|
55
|
+
var _b = _this.props,
|
|
56
|
+
className = _b.className,
|
|
57
|
+
disabled = _b.disabled,
|
|
58
|
+
size = _b.size,
|
|
59
|
+
theme = _b.theme;
|
|
60
|
+
var visible = _this.state.visible;
|
|
61
|
+
var innerStyle = {
|
|
62
|
+
width: "".concat(size, "px"),
|
|
63
|
+
height: "".concat(size, "px")
|
|
64
|
+
};
|
|
65
|
+
var iconStyle = {
|
|
66
|
+
width: "".concat(size * 6 / 16, "px"),
|
|
67
|
+
height: "".concat(size * 10 / 16, "px")
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
70
|
+
className: (0, _classnames.default)(cls, className, "".concat(cls, "-").concat(theme), (_a = {}, _a["".concat(cls, "-checked")] = visible, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
72
|
+
className: "".concat(cls, "-input"),
|
|
73
|
+
type: "checkbox",
|
|
74
|
+
onChange: _this.onVisibleChange
|
|
75
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
76
|
+
className: "".concat(cls, "-inner"),
|
|
77
|
+
style: innerStyle
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
79
|
+
className: "".concat(cls, "-icon"),
|
|
80
|
+
style: iconStyle
|
|
81
|
+
})));
|
|
82
|
+
};
|
|
83
|
+
_this.onClick = function (e) {
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
};
|
|
86
|
+
_this.state = {
|
|
87
|
+
visible: props.checked || props.defaultChecked
|
|
88
|
+
};
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
Checkbox.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
92
|
+
// 如果父级传了 checked 则更新 state
|
|
93
|
+
if ('checked' in nextProps && nextProps.checked !== prevState.visible) {
|
|
94
|
+
return {
|
|
95
|
+
visible: nextProps.checked
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
};
|
|
100
|
+
Checkbox.prototype.render = function () {
|
|
101
|
+
var _a;
|
|
102
|
+
var _b = this.props,
|
|
103
|
+
className = _b.className,
|
|
104
|
+
disabled = _b.disabled,
|
|
105
|
+
children = _b.children,
|
|
106
|
+
reverse = _b.reverse;
|
|
107
|
+
// 只渲染复选框
|
|
108
|
+
if (!children) {
|
|
109
|
+
return this.renderBox();
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement("label", {
|
|
112
|
+
onClick: this.onClick,
|
|
113
|
+
className: (0, _classnames.default)("".concat(cls, "-wrap"), className, (_a = {}, _a["".concat(cls, "-reverse")] = reverse, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
114
|
+
}, this.renderBox(), children ? /*#__PURE__*/_react.default.createElement("span", {
|
|
115
|
+
className: "".concat(cls, "-content")
|
|
116
|
+
}, children) : null);
|
|
117
|
+
};
|
|
118
|
+
Checkbox.defaultProps = {
|
|
119
|
+
size: 16,
|
|
120
|
+
disabled: false,
|
|
121
|
+
defaultChecked: false,
|
|
122
|
+
reverse: false,
|
|
123
|
+
theme: 'white'
|
|
124
|
+
};
|
|
125
|
+
return Checkbox;
|
|
126
|
+
}(_react.default.Component);
|
|
127
|
+
var _default = Checkbox;
|
|
128
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
checked: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckboxGroupProps extends CommonCheckboxProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
onChange: (options: CheckboxGroupOptionItem[], name?: string) => void;
|
|
12
|
+
options: CheckboxGroupOptionItem[];
|
|
13
|
+
}
|
|
14
|
+
declare const CheckboxGroup: FC<CheckboxGroupProps>;
|
|
15
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _utils = require("@autobest-ui/utils");
|
|
11
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
12
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
13
|
+
__assign = Object.assign || function (t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
return __assign.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
function getCheckboxProp(checkboxProp, checkboxGroupProp) {
|
|
25
|
+
return (0, _utils.isUndef)(checkboxProp) ? checkboxGroupProp : checkboxProp;
|
|
26
|
+
}
|
|
27
|
+
var cls = 'ab-checkbox';
|
|
28
|
+
var CheckboxGroup = function CheckboxGroup(_a) {
|
|
29
|
+
var onChange = _a.onChange,
|
|
30
|
+
groupName = _a.name,
|
|
31
|
+
options = _a.options,
|
|
32
|
+
className = _a.className,
|
|
33
|
+
disabled = _a.disabled,
|
|
34
|
+
reverse = _a.reverse,
|
|
35
|
+
theme = _a.theme;
|
|
36
|
+
if ((0, _utils.isEmptyArray)(options)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
var onCheckboxChange = function onCheckboxChange(checked, name) {
|
|
40
|
+
var newOptions = options.map(function (item) {
|
|
41
|
+
if (item.name === name) {
|
|
42
|
+
return __assign(__assign({}, item), {
|
|
43
|
+
checked: checked
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return item;
|
|
47
|
+
});
|
|
48
|
+
onChange(newOptions, groupName);
|
|
49
|
+
};
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
51
|
+
className: (0, _classnames.default)("".concat(cls, "-group"), className)
|
|
52
|
+
}, options.map(function (item) {
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
54
|
+
key: item.name,
|
|
55
|
+
name: item.name,
|
|
56
|
+
reverse: getCheckboxProp(item.reverse, reverse),
|
|
57
|
+
theme: getCheckboxProp(item.theme, theme),
|
|
58
|
+
disabled: getCheckboxProp(item.disabled, disabled),
|
|
59
|
+
checked: item.checked,
|
|
60
|
+
onChange: onCheckboxChange
|
|
61
|
+
}, item.name);
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
var _default = CheckboxGroup;
|
|
65
|
+
exports.default = _default;
|
package/lib/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/lib/checkbox/index.js
CHANGED
|
@@ -4,119 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _extendStatics = function extendStatics(d, b) {
|
|
12
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
13
|
-
__proto__: []
|
|
14
|
-
} instanceof Array && function (d, b) {
|
|
15
|
-
d.__proto__ = b;
|
|
16
|
-
} || function (d, b) {
|
|
17
|
-
for (var p in b) {
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
return _extendStatics(d, b);
|
|
22
|
-
};
|
|
23
|
-
return function (d, b) {
|
|
24
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
25
|
-
_extendStatics(d, b);
|
|
26
|
-
function __() {
|
|
27
|
-
this.constructor = d;
|
|
28
|
-
}
|
|
29
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
-
};
|
|
31
|
-
}();
|
|
32
|
-
var cls = 'ab-checkbox';
|
|
33
|
-
var Checkbox = /** @class */function (_super) {
|
|
34
|
-
__extends(Checkbox, _super);
|
|
35
|
-
function Checkbox(props) {
|
|
36
|
-
var _this = _super.call(this, props) || this;
|
|
37
|
-
_this.onVisibleChange = function () {
|
|
38
|
-
var _a = _this.props,
|
|
39
|
-
disabled = _a.disabled,
|
|
40
|
-
onChange = _a.onChange,
|
|
41
|
-
name = _a.name;
|
|
42
|
-
if (disabled) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
var visible = !_this.state.visible;
|
|
46
|
-
if (!('checked' in _this.props)) {
|
|
47
|
-
_this.setState({
|
|
48
|
-
visible: visible
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
onChange(visible, name);
|
|
52
|
-
};
|
|
53
|
-
_this.renderBox = function () {
|
|
54
|
-
var _a;
|
|
55
|
-
var _b = _this.props,
|
|
56
|
-
className = _b.className,
|
|
57
|
-
disabled = _b.disabled,
|
|
58
|
-
size = _b.size;
|
|
59
|
-
var visible = _this.state.visible;
|
|
60
|
-
var innerStyle = {
|
|
61
|
-
width: "".concat(size, "px"),
|
|
62
|
-
height: "".concat(size, "px")
|
|
63
|
-
};
|
|
64
|
-
var iconStyle = {
|
|
65
|
-
width: "".concat(size * 6 / 16, "px"),
|
|
66
|
-
height: "".concat(size * 10 / 16, "px")
|
|
67
|
-
};
|
|
68
|
-
return /*#__PURE__*/_react.default.createElement("span", {
|
|
69
|
-
className: (0, _classnames.default)(cls, className, (_a = {}, _a["".concat(cls, "-checked")] = visible, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
70
|
-
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
71
|
-
className: "".concat(cls, "-input"),
|
|
72
|
-
type: "checkbox",
|
|
73
|
-
onChange: _this.onVisibleChange
|
|
74
|
-
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
75
|
-
className: "".concat(cls, "-inner"),
|
|
76
|
-
style: innerStyle
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
78
|
-
className: "".concat(cls, "-icon"),
|
|
79
|
-
style: iconStyle
|
|
80
|
-
})));
|
|
81
|
-
};
|
|
82
|
-
_this.state = {
|
|
83
|
-
visible: props.checked || props.defaultChecked
|
|
84
|
-
};
|
|
85
|
-
return _this;
|
|
7
|
+
Object.defineProperty(exports, "Checkbox", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _Checkbox.default;
|
|
86
11
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
Checkbox.prototype.render = function () {
|
|
97
|
-
var _a;
|
|
98
|
-
var _b = this.props,
|
|
99
|
-
className = _b.className,
|
|
100
|
-
disabled = _b.disabled,
|
|
101
|
-
children = _b.children,
|
|
102
|
-
reverse = _b.reverse;
|
|
103
|
-
// 只渲染复选框
|
|
104
|
-
if (!children) {
|
|
105
|
-
return this.renderBox();
|
|
106
|
-
}
|
|
107
|
-
return /*#__PURE__*/_react.default.createElement("label", {
|
|
108
|
-
className: (0, _classnames.default)("".concat(cls, "-wrap"), className, (_a = {}, _a["".concat(cls, "-reverse")] = reverse, _a["".concat(cls, "-disabled")] = disabled, _a))
|
|
109
|
-
}, this.renderBox(), children ? /*#__PURE__*/_react.default.createElement("span", {
|
|
110
|
-
className: "".concat(cls, "-content")
|
|
111
|
-
}, children) : null);
|
|
112
|
-
};
|
|
113
|
-
Checkbox.defaultProps = {
|
|
114
|
-
size: 16,
|
|
115
|
-
disabled: false,
|
|
116
|
-
defaultChecked: false,
|
|
117
|
-
reverse: false
|
|
118
|
-
};
|
|
119
|
-
return Checkbox;
|
|
120
|
-
}(_react.default.Component);
|
|
121
|
-
var _default = Checkbox;
|
|
122
|
-
exports.default = _default;
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "CheckboxGroup", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _CheckboxGroup.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
20
|
+
var _CheckboxGroup = _interopRequireDefault(require("./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/lib/ellipsis/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare type EllipsisLinesType = 1 | 2 | 3 | 4 | 5;
|
|
3
2
|
export interface EllipsisProps {
|
|
4
3
|
/**
|
|
5
4
|
* 需要显示的文本
|
|
@@ -16,11 +15,7 @@ export interface EllipsisProps {
|
|
|
16
15
|
/**
|
|
17
16
|
* 桌面端限制显示的行数,若不传值,则桌面端会不做行数限值,显示全
|
|
18
17
|
*/
|
|
19
|
-
lines?:
|
|
20
|
-
/**
|
|
21
|
-
* 移动端限制显示的行数,若不传值,则移动端会不做行数限值,显示全
|
|
22
|
-
*/
|
|
23
|
-
mobileLines?: EllipsisLinesType;
|
|
18
|
+
lines?: number;
|
|
24
19
|
/**
|
|
25
20
|
* title属性
|
|
26
21
|
*/
|
package/lib/ellipsis/index.js
CHANGED
|
@@ -22,34 +22,34 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
22
22
|
};
|
|
23
23
|
var cls = 'ab-ellipsis';
|
|
24
24
|
function Ellipsis(props) {
|
|
25
|
-
var _a, _b;
|
|
26
25
|
var children = props.children,
|
|
27
26
|
maxHeight = props.maxHeight,
|
|
28
27
|
className = props.className,
|
|
29
|
-
|
|
30
|
-
lines =
|
|
31
|
-
title = props.title
|
|
32
|
-
|
|
33
|
-
mobileLines = _d === void 0 ? 0 : _d;
|
|
34
|
-
var wrapCls = (0, _classnames.default)(cls, className, (_a = {}, _a["".concat(cls, "-line").concat(lines)] = lines > 0, _a), (_b = {}, _b["".concat(cls, "-m-line").concat(mobileLines)] = mobileLines > 0, _b));
|
|
28
|
+
_a = props.lines,
|
|
29
|
+
lines = _a === void 0 ? 0 : _a,
|
|
30
|
+
title = props.title;
|
|
31
|
+
var wrapCls = (0, _classnames.default)(cls, className);
|
|
35
32
|
var style = maxHeight ? {
|
|
36
33
|
maxHeight: maxHeight
|
|
37
34
|
} : null;
|
|
38
35
|
var titleParam = title ? {
|
|
39
36
|
title: title
|
|
40
37
|
} : null;
|
|
38
|
+
var lineStyle = lines > 0 ? {
|
|
39
|
+
'-webkit-line-clamp': "".concat(lines)
|
|
40
|
+
} : null;
|
|
41
41
|
// 当children是单个标签元素时(非文本元素),将直接在该标签上加上style, className,title属性
|
|
42
42
|
if (!(0, _reactIs.isFragment)(children) && (0, _reactIs.isElement)(children)) {
|
|
43
43
|
var child = children;
|
|
44
44
|
return /*#__PURE__*/_react.default.cloneElement(child, __assign(__assign({}, titleParam), {
|
|
45
45
|
className: (0, _classnames.default)(wrapCls, child.props.className),
|
|
46
|
-
style: __assign(__assign({}, style), child.props.style)
|
|
46
|
+
style: __assign(__assign(__assign({}, style), lineStyle), child.props.style)
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
49
|
return /*#__PURE__*/_react.default.createElement("span", __assign({
|
|
50
50
|
className: wrapCls
|
|
51
51
|
}, titleParam, {
|
|
52
|
-
style: style
|
|
52
|
+
style: __assign(__assign({}, style), lineStyle)
|
|
53
53
|
}), children);
|
|
54
54
|
}
|
|
55
55
|
var _default = /*#__PURE__*/_react.default.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/lib/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';
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,13 @@ Object.defineProperty(exports, "Carousel", {
|
|
|
26
26
|
Object.defineProperty(exports, "Checkbox", {
|
|
27
27
|
enumerable: true,
|
|
28
28
|
get: function get() {
|
|
29
|
-
return _checkbox.
|
|
29
|
+
return _checkbox.Checkbox;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "CheckboxGroup", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _checkbox.CheckboxGroup;
|
|
30
36
|
}
|
|
31
37
|
});
|
|
32
38
|
Object.defineProperty(exports, "Collapse", {
|
|
@@ -227,7 +233,7 @@ var _input = require("./input");
|
|
|
227
233
|
var _inputNumber = _interopRequireDefault(require("./input-number"));
|
|
228
234
|
var _lazyImage = _interopRequireDefault(require("./lazy-image"));
|
|
229
235
|
var _linkList = _interopRequireDefault(require("./link-list"));
|
|
230
|
-
var _checkbox =
|
|
236
|
+
var _checkbox = require("./checkbox");
|
|
231
237
|
var _script = _interopRequireDefault(require("./script"));
|
|
232
238
|
var _message = _interopRequireWildcard(require("./message"));
|
|
233
239
|
var _table = _interopRequireDefault(require("./table"));
|