@autobest-ui/components 2.3.0 → 2.5.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/accordion/Item.js +6 -23
- package/esm/accordion/index.js +8 -36
- package/esm/affix/PortalAffix.js +7 -11
- package/esm/affix/index.js +30 -70
- package/esm/carousel/index.js +45 -141
- package/esm/checkbox/index.js +12 -37
- package/esm/collapse/index.js +11 -49
- package/esm/confirm/index.d.ts +8 -0
- package/esm/confirm/index.js +23 -31
- package/esm/date-picker/DateEnum.js +0 -3
- package/esm/date-picker/calendar/Day.js +62 -78
- package/esm/date-picker/calendar/MonthYear.js +20 -53
- package/esm/date-picker/calendar/grid/index.js +7 -12
- package/esm/date-picker/calendar/index.js +4 -31
- package/esm/date-picker/index.js +11 -51
- package/esm/date-picker/utils.js +6 -11
- package/esm/drawer/Child.js +10 -20
- package/esm/drawer/index.js +22 -71
- package/esm/ellipsis/index.js +9 -17
- package/esm/guide/index.js +25 -63
- package/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/input-number/ControlArrow.js +0 -2
- package/esm/input-number/constants.js +2 -2
- package/esm/input-number/index.js +26 -106
- package/esm/lazy-image/index.js +10 -55
- package/esm/link-list/index.js +11 -35
- package/esm/loading/index.js +15 -42
- package/esm/loading-container/index.js +3 -6
- package/esm/loading-icon/index.js +0 -2
- package/esm/mask/index.js +6 -9
- package/esm/message/index.d.ts +44 -7
- package/esm/message/index.js +96 -111
- package/esm/message/renderMessage.d.ts +17 -0
- package/esm/message/renderMessage.js +137 -0
- package/esm/message/style/index.css +1 -1
- package/esm/modal/Title.js +5 -12
- package/esm/modal/getPopupLocation.js +5 -7
- package/esm/modal/index.js +44 -125
- package/esm/move/index.js +32 -132
- package/esm/move/range.js +6 -12
- package/esm/move/utils.js +3 -10
- package/esm/popover/index.js +9 -28
- package/esm/portal/index.js +1 -22
- package/esm/script/index.js +19 -59
- package/esm/select/index.js +28 -106
- package/esm/show-more/index.js +40 -103
- package/esm/skeleton/Item.js +1 -3
- package/esm/skeleton/index.js +5 -11
- package/esm/style.css +1 -1
- package/esm/table/body/BodyRow.js +11 -28
- package/esm/table/body/CheckIcon.js +10 -18
- package/esm/table/body/index.js +8 -12
- package/esm/table/header/CheckIcon.js +3 -11
- package/esm/table/header/HeaderCell.js +12 -33
- package/esm/table/header/HeaderRow.js +6 -17
- package/esm/table/index.js +30 -100
- package/esm/tabs/index.js +35 -118
- package/esm/tooltip/index.js +0 -4
- package/esm/trigger/align.js +6 -6
- package/esm/trigger/bottomAlign.js +33 -45
- package/esm/trigger/constants.js +0 -1
- package/esm/trigger/getPopupLocation.js +48 -68
- package/esm/trigger/index.js +52 -187
- package/esm/trigger/leftAlign.js +33 -47
- package/esm/trigger/ref.js +2 -7
- package/esm/trigger/rightAlign.js +33 -45
- package/esm/trigger/topAlign.js +33 -45
- package/esm/trigger/utils.js +28 -45
- package/lib/accordion/Item.js +6 -27
- package/lib/accordion/index.js +8 -41
- package/lib/affix/PortalAffix.js +7 -17
- package/lib/affix/index.js +30 -75
- package/lib/carousel/index.js +45 -146
- package/lib/checkbox/index.js +12 -41
- package/lib/collapse/index.js +11 -53
- package/lib/confirm/index.d.ts +8 -0
- package/lib/confirm/index.js +23 -38
- package/lib/date-picker/DateEnum.js +0 -3
- package/lib/date-picker/calendar/Day.js +62 -87
- package/lib/date-picker/calendar/MonthYear.js +20 -62
- package/lib/date-picker/calendar/grid/index.js +7 -16
- package/lib/date-picker/calendar/index.js +4 -37
- package/lib/date-picker/index.js +9 -58
- package/lib/date-picker/utils.js +6 -26
- package/lib/drawer/Child.js +10 -25
- package/lib/drawer/index.js +22 -78
- package/lib/ellipsis/index.js +9 -23
- package/lib/guide/index.js +25 -71
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -32
- package/lib/input-number/ControlArrow.js +0 -4
- package/lib/input-number/constants.js +2 -2
- package/lib/input-number/index.js +26 -114
- package/lib/lazy-image/index.js +10 -58
- package/lib/link-list/index.js +11 -40
- package/lib/loading/index.js +13 -48
- package/lib/loading-bar/index.js +0 -5
- package/lib/loading-container/index.js +3 -11
- package/lib/loading-icon/index.js +0 -7
- package/lib/mask/index.js +6 -17
- package/lib/message/index.d.ts +44 -7
- package/lib/message/index.js +97 -120
- package/lib/message/renderMessage.d.ts +17 -0
- package/lib/message/renderMessage.js +144 -0
- package/lib/message/style/index.css +1 -1
- package/lib/modal/Affix.js +0 -4
- package/lib/modal/Title.js +5 -15
- package/lib/modal/getPopupLocation.js +5 -9
- package/lib/modal/index.js +44 -135
- package/lib/move/index.js +32 -144
- package/lib/move/range.js +6 -14
- package/lib/move/utils.js +3 -12
- package/lib/popover/index.js +9 -33
- package/lib/portal/index.js +1 -25
- package/lib/script/index.js +19 -61
- package/lib/select/index.js +28 -113
- package/lib/show-more/index.js +40 -110
- package/lib/skeleton/Item.js +1 -8
- package/lib/skeleton/index.js +5 -16
- package/lib/style.css +1 -1
- package/lib/table/body/BodyRow.js +11 -33
- package/lib/table/body/CheckIcon.js +10 -22
- package/lib/table/body/index.js +8 -17
- package/lib/table/header/CheckIcon.js +3 -15
- package/lib/table/header/HeaderCell.js +12 -37
- package/lib/table/header/HeaderRow.js +6 -22
- package/lib/table/index.js +30 -107
- package/lib/tabs/index.js +35 -122
- package/lib/tooltip/index.js +0 -9
- package/lib/trigger/align.js +0 -4
- package/lib/trigger/bottomAlign.js +33 -48
- package/lib/trigger/constants.js +0 -2
- package/lib/trigger/getPopupLocation.js +48 -74
- package/lib/trigger/index.js +52 -198
- package/lib/trigger/leftAlign.js +33 -50
- package/lib/trigger/ref.js +2 -12
- package/lib/trigger/rightAlign.js +33 -48
- package/lib/trigger/topAlign.js +33 -48
- package/lib/trigger/utils.js +28 -53
- package/package.json +7 -3
package/lib/popover/index.js
CHANGED
|
@@ -1,88 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _trigger = _interopRequireDefault(require("../trigger"));
|
|
15
|
-
|
|
16
11
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
17
12
|
__assign = Object.assign || function (t) {
|
|
18
13
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
14
|
s = arguments[i];
|
|
20
|
-
|
|
21
15
|
for (var p in s) {
|
|
22
16
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
|
-
|
|
26
19
|
return t;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return __assign.apply(this, arguments);
|
|
30
22
|
};
|
|
31
|
-
|
|
32
23
|
var prefixCls = 'ab-popover';
|
|
33
|
-
|
|
34
24
|
function Popover(props) {
|
|
35
25
|
var _a;
|
|
36
|
-
|
|
37
26
|
var triggerEl = _react.default.useRef(null);
|
|
38
|
-
|
|
39
27
|
var _b = _react.default.useState({}),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
arrowStyle = _b[0],
|
|
29
|
+
setState = _b[1];
|
|
43
30
|
var cls = props.prefixCls || prefixCls;
|
|
44
|
-
|
|
45
31
|
var onHidePopup = function onHidePopup() {
|
|
46
32
|
if (triggerEl.current && triggerEl.current.hidePopup) {
|
|
47
33
|
triggerEl.current.hidePopup();
|
|
48
34
|
}
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
var onArrowStyleChange = function onArrowStyleChange(value) {
|
|
52
37
|
if (props.hiddenArrow) {
|
|
53
38
|
return;
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
setState(value);
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
var hiddenClose = props.hiddenClose,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
43
|
+
closeIcon = props.closeIcon,
|
|
44
|
+
closeClassName = props.closeClassName,
|
|
45
|
+
innerClassName = props.innerClassName,
|
|
46
|
+
tip = props.tip,
|
|
47
|
+
arrowClassName = props.arrowClassName;
|
|
66
48
|
function renderClose() {
|
|
67
49
|
if (hiddenClose) {
|
|
68
50
|
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
}
|
|
52
|
+
// 当有自定义的icon时,直接使用,样式需要完全自定义
|
|
72
53
|
if (closeIcon) {
|
|
73
54
|
return /*#__PURE__*/_react.default.cloneElement(closeIcon, {
|
|
74
55
|
onClick: onHidePopup
|
|
75
56
|
});
|
|
76
57
|
}
|
|
77
|
-
|
|
78
58
|
return /*#__PURE__*/_react.default.createElement("i", {
|
|
79
59
|
className: (0, _classnames.default)("".concat(cls, "-close"), closeClassName),
|
|
80
60
|
onClick: onHidePopup
|
|
81
61
|
}, "\xD7");
|
|
82
62
|
}
|
|
83
|
-
|
|
84
63
|
var innerClass = (0, _classnames.default)("".concat(cls, "-inner"), innerClassName, (_a = {}, _a["".concat(cls, "-inner-expand")] = !hiddenClose, _a));
|
|
85
|
-
|
|
86
64
|
function renderPopup() {
|
|
87
65
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderClose(), props.hiddenArrow ? null : /*#__PURE__*/_react.default.createElement("i", {
|
|
88
66
|
className: (0, _classnames.default)("".concat(cls, "-arrow"), arrowClassName),
|
|
@@ -91,7 +69,6 @@ function Popover(props) {
|
|
|
91
69
|
className: innerClass
|
|
92
70
|
}, tip));
|
|
93
71
|
}
|
|
94
|
-
|
|
95
72
|
return /*#__PURE__*/_react.default.createElement(_trigger.default, __assign({}, props, {
|
|
96
73
|
wrapClassName: (0, _classnames.default)("".concat(cls, "-wrap "), props.wrapClassName),
|
|
97
74
|
ref: triggerEl,
|
|
@@ -99,7 +76,6 @@ function Popover(props) {
|
|
|
99
76
|
onArrowStyleChange: onArrowStyleChange
|
|
100
77
|
}), props.children);
|
|
101
78
|
}
|
|
102
|
-
|
|
103
79
|
Popover.defaultProps = {
|
|
104
80
|
hiddenClose: true,
|
|
105
81
|
hiddenArrow: false
|
package/lib/portal/index.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
-
|
|
14
10
|
var __extends = void 0 && (void 0).__extends || function () {
|
|
15
11
|
var _extendStatics = function extendStatics(d, b) {
|
|
16
12
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -22,53 +18,38 @@ var __extends = void 0 && (void 0).__extends || function () {
|
|
|
22
18
|
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
23
19
|
}
|
|
24
20
|
};
|
|
25
|
-
|
|
26
21
|
return _extendStatics(d, b);
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
return function (d, b) {
|
|
30
24
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
31
|
-
|
|
32
25
|
_extendStatics(d, b);
|
|
33
|
-
|
|
34
26
|
function __() {
|
|
35
27
|
this.constructor = d;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
39
30
|
};
|
|
40
31
|
}();
|
|
41
|
-
|
|
42
|
-
var Portal =
|
|
43
|
-
/** @class */
|
|
44
|
-
function (_super) {
|
|
32
|
+
var Portal = /** @class */function (_super) {
|
|
45
33
|
__extends(Portal, _super);
|
|
46
|
-
|
|
47
34
|
function Portal() {
|
|
48
35
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
Portal.prototype.componentDidMount = function () {
|
|
52
38
|
this.createContainer();
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
Portal.prototype.componentDidUpdate = function (prevProps) {
|
|
56
41
|
var didUpdate = this.props.didUpdate;
|
|
57
|
-
|
|
58
42
|
if (didUpdate) {
|
|
59
43
|
didUpdate(prevProps);
|
|
60
44
|
}
|
|
61
45
|
};
|
|
62
|
-
|
|
63
46
|
Portal.prototype.componentWillUnmount = function () {
|
|
64
47
|
this.removeContainer();
|
|
65
48
|
};
|
|
66
|
-
|
|
67
49
|
Portal.prototype.createContainer = function () {
|
|
68
50
|
this.container = this.props.getContainer ? this.props.getContainer() : Portal.getContainer();
|
|
69
51
|
this.forceUpdate();
|
|
70
52
|
};
|
|
71
|
-
|
|
72
53
|
Portal.prototype.removeContainer = function () {
|
|
73
54
|
if (this.container && this.container.parentNode) {
|
|
74
55
|
try {
|
|
@@ -76,15 +57,12 @@ function (_super) {
|
|
|
76
57
|
} catch (e) {}
|
|
77
58
|
}
|
|
78
59
|
};
|
|
79
|
-
|
|
80
60
|
Portal.prototype.render = function () {
|
|
81
61
|
if (this.container) {
|
|
82
62
|
return /*#__PURE__*/_reactDom.default.createPortal(this.props.children, this.container);
|
|
83
63
|
}
|
|
84
|
-
|
|
85
64
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
86
65
|
};
|
|
87
|
-
|
|
88
66
|
Portal.getContainer = function () {
|
|
89
67
|
var element = document.createElement('div');
|
|
90
68
|
element.style.position = 'absolute';
|
|
@@ -94,9 +72,7 @@ function (_super) {
|
|
|
94
72
|
window.document.body.appendChild(element);
|
|
95
73
|
return element;
|
|
96
74
|
};
|
|
97
|
-
|
|
98
75
|
return Portal;
|
|
99
76
|
}(_react.default.Component);
|
|
100
|
-
|
|
101
77
|
var _default = Portal;
|
|
102
78
|
exports.default = _default;
|
package/lib/script/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var __extends = void 0 && (void 0).__extends || function () {
|
|
13
10
|
var _extendStatics = function extendStatics(d, b) {
|
|
14
11
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -20,23 +17,17 @@ var __extends = void 0 && (void 0).__extends || function () {
|
|
|
20
17
|
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
21
18
|
}
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
return _extendStatics(d, b);
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
return function (d, b) {
|
|
28
23
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29
|
-
|
|
30
24
|
_extendStatics(d, b);
|
|
31
|
-
|
|
32
25
|
function __() {
|
|
33
26
|
this.constructor = d;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
29
|
};
|
|
38
30
|
}();
|
|
39
|
-
|
|
40
31
|
/**
|
|
41
32
|
* 动态加入js 代码
|
|
42
33
|
* @param code
|
|
@@ -46,141 +37,109 @@ function loadScriptCode(code, url) {
|
|
|
46
37
|
if (!code) {
|
|
47
38
|
return;
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
var script = document.createElement('script');
|
|
51
41
|
script.type = 'text/javascript';
|
|
52
42
|
script.setAttribute('data-src', url);
|
|
53
|
-
|
|
54
43
|
try {
|
|
55
44
|
script.appendChild(document.createTextNode(code));
|
|
56
45
|
} catch (ex) {
|
|
57
46
|
// 兼容IE
|
|
58
47
|
script.text = code;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
document.body.appendChild(script);
|
|
62
50
|
}
|
|
63
51
|
/**
|
|
64
52
|
* 动态创建和加载js文件,比如jquery
|
|
65
53
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var Script =
|
|
69
|
-
/** @class */
|
|
70
|
-
function (_super) {
|
|
54
|
+
var Script = /** @class */function (_super) {
|
|
71
55
|
__extends(Script, _super);
|
|
72
|
-
|
|
73
56
|
function Script() {
|
|
74
57
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
75
|
-
|
|
76
58
|
_this.loadSrc = function (isRefresh, preProps) {
|
|
77
59
|
var _a = _this.props,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
url = _a.url,
|
|
61
|
+
beforeCode = _a.beforeCode,
|
|
62
|
+
cancelable = _a.cancelable,
|
|
63
|
+
onRemove = _a.onRemove;
|
|
64
|
+
// beforeCode
|
|
83
65
|
if (isRefresh || preProps.beforeCode !== beforeCode) {
|
|
84
66
|
// 这里只支持在url改变时,删除code, 并不对code进行判断来删除url的script, 原因是没有这种需求
|
|
85
67
|
if (cancelable && preProps && preProps.beforeCode !== beforeCode) {
|
|
86
68
|
var preCodeElement = document.querySelector("script[data-src='".concat(preProps.url, "']"));
|
|
87
|
-
|
|
88
69
|
if (preCodeElement && preCodeElement.remove) {
|
|
89
70
|
preCodeElement.remove();
|
|
90
71
|
}
|
|
91
|
-
|
|
92
72
|
onRemove(true, preProps.url, preProps.attributes);
|
|
93
73
|
}
|
|
94
|
-
|
|
95
74
|
loadScriptCode(beforeCode, url);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
75
|
+
}
|
|
76
|
+
// url 不变的情况下,每个组件只执行一次onLoad,onError
|
|
99
77
|
if (isRefresh || url !== preProps.url) {
|
|
100
|
-
var scriptsElement = document.querySelector("script[src='".concat(url, "']"));
|
|
101
|
-
|
|
78
|
+
var scriptsElement = document.querySelector("script[src='".concat(url, "']"));
|
|
79
|
+
// 如果已经存在, 警告, 并终止执行
|
|
102
80
|
if (scriptsElement) {
|
|
103
81
|
// eslint-disable-next-line no-console
|
|
104
82
|
console.error("Src: ".concat(url, " has been created, the corresponding callback will no longer be executed, Please use it directly"));
|
|
105
83
|
return;
|
|
106
84
|
}
|
|
107
|
-
|
|
108
85
|
if (cancelable && preProps && url !== preProps.url) {
|
|
109
86
|
var preScriptsElement = document.querySelector("script[src='".concat(preProps.url, "']"));
|
|
110
|
-
|
|
111
87
|
if (preScriptsElement && preScriptsElement.remove) {
|
|
112
88
|
preScriptsElement.remove();
|
|
113
89
|
}
|
|
114
|
-
|
|
115
90
|
onRemove(false, preProps.url, preProps.attributes);
|
|
116
91
|
}
|
|
117
|
-
|
|
118
92
|
_this.createScript();
|
|
119
93
|
}
|
|
120
94
|
};
|
|
121
|
-
|
|
122
95
|
return _this;
|
|
123
96
|
}
|
|
124
|
-
|
|
125
97
|
Script.prototype.componentDidMount = function () {
|
|
126
98
|
this.loadSrc(true);
|
|
127
99
|
};
|
|
128
|
-
|
|
129
100
|
Script.prototype.componentDidUpdate = function (prevProps) {
|
|
130
101
|
this.loadSrc(false, prevProps);
|
|
131
102
|
};
|
|
132
|
-
|
|
133
103
|
Script.prototype.componentWillUnmount = function () {
|
|
134
104
|
var _a = this.props,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
105
|
+
cancelable = _a.cancelable,
|
|
106
|
+
url = _a.url,
|
|
107
|
+
attributes = _a.attributes,
|
|
108
|
+
onRemove = _a.onRemove;
|
|
140
109
|
if (cancelable && url) {
|
|
141
110
|
var scriptsElement = document.querySelector("script[src='".concat(url, "']"));
|
|
142
|
-
|
|
143
111
|
if (scriptsElement && scriptsElement.remove) {
|
|
144
112
|
scriptsElement.remove();
|
|
145
113
|
}
|
|
146
|
-
|
|
147
114
|
onRemove(false, url, attributes);
|
|
148
115
|
}
|
|
149
116
|
};
|
|
150
|
-
|
|
151
117
|
Script.prototype.createScript = function () {
|
|
152
118
|
var _a = this.props,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
119
|
+
url = _a.url,
|
|
120
|
+
attributes = _a.attributes,
|
|
121
|
+
onCreate = _a.onCreate,
|
|
122
|
+
onLoad = _a.onLoad,
|
|
123
|
+
onError = _a.onError;
|
|
158
124
|
onCreate(url, attributes);
|
|
159
125
|
var script = document.createElement('script');
|
|
160
|
-
|
|
161
126
|
if (attributes) {
|
|
162
127
|
Object.keys(attributes).forEach(function (prop) {
|
|
163
128
|
script.setAttribute(prop, prop === 'async' || prop === 'crossOrigin' ? '' : attributes[prop]);
|
|
164
129
|
});
|
|
165
130
|
}
|
|
166
|
-
|
|
167
131
|
script.src = url;
|
|
168
|
-
|
|
169
132
|
script.onload = function () {
|
|
170
133
|
onLoad(url, attributes);
|
|
171
134
|
};
|
|
172
|
-
|
|
173
135
|
script.onerror = function () {
|
|
174
136
|
onError(url, attributes);
|
|
175
137
|
};
|
|
176
|
-
|
|
177
138
|
document.body.appendChild(script);
|
|
178
139
|
};
|
|
179
|
-
|
|
180
140
|
Script.prototype.render = function () {
|
|
181
141
|
return null;
|
|
182
142
|
};
|
|
183
|
-
|
|
184
143
|
Script.defaultProps = {
|
|
185
144
|
beforeCode: '',
|
|
186
145
|
cancelable: true,
|
|
@@ -194,6 +153,5 @@ function (_super) {
|
|
|
194
153
|
};
|
|
195
154
|
return Script;
|
|
196
155
|
}(_react.default.Component);
|
|
197
|
-
|
|
198
156
|
var _default = Script;
|
|
199
157
|
exports.default = _default;
|