motion-plus-vue 1.2.0 → 1.2.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/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("motion-v");function ke(o,{locales:t,format:n},r,i){const l=new Intl.NumberFormat(t,n).formatToParts(Number(o));r&&l.unshift({type:"prefix",value:r}),i&&l.push({type:"suffix",value:i});const d=[],g=[],w=[],h=[],u={},m=c=>`${c}:${u[c]=(u[c]??-1)+1}`;let y="",k=!1,x=!1,f=0;for(const c of l){y+=c.value;const p=c.type==="minusSign"||c.type==="plusSign"?"sign":c.type;switch(p){case"integer":k=!0,g.push(...c.value.split("").map(C=>({type:p,value:parseInt(C)})));break;case"group":g.push({type:p,value:c.value});break;case"decimal":x=!0,w.push({type:p,value:c.value,key:m(p),originalIndex:f++});break;case"fraction":w.push(...c.value.split("").map(C=>({type:p,value:parseInt(C),key:m(p),originalIndex:f++})));break;default:(k||x?h:d).push({type:p,value:c.value,key:m(p),originalIndex:f++})}}const v=[];for(let c=g.length-1;c>=0;c--){const p=m(g[c].type);v.unshift({...g[c],key:p,originalIndex:c})}return{pre:d,integer:v,fraction:w,post:h,formatted:y}}const[Se,Be]=a.createContext("SectionContext");function me(){const o={current:!0};return e.onMounted(()=>{o.current=!1}),o}function X(o){const{width:t,fontSize:n}=getComputedStyle(o);return`${parseFloat(t)/parseFloat(n)}em`}const E="var(--mask-height, 0.15em)",U="var(--mask-width, 0.5em)",V=`calc(${U} / var(--invert-x, 1))`,F="#000 0, transparent 71%",Ce=`linear-gradient(to right, transparent 0, #000 ${V}, #000 calc(100% - ${V}), transparent),linear-gradient(to bottom, transparent 0, #000 ${E}, #000 calc(100% - ${E}), transparent 100%),radial-gradient(at bottom right, ${F}),radial-gradient(at bottom left, ${F}), radial-gradient(at top left, ${F}), radial-gradient(at top right, ${F})`,ze=`100% calc(100% - ${E} * 2),calc(100% - ${V} * 2) 100%,${V} ${E},${V} ${E},${V} ${E},${V} ${E}`;a.addScaleCorrector({"--invert-x":{correct:(o,{treeScale:t,projectionDelta:n})=>n.x.scale*t.x}});const oe={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function ye(o){const t=e.ref();function n(i){t.value=i==null?void 0:i.$el}e.watch(()=>o.isPresent,i=>{var s;t.value&&((s=a.mountedStates.get(t.value))==null||s.setActive("exit",!i))});function r(i){var s;i.detail.isExit&&!o.isPresent&&((s=o.onRemove)==null||s.call(o,o.partKey,i.target))}return{root:t,getRoot:n,handleComplete:r}}const be=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{},layoutDependency:{},preInitial:{type:Boolean}},setup(o){const t=o,{justify:n}=Se(),{getRoot:r,handleComplete:i}=ye(t);return(s,l)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(r),layout:"position","layout-dependency":s.layoutDependency,"data-state":s.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(n),padding:`calc(${e.unref(E)}/2) 0`,position:"relative",pointerEvents:s.isPresent?void 0:"none"}),"aria-hidden":!s.isPresent,onMotioncomplete:e.unref(i)},{default:e.withCtx(()=>[e.createVNode(e.unref(a.AnimatePresence),{mode:"popLayout","anchor-x":e.unref(n),initial:s.preInitial},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(a.motion).span,{key:s.value,layout:e.unref(n)==="right"?"position":!1,"layout-dependency":s.layoutDependency,initial:{opacity:0,left:e.unref(n)==="right"&&s.preInitial===void 0?"-100%":void 0},animate:{opacity:[null,1],left:0},exit:{opacity:[null,0],transition:{opacity:{duration:.4}}},style:{display:"inline-block",whiteSpace:"pre",position:"relative"}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1},8,["layout","layout-dependency","initial"]))]),_:1},8,["anchor-x","initial"])]),_:1},8,["layout-dependency","data-state","style","aria-hidden","onMotioncomplete"]))}}),Pe=new WeakMap,Ie=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{},layoutDependency:{}},setup(o){const t=o,n=t.initialValue??t.value,r=me(),i=a.useMotionConfig(),s=e.ref(),l=e.ref(Array(10).fill(null)),d=e.ref(),{getRoot:g,handleComplete:w,root:h}=ye(t);let u=n;const m=e.ref(n);e.watch([()=>t.value,()=>t.isPresent],([f,v])=>{if(!v)return m.value=0;if(r.current)return e.nextTick(()=>{m.value=f});m.value=f},{immediate:!0});function y(f){var C;if(!s.value||f===u)return;const v=s.value.getBoundingClientRect(),c=(C=h.value)==null?void 0:C.getBoundingClientRect(),p=v.height*(f-u)+(v.top-(c?c.top||0:v.top));a.animate(s.value,{y:[p,0]},i.value.transition)}function k(f){if(r.current&&n===f||!l.value[f])return;const v=X(l.value[f]);h.value&&(Pe.set(h.value,v),h.value.style.width=v),d.value=v}e.watch(m,f=>{k(f)},{immediate:!0,flush:"sync"}),e.watch(m,async(f,v,c)=>{await e.nextTick(),y(f),c(()=>{u=f})},{immediate:!0,flush:"sync"});function x(f){return()=>e.createVNode("span",{key:f,style:{display:"inline-block",padding:`calc(${E}/2) 0`},ref:v=>{l.value[f]=v}},[f])}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(g),layout:"position","layout-dependency":f.layoutDependency,"data-state":f.isPresent?void 0:"exiting","data-key":f.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:d.value,pointerEvents:f.isPresent?void 0:"none"}),"aria-hidden":!f.isPresent,onMotioncomplete:e.unref(w)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:s,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[m.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(oe),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,c=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(c-1)),{key:c-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(m.value)))),m.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(oe),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-m.value,c=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(m.value+c)),{key:m.value+c}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["layout-dependency","data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),O=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{},layoutDependency:{}},setup(o){var h;const t=o,n=e.ref(),r=a.useDomRef(),i=e.ref(),s=me(),l=e.ref(t.parts);let d=t.name==="pre"&&!((h=t.parts)!=null&&h.length)?void 0:!1;e.watch(()=>t.parts,u=>{const m=new Map(u.map(x=>[x.key,{...x,isPresent:!0}])),y=l.value.filter(x=>!m.get(x.key)).map(x=>({...x,isPresent:!1})),k=u.sort((x,f)=>x.originalIndex-f.originalIndex);l.value=y.concat(k)},{flush:"pre"}),e.watch(()=>{var u;return(u=t.parts)==null?void 0:u.map(m=>m.value).join("")},async(u,m)=>{if(await e.nextTick(),d=!1,!i.value)return;if(s.current){r.value&&(r.value.style.width=X(i.value));return}const y=Array.from(i.value.children).map(x=>{if(x instanceof HTMLElement&&x.dataset.state==="exiting"){const f=x.nextSibling;return x.remove(),()=>{i.value&&i.value.insertBefore(x,f)}}}),k=X(i.value);n.value=k;for(let x=y.length-1;x>=0;x--){const f=y[x];f&&f()}},{flush:"post"});const g=e.toRef(t,"justify");Be({justify:g});function w(u,m){var y;l.value=l.value.filter(k=>k.key!==u),(y=m==null?void 0:m.parentElement)==null||y.removeChild(m)}return(u,m)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(r),class:e.normalizeClass(`number-section-${u.name}`),style:e.normalizeStyle({...u.style,display:"inline-flex",justifyContent:g.value,width:n.value}),layout:"position","layout-dependency":u.layoutDependency},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:i,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[m[0]||(m[0]=e.createTextVNode(" ​ ")),e.createVNode(e.unref(a.AnimatePresence),{mode:u.mode,"anchor-x":g.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,y=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:y.key},[y.type==="integer"||y.type==="fraction"?(e.openBlock(),e.createBlock(Ie,{key:y.key,"part-key":y.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:y.value,"is-present":y.isPresent??!0,"initial-value":e.unref(s).current?void 0:0,"layout-dependency":u.layoutDependency,onRemove:w},null,8,["part-key","value","is-present","initial-value","layout-dependency"])):(e.openBlock(),e.createBlock(be,{key:y.type==="literal"?`${y.key}:${y.value}`:y.key,type:y.type,"part-key":y.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:y.value,"is-present":y.isPresent??!0,"pre-initial":e.unref(d),"layout-dependency":u.layoutDependency,onRemove:w},null,8,["type","part-key","value","is-present","pre-initial","layout-dependency"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style","layout-dependency"]))}}),Ee=e.defineComponent({__name:"Mask",props:{layoutDependency:{}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{layout:"","layout-dependency":t.layoutDependency,"aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(U)})`,padding:`calc(${e.unref(E)}/2) ${e.unref(U)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(Ce),webkitMaskSize:e.unref(ze),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["layout-dependency","style"]))}}),Te=e.defineComponent({name:"AnimateNumber",inheritAttrs:!1,__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{},layoutDependency:{}},setup(o){const t={opacity:{duration:1,ease:a.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},n=o,r=e.computed(()=>{const g=n.value;return ke(g,{locales:n.locales,format:n.format},n.prefix,n.suffix)}),i=a.useMotionConfig(),s=e.computed(()=>n.transition??i.value.transition??t);function l(){const{format:g,prefix:w,suffix:h,locales:u,value:m,layoutDependency:y,...k}=n;return k}const d=e.computed(()=>{if(n.layoutDependency!==void 0)return{layoutDependency:n.layoutDependency,value:n.value}});return(g,w)=>(e.openBlock(),e.createBlock(e.unref(a.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(a.MotionConfig),{transition:s.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).div,e.mergeProps({...g.$attrs,...l()},{layout:"","layout-dependency":d.value,style:{lineHeight:"1",...g.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).div,{layout:"","layout-dependency":d.value,"aria-label":r.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode(O,{"layout-dependency":d.value,style:e.normalizeStyle({padding:`calc(${e.unref(E)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:r.value.pre,name:"pre"},null,8,["layout-dependency","style","parts"]),e.createVNode(Ee,{"layout-dependency":d.value},{default:e.withCtx(()=>[e.createVNode(O,{"layout-dependency":d.value,justify:"right",parts:r.value.integer,name:"integer",mode:"popLayout"},null,8,["layout-dependency","parts"]),e.createVNode(O,{"layout-dependency":d.value,layout:"position",parts:r.value.fraction,name:"fraction",mode:"popLayout"},null,8,["layout-dependency","parts"])]),_:1},8,["layout-dependency"]),e.createVNode(O,{"layout-dependency":d.value,style:e.normalizeStyle({padding:`calc(${e.unref(E)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:r.value.post,name:"post"},null,8,["layout-dependency","style","parts"])]),_:1},8,["layout-dependency","aria-label"])]),_:1},16,["layout-dependency","style"])]),_:1},8,["transition"])]),_:1}))}}),$e=Te;function Le(){const o=document.createElement("style");return o.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("motion-v");function ke(o,{locales:t,format:n},r,i){const l=new Intl.NumberFormat(t,n).formatToParts(Number(o));r&&l.unshift({type:"prefix",value:r}),i&&l.push({type:"suffix",value:i});const d=[],g=[],w=[],h=[],u={},m=c=>`${c}:${u[c]=(u[c]??-1)+1}`;let y="",k=!1,x=!1,f=0;for(const c of l){y+=c.value;const p=c.type==="minusSign"||c.type==="plusSign"?"sign":c.type;switch(p){case"integer":k=!0,g.push(...c.value.split("").map(C=>({type:p,value:parseInt(C)})));break;case"group":g.push({type:p,value:c.value});break;case"decimal":x=!0,w.push({type:p,value:c.value,key:m(p),originalIndex:f++});break;case"fraction":w.push(...c.value.split("").map(C=>({type:p,value:parseInt(C),key:m(p),originalIndex:f++})));break;default:(k||x?h:d).push({type:p,value:c.value,key:m(p),originalIndex:f++})}}const v=[];for(let c=g.length-1;c>=0;c--){const p=m(g[c].type);v.unshift({...g[c],key:p,originalIndex:c})}return{pre:d,integer:v,fraction:w,post:h,formatted:y}}const[Se,Be]=a.createContext("SectionContext");function ye(){const o={current:!0};return e.onMounted(()=>{o.current=!1}),o}function U(o){const{width:t,fontSize:n}=getComputedStyle(o);return`${parseFloat(t)/parseFloat(n)}em`}const E="var(--mask-height, 0.15em)",Y="var(--mask-width, 0.5em)",N=`calc(${Y} / var(--invert-x, 1))`,O="#000 0, transparent 71%",Ce=`linear-gradient(to right, transparent 0, #000 ${N}, #000 calc(100% - ${N}), transparent),linear-gradient(to bottom, transparent 0, #000 ${E}, #000 calc(100% - ${E}), transparent 100%),radial-gradient(at bottom right, ${O}),radial-gradient(at bottom left, ${O}), radial-gradient(at top left, ${O}), radial-gradient(at top right, ${O})`,ze=`100% calc(100% - ${E} * 2),calc(100% - ${N} * 2) 100%,${N} ${E},${N} ${E},${N} ${E},${N} ${E}`;a.addScaleCorrector({"--invert-x":{correct:(o,{treeScale:t,projectionDelta:n})=>n.x.scale*t.x}});const ie={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function ve(o){const t=e.ref();function n(i){t.value=i==null?void 0:i.$el}e.watch(()=>o.isPresent,i=>{var s;t.value&&((s=a.mountedStates.get(t.value))==null||s.setActive("exit",!i))});function r(i){var s;i.detail.isExit&&!o.isPresent&&((s=o.onRemove)==null||s.call(o,o.partKey,i.target))}return{root:t,getRoot:n,handleComplete:r}}const be=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{},layoutDependency:{},preInitial:{type:Boolean}},setup(o){const t=o,{justify:n}=Se(),{getRoot:r,handleComplete:i}=ve(t);return(s,l)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(r),layout:"position","layout-dependency":s.layoutDependency,"data-state":s.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(n),padding:`calc(${e.unref(E)}/2) 0`,position:"relative",pointerEvents:s.isPresent?void 0:"none"}),"aria-hidden":!s.isPresent,onMotioncomplete:e.unref(i)},{default:e.withCtx(()=>[e.createVNode(e.unref(a.AnimatePresence),{mode:"popLayout","anchor-x":e.unref(n),initial:s.preInitial},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(a.motion).span,{key:s.value,layout:e.unref(n)==="right"?"position":!1,"layout-dependency":s.layoutDependency,initial:{opacity:0,left:e.unref(n)==="right"&&s.preInitial===void 0?"-100%":void 0},animate:{opacity:[null,1],left:0},exit:{opacity:[null,0],transition:{opacity:{duration:.4}}},style:{display:"inline-block",whiteSpace:"pre",position:"relative"}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1},8,["layout","layout-dependency","initial"]))]),_:1},8,["anchor-x","initial"])]),_:1},8,["layout-dependency","data-state","style","aria-hidden","onMotioncomplete"]))}}),Pe=new WeakMap,Ie=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{},layoutDependency:{}},setup(o){const t=o,n=t.initialValue??t.value,r=ye(),i=a.useMotionConfig(),s=e.ref(),l=e.ref(Array(10).fill(null)),d=e.ref(),{getRoot:g,handleComplete:w,root:h}=ve(t);let u=n;const m=e.ref(n);e.watch([()=>t.value,()=>t.isPresent],([f,v])=>{if(!v)return m.value=0;if(r.current)return e.nextTick(()=>{m.value=f});m.value=f},{immediate:!0});function y(f){var C;if(!s.value||f===u)return;const v=s.value.getBoundingClientRect(),c=(C=h.value)==null?void 0:C.getBoundingClientRect(),p=v.height*(f-u)+(v.top-(c?c.top||0:v.top));a.animate(s.value,{y:[p,0]},i.value.transition)}function k(f){if(r.current&&n===f||!l.value[f])return;const v=U(l.value[f]);h.value&&(Pe.set(h.value,v),h.value.style.width=v),d.value=v}e.watch(m,f=>{k(f)},{immediate:!0,flush:"sync"}),e.watch(m,async(f,v,c)=>{await e.nextTick(),y(f),c(()=>{u=f})},{immediate:!0,flush:"sync"});function x(f){return()=>e.createVNode("span",{key:f,style:{display:"inline-block",padding:`calc(${E}/2) 0`},ref:v=>{l.value[f]=v}},[f])}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(g),layout:"position","layout-dependency":f.layoutDependency,"data-state":f.isPresent?void 0:"exiting","data-key":f.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:d.value,pointerEvents:f.isPresent?void 0:"none"}),"aria-hidden":!f.isPresent,onMotioncomplete:e.unref(w)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:s,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[m.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(ie),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,c=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(c-1)),{key:c-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(m.value)))),m.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(ie),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-m.value,c=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x(m.value+c)),{key:m.value+c}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["layout-dependency","data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),_=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{},layoutDependency:{}},setup(o){var h;const t=o,n=e.ref(),r=a.useDomRef(),i=e.ref(),s=ye(),l=e.ref(t.parts);let d=t.name==="pre"&&!((h=t.parts)!=null&&h.length)?void 0:!1;e.watch(()=>t.parts,u=>{const m=new Map(u.map(x=>[x.key,{...x,isPresent:!0}])),y=l.value.filter(x=>!m.get(x.key)).map(x=>({...x,isPresent:!1})),k=u.sort((x,f)=>x.originalIndex-f.originalIndex);l.value=y.concat(k)},{flush:"pre"}),e.watch(()=>{var u;return(u=t.parts)==null?void 0:u.map(m=>m.value).join("")},async(u,m)=>{if(await e.nextTick(),d=!1,!i.value)return;if(s.current){r.value&&(r.value.style.width=U(i.value));return}const y=Array.from(i.value.children).map(x=>{if(x instanceof HTMLElement&&x.dataset.state==="exiting"){const f=x.nextSibling;return x.remove(),()=>{i.value&&i.value.insertBefore(x,f)}}}),k=U(i.value);n.value=k;for(let x=y.length-1;x>=0;x--){const f=y[x];f&&f()}},{flush:"post"});const g=e.toRef(t,"justify");Be({justify:g});function w(u,m){var y;l.value=l.value.filter(k=>k.key!==u),(y=m==null?void 0:m.parentElement)==null||y.removeChild(m)}return(u,m)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{ref:e.unref(r),class:e.normalizeClass(`number-section-${u.name}`),style:e.normalizeStyle({...u.style,display:"inline-flex",justifyContent:g.value,width:n.value}),layout:"position","layout-dependency":u.layoutDependency},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:i,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[m[0]||(m[0]=e.createTextVNode(" ​ ")),e.createVNode(e.unref(a.AnimatePresence),{mode:u.mode,"anchor-x":g.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,y=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:y.key},[y.type==="integer"||y.type==="fraction"?(e.openBlock(),e.createBlock(Ie,{key:y.key,"part-key":y.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:y.value,"is-present":y.isPresent??!0,"initial-value":e.unref(s).current?void 0:0,"layout-dependency":u.layoutDependency,onRemove:w},null,8,["part-key","value","is-present","initial-value","layout-dependency"])):(e.openBlock(),e.createBlock(be,{key:y.type==="literal"?`${y.key}:${y.value}`:y.key,type:y.type,"part-key":y.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:y.value,"is-present":y.isPresent??!0,"pre-initial":e.unref(d),"layout-dependency":u.layoutDependency,onRemove:w},null,8,["type","part-key","value","is-present","pre-initial","layout-dependency"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style","layout-dependency"]))}}),Ee=e.defineComponent({__name:"Mask",props:{layoutDependency:{}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(a.motion).span,{layout:"","layout-dependency":t.layoutDependency,"aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(Y)})`,padding:`calc(${e.unref(E)}/2) ${e.unref(Y)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(Ce),webkitMaskSize:e.unref(ze),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["layout-dependency","style"]))}}),Te=e.defineComponent({name:"AnimateNumber",inheritAttrs:!1,__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{},layoutDependency:{}},setup(o){const t={opacity:{duration:1,ease:a.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},n=o,r=e.computed(()=>{const g=n.value;return ke(g,{locales:n.locales,format:n.format},n.prefix,n.suffix)}),i=a.useMotionConfig(),s=e.computed(()=>n.transition??i.value.transition??t);function l(){const{format:g,prefix:w,suffix:h,locales:u,value:m,layoutDependency:y,...k}=n;return k}const d=e.computed(()=>{if(n.layoutDependency!==void 0)return{layoutDependency:n.layoutDependency,value:n.value}});return(g,w)=>(e.openBlock(),e.createBlock(e.unref(a.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(a.MotionConfig),{transition:s.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).div,e.mergeProps({...g.$attrs,...l()},{layout:"","layout-dependency":d.value,style:{lineHeight:"1",...g.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).div,{layout:"","layout-dependency":d.value,"aria-label":r.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode(_,{"layout-dependency":d.value,style:e.normalizeStyle({padding:`calc(${e.unref(E)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:r.value.pre,name:"pre"},null,8,["layout-dependency","style","parts"]),e.createVNode(Ee,{"layout-dependency":d.value},{default:e.withCtx(()=>[e.createVNode(_,{"layout-dependency":d.value,justify:"right",parts:r.value.integer,name:"integer",mode:"popLayout"},null,8,["layout-dependency","parts"]),e.createVNode(_,{"layout-dependency":d.value,layout:"position",parts:r.value.fraction,name:"fraction",mode:"popLayout"},null,8,["layout-dependency","parts"])]),_:1},8,["layout-dependency"]),e.createVNode(_,{"layout-dependency":d.value,style:e.normalizeStyle({padding:`calc(${e.unref(E)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:r.value.post,name:"post"},null,8,["layout-dependency","style","parts"])]),_:1},8,["layout-dependency","aria-label"])]),_:1},16,["layout-dependency","style"])]),_:1},8,["transition"])]),_:1}))}}),$e=Te;function Le(){const o=document.createElement("style");return o.textContent=`
2
2
  * {
3
3
  cursor: none !important;
4
4
  }
@@ -6,4 +6,4 @@
6
6
  [data-motion-cursor="pointer"] {
7
7
  background-color: #333;
8
8
  }
9
- `,document.head.appendChild(o),()=>{document.head.removeChild(o)}}function Me(o){e.watch(o,(t,n,r)=>{const i=t?Le():a.noop;return r(()=>{i()})},{immediate:!0,flush:"post"})}function q(o){return t=>{t.pointerType==="mouse"&&o(t)}}function ie(o){return q(t=>{t.button===0&&o(t)})}let A,Y;function Ve(){A=a.motionValue(0),Y=a.motionValue(0);let o=0,t=0;function n(){A.set(o),Y.set(t)}typeof window<"u"&&window.addEventListener("pointermove",q(r=>{o=r.clientX,t=r.clientY,a.frame.update(n)}))}function G(){return A||Ve(),{x:A,y:Y}}function Re(o,t){return{x:a.useTransform(()=>o.x.get()+t.value.x),y:a.useTransform(()=>o.y.get()+t.value.y)}}function De(o){return o.closest("[data-cursor]")}function Ne(o){return o.closest('a, button, input[type="button"]:not(:disabled)')}function Fe(o){return window.getComputedStyle(o).userSelect==="none"?null:o.closest("p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6")}function Oe(o){let t=De(o);return t?[t.dataset.cursor,t]:(t=Ne(o),t?["pointer",t]:(t=Fe(o),t?["text",t]:["default",null]))}let K=null,I={type:"default",isPressed:!1,fontSize:null,targetBoundingBox:null,target:null,zone:null};function _e(o){let t=null;if("closest"in o){const n=o.closest("[data-cursor-zone]");n instanceof HTMLElement&&(t=n.dataset.cursorZone||null)}return t}function Ae(){if(typeof window>"u")return{onChange:()=>()=>{}};const o=new Set;function t(d){I={...I,...d},o.forEach(g=>g(I))}const n=ie(()=>{I.isPressed||t({isPressed:!0})}),r=ie(()=>{I.isPressed&&t({isPressed:!1})}),i=q(({target:d})=>{if(!d)return;const[g,w]=Oe(d);let h=!1;const u={target:w,zone:_e(d)};g!==I.type&&(u.type=g,h=!0),u.zone!==I.zone&&(I.zone=u.zone,h=!0);const m=g==="pointer"&&w?w.getBoundingClientRect():null;if(m!==I.targetBoundingBox&&(u.targetBoundingBox=m,h=!0),g==="text"){const{fontSize:y}=window.getComputedStyle(d),k=y?parseInt(y):null;k!==I.fontSize&&(u.fontSize=k,h=!0)}else I.fontSize&&(u.fontSize=null,h=!0);h&&t(u)});function s(){typeof window>"u"||(window.addEventListener("pointerover",i),window.addEventListener("pointerdown",n),window.addEventListener("pointerup",r))}function l(){window.removeEventListener("pointerover",i),window.removeEventListener("pointerdown",n),window.removeEventListener("pointerup",r)}return{onChange:d=>(o.size||s(),o.add(d),()=>{o.delete(d),o.size||l()})}}function je(){return K||(K=Ae()),K}function Z(){const o=e.ref({...I});return e.watch(o,()=>je().onChange(t=>{o.value=t}),{immediate:!0,flush:"post"}),o}let W=null;function He(){const o=new Set;function t(){o.forEach(s=>s.show())}function n(){o.forEach(s=>s.hide())}function r(){document.body.addEventListener("mouseenter",t),document.body.addEventListener("mouseleave",n)}function i(){document.body.removeEventListener("mouseenter",t),document.body.removeEventListener("mouseleave",n)}return{on:s=>typeof window>"u"?a.noop:(o.size||r(),o.add(s),()=>{o.delete(s),o.size===0&&i()})}}function Ke(){return W||(W=He()),W}function ve(o){const t=e.ref(!0);return e.watch(t,()=>Ke().on({show:()=>{t.value||(o(),t.value=!0)},hide:()=>t.value=!1}),{immediate:!0}),t}const re={x:0,y:0},We={x:.5,y:.5},Xe={duration:0},Ue={stiffness:1e3,damping:100},Ye={duration:.15,ease:[.38,.12,.29,1]},ae={magneticOptions:{morph:!0,padding:5,snap:.8}},se=17,ue=31,le=4,qe=20;function _(o,t,n){const r={width:(n==null?void 0:n.width)??o,height:(n==null?void 0:n.height)??t};return typeof r.width=="number"&&(r.width=`${r.width}px`),typeof r.height=="number"&&(r.height=`${r.height}px`),r}function Ge({type:o,state:t,hasChildren:n,style:r,isMagnetic:i,magneticOptions:s,matchTextSize:l}){const d=i&&t.targetBoundingBox;if(n&&!d)return _("auto","auto",r);const{padding:g,morph:w}=s;switch(o){case"pointer":if(i&&w&&t.targetBoundingBox){const{width:h,height:u}=t.targetBoundingBox;return{width:`${h+g*2}px`,height:`${u+g*2}px`}}return _(ue,ue,r);case"text":return l&&t.fontSize?{width:`${le}px`,height:`${t.fontSize}px`}:_(le,qe,r);default:return _(se,se,r)}}function Ze({x:o,y:t},n){const r=e.ref(o.prev!==void 0||t.prev!==void 0);return e.watch(r,()=>{if(r.value)return;const i=()=>{r.value=!0,n(),s()},s=a.pipe(o.on("change",i),t.on("change",i));return()=>s()},{immediate:!0}),r}function Je(o,t,n){return a.useTransform(()=>a.mix(o.value.get(),t.get(),n.get()))}function ce(o,t,n){const r=a.useSpring(0,{stiffness:600,damping:50}),i=a.useMotionValue(0),s=Je(o,r,i);return e.watch(()=>n==null?void 0:n.value,(l,d)=>{l?(!d&&!i.isAnimating()?r.jump(l):r.set(l),a.animate(i,t.value||0)):a.animate(i,0)},{immediate:!0,flush:"sync"}),s}function Qe(o,t,n,r){const i=ce(e.computed(()=>o.value.x),r,e.computed(()=>n.value.targetBoundingBox?n.value.targetBoundingBox.left+n.value.targetBoundingBox.width/2:void 0)),s=ce(e.computed(()=>o.value.y),r,e.computed(()=>n.value.targetBoundingBox?n.value.targetBoundingBox.top+n.value.targetBoundingBox.height/2:void 0));return e.computed(()=>t.value?{x:i,y:s}:o.value)}const et=e.defineComponent({name:"Cursor",inheritAttrs:!1,__name:"Cursor",props:{follow:{type:Boolean,default:!1},center:{default:({follow:o})=>o?re:We},offset:{default:()=>re},spring:{type:[Boolean,Object],default:({follow:o})=>o?Ue:!1},matchTextSize:{type:Boolean,default:!0},magnetic:{type:[Boolean,Object],default:!1},transition:{},variants:{},style:{},show:{type:Boolean,default:!0}},setup(o){const t=o,{offset:n,magnetic:r}=e.toRefs(t),i=a.useReducedMotion();Me(()=>!i.value&&!t.follow);const s=G(),l=Re(s,n),d=a.useSpring(l.x,t.spring||void 0),g=a.useSpring(l.y,t.spring||void 0),w=e.computed(()=>typeof t.magnetic=="object"?{...ae.magneticOptions,...t.magnetic}:ae.magneticOptions);function h(){const p=l.x.on("change",b=>{d.jump(b),p()}),C=l.y.on("change",b=>{g.jump(b),C()})}const u=Z(),m=ve(h),y=Qe(e.computed(()=>t.spring?{x:d,y:g}:s),e.computed(()=>!!r.value),u,e.computed(()=>w.value&&w.value.snap)),k=e.useSlots(),x=e.computed(()=>{var b,T;const p=(T=(b=k.default)==null?void 0:b.call(k))==null?void 0:T.filter($=>$.type!==Symbol.for("v-cmt"));return Ge({type:u.value.type,state:u.value,hasChildren:!!(p!=null&&p.length),isMagnetic:!!t.magnetic,style:t.style,magneticOptions:w.value,matchTextSize:t.matchTextSize})}),f=Ze(s,h);function v(p){return(C,b)=>`translate(-${p.x*100}%, -${p.y*100}%) ${b}`}function c(){const{follow:p,center:C,offset:b,spring:T,matchTextSize:$,magnetic:R,...B}=t;return B}return(p,C)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(f)?(e.openBlock(),e.createBlock(e.unref(a.LayoutGroup),{key:0},{default:e.withCtx(()=>[e.createVNode(e.unref(a.MotionConfig),{transition:e.unref(i)?e.unref(Xe):p.transition||e.unref(Ye)},{default:e.withCtx(()=>{var b,T;return[e.createVNode(e.unref(a.motion).div,e.mergeProps({layout:"","data-motion-cursor":p.follow?"follow":"pointer","data-framer-portal-id":"motion-cursor",initial:"exit",exit:"exit"},{...p.$attrs,...c()},{variants:{pressed:p.follow?{}:{scale:.9},...p.variants,default:{opacity:1,scale:1,...(b=p.variants)==null?void 0:b.default},exit:{opacity:0,scale:0,...(T=p.variants)==null?void 0:T.exit}},animate:["default",e.unref(u).type,e.unref(r)&&e.unref(u).targetBoundingBox?"magnetic":"",!e.unref(m)||!p.show?"exit":e.unref(u).isPressed?"pressed":""],"transform-template":v(p.center),style:{borderRadius:p.follow?0:20,zIndex:p.follow?99998:99999,willChange:"transform",contain:"layout",originX:p.center.x,originY:p.center.y,...p.style,width:x.value.width,height:x.value.height,x:e.unref(y).x,y:e.unref(y).y,top:0,left:0,position:"fixed",pointerEvents:"none"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.AnimatePresence),null,{default:e.withCtx(()=>[e.renderSlot(p.$slots,"default")]),_:3})]),_:3},16,["data-motion-cursor","variants","animate","transform-template","style"])]}),_:3},8,["transition"])]),_:3})):e.createCommentVNode("",!0)]))}});function de(o,t,n){const r=a.useMotionValue(0),i=a.useMotionValue(0),s=a.useMotionValue(0);return e.watch(()=>n==null?void 0:n.value,l=>{if(typeof l=="number"){a.animate(s,1);const d=()=>{i.set(t*(o.get()-l))};return d(),o.on("change",d)}else a.animate(s,0)},{immediate:!0,flush:"post"}),a.useTransform(()=>a.mix(r.get(),i.get(),s.get()))}function tt(o,t=.1){const n=Z(),r=G(),i=e.computed(()=>n.value.targetBoundingBox&&n.value.target===o.value),s=de(r.x,t,e.computed(()=>i.value?n.value.targetBoundingBox.left+n.value.targetBoundingBox.width/2:void 0)),l=de(r.y,t,e.computed(()=>i.value?n.value.targetBoundingBox.top+n.value.targetBoundingBox.height/2:void 0));return{x:s,y:l}}const[nt,ot]=a.createContext("TickerItemContext"),fe=e.defineComponent({__name:"TickerItem",props:{offset:{},axis:{},listSize:{},containerPaddingStart:{},bounds:{},itemIndex:{},cloneIndex:{}},setup(o){const t=o,n=a.useMotionValue(0);a.useTransform(()=>{const i=t.offset.get(),{start:s,end:l}=t.bounds;return!s&&!l||!t.listSize?n.set(0):i+l<=-t.containerPaddingStart?n.set(t.listSize):n.set(0)});const r=a.useMotionValue(0);return a.useTransform(()=>{const{offset:i,listSize:s,bounds:l}=t,{start:d,end:g}=l,w=i.get(),h=n.get();return!d&&!g||!s?r.set(0):r.set(w+d+h)}),ot({offset:r}),(i,s)=>(e.openBlock(),e.createBlock(e.unref(a.motion).li,e.mergeProps(i.$attrs,{class:i.cloneIndex===void 0?"ticker-item":"clone-item","aria-hidden":i.cloneIndex!==void 0?!0:void 0,style:{flexShrink:0,flexGrow:0,x:i.axis==="x"?e.unref(n):0,y:i.axis==="y"?e.unref(n):0}}),{default:e.withCtx(()=>[e.renderSlot(i.$slots,"default")]),_:3},16,["class","aria-hidden","style"]))}});function ge(o,t,n){let r=!1;e.onMounted(()=>{const i=o.value;if(!i)return;const s=t.value==="x"?"scrollLeft":"scrollTop",l=t.value==="x"?"offsetLeft":"offsetTop",d=t.value==="x"?"ArrowLeft":"ArrowUp",g=t.value==="x"?"ArrowRight":"ArrowDown";let w=[],h=0;const u=()=>{const v=w[h];v.focus(),n.set(-v[l]),i[s]=0,a.frame.render(()=>{i[s]=0})},m=v=>{if(v.key==="Tab"){v.preventDefault(),x();const c=Array.from(document.querySelectorAll('a, button, input, textarea, select, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]')).filter(a.isHTMLElement);c.sort(it);const p=c[v.shiftKey?0:c.length-1],C=v.shiftKey?c.length-1:0;if(i.contains(p)){c[C].focus();return}else{const b=c.indexOf(w[h]),T=v.shiftKey?-1:1;for(let $=b;$<c.length&&$>=0;$+=T){const R=c[$];if(!i.contains(R)){R.focus();return}}}return}else v.key===d?h--:v.key===g&&h++;h=a.wrap(0,w.length,h),u()},y=()=>{r||(r=!0,w=Array.from(i.querySelectorAll('.ticker-item a, .ticker-item button, .ticker-item input, .ticker-item textarea, .ticker-item select, .ticker-item [tabindex]:not([tabindex="-1"]), .ticker-item [contenteditable="true"]')).filter(a.isHTMLElement),h=0,u(),window.addEventListener("focus",k,!0),window.addEventListener("blur",k,!0),i.addEventListener("keydown",m))},k=v=>{(!v.target||!(v.target instanceof HTMLElement)||!i.contains(v.target))&&x()},x=()=>{r&&(r=!1,window.removeEventListener("focus",k,!0),window.removeEventListener("blur",k,!0),i.removeEventListener("keydown",m))},f=v=>{const{target:c}=v;a.isHTMLElement(c)&&(r||y())};i.addEventListener("focus",f,!0),e.onUnmounted(()=>{i.removeEventListener("focus",f),x()})})}function it(o,t){return o.tabIndex>=1&&t.tabIndex>=1?o.tabIndex-t.tabIndex:o.tabIndex>=1&&t.tabIndex<=0?-1:t.tabIndex>=1&&o.tabIndex<=0?1:0}const pe={start:0,end:0};function he(o=[]){const t=[];for(const n of o)n.type!==e.Comment&&(n.type===e.Fragment&&Array.isArray(n.children)?t.push(...he(n.children)):t.push(n));return t}function rt(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!e.isVNode(o)}const at=e.defineComponent({__name:"Ticker",props:{axis:{default:"x"},style:{},velocity:{default:50},hoverFactor:{default:1},gap:{default:10},align:{default:"center"},offset:{}},setup(o){const t=o,n=e.reactive({listSize:0,containerSize:0,containerPaddingStart:0,containerPaddingEnd:0,itemSizes:[]}),r=e.ref(!1),i=a.useMotionValue(1),s=a.useMotionValue(0),l=e.computed(()=>t.offset??s),d=a.useMotionValue(0);a.useTransform(()=>(d.set(a.wrap(-n.listSize-t.gap-n.containerPaddingStart,-n.containerPaddingStart,l.value.get())),d.get()));const g=a.useMotionValue(0),w=e.computed(()=>r.value?g:d),h=e.computed(()=>t.align==="start"?"flex-start":t.align==="center"?"center":"flex-end"),u=a.useDomRef(),m=a.useDomRef(),y=a.useInView(u,{margin:"100px"}),k=a.useReducedMotion();function x(){if(!u.value||!m.value)return;const{axis:B}=t,S=B==="x"?"offsetWidth":"offsetHeight",z=B==="x"?"offsetLeft":"offsetTop",P=B==="x"?"paddingLeft":"paddingTop",D=B==="x"?"paddingRight":"paddingBottom",N=u.value,j=m.value.querySelectorAll(".ticker-item");if(!j.length)return;let Q=!1;const M=[];for(let L=0;L<j.length;L++){const H=j[L];M.push({start:H[z],end:H[z]+H[S]}),(!n.itemSizes[L]||M[L].start!==n.itemSizes[L].start||M[L].end!==n.itemSizes[L].end)&&(Q=!0)}const ee=N[S],te=M[M.length-1].end-M[0].start,ne=window.getComputedStyle(N),xe=parseInt(ne[P]??0),we=parseInt(ne[D]??0);(te!==n.listSize||ee!==n.containerSize||Q)&&(n.listSize=te,n.containerSize=ee,n.containerPaddingStart=xe,n.containerPaddingEnd=we,n.itemSizes=M)}const f=e.useSlots(),v=e.computed(()=>{var B;return he((B=f.default)==null?void 0:B.call(f))});e.watch([v,y,u],(B,S,z)=>{if(!y.value||!u.value)return;x();const P=a.resize(u.value,x);z(P)},{immediate:!0,flush:"sync"});const c=e.computed(()=>n.containerSize>0&&n.listSize>0);a.useAnimationFrame((B,S)=>{if(c.value&&y.value&&l.value===s&&!k.value){const z=S/1e3*(t.velocity*i.get());l.value.set(l.value.get()-z)}});const p=e.computed(()=>{let B=0;if(!c.value||!n.containerSize)return 0;let S=0;const z=Math.max(...n.itemSizes.map(P=>P.end-P.start));for(;S<n.containerSize+n.containerPaddingStart;)S=(n.listSize+t.gap)*(B+1)-z,B++;return Math.max(B-1,0)}),C=e.computed(()=>n.listSize===0?0:(n.listSize+t.gap)*(p.value+1)),b=e.computed(()=>{const B=[];for(let S=0;S<p.value;S++)v.value.forEach((z,P)=>{const D=n.itemSizes[P],N=(n.listSize+t.gap)*(S+1),J=D?{start:D.start+N,end:D.end+N}:pe;B.push(e.createVNode(fe,{key:`clone-${S}-${P}`,offset:w.value,axis:t.axis,listSize:C.value,cloneIndex:P,bounds:J,containerPaddingStart:n.containerPaddingStart},rt(z)?z:{default:()=>[z]}))});return B}),T=e.toRef(t,"axis");ge(u,T,g);const $={display:"flex",position:"relative",overflow:"hidden"},R=e.computed(()=>({display:"flex",position:"relative",willChange:"transform",listStyleType:"none",padding:0,margin:0,justifyContent:"flex-start",flexDirection:t.axis==="x"?"row":"column",gap:`${t.gap}px`,alignItems:h.value,x:t.axis==="x"?w.value:0,y:t.axis==="y"?w.value:0,opacity:c.value?1:0}));return(B,S)=>(e.openBlock(),e.createBlock(e.unref(a.motion).div,e.mergeProps({...B.$attrs},{ref_key:"containerRef",ref:u,"data-size":n.listSize,style:{...$,...t.style},onFocusCapture:S[0]||(S[0]=()=>{r.value=!0}),onBlurCapture:S[1]||(S[1]=()=>{r.value=!1,l.value.set(e.unref(g).get())}),onPointerenter:S[2]||(S[2]=()=>{e.unref(a.animate)(e.unref(i),B.hoverFactor)}),onPointerleave:S[3]||(S[3]=()=>{e.unref(a.animate)(e.unref(i),1)})}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).ul,{ref_key:"listRef",ref:m,style:e.normalizeStyle(R.value)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,(z,P)=>(e.openBlock(),e.createBlock(fe,{key:`original-${P}`,axis:T.value,offset:w.value,"list-size":C.value,"item-index":P,bounds:n.itemSizes[P]??e.unref(pe),"container-padding-start":n.containerPaddingStart},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(z),{index:P},null,8,["index"]))]),_:2},1032,["axis","offset","list-size","item-index","bounds","container-padding-start"]))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,z=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(z),{key:z.key}))),128))]),_:1},8,["style"])]),_:1},16,["data-size","style"]))}});function st(){const o=nt(null);return a.invariant(!!o,"useItemOffset must be used within a TickerItem"),o==null?void 0:o.offset}const ut=at;exports.AnimateNumber=$e;exports.Cursor=et;exports.Ticker=ut;exports.useCursorIsInView=ve;exports.useCursorState=Z;exports.useItemOffset=st;exports.useKeyboardFocus=ge;exports.useMagneticPull=tt;exports.usePointerPosition=G;
9
+ `,document.head.appendChild(o),()=>{document.head.removeChild(o)}}function Me(o){e.watch(o,(t,n,r)=>{const i=t?Le():a.noop;return r(()=>{i()})},{immediate:!0,flush:"post"})}function Z(o){return t=>{t.pointerType==="mouse"&&o(t)}}function re(o){return Z(t=>{t.button===0&&o(t)})}let j,q;function Ve(){j=a.motionValue(0),q=a.motionValue(0);let o=0,t=0;function n(){j.set(o),q.set(t)}typeof window<"u"&&window.addEventListener("pointermove",Z(r=>{o=r.clientX,t=r.clientY,a.frame.update(n)}))}function J(){return j||Ve(),{x:j,y:q}}function Re(o,t){return{x:a.useTransform(()=>o.x.get()+t.value.x),y:a.useTransform(()=>o.y.get()+t.value.y)}}function Ne(o){return o.closest("[data-cursor]")}function De(o){return o.closest('a, button, input[type="button"]:not(:disabled)')}function Fe(o){return window.getComputedStyle(o).userSelect==="none"?null:o.closest("p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6")}function Oe(o){let t=Ne(o);return t?[t.dataset.cursor,t]:(t=De(o),t?["pointer",t]:(t=Fe(o),t?["text",t]:["default",null]))}let W=null,I={type:"default",isPressed:!1,fontSize:null,targetBoundingBox:null,target:null,zone:null};function _e(o){let t=null;if("closest"in o){const n=o.closest("[data-cursor-zone]");n instanceof HTMLElement&&(t=n.dataset.cursorZone||null)}return t}function Ae(){if(typeof window>"u")return{onChange:()=>()=>{}};const o=new Set;function t(d){I={...I,...d},o.forEach(g=>g(I))}const n=re(()=>{I.isPressed||t({isPressed:!0})}),r=re(()=>{I.isPressed&&t({isPressed:!1})}),i=Z(({target:d})=>{if(!d)return;const[g,w]=Oe(d);let h=!1;const u={target:w,zone:_e(d)};g!==I.type&&(u.type=g,h=!0),u.zone!==I.zone&&(I.zone=u.zone,h=!0);const m=g==="pointer"&&w?w.getBoundingClientRect():null;if(m!==I.targetBoundingBox&&(u.targetBoundingBox=m,h=!0),g==="text"){const{fontSize:y}=window.getComputedStyle(d),k=y?parseInt(y):null;k!==I.fontSize&&(u.fontSize=k,h=!0)}else I.fontSize&&(u.fontSize=null,h=!0);h&&t(u)});function s(){typeof window>"u"||(window.addEventListener("pointerover",i),window.addEventListener("pointerdown",n),window.addEventListener("pointerup",r))}function l(){window.removeEventListener("pointerover",i),window.removeEventListener("pointerdown",n),window.removeEventListener("pointerup",r)}return{onChange:d=>(o.size||s(),o.add(d),()=>{o.delete(d),o.size||l()})}}function je(){return W||(W=Ae()),W}function Q(){const o=e.ref({...I});return e.watch(o,()=>je().onChange(t=>{o.value=t}),{immediate:!0,flush:"post"}),o}let X=null;function He(){const o=new Set;function t(){o.forEach(s=>s.show())}function n(){o.forEach(s=>s.hide())}function r(){document.body.addEventListener("mouseenter",t),document.body.addEventListener("mouseleave",n)}function i(){document.body.removeEventListener("mouseenter",t),document.body.removeEventListener("mouseleave",n)}return{on:s=>typeof window>"u"?a.noop:(o.size||r(),o.add(s),()=>{o.delete(s),o.size===0&&i()})}}function Ke(){return X||(X=He()),X}function ge(o){const t=e.ref(!0);return e.watch(t,()=>Ke().on({show:()=>{t.value||(o(),t.value=!0)},hide:()=>t.value=!1}),{immediate:!0}),t}const ae={x:0,y:0},We={x:.5,y:.5},Xe={duration:0},Ue={stiffness:1e3,damping:100},Ye={duration:.15,ease:[.38,.12,.29,1]},se={magneticOptions:{morph:!0,padding:5,snap:.8}},ue=17,le=31,ce=4,qe=20;function A(o,t,n){const r={width:(n==null?void 0:n.width)??o,height:(n==null?void 0:n.height)??t};return typeof r.width=="number"&&(r.width=`${r.width}px`),typeof r.height=="number"&&(r.height=`${r.height}px`),r}function Ge({type:o,state:t,hasChildren:n,style:r,isMagnetic:i,magneticOptions:s,matchTextSize:l}){const d=i&&t.targetBoundingBox;if(n&&!d)return A("auto","auto",r);const{padding:g,morph:w}=s;switch(o){case"pointer":if(i&&w&&t.targetBoundingBox){const{width:h,height:u}=t.targetBoundingBox;return{width:`${h+g*2}px`,height:`${u+g*2}px`}}return A(le,le,r);case"text":return l&&t.fontSize?{width:`${ce}px`,height:`${t.fontSize}px`}:A(ce,qe,r);default:return A(ue,ue,r)}}function Ze({x:o,y:t},n){const r=e.ref(o.prev!==void 0||t.prev!==void 0);return e.watch(r,()=>{if(r.value)return;const i=()=>{r.value=!0,n(),s()},s=a.pipe(o.on("change",i),t.on("change",i));return()=>s()},{immediate:!0}),r}function Je(o,t,n){return a.useTransform(()=>a.mix(o.value.get(),t.get(),n.get()))}function de(o,t,n){const r=a.useSpring(0,{stiffness:600,damping:50}),i=a.useMotionValue(0),s=Je(o,r,i);return e.watch(()=>n==null?void 0:n.value,(l,d)=>{l?(!d&&!i.isAnimating()?r.jump(l):r.set(l),a.animate(i,t.value||0)):a.animate(i,0)},{immediate:!0,flush:"sync"}),s}function Qe(o,t,n,r){const i=de(e.computed(()=>o.value.x),r,e.computed(()=>n.value.targetBoundingBox?n.value.targetBoundingBox.left+n.value.targetBoundingBox.width/2:void 0)),s=de(e.computed(()=>o.value.y),r,e.computed(()=>n.value.targetBoundingBox?n.value.targetBoundingBox.top+n.value.targetBoundingBox.height/2:void 0));return e.computed(()=>t.value?{x:i,y:s}:o.value)}const et=e.defineComponent({name:"Cursor",inheritAttrs:!1,__name:"Cursor",props:{follow:{type:Boolean,default:!1},center:{default:({follow:o})=>o?ae:We},offset:{default:()=>ae},spring:{type:[Boolean,Object],default:({follow:o})=>o?Ue:!1},matchTextSize:{type:Boolean,default:!0},magnetic:{type:[Boolean,Object],default:!1},transition:{},variants:{},style:{},show:{type:Boolean,default:!0}},setup(o){const t=o,{offset:n,magnetic:r}=e.toRefs(t),i=a.useReducedMotion();Me(()=>!i.value&&!t.follow);const s=J(),l=Re(s,n),d=a.useSpring(l.x,t.spring||void 0),g=a.useSpring(l.y,t.spring||void 0),w=e.computed(()=>typeof t.magnetic=="object"?{...se.magneticOptions,...t.magnetic}:se.magneticOptions);function h(){const p=l.x.on("change",z=>{d.jump(z),p()}),C=l.y.on("change",z=>{g.jump(z),C()})}const u=Q(),m=ge(h),y=Qe(e.computed(()=>t.spring?{x:d,y:g}:s),e.computed(()=>!!r.value),u,e.computed(()=>w.value&&w.value.snap)),k=e.useSlots(),x=e.computed(()=>{var z,T;const p=(T=(z=k.default)==null?void 0:z.call(k))==null?void 0:T.filter($=>$.type!==Symbol.for("v-cmt"));return Ge({type:u.value.type,state:u.value,hasChildren:!!(p!=null&&p.length),isMagnetic:!!t.magnetic,style:t.style,magneticOptions:w.value,matchTextSize:t.matchTextSize})}),f=Ze(s,h);function v(p){return(C,z)=>`translate(-${p.x*100}%, -${p.y*100}%) ${z}`}function c(){const{follow:p,center:C,offset:z,spring:T,matchTextSize:$,magnetic:D,...B}=t;return B}return(p,C)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(f)?(e.openBlock(),e.createBlock(e.unref(a.LayoutGroup),{key:0},{default:e.withCtx(()=>[e.createVNode(e.unref(a.MotionConfig),{transition:e.unref(i)?e.unref(Xe):p.transition||e.unref(Ye)},{default:e.withCtx(()=>{var z,T;return[e.createVNode(e.unref(a.motion).div,e.mergeProps({layout:"","data-motion-cursor":p.follow?"follow":"pointer","data-framer-portal-id":"motion-cursor",initial:"exit",exit:"exit"},{...p.$attrs,...c()},{variants:{pressed:p.follow?{}:{scale:.9},...p.variants,default:{opacity:1,scale:1,...(z=p.variants)==null?void 0:z.default},exit:{opacity:0,scale:0,...(T=p.variants)==null?void 0:T.exit}},animate:["default",e.unref(u).type,e.unref(r)&&e.unref(u).targetBoundingBox?"magnetic":"",!e.unref(m)||!p.show?"exit":e.unref(u).isPressed?"pressed":""],"transform-template":v(p.center),style:{borderRadius:p.follow?0:20,zIndex:p.follow?99998:99999,willChange:"transform",contain:"layout",originX:p.center.x,originY:p.center.y,...p.style,width:x.value.width,height:x.value.height,x:e.unref(y).x,y:e.unref(y).y,top:0,left:0,position:"fixed",pointerEvents:"none"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.AnimatePresence),null,{default:e.withCtx(()=>[e.renderSlot(p.$slots,"default")]),_:3})]),_:3},16,["data-motion-cursor","variants","animate","transform-template","style"])]}),_:3},8,["transition"])]),_:3})):e.createCommentVNode("",!0)]))}});function fe(o,t,n){const r=a.useMotionValue(0),i=a.useMotionValue(0),s=a.useMotionValue(0);return e.watch(()=>n==null?void 0:n.value,l=>{if(typeof l=="number"){a.animate(s,1);const d=()=>{i.set(t*(o.get()-l))};return d(),o.on("change",d)}else a.animate(s,0)},{immediate:!0,flush:"post"}),a.useTransform(()=>a.mix(r.get(),i.get(),s.get()))}function tt(o,t=.1){const n=Q(),r=J(),i=e.computed(()=>n.value.targetBoundingBox&&n.value.target===o.value),s=fe(r.x,t,e.computed(()=>i.value?n.value.targetBoundingBox.left+n.value.targetBoundingBox.width/2:void 0)),l=fe(r.y,t,e.computed(()=>i.value?n.value.targetBoundingBox.top+n.value.targetBoundingBox.height/2:void 0));return{x:s,y:l}}const[nt,ot]=a.createContext("TickerItemContext"),pe=e.defineComponent({__name:"TickerItem",props:{offset:{},axis:{},listSize:{},containerPaddingStart:{},bounds:{},itemIndex:{},cloneIndex:{}},setup(o){const t=o,n=a.useMotionValue(0);a.useTransform(()=>{const i=t.offset.get(),{start:s,end:l}=t.bounds;return!s&&!l||!t.listSize?n.set(0):i+l<=-t.containerPaddingStart?n.set(t.listSize):n.set(0)});const r=a.useMotionValue(0);return a.useTransform(()=>{const{offset:i,listSize:s,bounds:l}=t,{start:d,end:g}=l,w=i.get(),h=n.get();return!d&&!g||!s?r.set(0):r.set(w+d+h)}),ot({offset:r}),(i,s)=>(e.openBlock(),e.createBlock(e.unref(a.motion).li,e.mergeProps(i.$attrs,{class:i.cloneIndex===void 0?"ticker-item":"clone-item","aria-hidden":i.cloneIndex!==void 0?!0:void 0,style:{flexShrink:0,flexGrow:0,x:i.axis==="x"?e.unref(n):0,y:i.axis==="y"?e.unref(n):0}}),{default:e.withCtx(()=>[e.renderSlot(i.$slots,"default")]),_:3},16,["class","aria-hidden","style"]))}});function he(o,t,n){let r=!1;e.onMounted(()=>{const i=o.value;if(!i)return;const s=t.value==="x"?"scrollLeft":"scrollTop",l=t.value==="x"?"offsetLeft":"offsetTop",d=t.value==="x"?"ArrowLeft":"ArrowUp",g=t.value==="x"?"ArrowRight":"ArrowDown";let w=[],h=0;const u=()=>{const v=w[h];v.focus(),n.set(-v[l]),i[s]=0,a.frame.render(()=>{i[s]=0})},m=v=>{if(v.key==="Tab"){v.preventDefault(),x();const c=Array.from(document.querySelectorAll('a, button, input, textarea, select, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]')).filter(a.isHTMLElement);c.sort(it);const p=c[v.shiftKey?0:c.length-1],C=v.shiftKey?c.length-1:0;if(i.contains(p)){c[C].focus();return}else{const z=c.indexOf(w[h]),T=v.shiftKey?-1:1;for(let $=z;$<c.length&&$>=0;$+=T){const D=c[$];if(!i.contains(D)){D.focus();return}}}return}else v.key===d?h--:v.key===g&&h++;h=a.wrap(0,w.length,h),u()},y=()=>{r||(r=!0,w=Array.from(i.querySelectorAll('.ticker-item a, .ticker-item button, .ticker-item input, .ticker-item textarea, .ticker-item select, .ticker-item [tabindex]:not([tabindex="-1"]), .ticker-item [contenteditable="true"]')).filter(a.isHTMLElement),h=0,u(),window.addEventListener("focus",k,!0),window.addEventListener("blur",k,!0),i.addEventListener("keydown",m))},k=v=>{(!v.target||!(v.target instanceof HTMLElement)||!i.contains(v.target))&&x()},x=()=>{r&&(r=!1,window.removeEventListener("focus",k,!0),window.removeEventListener("blur",k,!0),i.removeEventListener("keydown",m))},f=v=>{const{target:c}=v;a.isHTMLElement(c)&&(r||y())};i.addEventListener("focus",f,!0),e.onUnmounted(()=>{i.removeEventListener("focus",f),x()})})}function it(o,t){return o.tabIndex>=1&&t.tabIndex>=1?o.tabIndex-t.tabIndex:o.tabIndex>=1&&t.tabIndex<=0?-1:t.tabIndex>=1&&o.tabIndex<=0?1:0}const me={start:0,end:0};function rt(o=[]){const t=[];for(const n of o)n.type!==e.Comment&&t.push(n);return t}function G(o){const t=[];for(const n of o)n.type===e.Fragment?t.push(...G(n.children.default())):t.push(n);return t}function at(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!e.isVNode(o)}const st=e.defineComponent({__name:"Ticker",props:{axis:{default:"x"},style:{},velocity:{default:50},hoverFactor:{default:1},gap:{default:10},align:{default:"center"},offset:{}},setup(o){const t=o,n=e.reactive({listSize:0,containerSize:0,containerPaddingStart:0,containerPaddingEnd:0,itemSizes:[]}),r=e.ref(!1),i=a.useMotionValue(1),s=a.useMotionValue(0),l=e.computed(()=>t.offset??s),d=a.useMotionValue(0);a.useTransform(()=>(d.set(a.wrap(-n.listSize-t.gap-n.containerPaddingStart,-n.containerPaddingStart,l.value.get())),d.get()));const g=a.useMotionValue(0),w=e.computed(()=>r.value?g:d),h=e.computed(()=>t.align==="start"?"flex-start":t.align==="center"?"center":"flex-end"),u=a.useDomRef(),m=a.useDomRef(),y=a.useInView(u,{margin:"100px"}),k=a.useReducedMotion();function x(){if(!u.value||!m.value)return;const{axis:B}=t,S=B==="x"?"offsetWidth":"offsetHeight",b=B==="x"?"offsetLeft":"offsetTop",P=B==="x"?"paddingLeft":"paddingTop",V=B==="x"?"paddingRight":"paddingBottom",L=u.value,F=m.value.querySelectorAll(".ticker-item");if(!F.length)return;let ee=!1;const R=[];for(let M=0;M<F.length;M++){const K=F[M];R.push({start:K[b],end:K[b]+K[S]}),(!n.itemSizes[M]||R[M].start!==n.itemSizes[M].start||R[M].end!==n.itemSizes[M].end)&&(ee=!0)}const te=L[S],ne=R[R.length-1].end-R[0].start,oe=window.getComputedStyle(L),xe=parseInt(oe[P]??0),we=parseInt(oe[V]??0);(ne!==n.listSize||te!==n.containerSize||ee)&&(n.listSize=ne,n.containerSize=te,n.containerPaddingStart=xe,n.containerPaddingEnd=we,n.itemSizes=R)}const f=e.useSlots(),v=e.computed(()=>{var B;return rt((B=f.default)==null?void 0:B.call(f))});e.watch([v,y,u],(B,S,b)=>{if(!y.value||!u.value)return;x();const P=a.resize(u.value,x);b(P)},{immediate:!0,flush:"sync"});const c=e.computed(()=>n.containerSize>0&&n.listSize>0);a.useAnimationFrame((B,S)=>{if(c.value&&y.value&&l.value===s&&!k.value){const b=S/1e3*(t.velocity*i.get());l.value.set(l.value.get()-b)}});const p=e.computed(()=>{let B=0;if(!c.value||!n.containerSize)return 0;let S=0;const b=Math.max(...n.itemSizes.map(P=>P.end-P.start));for(;S<n.containerSize+n.containerPaddingStart;)S=(n.listSize+t.gap)*(B+1)-b,B++;return Math.max(B-1,0)}),C=e.computed(()=>n.listSize===0?0:(n.listSize+t.gap)*(p.value+1)),z=e.computed(()=>{const B=[];for(let S=0;S<p.value;S++)v.value.forEach((b,P)=>{let V;const L=n.itemSizes[P],H=(n.listSize+t.gap)*(S+1),F=L?{start:L.start+H,end:L.end+H}:me;B.push(e.createVNode(pe,{key:`clone-${S}-${P}`,offset:w.value,axis:t.axis,listSize:C.value,cloneIndex:P,bounds:F,containerPaddingStart:n.containerPaddingStart},at(V=G([b]))?V:{default:()=>[V]}))});return B}),T=e.toRef(t,"axis");he(u,T,g);const $={display:"flex",position:"relative",overflow:"hidden"},D=e.computed(()=>({display:"flex",position:"relative",willChange:"transform",listStyleType:"none",padding:0,margin:0,justifyContent:"flex-start",flexDirection:t.axis==="x"?"row":"column",gap:`${t.gap}px`,alignItems:h.value,x:t.axis==="x"?w.value:0,y:t.axis==="y"?w.value:0,opacity:c.value?1:0}));return(B,S)=>(e.openBlock(),e.createBlock(e.unref(a.motion).div,e.mergeProps({...B.$attrs},{ref_key:"containerRef",ref:u,"data-size":n.listSize,style:{...$,...t.style},onFocusCapture:S[0]||(S[0]=()=>{r.value=!0}),onBlurCapture:S[1]||(S[1]=()=>{r.value=!1,l.value.set(e.unref(g).get())}),onPointerenter:S[2]||(S[2]=()=>{e.unref(a.animate)(e.unref(i),B.hoverFactor)}),onPointerleave:S[3]||(S[3]=()=>{e.unref(a.animate)(e.unref(i),1)})}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.motion).ul,{ref_key:"listRef",ref:m,style:e.normalizeStyle(D.value)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,(b,P)=>(e.openBlock(),e.createBlock(pe,{key:`original-${P}`,axis:T.value,offset:w.value,"list-size":C.value,"item-index":P,bounds:n.itemSizes[P]??e.unref(me),"container-padding-start":n.containerPaddingStart},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(G)([b]),(V,L)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(V),{key:L}))),128))]),_:2},1032,["axis","offset","list-size","item-index","bounds","container-padding-start"]))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,b=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b),{key:b.key}))),128))]),_:1},8,["style"])]),_:1},16,["data-size","style"]))}});function ut(){const o=nt(null);return a.invariant(!!o,"useItemOffset must be used within a TickerItem"),o==null?void 0:o.offset}const lt=st;exports.AnimateNumber=$e;exports.Cursor=et;exports.Ticker=lt;exports.useCursorIsInView=ge;exports.useCursorState=Q;exports.useItemOffset=ut;exports.useKeyboardFocus=he;exports.useMagneticPull=tt;exports.usePointerPosition=J;
@@ -1,13 +1,13 @@
1
- import { defineComponent as ae, reactive as oe, ref as se, computed as s, useSlots as re, watch as le, createVNode as A, toRef as ue, createBlock as v, openBlock as d, unref as u, mergeProps as ce, withCtx as F, normalizeStyle as de, createElementBlock as N, Fragment as q, renderList as H, resolveDynamicComponent as K, isVNode as fe } from "vue";
2
- import { useMotionValue as z, useTransform as pe, wrap as me, useDomRef as W, useInView as ge, useReducedMotion as Se, resize as ve, useAnimationFrame as ze, motion as G, animate as J } from "motion-v";
1
+ import { defineComponent as oe, reactive as se, ref as re, computed as s, useSlots as le, watch as ue, createVNode as H, toRef as ce, createBlock as z, openBlock as p, unref as r, mergeProps as de, withCtx as O, normalizeStyle as fe, createElementBlock as _, Fragment as M, renderList as V, resolveDynamicComponent as K, isVNode as pe } from "vue";
2
+ import { useMotionValue as y, useTransform as me, wrap as ge, useDomRef as W, useInView as Se, useReducedMotion as ve, resize as ze, useAnimationFrame as ye, motion as G, animate as J } from "motion-v";
3
3
  import Q from "./TickerItem.vue.mjs";
4
- import { useKeyboardFocus as ye } from "./use-keyboard-focus.mjs";
4
+ import { useKeyboardFocus as xe } from "./use-keyboard-focus.mjs";
5
5
  import { defaultBounds as U } from "./const.mjs";
6
- import { flattenSlots as xe } from "../../utils/flatten-slots.mjs";
7
- function Pe(f) {
8
- return typeof f == "function" || Object.prototype.toString.call(f) === "[object Object]" && !fe(f);
6
+ import { flattenSlots as Pe, renderVNode as X } from "../../utils/flatten-slots.mjs";
7
+ function he(m) {
8
+ return typeof m == "function" || Object.prototype.toString.call(m) === "[object Object]" && !pe(m);
9
9
  }
10
- const be = /* @__PURE__ */ ae({
10
+ const Be = /* @__PURE__ */ oe({
11
11
  __name: "Ticker",
12
12
  props: {
13
13
  axis: {
@@ -28,92 +28,93 @@ const be = /* @__PURE__ */ ae({
28
28
  },
29
29
  offset: {}
30
30
  },
31
- setup(f) {
32
- const a = f, e = oe({
31
+ setup(m) {
32
+ const i = m, e = se({
33
33
  listSize: 0,
34
34
  containerSize: 0,
35
35
  containerPaddingStart: 0,
36
36
  containerPaddingEnd: 0,
37
37
  itemSizes: []
38
- }), y = se(!1), x = z(1), O = z(0), p = s(() => a.offset ?? O), P = z(0);
39
- pe(() => (P.set(me(-e.listSize - a.gap - e.containerPaddingStart, -e.containerPaddingStart, p.value.get())), P.get()));
40
- const h = z(0), S = s(() => y.value ? h : P), X = s(() => a.align === "start" ? "flex-start" : a.align === "center" ? "center" : "flex-end"), r = W(), w = W(), k = ge(r, {
38
+ }), x = re(!1), P = y(1), E = y(0), g = s(() => i.offset ?? E), h = y(0);
39
+ me(() => (h.set(ge(-e.listSize - i.gap - e.containerPaddingStart, -e.containerPaddingStart, g.value.get())), h.get()));
40
+ const k = y(0), v = s(() => x.value ? k : h), Y = s(() => i.align === "start" ? "flex-start" : i.align === "center" ? "center" : "flex-end"), l = W(), w = W(), C = Se(l, {
41
41
  margin: "100px"
42
- }), Y = Se();
43
- function M() {
44
- if (!r.value || !w.value) return;
42
+ }), Z = ve();
43
+ function $() {
44
+ if (!l.value || !w.value) return;
45
45
  const {
46
46
  axis: n
47
- } = a, t = n === "x" ? "offsetWidth" : "offsetHeight", i = n === "x" ? "offsetLeft" : "offsetTop", o = n === "x" ? "paddingLeft" : "paddingTop", m = n === "x" ? "paddingRight" : "paddingBottom", g = r.value, b = w.value.querySelectorAll(".ticker-item");
48
- if (!b.length) return;
49
- let T = !1;
50
- const c = [];
51
- for (let l = 0; l < b.length; l++) {
52
- const B = b[l];
53
- c.push({
54
- start: B[i],
55
- end: B[i] + B[t]
56
- }), (!e.itemSizes[l] || c[l].start !== e.itemSizes[l].start || c[l].end !== e.itemSizes[l].end) && (T = !0);
47
+ } = i, t = n === "x" ? "offsetWidth" : "offsetHeight", a = n === "x" ? "offsetLeft" : "offsetTop", o = n === "x" ? "paddingLeft" : "paddingTop", d = n === "x" ? "paddingRight" : "paddingBottom", u = l.value, S = w.value.querySelectorAll(".ticker-item");
48
+ if (!S.length) return;
49
+ let D = !1;
50
+ const f = [];
51
+ for (let c = 0; c < S.length; c++) {
52
+ const F = S[c];
53
+ f.push({
54
+ start: F[a],
55
+ end: F[a] + F[t]
56
+ }), (!e.itemSizes[c] || f[c].start !== e.itemSizes[c].start || f[c].end !== e.itemSizes[c].end) && (D = !0);
57
57
  }
58
- const j = g[t], L = c[c.length - 1].end - c[0].start, D = window.getComputedStyle(g), ne = parseInt(D[o] ?? 0), ie = parseInt(D[m] ?? 0);
59
- (L !== e.listSize || j !== e.containerSize || T) && (e.listSize = L, e.containerSize = j, e.containerPaddingStart = ne, e.containerPaddingEnd = ie, e.itemSizes = c);
58
+ const N = u[t], A = f[f.length - 1].end - f[0].start, q = window.getComputedStyle(u), ie = parseInt(q[o] ?? 0), ae = parseInt(q[d] ?? 0);
59
+ (A !== e.listSize || N !== e.containerSize || D) && (e.listSize = A, e.containerSize = N, e.containerPaddingStart = ie, e.containerPaddingEnd = ae, e.itemSizes = f);
60
60
  }
61
- const C = re(), I = s(() => {
61
+ const I = le(), R = s(() => {
62
62
  var n;
63
- return xe((n = C.default) == null ? void 0 : n.call(C));
63
+ return Pe((n = I.default) == null ? void 0 : n.call(I));
64
64
  });
65
- le([I, k, r], (n, t, i) => {
66
- if (!k.value || !r.value) return;
67
- M();
68
- const o = ve(r.value, M);
69
- i(o);
65
+ ue([R, C, l], (n, t, a) => {
66
+ if (!C.value || !l.value) return;
67
+ $();
68
+ const o = ze(l.value, $);
69
+ a(o);
70
70
  }, {
71
71
  immediate: !0,
72
72
  flush: "sync"
73
73
  });
74
- const R = s(() => e.containerSize > 0 && e.listSize > 0);
75
- ze((n, t) => {
76
- if (R.value && k.value && p.value === O && !Y.value) {
77
- const i = t / 1e3 * (a.velocity * x.get());
78
- p.value.set(p.value.get() - i);
74
+ const b = s(() => e.containerSize > 0 && e.listSize > 0);
75
+ ye((n, t) => {
76
+ if (b.value && C.value && g.value === E && !Z.value) {
77
+ const a = t / 1e3 * (i.velocity * P.get());
78
+ g.value.set(g.value.get() - a);
79
79
  }
80
80
  });
81
- const _ = s(() => {
81
+ const T = s(() => {
82
82
  let n = 0;
83
- if (!R.value || !e.containerSize) return 0;
83
+ if (!b.value || !e.containerSize) return 0;
84
84
  let t = 0;
85
- const i = Math.max(...e.itemSizes.map((o) => o.end - o.start));
85
+ const a = Math.max(...e.itemSizes.map((o) => o.end - o.start));
86
86
  for (; t < e.containerSize + e.containerPaddingStart; )
87
- t = (e.listSize + a.gap) * (n + 1) - i, n++;
87
+ t = (e.listSize + i.gap) * (n + 1) - a, n++;
88
88
  return Math.max(n - 1, 0);
89
- }), E = s(() => e.listSize === 0 ? 0 : (e.listSize + a.gap) * (_.value + 1)), Z = s(() => {
89
+ }), j = s(() => e.listSize === 0 ? 0 : (e.listSize + i.gap) * (T.value + 1)), ee = s(() => {
90
90
  const n = [];
91
- for (let t = 0; t < _.value; t++)
92
- I.value.forEach((i, o) => {
93
- const m = e.itemSizes[o], g = (e.listSize + a.gap) * (t + 1), $ = m ? {
94
- start: m.start + g,
95
- end: m.end + g
91
+ for (let t = 0; t < T.value; t++)
92
+ R.value.forEach((a, o) => {
93
+ let d;
94
+ const u = e.itemSizes[o], B = (e.listSize + i.gap) * (t + 1), S = u ? {
95
+ start: u.start + B,
96
+ end: u.end + B
96
97
  } : U;
97
- n.push(A(Q, {
98
+ n.push(H(Q, {
98
99
  key: `clone-${t}-${o}`,
99
- offset: S.value,
100
- axis: a.axis,
101
- listSize: E.value,
100
+ offset: v.value,
101
+ axis: i.axis,
102
+ listSize: j.value,
102
103
  cloneIndex: o,
103
- bounds: $,
104
+ bounds: S,
104
105
  containerPaddingStart: e.containerPaddingStart
105
- }, Pe(i) ? i : {
106
- default: () => [i]
106
+ }, he(d = X([a])) ? d : {
107
+ default: () => [d]
107
108
  }));
108
109
  });
109
110
  return n;
110
- }), V = ue(a, "axis");
111
- ye(r, V, h);
112
- const ee = {
111
+ }), L = ce(i, "axis");
112
+ xe(l, L, k);
113
+ const te = {
113
114
  display: "flex",
114
115
  position: "relative",
115
116
  overflow: "hidden"
116
- }, te = s(() => ({
117
+ }, ne = s(() => ({
117
118
  display: "flex",
118
119
  position: "relative",
119
120
  willChange: "transform",
@@ -121,56 +122,56 @@ const be = /* @__PURE__ */ ae({
121
122
  padding: 0,
122
123
  margin: 0,
123
124
  justifyContent: "flex-start",
124
- flexDirection: a.axis === "x" ? "row" : "column",
125
- gap: `${a.gap}px`,
126
- alignItems: X.value,
127
- x: a.axis === "x" ? S.value : 0,
128
- y: a.axis === "y" ? S.value : 0,
129
- opacity: R.value ? 1 : 0
125
+ flexDirection: i.axis === "x" ? "row" : "column",
126
+ gap: `${i.gap}px`,
127
+ alignItems: Y.value,
128
+ x: i.axis === "x" ? v.value : 0,
129
+ y: i.axis === "y" ? v.value : 0,
130
+ opacity: b.value ? 1 : 0
130
131
  }));
131
- return (n, t) => (d(), v(u(G).div, ce({
132
+ return (n, t) => (p(), z(r(G).div, de({
132
133
  ...n.$attrs
133
134
  }, {
134
135
  ref_key: "containerRef",
135
- ref: r,
136
+ ref: l,
136
137
  "data-size": e.listSize,
137
138
  style: {
138
- ...ee,
139
- ...a.style
139
+ ...te,
140
+ ...i.style
140
141
  },
141
142
  onFocusCapture: t[0] || (t[0] = () => {
142
- y.value = !0;
143
+ x.value = !0;
143
144
  }),
144
145
  onBlurCapture: t[1] || (t[1] = () => {
145
- y.value = !1, p.value.set(u(h).get());
146
+ x.value = !1, g.value.set(r(k).get());
146
147
  }),
147
148
  onPointerenter: t[2] || (t[2] = () => {
148
- u(J)(u(x), n.hoverFactor);
149
+ r(J)(r(P), n.hoverFactor);
149
150
  }),
150
151
  onPointerleave: t[3] || (t[3] = () => {
151
- u(J)(u(x), 1);
152
+ r(J)(r(P), 1);
152
153
  })
153
154
  }), {
154
- default: F(() => [A(u(G).ul, {
155
+ default: O(() => [H(r(G).ul, {
155
156
  ref_key: "listRef",
156
157
  ref: w,
157
- style: de(te.value)
158
+ style: fe(ne.value)
158
159
  }, {
159
- default: F(() => [(d(!0), N(q, null, H(I.value, (i, o) => (d(), v(Q, {
160
+ default: O(() => [(p(!0), _(M, null, V(R.value, (a, o) => (p(), z(Q, {
160
161
  key: `original-${o}`,
161
- axis: V.value,
162
- offset: S.value,
163
- "list-size": E.value,
162
+ axis: L.value,
163
+ offset: v.value,
164
+ "list-size": j.value,
164
165
  "item-index": o,
165
- bounds: e.itemSizes[o] ?? u(U),
166
+ bounds: e.itemSizes[o] ?? r(U),
166
167
  "container-padding-start": e.containerPaddingStart
167
168
  }, {
168
- default: F(() => [(d(), v(K(i), {
169
- index: o
170
- }, null, 8, ["index"]))]),
169
+ default: O(() => [(p(!0), _(M, null, V(r(X)([a]), (d, u) => (p(), z(K(d), {
170
+ key: u
171
+ }))), 128))]),
171
172
  _: 2
172
- }, 1032, ["axis", "offset", "list-size", "item-index", "bounds", "container-padding-start"]))), 128)), (d(!0), N(q, null, H(Z.value, (i) => (d(), v(K(i), {
173
- key: i.key
173
+ }, 1032, ["axis", "offset", "list-size", "item-index", "bounds", "container-padding-start"]))), 128)), (p(!0), _(M, null, V(ee.value, (a) => (p(), z(K(a), {
174
+ key: a.key
174
175
  }))), 128))]),
175
176
  _: 1
176
177
  }, 8, ["style"])]),
@@ -179,5 +180,5 @@ const be = /* @__PURE__ */ ae({
179
180
  }
180
181
  });
181
182
  export {
182
- be as default
183
+ Be as default
183
184
  };
@@ -1,10 +1,17 @@
1
- import { Comment as n, Fragment as o } from "vue";
2
- function i(r = []) {
3
- const e = [];
4
- for (const t of r)
5
- t.type !== n && (t.type === o && Array.isArray(t.children) ? e.push(...i(t.children)) : e.push(t));
6
- return e;
1
+ import { Comment as o, Fragment as r } from "vue";
2
+ function u(n = []) {
3
+ const t = [];
4
+ for (const e of n)
5
+ e.type !== o && t.push(e);
6
+ return t;
7
+ }
8
+ function f(n) {
9
+ const t = [];
10
+ for (const e of n)
11
+ e.type === r ? t.push(...f(e.children.default())) : t.push(e);
12
+ return t;
7
13
  }
8
14
  export {
9
- i as flattenSlots
15
+ u as flattenSlots,
16
+ f as renderVNode
10
17
  };
@@ -1,2 +1,7 @@
1
1
  import { VNode } from 'vue';
2
2
  export declare function flattenSlots(slots?: VNode[]): VNode[];
3
+ /**
4
+ * Recursively render a VNode, flattening Fragment nodes and skipping comments.
5
+ * Returns an array of rendered VNodes (can be used in render function).
6
+ */
7
+ export declare function renderVNode(nodes: VNode[]): VNode[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-plus-vue",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Motion Plus Vue",
5
5
  "author": "",
6
6
  "license": "ISC",