rox-react-components 0.0.33 → 0.0.34

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.
@@ -1 +1 @@
1
- import{__assign as t}from"tslib";import{css as r}from"aphrodite/no-important";import e,{useRef as o,useEffect as n}from"react";import{createPortal as i}from"react-dom";import m from"./styles.js";var a={visible:!1,position:"bottom",duration:300,bg:"rgba(0,0,0,.3)",maskClosable:!0,popupType:"slide"};function c(t){var o=t.bg;return e.createElement("div",{style:{"--bg":o},className:r(m.container)})}function u(r){var m=t(t({},a),r),u=o(document.createElement("div"));return n((function(){var t=u.current;return document.body.appendChild(t),function(){document.body.removeChild(t)}}),[]),u.current?i(e.createElement(c,t({},m)),u.current):null}export{u as default};
1
+ import{__assign as r}from"tslib";import{css as t}from"aphrodite/no-important";import e,{useRef as o,useEffect as n,useState as i}from"react";import{createPortal as a}from"react-dom";import m from"./styles.js";var u={visible:!1,position:"bottom",duration:300,bg:"rgba(0,0,0,.3)",maskClosable:!0,popupType:"slide"};function c(r){var o=r.bg;r.visible,r.duration;var n=i(!1);return n[0],n[1],e.createElement("div",{style:{"--bg":o},className:t(m.container)})}function l(t){var i=r(r({},u),t),m=o(document.createElement("div"));return n((function(){var r=m.current;return document.body.appendChild(r),function(){document.body.removeChild(r)}}),[]),m.current?a(e.createElement(c,r({},i)),m.current):null}export{l as default};
@@ -1,4 +1,5 @@
1
1
  import React, { CSSProperties, PropsWithChildren } from 'react';
2
+ import { ExposedScrollViewMethods } from './type';
2
3
  interface OnScrollParameters {
3
4
  x?: number;
4
5
  y?: number;
@@ -14,5 +15,5 @@ interface ScrollViewProps extends PropsWithChildren {
14
15
  onReachLeft?: (done: Function) => void;
15
16
  onReachRight?: (done: Function) => void;
16
17
  }
17
- declare function ScrollView(props?: ScrollViewProps): React.JSX.Element;
18
- export default ScrollView;
18
+ declare const _default: (props: ScrollViewProps & React.RefAttributes<ExposedScrollViewMethods>) => React.ReactNode;
19
+ export default _default;
@@ -1 +1 @@
1
- import{__assign as r}from"tslib";import{css as t}from"aphrodite/no-important";import e,{useRef as n,useMemo as o,useCallback as c}from"react";import l from"../utils.js";import u from"./styles.js";var i={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()}};function f(f){void 0===f&&(f=i);var a=r(r({},i),f),h=a.style,s=a.children,d=a.horizontal,m=a.vertical,p=a.onScroll,v=a.threshold,R=a.onReachTop,b=a.onReachBottom,_=a.onReachLeft,g=a.onReachRight,y=n(0),T=n(0),w=n(!1),x=n(!1),L=n(!1),S=n(!1),E=o((function(){return r(r({},i.style),h)}),[h]),N=o((function(){return{overflowX:d?"scroll":"hidden",overflowY:m?"scroll":"hidden",scrollbarWidth:"none",msOverflowStyle:"none"}}),[d,m]),W=c((function(r){var t=r.currentTarget,e=t.scrollTop,n=t.scrollHeight,o=t.clientHeight;e>y.current?e+o>=n-v&&!x.current&&(x.current=!0,b((function(){return l.sleep(60).then((function(){return x.current=!1}))}))):e<y.current&&e<=0&&!w.current&&(w.current=!0,R((function(){return l.sleep(60).then((function(){return w.current=!1}))}))),y.current=e}),[v,b,R]),j=c((function(r){var t=r.currentTarget,e=t.scrollLeft,n=t.scrollWidth,o=t.clientWidth;e>T.current?e+o>=n-v&&!S.current&&(S.current=!0,g((function(){return l.sleep(60).then((function(){return S.current=!1}))}))):e<T.current&&e<=0&&!L.current&&(L.current=!0,_((function(){return l.sleep(60).then((function(){return L.current=!1}))}))),T.current=e}),[v,_,g]),z=c((function(r){j(r),W(r)}),[j,W]),B=c((function(r){var t=r.currentTarget,e=t.scrollTop,n=t.scrollLeft;p({x:n,y:e}),d&&m?z(r):d?j(r):m&&W(r)}),[d,m,p,j,W,z]);return e.createElement("div",{style:E,className:t(u.border_box)},e.createElement("div",{className:t(u.w_full,u.h_full,u.border_box)},e.createElement("div",{onScroll:B,style:N,className:t(u.border_box,u.w_full,u.h_full,u.scroll_bar_hide)},s)))}export{f as default};
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};
@@ -0,0 +1,8 @@
1
+ export interface ToParams {
2
+ x?: number;
3
+ y?: number;
4
+ animation?: boolean;
5
+ }
6
+ export interface ExposedScrollViewMethods {
7
+ to: (data?: ToParams) => void;
8
+ }
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ interface SwiperExposeMethods {
26
26
  declare function sleep(timestamp?: number, result?: boolean): Promise<boolean>;
27
27
  type parseUrlResponse = Record<string, string | (string | boolean)[] | boolean> | string | boolean | (string | boolean)[] | undefined;
28
28
  declare function parseUrl(key?: string): parseUrlResponse;
29
- declare const _default$1: {
29
+ declare const _default$2: {
30
30
  sleep: typeof sleep;
31
31
  parseUrl: typeof parseUrl;
32
32
  };
@@ -84,6 +84,15 @@ interface PopupProps extends PropsWithChildren {
84
84
  }
85
85
  declare function PopupContainer(_props: PopupProps): React.ReactPortal | null;
86
86
 
87
+ interface ToParams {
88
+ x?: number;
89
+ y?: number;
90
+ animation?: boolean;
91
+ }
92
+ interface ExposedScrollViewMethods {
93
+ to: (data?: ToParams) => void;
94
+ }
95
+
87
96
  interface OnScrollParameters {
88
97
  x?: number;
89
98
  y?: number;
@@ -99,11 +108,11 @@ interface ScrollViewProps extends PropsWithChildren {
99
108
  onReachLeft?: (done: Function) => void;
100
109
  onReachRight?: (done: Function) => void;
101
110
  }
102
- declare function ScrollView(props?: ScrollViewProps): React.JSX.Element;
111
+ declare const _default$1: (props: ScrollViewProps & React.RefAttributes<ExposedScrollViewMethods>) => React.ReactNode;
103
112
 
104
113
  declare module 'react' {
105
114
  function forwardRef<T, P = {}>(render: (props: P, ref: React.Ref<T>) => React.ReactNode | null): (props: P & React.RefAttributes<T>) => React.ReactNode | null;
106
115
  }
107
116
  declare const _default: <T extends unknown>(props: SwiperProps<T> & React.RefAttributes<SwiperExposeMethods>) => React.ReactNode;
108
117
 
109
- export { Card, Container, Loading, PopupContainer as Popup, type PopupPosition, type PopupType, ScrollView, _default as Swiper, type SwiperExposeMethods, type SwiperProps, _default$1 as utils };
118
+ export { Card, Container, Loading, PopupContainer as Popup, type PopupPosition, type PopupType, _default$1 as ScrollView, _default as Swiper, type SwiperExposeMethods, type SwiperProps, _default$2 as utils };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("aphrodite/no-important"),t=require("react"),n=require("react-dom"),i=require("./styles.js"),u={visible:!1,position:"bottom",duration:300,bg:"rgba(0,0,0,.3)",maskClosable:!0,popupType:"slide"};function a(e){var n=e.bg;return t.createElement("div",{style:{"--bg":n},className:r.css(i.default.container)})}exports.default=function(r){var i=e.__assign(e.__assign({},u),r),o=t.useRef(document.createElement("div"));return t.useEffect((function(){var e=o.current;return document.body.appendChild(e),function(){document.body.removeChild(e)}}),[]),o.current?n.createPortal(t.createElement(a,e.__assign({},i)),o.current):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("aphrodite/no-important"),t=require("react"),n=require("react-dom"),i=require("./styles.js"),a={visible:!1,position:"bottom",duration:300,bg:"rgba(0,0,0,.3)",maskClosable:!0,popupType:"slide"};function u(e){var n=e.bg;e.visible,e.duration;var a=t.useState(!1);return a[0],a[1],t.createElement("div",{style:{"--bg":n},className:r.css(i.default.container)})}exports.default=function(r){var i=e.__assign(e.__assign({},a),r),s=t.useRef(document.createElement("div"));return t.useEffect((function(){var e=s.current;return document.body.appendChild(e),function(){document.body.removeChild(e)}}),[]),s.current?n.createPortal(t.createElement(u,e.__assign({},i)),s.current):null};
@@ -1,4 +1,5 @@
1
1
  import React, { CSSProperties, PropsWithChildren } from 'react';
2
+ import { ExposedScrollViewMethods } from './type';
2
3
  interface OnScrollParameters {
3
4
  x?: number;
4
5
  y?: number;
@@ -14,5 +15,5 @@ interface ScrollViewProps extends PropsWithChildren {
14
15
  onReachLeft?: (done: Function) => void;
15
16
  onReachRight?: (done: Function) => void;
16
17
  }
17
- declare function ScrollView(props?: ScrollViewProps): React.JSX.Element;
18
- export default ScrollView;
18
+ declare const _default: (props: ScrollViewProps & React.RefAttributes<ExposedScrollViewMethods>) => React.ReactNode;
19
+ export default _default;
@@ -1 +1 @@
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()}};exports.default=function(c){void 0===c&&(c=l);var o=e.__assign(e.__assign({},l),c),s=o.style,a=o.children,i=o.horizontal,f=o.vertical,d=o.onScroll,h=o.threshold,_=o.onReachTop,R=o.onReachBottom,v=o.onReachLeft,b=o.onReachRight,p=t.useRef(0),g=t.useRef(0),m=t.useRef(!1),y=t.useRef(!1),T=t.useRef(!1),w=t.useRef(!1),x=t.useMemo((function(){return e.__assign(e.__assign({},l.style),s)}),[s]),q=t.useMemo((function(){return{overflowX:i?"scroll":"hidden",overflowY:f?"scroll":"hidden",scrollbarWidth:"none",msOverflowStyle:"none"}}),[i,f]),k=t.useCallback((function(e){var r=e.currentTarget,t=r.scrollTop,u=r.scrollHeight,l=r.clientHeight;t>p.current?t+l>=u-h&&!y.current&&(y.current=!0,R((function(){return n.default.sleep(60).then((function(){return y.current=!1}))}))):t<p.current&&t<=0&&!m.current&&(m.current=!0,_((function(){return n.default.sleep(60).then((function(){return m.current=!1}))}))),p.current=t}),[h,R,_]),C=t.useCallback((function(e){var r=e.currentTarget,t=r.scrollLeft,u=r.scrollWidth,l=r.clientWidth;t>g.current?t+l>=u-h&&!w.current&&(w.current=!0,b((function(){return n.default.sleep(60).then((function(){return w.current=!1}))}))):t<g.current&&t<=0&&!T.current&&(T.current=!0,v((function(){return n.default.sleep(60).then((function(){return T.current=!1}))}))),g.current=t}),[h,v,b]),L=t.useCallback((function(e){C(e),k(e)}),[C,k]),S=t.useCallback((function(e){var r=e.currentTarget,t=r.scrollTop,n=r.scrollLeft;d({x:n,y:t}),i&&f?L(e):i?C(e):f&&k(e)}),[i,f,d,C,k,L]);return t.createElement("div",{style:x,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",{onScroll:S,style:q,className:r.css(u.default.border_box,u.default.w_full,u.default.h_full,u.default.scroll_bar_hide)},a)))};
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;
@@ -0,0 +1,8 @@
1
+ export interface ToParams {
2
+ x?: number;
3
+ y?: number;
4
+ animation?: boolean;
5
+ }
6
+ export interface ExposedScrollViewMethods {
7
+ to: (data?: ToParams) => void;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rox-react-components",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "main": "dist/lib/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/index.d.ts",