@autobest-ui/components 2.11.3 → 2.12.1
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 +8 -31
- package/esm/checkbox/Checkbox.js +51 -113
- package/esm/checkbox/CheckboxGroup.d.ts +1 -1
- package/esm/checkbox/CheckboxGroup.js +3 -3
- package/esm/checkbox/style/index.css +1 -1
- package/esm/input-phone/index.d.ts +0 -1
- package/esm/input-phone/index.js +14 -6
- package/esm/move/index.d.ts +10 -0
- package/esm/move/index.js +12 -7
- package/esm/radio/Radio.d.ts +1 -1
- package/esm/radio/Radio.js +37 -9
- package/esm/radio/RadioGroup.d.ts +2 -2
- package/esm/radio/RadioGroup.js +7 -7
- package/esm/radio/context.d.ts +2 -2
- package/esm/radio/context.js +1 -1
- package/esm/radio/index.d.ts +1 -1
- package/esm/radio/style/index.css +1 -1
- package/esm/radio/{interface.d.ts → type.d.ts} +4 -3
- package/esm/style.css +1 -1
- package/esm/table/body/CheckIcon.js +1 -0
- package/esm/table/header/CheckIcon.js +1 -0
- package/esm/table/index.d.ts +0 -4
- package/esm/table/style/index.css +1 -1
- package/lib/checkbox/Checkbox.d.ts +8 -31
- package/lib/checkbox/Checkbox.js +54 -113
- package/lib/checkbox/CheckboxGroup.d.ts +1 -1
- package/lib/checkbox/CheckboxGroup.js +3 -3
- package/lib/checkbox/style/index.css +1 -1
- package/lib/input-phone/index.d.ts +0 -1
- package/lib/input-phone/index.js +14 -6
- package/lib/move/index.d.ts +10 -0
- package/lib/move/index.js +12 -7
- package/lib/radio/Radio.d.ts +1 -1
- package/lib/radio/Radio.js +37 -9
- package/lib/radio/RadioGroup.d.ts +2 -2
- package/lib/radio/RadioGroup.js +7 -7
- package/lib/radio/context.d.ts +2 -2
- package/lib/radio/context.js +3 -5
- package/lib/radio/index.d.ts +1 -1
- package/lib/radio/style/index.css +1 -1
- package/lib/radio/{interface.d.ts → type.d.ts} +4 -3
- package/lib/style.css +1 -1
- package/lib/table/body/CheckIcon.js +1 -0
- package/lib/table/header/CheckIcon.js +1 -0
- package/lib/table/index.d.ts +0 -4
- package/lib/table/style/index.css +1 -1
- package/package.json +2 -2
- /package/esm/radio/{interface.js → type.js} +0 -0
- /package/lib/radio/{interface.js → type.js} +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactChild } from 'react';
|
|
2
2
|
export interface CheckboxProps {
|
|
3
|
-
children?:
|
|
3
|
+
children?: ReactChild | ReactChild[];
|
|
4
|
+
/**
|
|
5
|
+
* 勾选框尺寸,单位px
|
|
6
|
+
*/
|
|
7
|
+
size?: number;
|
|
4
8
|
/**
|
|
5
9
|
* checked变化的回调函数, 参数 checked: boolean
|
|
6
10
|
*/
|
|
7
|
-
onChange
|
|
11
|
+
onChange?: (checked: boolean, name?: string | number) => void;
|
|
8
12
|
/**
|
|
9
13
|
* 是否选中
|
|
10
14
|
*/
|
|
@@ -18,18 +22,10 @@ export interface CheckboxProps {
|
|
|
18
22
|
*/
|
|
19
23
|
className?: string;
|
|
20
24
|
name?: string | number;
|
|
21
|
-
/**
|
|
22
|
-
* 勾选框尺寸,单位px
|
|
23
|
-
*/
|
|
24
|
-
size?: number;
|
|
25
25
|
/**
|
|
26
26
|
* 是否禁用
|
|
27
27
|
*/
|
|
28
28
|
disabled?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 掉转文字和勾选框位置
|
|
31
|
-
*/
|
|
32
|
-
reverse?: boolean;
|
|
33
29
|
/**
|
|
34
30
|
* 主题样式
|
|
35
31
|
* white为选中时白底红箭头
|
|
@@ -37,24 +33,5 @@ export interface CheckboxProps {
|
|
|
37
33
|
*/
|
|
38
34
|
theme?: 'white' | 'blue';
|
|
39
35
|
}
|
|
40
|
-
|
|
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
|
-
}
|
|
36
|
+
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
60
37
|
export default Checkbox;
|
package/esm/checkbox/Checkbox.js
CHANGED
|
@@ -1,120 +1,58 @@
|
|
|
1
|
-
|
|
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';
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from 'react';
|
|
24
2
|
import classNames from 'classnames';
|
|
3
|
+
import { isUndef } from '@autobest-ui/utils';
|
|
25
4
|
var cls = 'ab-checkbox';
|
|
26
|
-
var Checkbox =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
};
|
|
5
|
+
var Checkbox = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
6
|
+
var _b;
|
|
7
|
+
var className = _a.className,
|
|
8
|
+
name = _a.name,
|
|
9
|
+
onChange = _a.onChange,
|
|
10
|
+
propsChecked = _a.checked,
|
|
11
|
+
defaultChecked = _a.defaultChecked,
|
|
12
|
+
disabled = _a.disabled,
|
|
13
|
+
children = _a.children,
|
|
14
|
+
theme = _a.theme,
|
|
15
|
+
size = _a.size;
|
|
16
|
+
var _c = useState(defaultChecked),
|
|
17
|
+
checked = _c[0],
|
|
18
|
+
setChecked = _c[1];
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
if (!isUndef(propsChecked) && propsChecked !== checked) {
|
|
21
|
+
setChecked(propsChecked);
|
|
90
22
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
className = _b.className,
|
|
97
|
-
disabled = _b.disabled,
|
|
98
|
-
children = _b.children,
|
|
99
|
-
reverse = _b.reverse;
|
|
100
|
-
// 只渲染复选框
|
|
101
|
-
if (!children) {
|
|
102
|
-
return this.renderBox();
|
|
23
|
+
}, [propsChecked, checked]);
|
|
24
|
+
var onCheckboxChange = function onCheckboxChange(e) {
|
|
25
|
+
setChecked(e.target.checked);
|
|
26
|
+
if (onChange) {
|
|
27
|
+
onChange(e.target.checked, name);
|
|
103
28
|
}
|
|
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
29
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
disabled: false,
|
|
114
|
-
defaultChecked: false,
|
|
115
|
-
reverse: false,
|
|
116
|
-
theme: 'white'
|
|
30
|
+
var onWrapClick = function onWrapClick(e) {
|
|
31
|
+
e.stopPropagation();
|
|
117
32
|
};
|
|
118
|
-
return
|
|
119
|
-
}(
|
|
33
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
34
|
+
className: classNames(cls, "".concat(cls, "-").concat(theme), (_b = {}, _b["".concat(cls, "-checked")] = checked, _b["".concat(cls, "-disabled")] = disabled, _b), className),
|
|
35
|
+
onClick: onWrapClick
|
|
36
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: "".concat(cls, "-input"),
|
|
39
|
+
type: "checkbox",
|
|
40
|
+
checked: checked,
|
|
41
|
+
disabled: disabled,
|
|
42
|
+
onChange: onCheckboxChange
|
|
43
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
44
|
+
className: "".concat(cls, "-inner"),
|
|
45
|
+
style: {
|
|
46
|
+
width: size,
|
|
47
|
+
height: size
|
|
48
|
+
}
|
|
49
|
+
}), children);
|
|
50
|
+
});
|
|
51
|
+
Checkbox.defaultProps = {
|
|
52
|
+
disabled: false,
|
|
53
|
+
defaultChecked: false,
|
|
54
|
+
theme: 'blue',
|
|
55
|
+
size: 16
|
|
56
|
+
};
|
|
57
|
+
Checkbox.displayName = 'Checkbox';
|
|
120
58
|
export default Checkbox;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { CheckboxProps } from './Checkbox';
|
|
3
|
-
declare type CommonCheckboxProps = Partial<Pick<CheckboxProps, 'theme' | '
|
|
3
|
+
declare type CommonCheckboxProps = Partial<Pick<CheckboxProps, 'theme' | 'disabled' | 'size'>>;
|
|
4
4
|
export interface CheckboxGroupOptionItem extends CommonCheckboxProps {
|
|
5
5
|
name: string;
|
|
6
6
|
value?: string | number;
|
|
@@ -24,8 +24,8 @@ var CheckboxGroup = function CheckboxGroup(_a) {
|
|
|
24
24
|
options = _a.options,
|
|
25
25
|
className = _a.className,
|
|
26
26
|
disabled = _a.disabled,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
theme = _a.theme,
|
|
28
|
+
size = _a.size;
|
|
29
29
|
if (isEmptyArray(options)) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
@@ -46,8 +46,8 @@ var CheckboxGroup = function CheckboxGroup(_a) {
|
|
|
46
46
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
47
47
|
key: item.name,
|
|
48
48
|
name: item.name,
|
|
49
|
-
reverse: getCheckboxProp(item.reverse, reverse),
|
|
50
49
|
theme: getCheckboxProp(item.theme, theme),
|
|
50
|
+
size: getCheckboxProp(item.size, size),
|
|
51
51
|
disabled: getCheckboxProp(item.disabled, disabled),
|
|
52
52
|
checked: item.checked,
|
|
53
53
|
onChange: onCheckboxChange
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-checkbox{display:inline-
|
|
1
|
+
.ab-checkbox{cursor:pointer;display:inline-flex;align-items:center;user-select:none}.ab-checkbox-input{cursor:pointer;position:absolute;opacity:0;margin:0;padding:0;z-index:2}.ab-checkbox-inner{display:inline-block;margin-right:.06rem;position:relative;border:1px solid #b0b0b0;border-radius:.02rem;background-color:#fff;transition:.3s;flex-shrink:0}.ab-checkbox-inner::after{box-sizing:border-box;position:absolute;top:45%;left:22%;display:table;width:37.5%;height:62.5%;border-style:solid;border-width:2px;border-top:0;border-inline-start:0;transform:rotate(45deg) scale(0) translate(-50%,-50%);opacity:0;content:"";transition:.2s cubic-bezier(.71,-.46,.88,.6),opacity .1s}.ab-checkbox-checked .ab-checkbox-inner::after{opacity:1;transform:rotate(45deg) scale(1) translate(-50%,-50%);transition:.2s cubic-bezier(.12,.4,.29,1.46) .1s}.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox-disabled .ab-checkbox-input{cursor:not-allowed}.ab-checkbox-white .ab-checkbox-inner::after{border-color:#e84040}.ab-checkbox-white.ab-checkbox-disabled .ab-checkbox-inner::after{border-color:#cecece}.ab-checkbox-blue .ab-checkbox-inner::after{border-color:#fff}.ab-checkbox-blue.ab-checkbox-checked .ab-checkbox-inner{transition:none;background-color:#0075ff;border-color:#0075ff}.ab-checkbox-blue.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox-blue.ab-checkbox-disabled .ab-checkbox-inner::after{border-color:#cecece}.ab-checkbox-group{display:flex;flex-wrap:wrap}.ab-checkbox-group .ab-checkbox{margin-right:.08rem}
|
|
@@ -45,7 +45,6 @@ interface InputPhonePropsWithRef extends InputPhoneProps {
|
|
|
45
45
|
export declare class InputPhoneNotRef extends React.Component<InputPhonePropsWithRef, InputPhoneState> {
|
|
46
46
|
prefixCls: string;
|
|
47
47
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
48
|
-
prevFormatValue: string;
|
|
49
48
|
onFocusTimer: ReturnType<typeof setTimeout>;
|
|
50
49
|
static defaultProps: {
|
|
51
50
|
defaultValue: string;
|
package/esm/input-phone/index.js
CHANGED
|
@@ -76,6 +76,7 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
76
76
|
_this.onFocus = function (inputValue, name) {
|
|
77
77
|
var _a = _this.props,
|
|
78
78
|
onFocus = _a.onFocus,
|
|
79
|
+
onChange = _a.onChange,
|
|
79
80
|
format = _a.format,
|
|
80
81
|
placeholderChar = _a.placeholderChar;
|
|
81
82
|
var formatValue = inputValue;
|
|
@@ -89,6 +90,9 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
89
90
|
}, function () {
|
|
90
91
|
_this.resetCursorPositionOnFocus('', 50);
|
|
91
92
|
});
|
|
93
|
+
if (onChange) {
|
|
94
|
+
onChange(formatValue, getNumberValue(formatValue), name);
|
|
95
|
+
}
|
|
92
96
|
return;
|
|
93
97
|
}
|
|
94
98
|
_this.resetCursorPositionOnFocus(inputValue, 50);
|
|
@@ -102,11 +106,15 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
102
106
|
var _a = _this.props,
|
|
103
107
|
format = _a.format,
|
|
104
108
|
placeholderChar = _a.placeholderChar,
|
|
105
|
-
onBlur = _a.onBlur
|
|
109
|
+
onBlur = _a.onBlur,
|
|
110
|
+
onChange = _a.onChange;
|
|
106
111
|
if (formatValue === getPhoneFormat('', format, placeholderChar)) {
|
|
107
112
|
_this.setState({
|
|
108
113
|
formatValue: ''
|
|
109
114
|
});
|
|
115
|
+
if (onChange) {
|
|
116
|
+
onChange('', '', name);
|
|
117
|
+
}
|
|
110
118
|
if (onBlur) {
|
|
111
119
|
onBlur('', '', name);
|
|
112
120
|
}
|
|
@@ -124,16 +132,16 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
124
132
|
format = _a.format,
|
|
125
133
|
onChange = _a.onChange,
|
|
126
134
|
placeholderChar = _a.placeholderChar;
|
|
135
|
+
var prevFormatValue = _this.state.formatValue;
|
|
127
136
|
var _b = getUpdatedValue({
|
|
128
137
|
value: inputValue,
|
|
129
|
-
prevValue:
|
|
138
|
+
prevValue: prevFormatValue,
|
|
130
139
|
format: format,
|
|
131
140
|
selectionEnd: _this.inputRef.current.selectionEnd,
|
|
132
141
|
placeholder: placeholderChar
|
|
133
142
|
}),
|
|
134
143
|
formatValue = _b.value,
|
|
135
144
|
cursorPosition = _b.cursorPosition;
|
|
136
|
-
_this.prevFormatValue = formatValue;
|
|
137
145
|
_this.setState({
|
|
138
146
|
formatValue: formatValue
|
|
139
147
|
}, function () {
|
|
@@ -146,9 +154,8 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
146
154
|
var defaultValue = props.defaultValue,
|
|
147
155
|
format = props.format,
|
|
148
156
|
placeholderChar = props.placeholderChar;
|
|
149
|
-
_this.prevFormatValue = getPhoneFormat(defaultValue, format, placeholderChar);
|
|
150
157
|
_this.state = {
|
|
151
|
-
formatValue: isBlank(defaultValue) ? '' :
|
|
158
|
+
formatValue: isBlank(defaultValue) ? '' : getPhoneFormat(defaultValue, format, placeholderChar)
|
|
152
159
|
};
|
|
153
160
|
return _this;
|
|
154
161
|
}
|
|
@@ -157,8 +164,9 @@ var InputPhoneNotRef = /** @class */function (_super) {
|
|
|
157
164
|
if (nextProps.value !== prevState.formatValue && (
|
|
158
165
|
// 兼容外部传入空string/null的情况, 只有当一个值非空时,才会重新重置State信息
|
|
159
166
|
!isBlank(nextProps.value) || !isBlank(prevState.formatValue))) {
|
|
167
|
+
var formatValue = isBlank(nextProps.value) ? '' : getPhoneFormat(nextProps.value, nextProps.format, nextProps.placeholderChar);
|
|
160
168
|
return {
|
|
161
|
-
formatValue:
|
|
169
|
+
formatValue: formatValue
|
|
162
170
|
};
|
|
163
171
|
}
|
|
164
172
|
}
|
package/esm/move/index.d.ts
CHANGED
|
@@ -36,6 +36,14 @@ export interface MoveProps {
|
|
|
36
36
|
* 点击的回调函数, 如果移动,则不是click
|
|
37
37
|
*/
|
|
38
38
|
onClick?: (event: any) => void;
|
|
39
|
+
/**
|
|
40
|
+
* 禁止水平方向的移动
|
|
41
|
+
*/
|
|
42
|
+
horizontalMoveDisabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 禁止垂直方向的移动
|
|
45
|
+
*/
|
|
46
|
+
verticalMoveDisabled?: boolean;
|
|
39
47
|
}
|
|
40
48
|
declare class Move extends React.Component<MoveProps> {
|
|
41
49
|
readonly prefixCls = "ab-move";
|
|
@@ -46,6 +54,8 @@ declare class Move extends React.Component<MoveProps> {
|
|
|
46
54
|
maxScalable: number;
|
|
47
55
|
horizontalPlacement: string;
|
|
48
56
|
verticalPlacement: string;
|
|
57
|
+
horizontalMoveDisabled: boolean;
|
|
58
|
+
verticalMoveDisabled: boolean;
|
|
49
59
|
};
|
|
50
60
|
prevElementSize: {
|
|
51
61
|
width: number;
|
package/esm/move/index.js
CHANGED
|
@@ -205,13 +205,16 @@ var Move = /** @class */function (_super) {
|
|
|
205
205
|
if (_this.isTouchScale && event.touches.length <= 1) {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
+
var _a = _this.props,
|
|
209
|
+
horizontalMoveDisabled = _a.horizontalMoveDisabled,
|
|
210
|
+
verticalMoveDisabled = _a.verticalMoveDisabled;
|
|
208
211
|
_this.moveObj = {
|
|
209
212
|
left: event.touches ? event.touches[0].pageX : event.clientX,
|
|
210
213
|
top: event.touches ? event.touches[0].pageY : event.clientY
|
|
211
214
|
};
|
|
212
215
|
_this.currentObj = {
|
|
213
|
-
left: _this.prevObj.left + _this.moveObj.left - _this.startObj.left,
|
|
214
|
-
top: _this.prevObj.top + _this.moveObj.top - _this.startObj.top
|
|
216
|
+
left: horizontalMoveDisabled ? _this.prevObj.left : _this.prevObj.left + _this.moveObj.left - _this.startObj.left,
|
|
217
|
+
top: verticalMoveDisabled ? _this.prevObj.top : _this.prevObj.top + _this.moveObj.top - _this.startObj.top
|
|
215
218
|
};
|
|
216
219
|
_this.setElementInfo(element);
|
|
217
220
|
};
|
|
@@ -223,6 +226,10 @@ var Move = /** @class */function (_super) {
|
|
|
223
226
|
if (event.stopPropagation) {
|
|
224
227
|
event.stopPropagation();
|
|
225
228
|
}
|
|
229
|
+
var onClick = _this.props.onClick;
|
|
230
|
+
if (onClick && _this.currentObj.left === _this.prevObj.left && _this.currentObj.top === _this.prevObj.top && _this.prevScaleSize === _this.currentScaleSize) {
|
|
231
|
+
onClick(event);
|
|
232
|
+
}
|
|
226
233
|
var _a = _this.checkRange(),
|
|
227
234
|
nextX = _a.nextX,
|
|
228
235
|
nextY = _a.nextY,
|
|
@@ -237,10 +244,6 @@ var Move = /** @class */function (_super) {
|
|
|
237
244
|
_this.currentScaleSize = nextScaleSize;
|
|
238
245
|
_this.setElementInfo(element);
|
|
239
246
|
}
|
|
240
|
-
var onClick = _this.props.onClick;
|
|
241
|
-
if (onClick && _this.currentObj.left === _this.prevObj.left && _this.currentObj.top === _this.prevObj.top && _this.prevScaleSize === _this.currentScaleSize) {
|
|
242
|
-
onClick(event);
|
|
243
|
-
}
|
|
244
247
|
};
|
|
245
248
|
_this.onTransitionEnd = function () {
|
|
246
249
|
var element = _this.getDomNode();
|
|
@@ -375,7 +378,9 @@ var Move = /** @class */function (_super) {
|
|
|
375
378
|
minScalable: 1,
|
|
376
379
|
maxScalable: 1,
|
|
377
380
|
horizontalPlacement: 'left',
|
|
378
|
-
verticalPlacement: 'top'
|
|
381
|
+
verticalPlacement: 'top',
|
|
382
|
+
horizontalMoveDisabled: false,
|
|
383
|
+
verticalMoveDisabled: false
|
|
379
384
|
};
|
|
380
385
|
return Move;
|
|
381
386
|
}(React.Component);
|
package/esm/radio/Radio.d.ts
CHANGED
package/esm/radio/Radio.js
CHANGED
|
@@ -19,6 +19,7 @@ var Radio = function Radio(props) {
|
|
|
19
19
|
var _a;
|
|
20
20
|
var _b = props.checked,
|
|
21
21
|
propsChecked = _b === void 0 ? false : _b,
|
|
22
|
+
size = props.size,
|
|
22
23
|
name = props.name,
|
|
23
24
|
onChange = props.onChange,
|
|
24
25
|
children = props.children,
|
|
@@ -45,36 +46,63 @@ var Radio = function Radio(props) {
|
|
|
45
46
|
setChecked(groupContext.value === value);
|
|
46
47
|
}
|
|
47
48
|
}, [groupContext, value]);
|
|
48
|
-
var onRadioChange = function onRadioChange(
|
|
49
|
+
var onRadioChange = function onRadioChange(ev) {
|
|
49
50
|
if (mergedProps.disabled) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
53
|
+
var checkedValue = ev.target.value;
|
|
52
54
|
if (onChange) {
|
|
53
|
-
onChange(
|
|
55
|
+
onChange(checkedValue, mergedProps.name, ev.target.checked);
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
// radioGroup
|
|
57
59
|
if (groupContext.onChange) {
|
|
58
|
-
groupContext.onChange(
|
|
60
|
+
groupContext.onChange(checkedValue, mergedProps.name);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
setChecked(!checked);
|
|
62
64
|
};
|
|
63
|
-
var onClick = function onClick(
|
|
64
|
-
|
|
65
|
+
var onClick = function onClick(ev) {
|
|
66
|
+
ev.stopPropagation();
|
|
65
67
|
};
|
|
66
68
|
return /*#__PURE__*/React.createElement("label", {
|
|
67
69
|
onClick: onClick,
|
|
68
70
|
className: classNames(cls, (_a = {}, _a["".concat(cls, "-disabled")] = mergedProps.disabled, _a["".concat(cls, "-checked")] = checked, _a), groupContext.className, className)
|
|
69
71
|
}, /*#__PURE__*/React.createElement("input", __assign({
|
|
72
|
+
style: {
|
|
73
|
+
width: size,
|
|
74
|
+
height: size
|
|
75
|
+
},
|
|
70
76
|
type: "radio",
|
|
71
77
|
checked: checked,
|
|
72
78
|
value: value,
|
|
73
79
|
onChange: onRadioChange
|
|
74
80
|
}, mergedProps)), /*#__PURE__*/React.createElement("span", {
|
|
75
|
-
className: "".concat(cls, "-control")
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
className: "".concat(cls, "-control"),
|
|
82
|
+
style: {
|
|
83
|
+
width: size,
|
|
84
|
+
height: size,
|
|
85
|
+
fontSize: size
|
|
86
|
+
}
|
|
87
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
88
|
+
className: "".concat(cls, "-outer"),
|
|
89
|
+
focusable: "false",
|
|
90
|
+
"aria-hidden": "true",
|
|
91
|
+
viewBox: "0 0 512 512"
|
|
92
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
93
|
+
d: "M448,256c0-106-86-192-192-192S64,150,64,256s86,192,192,192S448,362,448,256Z",
|
|
94
|
+
strokeWidth: "1.5em",
|
|
95
|
+
fill: "#fff"
|
|
96
|
+
})), /*#__PURE__*/React.createElement("svg", {
|
|
97
|
+
className: "".concat(cls, "-dot"),
|
|
98
|
+
focusable: "false",
|
|
99
|
+
"aria-hidden": "true",
|
|
100
|
+
viewBox: "0 0 24 24"
|
|
101
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
102
|
+
d: "M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"
|
|
103
|
+
}))), children);
|
|
104
|
+
};
|
|
105
|
+
Radio.defaultProps = {
|
|
106
|
+
size: 16
|
|
79
107
|
};
|
|
80
108
|
export default Radio;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { RadioGroupProps, RadioValue } from './
|
|
2
|
+
import { RadioGroupProps, RadioValue } from './type';
|
|
3
3
|
interface RadioGroupState {
|
|
4
4
|
value: RadioValue;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ declare class RadioGroup extends Component<RadioGroupProps, RadioGroupState> {
|
|
|
8
8
|
static getDerivedStateFromProps(nextProps: RadioGroupProps, prevState: RadioGroupState): {
|
|
9
9
|
value: RadioValue;
|
|
10
10
|
};
|
|
11
|
-
onRadioChange: (
|
|
11
|
+
onRadioChange: (value: RadioValue, name?: string) => void;
|
|
12
12
|
renderRadioGroup: () => JSX.Element;
|
|
13
13
|
renderRadioList: () => JSX.Element;
|
|
14
14
|
render(): JSX.Element;
|
package/esm/radio/RadioGroup.js
CHANGED
|
@@ -32,14 +32,14 @@ var RadioGroup = /** @class */function (_super) {
|
|
|
32
32
|
__extends(RadioGroup, _super);
|
|
33
33
|
function RadioGroup(props) {
|
|
34
34
|
var _this = _super.call(this, props) || this;
|
|
35
|
-
_this.onRadioChange = function (
|
|
35
|
+
_this.onRadioChange = function (value, name) {
|
|
36
36
|
var onChange = _this.props.onChange;
|
|
37
37
|
if (onChange) {
|
|
38
|
-
onChange(
|
|
38
|
+
onChange(value, name);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
_this.setState({
|
|
42
|
-
value:
|
|
42
|
+
value: value
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
_this.renderRadioGroup = function () {
|
|
@@ -62,7 +62,8 @@ var RadioGroup = /** @class */function (_super) {
|
|
|
62
62
|
var _a = _this.props,
|
|
63
63
|
name = _a.name,
|
|
64
64
|
options = _a.options,
|
|
65
|
-
disabled = _a.disabled
|
|
65
|
+
disabled = _a.disabled,
|
|
66
|
+
size = _a.size;
|
|
66
67
|
var value = _this.state.value;
|
|
67
68
|
if (isEmptyArray(options)) {
|
|
68
69
|
return null;
|
|
@@ -72,12 +73,11 @@ var RadioGroup = /** @class */function (_super) {
|
|
|
72
73
|
key: item.value,
|
|
73
74
|
className: "".concat(cls, "-item"),
|
|
74
75
|
name: name,
|
|
76
|
+
size: size,
|
|
75
77
|
value: item.value,
|
|
76
78
|
disabled: getRadioProp(item.disabled, disabled),
|
|
77
79
|
checked: value === item.value,
|
|
78
|
-
onChange:
|
|
79
|
-
return _this.onRadioChange(e.target.value, n);
|
|
80
|
-
}
|
|
80
|
+
onChange: _this.onRadioChange
|
|
81
81
|
}, item.name);
|
|
82
82
|
}));
|
|
83
83
|
};
|
package/esm/radio/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RadioGroupProps } from './
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RadioGroupProps } from './type';
|
|
3
3
|
declare const RadioGroupContext: React.Context<RadioGroupProps>;
|
|
4
4
|
export declare const RadioGroupContextProvider: React.Provider<RadioGroupProps>;
|
|
5
5
|
export default RadioGroupContext;
|
package/esm/radio/context.js
CHANGED
package/esm/radio/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { RadioProps, RadioGroupProps, RadioValue, RadioOptionItem } from './
|
|
1
|
+
export type { RadioProps, RadioGroupProps, RadioValue, RadioOptionItem } from './type';
|
|
2
2
|
export { default as Radio } from './Radio';
|
|
3
3
|
export { default as RadioGroup } from './RadioGroup';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-radio{position:relative;overflow:hidden;display:inline-flex;align-items:center;cursor:pointer}.ab-radio input{
|
|
1
|
+
.ab-radio{position:relative;overflow:hidden;display:inline-flex;align-items:center;cursor:pointer;font-size:.14rem}.ab-radio:hover .ab-radio-control{color:#4f4f4f}.ab-radio input{cursor:inherit;position:absolute;margin:0;padding:0;opacity:0;top:0;left:0;z-index:1}.ab-radio-checked:hover .ab-radio-control{color:#005cc8}.ab-radio-checked .ab-radio-control{color:#0075ff}.ab-radio-checked .ab-radio-control svg{display:inline-block}.ab-radio-disabled{cursor:not-allowed}.ab-radio-disabled .ab-radio-control,.ab-radio-disabled:hover .ab-radio-control{color:#d1d1d1}.ab-radio-control{margin-right:.06rem;position:relative;color:#767676}.ab-radio-control svg{width:1em;height:1em;user-select:none;flex-shrink:0;fill:currentcolor;stroke:currentcolor}.ab-radio-dot,.ab-radio-outer{position:absolute;left:0;top:0}.ab-radio-dot{display:none}.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}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
1
|
export declare type RadioValue = string | number;
|
|
3
2
|
export interface RadioProps {
|
|
4
3
|
name?: string;
|
|
5
4
|
checked?: boolean;
|
|
6
5
|
disabled?: boolean;
|
|
7
6
|
value?: RadioValue;
|
|
8
|
-
|
|
7
|
+
/**单位为px */
|
|
8
|
+
size?: number;
|
|
9
|
+
onChange?: (value: RadioValue, name?: string, checked?: boolean) => void;
|
|
9
10
|
className?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare type RadioOptionItem = Pick<RadioProps, 'disabled' | 'name' | 'value'>;
|
|
12
|
-
export interface RadioGroupProps extends Pick<RadioProps, 'value' | 'name' | 'disabled' | 'className'> {
|
|
13
|
+
export interface RadioGroupProps extends Pick<RadioProps, 'value' | 'name' | 'disabled' | 'className' | 'size'> {
|
|
13
14
|
options?: RadioOptionItem[];
|
|
14
15
|
defaultValue?: RadioValue;
|
|
15
16
|
onChange?: (value: RadioValue, name: string) => void;
|