rox-react-components 0.0.45 → 0.0.46
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/dist/es/Button/Button.js +46 -1
- package/dist/es/Button/index.js +5 -1
- package/dist/es/Button/styles.js +40 -1
- package/dist/es/Card/Card.js +22 -1
- package/dist/es/Card/index.js +5 -1
- package/dist/es/Card/styles.js +18 -1
- package/dist/es/Container/Container.js +20 -1
- package/dist/es/Container/index.js +5 -1
- package/dist/es/Container/styles.js +30 -1
- package/dist/es/Loading/Inner.js +13 -1
- package/dist/es/Loading/Loading.js +67 -1
- package/dist/es/Loading/dom.js +11 -1
- package/dist/es/Loading/index.js +5 -1
- package/dist/es/Loading/styles.js +80 -1
- package/dist/es/Loading/type.js +3 -1
- package/dist/es/Popup/Popup.js +112 -1
- package/dist/es/Popup/index.js +5 -1
- package/dist/es/Popup/styles.js +138 -1
- package/dist/es/ScrollView/ScrollView.js +105 -1
- package/dist/es/ScrollView/index.js +5 -1
- package/dist/es/ScrollView/styles.js +23 -1
- package/dist/es/Swiper/Swiper.js +388 -1
- package/dist/es/Swiper/index.js +5 -1
- package/dist/es/Swiper/styles.js +48 -1
- package/dist/es/hooks/useShow.js +18 -1
- package/dist/es/index.js +9 -1
- package/dist/es/utils.js +69 -1
- package/dist/index.d.ts +4 -3
- package/dist/lib/Button/Button.js +50 -1
- package/dist/lib/Button/index.js +9 -1
- package/dist/lib/Button/styles.js +44 -1
- package/dist/lib/Card/Card.js +26 -1
- package/dist/lib/Card/index.js +9 -1
- package/dist/lib/Card/styles.js +22 -1
- package/dist/lib/Container/Container.js +24 -1
- package/dist/lib/Container/index.js +9 -1
- package/dist/lib/Container/styles.js +34 -1
- package/dist/lib/Loading/Inner.js +17 -1
- package/dist/lib/Loading/Loading.js +71 -1
- package/dist/lib/Loading/dom.js +15 -1
- package/dist/lib/Loading/index.js +9 -1
- package/dist/lib/Loading/styles.js +84 -1
- package/dist/lib/Loading/type.js +5 -1
- package/dist/lib/Popup/Popup.js +116 -1
- package/dist/lib/Popup/index.js +9 -1
- package/dist/lib/Popup/styles.js +143 -1
- package/dist/lib/ScrollView/ScrollView.js +109 -1
- package/dist/lib/ScrollView/index.js +9 -1
- package/dist/lib/ScrollView/styles.js +27 -1
- package/dist/lib/Swiper/Swiper.js +392 -1
- package/dist/lib/Swiper/index.js +9 -1
- package/dist/lib/Swiper/styles.js +52 -1
- package/dist/lib/hooks/useShow.js +22 -1
- package/dist/lib/index.js +23 -1
- package/dist/lib/utils.js +73 -1
- package/package.json +58 -58
|
@@ -1 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var noImportant = require('aphrodite/no-important');
|
|
6
|
+
|
|
7
|
+
var rippleKey = {
|
|
8
|
+
to: {
|
|
9
|
+
opacity: 0,
|
|
10
|
+
transform: 'scale(2)',
|
|
11
|
+
'-webkit-transform': 'scale(2)',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
var styles = noImportant.StyleSheet.create({
|
|
15
|
+
button: {
|
|
16
|
+
border: '1px solid transparent',
|
|
17
|
+
boxSizing: 'border-box',
|
|
18
|
+
padding: '8px 20px',
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
outline: 'none',
|
|
21
|
+
':focus': {
|
|
22
|
+
outline: 'none',
|
|
23
|
+
},
|
|
24
|
+
':focus-within': {
|
|
25
|
+
outline: 'none',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
block: {
|
|
29
|
+
display: 'block',
|
|
30
|
+
width: '100%',
|
|
31
|
+
},
|
|
32
|
+
ripple: {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
borderRadius: '100%',
|
|
35
|
+
pointerEvents: 'none',
|
|
36
|
+
transform: 'scale(0)',
|
|
37
|
+
opacity: 1,
|
|
38
|
+
animationName: [rippleKey],
|
|
39
|
+
animationDuration: '0.4s',
|
|
40
|
+
animationTimingFunction: 'ease-out',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
exports.default = styles;
|
package/dist/lib/Card/Card.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var noImportant = require('aphrodite/no-important');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var styles = require('./styles.js');
|
|
9
|
+
|
|
10
|
+
var initCardProps = {
|
|
11
|
+
expand: false,
|
|
12
|
+
duration: 200,
|
|
13
|
+
};
|
|
14
|
+
var Card = function (props) {
|
|
15
|
+
var _a = tslib.__assign(tslib.__assign({}, initCardProps), props), duration = _a.duration, expand = _a.expand, children = _a.children;
|
|
16
|
+
var transitionDuration = React.useMemo(function () { return ({
|
|
17
|
+
transitionDuration: "".concat(duration, "ms"),
|
|
18
|
+
msTransitionDuration: "".concat(duration, "ms"),
|
|
19
|
+
MozTransitionDuration: "".concat(duration, "ms"),
|
|
20
|
+
WebkitTransitionDuration: "".concat(duration, "ms"),
|
|
21
|
+
}); }, [duration]);
|
|
22
|
+
return (React.createElement("div", { style: transitionDuration, className: "".concat(noImportant.css(styles.default.collapse), " ").concat(expand ? noImportant.css(styles.default.expand) : '') },
|
|
23
|
+
React.createElement("div", { className: noImportant.css(styles.default.hide0) }, children)));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.default = Card;
|
package/dist/lib/Card/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Card = require('./Card.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.default = Card.default;
|
package/dist/lib/Card/styles.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var noImportant = require('aphrodite/no-important');
|
|
6
|
+
|
|
7
|
+
var styles = noImportant.StyleSheet.create({
|
|
8
|
+
collapse: {
|
|
9
|
+
display: 'grid',
|
|
10
|
+
gridTemplateRows: '0fr',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
outline: 'none'
|
|
13
|
+
},
|
|
14
|
+
expand: {
|
|
15
|
+
gridTemplateRows: '1fr',
|
|
16
|
+
},
|
|
17
|
+
hide0: {
|
|
18
|
+
minHeight: 0,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.default = styles;
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var noImportant = require('aphrodite/no-important');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var styles = require('./styles.js');
|
|
9
|
+
|
|
10
|
+
var initContainerProps = {
|
|
11
|
+
ratio: 1,
|
|
12
|
+
};
|
|
13
|
+
var Container = function (_props) {
|
|
14
|
+
var _a = tslib.__assign(tslib.__assign({}, initContainerProps), _props), ratio = _a.ratio, children = _a.children;
|
|
15
|
+
var pb = React.useMemo(function () {
|
|
16
|
+
if (ratio === undefined || ratio === null || ratio <= 0)
|
|
17
|
+
return '100%';
|
|
18
|
+
return 100 / ratio + '%';
|
|
19
|
+
}, [ratio]);
|
|
20
|
+
return (React.createElement("div", { className: noImportant.css(styles.default.relative, styles.default.w_full, styles.default.h_0, styles.default.border_box), style: { paddingBottom: pb } },
|
|
21
|
+
React.createElement("div", { className: noImportant.css(styles.default.absolute, styles.default.top_0, styles.default.left_0, styles.default.w_full, styles.default.h_full) }, children)));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.default = Container;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Container = require('./Container.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.default = Container.default;
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var noImportant = require('aphrodite/no-important');
|
|
6
|
+
|
|
7
|
+
var styles = noImportant.StyleSheet.create({
|
|
8
|
+
relative: {
|
|
9
|
+
position: 'relative',
|
|
10
|
+
},
|
|
11
|
+
absolute: {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
},
|
|
14
|
+
top_0: {
|
|
15
|
+
top: '0px',
|
|
16
|
+
},
|
|
17
|
+
left_0: {
|
|
18
|
+
left: '0px',
|
|
19
|
+
},
|
|
20
|
+
w_full: {
|
|
21
|
+
width: '100%',
|
|
22
|
+
},
|
|
23
|
+
h_full: {
|
|
24
|
+
height: '100%',
|
|
25
|
+
},
|
|
26
|
+
h_0: {
|
|
27
|
+
height: '0px',
|
|
28
|
+
},
|
|
29
|
+
border_box: {
|
|
30
|
+
boxSizing: 'border-box',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
exports.default = styles;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var noImportant = require('aphrodite/no-important');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var styles = require('./styles.js');
|
|
9
|
+
var type = require('./type.js');
|
|
10
|
+
|
|
11
|
+
var arr = [{ delay: '0s' }, { delay: '-1.1s' }, { delay: '-1.0s' }, { delay: '-0.9s' }, { delay: '-0.8s' }];
|
|
12
|
+
var Inner = function (props) {
|
|
13
|
+
var style = tslib.__assign(tslib.__assign({}, type.initLoadingStyle), props.style);
|
|
14
|
+
return (React.createElement("div", { className: noImportant.css(styles.default.inner_box), style: { '--width': style.width, '--height': style.height, '--bg': style.bg, '--margin': style.margin } }, arr.map(function (item, i) { return (React.createElement("div", { key: i, style: { '--delay': item.delay }, className: noImportant.css(styles.default.inner_box_item) })); })));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.default = Inner;
|
|
@@ -1 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var noImportant = require('aphrodite/no-important');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var client = require('react-dom/client');
|
|
9
|
+
var Inner = require('./Inner.js');
|
|
10
|
+
var dom = require('./dom.js');
|
|
11
|
+
var styles = require('./styles.js');
|
|
12
|
+
|
|
13
|
+
var Loading = /** @class */ (function (_super) {
|
|
14
|
+
tslib.__extends(Loading, _super);
|
|
15
|
+
function Loading() {
|
|
16
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
17
|
+
_this.state = {};
|
|
18
|
+
return _this;
|
|
19
|
+
}
|
|
20
|
+
Loading.show = function (options) {
|
|
21
|
+
if (Loading.el)
|
|
22
|
+
return;
|
|
23
|
+
Loading.el = document.createElement('div');
|
|
24
|
+
dom.default.addClass(Loading.el, noImportant.css(styles.default.fixed));
|
|
25
|
+
dom.default.addClass(document.body, noImportant.css(styles.default.page_hide));
|
|
26
|
+
document.body.appendChild(Loading.el);
|
|
27
|
+
client.createRoot(Loading.el).render(React.createElement(Loading, tslib.__assign({}, options, { children: null, visible: true })));
|
|
28
|
+
};
|
|
29
|
+
Loading.hide = function () {
|
|
30
|
+
try {
|
|
31
|
+
dom.default.removeClass(document.body, noImportant.css(styles.default.page_hide));
|
|
32
|
+
if (!Loading.el)
|
|
33
|
+
return;
|
|
34
|
+
document.body.removeChild(Loading.el);
|
|
35
|
+
Loading.el = null;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
dom.default.removeClass(document.body, noImportant.css(styles.default.page_hide));
|
|
39
|
+
Loading.el = null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
Loading.prototype.render = function () {
|
|
43
|
+
var _a = this.props, visible = _a.visible, bg = _a.bg, customLoading = _a.customLoading, loadingStyle = _a.loadingStyle, children = _a.children;
|
|
44
|
+
return (React.createElement("div", { className: noImportant.css(styles.default.relative, styles.default.w_full, styles.default.h_full, styles.default.border_box) },
|
|
45
|
+
children,
|
|
46
|
+
visible ? (React.createElement("div", { className: noImportant.css(styles.default.absolute, styles.default.top_0, styles.default.left_0, styles.default.w_full, styles.default.h_full, styles.default.z_99, styles.default.center), style: { backgroundColor: bg } }, customLoading || React.createElement(Inner.default, { style: loadingStyle }))) : null));
|
|
47
|
+
};
|
|
48
|
+
Loading.getDerivedStateFromProps = function (props, state) {
|
|
49
|
+
// console.log('getDerivedStateFromProps', props, state)
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
Loading.prototype.getSnapshotBeforeUpdate = function (prevProps, prevState) {
|
|
53
|
+
// console.log('getSnapshotBeforeUpdate', prevProps, prevState)
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
Loading.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) { };
|
|
57
|
+
Loading.prototype.componentWillUnmount = function () {
|
|
58
|
+
// console.log('componentWillUnmount')
|
|
59
|
+
Loading.hide();
|
|
60
|
+
};
|
|
61
|
+
Loading.defaultProps = {
|
|
62
|
+
visible: true,
|
|
63
|
+
bg: 'rgba(0,0,0,.7)',
|
|
64
|
+
customLoading: null,
|
|
65
|
+
loadingStyle: {},
|
|
66
|
+
};
|
|
67
|
+
Loading.el = null;
|
|
68
|
+
return Loading;
|
|
69
|
+
}(React.Component));
|
|
70
|
+
|
|
71
|
+
exports.default = Loading;
|
package/dist/lib/Loading/dom.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function addClass(el, cls) {
|
|
6
|
+
if (el.classList.contains(cls))
|
|
7
|
+
return;
|
|
8
|
+
el.classList.add(cls);
|
|
9
|
+
}
|
|
10
|
+
function removeClass(el, cls) {
|
|
11
|
+
el.classList.remove(cls);
|
|
12
|
+
}
|
|
13
|
+
var dom = { addClass: addClass, removeClass: removeClass };
|
|
14
|
+
|
|
15
|
+
exports.default = dom;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Loading = require('./Loading.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.default = Loading.default;
|
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var noImportant = require('aphrodite/no-important');
|
|
6
|
+
|
|
7
|
+
var keys = {
|
|
8
|
+
'0%, 40%, 100%': {
|
|
9
|
+
transform: 'scaleY(0.4)',
|
|
10
|
+
'-webkit-transform': 'scaleY(0.4)',
|
|
11
|
+
},
|
|
12
|
+
'20%': {
|
|
13
|
+
transform: 'scaleY(1.0)',
|
|
14
|
+
'-webkit-transform': 'scaleY(1.0)',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
var styles = noImportant.StyleSheet.create({
|
|
18
|
+
relative: {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
},
|
|
21
|
+
center: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
},
|
|
26
|
+
absolute: {
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
},
|
|
29
|
+
top_0: {
|
|
30
|
+
top: '0px',
|
|
31
|
+
},
|
|
32
|
+
left_0: {
|
|
33
|
+
left: '0px',
|
|
34
|
+
},
|
|
35
|
+
w_full: {
|
|
36
|
+
width: '100%',
|
|
37
|
+
},
|
|
38
|
+
h_full: {
|
|
39
|
+
height: '100%',
|
|
40
|
+
},
|
|
41
|
+
border_box: {
|
|
42
|
+
boxSizing: 'border-box',
|
|
43
|
+
},
|
|
44
|
+
z_99: {
|
|
45
|
+
zIndex: 99,
|
|
46
|
+
},
|
|
47
|
+
inner_box: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
width: '100%',
|
|
50
|
+
height: '100%',
|
|
51
|
+
textAlign: 'center',
|
|
52
|
+
fontSize: '10px',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
},
|
|
56
|
+
inner_box_item: {
|
|
57
|
+
height: 'var(--height)',
|
|
58
|
+
width: 'var(--width)',
|
|
59
|
+
margin: 'var(--margin)',
|
|
60
|
+
backgroundColor: 'var(--bg)',
|
|
61
|
+
animationName: [keys],
|
|
62
|
+
animationDelay: 'var(--delay)',
|
|
63
|
+
animationDuration: '1.2s',
|
|
64
|
+
animationIterationCount: 'infinite',
|
|
65
|
+
},
|
|
66
|
+
fixed: {
|
|
67
|
+
position: 'fixed',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
top: '0',
|
|
72
|
+
left: '0',
|
|
73
|
+
width: '100%',
|
|
74
|
+
height: '100%',
|
|
75
|
+
zIndex: 99,
|
|
76
|
+
},
|
|
77
|
+
page_hide: {
|
|
78
|
+
width: '100%',
|
|
79
|
+
height: '100%',
|
|
80
|
+
overflow: 'hidden',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
exports.default = styles;
|
package/dist/lib/Loading/type.js
CHANGED
package/dist/lib/Popup/Popup.js
CHANGED
|
@@ -1 +1,116 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactDom = require('react-dom');
|
|
8
|
+
var noImportant = require('aphrodite/no-important');
|
|
9
|
+
var styles = require('./styles.js');
|
|
10
|
+
|
|
11
|
+
var initPopupProps = {
|
|
12
|
+
visible: false,
|
|
13
|
+
position: 'bottom',
|
|
14
|
+
duration: 200,
|
|
15
|
+
bg: 'rgba(0,0,0,.35)',
|
|
16
|
+
maskClosable: true,
|
|
17
|
+
popupType: 'fade',
|
|
18
|
+
onClose: function () { return null; },
|
|
19
|
+
contentClassName: '',
|
|
20
|
+
contentStyle: {},
|
|
21
|
+
scale: [0.2],
|
|
22
|
+
curve: 'linear'
|
|
23
|
+
};
|
|
24
|
+
function _Popup(props) {
|
|
25
|
+
var bg = props.bg, visible = props.visible, duration = props.duration, inject = props.inject, dispose = props.dispose, maskClosable = props.maskClosable, onClose = props.onClose, children = props.children, position = props.position, contentStyle = props.contentStyle, contentClassName = props.contentClassName, popupType = props.popupType, scale = props.scale, curve = props.curve;
|
|
26
|
+
var _a = React.useState(visible), tweenAnimation = _a[0], setTweenAnimation = _a[1];
|
|
27
|
+
var _b = React.useState(false), show = _b[0], setShow = _b[1];
|
|
28
|
+
React.useEffect(function () {
|
|
29
|
+
setTweenAnimation(visible);
|
|
30
|
+
if (visible) {
|
|
31
|
+
dispose();
|
|
32
|
+
inject();
|
|
33
|
+
setShow(true);
|
|
34
|
+
}
|
|
35
|
+
}, [visible]);
|
|
36
|
+
React.useEffect(function () {
|
|
37
|
+
return function () {
|
|
38
|
+
setShow(false);
|
|
39
|
+
dispose();
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
var handleMaskClick = React.useCallback(function () {
|
|
43
|
+
if (!maskClosable)
|
|
44
|
+
return;
|
|
45
|
+
setTweenAnimation(false);
|
|
46
|
+
}, [maskClosable]);
|
|
47
|
+
var handleAnimationEnd = React.useCallback(function () {
|
|
48
|
+
if (!tweenAnimation) {
|
|
49
|
+
setShow(false);
|
|
50
|
+
onClose();
|
|
51
|
+
dispose();
|
|
52
|
+
}
|
|
53
|
+
}, [tweenAnimation, onClose]);
|
|
54
|
+
var containerStyle = React.useMemo(function () {
|
|
55
|
+
if (position === 'bottom') {
|
|
56
|
+
return { justifyContent: 'center', alignItems: 'flex-end' };
|
|
57
|
+
}
|
|
58
|
+
if (position === 'top') {
|
|
59
|
+
return { justifyContent: 'center', alignItems: 'flex-start' };
|
|
60
|
+
}
|
|
61
|
+
if (position === 'left') {
|
|
62
|
+
return { justifyContent: 'flex-start', alignItems: 'center' };
|
|
63
|
+
}
|
|
64
|
+
if (position === 'right') {
|
|
65
|
+
return { justifyContent: 'flex-end', alignItems: 'center' };
|
|
66
|
+
}
|
|
67
|
+
if (position === 'center') {
|
|
68
|
+
return { justifyContent: 'center', alignItems: 'center' };
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
}, [position]);
|
|
72
|
+
var contentAnimationName = React.useMemo(function () {
|
|
73
|
+
if (popupType === 'slide') {
|
|
74
|
+
if (position === 'top')
|
|
75
|
+
return tweenAnimation ? styles.default.slide_in_top : styles.default.slide_out_top;
|
|
76
|
+
if (position === 'bottom')
|
|
77
|
+
return tweenAnimation ? styles.default.slide_in_bottom : styles.default.slide_out_bottom;
|
|
78
|
+
if (position === 'left')
|
|
79
|
+
return tweenAnimation ? styles.default.slide_in_left : styles.default.slide_out_left;
|
|
80
|
+
if (position === 'right')
|
|
81
|
+
return tweenAnimation ? styles.default.slide_in_right : styles.default.slide_out_right;
|
|
82
|
+
}
|
|
83
|
+
else if (popupType === 'scale') {
|
|
84
|
+
if (Array.isArray(scale) && scale.length >= 1) {
|
|
85
|
+
var styles_1 = styles.animateStyles(scale);
|
|
86
|
+
return tweenAnimation ? styles_1.scale_in : styles_1.scale_out;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return tweenAnimation ? styles.default.fade_in : styles.default.fade_out;
|
|
90
|
+
}, [popupType, position, tweenAnimation, scale]);
|
|
91
|
+
if (!show)
|
|
92
|
+
return null;
|
|
93
|
+
return (React.createElement("div", { style: tslib.__assign({ '--bg': bg, '--duration': duration + 'ms', '--curve': curve }, containerStyle), className: noImportant.css(styles.default.container) },
|
|
94
|
+
React.createElement("div", { onClick: handleMaskClick, onAnimationEnd: handleAnimationEnd, className: noImportant.css(styles.default.mask, styles.default.animation_properties, tweenAnimation ? styles.default.fade_in : styles.default.fade_out) }),
|
|
95
|
+
React.createElement("div", { style: contentStyle, className: "".concat(contentClassName, " ").concat(noImportant.css(styles.default.animation_properties, contentAnimationName)) }, children)));
|
|
96
|
+
}
|
|
97
|
+
function Popup(_props) {
|
|
98
|
+
var props = tslib.__assign(tslib.__assign({}, initPopupProps), _props);
|
|
99
|
+
var container = React.useRef(document.createElement('div'));
|
|
100
|
+
var injectBody = React.useCallback(function () {
|
|
101
|
+
document.body.appendChild(container.current);
|
|
102
|
+
}, []);
|
|
103
|
+
var dispose = React.useCallback(function () {
|
|
104
|
+
try {
|
|
105
|
+
document.body.removeChild(container.current);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
}
|
|
109
|
+
}, []);
|
|
110
|
+
React.useEffect(function () {
|
|
111
|
+
return function () { return dispose(); };
|
|
112
|
+
}, []);
|
|
113
|
+
return reactDom.createPortal(React.createElement(_Popup, tslib.__assign({}, props, { inject: injectBody, dispose: dispose })), container.current);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
exports.default = Popup;
|
package/dist/lib/Popup/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Popup = require('./Popup.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.default = Popup.default;
|