@zenpatient-org/healthspan-marketing-ui 0.1.93 → 0.1.95

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
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),e=require("react"),R=require("../../utils/cn/cn.cjs.js"),q=require("./infiniteScroll.module.css.cjs.js");function L({items:u,speed:d=50,direction:o="left",contentClassName:y,itemClassName:v,rootClassName:w,renderItem:b},A){const f=e.useRef(null),[i,p]=e.useState(0),[c,E]=e.useState(0),m=e.useRef(null),g=e.useRef(!1),h=e.useRef(performance.now()),[T,W]=e.useState(2);e.useEffect(()=>{f.current&&u.length>0&&setTimeout(()=>{var a,l,n;const r=((l=(a=f.current)==null?void 0:a.parentElement)==null?void 0:l.offsetWidth)||0,t=(((n=f.current)==null?void 0:n.scrollWidth)||0)/2,s=Math.ceil(r*2/t);W(Math.max(2,s%2===0?s:s+1)),E(t)},0)},[u]),e.useEffect(()=>{p(o==="right"?-c:0)},[c,o]);const S=e.useCallback(r=>{if(!g.current){const t=r??performance.now(),s=t-h.current||16.67;h.current=t,p(a=>{const l=o==="right"?-d:d,n=a-l*(s/1e3);if(o==="left"){if(n<=-c)return n+c}else if(o==="right"&&n>=0)return n-c;return n})}m.current=requestAnimationFrame(S)},[c,d,o]);e.useEffect(()=>(h.current=performance.now(),m.current=requestAnimationFrame(S),()=>{m.current&&cancelAnimationFrame(m.current)}),[S]);const F=e.useCallback(()=>{g.current=!0},[]),j=e.useCallback(()=>{g.current=!1,h.current=performance.now()},[]),C=e.useCallback((r,t=300)=>{const s=i,a=r-s,l=performance.now(),n=k=>{const I=k-l,x=Math.min(I/t,1),_=1-Math.pow(1-x,3);p(s+a*_),x<1&&requestAnimationFrame(n)};requestAnimationFrame(n)},[i]);return e.useImperativeHandle(A,()=>({scrollLeft:()=>{const r=i-200,t=Math.max(r,-c);C(t)},scrollRight:()=>{const r=i+200,t=Math.min(r,c);C(t)}})),M.jsx("div",{className:R.cn(q.default.root,w),onMouseEnter:F,onMouseLeave:j,children:M.jsx("div",{className:R.cn(q.default.content,y),style:{transform:`translate3D(${i}px, 0, 0)`},ref:f,children:Array.from({length:u.length*T},(r,t)=>M.jsx("div",{className:R.cn(q.default.item,v),children:b(u[t%u.length],t)},t))})})}const N=e.forwardRef(L);exports.InfiniteScroll=N;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),t=require("react"),v=require("../../utils/cn/cn.cjs.js"),M=require("./infiniteScroll.module.css.cjs.js");function N({items:u,speed:R=50,direction:h="left",contentClassName:T,itemClassName:F,rootClassName:P,renderItem:k},x){const i=t.useRef(null),S=t.useRef(null),f=t.useRef(null),d=t.useRef(!1),p=t.useRef(performance.now()),[m,y]=t.useState(0),[r,j]=t.useState(0),[s,E]=t.useState(4),q=t.useCallback(()=>{if(!S.current||!i.current||u.length===0)return;const e=S.current.scrollWidth/s,o=i.current.offsetWidth,l=Math.ceil(o*2.5/e),a=Math.max(4,Math.min(20,l%2===0?l:l+1));E(a),j(e);const c=Math.floor(a/2);y(-e*c)},[u.length,s]);t.useEffect(()=>{q();const n=new ResizeObserver(()=>{q()});return i.current&&n.observe(i.current),()=>n.disconnect()},[q]);const C=t.useCallback(n=>{if(d.current||r===0){f.current=requestAnimationFrame(C);return}const e=n??performance.now(),o=e-p.current||16.67;p.current=e,y(l=>{const a=h==="right"?-R:R;let c=l-a*(o/1e3);const W=r*s,g=r*Math.floor(s/2);return h==="left"&&c<=-W+g?c+r:h==="right"&&c>=g?c-r:c}),f.current=requestAnimationFrame(C)},[h,R,r,s]);t.useEffect(()=>(p.current=performance.now(),f.current=requestAnimationFrame(C),()=>{f.current&&cancelAnimationFrame(f.current)}),[C]);const I=t.useCallback(n=>{d.current=!0,n.pointerType==="mouse"&&(d.current=!0)},[]),L=t.useCallback(n=>{n.pointerType==="mouse"&&(d.current=!1,p.current=performance.now())},[]),w=t.useCallback((n,e=300)=>{const o=m,l=n-o,a=performance.now(),c=W=>{const g=W-a,A=Math.min(g/e,1),_=1-Math.pow(1-A,3);y(o+l*_),A<1&&requestAnimationFrame(c)};requestAnimationFrame(c)},[m]);return t.useImperativeHandle(x,()=>({scrollLeft:()=>{const n=r*s,e=-r*Math.floor(s/2);let o=m-200;o<-n+e&&(o+=r),w(o)},scrollRight:()=>{const n=-r*Math.floor(s/2);let e=m+200;e>n&&(e-=r),w(e)}})),b.jsx("div",{className:v.cn(M.default.root,P),ref:i,onPointerEnter:I,onPointerLeave:L,children:b.jsx("div",{className:v.cn(M.default.content,T),ref:S,style:{transform:`translate3d(${m}px, 0, 0)`},children:Array.from({length:u.length*s},(n,e)=>b.jsx("div",{className:v.cn(M.default.item,F),children:k(u[e%u.length],e)},e))})})}const O=t.forwardRef(N);exports.InfiniteScroll=O;
@@ -1,82 +1,95 @@
1
1
  "use client";
2
- import { jsx as x } from "react/jsx-runtime";
3
- import { forwardRef as H, useRef as h, useState as y, useEffect as C, useCallback as p, useImperativeHandle as P } from "react";
4
- import { cn as R } from "../../utils/cn/cn.es.js";
5
- import v from "./infiniteScroll.module.css.es.js";
6
- function _({
7
- items: l,
8
- speed: d = 50,
9
- direction: c = "left",
10
- contentClassName: W,
11
- itemClassName: q,
12
- rootClassName: F,
13
- renderItem: T
14
- }, E) {
15
- const i = h(null), [u, g] = y(0), [r, I] = y(0), m = h(null), M = h(!1), f = h(performance.now()), [L, N] = y(2);
16
- C(() => {
17
- i.current && l.length > 0 && setTimeout(() => {
18
- var s, a, e;
19
- const n = ((a = (s = i.current) == null ? void 0 : s.parentElement) == null ? void 0 : a.offsetWidth) || 0, t = (((e = i.current) == null ? void 0 : e.scrollWidth) || 0) / 2, o = Math.ceil(n * 2 / t);
20
- N(Math.max(2, o % 2 === 0 ? o : o + 1)), I(t);
21
- }, 0);
22
- }, [l]), C(() => {
23
- g(c === "right" ? -r : 0);
24
- }, [r, c]);
25
- const w = p(
26
- (n) => {
27
- if (!M.current) {
28
- const t = n ?? performance.now(), o = t - f.current || 16.67;
29
- f.current = t, g((s) => {
30
- const a = c === "right" ? -d : d, e = s - a * (o / 1e3);
31
- if (c === "left") {
32
- if (e <= -r)
33
- return e + r;
34
- } else if (c === "right" && e >= 0)
35
- return e - r;
36
- return e;
37
- });
2
+ import { jsx as S } from "react/jsx-runtime";
3
+ import { forwardRef as H, useRef as m, useState as A, useCallback as h, useEffect as b, useImperativeHandle as _ } from "react";
4
+ import { cn as q } from "../../utils/cn/cn.es.js";
5
+ import F from "./infiniteScroll.module.css.es.js";
6
+ function $({
7
+ items: a,
8
+ speed: W = 50,
9
+ direction: d = "left",
10
+ contentClassName: x,
11
+ itemClassName: L,
12
+ rootClassName: E,
13
+ renderItem: I
14
+ }, N) {
15
+ const i = m(null), v = m(null), u = m(null), p = m(!1), g = m(performance.now()), [f, w] = A(0), [n, X] = A(0), [c, O] = A(4), M = h(() => {
16
+ if (!v.current || !i.current || a.length === 0) return;
17
+ const t = v.current.scrollWidth / c, r = i.current.offsetWidth, s = Math.ceil(r * 2.5 / t), l = Math.max(4, Math.min(20, s % 2 === 0 ? s : s + 1));
18
+ O(l), X(t);
19
+ const o = Math.floor(l / 2);
20
+ w(-t * o);
21
+ }, [a.length, c]);
22
+ b(() => {
23
+ M();
24
+ const e = new ResizeObserver(() => {
25
+ M();
26
+ });
27
+ return i.current && e.observe(i.current), () => e.disconnect();
28
+ }, [M]);
29
+ const y = h(
30
+ (e) => {
31
+ if (p.current || n === 0) {
32
+ u.current = requestAnimationFrame(y);
33
+ return;
38
34
  }
39
- m.current = requestAnimationFrame(w);
35
+ const t = e ?? performance.now(), r = t - g.current || 16.67;
36
+ g.current = t, w((s) => {
37
+ const l = d === "right" ? -W : W;
38
+ let o = s - l * (r / 1e3);
39
+ const R = n * c, C = n * Math.floor(c / 2);
40
+ return d === "left" && o <= -R + C ? o + n : d === "right" && o >= C ? o - n : o;
41
+ }), u.current = requestAnimationFrame(y);
40
42
  },
41
- [r, d, c]
43
+ [d, W, n, c]
42
44
  );
43
- C(() => (f.current = performance.now(), m.current = requestAnimationFrame(w), () => {
44
- m.current && cancelAnimationFrame(m.current);
45
- }), [w]);
46
- const X = p(() => {
47
- M.current = !0;
48
- }, []), b = p(() => {
49
- M.current = !1, f.current = performance.now();
50
- }, []), A = p(
51
- (n, t = 300) => {
52
- const o = u, s = n - o, a = performance.now(), e = (j) => {
53
- const k = j - a, S = Math.min(k / t, 1), D = 1 - Math.pow(1 - S, 3);
54
- g(o + s * D), S < 1 && requestAnimationFrame(e);
45
+ b(() => (g.current = performance.now(), u.current = requestAnimationFrame(y), () => {
46
+ u.current && cancelAnimationFrame(u.current);
47
+ }), [y]);
48
+ const j = h((e) => {
49
+ p.current = !0, e.pointerType === "mouse" && (p.current = !0);
50
+ }, []), k = h((e) => {
51
+ e.pointerType === "mouse" && (p.current = !1, g.current = performance.now());
52
+ }, []), T = h(
53
+ (e, t = 300) => {
54
+ const r = f, s = e - r, l = performance.now(), o = (R) => {
55
+ const C = R - l, P = Math.min(C / t, 1), z = 1 - Math.pow(1 - P, 3);
56
+ w(r + s * z), P < 1 && requestAnimationFrame(o);
55
57
  };
56
- requestAnimationFrame(e);
58
+ requestAnimationFrame(o);
57
59
  },
58
- [u]
60
+ [f]
59
61
  );
60
- return P(E, () => ({
62
+ return _(N, () => ({
61
63
  scrollLeft: () => {
62
- const n = u - 200, t = Math.max(n, -r);
63
- A(t);
64
+ const e = n * c, t = -n * Math.floor(c / 2);
65
+ let r = f - 200;
66
+ r < -e + t && (r += n), T(r);
64
67
  },
65
68
  scrollRight: () => {
66
- const n = u + 200, t = Math.min(n, r);
67
- A(t);
69
+ const e = -n * Math.floor(c / 2);
70
+ let t = f + 200;
71
+ t > e && (t -= n), T(t);
68
72
  }
69
- })), /* @__PURE__ */ x("div", { className: R(v.root, F), onMouseEnter: X, onMouseLeave: b, children: /* @__PURE__ */ x(
73
+ })), /* @__PURE__ */ S(
70
74
  "div",
71
75
  {
72
- className: R(v.content, W),
73
- style: { transform: `translate3D(${u}px, 0, 0)` },
76
+ className: q(F.root, E),
74
77
  ref: i,
75
- children: Array.from({ length: l.length * L }, (n, t) => /* @__PURE__ */ x("div", { className: R(v.item, q), children: T(l[t % l.length], t) }, t))
78
+ onPointerEnter: j,
79
+ onPointerLeave: k,
80
+ children: /* @__PURE__ */ S(
81
+ "div",
82
+ {
83
+ className: q(F.content, x),
84
+ ref: v,
85
+ style: { transform: `translate3d(${f}px, 0, 0)` },
86
+ children: Array.from({ length: a.length * c }, (e, t) => /* @__PURE__ */ S("div", { className: q(F.item, L), children: I(a[t % a.length], t) }, t))
87
+ }
88
+ )
76
89
  }
77
- ) });
90
+ );
78
91
  }
79
- const J = H(_);
92
+ const K = H($);
80
93
  export {
81
- J as InfiniteScroll
94
+ K as InfiniteScroll
82
95
  };