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,46 @@
1
- import{__rest as t,__assign as e}from"tslib";import{css as o}from"aphrodite/no-important";import r,{useRef as i,useMemo as n,useCallback as l,useEffect as a}from"react";import c from"./styles.js";var s=["relative","absolute","fixed"],d=function(d){var u=d.children,f=d.style,p=void 0===f?{}:f,v=d.block,m=void 0!==v&&v,h=d.className,g=void 0===h?"":h,b=d.radius,y=void 0===b?4:b,C=d.bg,k=void 0===C?"rgba(0,0,0,.7)":C,x=d.color,w=void 0===x?"#ffffff":x,N=d.onClick,E=d.wavesColor,R=void 0===E?"rgba(255,255,255,.3)":E,j=t(d,["children","style","block","className","radius","bg","color","onClick","wavesColor"]),B=i([]),H=i(null),L=n((function(){return e(e({},p),{overflow:"hidden",borderRadius:y+"px",background:k,color:w})}),[p,y,k,w]),M=l((function(t){null==N||N(t);var e,r=t.currentTarget;B.current.length?e=B.current.shift():(e=document.createElement("div")).classList.add(o(c.ripple));var i=r.getBoundingClientRect();e.style.width=e.style.height=Math.max(i.width,i.height)+"px",e.style.backgroundColor=R,r.appendChild(e);var n=t.pageY-i.top-e.offsetHeight/2+"px",l=t.pageX-i.left-e.offsetWidth/2+"px";e.style.top=n,e.style.left=l,e.onanimationend=function(){r.removeChild(e),B.current.push(e)}}),[N,R]);return a((function(){if(H.current){var t=getComputedStyle(H.current);s.includes(t.position)||(H.current.style.position="relative")}}),[]),r.createElement("button",e({},j,{className:"".concat(g," ").concat(o(c.button)," ").concat(m?o(c.block):""),style:L,ref:H,onClick:M}),u)};export{d as default};
1
+ import { __rest, __assign } from 'tslib';
2
+ import { css } from 'aphrodite/no-important';
3
+ import React, { useRef, useMemo, useCallback, useEffect } from 'react';
4
+ import styles from './styles.js';
5
+
6
+ var positions = ['relative', 'absolute', 'fixed'];
7
+ var Button = function (props) {
8
+ var children = props.children, _a = props.style, style = _a === void 0 ? {} : _a, _b = props.block, block = _b === void 0 ? false : _b, _c = props.className, className = _c === void 0 ? '' : _c, _d = props.radius, radius = _d === void 0 ? 4 : _d, _e = props.bg, bg = _e === void 0 ? 'rgba(0,0,0,.7)' : _e, _f = props.color, color = _f === void 0 ? '#ffffff' : _f, onClick = props.onClick, _g = props.wavesColor, wavesColor = _g === void 0 ? 'rgba(255,255,255,.3)' : _g, rest = __rest(props, ["children", "style", "block", "className", "radius", "bg", "color", "onClick", "wavesColor"]);
9
+ var pools = useRef([]);
10
+ var btn_ref = useRef(null);
11
+ var btnStyle = useMemo(function () { return (__assign(__assign({}, style), { overflow: 'hidden', borderRadius: radius + 'px', background: bg, color: color })); }, [style, radius, bg, color]);
12
+ var handleButtonClick = useCallback(function (event) {
13
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
14
+ var target = event.currentTarget;
15
+ var node;
16
+ if (pools.current.length) {
17
+ node = pools.current.shift();
18
+ }
19
+ else {
20
+ node = document.createElement('div');
21
+ node.classList.add(css(styles.ripple));
22
+ }
23
+ var rect = target.getBoundingClientRect();
24
+ node.style.width = node.style.height = Math.max(rect.width, rect.height) + 'px';
25
+ node.style.backgroundColor = wavesColor;
26
+ target.appendChild(node);
27
+ var y = event.pageY - rect.top - node.offsetHeight / 2 + 'px';
28
+ var x = event.pageX - rect.left - node.offsetWidth / 2 + 'px';
29
+ node.style.top = y;
30
+ node.style.left = x;
31
+ node.onanimationend = function () {
32
+ target.removeChild(node);
33
+ pools.current.push(node);
34
+ };
35
+ }, [onClick, wavesColor]);
36
+ useEffect(function () {
37
+ if (btn_ref.current) {
38
+ var style_1 = getComputedStyle(btn_ref.current);
39
+ if (!positions.includes(style_1.position))
40
+ btn_ref.current.style.position = 'relative';
41
+ }
42
+ }, []);
43
+ return (React.createElement("button", __assign({}, rest, { className: "".concat(className, " ").concat(css(styles.button), " ").concat(block ? css(styles.block) : ''), style: btnStyle, ref: btn_ref, onClick: handleButtonClick }), children));
44
+ };
45
+
46
+ export { Button as default };
@@ -1 +1,5 @@
1
- import t from"./Button.js";export{t as default};
1
+ import Button from './Button.js';
2
+
3
+
4
+
5
+ export { Button as default };
@@ -1 +1,40 @@
1
- import{StyleSheet as o}from"aphrodite/no-important";var n=o.create({button:{border:"1px solid transparent",boxSizing:"border-box",padding:"8px 20px",cursor:"pointer",outline:"none",":focus":{outline:"none"},":focus-within":{outline:"none"}},block:{display:"block",width:"100%"},ripple:{position:"absolute",borderRadius:"100%",pointerEvents:"none",transform:"scale(0)",opacity:1,animationName:[{to:{opacity:0,transform:"scale(2)","-webkit-transform":"scale(2)"}}],animationDuration:"0.4s",animationTimingFunction:"ease-out"}});export{n as default};
1
+ import { StyleSheet } from 'aphrodite/no-important';
2
+
3
+ var rippleKey = {
4
+ to: {
5
+ opacity: 0,
6
+ transform: 'scale(2)',
7
+ '-webkit-transform': 'scale(2)',
8
+ },
9
+ };
10
+ var styles = StyleSheet.create({
11
+ button: {
12
+ border: '1px solid transparent',
13
+ boxSizing: 'border-box',
14
+ padding: '8px 20px',
15
+ cursor: 'pointer',
16
+ outline: 'none',
17
+ ':focus': {
18
+ outline: 'none',
19
+ },
20
+ ':focus-within': {
21
+ outline: 'none',
22
+ },
23
+ },
24
+ block: {
25
+ display: 'block',
26
+ width: '100%',
27
+ },
28
+ ripple: {
29
+ position: 'absolute',
30
+ borderRadius: '100%',
31
+ pointerEvents: 'none',
32
+ transform: 'scale(0)',
33
+ opacity: 1,
34
+ animationName: [rippleKey],
35
+ animationDuration: '0.4s',
36
+ animationTimingFunction: 'ease-out',
37
+ },
38
+ });
39
+
40
+ export { styles as default };
@@ -1 +1,22 @@
1
- import{__assign as t}from"tslib";import{css as n}from"aphrodite/no-important";import a,{useMemo as o}from"react";import r from"./styles.js";var i={expand:!1,duration:200},e=function(e){var c=t(t({},i),e),s=c.duration,m=c.expand,d=c.children,l=o((function(){return{transitionDuration:"".concat(s,"ms"),msTransitionDuration:"".concat(s,"ms"),MozTransitionDuration:"".concat(s,"ms"),WebkitTransitionDuration:"".concat(s,"ms")}}),[s]);return a.createElement("div",{style:l,className:"".concat(n(r.collapse)," ").concat(m?n(r.expand):"")},a.createElement("div",{className:n(r.hide0)},d))};export{e as default};
1
+ import { __assign } from 'tslib';
2
+ import { css } from 'aphrodite/no-important';
3
+ import React, { useMemo } from 'react';
4
+ import styles from './styles.js';
5
+
6
+ var initCardProps = {
7
+ expand: false,
8
+ duration: 200,
9
+ };
10
+ var Card = function (props) {
11
+ var _a = __assign(__assign({}, initCardProps), props), duration = _a.duration, expand = _a.expand, children = _a.children;
12
+ var transitionDuration = useMemo(function () { return ({
13
+ transitionDuration: "".concat(duration, "ms"),
14
+ msTransitionDuration: "".concat(duration, "ms"),
15
+ MozTransitionDuration: "".concat(duration, "ms"),
16
+ WebkitTransitionDuration: "".concat(duration, "ms"),
17
+ }); }, [duration]);
18
+ return (React.createElement("div", { style: transitionDuration, className: "".concat(css(styles.collapse), " ").concat(expand ? css(styles.expand) : '') },
19
+ React.createElement("div", { className: css(styles.hide0) }, children)));
20
+ };
21
+
22
+ export { Card as default };
@@ -1 +1,5 @@
1
- import r from"./Card.js";export{r as default};
1
+ import Card from './Card.js';
2
+
3
+
4
+
5
+ export { Card as default };
@@ -1 +1,18 @@
1
- import{StyleSheet as e}from"aphrodite/no-important";var o=e.create({collapse:{display:"grid",gridTemplateRows:"0fr",overflow:"hidden",outline:"none"},expand:{gridTemplateRows:"1fr"},hide0:{minHeight:0}});export{o as default};
1
+ import { StyleSheet } from 'aphrodite/no-important';
2
+
3
+ var styles = StyleSheet.create({
4
+ collapse: {
5
+ display: 'grid',
6
+ gridTemplateRows: '0fr',
7
+ overflow: 'hidden',
8
+ outline: 'none'
9
+ },
10
+ expand: {
11
+ gridTemplateRows: '1fr',
12
+ },
13
+ hide0: {
14
+ minHeight: 0,
15
+ },
16
+ });
17
+
18
+ export { styles as default };
@@ -1 +1,20 @@
1
- import{__assign as t}from"tslib";import{css as r}from"aphrodite/no-important";import e,{useMemo as o}from"react";import l from"./styles.js";var a={ratio:1},i=function(i){var m=t(t({},a),i),n=m.ratio,f=m.children,s=o((function(){return null==n||n<=0?"100%":100/n+"%"}),[n]);return e.createElement("div",{className:r(l.relative,l.w_full,l.h_0,l.border_box),style:{paddingBottom:s}},e.createElement("div",{className:r(l.absolute,l.top_0,l.left_0,l.w_full,l.h_full)},f))};export{i as default};
1
+ import { __assign } from 'tslib';
2
+ import { css } from 'aphrodite/no-important';
3
+ import React, { useMemo } from 'react';
4
+ import styles from './styles.js';
5
+
6
+ var initContainerProps = {
7
+ ratio: 1,
8
+ };
9
+ var Container = function (_props) {
10
+ var _a = __assign(__assign({}, initContainerProps), _props), ratio = _a.ratio, children = _a.children;
11
+ var pb = useMemo(function () {
12
+ if (ratio === undefined || ratio === null || ratio <= 0)
13
+ return '100%';
14
+ return 100 / ratio + '%';
15
+ }, [ratio]);
16
+ return (React.createElement("div", { className: css(styles.relative, styles.w_full, styles.h_0, styles.border_box), style: { paddingBottom: pb } },
17
+ React.createElement("div", { className: css(styles.absolute, styles.top_0, styles.left_0, styles.w_full, styles.h_full) }, children)));
18
+ };
19
+
20
+ export { Container as default };
@@ -1 +1,5 @@
1
- import o from"./Container.js";export{o as default};
1
+ import Container from './Container.js';
2
+
3
+
4
+
5
+ export { Container as default };
@@ -1 +1,30 @@
1
- import{StyleSheet as t}from"aphrodite/no-important";var o=t.create({relative:{position:"relative"},absolute:{position:"absolute"},top_0:{top:"0px"},left_0:{left:"0px"},w_full:{width:"100%"},h_full:{height:"100%"},h_0:{height:"0px"},border_box:{boxSizing:"border-box"}});export{o as default};
1
+ import { StyleSheet } from 'aphrodite/no-important';
2
+
3
+ var styles = StyleSheet.create({
4
+ relative: {
5
+ position: 'relative',
6
+ },
7
+ absolute: {
8
+ position: 'absolute',
9
+ },
10
+ top_0: {
11
+ top: '0px',
12
+ },
13
+ left_0: {
14
+ left: '0px',
15
+ },
16
+ w_full: {
17
+ width: '100%',
18
+ },
19
+ h_full: {
20
+ height: '100%',
21
+ },
22
+ h_0: {
23
+ height: '0px',
24
+ },
25
+ border_box: {
26
+ boxSizing: 'border-box',
27
+ },
28
+ });
29
+
30
+ export { styles as default };
@@ -1 +1,13 @@
1
- import{__assign as e}from"tslib";import{css as t}from"aphrodite/no-important";import r from"react";import a from"./styles.js";import{initLoadingStyle as i}from"./type.js";var m=[{delay:"0s"},{delay:"-1.1s"},{delay:"-1.0s"},{delay:"-0.9s"},{delay:"-0.8s"}],o=function(o){var s=e(e({},i),o.style);return r.createElement("div",{className:t(a.inner_box),style:{"--width":s.width,"--height":s.height,"--bg":s.bg,"--margin":s.margin}},m.map((function(e,i){return r.createElement("div",{key:i,style:{"--delay":e.delay},className:t(a.inner_box_item)})})))};export{o as default};
1
+ import { __assign } from 'tslib';
2
+ import { css } from 'aphrodite/no-important';
3
+ import React from 'react';
4
+ import styles from './styles.js';
5
+ import { initLoadingStyle } from './type.js';
6
+
7
+ var arr = [{ delay: '0s' }, { delay: '-1.1s' }, { delay: '-1.0s' }, { delay: '-0.9s' }, { delay: '-0.8s' }];
8
+ var Inner = function (props) {
9
+ var style = __assign(__assign({}, initLoadingStyle), props.style);
10
+ return (React.createElement("div", { className: css(styles.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: css(styles.inner_box_item) })); })));
11
+ };
12
+
13
+ export { Inner as default };
@@ -1 +1,67 @@
1
- import{__extends as e,__assign as t}from"tslib";import{css as o}from"aphrodite/no-important";import l,{Component as n}from"react";import{createRoot as r}from"react-dom/client";import i from"./Inner.js";import d from"./dom.js";import a from"./styles.js";var u=function(n){function u(){var e=null!==n&&n.apply(this,arguments)||this;return e.state={},e}return e(u,n),u.show=function(e){u.el||(u.el=document.createElement("div"),d.addClass(u.el,o(a.fixed)),d.addClass(document.body,o(a.page_hide)),document.body.appendChild(u.el),r(u.el).render(l.createElement(u,t({},e,{children:null,visible:!0}))))},u.hide=function(){try{if(d.removeClass(document.body,o(a.page_hide)),!u.el)return;document.body.removeChild(u.el),u.el=null}catch(e){d.removeClass(document.body,o(a.page_hide)),u.el=null}},u.prototype.render=function(){var e=this.props,t=e.visible,n=e.bg,r=e.customLoading,d=e.loadingStyle,u=e.children;return l.createElement("div",{className:o(a.relative,a.w_full,a.h_full,a.border_box)},u,t?l.createElement("div",{className:o(a.absolute,a.top_0,a.left_0,a.w_full,a.h_full,a.z_99,a.center),style:{backgroundColor:n}},r||l.createElement(i,{style:d})):null)},u.getDerivedStateFromProps=function(e,t){return null},u.prototype.getSnapshotBeforeUpdate=function(e,t){return null},u.prototype.componentDidUpdate=function(e,t,o){},u.prototype.componentWillUnmount=function(){u.hide()},u.defaultProps={visible:!0,bg:"rgba(0,0,0,.7)",customLoading:null,loadingStyle:{}},u.el=null,u}(n);export{u as default};
1
+ import { __extends, __assign } from 'tslib';
2
+ import { css } from 'aphrodite/no-important';
3
+ import React, { Component } from 'react';
4
+ import { createRoot } from 'react-dom/client';
5
+ import Inner from './Inner.js';
6
+ import dom from './dom.js';
7
+ import styles from './styles.js';
8
+
9
+ var Loading = /** @class */ (function (_super) {
10
+ __extends(Loading, _super);
11
+ function Loading() {
12
+ var _this = _super !== null && _super.apply(this, arguments) || this;
13
+ _this.state = {};
14
+ return _this;
15
+ }
16
+ Loading.show = function (options) {
17
+ if (Loading.el)
18
+ return;
19
+ Loading.el = document.createElement('div');
20
+ dom.addClass(Loading.el, css(styles.fixed));
21
+ dom.addClass(document.body, css(styles.page_hide));
22
+ document.body.appendChild(Loading.el);
23
+ createRoot(Loading.el).render(React.createElement(Loading, __assign({}, options, { children: null, visible: true })));
24
+ };
25
+ Loading.hide = function () {
26
+ try {
27
+ dom.removeClass(document.body, css(styles.page_hide));
28
+ if (!Loading.el)
29
+ return;
30
+ document.body.removeChild(Loading.el);
31
+ Loading.el = null;
32
+ }
33
+ catch (e) {
34
+ dom.removeClass(document.body, css(styles.page_hide));
35
+ Loading.el = null;
36
+ }
37
+ };
38
+ Loading.prototype.render = function () {
39
+ var _a = this.props, visible = _a.visible, bg = _a.bg, customLoading = _a.customLoading, loadingStyle = _a.loadingStyle, children = _a.children;
40
+ return (React.createElement("div", { className: css(styles.relative, styles.w_full, styles.h_full, styles.border_box) },
41
+ children,
42
+ visible ? (React.createElement("div", { className: css(styles.absolute, styles.top_0, styles.left_0, styles.w_full, styles.h_full, styles.z_99, styles.center), style: { backgroundColor: bg } }, customLoading || React.createElement(Inner, { style: loadingStyle }))) : null));
43
+ };
44
+ Loading.getDerivedStateFromProps = function (props, state) {
45
+ // console.log('getDerivedStateFromProps', props, state)
46
+ return null;
47
+ };
48
+ Loading.prototype.getSnapshotBeforeUpdate = function (prevProps, prevState) {
49
+ // console.log('getSnapshotBeforeUpdate', prevProps, prevState)
50
+ return null;
51
+ };
52
+ Loading.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) { };
53
+ Loading.prototype.componentWillUnmount = function () {
54
+ // console.log('componentWillUnmount')
55
+ Loading.hide();
56
+ };
57
+ Loading.defaultProps = {
58
+ visible: true,
59
+ bg: 'rgba(0,0,0,.7)',
60
+ customLoading: null,
61
+ loadingStyle: {},
62
+ };
63
+ Loading.el = null;
64
+ return Loading;
65
+ }(Component));
66
+
67
+ export { Loading as default };
@@ -1 +1,11 @@
1
- var s={addClass:function(s,a){s.classList.contains(a)||s.classList.add(a)},removeClass:function(s,a){s.classList.remove(a)}};export{s as default};
1
+ function addClass(el, cls) {
2
+ if (el.classList.contains(cls))
3
+ return;
4
+ el.classList.add(cls);
5
+ }
6
+ function removeClass(el, cls) {
7
+ el.classList.remove(cls);
8
+ }
9
+ var dom = { addClass: addClass, removeClass: removeClass };
10
+
11
+ export { dom as default };
@@ -1 +1,5 @@
1
- import o from"./Loading.js";export{o as default};
1
+ import Loading from './Loading.js';
2
+
3
+
4
+
5
+ export { Loading as default };
@@ -1 +1,80 @@
1
- import{StyleSheet as e}from"aphrodite/no-important";var t=e.create({relative:{position:"relative"},center:{display:"flex",alignItems:"center",justifyContent:"center"},absolute:{position:"absolute"},top_0:{top:"0px"},left_0:{left:"0px"},w_full:{width:"100%"},h_full:{height:"100%"},border_box:{boxSizing:"border-box"},z_99:{zIndex:99},inner_box:{display:"flex",width:"100%",height:"100%",textAlign:"center",fontSize:"10px",alignItems:"center",justifyContent:"center"},inner_box_item:{height:"var(--height)",width:"var(--width)",margin:"var(--margin)",backgroundColor:"var(--bg)",animationName:[{"0%, 40%, 100%":{transform:"scaleY(0.4)","-webkit-transform":"scaleY(0.4)"},"20%":{transform:"scaleY(1.0)","-webkit-transform":"scaleY(1.0)"}}],animationDelay:"var(--delay)",animationDuration:"1.2s",animationIterationCount:"infinite"},fixed:{position:"fixed",display:"flex",alignItems:"center",justifyContent:"center",top:"0",left:"0",width:"100%",height:"100%",zIndex:99},page_hide:{width:"100%",height:"100%",overflow:"hidden"}});export{t as default};
1
+ import { StyleSheet } from 'aphrodite/no-important';
2
+
3
+ var keys = {
4
+ '0%, 40%, 100%': {
5
+ transform: 'scaleY(0.4)',
6
+ '-webkit-transform': 'scaleY(0.4)',
7
+ },
8
+ '20%': {
9
+ transform: 'scaleY(1.0)',
10
+ '-webkit-transform': 'scaleY(1.0)',
11
+ },
12
+ };
13
+ var styles = StyleSheet.create({
14
+ relative: {
15
+ position: 'relative',
16
+ },
17
+ center: {
18
+ display: 'flex',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ },
22
+ absolute: {
23
+ position: 'absolute',
24
+ },
25
+ top_0: {
26
+ top: '0px',
27
+ },
28
+ left_0: {
29
+ left: '0px',
30
+ },
31
+ w_full: {
32
+ width: '100%',
33
+ },
34
+ h_full: {
35
+ height: '100%',
36
+ },
37
+ border_box: {
38
+ boxSizing: 'border-box',
39
+ },
40
+ z_99: {
41
+ zIndex: 99,
42
+ },
43
+ inner_box: {
44
+ display: 'flex',
45
+ width: '100%',
46
+ height: '100%',
47
+ textAlign: 'center',
48
+ fontSize: '10px',
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ },
52
+ inner_box_item: {
53
+ height: 'var(--height)',
54
+ width: 'var(--width)',
55
+ margin: 'var(--margin)',
56
+ backgroundColor: 'var(--bg)',
57
+ animationName: [keys],
58
+ animationDelay: 'var(--delay)',
59
+ animationDuration: '1.2s',
60
+ animationIterationCount: 'infinite',
61
+ },
62
+ fixed: {
63
+ position: 'fixed',
64
+ display: 'flex',
65
+ alignItems: 'center',
66
+ justifyContent: 'center',
67
+ top: '0',
68
+ left: '0',
69
+ width: '100%',
70
+ height: '100%',
71
+ zIndex: 99,
72
+ },
73
+ page_hide: {
74
+ width: '100%',
75
+ height: '100%',
76
+ overflow: 'hidden',
77
+ },
78
+ });
79
+
80
+ export { styles as default };
@@ -1 +1,3 @@
1
- var p={width:"6px",height:"50px",bg:"#fff",margin:"0 3px"};export{p as initLoadingStyle};
1
+ var initLoadingStyle = { width: '6px', height: '50px', bg: '#fff', margin: '0 3px' };
2
+
3
+ export { initLoadingStyle };
@@ -1 +1,112 @@
1
- import{__assign as t}from"tslib";import e,{useRef as n,useCallback as i,useEffect as o,useState as r,useMemo as a}from"react";import{createPortal as l}from"react-dom";import{css as s}from"aphrodite/no-important";import c,{animateStyles as u}from"./styles.js";var f={visible:!1,position:"bottom",duration:200,bg:"rgba(0,0,0,.35)",maskClosable:!0,popupType:"fade",onClose:function(){return null},contentClassName:"",contentStyle:{},scale:[.2],curve:"linear"};function m(n){var l=n.bg,f=n.visible,m=n.duration,d=n.inject,p=n.dispose,_=n.maskClosable,y=n.onClose,b=n.children,v=n.position,g=n.contentStyle,C=n.contentClassName,h=n.popupType,j=n.scale,E=n.curve,x=r(f),I=x[0],N=x[1],k=r(!1),A=k[0],S=k[1];o((function(){N(f),f&&(p(),d(),S(!0))}),[f]),o((function(){return function(){S(!1),p()}}),[]);var T=i((function(){_&&N(!1)}),[_]),q=i((function(){I||(S(!1),y(),p())}),[I,y]),w=a((function(){return"bottom"===v?{justifyContent:"center",alignItems:"flex-end"}:"top"===v?{justifyContent:"center",alignItems:"flex-start"}:"left"===v?{justifyContent:"flex-start",alignItems:"center"}:"right"===v?{justifyContent:"flex-end",alignItems:"center"}:"center"===v?{justifyContent:"center",alignItems:"center"}:{}}),[v]),z=a((function(){if("slide"===h){if("top"===v)return I?c.slide_in_top:c.slide_out_top;if("bottom"===v)return I?c.slide_in_bottom:c.slide_out_bottom;if("left"===v)return I?c.slide_in_left:c.slide_out_left;if("right"===v)return I?c.slide_in_right:c.slide_out_right}else if("scale"===h&&Array.isArray(j)&&j.length>=1){var t=u(j);return I?t.scale_in:t.scale_out}return I?c.fade_in:c.fade_out}),[h,v,I,j]);return A?e.createElement("div",{style:t({"--bg":l,"--duration":m+"ms","--curve":E},w),className:s(c.container)},e.createElement("div",{onClick:T,onAnimationEnd:q,className:s(c.mask,c.animation_properties,I?c.fade_in:c.fade_out)}),e.createElement("div",{style:g,className:"".concat(C," ").concat(s(c.animation_properties,z))},b)):null}function d(r){var a=t(t({},f),r),s=n(document.createElement("div")),c=i((function(){document.body.appendChild(s.current)}),[]),u=i((function(){try{document.body.removeChild(s.current)}catch(t){}}),[]);return o((function(){return function(){return u()}}),[]),l(e.createElement(m,t({},a,{inject:c,dispose:u})),s.current)}export{d as default};
1
+ import { __assign } from 'tslib';
2
+ import React, { useRef, useCallback, useEffect, useState, useMemo } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { css } from 'aphrodite/no-important';
5
+ import styles, { animateStyles } from './styles.js';
6
+
7
+ var initPopupProps = {
8
+ visible: false,
9
+ position: 'bottom',
10
+ duration: 200,
11
+ bg: 'rgba(0,0,0,.35)',
12
+ maskClosable: true,
13
+ popupType: 'fade',
14
+ onClose: function () { return null; },
15
+ contentClassName: '',
16
+ contentStyle: {},
17
+ scale: [0.2],
18
+ curve: 'linear'
19
+ };
20
+ function _Popup(props) {
21
+ 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;
22
+ var _a = useState(visible), tweenAnimation = _a[0], setTweenAnimation = _a[1];
23
+ var _b = useState(false), show = _b[0], setShow = _b[1];
24
+ useEffect(function () {
25
+ setTweenAnimation(visible);
26
+ if (visible) {
27
+ dispose();
28
+ inject();
29
+ setShow(true);
30
+ }
31
+ }, [visible]);
32
+ useEffect(function () {
33
+ return function () {
34
+ setShow(false);
35
+ dispose();
36
+ };
37
+ }, []);
38
+ var handleMaskClick = useCallback(function () {
39
+ if (!maskClosable)
40
+ return;
41
+ setTweenAnimation(false);
42
+ }, [maskClosable]);
43
+ var handleAnimationEnd = useCallback(function () {
44
+ if (!tweenAnimation) {
45
+ setShow(false);
46
+ onClose();
47
+ dispose();
48
+ }
49
+ }, [tweenAnimation, onClose]);
50
+ var containerStyle = useMemo(function () {
51
+ if (position === 'bottom') {
52
+ return { justifyContent: 'center', alignItems: 'flex-end' };
53
+ }
54
+ if (position === 'top') {
55
+ return { justifyContent: 'center', alignItems: 'flex-start' };
56
+ }
57
+ if (position === 'left') {
58
+ return { justifyContent: 'flex-start', alignItems: 'center' };
59
+ }
60
+ if (position === 'right') {
61
+ return { justifyContent: 'flex-end', alignItems: 'center' };
62
+ }
63
+ if (position === 'center') {
64
+ return { justifyContent: 'center', alignItems: 'center' };
65
+ }
66
+ return {};
67
+ }, [position]);
68
+ var contentAnimationName = useMemo(function () {
69
+ if (popupType === 'slide') {
70
+ if (position === 'top')
71
+ return tweenAnimation ? styles.slide_in_top : styles.slide_out_top;
72
+ if (position === 'bottom')
73
+ return tweenAnimation ? styles.slide_in_bottom : styles.slide_out_bottom;
74
+ if (position === 'left')
75
+ return tweenAnimation ? styles.slide_in_left : styles.slide_out_left;
76
+ if (position === 'right')
77
+ return tweenAnimation ? styles.slide_in_right : styles.slide_out_right;
78
+ }
79
+ else if (popupType === 'scale') {
80
+ if (Array.isArray(scale) && scale.length >= 1) {
81
+ var styles_1 = animateStyles(scale);
82
+ return tweenAnimation ? styles_1.scale_in : styles_1.scale_out;
83
+ }
84
+ }
85
+ return tweenAnimation ? styles.fade_in : styles.fade_out;
86
+ }, [popupType, position, tweenAnimation, scale]);
87
+ if (!show)
88
+ return null;
89
+ return (React.createElement("div", { style: __assign({ '--bg': bg, '--duration': duration + 'ms', '--curve': curve }, containerStyle), className: css(styles.container) },
90
+ React.createElement("div", { onClick: handleMaskClick, onAnimationEnd: handleAnimationEnd, className: css(styles.mask, styles.animation_properties, tweenAnimation ? styles.fade_in : styles.fade_out) }),
91
+ React.createElement("div", { style: contentStyle, className: "".concat(contentClassName, " ").concat(css(styles.animation_properties, contentAnimationName)) }, children)));
92
+ }
93
+ function Popup(_props) {
94
+ var props = __assign(__assign({}, initPopupProps), _props);
95
+ var container = useRef(document.createElement('div'));
96
+ var injectBody = useCallback(function () {
97
+ document.body.appendChild(container.current);
98
+ }, []);
99
+ var dispose = useCallback(function () {
100
+ try {
101
+ document.body.removeChild(container.current);
102
+ }
103
+ catch (e) {
104
+ }
105
+ }, []);
106
+ useEffect(function () {
107
+ return function () { return dispose(); };
108
+ }, []);
109
+ return createPortal(React.createElement(_Popup, __assign({}, props, { inject: injectBody, dispose: dispose })), container.current);
110
+ }
111
+
112
+ export { Popup as default };
@@ -1 +1,5 @@
1
- import o from"./Popup.js";export{o as default};
1
+ import Popup from './Popup.js';
2
+
3
+
4
+
5
+ export { Popup as default };