rox-react-components 0.0.44 → 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.
Files changed (56) hide show
  1. package/dist/es/Button/Button.js +46 -1
  2. package/dist/es/Button/index.js +5 -1
  3. package/dist/es/Button/styles.js +40 -1
  4. package/dist/es/Card/Card.js +22 -1
  5. package/dist/es/Card/index.js +5 -1
  6. package/dist/es/Card/styles.js +18 -1
  7. package/dist/es/Container/Container.js +20 -1
  8. package/dist/es/Container/index.js +5 -1
  9. package/dist/es/Container/styles.js +30 -1
  10. package/dist/es/Loading/Inner.js +13 -1
  11. package/dist/es/Loading/Loading.js +67 -1
  12. package/dist/es/Loading/dom.js +11 -1
  13. package/dist/es/Loading/index.js +5 -1
  14. package/dist/es/Loading/styles.js +80 -1
  15. package/dist/es/Loading/type.js +3 -1
  16. package/dist/es/Popup/Popup.js +112 -1
  17. package/dist/es/Popup/index.js +5 -1
  18. package/dist/es/Popup/styles.js +138 -1
  19. package/dist/es/ScrollView/ScrollView.js +105 -1
  20. package/dist/es/ScrollView/index.js +5 -1
  21. package/dist/es/ScrollView/styles.js +23 -1
  22. package/dist/es/Swiper/Swiper.js +388 -1
  23. package/dist/es/Swiper/index.js +5 -1
  24. package/dist/es/Swiper/styles.js +48 -1
  25. package/dist/es/hooks/useShow.js +18 -1
  26. package/dist/es/index.js +9 -1
  27. package/dist/es/utils.js +69 -1
  28. package/dist/index.d.ts +4 -3
  29. package/dist/lib/Button/Button.js +50 -1
  30. package/dist/lib/Button/index.js +9 -1
  31. package/dist/lib/Button/styles.js +44 -1
  32. package/dist/lib/Card/Card.js +26 -1
  33. package/dist/lib/Card/index.js +9 -1
  34. package/dist/lib/Card/styles.js +22 -1
  35. package/dist/lib/Container/Container.js +24 -1
  36. package/dist/lib/Container/index.js +9 -1
  37. package/dist/lib/Container/styles.js +34 -1
  38. package/dist/lib/Loading/Inner.js +17 -1
  39. package/dist/lib/Loading/Loading.js +71 -1
  40. package/dist/lib/Loading/dom.js +15 -1
  41. package/dist/lib/Loading/index.js +9 -1
  42. package/dist/lib/Loading/styles.js +84 -1
  43. package/dist/lib/Loading/type.js +5 -1
  44. package/dist/lib/Popup/Popup.js +116 -1
  45. package/dist/lib/Popup/index.js +9 -1
  46. package/dist/lib/Popup/styles.js +143 -1
  47. package/dist/lib/ScrollView/ScrollView.js +109 -1
  48. package/dist/lib/ScrollView/index.js +9 -1
  49. package/dist/lib/ScrollView/styles.js +27 -1
  50. package/dist/lib/Swiper/Swiper.js +392 -1
  51. package/dist/lib/Swiper/index.js +9 -1
  52. package/dist/lib/Swiper/styles.js +52 -1
  53. package/dist/lib/hooks/useShow.js +22 -1
  54. package/dist/lib/index.js +23 -1
  55. package/dist/lib/utils.js +73 -1
  56. package/package.json +58 -58
@@ -1 +1,138 @@
1
- import{__assign as t}from"tslib";import{StyleSheet as a}from"aphrodite/no-important";function n(t){return{from:{opacity:t?0:1},to:{opacity:t?1:0}}}function i(t,a){var n="0",i="0";return t?(n=a?"-100%":"100%",i="0"):(n="0",i=a?"-100%":"100%"),{from:{transform:"translate3d(0, ".concat(n,", 0)")},to:{transform:"translate3d(0, ".concat(i,", 0)")}}}function o(t,a){var n="0",i="0";return t?(n=a?"-100%":"100%",i="0"):(n="0",i=a?"-100%":"100%"),{from:{transform:"translate3d(".concat(n,", 0, 0)")},to:{transform:"translate3d(".concat(i,", 0, 0)")}}}var e=a.create({container:{position:"absolute",display:"flex",width:"100%",height:"100%",top:0,left:0,zIndex:99},mask:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:-10,backgroundColor:"var(--bg)"},animation_properties:{animationFillMode:"forwards",animationTimingFunction:"var(--curve)",animationDuration:"var(--duration)"},fade_in:{animationName:[n(!0)]},fade_out:{animationName:[n(!1)]},slide_in_top:{animationName:[i(!0,!0)]},slide_out_top:{animationName:[i(!1,!0)]},slide_in_right:{animationName:[o(!0,!1)]},slide_out_right:{animationName:[o(!1,!1)]},slide_in_bottom:{animationName:[i(!0,!1)]},slide_out_bottom:{animationName:[i(!1,!1)]},slide_in_left:{animationName:[o(!0,!0)]},slide_out_left:{animationName:[o(!1,!0)]}}),r=function(n){var i=1===n[n.length-1]?n.slice(0,-1):n,o={},e={};if(i.length){var r=100/i.length;o=t(t({},m({step:"0%",value:i[0]})),m({step:"100%",value:1})),e=t(t({},m({step:"0%",value:1})),m({step:"100%",value:i[0]})),i.forEach((function(t,a){a>0&&(Object.assign(o,m({step:"".concat(r*a,"%"),value:t})),Object.assign(e,m({step:"".concat(r*(n.length-a),"%"),value:t})))}))}return a.create({scale_in:{animationName:[o]},scale_out:{animationName:[e]}})};function m(t){var a;return(a={})[t.step]={transform:"scale3d(".concat(t.value,", ").concat(t.value,", 1)")},a}export{r as animateStyles,e as default};
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{__assign as r}from"tslib";import{css as t}from"aphrodite/no-important";import n,{forwardRef as e,useRef as o,useMemo as c,useCallback as l,useImperativeHandle as u}from"react";import i from"../utils.js";import a from"./styles.js";var f={style:{width:"100%",height:"100%"},horizontal:!1,vertical:!0,onScroll:function(){return null},threshold:50,onReachTop:function(r){return r()},onReachBottom:function(r){return r()},onReachLeft:function(r){return r()},onReachRight:function(r){return r()}},h={x:0,y:0,animation:!1};var s=e((function(e,s){void 0===e&&(e=f);var m=r(r({},f),e),d=m.style,v=m.children,p=m.horizontal,b=m.vertical,y=m.onScroll,R=m.threshold,_=m.onReachTop,g=m.onReachBottom,T=m.onReachLeft,x=m.onReachRight,w=o(null),L=o(0),S=o(0),E=o(!1),N=o(!1),W=o(!1),j=o(!1),z=c((function(){return r(r({},f.style),d)}),[d]),B=c((function(){return{overflowX:p?"scroll":"hidden",overflowY:b?"scroll":"hidden",scrollbarWidth:"none",msOverflowStyle:"none"}}),[p,b]),H=l((function(r){var t=r.currentTarget,n=t.scrollTop,e=t.scrollHeight,o=t.clientHeight;n>L.current?n+o>=e-R&&!N.current&&(N.current=!0,g((function(){return i.sleep(60).then((function(){return N.current=!1}))}))):n<L.current&&n<=0&&!E.current&&(E.current=!0,_((function(){return i.sleep(60).then((function(){return E.current=!1}))}))),L.current=n}),[R,g,_]),O=l((function(r){var t=r.currentTarget,n=t.scrollLeft,e=t.scrollWidth,o=t.clientWidth;n>S.current?n+o>=e-R&&!j.current&&(j.current=!0,x((function(){return i.sleep(60).then((function(){return j.current=!1}))}))):n<S.current&&n<=0&&!W.current&&(W.current=!0,T((function(){return i.sleep(60).then((function(){return W.current=!1}))}))),S.current=n}),[R,T,x]),X=l((function(r){O(r),H(r)}),[O,H]),Y=l((function(r){var t=r.currentTarget,n=t.scrollTop,e=t.scrollLeft;y({x:e,y:n}),p&&b?X(r):p?O(r):b&&H(r)}),[p,b,y,O,H,X]);return u(s,(function(){return{to:function(t){if(void 0===t&&(t=h),w.current){var n=r(r({},h),t),e=n.x,o=n.y,c=n.animation;w.current.scrollTo({left:e,top:o,behavior:c?"smooth":"auto"})}}}}),[]),n.createElement("div",{style:z,className:t(a.border_box)},n.createElement("div",{className:t(a.w_full,a.h_full,a.border_box)},n.createElement("div",{ref:w,onScroll:Y,style:B,className:t(a.border_box,a.w_full,a.h_full,a.scroll_bar_hide)},v)))}));export{s as default};
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,5 @@
1
- import o from"./ScrollView.js";export{o as default};
1
+ import ScrollView from './ScrollView.js';
2
+
3
+
4
+
5
+ export { ScrollView as default };
@@ -1 +1,23 @@
1
- import{StyleSheet as o}from"aphrodite/no-important";var r=o.create({border_box:{boxSizing:"border-box"},w_full:{width:"100%"},h_full:{height:"100%"},scroll_bar_hide:{"scrollbar-width":"none","-ms-overflow-style":"none","::-webkit-scrollbar":{display:"none"}}});export{r as default};
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 };