assui 2.0.2 → 2.0.6
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/es/button-drawer/index.d.ts +10 -0
- package/es/button-drawer/index.js +116 -0
- package/es/button-drawer/style/index.d.ts +1 -0
- package/es/button-drawer/style/index.js +1 -0
- package/es/button-modal/index.d.ts +14 -0
- package/es/button-modal/index.js +131 -0
- package/es/button-modal/style/index.d.ts +1 -0
- package/es/button-modal/style/index.js +1 -0
- package/es/condition-input/index.d.ts +15 -0
- package/es/condition-input/index.js +108 -0
- package/es/condition-input/parse2RegexOption.d.ts +13 -0
- package/es/condition-input/parse2RegexOption.js +57 -0
- package/es/condition-input/style/index.d.ts +1 -0
- package/es/condition-input/style/index.js +1 -0
- package/es/copy-to-clipboard/index.d.ts +22 -0
- package/es/copy-to-clipboard/index.js +95 -0
- package/es/copy-to-clipboard/style/index.css +249 -0
- package/es/copy-to-clipboard/style/index.d.ts +1 -0
- package/es/copy-to-clipboard/style/index.js +1 -0
- package/es/copy-to-clipboard/style/index.less +1 -0
- package/es/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/es/highlight-textarea/HighlighedContents.js +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.js +159 -0
- package/es/highlight-textarea/getRanges.d.ts +2 -0
- package/es/highlight-textarea/getRanges.js +142 -0
- package/es/highlight-textarea/getType.d.ts +2 -0
- package/es/highlight-textarea/getType.js +29 -0
- package/es/highlight-textarea/index.d.ts +12 -0
- package/es/highlight-textarea/index.js +132 -0
- package/es/highlight-textarea/style/index.css +38 -0
- package/es/highlight-textarea/style/index.d.ts +2 -0
- package/es/highlight-textarea/style/index.js +2 -0
- package/es/highlight-textarea/style/index.less +42 -0
- package/es/highlight-textarea/types.d.ts +16 -0
- package/es/highlight-textarea/types.js +0 -0
- package/es/highlight-words/index.d.ts +3 -0
- package/es/highlight-words/index.js +2 -0
- package/es/highlight-words/style/index.d.ts +1 -0
- package/es/highlight-words/style/index.js +0 -0
- package/es/icon/demo/svg/check-circle-filled.svg +6 -0
- package/es/icon/demo/svg/coin-circle.svg +9 -0
- package/es/icon/index.d.ts +27 -0
- package/es/icon/index.js +95 -0
- package/es/icon/style/index.d.ts +1 -0
- package/es/icon/style/index.js +0 -0
- package/es/icon/utils.d.ts +6 -0
- package/es/icon/utils.js +22 -0
- package/es/img-crop/EasyCrop.d.ts +6 -0
- package/es/img-crop/EasyCrop.js +113 -0
- package/es/img-crop/getCroppedImg.d.ts +6 -0
- package/es/img-crop/getCroppedImg.js +199 -0
- package/es/img-crop/index.d.ts +53 -0
- package/es/img-crop/index.js +531 -0
- package/es/img-crop/style/index.css +52 -0
- package/es/img-crop/style/index.d.ts +3 -0
- package/es/img-crop/style/index.js +3 -0
- package/es/img-crop/style/index.less +54 -0
- package/es/index.d.ts +34 -2
- package/es/index.js +18 -2
- package/es/keep-tab/demo/index.modules.less +66 -0
- package/es/keep-tab/index.d.ts +29 -0
- package/es/keep-tab/index.js +129 -0
- package/es/keep-tab/style/index.css +1129 -0
- package/es/keep-tab/style/index.d.ts +2 -0
- package/es/keep-tab/style/index.js +2 -0
- package/es/keep-tab/style/index.less +2 -0
- package/es/number-input/index.d.ts +22 -7
- package/es/number-input/index.js +22 -11
- package/es/number-input/style/index.d.ts +1 -1
- package/es/number-input/style/index.js +1 -1
- package/es/number-input/utils.d.ts +10 -11
- package/es/number-input/utils.js +7 -7
- package/es/rc-echart/core.d.ts +32 -0
- package/es/rc-echart/core.js +136 -0
- package/es/rc-echart/index.d.ts +21 -0
- package/es/rc-echart/index.js +27 -0
- package/es/rc-echart/style/index.d.ts +1 -0
- package/es/rc-echart/style/index.js +0 -0
- package/es/rc-motion/demo/CSSMotion.less +91 -0
- package/es/rc-motion/index.d.ts +2 -0
- package/es/rc-motion/index.js +2 -0
- package/es/rc-motion/style/index.d.ts +1 -0
- package/es/rc-motion/style/index.js +0 -0
- package/es/rc-qrcode/index.d.ts +20 -0
- package/es/rc-qrcode/index.js +57 -0
- package/es/rc-qrcode/style/index.d.ts +1 -0
- package/es/rc-qrcode/style/index.js +0 -0
- package/es/rc-qrcode/useQrcode.d.ts +4 -0
- package/es/rc-qrcode/useQrcode.js +50 -0
- package/es/rc-transition-group/index.d.ts +2 -0
- package/es/rc-transition-group/index.js +2 -0
- package/es/rc-transition-group/style/index.d.ts +1 -0
- package/es/rc-transition-group/style/index.js +0 -0
- package/es/single-img-upload/index.d.ts +19 -0
- package/es/single-img-upload/index.js +199 -0
- package/es/single-img-upload/style/index.css +74 -0
- package/es/single-img-upload/style/index.d.ts +3 -0
- package/es/single-img-upload/style/index.js +3 -0
- package/es/single-img-upload/style/index.less +85 -0
- package/es/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/es/sortable-hoc/demo/index.modules.less +248 -0
- package/es/sortable-hoc/index.d.ts +2 -0
- package/es/sortable-hoc/index.js +2 -0
- package/es/sortable-hoc/style/index.d.ts +1 -0
- package/es/sortable-hoc/style/index.js +0 -0
- package/es/split-pane/index.d.ts +59 -0
- package/es/split-pane/index.js +21 -0
- package/es/split-pane/style/index.css +41 -0
- package/es/split-pane/style/index.d.ts +1 -0
- package/es/split-pane/style/index.js +1 -0
- package/es/split-pane/style/index.less +49 -0
- package/es/text-area/index.d.ts +12 -0
- package/es/text-area/index.js +96 -0
- package/es/text-area/style/index.d.ts +1 -0
- package/es/text-area/style/index.js +1 -0
- package/es/text-input/index.d.ts +5 -0
- package/es/text-input/index.js +85 -0
- package/es/{number-input → text-input}/style/index.css +0 -3
- package/es/text-input/style/index.d.ts +1 -0
- package/es/text-input/style/index.js +1 -0
- package/es/{number-input → text-input}/style/index.less +0 -4
- package/lib/button-drawer/index.d.ts +10 -0
- package/lib/button-drawer/index.js +164 -0
- package/lib/button-drawer/style/index.d.ts +1 -0
- package/lib/button-drawer/style/index.js +7 -0
- package/lib/button-modal/index.d.ts +14 -0
- package/lib/button-modal/index.js +178 -0
- package/lib/button-modal/style/index.d.ts +1 -0
- package/lib/button-modal/style/index.js +7 -0
- package/lib/condition-input/index.d.ts +15 -0
- package/lib/condition-input/index.js +158 -0
- package/lib/condition-input/parse2RegexOption.d.ts +13 -0
- package/lib/condition-input/parse2RegexOption.js +72 -0
- package/lib/condition-input/style/index.d.ts +1 -0
- package/lib/condition-input/style/index.js +7 -0
- package/lib/copy-to-clipboard/index.d.ts +22 -0
- package/lib/copy-to-clipboard/index.js +143 -0
- package/lib/copy-to-clipboard/style/index.css +249 -0
- package/lib/copy-to-clipboard/style/index.d.ts +1 -0
- package/lib/copy-to-clipboard/style/index.js +7 -0
- package/lib/copy-to-clipboard/style/index.less +1 -0
- package/lib/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/lib/highlight-textarea/HighlighedContents.js +29 -0
- package/lib/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/lib/highlight-textarea/extractSpansOfClasses.js +173 -0
- package/lib/highlight-textarea/getRanges.d.ts +2 -0
- package/lib/highlight-textarea/getRanges.js +156 -0
- package/lib/highlight-textarea/getType.d.ts +2 -0
- package/lib/highlight-textarea/getType.js +37 -0
- package/lib/highlight-textarea/index.d.ts +12 -0
- package/lib/highlight-textarea/index.js +183 -0
- package/lib/highlight-textarea/style/index.css +38 -0
- package/lib/highlight-textarea/style/index.d.ts +2 -0
- package/lib/highlight-textarea/style/index.js +9 -0
- package/lib/highlight-textarea/style/index.less +42 -0
- package/lib/highlight-textarea/types.d.ts +16 -0
- package/lib/highlight-textarea/types.js +5 -0
- package/lib/highlight-words/index.d.ts +3 -0
- package/lib/highlight-words/index.js +15 -0
- package/lib/highlight-words/style/index.d.ts +1 -0
- package/lib/highlight-words/style/index.js +0 -0
- package/lib/icon/demo/svg/check-circle-filled.svg +6 -0
- package/lib/icon/demo/svg/coin-circle.svg +9 -0
- package/lib/icon/index.d.ts +27 -0
- package/lib/icon/index.js +143 -0
- package/lib/icon/style/index.d.ts +1 -0
- package/lib/icon/style/index.js +0 -0
- package/lib/icon/utils.d.ts +6 -0
- package/lib/icon/utils.js +32 -0
- package/lib/img-crop/EasyCrop.d.ts +6 -0
- package/lib/img-crop/EasyCrop.js +160 -0
- package/lib/img-crop/getCroppedImg.d.ts +6 -0
- package/lib/img-crop/getCroppedImg.js +205 -0
- package/lib/img-crop/index.d.ts +53 -0
- package/lib/img-crop/index.js +582 -0
- package/lib/img-crop/style/index.css +52 -0
- package/lib/img-crop/style/index.d.ts +3 -0
- package/lib/img-crop/style/index.js +11 -0
- package/lib/img-crop/style/index.less +54 -0
- package/lib/index.d.ts +34 -2
- package/lib/index.js +160 -9
- package/lib/keep-tab/demo/index.modules.less +66 -0
- package/lib/keep-tab/index.d.ts +29 -0
- package/lib/keep-tab/index.js +181 -0
- package/lib/keep-tab/style/index.css +1129 -0
- package/lib/keep-tab/style/index.d.ts +2 -0
- package/lib/keep-tab/style/index.js +9 -0
- package/lib/keep-tab/style/index.less +2 -0
- package/lib/number-input/index.d.ts +22 -7
- package/lib/number-input/index.js +22 -11
- package/lib/number-input/style/index.d.ts +1 -1
- package/lib/number-input/style/index.js +1 -1
- package/lib/number-input/utils.d.ts +10 -11
- package/lib/number-input/utils.js +8 -8
- package/lib/rc-echart/core.d.ts +32 -0
- package/lib/rc-echart/core.js +185 -0
- package/lib/rc-echart/index.d.ts +21 -0
- package/lib/rc-echart/index.js +75 -0
- package/lib/rc-echart/style/index.d.ts +1 -0
- package/lib/rc-echart/style/index.js +0 -0
- package/lib/rc-motion/demo/CSSMotion.less +91 -0
- package/lib/rc-motion/index.d.ts +2 -0
- package/lib/rc-motion/index.js +43 -0
- package/lib/rc-motion/style/index.d.ts +1 -0
- package/lib/rc-motion/style/index.js +0 -0
- package/lib/rc-qrcode/index.d.ts +20 -0
- package/lib/rc-qrcode/index.js +108 -0
- package/lib/rc-qrcode/style/index.d.ts +1 -0
- package/lib/rc-qrcode/style/index.js +0 -0
- package/lib/rc-qrcode/useQrcode.d.ts +4 -0
- package/lib/rc-qrcode/useQrcode.js +66 -0
- package/lib/rc-transition-group/index.d.ts +2 -0
- package/lib/rc-transition-group/index.js +43 -0
- package/lib/rc-transition-group/style/index.d.ts +1 -0
- package/lib/rc-transition-group/style/index.js +0 -0
- package/lib/single-img-upload/index.d.ts +19 -0
- package/lib/single-img-upload/index.js +250 -0
- package/lib/single-img-upload/style/index.css +74 -0
- package/lib/single-img-upload/style/index.d.ts +3 -0
- package/lib/single-img-upload/style/index.js +11 -0
- package/lib/single-img-upload/style/index.less +85 -0
- package/lib/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/lib/sortable-hoc/demo/index.modules.less +248 -0
- package/lib/sortable-hoc/index.d.ts +2 -0
- package/lib/sortable-hoc/index.js +43 -0
- package/lib/sortable-hoc/style/index.d.ts +1 -0
- package/lib/sortable-hoc/style/index.js +0 -0
- package/lib/split-pane/index.d.ts +59 -0
- package/lib/split-pane/index.js +69 -0
- package/lib/split-pane/style/index.css +41 -0
- package/lib/split-pane/style/index.d.ts +1 -0
- package/lib/split-pane/style/index.js +7 -0
- package/lib/split-pane/style/index.less +49 -0
- package/lib/text-area/index.d.ts +12 -0
- package/lib/text-area/index.js +144 -0
- package/lib/text-area/style/index.d.ts +1 -0
- package/lib/text-area/style/index.js +7 -0
- package/lib/text-input/index.d.ts +5 -0
- package/lib/text-input/index.js +99 -0
- package/lib/{number-input → text-input}/style/index.css +0 -3
- package/lib/text-input/style/index.d.ts +1 -0
- package/lib/text-input/style/index.js +7 -0
- package/lib/{number-input → text-input}/style/index.less +0 -4
- package/package.json +20 -3
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
declare type ValueType = string | number;
|
|
2
1
|
export interface NumberInputProps {
|
|
3
|
-
|
|
2
|
+
/** 输入框的内容 */
|
|
3
|
+
value?: string;
|
|
4
|
+
/** 输入数据的类型 */
|
|
4
5
|
numberType?: 'int' | 'float';
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/** 精度,只对float有效 */
|
|
7
|
+
precision: number;
|
|
8
|
+
/** 指定输入框展示值的格式 */
|
|
9
|
+
formatter?: (value: string) => string;
|
|
10
|
+
/** 指定从 formatter 里转换回数字的方式,和 formatter 搭配使用 */
|
|
11
|
+
parser?: (value: string) => string;
|
|
12
|
+
/** 是否允许输入负数 */
|
|
7
13
|
enableMinus?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
/** 变化回调 */
|
|
15
|
+
onChange?: (value: string) => void;
|
|
16
|
+
/** 失去焦点回调 */
|
|
17
|
+
onBlur?: (value: string) => void;
|
|
10
18
|
}
|
|
11
|
-
declare const NumberInput:
|
|
19
|
+
declare const NumberInput: {
|
|
20
|
+
(props: NumberInputProps): JSX.Element;
|
|
21
|
+
defaultProps: {
|
|
22
|
+
numberType: string;
|
|
23
|
+
precision: number;
|
|
24
|
+
enableMinus: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
12
27
|
export default NumberInput;
|
|
@@ -102,7 +102,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
102
102
|
|
|
103
103
|
var React = __importStar(require("react"));
|
|
104
104
|
|
|
105
|
-
var input_1 = __importDefault(require("antd/
|
|
105
|
+
var input_1 = __importDefault(require("antd/es/input"));
|
|
106
106
|
|
|
107
107
|
var numberType_1 = require("./const/numberType");
|
|
108
108
|
|
|
@@ -114,15 +114,16 @@ var NumberInput = function NumberInput(props) {
|
|
|
114
114
|
numberType = props.numberType,
|
|
115
115
|
precision = props.precision,
|
|
116
116
|
formatter = props.formatter,
|
|
117
|
+
parser = props.parser,
|
|
117
118
|
enableMinus = props.enableMinus,
|
|
118
119
|
onBlur = props.onBlur,
|
|
119
|
-
restProps = __rest(props, ["value", "onChange", "numberType", "precision", "formatter", "enableMinus", "onBlur"]);
|
|
120
|
+
restProps = __rest(props, ["value", "onChange", "numberType", "precision", "formatter", "parser", "enableMinus", "onBlur"]);
|
|
120
121
|
|
|
121
122
|
var _a = __read(React.useState(''), 2),
|
|
122
123
|
number = _a[0],
|
|
123
124
|
setNumber = _a[1];
|
|
124
125
|
|
|
125
|
-
var resultValue =
|
|
126
|
+
var resultValue = value === undefined ? number : value;
|
|
126
127
|
|
|
127
128
|
var onNumberChange = function onNumberChange(e) {
|
|
128
129
|
var newNumber;
|
|
@@ -143,39 +144,49 @@ var NumberInput = function NumberInput(props) {
|
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
if (
|
|
147
|
-
newNumber =
|
|
147
|
+
if (parser) {
|
|
148
|
+
newNumber = parser(newNumber);
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
if (resultValue !== newNumber) {
|
|
152
|
+
if (value === undefined) {
|
|
153
|
+
setNumber(newNumber);
|
|
154
|
+
}
|
|
155
|
+
|
|
151
156
|
if (onChange) {
|
|
152
157
|
onChange(newNumber);
|
|
153
|
-
} else {
|
|
154
|
-
setNumber(newNumber);
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
};
|
|
158
161
|
|
|
159
162
|
var onNumberBlur = function onNumberBlur() {
|
|
160
163
|
if (resultValue === '-' || resultValue === '.') {
|
|
164
|
+
if (value === undefined) {
|
|
165
|
+
setNumber('');
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
if (onChange) {
|
|
162
169
|
onChange('');
|
|
163
|
-
} else {
|
|
164
|
-
setNumber('');
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
|
|
168
173
|
if (onBlur) {
|
|
169
|
-
onBlur(resultValue);
|
|
174
|
+
onBlur(resultValue || '');
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
177
|
|
|
178
|
+
var inputValue = formatter ? formatter(resultValue) : resultValue;
|
|
173
179
|
return React.createElement(input_1["default"], __assign({
|
|
174
180
|
type: "text",
|
|
175
|
-
value:
|
|
181
|
+
value: inputValue,
|
|
176
182
|
onBlur: onNumberBlur,
|
|
177
183
|
onChange: onNumberChange
|
|
178
184
|
}, restProps));
|
|
179
185
|
};
|
|
180
186
|
|
|
187
|
+
NumberInput.defaultProps = {
|
|
188
|
+
numberType: numberType_1.INT,
|
|
189
|
+
precision: 2,
|
|
190
|
+
enableMinus: false
|
|
191
|
+
};
|
|
181
192
|
exports["default"] = NumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import 'antd/es/input/style';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
value:
|
|
3
|
-
enableMinus
|
|
4
|
-
preValue:
|
|
5
|
-
}
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}) => any;
|
|
1
|
+
export interface FilterIntType {
|
|
2
|
+
value: string;
|
|
3
|
+
enableMinus?: boolean;
|
|
4
|
+
preValue: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const filterInt: ({ value, enableMinus, preValue }: FilterIntType) => string;
|
|
7
|
+
export interface FilterFloatType extends FilterIntType {
|
|
8
|
+
precision: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const filterFloat: ({ value, preValue, precision, enableMinus }: FilterFloatType) => string;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable no-useless-escape */
|
|
2
3
|
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.filterFloat = exports.filterInt = void 0;
|
|
7
|
-
/* eslint-disable no-useless-escape */
|
|
8
8
|
|
|
9
9
|
exports.filterInt = function (_a) {
|
|
10
10
|
var value = _a.value,
|
|
11
11
|
enableMinus = _a.enableMinus,
|
|
12
12
|
preValue = _a.preValue;
|
|
13
|
-
var nextValue = value.replace(/[
|
|
13
|
+
var nextValue = value.replace(/[^\d\-]/g, '');
|
|
14
14
|
|
|
15
15
|
if (!enableMinus) {
|
|
16
|
-
nextValue = value.replace(/
|
|
16
|
+
nextValue = value.replace(/\D/g, '');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
var intNumberReg =
|
|
19
|
+
var intNumberReg = /^-?\d+$/;
|
|
20
20
|
|
|
21
21
|
if (nextValue && nextValue.length > 1 && !intNumberReg.test(nextValue)) {
|
|
22
22
|
return preValue;
|
|
@@ -30,18 +30,18 @@ exports.filterFloat = function (_a) {
|
|
|
30
30
|
preValue = _a.preValue,
|
|
31
31
|
precision = _a.precision,
|
|
32
32
|
enableMinus = _a.enableMinus;
|
|
33
|
-
var nextValue = value.replace(/[
|
|
34
|
-
var matchDecimalPoint = nextValue.match(
|
|
33
|
+
var nextValue = value.replace(/[^\d.\-]/g, '');
|
|
34
|
+
var matchDecimalPoint = nextValue.match(/\./g) || [];
|
|
35
35
|
|
|
36
36
|
if (matchDecimalPoint.length > 1) {
|
|
37
37
|
return preValue;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (!enableMinus) {
|
|
41
|
-
nextValue = value.replace(/[
|
|
41
|
+
nextValue = value.replace(/[^\d.]/g, '');
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
var floatNumberReg =
|
|
44
|
+
var floatNumberReg = /^-?\d+\.?\d*$/;
|
|
45
45
|
|
|
46
46
|
if (nextValue && nextValue.length > 1 && !floatNumberReg.test(nextValue)) {
|
|
47
47
|
return preValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EChartsOption } from 'echarts';
|
|
3
|
+
export declare type Opts = {
|
|
4
|
+
devicePixelRatio?: number;
|
|
5
|
+
renderer?: 'canvas' | 'svg';
|
|
6
|
+
width?: number | null | undefined | 'auto';
|
|
7
|
+
height?: number | null | undefined | 'auto';
|
|
8
|
+
locale?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface RcEchartPropsType {
|
|
11
|
+
option: EChartsOption;
|
|
12
|
+
notMerge?: boolean;
|
|
13
|
+
lazyUpdate?: boolean;
|
|
14
|
+
echarts: any;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
17
|
+
theme?: string;
|
|
18
|
+
onEvents?: Record<string, Function>;
|
|
19
|
+
opts?: Opts;
|
|
20
|
+
}
|
|
21
|
+
declare const ReactEchartCore: {
|
|
22
|
+
(props: RcEchartPropsType): JSX.Element;
|
|
23
|
+
defaultProps: {
|
|
24
|
+
notMerge: boolean;
|
|
25
|
+
lazyUpdate: boolean;
|
|
26
|
+
style: {};
|
|
27
|
+
className: string;
|
|
28
|
+
onEvents: {};
|
|
29
|
+
opts: {};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default ReactEchartCore;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
Object.defineProperty(o, k2, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return m[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} : function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
value: v
|
|
36
|
+
});
|
|
37
|
+
} : function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var __importStar = this && this.__importStar || function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k in mod) {
|
|
45
|
+
if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
54
|
+
return mod && mod.__esModule ? mod : {
|
|
55
|
+
"default": mod
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Object.defineProperty(exports, "__esModule", {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
|
62
|
+
/* eslint-disable no-unused-expressions */
|
|
63
|
+
|
|
64
|
+
/* eslint-disable no-restricted-syntax */
|
|
65
|
+
|
|
66
|
+
var react_1 = __importStar(require("react"));
|
|
67
|
+
|
|
68
|
+
var useMount_1 = __importDefault(require("ahooks/lib/useMount"));
|
|
69
|
+
|
|
70
|
+
var useUpdateEffect_1 = __importDefault(require("ahooks/lib/useUpdateEffect"));
|
|
71
|
+
|
|
72
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
73
|
+
|
|
74
|
+
var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
|
|
75
|
+
|
|
76
|
+
var ReactEchartCore = function ReactEchartCore(props) {
|
|
77
|
+
var className = props.className,
|
|
78
|
+
option = props.option,
|
|
79
|
+
style = props.style,
|
|
80
|
+
echarts = props.echarts,
|
|
81
|
+
notMerge = props.notMerge,
|
|
82
|
+
lazyUpdate = props.lazyUpdate,
|
|
83
|
+
onEvents = props.onEvents,
|
|
84
|
+
opts = props.opts,
|
|
85
|
+
theme = props.theme;
|
|
86
|
+
var chartDomRef = react_1.useRef();
|
|
87
|
+
var chartRef = react_1.useRef();
|
|
88
|
+
|
|
89
|
+
var bindEvents = function bindEvents() {
|
|
90
|
+
var bindEventFunc = function bindEventFunc(eventName, func) {
|
|
91
|
+
if (typeof eventName === 'string' && typeof func === 'function') {
|
|
92
|
+
if (chartRef.current) {
|
|
93
|
+
chartRef.current.on(eventName, function (param) {
|
|
94
|
+
func(param, chartRef.current);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
for (var eventName in onEvents) {
|
|
101
|
+
if (Object.prototype.hasOwnProperty.call(onEvents, eventName)) {
|
|
102
|
+
bindEventFunc(eventName, onEvents[eventName]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var initEcharts = function initEcharts() {
|
|
108
|
+
chartRef.current = echarts.init(chartDomRef.current, theme, opts);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var renderEchartDom = function renderEchartDom() {
|
|
112
|
+
if (chartRef.current) {
|
|
113
|
+
chartRef.current.setOption(option, notMerge, lazyUpdate);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var dispose = function dispose() {
|
|
118
|
+
if (chartRef.current) {
|
|
119
|
+
chartRef.current.dispose();
|
|
120
|
+
}
|
|
121
|
+
}; // first add
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
useMount_1["default"](function () {
|
|
125
|
+
initEcharts();
|
|
126
|
+
renderEchartDom();
|
|
127
|
+
bindEvents();
|
|
128
|
+
}); // need reBuild
|
|
129
|
+
|
|
130
|
+
useUpdateEffect_1["default"](function () {
|
|
131
|
+
dispose();
|
|
132
|
+
renderEchartDom();
|
|
133
|
+
bindEvents();
|
|
134
|
+
}, [theme, opts, onEvents]); // need setOption
|
|
135
|
+
|
|
136
|
+
useUpdateEffect_1["default"](function () {
|
|
137
|
+
renderEchartDom();
|
|
138
|
+
}, [option, notMerge, lazyUpdate]); // need resize
|
|
139
|
+
|
|
140
|
+
var resizeChart = function resizeChart() {
|
|
141
|
+
if (chartRef.current) {
|
|
142
|
+
chartRef.current.resize();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
react_1.useLayoutEffect(function () {
|
|
147
|
+
var resizeObserver = new resize_observer_polyfill_1["default"](function () {
|
|
148
|
+
resizeChart();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (chartDomRef.current) {
|
|
152
|
+
resizeObserver.observe(chartDomRef.current);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return function () {
|
|
156
|
+
resizeObserver.disconnect();
|
|
157
|
+
};
|
|
158
|
+
}, []);
|
|
159
|
+
useUpdateEffect_1["default"](function () {
|
|
160
|
+
resizeChart();
|
|
161
|
+
}, [style, className]);
|
|
162
|
+
|
|
163
|
+
var finallyStyle = __assign({
|
|
164
|
+
width: '100%',
|
|
165
|
+
height: '100%'
|
|
166
|
+
}, style);
|
|
167
|
+
|
|
168
|
+
return react_1["default"].createElement("div", {
|
|
169
|
+
ref: function ref(node) {
|
|
170
|
+
chartDomRef.current = node;
|
|
171
|
+
},
|
|
172
|
+
style: finallyStyle,
|
|
173
|
+
className: classnames_1["default"]('react-echart', className)
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
ReactEchartCore.defaultProps = {
|
|
178
|
+
notMerge: false,
|
|
179
|
+
lazyUpdate: false,
|
|
180
|
+
style: {},
|
|
181
|
+
className: '',
|
|
182
|
+
onEvents: {},
|
|
183
|
+
opts: {}
|
|
184
|
+
};
|
|
185
|
+
exports["default"] = ReactEchartCore;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as echarts from 'echarts';
|
|
3
|
+
export declare type Opts = {
|
|
4
|
+
devicePixelRatio?: number;
|
|
5
|
+
renderer?: 'canvas' | 'svg';
|
|
6
|
+
width?: number | null | undefined | 'auto';
|
|
7
|
+
height?: number | null | undefined | 'auto';
|
|
8
|
+
locale?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface RcEchartPropsType {
|
|
11
|
+
option: echarts.EChartsOption;
|
|
12
|
+
notMerge?: boolean;
|
|
13
|
+
lazyUpdate?: boolean;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
className?: string;
|
|
16
|
+
theme?: string;
|
|
17
|
+
onEvents?: Record<string, Function>;
|
|
18
|
+
opts?: Opts;
|
|
19
|
+
}
|
|
20
|
+
declare const RcEcharts: (props: RcEchartPropsType) => JSX.Element;
|
|
21
|
+
export default RcEcharts;
|