@cntrl-site/components 1.0.63 → 1.0.64

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/index.js CHANGED
@@ -2601,7 +2601,7 @@ ${o}
2601
2601
  left: -9999px;
2602
2602
  top: 0;
2603
2603
  }
2604
- `}const rg=30,Ur=3,ag=12,sg=3,La=.72,lg=100,cg=10,dg=e=>Math.max(0,e)/lg,ug=e=>Math.max(0,e)/cg,pg=e=>{e.style.setProperty("animation-name","none"),e.style.setProperty("-webkit-animation-name","none"),e.offsetHeight,e.style.removeProperty("animation-name"),e.style.removeProperty("-webkit-animation-name")},mg=(e,t)=>Array.from({length:t*e.length},(n,i)=>e[i%e.length]),Si={ctx:void 0},gg=()=>Si.ctx!==void 0?Si.ctx:typeof document>"u"?(Si.ctx=null,Si.ctx):(Si.ctx=document.createElement("canvas").getContext("2d"),Si.ctx),hg=(e,t,n,i)=>{e.style.transform=`translate3d(${t}px, ${n}px, 0) rotate(${i}deg)`},fg=e=>{e.style.transform=""},yg=e=>{if(!e||e==="none")return 0;try{return new DOMMatrixReadOnly(e).m41}catch{return 0}},vg=(e,t)=>{const n=(i,o)=>{if(!i||i===t)return o;const s=o+i.offsetLeft,l=i.offsetParent;return!l||l===i?s:n(l,s)};return n(e,e.offsetWidth/2)},xg=96,bg=(e,t,n)=>{if(t<=0||e<=0||n<2)return null;const i=2*Math.PI/t,o=new Float64Array(n+1),s=new Float64Array(n+1),l=e*t,d=u=>Math.sqrt(1+(l*Math.cos(t*u))**2),c=i/n;return Array.from({length:n},(u,p)=>{const v=p*c,y=v+c;o[p+1]=y,s[p+1]=s[p]+(d(v)+d(y))*.5*c}),{wavelength:i,periodArc:s[n],x:o,s}},wg=(e,t)=>{if(e.periodArc<=0)return t;const n=t<0?-1:1,i=Math.abs(t),o=Math.floor(i/e.periodArc),s=i-o*e.periodArc,{s:l,x:d}=e,c=(g,h)=>{if(h-g<=1)return[g,h];const m=g+h>>1;return l[m]<=s?c(m,h):c(g,m)},[u,p]=c(0,l.length-1),v=l[p]-l[u],y=v>0?(s-l[u])/v:0;return n*(o*e.wavelength+d[u]+(d[p]-d[u])*y)},Sg=(e,t,n,i)=>{const o=Math.max(0,n),s=e>0?2*Math.PI*o/e:0,l=p=>i+t*Math.sin(s*p),d=p=>t*s*Math.cos(s*p),c=Math.max(4,Math.ceil(o*4)),u=Array.from({length:c},(p,v)=>{const y=v/c*e,g=(v+1)/c*e,h=g-y,m=l(y),b=l(g),I=y+h/3,R=m+d(y)*h/3,T=g-h/3,q=b-d(g)*h/3;return`C${I.toFixed(2)} ${R.toFixed(2)} ${T.toFixed(2)} ${q.toFixed(2)} ${g.toFixed(2)} ${b.toFixed(2)}`});return[`M0 ${l(0).toFixed(2)}`,...u].join(" ")},$g=({item:e,prefix:t,textCss:n,capHeightPx:i,opticalOffsetY:o,imageGapPx:s,isCurve:l})=>{var g;const d=o!==0?{...n,transform:`translateY(${o}px)`}:n,c=i>0?{height:`${i}px`}:{fontSize:n.fontSize,height:`${La}em`},u=((g=e.image)==null?void 0:g.url)&&r.jsx("img",{src:e.image.url,alt:e.image.name??"",className:`${t}-item-image`,style:c}),p=u&&(l?r.jsx("span",{className:`${t}-item-image-wrap`,"data-marquee-wave-node":!0,children:u}):u),v=l?r.jsx("span",{className:`${t}-text`,style:d,children:Array.from(e.text).map((h,m)=>r.jsx("span",{className:`${t}-glyph`,"data-marquee-wave-node":!0,children:r.jsx("span",{className:`${t}-glyph-inner`,children:h===" "?" ":h})},m))}):r.jsx("span",{className:`${t}-text`,style:d,children:e.text}),y=r.jsxs(r.Fragment,{children:[p,v]});return r.jsx("div",{className:`${t}-item`,"data-marquee-text-item":!0,style:{gap:s},children:e.link?r.jsx("a",{href:e.link,className:`${t}-item-link`,style:{gap:s},children:y}):y})},Cg=({settings:e,content:t,isEditor:n,isPreviewMode:i})=>{const{prefix:o}=C.useScopedStyles(),[s,l]=a.useState(0),d=s>0?Math.round(s):0,{speed:c,direction:u,pauseOnHover:p,gap:v,layoutType:y,curveAmplitude:g,curveFrequency:h,textFontFamily:m,textFontSettings:b,textFontSize:I,textLineHeight:R,textLetterSpacing:T,textWordSpacing:q,textTextAppearance:F,textColor:V,backgroundColor:A,ribbonWidth:L}=e,O=L??R,x=y==="curve",W=dg(g),E=ug(h),J=a.useMemo(()=>og(o,d,x),[o,d,x]),P=a.useMemo(()=>Xt({fontSettings:{fontFamily:m,fontWeight:b.fontWeight,fontStyle:b.fontStyle},letterSpacing:T,wordSpacing:q,fontSize:I,lineHeight:R,textAppearance:F,color:V},n),[m,b,T,q,I,R,F,V,n]),K=ne=>C.scalingValue(ne,n??!1),B=((t==null?void 0:t.length)??0)>0,z=n?!!i:!0,ie=B&&(z||!!n),S=Math.max(0,c)*rg,M=z&&p==="on",[D,le]=a.useState(!1),oe=z?M&&D?"paused":"running":"paused",$=oe==="running"&&S>0&&d>0,ae=a.useRef(null),k=a.useRef(null),te=a.useRef(null),X=a.useRef(null),ve=a.useRef(null),Pe=a.useRef(null),he=a.useRef($),ce=a.useRef(null);he.current=$;const[U,Y]=a.useState(0),[Z,We]=a.useState(0),[$e,ke]=a.useState(0),[de,fe]=a.useState(0),[we,G]=a.useState(0),se=a.useMemo(()=>(t??[]).map(ne=>{var ge;return`${ne.text}\0${((ge=ne.image)==null?void 0:ge.url)??""}`}).join("\0"),[t]),[pe,Se]=a.useState(Ur),Me=a.useMemo(()=>{const ne=t??[];return ne.length===0||!(z||n)?ne:mg(ne,pe)},[t,z,pe,n]),Le=ie?sg:1;a.useLayoutEffect(()=>{Se(Ur),l(0)},[se]),a.useLayoutEffect(()=>{var Ze;const ne=Pe.current;if(!ne)return;const ge=()=>{const Ve=getComputedStyle(ne),at=parseFloat(Ve.fontSize)||0;if(at<=0)return;const Je=gg();if(!Je){Y(at*La),We(0);return}Je.font=`${Ve.fontStyle} ${Ve.fontWeight} ${at}px ${Ve.fontFamily}`;const Ee=Je.measureText("H"),qe=Ee.actualBoundingBoxAscent>0?Ee.actualBoundingBoxAscent:at*La,_e=Math.max(0,Ee.actualBoundingBoxDescent||0),tt=Ee.fontBoundingBoxAscent||0,rt=Ee.fontBoundingBoxDescent||0;Y(Tt=>Math.abs(Tt-qe)>.5?qe:Tt);const lt=tt>0||rt>0?(rt-_e-(tt-qe))/2:0;We(Tt=>Math.abs(Tt-lt)>.25?lt:Tt)};ge();const Ie=typeof document<"u"?document.fonts:void 0;(Ze=Ie==null?void 0:Ie.ready)==null||Ze.then(ge).catch(()=>{});const Ge=new ResizeObserver(ge);return Ge.observe(ne),()=>Ge.disconnect()},[P.fontFamily,P.fontWeight,P.fontStyle,P.fontSize,P.lineHeight]),a.useLayoutEffect(()=>{if(!ie)return;const ne=ae.current,ge=X.current;if(!ne||!ge)return;const Ie={id:0},Ge=()=>{const Ve=ne.getBoundingClientRect().width||ne.offsetWidth,at=ge.getBoundingClientRect().width||ge.offsetWidth;if(B&&Ve>0&&at>0){const Je=at/pe;if(Je>0){const Ee=Math.min(ag,Math.max(Ur,Math.ceil(Ve/Je)+1));if(Ee!==pe){Se(Ee);return}}}at>0&&l(at)};Ie.id=requestAnimationFrame(Ge);const Ze=new ResizeObserver(()=>{cancelAnimationFrame(Ie.id),Ie.id=requestAnimationFrame(Ge)});return Ze.observe(ne),Ze.observe(ge),()=>{cancelAnimationFrame(Ie.id),Ze.disconnect()}},[ie,se,pe,B,U]),a.useLayoutEffect(()=>{const ne=ve.current;if(!ne)return;const ge={id:0},Ie=()=>{const Ze=ne.offsetHeight;Ze>0&&G(Ve=>Math.abs(Ve-Ze)>.5?Ze:Ve)};ge.id=requestAnimationFrame(Ie);const Ge=new ResizeObserver(()=>{cancelAnimationFrame(ge.id),ge.id=requestAnimationFrame(Ie)});return Ge.observe(ne),()=>{cancelAnimationFrame(ge.id),Ge.disconnect()}},[O,n]),a.useLayoutEffect(()=>{if(!x){ke(0),fe(0);return}const ne=ae.current,ge=X.current;if(!ne||!ge)return;const Ie={id:0},Ge=()=>{const Ve=ne.offsetWidth,at=ge.offsetHeight;Ve>0&&fe(Je=>Math.abs(Je-Ve)>.5?Ve:Je),at>0&&ke(Je=>Math.abs(Je-at)>.5?at:Je)};Ie.id=requestAnimationFrame(Ge);const Ze=new ResizeObserver(()=>{cancelAnimationFrame(Ie.id),Ie.id=requestAnimationFrame(Ge)});return Ze.observe(ne),Ze.observe(ge),()=>{cancelAnimationFrame(Ie.id),Ze.disconnect()}},[x,se,U,R,I,ie]),a.useLayoutEffect(()=>{if(!ie||d<=0)return;const ne=te.current;ne&&pg(ne)},[ie,d,u,S]),a.useLayoutEffect(()=>{if(!x||!B)return;const ne=ae.current;if(!ne)return;const ge={raf:0,cancelled:!1,lut:null,lutKey:"",itemsCache:[],cacheDirty:!0},Ie=()=>{for(const Ee of ge.itemsCache)for(const qe of Ee.glyphs)fg(qe.inner)},Ge=()=>{const Ee=k.current??ne;ge.itemsCache=Array.from(ne.querySelectorAll("[data-marquee-text-item]"),qe=>{const _e=[];return qe.querySelectorAll("[data-marquee-wave-node]").forEach(tt=>{const rt=tt.firstElementChild;rt&&_e.push({inner:rt,layoutLocalX:vg(tt,Ee)})}),{item:qe,glyphs:_e}}),ge.cacheDirty=!1},Ze=()=>{ge.cacheDirty&&Ge();const qe=(k.current??ne).offsetWidth||1,_e=qe*W,tt=2*Math.PI*E/qe,rt=`${qe}|${_e}|${tt}`;rt!==ge.lutKey&&(ge.lutKey=rt,ge.lut=bg(_e,tt,xg));const lt=te.current,Tt=lt?yg(getComputedStyle(lt).transform):0,Ut=ne.getBoundingClientRect(),Zt=Ut.left,xt=Ut.right,wt=ge.lut&&ge.lut.wavelength>0?Math.max(0,(ge.lut.periodArc/ge.lut.wavelength-1)*qe):0;for(const{item:jt,glyphs:At}of ge.itemsCache){const vt=jt.getBoundingClientRect();if(!(vt.right<Zt||vt.left>xt+wt))for(const Ft of At){const _t=Ft.layoutLocalX+Tt,Kt=ge.lut?wg(ge.lut,_t):_t,Jt=tt*Kt,Ct=_e*Math.sin(Jt),Ht=_e*tt*Math.cos(Jt),on=Math.atan(Ht)*(180/Math.PI);hg(Ft.inner,Kt-_t,Ct,on)}}},Ve=()=>{ge.cancelled||(ge.raf=0,Ze(),he.current&&!document.hidden&&(ge.raf=requestAnimationFrame(Ve)))},at=()=>{ge.cancelled||ge.raf||(ge.raf=requestAnimationFrame(Ve))};ce.current=at,at();const Je=()=>{if(document.hidden){cancelAnimationFrame(ge.raf),ge.raf=0;return}at()};return document.addEventListener("visibilitychange",Je),()=>{ge.cancelled=!0,ce.current=null,cancelAnimationFrame(ge.raf),document.removeEventListener("visibilitychange",Je),Ie()}},[x,W,E,B,s,se,pe,U]),a.useLayoutEffect(()=>{var ne;(ne=ce.current)==null||ne.call(ce)},[$]);const H=()=>{M&&le(!0)},ye=()=>{M&&le(!1)},re=x?W*100:0,_=K(O),ee={minHeight:_,...x?{paddingTop:`${re}%`,paddingBottom:`${re}%`}:{}},Ae={height:_,...x?{visibility:"hidden"}:{backgroundColor:A}},ue={gap:K(v),minHeight:_},N=de*W,Ue=we>0?we:$e,Oe=Math.max($e,Ue),dt=x&&de>0&&Oe>0?Sg(de,N,E,N+Oe/2):"",nt=N*2+Oe,ht=dt?r.jsx("svg",{className:`${o}-curve-bg`,viewBox:`0 0 ${de} ${nt}`,preserveAspectRatio:"none","aria-hidden":!0,children:r.jsx("path",{d:dt,fill:"none",stroke:A,strokeWidth:Ue,strokeLinecap:"round",strokeLinejoin:"round"})}):null,st=r.jsx("div",{ref:ve,className:`${o}-ribbon`,style:Ae,"aria-hidden":!0}),Be=(ne,ge,Ie)=>r.jsx($g,{item:ne,prefix:o,textCss:P,capHeightPx:U,opticalOffsetY:Z,imageGapPx:K(v),isCurve:x},`${ge}-${Ie}`),xe=r.jsx("span",{ref:Pe,"aria-hidden":!0,className:`${o}-cap-ref`,style:P,children:"H"}),Fe=d>0&&S>0?d/S*1e3:0,je=`${Math.max(0,Fe)/1e3}s`,Ke=ie?r.jsx("div",{ref:te,className:`${o}-marquee-track`,"data-direction":u,onMouseEnter:H,onMouseLeave:ye,style:{WebkitAnimationDuration:je,animationDuration:je,WebkitAnimationPlayState:oe,animationPlayState:oe},children:Array.from({length:Le},(ne,ge)=>r.jsx("div",{ref:ge===0?X:void 0,className:`${o}-marquee-set`,style:{...ue,paddingRight:K(v)},"aria-hidden":ge>0,children:Me.map((Ie,Ge)=>Be(Ie,ge,Ge))},`set-${ge}`))}):r.jsx("div",{ref:X,className:ut(`${o}-marquee-set`,`${o}-marquee-static`),style:ue,children:t==null?void 0:t.map((ne,ge)=>Be(ne,0,ge))});return r.jsxs("div",{ref:ae,className:`${o}-wrapper`,"aria-label":"Marquee text",children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:J}}),xe,r.jsxs("div",{ref:k,className:`${o}-marquee-wrapper`,style:ee,children:[st,ht,Ke]})]})},Tg=`import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
2604
+ `}const rg=30,Ur=3,ag=12,sg=3,La=.72,lg=100,cg=10,dg=e=>Math.max(0,e)/lg,ug=e=>Math.max(0,e)/cg,pg=e=>{e.style.setProperty("animation-name","none"),e.style.setProperty("-webkit-animation-name","none"),e.offsetHeight,e.style.removeProperty("animation-name"),e.style.removeProperty("-webkit-animation-name")},mg=(e,t)=>Array.from({length:t*e.length},(n,i)=>e[i%e.length]),Si={ctx:void 0},gg=()=>Si.ctx!==void 0?Si.ctx:typeof document>"u"?(Si.ctx=null,Si.ctx):(Si.ctx=document.createElement("canvas").getContext("2d"),Si.ctx),hg=(e,t,n,i)=>{e.style.transform=`translate3d(${t}px, ${n}px, 0) rotate(${i}deg)`},fg=e=>{e.style.transform=""},yg=e=>{if(!e||e==="none")return 0;try{return new DOMMatrixReadOnly(e).m41}catch{return 0}},vg=(e,t)=>{const n=(i,o)=>{if(!i||i===t)return o;const s=o+i.offsetLeft,l=i.offsetParent;return!l||l===i?s:n(l,s)};return n(e,e.offsetWidth/2)},xg=96,bg=(e,t,n)=>{if(t<=0||e<=0||n<2)return null;const i=2*Math.PI/t,o=new Float64Array(n+1),s=new Float64Array(n+1),l=e*t,d=u=>Math.sqrt(1+(l*Math.cos(t*u))**2),c=i/n;return Array.from({length:n},(u,p)=>{const v=p*c,y=v+c;o[p+1]=y,s[p+1]=s[p]+(d(v)+d(y))*.5*c}),{wavelength:i,periodArc:s[n],x:o,s}},wg=(e,t)=>{if(e.periodArc<=0)return t;const n=t<0?-1:1,i=Math.abs(t),o=Math.floor(i/e.periodArc),s=i-o*e.periodArc,{s:l,x:d}=e,c=(g,h)=>{if(h-g<=1)return[g,h];const m=g+h>>1;return l[m]<=s?c(m,h):c(g,m)},[u,p]=c(0,l.length-1),v=l[p]-l[u],y=v>0?(s-l[u])/v:0;return n*(o*e.wavelength+d[u]+(d[p]-d[u])*y)},Sg=(e,t,n,i)=>{const o=Math.max(0,n),s=e>0?2*Math.PI*o/e:0,l=p=>i+t*Math.sin(s*p),d=p=>t*s*Math.cos(s*p),c=Math.max(4,Math.ceil(o*4)),u=Array.from({length:c},(p,v)=>{const y=v/c*e,g=(v+1)/c*e,h=g-y,m=l(y),b=l(g),I=y+h/3,R=m+d(y)*h/3,T=g-h/3,q=b-d(g)*h/3;return`C${I.toFixed(2)} ${R.toFixed(2)} ${T.toFixed(2)} ${q.toFixed(2)} ${g.toFixed(2)} ${b.toFixed(2)}`});return[`M0 ${l(0).toFixed(2)}`,...u].join(" ")},$g=({item:e,prefix:t,textCss:n,capHeightPx:i,opticalOffsetY:o,imageGapPx:s,isCurve:l})=>{var g;const d=o!==0?{...n,transform:`translateY(${o}px)`}:n,c=i>0?{height:`${i}px`}:{fontSize:n.fontSize,height:`${La}em`},u=((g=e.image)==null?void 0:g.url)&&r.jsx("img",{src:e.image.url,alt:e.image.name??"",className:`${t}-item-image`,style:c}),p=u&&(l?r.jsx("span",{className:`${t}-item-image-wrap`,"data-marquee-wave-node":!0,children:u}):u),v=l?r.jsx("span",{className:`${t}-text`,style:d,children:Array.from(e.text).map((h,m)=>r.jsx("span",{className:`${t}-glyph`,"data-marquee-wave-node":!0,children:r.jsx("span",{className:`${t}-glyph-inner`,children:h===" "?" ":h})},m))}):r.jsx("span",{className:`${t}-text`,style:d,children:e.text}),y=r.jsxs(r.Fragment,{children:[p,v]});return r.jsx("div",{className:`${t}-item`,"data-marquee-text-item":!0,style:{gap:s},children:e.link?r.jsx("a",{href:e.link,className:`${t}-item-link`,style:{gap:s},children:y}):y})},Cg=({settings:e,content:t,isEditor:n,isPreviewMode:i})=>{const{prefix:o}=C.useScopedStyles(),[s,l]=a.useState(0),d=s>0?Math.round(s):0,{speed:c,direction:u,pauseOnHover:p,gap:v,layoutType:y,curveAmplitude:g,curveFrequency:h,textFontFamily:m,textFontSettings:b,textFontSize:I,textLineHeight:R,textLetterSpacing:T,textWordSpacing:q,textTextAppearance:F,textColor:V,backgroundColor:A,ribbonWidth:L}=e,O=L??R,x=y==="curve",W=dg(g),E=ug(h),J=a.useMemo(()=>og(o,d,x),[o,d,x]),P=a.useMemo(()=>Xt({fontSettings:{fontFamily:m,fontWeight:b.fontWeight,fontStyle:b.fontStyle},letterSpacing:T,wordSpacing:q,fontSize:I,lineHeight:R,textAppearance:F,color:V},n),[m,b,T,q,I,R,F,V,n]),K=ne=>C.scalingValue(ne,n??!1),B=((t==null?void 0:t.length)??0)>0,z=n?!!i:!0,ie=B&&(z||!!n),S=Math.max(0,c)*rg,M=z&&p==="on",[D,le]=a.useState(!1),oe=z?M&&D?"paused":"running":"paused",$=oe==="running"&&S>0&&d>0,ae=a.useRef(null),k=a.useRef(null),te=a.useRef(null),X=a.useRef(null),ve=a.useRef(null),Pe=a.useRef(null),he=a.useRef($),ce=a.useRef(null);he.current=$;const[U,Y]=a.useState(0),[Z,We]=a.useState(0),[$e,ke]=a.useState(0),[de,fe]=a.useState(0),[we,G]=a.useState(0),se=a.useMemo(()=>(t??[]).map(ne=>{var ge;return`${ne.text}\0${((ge=ne.image)==null?void 0:ge.url)??""}`}).join("\0"),[t]),[pe,Se]=a.useState(Ur),Me=a.useMemo(()=>{const ne=t??[];return ne.length===0||!(z||n)?ne:mg(ne,pe)},[t,z,pe,n]),Le=ie?sg:1;a.useLayoutEffect(()=>{Se(Ur),l(0)},[se]),a.useLayoutEffect(()=>{var Ze;const ne=Pe.current;if(!ne)return;const ge=()=>{const Ve=getComputedStyle(ne),at=parseFloat(Ve.fontSize)||0;if(at<=0)return;const Je=gg();if(!Je){Y(at*La),We(0);return}Je.font=`${Ve.fontStyle} ${Ve.fontWeight} ${at}px ${Ve.fontFamily}`;const Ee=Je.measureText("H"),qe=Ee.actualBoundingBoxAscent>0?Ee.actualBoundingBoxAscent:at*La,_e=Math.max(0,Ee.actualBoundingBoxDescent||0),tt=Ee.fontBoundingBoxAscent||0,rt=Ee.fontBoundingBoxDescent||0;Y(Tt=>Math.abs(Tt-qe)>.5?qe:Tt);const lt=tt>0||rt>0?(rt-_e-(tt-qe))/2:0;We(Tt=>Math.abs(Tt-lt)>.25?lt:Tt)};ge();const Ie=typeof document<"u"?document.fonts:void 0;(Ze=Ie==null?void 0:Ie.ready)==null||Ze.then(ge).catch(()=>{});const Ge=new ResizeObserver(ge);return Ge.observe(ne),()=>Ge.disconnect()},[P.fontFamily,P.fontWeight,P.fontStyle,P.fontSize,P.lineHeight]),a.useLayoutEffect(()=>{if(!ie)return;const ne=ae.current,ge=X.current;if(!ne||!ge)return;const Ie={id:0},Ge=()=>{const Ve=ne.offsetWidth||ne.getBoundingClientRect().width,at=ge.offsetWidth||ge.getBoundingClientRect().width;if(B&&Ve>0&&at>0){const Je=at/pe;if(Je>0){const Ee=Math.min(ag,Math.max(Ur,Math.ceil(Ve/Je)+1));if(Ee!==pe){Se(Ee);return}}}at>0&&l(at)};Ie.id=requestAnimationFrame(Ge);const Ze=new ResizeObserver(()=>{cancelAnimationFrame(Ie.id),Ie.id=requestAnimationFrame(Ge)});return Ze.observe(ne),Ze.observe(ge),()=>{cancelAnimationFrame(Ie.id),Ze.disconnect()}},[ie,se,pe,B,U]),a.useLayoutEffect(()=>{const ne=ve.current;if(!ne)return;const ge={id:0},Ie=()=>{const Ze=ne.offsetHeight;Ze>0&&G(Ve=>Math.abs(Ve-Ze)>.5?Ze:Ve)};ge.id=requestAnimationFrame(Ie);const Ge=new ResizeObserver(()=>{cancelAnimationFrame(ge.id),ge.id=requestAnimationFrame(Ie)});return Ge.observe(ne),()=>{cancelAnimationFrame(ge.id),Ge.disconnect()}},[O,n]),a.useLayoutEffect(()=>{if(!x){ke(0),fe(0);return}const ne=ae.current,ge=X.current;if(!ne||!ge)return;const Ie={id:0},Ge=()=>{const Ve=ne.offsetWidth,at=ge.offsetHeight;Ve>0&&fe(Je=>Math.abs(Je-Ve)>.5?Ve:Je),at>0&&ke(Je=>Math.abs(Je-at)>.5?at:Je)};Ie.id=requestAnimationFrame(Ge);const Ze=new ResizeObserver(()=>{cancelAnimationFrame(Ie.id),Ie.id=requestAnimationFrame(Ge)});return Ze.observe(ne),Ze.observe(ge),()=>{cancelAnimationFrame(Ie.id),Ze.disconnect()}},[x,se,U,R,I,ie]),a.useLayoutEffect(()=>{if(!ie||d<=0)return;const ne=te.current;ne&&pg(ne)},[ie,d,u,S]),a.useLayoutEffect(()=>{if(!x||!B)return;const ne=ae.current;if(!ne)return;const ge={raf:0,cancelled:!1,lut:null,lutKey:"",itemsCache:[],cacheDirty:!0},Ie=()=>{for(const Ee of ge.itemsCache)for(const qe of Ee.glyphs)fg(qe.inner)},Ge=()=>{const Ee=k.current??ne;ge.itemsCache=Array.from(ne.querySelectorAll("[data-marquee-text-item]"),qe=>{const _e=[];return qe.querySelectorAll("[data-marquee-wave-node]").forEach(tt=>{const rt=tt.firstElementChild;rt&&_e.push({inner:rt,layoutLocalX:vg(tt,Ee)})}),{item:qe,glyphs:_e}}),ge.cacheDirty=!1},Ze=()=>{ge.cacheDirty&&Ge();const qe=(k.current??ne).offsetWidth||1,_e=qe*W,tt=2*Math.PI*E/qe,rt=`${qe}|${_e}|${tt}`;rt!==ge.lutKey&&(ge.lutKey=rt,ge.lut=bg(_e,tt,xg));const lt=te.current,Tt=lt?yg(getComputedStyle(lt).transform):0,Ut=ne.getBoundingClientRect(),Zt=Ut.left,xt=Ut.right,wt=ge.lut&&ge.lut.wavelength>0?Math.max(0,(ge.lut.periodArc/ge.lut.wavelength-1)*qe):0;for(const{item:jt,glyphs:At}of ge.itemsCache){const vt=jt.getBoundingClientRect();if(!(vt.right<Zt||vt.left>xt+wt))for(const Ft of At){const _t=Ft.layoutLocalX+Tt,Kt=ge.lut?wg(ge.lut,_t):_t,Jt=tt*Kt,Ct=_e*Math.sin(Jt),Ht=_e*tt*Math.cos(Jt),on=Math.atan(Ht)*(180/Math.PI);hg(Ft.inner,Kt-_t,Ct,on)}}},Ve=()=>{ge.cancelled||(ge.raf=0,Ze(),he.current&&!document.hidden&&(ge.raf=requestAnimationFrame(Ve)))},at=()=>{ge.cancelled||ge.raf||(ge.raf=requestAnimationFrame(Ve))};ce.current=at,at();const Je=()=>{if(document.hidden){cancelAnimationFrame(ge.raf),ge.raf=0;return}at()};return document.addEventListener("visibilitychange",Je),()=>{ge.cancelled=!0,ce.current=null,cancelAnimationFrame(ge.raf),document.removeEventListener("visibilitychange",Je),Ie()}},[x,W,E,B,s,se,pe,U]),a.useLayoutEffect(()=>{var ne;(ne=ce.current)==null||ne.call(ce)},[$]);const H=()=>{M&&le(!0)},ye=()=>{M&&le(!1)},re=x?W*100:0,_=K(O),ee={minHeight:_,...x?{paddingTop:`${re}%`,paddingBottom:`${re}%`}:{}},Ae={height:_,...x?{visibility:"hidden"}:{backgroundColor:A}},ue={gap:K(v),minHeight:_},N=de*W,Ue=we>0?we:$e,Oe=Math.max($e,Ue),dt=x&&de>0&&Oe>0?Sg(de,N,E,N+Oe/2):"",nt=N*2+Oe,ht=dt?r.jsx("svg",{className:`${o}-curve-bg`,viewBox:`0 0 ${de} ${nt}`,preserveAspectRatio:"none","aria-hidden":!0,children:r.jsx("path",{d:dt,fill:"none",stroke:A,strokeWidth:Ue,strokeLinecap:"round",strokeLinejoin:"round"})}):null,st=r.jsx("div",{ref:ve,className:`${o}-ribbon`,style:Ae,"aria-hidden":!0}),Be=(ne,ge,Ie)=>r.jsx($g,{item:ne,prefix:o,textCss:P,capHeightPx:U,opticalOffsetY:Z,imageGapPx:K(v),isCurve:x},`${ge}-${Ie}`),xe=r.jsx("span",{ref:Pe,"aria-hidden":!0,className:`${o}-cap-ref`,style:P,children:"H"}),Fe=d>0&&S>0?d/S*1e3:0,je=`${Math.max(0,Fe)/1e3}s`,Ke=ie?r.jsx("div",{ref:te,className:`${o}-marquee-track`,"data-direction":u,onMouseEnter:H,onMouseLeave:ye,style:{WebkitAnimationDuration:je,animationDuration:je,WebkitAnimationPlayState:oe,animationPlayState:oe},children:Array.from({length:Le},(ne,ge)=>r.jsx("div",{ref:ge===0?X:void 0,className:`${o}-marquee-set`,style:{...ue,paddingRight:K(v)},"aria-hidden":ge>0,children:Me.map((Ie,Ge)=>Be(Ie,ge,Ge))},`set-${ge}`))}):r.jsx("div",{ref:X,className:ut(`${o}-marquee-set`,`${o}-marquee-static`),style:ue,children:t==null?void 0:t.map((ne,ge)=>Be(ne,0,ge))});return r.jsxs("div",{ref:ae,className:`${o}-wrapper`,"aria-label":"Marquee text",children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:J}}),xe,r.jsxs("div",{ref:k,className:`${o}-marquee-wrapper`,style:ee,children:[st,ht,Ke]})]})},Tg=`import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
2605
2605
  import cn from 'classnames';
2606
2606
  import { CommonComponentProps } from '../props';
2607
2607
  import { scalingValue } from '../utils/scalingValue';
@@ -3069,8 +3069,8 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
3069
3069
  if (!wrapper || !set) return;
3070
3070
  const raf = { id: 0 };
3071
3071
  const measure = () => {
3072
- const containerWidth = wrapper.getBoundingClientRect().width || wrapper.offsetWidth;
3073
- const rawSetWidth = set.getBoundingClientRect().width || set.offsetWidth;
3072
+ const containerWidth = wrapper.offsetWidth || wrapper.getBoundingClientRect().width;
3073
+ const rawSetWidth = set.offsetWidth || set.getBoundingClientRect().width;
3074
3074
  if (hasContent && containerWidth > 0 && rawSetWidth > 0) {
3075
3075
  const singleCycleWidth = rawSetWidth / contentSequenceRepeat;
3076
3076
  if (singleCycleWidth > 0) {
@@ -3442,7 +3442,7 @@ type MarqueeTextProps = {
3442
3442
  isPreviewMode?: boolean;
3443
3443
  isEditMode?: boolean;
3444
3444
  } & CommonComponentProps;
3445
- `,Lg={fontSettings:{type:"object",scope:"common",display:{type:"font-settings-weight"},properties:{fontWeight:{type:"number",scope:"common"},fontStyle:{type:"string",scope:"common"}}}},Rg={type:"object",version:1,settings:{sizing:"auto manual",properties:{speed:{type:"number",scope:"layout",title:"Speed",display:{type:"speed-control"},min:0,max:7},direction:{type:"string",scope:"common",title:"Direction",display:{type:"direction-control"},enum:["left","right"]},pauseOnHover:{title:"Pause on hover",type:"string",scope:"common",display:{type:"toggle-cycle",enum:["on","off"]}},gap:{type:"number",scope:"layout",title:"Gap",min:0,display:{type:"numeric-input"}},ribbonWidth:{type:"number",scope:"layout",title:"Ribbon Width",min:0,display:{type:"numeric-input"}},layoutType:{type:"string",scope:"common",title:"Path Type",display:{type:"toggle-cycle",enum:["straight","curve"]}},curveAmplitude:{type:"number",scope:"layout",title:"Amplitude",min:0,max:30,step:1,display:{type:"common-numeric-input",visible:!1}},curveFrequency:{type:"number",scope:"layout",title:"Frequency",min:0,max:100,step:1,display:{type:"common-numeric-input",visible:!1}},textFontFamily:{type:"string",scope:"common",title:"Font Family",display:{type:"font-family-select"}},textFontSettings:{...Lg.fontSettings,scope:"common",title:"",display:{type:"font-settings-weight"}},textFontSize:{type:"number",scope:"layout",title:"Font Size",display:{type:"font-size"}},textLineHeight:{type:"number",scope:"layout",title:"Line Height",display:{type:"line-height-input"}},textLetterSpacing:{type:"number",scope:"layout",title:"Letter Spacing",display:{type:"letter-spacing-input"}},textWordSpacing:{type:"number",scope:"layout",title:"Word Spacing",display:{type:"word-spacing-input"}},textTextAppearance:{type:"object",scope:"layout",title:"Text Appearance",display:{type:"text-appearance"}},textColor:{display:{type:"style-panel-color-picker"},type:"string",scope:"common",title:"Text Color"},backgroundColor:{display:{type:"style-panel-color-picker"},type:"string",scope:"common",title:"Ribbon Color"}},defaults:{direction:"left",pauseOnHover:"off",layoutType:"curve",textFontFamily:"Antique Série",textFontSettings:{fontWeight:400,fontStyle:"normal"},textLetterSpacing:0,textWordSpacing:0,textTextAppearance:{textTransform:"none",textDecoration:"none",fontVariant:"normal"},textColor:"#FFFFFF",backgroundColor:"#2E12F0"},layoutDefaults:{m:{speed:.55,gap:.04,ribbonWidth:.08,curveAmplitude:6,curveFrequency:15,textFontSize:.08,textLineHeight:.08},t:{speed:1.3,gap:.02,ribbonWidth:.11,curveAmplitude:5,curveFrequency:15,textFontSize:.07,textLineHeight:.05},d:{speed:2.5,gap:.02,ribbonWidth:.11,curveAmplitude:5,curveFrequency:18,textFontSize:.071,textLineHeight:.035}},displayRules:[{if:{name:"layoutType",value:"curve"},then:{name:"properties.curveAmplitude.display.visible",value:!0}},{if:{name:"layoutType",value:"curve"},then:{name:"properties.curveFrequency.display.visible",value:!0}}],layout:["__componentName__","speed","direction","pauseOnHover","gap","ribbonWidth","layoutType","curveAmplitude","curveFrequency"]},panels:[{id:"general",icon:"settings",title:"General",tooltip:"General Settings",layout:[{type:"row",items:["__componentName__"]},{type:"row",items:["direction","speed"]},{type:"row",items:["ribbonWidth","gap"]},{type:"row",items:["pauseOnHover","layoutType"]},{type:"row",items:["curveAmplitude","curveFrequency"]}]},{id:"typeStyle",icon:"text-icon",title:"Type Style",tooltip:"Typography",layout:["__componentName__","textFontFamily","textFontSettings",{type:"row",items:["textFontSize","textLineHeight","textLetterSpacing","textWordSpacing"]},"textTextAppearance"]}],paletteBookmark:{items:["textColor","backgroundColor"],panelIds:["general","typeStyle"]},content:{type:"array",settings:{addItemFromFileExplorer:!1},items:{type:"object",properties:{text:{placeholder:"Add text...",label:"Text",display:{type:"text-input"}},image:{type:"object",label:"Image",display:{type:"media-input"}},link:{type:"string",label:"Link",placeholder:"Add link...",display:{type:"text-input"}}}},default:[{text:"NEW WORK",image:{url:"https://cdn.cntrl.site/component-assets/marquee_text_icon.svg",name:""},link:""}]}},Ig={element:Cg,id:"marquee-text",name:"Marquee Text",category:"galleries",version:1,defaultSize:{d:{width:"100%"},t:{width:"100%"},m:{width:"100%"}},preview:{type:"image",url:"https://cdn.cntrl.site/component-assets/Text_Marquee.mp4"},schema:Rg,sourceCode:Tg,assetsPaths:{content:[{path:"image.url",placeholderEnabled:!0}],parameters:[]},fontSettingsPaths:{content:[],parameters:[{path:"textFontFamily"}]},fontRelations:{textFontSettings:"textFontFamily"}};function Eg(e,t){const n=t>0?`${t}px`:"0px";return`
3445
+ `,Lg={fontSettings:{type:"object",scope:"common",display:{type:"font-settings-weight"},properties:{fontWeight:{type:"number",scope:"common"},fontStyle:{type:"string",scope:"common"}}}},Rg={type:"object",version:1,settings:{sizing:"auto manual",properties:{speed:{type:"number",scope:"layout",title:"Speed",display:{type:"speed-control"},min:0,max:7},direction:{type:"string",scope:"common",title:"Direction",display:{type:"direction-control"},enum:["left","right"]},pauseOnHover:{title:"Pause on hover",type:"string",scope:"common",display:{type:"toggle-cycle",enum:["on","off"]}},gap:{type:"number",scope:"layout",title:"Gap",min:0,display:{type:"numeric-input"}},ribbonWidth:{type:"number",scope:"layout",title:"Ribbon Width",min:0,display:{type:"numeric-input"}},layoutType:{type:"string",scope:"common",title:"Path Type",display:{type:"toggle-cycle",enum:["straight","curve"]}},curveAmplitude:{type:"number",scope:"layout",title:"Amplitude",min:0,max:30,step:1,display:{type:"common-numeric-input",visible:!1}},curveFrequency:{type:"number",scope:"layout",title:"Frequency",min:0,max:100,step:1,display:{type:"common-numeric-input",visible:!1}},textFontFamily:{type:"string",scope:"common",title:"Font Family",display:{type:"font-family-select"}},textFontSettings:{...Lg.fontSettings,scope:"common",title:"",display:{type:"font-settings-weight"}},textFontSize:{type:"number",scope:"layout",title:"Font Size",display:{type:"font-size"}},textLineHeight:{type:"number",scope:"layout",title:"Line Height",display:{type:"line-height-input"}},textLetterSpacing:{type:"number",scope:"layout",title:"Letter Spacing",display:{type:"letter-spacing-input"}},textWordSpacing:{type:"number",scope:"layout",title:"Word Spacing",display:{type:"word-spacing-input"}},textTextAppearance:{type:"object",scope:"layout",title:"Text Appearance",display:{type:"text-appearance"}},textColor:{display:{type:"style-panel-color-picker"},type:"string",scope:"common",title:"Text Color"},backgroundColor:{display:{type:"style-panel-color-picker"},type:"string",scope:"common",title:"Ribbon Color"}},defaults:{direction:"left",pauseOnHover:"off",layoutType:"curve",textFontFamily:"Antique Série",textFontSettings:{fontWeight:400,fontStyle:"normal"},textLetterSpacing:0,textWordSpacing:0,textTextAppearance:{textTransform:"none",textDecoration:"none",fontVariant:"normal"},textColor:"#FFFFFF",backgroundColor:"#2E12F0"},layoutDefaults:{m:{speed:.55,gap:.04,ribbonWidth:.08,curveAmplitude:6,curveFrequency:15,textFontSize:.08,textLineHeight:.08},t:{speed:1.3,gap:.02,ribbonWidth:.11,curveAmplitude:5,curveFrequency:15,textFontSize:.07,textLineHeight:.05},d:{speed:2.5,gap:.02,ribbonWidth:.11,curveAmplitude:5,curveFrequency:18,textFontSize:.071,textLineHeight:.035}},displayRules:[{if:{name:"layoutType",value:"curve"},then:{name:"properties.curveAmplitude.display.visible",value:!0}},{if:{name:"layoutType",value:"curve"},then:{name:"properties.curveFrequency.display.visible",value:!0}}],layout:["__componentName__","speed","direction","pauseOnHover","gap","ribbonWidth","layoutType","curveAmplitude","curveFrequency"]},panels:[{id:"general",icon:"settings",title:"General",tooltip:"General Settings",layout:[{type:"row",items:["__componentName__"]},{type:"row",items:["direction","speed"]},{type:"row",items:["ribbonWidth","gap"]},{type:"row",items:["pauseOnHover","layoutType"]},{type:"row",items:["curveAmplitude","curveFrequency"]}]},{id:"typeStyle",icon:"text-icon",title:"Type Style",tooltip:"Typography",layout:["__componentName__","textFontFamily","textFontSettings",{type:"row",items:["textFontSize","textLineHeight","textLetterSpacing","textWordSpacing"]},"textTextAppearance"]}],paletteBookmark:{items:["textColor","backgroundColor"],panelIds:["general","typeStyle"]},content:{type:"array",settings:{addItemFromFileExplorer:!1},items:{type:"object",properties:{text:{placeholder:"Add text...",label:"Text",display:{type:"text-input"}},image:{type:"object",label:"Image",display:{type:"media-input"}},link:{type:"string",label:"Link",placeholder:"Add link...",display:{type:"text-input"}}}},default:[{text:"NEW WORK",image:{url:"https://cdn.cntrl.site/component-assets/marquee_text_icon.svg",name:""},link:""}]}},Ig={element:Cg,id:"marquee-text",name:"Marquee Text",category:"typography",version:1,defaultSize:{d:{width:"100%"},t:{width:"100%"},m:{width:"100%"}},preview:{type:"image",url:"https://cdn.cntrl.site/component-assets/Text_Marquee.mp4"},schema:Rg,sourceCode:Tg,assetsPaths:{content:[{path:"image.url",placeholderEnabled:!0}],parameters:[]},fontSettingsPaths:{content:[],parameters:[{path:"textFontFamily"}]},fontRelations:{textFontSettings:"textFontFamily"}};function Eg(e,t){const n=t>0?`${t}px`:"0px";return`
3446
3446
  .${e}-marquee-wrapper {
3447
3447
  overflow: hidden;
3448
3448
  width: 100%;
package/dist/index.mjs CHANGED
@@ -10257,7 +10257,7 @@ const yg = 30, oa = 3, vg = 12, bg = 3, Ha = 0.72, xg = 100, wg = 10, Sg = (e) =
10257
10257
  const oe = se.current, fe = K.current;
10258
10258
  if (!oe || !fe) return;
10259
10259
  const Ee = { id: 0 }, Ye = () => {
10260
- const Ke = oe.getBoundingClientRect().width || oe.offsetWidth, pt = fe.getBoundingClientRect().width || fe.offsetWidth;
10260
+ const Ke = oe.offsetWidth || oe.getBoundingClientRect().width, pt = fe.offsetWidth || fe.getBoundingClientRect().width;
10261
10261
  if (V && Ke > 0 && pt > 0) {
10262
10262
  const it = pt / ge;
10263
10263
  if (it > 0) {
@@ -10939,8 +10939,8 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
10939
10939
  if (!wrapper || !set) return;
10940
10940
  const raf = { id: 0 };
10941
10941
  const measure = () => {
10942
- const containerWidth = wrapper.getBoundingClientRect().width || wrapper.offsetWidth;
10943
- const rawSetWidth = set.getBoundingClientRect().width || set.offsetWidth;
10942
+ const containerWidth = wrapper.offsetWidth || wrapper.getBoundingClientRect().width;
10943
+ const rawSetWidth = set.offsetWidth || set.getBoundingClientRect().width;
10944
10944
  if (hasContent && containerWidth > 0 && rawSetWidth > 0) {
10945
10945
  const singleCycleWidth = rawSetWidth / contentSequenceRepeat;
10946
10946
  if (singleCycleWidth > 0) {
@@ -11585,7 +11585,7 @@ type MarqueeTextProps = {
11585
11585
  element: _g,
11586
11586
  id: "marquee-text",
11587
11587
  name: "Marquee Text",
11588
- category: "galleries",
11588
+ category: "typography",
11589
11589
  version: 1,
11590
11590
  defaultSize: {
11591
11591
  d: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",