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
package/dist/es/Popup/styles.js
CHANGED
|
@@ -1 +1,138 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
import { StyleSheet } from 'aphrodite/no-important';
|
|
3
|
+
|
|
4
|
+
function createFade(_in) {
|
|
5
|
+
var start = _in ? 0 : 1;
|
|
6
|
+
var end = _in ? 1 : 0;
|
|
7
|
+
return {
|
|
8
|
+
from: {
|
|
9
|
+
opacity: start,
|
|
10
|
+
},
|
|
11
|
+
to: {
|
|
12
|
+
opacity: end
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function createVertical(_in, top) {
|
|
17
|
+
var start_y = '0', end_y = '0';
|
|
18
|
+
if (_in) {
|
|
19
|
+
start_y = top ? '-100%' : '100%';
|
|
20
|
+
end_y = '0';
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
start_y = '0';
|
|
24
|
+
end_y = top ? '-100%' : '100%';
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
from: {
|
|
28
|
+
transform: "translate3d(0, ".concat(start_y, ", 0)")
|
|
29
|
+
},
|
|
30
|
+
to: {
|
|
31
|
+
transform: "translate3d(0, ".concat(end_y, ", 0)")
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createHorizontal(_in, left) {
|
|
36
|
+
var start_x = '0', end_x = '0';
|
|
37
|
+
if (_in) {
|
|
38
|
+
start_x = left ? '-100%' : '100%';
|
|
39
|
+
end_x = '0';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
start_x = '0';
|
|
43
|
+
end_x = left ? '-100%' : '100%';
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
from: {
|
|
47
|
+
transform: "translate3d(".concat(start_x, ", 0, 0)")
|
|
48
|
+
},
|
|
49
|
+
to: {
|
|
50
|
+
transform: "translate3d(".concat(end_x, ", 0, 0)")
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var styles = StyleSheet.create({
|
|
55
|
+
container: {
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
display: 'flex',
|
|
58
|
+
width: '100%',
|
|
59
|
+
height: '100%',
|
|
60
|
+
top: 0,
|
|
61
|
+
left: 0,
|
|
62
|
+
zIndex: 99,
|
|
63
|
+
},
|
|
64
|
+
mask: {
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
top: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%',
|
|
70
|
+
zIndex: -10,
|
|
71
|
+
backgroundColor: 'var(--bg)',
|
|
72
|
+
},
|
|
73
|
+
animation_properties: {
|
|
74
|
+
animationFillMode: 'forwards',
|
|
75
|
+
animationTimingFunction: 'var(--curve)',
|
|
76
|
+
animationDuration: 'var(--duration)',
|
|
77
|
+
},
|
|
78
|
+
fade_in: {
|
|
79
|
+
animationName: [createFade(true)],
|
|
80
|
+
},
|
|
81
|
+
fade_out: {
|
|
82
|
+
animationName: [createFade(false)],
|
|
83
|
+
},
|
|
84
|
+
slide_in_top: {
|
|
85
|
+
animationName: [createVertical(true, true)]
|
|
86
|
+
},
|
|
87
|
+
slide_out_top: {
|
|
88
|
+
animationName: [createVertical(false, true)]
|
|
89
|
+
},
|
|
90
|
+
slide_in_right: {
|
|
91
|
+
animationName: [createHorizontal(true, false)]
|
|
92
|
+
},
|
|
93
|
+
slide_out_right: {
|
|
94
|
+
animationName: [createHorizontal(false, false)]
|
|
95
|
+
},
|
|
96
|
+
slide_in_bottom: {
|
|
97
|
+
animationName: [createVertical(true, false)]
|
|
98
|
+
},
|
|
99
|
+
slide_out_bottom: {
|
|
100
|
+
animationName: [createVertical(false, false)]
|
|
101
|
+
},
|
|
102
|
+
slide_in_left: {
|
|
103
|
+
animationName: [createHorizontal(true, true)]
|
|
104
|
+
},
|
|
105
|
+
slide_out_left: {
|
|
106
|
+
animationName: [createHorizontal(false, true)]
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
var animateStyles = function (scale) {
|
|
110
|
+
var _scale = scale[scale.length - 1] === 1 ? scale.slice(0, -1) : scale;
|
|
111
|
+
var scaleIn = {};
|
|
112
|
+
var scaleOut = {};
|
|
113
|
+
if (_scale.length) {
|
|
114
|
+
var step_1 = 100 / _scale.length;
|
|
115
|
+
scaleIn = __assign(__assign({}, generateKeyFrame({ step: '0%', value: _scale[0] })), generateKeyFrame({ step: '100%', value: 1 }));
|
|
116
|
+
scaleOut = __assign(__assign({}, generateKeyFrame({ step: '0%', value: 1 })), generateKeyFrame({ step: '100%', value: _scale[0] }));
|
|
117
|
+
_scale.forEach(function (item, index) {
|
|
118
|
+
if (index > 0) {
|
|
119
|
+
Object.assign(scaleIn, generateKeyFrame({ step: "".concat(step_1 * index, "%"), value: item }));
|
|
120
|
+
Object.assign(scaleOut, generateKeyFrame({ step: "".concat(step_1 * (scale.length - index), "%"), value: item }));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return StyleSheet.create({
|
|
125
|
+
scale_in: {
|
|
126
|
+
animationName: [scaleIn]
|
|
127
|
+
},
|
|
128
|
+
scale_out: {
|
|
129
|
+
animationName: [scaleOut]
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
function generateKeyFrame(data) {
|
|
134
|
+
var _a;
|
|
135
|
+
return _a = {}, _a[data.step] = { transform: "scale3d(".concat(data.value, ", ").concat(data.value, ", 1)") }, _a;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { animateStyles, styles as default };
|
|
@@ -1 +1,105 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
import { css } from 'aphrodite/no-important';
|
|
3
|
+
import React, { forwardRef, useRef, useMemo, useCallback, useImperativeHandle } from 'react';
|
|
4
|
+
import utils from '../utils.js';
|
|
5
|
+
import styles from './styles.js';
|
|
6
|
+
|
|
7
|
+
var keyframe = 60;
|
|
8
|
+
var initScrollViewProps = {
|
|
9
|
+
style: { width: '100%', height: '100%' },
|
|
10
|
+
horizontal: false,
|
|
11
|
+
vertical: true,
|
|
12
|
+
onScroll: function () { return null; },
|
|
13
|
+
threshold: 50,
|
|
14
|
+
onReachTop: function (done) { return done(); },
|
|
15
|
+
onReachBottom: function (done) { return done(); },
|
|
16
|
+
onReachLeft: function (done) { return done(); },
|
|
17
|
+
onReachRight: function (done) { return done(); },
|
|
18
|
+
};
|
|
19
|
+
var initScrollPosition = {
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
animation: false,
|
|
23
|
+
};
|
|
24
|
+
function ScrollView(props, ref) {
|
|
25
|
+
if (props === void 0) { props = initScrollViewProps; }
|
|
26
|
+
var _a = __assign(__assign({}, initScrollViewProps), props), style = _a.style, children = _a.children, horizontal = _a.horizontal, vertical = _a.vertical, onScroll = _a.onScroll, threshold = _a.threshold, onReachTop = _a.onReachTop, onReachBottom = _a.onReachBottom, onReachLeft = _a.onReachLeft, onReachRight = _a.onReachRight;
|
|
27
|
+
var scroll_el = useRef(null);
|
|
28
|
+
var start_y = useRef(0);
|
|
29
|
+
var start_x = useRef(0);
|
|
30
|
+
var triggerred_top = useRef(false); // 是否触发过事件了
|
|
31
|
+
var triggerred_bottom = useRef(false); // 是否触发过事件了
|
|
32
|
+
var triggerred_left = useRef(false); // 是否触发过事件了
|
|
33
|
+
var triggerred_right = useRef(false); // 是否触发过事件了
|
|
34
|
+
var container_box_style = useMemo(function () { return (__assign(__assign({}, initScrollViewProps.style), style)); }, [style]);
|
|
35
|
+
var scroll_box_style = useMemo(function () { return ({
|
|
36
|
+
overflowX: horizontal ? 'scroll' : 'hidden',
|
|
37
|
+
overflowY: vertical ? 'scroll' : 'hidden',
|
|
38
|
+
scrollbarWidth: 'none',
|
|
39
|
+
msOverflowStyle: 'none',
|
|
40
|
+
}); }, [horizontal, vertical]);
|
|
41
|
+
var onVerticalScroll = useCallback(function (ev) {
|
|
42
|
+
var _a = ev.currentTarget, y = _a.scrollTop, boundary = _a.scrollHeight, h = _a.clientHeight;
|
|
43
|
+
if (y > start_y.current) {
|
|
44
|
+
if (y + h >= boundary - threshold && !triggerred_bottom.current) {
|
|
45
|
+
triggerred_bottom.current = true;
|
|
46
|
+
onReachBottom(function () { return utils.sleep(keyframe).then(function () { return (triggerred_bottom.current = false); }); });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (y < start_y.current) {
|
|
50
|
+
if (y <= 0 && !triggerred_top.current) {
|
|
51
|
+
triggerred_top.current = true;
|
|
52
|
+
onReachTop(function () { return utils.sleep(keyframe).then(function () { return (triggerred_top.current = false); }); });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
start_y.current = y;
|
|
56
|
+
}, [threshold, onReachBottom, onReachTop]);
|
|
57
|
+
var onHorizontalScroll = useCallback(function (ev) {
|
|
58
|
+
var _a = ev.currentTarget, x = _a.scrollLeft, boundary = _a.scrollWidth, w = _a.clientWidth;
|
|
59
|
+
if (x > start_x.current) {
|
|
60
|
+
if (x + w >= boundary - threshold && !triggerred_right.current) {
|
|
61
|
+
triggerred_right.current = true;
|
|
62
|
+
onReachRight(function () { return utils.sleep(keyframe).then(function () { return (triggerred_right.current = false); }); });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (x < start_x.current) {
|
|
66
|
+
if (x <= 0 && !triggerred_left.current) {
|
|
67
|
+
triggerred_left.current = true;
|
|
68
|
+
onReachLeft(function () { return utils.sleep(keyframe).then(function () { return (triggerred_left.current = false); }); });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
start_x.current = x;
|
|
72
|
+
}, [threshold, onReachLeft, onReachRight]);
|
|
73
|
+
var onBothScroll = useCallback(function (ev) {
|
|
74
|
+
onHorizontalScroll(ev);
|
|
75
|
+
onVerticalScroll(ev);
|
|
76
|
+
}, [onHorizontalScroll, onVerticalScroll]);
|
|
77
|
+
var handleScroll = useCallback(function (ev) {
|
|
78
|
+
var _a = ev.currentTarget, y = _a.scrollTop, x = _a.scrollLeft;
|
|
79
|
+
onScroll({ x: x, y: y });
|
|
80
|
+
if (horizontal && vertical) {
|
|
81
|
+
onBothScroll(ev);
|
|
82
|
+
}
|
|
83
|
+
else if (horizontal) {
|
|
84
|
+
onHorizontalScroll(ev);
|
|
85
|
+
}
|
|
86
|
+
else if (vertical) {
|
|
87
|
+
onVerticalScroll(ev);
|
|
88
|
+
}
|
|
89
|
+
}, [horizontal, vertical, onScroll, onHorizontalScroll, onVerticalScroll, onBothScroll]);
|
|
90
|
+
useImperativeHandle(ref, function () { return ({
|
|
91
|
+
to: function (pos) {
|
|
92
|
+
if (pos === void 0) { pos = initScrollPosition; }
|
|
93
|
+
if (scroll_el.current) {
|
|
94
|
+
var _a = __assign(__assign({}, initScrollPosition), pos), x = _a.x, y = _a.y, animation = _a.animation;
|
|
95
|
+
scroll_el.current.scrollTo({ left: x, top: y, behavior: animation ? 'smooth' : 'auto' });
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
}); }, []);
|
|
99
|
+
return (React.createElement("div", { style: container_box_style, className: css(styles.border_box) },
|
|
100
|
+
React.createElement("div", { className: css(styles.w_full, styles.h_full, styles.border_box) },
|
|
101
|
+
React.createElement("div", { ref: scroll_el, onScroll: handleScroll, style: scroll_box_style, className: css(styles.border_box, styles.w_full, styles.h_full, styles.scroll_bar_hide) }, children))));
|
|
102
|
+
}
|
|
103
|
+
var ScrollView$1 = forwardRef(ScrollView);
|
|
104
|
+
|
|
105
|
+
export { ScrollView$1 as default };
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
import{StyleSheet
|
|
1
|
+
import { StyleSheet } from 'aphrodite/no-important';
|
|
2
|
+
|
|
3
|
+
var styles = StyleSheet.create({
|
|
4
|
+
border_box: {
|
|
5
|
+
boxSizing: 'border-box',
|
|
6
|
+
},
|
|
7
|
+
w_full: {
|
|
8
|
+
width: '100%',
|
|
9
|
+
},
|
|
10
|
+
h_full: {
|
|
11
|
+
height: '100%',
|
|
12
|
+
},
|
|
13
|
+
scroll_bar_hide: {
|
|
14
|
+
'scrollbar-width': 'none', // firefox
|
|
15
|
+
'-ms-overflow-style': 'none', // ie and edge
|
|
16
|
+
'::-webkit-scrollbar': {
|
|
17
|
+
// chrome、safari and opera
|
|
18
|
+
display: 'none',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { styles as default };
|