@brightlocal/ui-components 1.3.0 → 1.4.1

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.
package/dist/list.js CHANGED
@@ -1,9 +1,10 @@
1
- import { jsx as o, jsxs as f, Fragment as p } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as p, Fragment as g } from "react/jsx-runtime";
2
2
  import * as i from "react";
3
- import { cva as g } from "class-variance-authority";
3
+ import { Slot as u } from "@radix-ui/react-slot";
4
+ import { cva as x } from "class-variance-authority";
4
5
  import { cn as l } from "@brightlocal/ui-components/lib/utils";
5
6
  import { Skeleton as m } from "@brightlocal/ui-components/skeleton";
6
- const u = g(
7
+ const N = x(
7
8
  [
8
9
  "flex",
9
10
  "items-center",
@@ -21,125 +22,126 @@ const u = g(
21
22
  variant: {
22
23
  filled: ["bg-card"],
23
24
  outline: ["bg-background", "border", "border-border"],
24
- loading: ["flex-col", "gap-2", "px-0", "pt-0", "pb-2"]
25
+ loading: ["flex-col", "gap-2", "px-0", "pt-0", "pb-3"]
25
26
  }
26
27
  },
27
28
  defaultVariants: {
28
29
  variant: "filled"
29
30
  }
30
31
  }
31
- ), x = i.forwardRef(
32
- ({ className: e, dataHook: t, trackingEl: a, trackingLabel: s, ...r }, d) => /* @__PURE__ */ o(
32
+ ), I = i.forwardRef(
33
+ ({ className: e, dataHook: a, trackingEl: t, trackingLabel: r, ...s }, d) => /* @__PURE__ */ o(
33
34
  "ul",
34
35
  {
35
36
  ref: d,
36
37
  className: l("flex flex-col gap-2", e),
37
- "data-hook": t,
38
+ "data-hook": a,
38
39
  "data-slot": "list",
39
- "data-tracking-el": a,
40
- "data-tracking-label": s,
41
- ...r
40
+ "data-tracking-el": t,
41
+ "data-tracking-label": r,
42
+ ...s
42
43
  }
43
44
  )
44
45
  );
45
- x.displayName = "List";
46
- const N = i.forwardRef(
46
+ I.displayName = "List";
47
+ const b = i.forwardRef(
47
48
  ({
48
- className: e,
49
+ asChild: e = !1,
50
+ className: a,
49
51
  variant: t,
50
- dataHook: a,
52
+ dataHook: r,
51
53
  trackingEl: s,
52
- trackingLabel: r,
53
- children: d,
54
- ...n
55
- }, c) => /* @__PURE__ */ o(
56
- "li",
54
+ trackingLabel: d,
55
+ children: n,
56
+ ...c
57
+ }, f) => /* @__PURE__ */ o(
58
+ e ? u : "li",
57
59
  {
58
- ref: c,
59
- className: l(u({ variant: t }), e),
60
- "data-hook": a,
60
+ ref: f,
61
+ className: l(N({ variant: t }), a),
62
+ "data-hook": r,
61
63
  "data-slot": "item",
62
64
  "data-tracking-el": s,
63
- "data-tracking-label": r,
64
- ...n,
65
- children: t === "loading" ? /* @__PURE__ */ f(p, { children: [
65
+ "data-tracking-label": d,
66
+ ...c,
67
+ children: t === "loading" ? /* @__PURE__ */ p(g, { children: [
66
68
  /* @__PURE__ */ o(m, { className: "h-4 w-full" }),
67
69
  /* @__PURE__ */ o(m, { className: "h-4 w-full" })
68
- ] }) : d
70
+ ] }) : n
69
71
  }
70
72
  )
71
73
  );
72
- N.displayName = "Item";
73
- const I = i.forwardRef(
74
- ({ className: e, ...t }, a) => /* @__PURE__ */ o(
74
+ b.displayName = "Item";
75
+ const k = i.forwardRef(
76
+ ({ className: e, ...a }, t) => /* @__PURE__ */ o(
75
77
  "div",
76
78
  {
77
- ref: a,
79
+ ref: t,
78
80
  className: l("shrink-0", e),
79
81
  "data-slot": "item-media",
80
- ...t
82
+ ...a
81
83
  }
82
84
  )
83
85
  );
84
- I.displayName = "ItemMedia";
85
- const b = i.forwardRef(
86
- ({ className: e, ...t }, a) => /* @__PURE__ */ o(
86
+ k.displayName = "ItemMedia";
87
+ const w = i.forwardRef(
88
+ ({ className: e, ...a }, t) => /* @__PURE__ */ o(
87
89
  "div",
88
90
  {
89
- ref: a,
91
+ ref: t,
90
92
  className: l("flex flex-1 flex-col gap-1", e),
91
93
  "data-slot": "item-content",
92
- ...t
94
+ ...a
93
95
  }
94
96
  )
95
97
  );
96
- b.displayName = "ItemContent";
97
- const k = i.forwardRef(
98
- ({ className: e, ...t }, a) => /* @__PURE__ */ o(
98
+ w.displayName = "ItemContent";
99
+ const y = i.forwardRef(
100
+ ({ className: e, ...a }, t) => /* @__PURE__ */ o(
99
101
  "div",
100
102
  {
101
- ref: a,
103
+ ref: t,
102
104
  className: l("text-foreground text-lg font-medium", e),
103
105
  "data-slot": "item-title",
104
- ...t
106
+ ...a
105
107
  }
106
108
  )
107
109
  );
108
- k.displayName = "ItemTitle";
109
- const w = i.forwardRef(
110
- ({ className: e, ...t }, a) => /* @__PURE__ */ o(
110
+ y.displayName = "ItemTitle";
111
+ const h = i.forwardRef(
112
+ ({ className: e, ...a }, t) => /* @__PURE__ */ o(
111
113
  "div",
112
114
  {
113
- ref: a,
115
+ ref: t,
114
116
  className: l("text-muted-foreground text-base", e),
115
117
  "data-slot": "item-description",
116
- ...t
118
+ ...a
117
119
  }
118
120
  )
119
121
  );
120
- w.displayName = "ItemDescription";
121
- const y = i.forwardRef(
122
- ({ className: e, ...t }, a) => /* @__PURE__ */ o(
122
+ h.displayName = "ItemDescription";
123
+ const v = i.forwardRef(
124
+ ({ className: e, ...a }, t) => /* @__PURE__ */ o(
123
125
  "div",
124
126
  {
125
- ref: a,
127
+ ref: t,
126
128
  className: l(
127
129
  "text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-full",
128
130
  e
129
131
  ),
130
132
  "data-slot": "item-actions",
131
- ...t
133
+ ...a
132
134
  }
133
135
  )
134
136
  );
135
- y.displayName = "ItemActions";
137
+ v.displayName = "ItemActions";
136
138
  export {
137
- N as Item,
138
- y as ItemActions,
139
- b as ItemContent,
140
- w as ItemDescription,
141
- I as ItemMedia,
142
- k as ItemTitle,
143
- x as List,
144
- u as itemVariants
139
+ b as Item,
140
+ v as ItemActions,
141
+ w as ItemContent,
142
+ h as ItemDescription,
143
+ k as ItemMedia,
144
+ y as ItemTitle,
145
+ I as List,
146
+ N as itemVariants
145
147
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),c=require("react"),T=require("framer-motion"),ht=require("flubber"),gt=require("@brightlocal/ui-components/lib/utils"),bt=require("./hooks/use-prefers-reduced-motion.cjs");function yt(u){const S=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const m in u)if(m!=="default"){const P=Object.getOwnPropertyDescriptor(u,m);Object.defineProperty(S,m,P.get?P:{enumerable:!0,get:()=>u[m]})}}return S.default=u,Object.freeze(S)}const Q=yt(c),V="M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z",Y="M492.425 259.355C332.265 293.145 293.145 332.265 259.355 492.425C257.225 502.525 242.775 502.525 240.645 492.425C206.855 332.265 167.735 293.145 7.575 259.355C-2.525 257.225 -2.525 242.775 7.575 240.645C167.735 206.855 206.855 167.735 240.645 7.575C242.775 -2.525 257.225 -2.525 259.355 7.575C293.145 167.735 332.265 206.855 492.425 240.645C502.525 242.775 502.525 257.225 492.425 259.355Z",tt="M258.366 5.58795L296.379 97.3854C298.509 102.526 304.729 104.546 309.47 101.636L394.177 49.7215C401.057 45.5112 409.598 51.7117 407.708 59.5523L384.506 156.16C383.206 161.571 387.046 166.861 392.596 167.301L491.645 175.092C499.685 175.722 502.945 185.763 496.815 191.003L421.259 255.528C417.029 259.138 417.029 265.679 421.259 269.299L496.815 333.824C502.945 339.065 499.685 349.106 491.645 349.736L392.596 357.526C387.046 357.966 383.206 363.257 384.506 368.667L407.708 465.275C409.588 473.116 401.047 479.326 394.177 475.106L309.47 423.192C304.729 420.282 298.509 422.302 296.379 427.442L258.366 519.24C255.275 526.69 244.725 526.69 241.634 519.24L203.621 427.442C201.491 422.302 195.271 420.282 190.53 423.192L105.823 475.106C98.9428 479.316 90.4021 473.116 92.2922 465.275L115.494 368.667C116.794 363.257 112.954 357.966 107.403 357.526L8.35543 349.736C0.314784 349.106 -2.94548 339.065 3.18502 333.824L78.7411 269.299C82.9715 265.689 82.9715 259.148 78.7411 255.528L3.18502 191.003C-2.94548 185.763 0.314784 175.722 8.35543 175.092L107.403 167.301C112.954 166.861 116.794 161.571 115.494 156.16L92.2922 59.5523C90.4121 51.7117 98.9528 45.5012 105.823 49.7215L190.53 101.636C195.271 104.546 201.491 102.526 203.621 97.3854L241.634 5.58795C244.725 -1.86265 255.275 -1.86265 258.366 5.58795Z",j=u=>u<0?0:u>1?1:u,Ct=[V,Y,tt,V,tt,Y],et=Q.forwardRef(({className:u,dataHook:S,holdTime:m=1300,shimmer:P=!0,gradientFrom:nt="var(--loading-gradient-from)",gradientTo:st="var(--loading-gradient-to)",trackingEl:rt,trackingLabel:at,children:ot,...it},lt)=>{const o=Ct,q=.8,X=180,z=24,F=1,k=bt.usePrefersReducedMotion(),D=`text-reveal-gradient-${c.useId().replace(/:/g,"")}`,N=c.useRef(null),O=c.useRef(null),_=c.useRef(null),H=c.useRef(null),W=c.useRef(null),w=c.useRef(new Map),$=Q.Children.toArray(ot),[ct,ft]=c.useState({widths:[],ballSize:0}),{widths:R,ballSize:i}=ct,ut=c.useCallback(e=>t=>{t?w.current.set(e,t):w.current.delete(e)},[]);c.useEffect(()=>{if(w.current.size===0)return;const e=requestAnimationFrame(()=>{const t=[];let d=32;w.current.forEach((h,n)=>{if(t[n]=h.scrollWidth,n===0){const v=h.firstElementChild??h,b=parseFloat(getComputedStyle(v).fontSize)||16;d=Math.round(b*1.5)}}),ft({widths:t,ballSize:d})});return()=>cancelAnimationFrame(e)},[$.length]),c.useEffect(()=>{if(k)return;const e=W.current;if(!e)return;const t=e;let d,h=null;const n=.12+Math.random()*.06,v=.08+Math.random()*.04,b=Math.random()*Math.PI*2,U=Math.random()*Math.PI*2;let r=-1/0;function a(f){h||(h=f);const M=(f-h)/1e3,p=Math.sin(M*n+b)*Math.PI+Math.sin(M*v+U)*.5;if(Math.abs(p-r)>.01){r=p;const y=Math.cos(p),A=Math.sin(p);t.setAttribute("x1",`${50+45*y}%`),t.setAttribute("y1",`${50+45*A}%`),t.setAttribute("x2",`${50-45*y}%`),t.setAttribute("y2",`${50-45*A}%`)}d=requestAnimationFrame(a)}return d=requestAnimationFrame(a),()=>cancelAnimationFrame(d)},[k]);function dt(e){e.style.opacity="1",T.animate(0,1,{duration:1.2,ease:[.25,1,.5,1],onUpdate:t=>{e.style.transform=`translateX(${-100+t*200}%)`},onComplete:()=>{e.style.opacity="0"}})}c.useEffect(()=>{if(!_.current||!H.current||!N.current||!O.current||R.length===0||i===0)return;const e=_.current,t=H.current,d=N.current,h=O.current;if(k){e.setAttribute("d",o[0]),t.style.opacity="1";const r=w.current.get(0);r&&(r.style.visibility="visible",r.style.clipPath="none");const a=i*.5,f=(R[0]??0)+a+i/2;d.style.transform=`translateX(${f}px)`;return}let n=!1;const v=i*.5,b=[];for(let r=0;r<o.length;r++)b.push(ht.interpolate(o[r],o[(r+1)%o.length]));async function U(){t.style.opacity="1";let r=0,a=0,f=0;for(;!n;){const M=r%$.length,p=R[M]??0,y=-(v+i/2),A=p+v+i/2,G=A-y,B=w.current.get(M);if(!B)break;w.current.forEach((s,x)=>{s.style.visibility=x===M?"visible":"hidden",s.style.clipPath="inset(0 100% 0 0)"});const pt=b[a%o.length],E=360,J=f;if(await new Promise(s=>{if(n){s();return}const x=T.animate(y,A,{type:"spring",stiffness:X*q,damping:z,mass:F,onUpdate:g=>{if(n){x.stop(),s();return}d.style.transform=`translateX(${g}px)`;const L=p>0?100-j(g/p)*100:100;B.style.clipPath=`inset(0 ${L}% 0 0)`;const C=(g-y)/G;t.style.transform=`rotate(${J+C*E}deg)`,e.setAttribute("d",pt(j(C)))},onComplete:()=>{f=J+E,a=(a+1)%o.length,s()}})}),n)break;if(P&&dt(h),m>0){const s=performance.now();for(;!n&&performance.now()-s<m&&(await new Promise(I=>setTimeout(I,300)),!(n||performance.now()-s>=m));){const x=(a+1)%o.length,g=b[a%o.length],L=f,C=f+360;await T.animate(0,1,{type:"spring",stiffness:30,damping:9,mass:.5,onUpdate:I=>{e.setAttribute("d",g(j(I))),t.style.transform=`rotate(${L+I*(C-L)}deg)`}}),f=C,a=x}}if(n)break;const mt=b[a%o.length],K=f;if(await new Promise(s=>{if(n){s();return}const x=T.animate(A,y,{type:"spring",stiffness:X*q,damping:z,mass:F,onUpdate:g=>{if(n){x.stop(),s();return}d.style.transform=`translateX(${g}px)`;const L=p>0?100-j(g/p)*100:100;B.style.clipPath=`inset(0 ${L}% 0 0)`;const C=1-(g-y)/G;t.style.transform=`rotate(${K-C*E}deg)`,e.setAttribute("d",mt(j(C)))},onComplete:()=>{f=K-E,a=(a+1)%o.length,s()}})}),n)break;await new Promise(s=>setTimeout(s,300)),r++}}return U(),()=>{n=!0}},[R,i,$.length,k,q,m,P,X,z,F,o]);const Z=R.length>0?Math.max(...R):0;return l.jsx("div",{ref:lt,className:gt.cn("relative inline-flex items-center",u),"data-hook":S,"data-slot":"text-reveal","data-tracking-el":rt,"data-tracking-label":at,...it,children:l.jsxs("div",{className:"relative flex items-center",style:{width:Z||void 0},children:[l.jsxs("span",{className:"relative inline-block overflow-hidden",style:{width:Z||void 0},children:[$.map((e,t)=>l.jsx("span",{ref:ut(t),style:{display:"block",whiteSpace:"nowrap",visibility:"hidden",clipPath:"inset(0 100% 0 0)",willChange:"clip-path, visibility",...t>0?{position:"absolute",top:0,left:0}:{}},children:e},t)),l.jsx("div",{ref:O,className:"pointer-events-none absolute inset-0",style:{opacity:0,transform:"translateX(-100%)",willChange:"transform, opacity",background:"linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--background) 40%, transparent) 40%, color-mix(in srgb, var(--background) 70%, transparent) 50%, color-mix(in srgb, var(--background) 40%, transparent) 60%, transparent 100%)"}})]}),l.jsx("div",{ref:N,className:"absolute",style:{left:-i/2,top:"50%",marginTop:-i/2,width:i,height:i,transform:"translateX(0px)",willChange:"transform"},children:l.jsxs("svg",{"aria-label":"Loading","data-slot":"text-reveal-ball",fill:"none",height:i,role:"img",style:{overflow:"visible"},viewBox:"-30 -30 560 560",width:i,xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("defs",{children:l.jsxs("linearGradient",{ref:W,id:D,children:[l.jsx("stop",{offset:"-20%",stopColor:nt}),l.jsx("stop",{offset:"120%",stopColor:st})]})}),l.jsx("g",{ref:H,style:{opacity:0,transformOrigin:"250px 250px",willChange:"transform"},children:l.jsx("path",{ref:_,d:o[0],fill:`url(#${D})`})})]})})]})})});et.displayName="TextRevealMotion";exports.TextRevealMotion=et;
1
+ "use strict";var jt=Object.create;var mt=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Xt=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of It(n))!Ft.call(t,u)&&u!==e&&mt(t,u,{get:()=>n[u],enumerable:!(i=kt(n,u))||i.enumerable});return t};var $t=(t,n,e)=>(e=t!=null?jt(Et(t)):{},Xt(n||!t||!t.__esModule?mt(e,"default",{value:t,enumerable:!0}):e,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),o=require("react"),W=require("framer-motion"),qt=require("@brightlocal/ui-components/lib/utils"),Ot=require("./hooks/use-prefers-reduced-motion.cjs");function Tt(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const ht=Tt(o),gt="M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z",yt="M492.425 259.355C332.265 293.145 293.145 332.265 259.355 492.425C257.225 502.525 242.775 502.525 240.645 492.425C206.855 332.265 167.735 293.145 7.575 259.355C-2.525 257.225 -2.525 242.775 7.575 240.645C167.735 206.855 206.855 167.735 240.645 7.575C242.775 -2.525 257.225 -2.525 259.355 7.575C293.145 167.735 332.265 206.855 492.425 240.645C502.525 242.775 502.525 257.225 492.425 259.355Z",Ct="M258.366 5.58795L296.379 97.3854C298.509 102.526 304.729 104.546 309.47 101.636L394.177 49.7215C401.057 45.5112 409.598 51.7117 407.708 59.5523L384.506 156.16C383.206 161.571 387.046 166.861 392.596 167.301L491.645 175.092C499.685 175.722 502.945 185.763 496.815 191.003L421.259 255.528C417.029 259.138 417.029 265.679 421.259 269.299L496.815 333.824C502.945 339.065 499.685 349.106 491.645 349.736L392.596 357.526C387.046 357.966 383.206 363.257 384.506 368.667L407.708 465.275C409.588 473.116 401.047 479.326 394.177 475.106L309.47 423.192C304.729 420.282 298.509 422.302 296.379 427.442L258.366 519.24C255.275 526.69 244.725 526.69 241.634 519.24L203.621 427.442C201.491 422.302 195.271 420.282 190.53 423.192L105.823 475.106C98.9428 479.316 90.4021 473.116 92.2922 465.275L115.494 368.667C116.794 363.257 112.954 357.966 107.403 357.526L8.35543 349.736C0.314784 349.106 -2.94548 339.065 3.18502 333.824L78.7411 269.299C82.9715 265.689 82.9715 259.148 78.7411 255.528L3.18502 191.003C-2.94548 185.763 0.314784 175.722 8.35543 175.092L107.403 167.301C112.954 166.861 116.794 161.571 115.494 156.16L92.2922 59.5523C90.4121 51.7117 98.9528 45.5012 105.823 49.7215L190.53 101.636C195.271 104.546 201.491 102.526 203.621 97.3854L241.634 5.58795C244.725 -1.86265 255.275 -1.86265 258.366 5.58795Z",D=t=>t<0?0:t>1?1:t,_t=[gt,yt,Ct,gt,Ct,yt],Dt=30,zt=15,Ht=typeof navigator<"u"&&typeof navigator.hardwareConcurrency=="number"&&navigator.hardwareConcurrency<=4;function Nt(t,n,e){let i=!1,u=null;const h={ballX:0,clipRight:100,rotate:0,pathD:""};function B(){i=!1,t.style.transform=`translateX(${h.ballX}px)`,u&&(u.style.clipPath=`inset(0 ${h.clipRight}% 0 0)`),n.style.transform=`rotate(${h.rotate}deg)`,e.setAttribute("d",h.pathD)}function z(O,Z,G,c){h.ballX=O,h.clipRight=Z,h.rotate=G,h.pathD=c,i||(i=!0,requestAnimationFrame(B))}return z.setItem=O=>{u=O},z}function wt(t,n){return new Promise(e=>{const i=performance.now();function u(){n.cancelled||performance.now()-i>=t?e():requestAnimationFrame(u)}requestAnimationFrame(u)})}const bt=ht.forwardRef(({className:t,dataHook:n,holdTime:e=1300,shimmer:i=!0,gradientFrom:u="var(--loading-gradient-from)",gradientTo:h="var(--loading-gradient-to)",trackingEl:B,trackingLabel:z,children:O,...Z},G)=>{const c=_t,J=.8,K=180,Q=24,V=1,H=Ot.usePrefersReducedMotion(),at=o.useId(),ot=o.useMemo(()=>`text-reveal-gradient-${at.replace(/:/g,"")}`,[at]),Y=o.useRef(null),tt=o.useRef(null),et=o.useRef(null),nt=o.useRef(null),ct=o.useRef(null),rt=o.useRef(null),st=o.useRef(null),j=o.useRef([]),F=ht.Children.toArray(O),[xt,Rt]=o.useState({widths:[],ballSize:0}),{widths:y,ballSize:f}=xt,Mt=o.useCallback(a=>r=>{j.current[a]=r},[]);o.useEffect(()=>{if(j.current.length===0||!j.current[0])return;let a=!1;function r(){if(a)return;const C=[];let M=32;for(let w=0;w<F.length;w++){const v=j.current[w];if(v&&(C[w]=v.scrollWidth,w===0)){const X=v.firstElementChild??v,s=parseFloat(getComputedStyle(X).fontSize)||16;M=Math.round(s*1.5)}}Rt({widths:C,ballSize:M})}return document.fonts.ready.then(()=>{a||requestAnimationFrame(r)}),()=>{a=!0}},[F.length]),o.useEffect(()=>{if(H)return;const a=ct.current;if(!a)return;const r=a;let C,M=null;const w=.12+Math.random()*.06,v=.08+Math.random()*.04,X=Math.random()*Math.PI*2,s=Math.random()*Math.PI*2;let T=-1/0;function N(g){M||(M=g);const d=(g-M)/1e3,m=Math.sin(d*w+X)*Math.PI+Math.sin(d*v+s)*.5;if(Math.abs(m-T)>.01){T=m;const k=Math.cos(m),_=Math.sin(m);r.setAttribute("x1",`${50+45*k}%`),r.setAttribute("y1",`${50+45*_}%`),r.setAttribute("x2",`${50-45*k}%`),r.setAttribute("y2",`${50-45*_}%`)}C=requestAnimationFrame(N)}return C=requestAnimationFrame(N),()=>cancelAnimationFrame(C)},[H]);function vt(a){a.style.opacity="1",W.animate(0,1,{duration:1.2,ease:[.25,1,.5,1],onUpdate:r=>{a.style.transform=`translateX(${-100+r*200}%)`},onComplete:()=>{a.style.opacity="0"}})}o.useEffect(()=>{if(!et.current||!nt.current||!Y.current||!tt.current||!rt.current||!st.current||y.length===0||f===0)return;const a=et.current,r=nt.current,C=Y.current,M=tt.current,w=rt.current,v=st.current;function X(g){const d=`${g}px`;w.style.width=d,v.style.width=d}if(H){a.setAttribute("d",c[0]),r.style.opacity="1";const g=j.current[0];g&&(g.style.opacity="1",g.style.clipPath="none"),X(y[0]??0);const d=f*.25,m=(y[0]??0)+d+f/2;C.style.transform=`translateX(${m}px)`;return}const s={cancelled:!1},T=f*.25;async function N(){const{interpolate:g}=await import("flubber");if(s.cancelled)return;const d=Ht?zt:Dt,m=[];for(let L=0;L<c.length;L++){const S=g(c[L],c[(L+1)%c.length]),A=[];for(let P=0;P<=d;P++)A.push(S(P/d));m.push(A)}const k=Nt(C,r,a);r.style.opacity="1";let _=0,b=0,I=0;for(;!s.cancelled;){const L=_%F.length,S=y[L]??0;X(S);const A=-(T+f/2),P=S+T+f/2,it=P-A,ut=j.current[L];if(!ut)break;k.setItem(ut);for(let l=0;l<F.length;l++){const x=j.current[l];x&&(x.style.opacity=l===L?"1":"0",x.style.clipPath="inset(0 100% 0 0)")}const St=m[b%c.length],U=360,ft=I;if(await new Promise(l=>{if(s.cancelled){l();return}const x=W.animate(A,P,{type:"spring",stiffness:K*J,damping:Q,mass:V,onUpdate:R=>{if(s.cancelled){x.stop(),l();return}const E=D((R-A)/it),$=S>0?100-D(R/S)*100:100,q=Math.round(E*d);k(R,$,ft+E*U,St[q])},onComplete:()=>{I=ft+U,b=(b+1)%c.length,l()}})}),s.cancelled)break;if(i&&vt(M),e>0){const l=performance.now(),x=P;for(;!s.cancelled&&performance.now()-l<e&&(await wt(300,s),!(s.cancelled||performance.now()-l>=e));){const R=(b+1)%c.length,E=m[b%c.length],$=I,q=I+360;await W.animate(0,1,{type:"spring",stiffness:30,damping:9,mass:.5,onUpdate:pt=>{const Pt=Math.round(D(pt)*d);k(x,0,$+pt*(q-$),E[Pt])}}),I=q,b=R}}if(s.cancelled)break;const At=m[b%c.length],dt=I;if(await new Promise(l=>{if(s.cancelled){l();return}const x=W.animate(P,A,{type:"spring",stiffness:K*J,damping:Q,mass:V,onUpdate:R=>{if(s.cancelled){x.stop(),l();return}const E=D(1-(R-A)/it),$=S>0?100-D(R/S)*100:100,q=Math.round(E*d);k(R,$,dt-E*U,At[q])},onComplete:()=>{I=dt-U,b=(b+1)%c.length,l()}})}),s.cancelled)break;await wt(300,s),_++}}return N(),()=>{s.cancelled=!0}},[y,f,F.length,H,J,e,i,K,Q,V,c]);const lt=o.useMemo(()=>y.length>0?Math.max(...y):0,[y]),Lt=y.length>0&&f>0;return p.jsx("div",{ref:G,className:qt.cn("relative inline-flex items-center",t),"data-hook":n,"data-slot":"text-reveal","data-tracking-el":B,"data-tracking-label":z,style:{opacity:Lt?1:0,transition:"opacity 0.4s ease-out"},...Z,children:p.jsxs("div",{ref:rt,className:"relative flex items-center",style:{width:lt||void 0,transition:"width 0.3s ease-out"},children:[p.jsxs("span",{ref:st,className:"relative inline-block overflow-hidden",style:{width:lt||void 0,transition:"width 0.3s ease-out"},children:[F.map((a,r)=>p.jsx("span",{ref:Mt(r),style:{display:"block",whiteSpace:"nowrap",opacity:0,clipPath:"inset(0 100% 0 0)",willChange:"clip-path",...r>0?{position:"absolute",top:0,left:0}:{}},children:a},r)),p.jsx("div",{ref:tt,className:"pointer-events-none absolute inset-0",style:{opacity:0,transform:"translateX(-100%)",willChange:"transform",background:"linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--background) 40%, transparent) 40%, color-mix(in srgb, var(--background) 70%, transparent) 50%, color-mix(in srgb, var(--background) 40%, transparent) 60%, transparent 100%)"}})]}),p.jsx("div",{ref:Y,className:"absolute",style:{left:-f/2,top:"50%",marginTop:-f/2,width:f,height:f,transform:"translateX(0px)",willChange:"transform"},children:p.jsxs("svg",{"aria-label":"Loading","data-slot":"text-reveal-ball",fill:"none",height:f,role:"img",style:{overflow:"visible"},viewBox:"-30 -30 560 560",width:f,xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{ref:ct,id:ot,children:[p.jsx("stop",{offset:"-20%",stopColor:u}),p.jsx("stop",{offset:"120%",stopColor:h})]})}),p.jsx("g",{ref:nt,style:{opacity:0,transformOrigin:"250px 250px",willChange:"transform"},children:p.jsx("path",{ref:et,d:c[0],fill:`url(#${ot})`})})]})})]})})});bt.displayName="TextRevealMotion";exports.TextRevealMotion=bt;
@@ -1 +1 @@
1
- {"version":3,"file":"text-reveal-motion.d.ts","sourceRoot":"","sources":["../../src/components/text-reveal-motion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsC/B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EACrC,UAAU,CACX;IACC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,8FA8brB,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"text-reveal-motion.d.ts","sourceRoot":"","sources":["../../src/components/text-reveal-motion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmI/B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EACrC,UAAU,CACX;IACC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,8FAqgBrB,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}