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