motion-plus-vue 0.1.0 → 1.0.0

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"),u=require("motion-v");function K(n,{locales:t,format:i},a,c){const h=new Intl.NumberFormat(t,i).formatToParts(Number(n));a&&h.unshift({type:"prefix",value:a}),c&&h.push({type:"suffix",value:c});const p=[],m=[],x=[],f=[],v={},o=s=>`${s}:${v[s]=(v[s]??-1)+1}`;let d="",w=!1,B=!1,y=0;for(const s of h){d+=s.value;const g=s.type==="minusSign"||s.type==="plusSign"?"sign":s.type;switch(g){case"integer":w=!0,m.push(...s.value.split("").map(C=>({type:g,value:parseInt(C)})));break;case"group":m.push({type:g,value:s.value});break;case"decimal":B=!0,x.push({type:g,value:s.value,key:o(g),originalIndex:y++});break;case"fraction":x.push(...s.value.split("").map(C=>({type:g,value:parseInt(C),key:o(g),originalIndex:y++})));break;default:(w||B?f:p).push({type:g,value:s.value,key:o(g),originalIndex:y++})}}const l=[];for(let s=m.length-1;s>=0;s--){const g=o(m[s].type);l.unshift({...m[s],key:g,originalIndex:s})}return{pre:p,integer:l,fraction:x,post:f,formatted:d}}const[G,U]=u.createContext("SectionContext");function O(){const n={current:!0};return e.onMounted(()=>{n.current=!1}),n}function z(n){const{width:t,fontSize:i}=getComputedStyle(n);return`${parseFloat(t)/parseFloat(i)}em`}const k="var(--mask-height, 0.15em)",_="var(--mask-width, 0.5em)",P=`calc(${_} / var(--invert-x, 1))`,b="#000 0, transparent 71%",q=`linear-gradient(to right, transparent 0, #000 ${P}, #000 calc(100% - ${P}), transparent),linear-gradient(to bottom, transparent 0, #000 ${k}, #000 calc(100% - ${k}), transparent 100%),radial-gradient(at bottom right, ${b}),radial-gradient(at bottom left, ${b}), radial-gradient(at top left, ${b}), radial-gradient(at top right, ${b})`,Z=`100% calc(100% - ${k} * 2),calc(100% - ${P} * 2) 100%,${P} ${k},${P} ${k},${P} ${k},${P} ${k}`;u.addScaleCorrector({"--invert-x":{correct:(n,{treeScale:t,projectionDelta:i})=>i.x.scale*t.x}});const M={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function W(n){const t=e.ref();function i(c){t.value=c==null?void 0:c.$el}e.watch(()=>n.isPresent,c=>{var r;t.value&&((r=u.mountedStates.get(t.value))==null||r.setActive("exit",!c))});function a(c){var r;c.detail.isExit&&!n.isPresent&&((r=n.onRemove)==null||r.call(n,n.partKey))}return{root:t,getRoot:i,handleComplete:a}}const J=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{}},setup(n){const t=n,{justify:i}=G(),{getRoot:a,handleComplete:c}=W(t);return(r,h)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(a),layout:"position","data-state":r.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(i),padding:`calc(${e.unref(k)}/2) 0`,position:"relative",pointerEvents:r.isPresent?void 0:"none"}),"aria-hidden":!r.isPresent,onMotioncomplete:e.unref(c)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:"popLayout","anchor-x":e.unref(i),initial:!1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:r.value,layout:e.unref(i)==="right"?"position":!1,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0],transition:{duration:.3}},style:{display:"inline-block",whiteSpace:"pre"},transition:{duration:.2}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value),1)]),_:1},8,["layout"]))]),_:1},8,["anchor-x"])]),_:1},8,["data-state","style","aria-hidden","onMotioncomplete"]))}}),X=new WeakMap,Q=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{}},setup(n){const t=n,i=t.initialValue??t.value,a=O(),c=u.useMotionConfig(),r=e.ref(),h=e.ref(Array(10).fill(null)),p=e.ref(),{getRoot:m,handleComplete:x,root:f}=W(t);let v=i;const o=e.ref(i);e.watch([()=>t.value,()=>t.isPresent],([y,l])=>{if(!l)return o.value=0;if(a.current)return e.nextTick(()=>{o.value=y});o.value=y},{immediate:!0});function d(y){var C;if(!r.value||y===v)return;const l=r.value.getBoundingClientRect(),s=(C=f.value)==null?void 0:C.getBoundingClientRect(),g=l.height*(y-v)+(l.top-(s?s.top||0:l.top));u.animate(r.value,{y:[g,0]},c.value.transition)}function w(y){if(a.current&&i===y||!h.value[y])return;const l=z(h.value[y]);f.value&&X.set(f.value,l),p.value=l}e.watch(o,y=>{w(y)},{immediate:!0,flush:"post"}),e.watch(o,(y,l,s)=>{d(y),s(()=>{v=y})},{immediate:!0,flush:"pre"});function B(y){return()=>e.createVNode("span",{key:y,style:{display:"inline-block",padding:`calc(${k}/2) 0`}},[y])}return(y,l)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(m),layout:"position","data-state":y.isPresent?void 0:"exiting","data-key":y.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:p.value,pointerEvents:y.isPresent?void 0:"none"}),"aria-hidden":!y.isPresent,onMotioncomplete:e.unref(x)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:r,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[o.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(M),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,s=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(s-1)),{key:s-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(o.value)))),o.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(M),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-o.value,s=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(o.value+s)),{key:o.value+s}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),$=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{}},setup(n){const t=n,i=e.ref(),a=e.ref();function c(f){a.value=f==null?void 0:f.$el}const r=e.ref(),h=O();e.watch(()=>t.parts.map(f=>f.value).join(""),()=>{if(!r.value)return;if(h.current){a.value&&(a.value.style.width=z(r.value));return}const f=Array.from(r.value.children).map(o=>{if(!(o instanceof HTMLElement))return;if(o.dataset.state==="exiting"){const B=o.nextSibling;return o.remove(),()=>{r.value&&r.value.insertBefore(o,B)}}const d=X.get(o);if(!d)return;const w=o.style.width;return o.style.width=d,()=>{o.style.width=w}}),v=z(r.value);i.value=v;for(let o=f.length-1;o>=0;o--){const d=f[o];d&&d()}},{immediate:!0,flush:"post"});const p=e.toRef(t,"justify");U({justify:p});let m=t.parts;e.watch(()=>t.parts,f=>{const v=new Map(f.map(d=>[d.key,{...d,isPresent:!0}]));m=[...m.filter(d=>!v.get(d.key)).map(d=>({...d,isPresent:!1})),...f].sort((d,w)=>p.value==="right"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?-1:1:p.value==="left"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?1:-1:d.originalIndex-w.originalIndex)});function x(f){m=m.filter(v=>v.key!==f)}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:c,class:e.normalizeClass(`number-section-${f.name}`),style:e.normalizeStyle({...f.style,display:"inline-flex",justifyContent:p.value,width:i.value}),layout:"position"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:r,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[v[0]||(v[0]=e.createTextVNode(" ​ ")),e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:f.mode,"anchor-x":p.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[o.type==="integer"||o.type==="fraction"?(e.openBlock(),e.createBlock(Q,{key:o.key,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,"initial-value":e.unref(h).current?void 0:0,onRemove:x},null,8,["part-key","value","is-present","initial-value"])):(e.openBlock(),e.createBlock(J,{key:o.type==="literal"?`${o.key}:${o.value}`:o.key,type:o.type,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,onRemove:x},null,8,["type","part-key","value","is-present"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style"]))}}),ee=e.defineComponent({__name:"Mask",setup(n){return(t,i)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{layout:"","aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(_)})`,padding:`calc(${e.unref(k)}/2) ${e.unref(_)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(q),webkitMaskSize:e.unref(Z),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["style"]))}}),te=e.defineComponent({name:"AnimateNumber",__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{}},setup(n){const t={opacity:{duration:1,ease:u.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},i=n,a=e.computed(()=>{const p=i.value;return K(p,{locales:i.locales,format:i.format},i.prefix,i.suffix)}),c=u.useMotionConfig(),r=e.computed(()=>i.transition??c.value.transition??t);function h(){const{format:p,prefix:m,suffix:x,locales:f,value:v,...o}=i;return o}return(p,m)=>(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:r.value},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({...p.$attrs,...h()},{layout:"",style:{lineHeight:"1",...p.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,{layout:"","aria-label":a.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:a.value.pre,name:"pre"},null,8,["style","parts"]),e.createVNode(ee,null,{default:e.withCtx(()=>[e.createVNode($,{justify:"right",parts:a.value.integer,name:"integer",mode:"popLayout"},null,8,["parts"]),e.createVNode($,{layout:"position",parts:a.value.fraction,name:"fraction",mode:"popLayout"},null,8,["parts"])]),_:1}),e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:a.value.post,name:"post"},null,8,["style","parts"])]),_:1},8,["aria-label"])]),_:1},16,["style"])]),_:1},8,["transition"])]),_:1}))}}),ne=te;function oe(){const n=document.createElement("style");return n.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("motion-v");function G(n,{locales:t,format:i},s,l){const g=new Intl.NumberFormat(t,i).formatToParts(Number(n));s&&g.unshift({type:"prefix",value:s}),l&&g.push({type:"suffix",value:l});const d=[],y=[],m=[],v=[],c={},a=o=>`${o}:${c[o]=(c[o]??-1)+1}`;let f="",w=!1,B=!1,p=0;for(const o of g){f+=o.value;const h=o.type==="minusSign"||o.type==="plusSign"?"sign":o.type;switch(h){case"integer":w=!0,y.push(...o.value.split("").map(x=>({type:h,value:parseInt(x)})));break;case"group":y.push({type:h,value:o.value});break;case"decimal":B=!0,m.push({type:h,value:o.value,key:a(h),originalIndex:p++});break;case"fraction":m.push(...o.value.split("").map(x=>({type:h,value:parseInt(x),key:a(h),originalIndex:p++})));break;default:(w||B?v:d).push({type:h,value:o.value,key:a(h),originalIndex:p++})}}const k=[];for(let o=y.length-1;o>=0;o--){const h=a(y[o].type);k.unshift({...y[o],key:h,originalIndex:o})}return{pre:d,integer:k,fraction:m,post:v,formatted:f}}const[U,q]=u.createContext("SectionContext");function O(){const n={current:!0};return e.onMounted(()=>{n.current=!1}),n}function _(n){const{width:t,fontSize:i}=getComputedStyle(n);return`${parseFloat(t)/parseFloat(i)}em`}const C="var(--mask-height, 0.15em)",V="var(--mask-width, 0.5em)",P=`calc(${V} / var(--invert-x, 1))`,b="#000 0, transparent 71%",Z=`linear-gradient(to right, transparent 0, #000 ${P}, #000 calc(100% - ${P}), transparent),linear-gradient(to bottom, transparent 0, #000 ${C}, #000 calc(100% - ${C}), transparent 100%),radial-gradient(at bottom right, ${b}),radial-gradient(at bottom left, ${b}), radial-gradient(at top left, ${b}), radial-gradient(at top right, ${b})`,J=`100% calc(100% - ${C} * 2),calc(100% - ${P} * 2) 100%,${P} ${C},${P} ${C},${P} ${C},${P} ${C}`;u.addScaleCorrector({"--invert-x":{correct:(n,{treeScale:t,projectionDelta:i})=>i.x.scale*t.x}});const R={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function X(n){const t=e.ref();function i(l){t.value=l==null?void 0:l.$el}e.watch(()=>n.isPresent,l=>{var r;t.value&&((r=u.mountedStates.get(t.value))==null||r.setActive("exit",!l))});function s(l){var r;l.detail.isExit&&!n.isPresent&&((r=n.onRemove)==null||r.call(n,n.partKey))}return{root:t,getRoot:i,handleComplete:s}}const Q=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{}},setup(n){const t=n,{justify:i}=U(),{getRoot:s,handleComplete:l}=X(t);return(r,g)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(s),layout:"position","data-state":r.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(i),padding:`calc(${e.unref(C)}/2) 0`,position:"relative",pointerEvents:r.isPresent?void 0:"none"}),"aria-hidden":!r.isPresent,onMotioncomplete:e.unref(l)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{mode:"popLayout","anchor-x":e.unref(i),initial:!1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:r.value,layout:e.unref(i)==="right"?"position":!1,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0],transition:{duration:.3}},style:{display:"inline-block",whiteSpace:"pre"},transition:{duration:.2}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value),1)]),_:1},8,["layout"]))]),_:1},8,["anchor-x"])]),_:1},8,["data-state","style","aria-hidden","onMotioncomplete"]))}}),Y=new WeakMap,ee=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{}},setup(n){const t=n,i=t.initialValue??t.value,s=O(),l=u.useMotionConfig(),r=e.ref(),g=e.ref(Array(10).fill(null)),d=e.ref(),{getRoot:y,handleComplete:m,root:v}=X(t);let c=i;const a=e.ref(i);e.watch([()=>t.value,()=>t.isPresent],([p,k])=>{if(!k)return a.value=0;if(s.current)return e.nextTick(()=>{a.value=p});a.value=p},{immediate:!0});function f(p){var x;if(!r.value||p===c)return;const k=r.value.getBoundingClientRect(),o=(x=v.value)==null?void 0:x.getBoundingClientRect(),h=k.height*(p-c)+(k.top-(o?o.top||0:k.top));u.animate(r.value,{y:[h,0]},l.value.transition)}function w(p){if(s.current&&i===p||!g.value[p])return;const k=_(g.value[p]);v.value&&Y.set(v.value,k),d.value=k}e.watch(a,p=>{w(p)},{immediate:!0,flush:"post"}),e.watch(a,(p,k,o)=>{f(p),o(()=>{c=p})},{immediate:!0,flush:"pre"});function B(p){return()=>e.createVNode("span",{key:p,style:{display:"inline-block",padding:`calc(${C}/2) 0`}},[p])}return(p,k)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(y),layout:"position","data-state":p.isPresent?void 0:"exiting","data-key":p.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:d.value,pointerEvents:p.isPresent?void 0:"none"}),"aria-hidden":!p.isPresent,onMotioncomplete:e.unref(m)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:r,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[a.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(R),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,o=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(o-1)),{key:o-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(a.value)))),a.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(R),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-a.value,o=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(a.value+o)),{key:a.value+o}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),$=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{}},setup(n){const t=n,i=e.ref(),s=u.useDomRef(),l=e.ref(),r=O();e.watch(()=>t.parts,m=>{const v=new Map(m.map(a=>[a.key,{...a,isPresent:!0}]));d=[...d.filter(a=>!v.get(a.key)).map(a=>({...a,isPresent:!1})),...m].sort((a,f)=>g.value==="right"?a.isPresent===f.isPresent?a.originalIndex-f.originalIndex:a.isPresent?-1:1:g.value==="left"?a.isPresent===f.isPresent?a.originalIndex-f.originalIndex:a.isPresent?1:-1:a.originalIndex-f.originalIndex)},{flush:"pre"}),e.watch(()=>t.parts.map(m=>m.value).join(""),(m,v)=>{if(!l.value)return;if(r.current){s.value&&(s.value.style.width=_(l.value));return}const c=Array.from(l.value.children).map(f=>{if(!(f instanceof HTMLElement))return;if(f.dataset.state==="exiting"){const p=f.nextSibling;return f.remove(),()=>{l.value&&l.value.insertBefore(f,p)}}const w=Y.get(f);if(!w)return;const B=f.style.width;return f.style.width=w,()=>{f.style.width=B}});function a(){const f=_(l.value);i.value=f}+m>+(v||0)?u.frame.read(a):a();for(let f=c.length-1;f>=0;f--){const w=c[f];w&&w()}},{immediate:!0,flush:"post"});const g=e.toRef(t,"justify");q({justify:g});let d=t.parts;function y(m){d=d.filter(v=>v.key!==m)}return(m,v)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(s),class:e.normalizeClass(`number-section-${m.name}`),style:e.normalizeStyle({...m.style,display:"inline-flex",justifyContent:g.value,width:i.value}),layout:"position"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:l,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[v[0]||(v[0]=e.createTextVNode(" ​ ")),e.createVNode(e.unref(u.AnimatePresence),{mode:m.mode,"anchor-x":g.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(d),c=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:c.key},[c.type==="integer"||c.type==="fraction"?(e.openBlock(),e.createBlock(ee,{key:c.key,"part-key":c.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:c.value,"is-present":c.isPresent??!0,"initial-value":e.unref(r).current?void 0:0,onRemove:y},null,8,["part-key","value","is-present","initial-value"])):(e.openBlock(),e.createBlock(Q,{key:c.type==="literal"?`${c.key}:${c.value}`:c.key,type:c.type,"part-key":c.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:c.value,"is-present":c.isPresent??!0,onRemove:y},null,8,["type","part-key","value","is-present"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style"]))}}),te=e.defineComponent({__name:"Mask",setup(n){return(t,i)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{layout:"","aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(V)})`,padding:`calc(${e.unref(C)}/2) ${e.unref(V)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(Z),webkitMaskSize:e.unref(J),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["style"]))}}),ne=e.defineComponent({name:"AnimateNumber",inheritAttrs:!1,__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{}},setup(n){const t={opacity:{duration:1,ease:u.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},i=n,s=e.computed(()=>{const d=i.value;return G(d,{locales:i.locales,format:i.format},i.prefix,i.suffix)}),l=u.useMotionConfig(),r=e.computed(()=>i.transition??l.value.transition??t);function g(){const{format:d,prefix:y,suffix:m,locales:v,value:c,...a}=i;return a}return(d,y)=>(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:r.value},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({...d.$attrs,...g()},{layout:"",style:{lineHeight:"1",...d.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,{layout:"","aria-label":s.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(C)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:s.value.pre,name:"pre"},null,8,["style","parts"]),e.createVNode(te,null,{default:e.withCtx(()=>[e.createVNode($,{justify:"right",parts:s.value.integer,name:"integer",mode:"popLayout"},null,8,["parts"]),e.createVNode($,{layout:"position",parts:s.value.fraction,name:"fraction",mode:"popLayout"},null,8,["parts"])]),_:1}),e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(C)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:s.value.post,name:"post"},null,8,["style","parts"])]),_:1},8,["aria-label"])]),_:1},16,["style"])]),_:1},8,["transition"])]),_:1}))}}),oe=ne;function ie(){const n=document.createElement("style");return n.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(n),()=>{document.head.removeChild(n)}}function ie(n){e.watch(n,t=>t?oe():u.noop)}function L(n){return t=>{t.pointerType==="mouse"&&n(t)}}function R(n){return L(t=>{t.button===0&&n(t)})}let T,V;function re(){T=u.motionValue(0),V=u.motionValue(0);let n=0,t=0;function i(){T.set(n),V.set(t)}typeof window<"u"&&window.addEventListener("pointermove",L(a=>{n=a.clientX,t=a.clientY,u.frame.update(i)}))}function ae(){return T||re(),{x:T,y:V}}function se(n,t){return{x:u.useTransform(()=>n.x.get()+t.value.x),y:u.useTransform(()=>n.y.get()+t.value.y)}}function ue(n){return n.closest("[data-cursor]")}function le(n){return n.closest('a, button, input[type="button"]:not(:disabled)')}function ce(n){return window.getComputedStyle(n).userSelect==="none"?null:n.closest("p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6")}function fe(n){let t=ue(n);return t?[t.dataset.cursor,t]:(t=le(n),t?["pointer",t]:(t=ce(n),t?["text",t]:["default",null]))}let E=null,S={type:"default",isPressed:!1,fontSize:null,targetBoundingBox:null};function de(){if(typeof window>"u")return{onChange:()=>()=>{}};const n=new Set;function t(p){S={...S,...p},n.forEach(m=>m(S))}const i=R(()=>{S.isPressed||t({isPressed:!0})}),a=R(()=>{S.isPressed&&t({isPressed:!1})}),c=L(({target:p})=>{if(!p)return;const[m,x]=fe(p);let f=!1;const v={};m!==S.type&&(v.type=m,f=!0);const o=m==="pointer"&&x?x.getBoundingClientRect():null;if(o!==S.targetBoundingBox&&(v.targetBoundingBox=o,f=!0),m==="text"){const{fontSize:d}=window.getComputedStyle(p),w=d?parseInt(d):null;w!==S.fontSize&&(v.fontSize=w,f=!0)}else S.fontSize&&(v.fontSize=null,f=!0);f&&t(v)});function r(){typeof window>"u"||(window.addEventListener("pointerover",c),window.addEventListener("pointerdown",i),window.addEventListener("pointerup",a))}function h(){window.removeEventListener("pointerover",c),window.removeEventListener("pointerdown",i),window.removeEventListener("pointerup",a)}return{onChange:p=>(n.size||r(),n.add(p),()=>{n.delete(p),n.size||h()})}}function pe(){return E||(E=de()),E}function me(){const n=e.ref({...S});return e.watch(n,()=>pe().onChange(t=>{n.value=t}),{immediate:!0,flush:"post"}),n}let I=null;function ye(){const n=new Set;function t(){n.forEach(r=>r.show())}function i(){n.forEach(r=>r.hide())}function a(){document.body.addEventListener("mouseenter",t),document.body.addEventListener("mouseleave",i)}function c(){document.body.removeEventListener("mouseenter",t),document.body.removeEventListener("mouseleave",i)}return{on:r=>typeof window>"u"?u.noop:(n.size||a(),n.add(r),()=>{n.delete(r),n.size===0&&c()})}}function ve(){return I||(I=ye()),I}function ge(n){const t=e.ref(!0);return e.watch(t,()=>ve().on({show:()=>{t.value||(n(),t.value=!0)},hide:()=>t.value=!1}),{immediate:!0}),t}function j(n,t,i){return u.useTransform(()=>u.mix(n.get(),t.get(),i.get()))}function he(n,t,i){const a=u.useMotionValue(0),c=u.useMotionValue(0),r=u.useMotionValue(0),h=j(n.x,c,a),p=j(n.y,r,a);return e.watch([t,()=>i.value.targetBoundingBox],()=>{if(!t.value)return;i.value.targetBoundingBox&&(c.set(i.value.targetBoundingBox.left+i.value.targetBoundingBox.width/2),r.set(i.value.targetBoundingBox.top+i.value.targetBoundingBox.height/2));const m=u.animate(a,i.value.targetBoundingBox?.9:0);return()=>m.stop()},{immediate:!0}),{x:h,y:p}}const we={width:"auto",height:"auto"},A={x:0,y:0},xe={x:.5,y:.5},ke={stiffness:1e3,damping:100},Be={duration:.15,ease:[.38,.12,.29,1]},F=16,D=30,H=4,Ce=20;function Se(n,t,{matchPointerSize:i,matchTextSize:a}){switch(n){case"pointer":return i&&t.targetBoundingBox?t.targetBoundingBox:{width:D,height:D};case"text":return a&&t.fontSize?{width:H,height:t.fontSize}:{width:H,height:Ce};default:return{width:F,height:F}}}function Pe({x:n,y:t},i){const a=e.ref(n.prev!==void 0||t.prev!==void 0);return e.watch(a,()=>{if(a.value)return;const c=()=>{a.value=!0,i(),r()},r=u.pipe(n.on("change",c),t.on("change",c));return()=>r()},{immediate:!0}),a}const be=e.defineComponent({__name:"Cursor",props:{follow:{type:Boolean,default:!1},center:{default:({follow:n})=>n?A:xe},offset:{default:()=>A},spring:{type:[Boolean,Object],default:({follow:n})=>n?ke:!1},snapToTarget:{type:Boolean,default:!1},matchTextSize:{type:Boolean,default:!0},transition:{},variants:{},style:{},class:{},show:{type:Boolean,default:!0}},setup(n){const t=n,i=e.toRef(t,"offset");ie(()=>t.follow);const a=ae(),c=se(a,i),r=u.useSpring(c.x,t.spring||void 0),h=u.useSpring(c.y,t.spring||void 0);function p(){const l=c.x.on("change",g=>{r.jump(g),l()}),s=c.y.on("change",g=>{h.jump(g),s()})}const m=me(),x=ge(p),{x:f,y:v}=he(t.spring?{x:r,y:h}:a,e.toRef(t,"snapToTarget"),m),o=e.useSlots(),d=e.computed(()=>{var g,C;const l=(C=(g=o.default)==null?void 0:g.call(o))==null?void 0:C.filter(N=>N.type!==Symbol.for("v-cmt"));if(l!=null&&l.length)return we;const s=Se(m.value.type,m.value,{matchPointerSize:t.snapToTarget,matchTextSize:t.matchTextSize});return{width:`${s.width}px`,height:`${s.height}px`}}),w=Pe(a,p);function B(l){return(s,g)=>`translate(-${l.x*100}%, -${l.y*100}%) ${g}`}function y(){const{follow:l,center:s,offset:g,spring:C,snapToTarget:N,matchTextSize:Te,...Y}=t;return{...Y}}return(l,s)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(w)?(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),{key:0},{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:t.transition||e.unref(Be)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({layout:"","data-motion-cursor":l.follow?"follow":"pointer","data-framer-portal-id":"motion-cursor",initial:"exit",exit:"exit"},{...l.$attrs,...y()},{variants:{default:{opacity:1,scale:1},exit:{opacity:0,scale:0},pressed:l.follow?{opacity:1,scale:1}:{opacity:1,scale:.9},...l.variants},animate:["default",e.unref(m).type,!e.unref(x)||!l.show?"exit":e.unref(m).isPressed?"pressed":""],"transform-template":B(l.center),"data-w":d.value.width,style:{width:d.value.width,height:d.value.height,borderRadius:l.follow?0:20,zIndex:l.follow?99998:99999,willChange:"transform",contain:"layout",overflow:"hidden",originX:l.center.x,originY:l.center.y,...t.style,x:e.unref(f),y:e.unref(v),top:0,left:0,position:"fixed",pointerEvents:"none"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{multiple:""},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3})]),_:3},16,["data-motion-cursor","variants","animate","transform-template","data-w","style"])]),_:3},8,["transition"])]),_:3})):e.createCommentVNode("",!0)]))}}),$e=be;exports.AnimateNumber=ne;exports.Cursor=$e;
9
+ `,document.head.appendChild(n),()=>{document.head.removeChild(n)}}function re(n){e.watch(n,t=>t?ie():u.noop)}function N(n){return t=>{t.pointerType==="mouse"&&n(t)}}function j(n){return N(t=>{t.button===0&&n(t)})}let T,L;function ae(){T=u.motionValue(0),L=u.motionValue(0);let n=0,t=0;function i(){T.set(n),L.set(t)}typeof window<"u"&&window.addEventListener("pointermove",N(s=>{n=s.clientX,t=s.clientY,u.frame.update(i)}))}function se(){return T||ae(),{x:T,y:L}}function ue(n,t){return{x:u.useTransform(()=>n.x.get()+t.value.x),y:u.useTransform(()=>n.y.get()+t.value.y)}}function le(n){return n.closest("[data-cursor]")}function ce(n){return n.closest('a, button, input[type="button"]:not(:disabled)')}function fe(n){return window.getComputedStyle(n).userSelect==="none"?null:n.closest("p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6")}function de(n){let t=le(n);return t?[t.dataset.cursor,t]:(t=ce(n),t?["pointer",t]:(t=fe(n),t?["text",t]:["default",null]))}let I=null,S={type:"default",isPressed:!1,fontSize:null,targetBoundingBox:null};function pe(){if(typeof window>"u")return{onChange:()=>()=>{}};const n=new Set;function t(d){S={...S,...d},n.forEach(y=>y(S))}const i=j(()=>{S.isPressed||t({isPressed:!0})}),s=j(()=>{S.isPressed&&t({isPressed:!1})}),l=N(({target:d})=>{if(!d)return;const[y,m]=de(d);let v=!1;const c={};y!==S.type&&(c.type=y,v=!0);const a=y==="pointer"&&m?m.getBoundingClientRect():null;if(a!==S.targetBoundingBox&&(c.targetBoundingBox=a,v=!0),y==="text"){const{fontSize:f}=window.getComputedStyle(d),w=f?parseInt(f):null;w!==S.fontSize&&(c.fontSize=w,v=!0)}else S.fontSize&&(c.fontSize=null,v=!0);v&&t(c)});function r(){typeof window>"u"||(window.addEventListener("pointerover",l),window.addEventListener("pointerdown",i),window.addEventListener("pointerup",s))}function g(){window.removeEventListener("pointerover",l),window.removeEventListener("pointerdown",i),window.removeEventListener("pointerup",s)}return{onChange:d=>(n.size||r(),n.add(d),()=>{n.delete(d),n.size||g()})}}function me(){return I||(I=pe()),I}function ye(){const n=e.ref({...S});return e.watch(n,()=>me().onChange(t=>{n.value=t}),{immediate:!0,flush:"post"}),n}let z=null;function ve(){const n=new Set;function t(){n.forEach(r=>r.show())}function i(){n.forEach(r=>r.hide())}function s(){document.body.addEventListener("mouseenter",t),document.body.addEventListener("mouseleave",i)}function l(){document.body.removeEventListener("mouseenter",t),document.body.removeEventListener("mouseleave",i)}return{on:r=>typeof window>"u"?u.noop:(n.size||s(),n.add(r),()=>{n.delete(r),n.size===0&&l()})}}function ge(){return z||(z=ve()),z}function he(n){const t=e.ref(!0);return e.watch(t,()=>ge().on({show:()=>{t.value||(n(),t.value=!0)},hide:()=>t.value=!1}),{immediate:!0}),t}function A(n,t,i){return u.useTransform(()=>u.mix(n.get(),t.get(),i.get()))}function we(n,t,i){const s=u.useMotionValue(0),l=u.useMotionValue(0),r=u.useMotionValue(0),g=A(n.x,l,s),d=A(n.y,r,s);return e.watch([t,()=>i.value.targetBoundingBox],()=>{if(!t.value)return;i.value.targetBoundingBox&&(l.set(i.value.targetBoundingBox.left+i.value.targetBoundingBox.width/2),r.set(i.value.targetBoundingBox.top+i.value.targetBoundingBox.height/2));const y=u.animate(s,i.value.targetBoundingBox?.9:0);return()=>y.stop()},{immediate:!0}),{x:g,y:d}}const xe={width:"auto",height:"auto"},D={x:0,y:0},ke={x:.5,y:.5},Ce={duration:0},Be={stiffness:1e3,damping:100},Se={duration:.15,ease:[.38,.12,.29,1]},F=16,H=30,W=4,Pe=20;function be(n,t,{matchPointerSize:i,matchTextSize:s}){switch(n){case"pointer":return i&&t.targetBoundingBox?t.targetBoundingBox:{width:H,height:H};case"text":return s&&t.fontSize?{width:W,height:t.fontSize}:{width:W,height:Pe};default:return{width:F,height:F}}}function $e({x:n,y:t},i){const s=e.ref(n.prev!==void 0||t.prev!==void 0);return e.watch(s,()=>{if(s.value)return;const l=()=>{s.value=!0,i(),r()},r=u.pipe(n.on("change",l),t.on("change",l));return()=>r()},{immediate:!0}),s}const Te=e.defineComponent({name:"Cursor",inheritAttrs:!1,__name:"Cursor",props:{follow:{type:Boolean,default:!1},center:{default:({follow:n})=>n?D:ke},offset:{default:()=>D},spring:{type:[Boolean,Object],default:({follow:n})=>n?Be:!1},snapToTarget:{type:Boolean,default:!1},matchTextSize:{type:Boolean,default:!0},transition:{},variants:{},style:{},class:{},show:{type:Boolean,default:!0}},setup(n){const t=n,i=e.toRef(t,"offset"),s=u.useReducedMotion();re(()=>!s.value&&!t.follow);const l=se(),r=ue(l,i),g=u.useSpring(r.x,t.spring||void 0),d=u.useSpring(r.y,t.spring||void 0);function y(){const o=r.x.on("change",x=>{g.jump(x),o()}),h=r.y.on("change",x=>{d.jump(x),h()})}const m=ye(),v=he(y),{x:c,y:a}=we(t.spring?{x:g,y:d}:l,e.toRef(t,"snapToTarget"),m),f=e.useSlots(),w=e.computed(()=>{var x,E;const o=(E=(x=f.default)==null?void 0:x.call(f))==null?void 0:E.filter(M=>M.type!==Symbol.for("v-cmt"));if(o!=null&&o.length)return xe;const h=be(m.value.type,m.value,{matchPointerSize:t.snapToTarget,matchTextSize:t.matchTextSize});return{width:`${h.width}px`,height:`${h.height}px`}}),B=$e(l,y);function p(o){return(h,x)=>`translate(-${o.x*100}%, -${o.y*100}%) ${x}`}function k(){const{follow:o,center:h,offset:x,spring:E,snapToTarget:M,matchTextSize:Ie,...K}=t;return{...K}}return(o,h)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(B)?(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),{key:0},{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:e.unref(s)?e.unref(Ce):o.transition||e.unref(Se)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({layout:"","data-motion-cursor":o.follow?"follow":"pointer","data-framer-portal-id":"motion-cursor",initial:"exit",exit:"exit"},{...o.$attrs,...k()},{variants:{default:{opacity:1,scale:1},exit:{opacity:0,scale:0},pressed:o.follow?{opacity:1,scale:1}:{opacity:1,scale:.9},...o.variants},animate:["default",e.unref(m).type,!e.unref(v)||!o.show?"exit":e.unref(m).isPressed?"pressed":""],"transform-template":p(o.center),"data-w":w.value.width,style:{width:w.value.width,height:w.value.height,borderRadius:o.follow?0:20,zIndex:o.follow?99998:99999,willChange:"transform",contain:"layout",overflow:"hidden",originX:o.center.x,originY:o.center.y,...t.style,x:e.unref(c),y:e.unref(a),top:0,left:0,position:"fixed",pointerEvents:"none"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),null,{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3})]),_:3},16,["data-motion-cursor","variants","animate","transform-template","data-w","style"])]),_:3},8,["transition"])]),_:3})):e.createCommentVNode("",!0)]))}}),Ee=Te;exports.AnimateNumber=oe;exports.Cursor=Ee;
@@ -1,5 +1,5 @@
1
1
  import { AnimatePresence, LayoutGroup, MotionConfig, MotionProps, Point, SpringOptions, motion } from 'motion-v';
2
- import { defaultTransition } from './config';
2
+ import { defaultTransition, skipTransition } from './config';
3
3
  export interface CursorProps {
4
4
  follow?: boolean;
5
5
  center?: Point;
@@ -13,6 +13,7 @@ export interface CursorProps {
13
13
  class?: string;
14
14
  show?: boolean;
15
15
  }
16
+ declare const shouldReduceMotion: import('vue').Ref<boolean, boolean>;
16
17
  declare const state: import('vue').Ref<import('./hooks/use-cursor-state/types').CursorState, import('./hooks/use-cursor-state/types').CursorState>;
17
18
  declare const isInView: import('vue').Ref<boolean, boolean>;
18
19
  declare const x: import('motion-v/es').MotionValue<number>, y: import('motion-v/es').MotionValue<number>;
@@ -40,6 +41,8 @@ declare const __VLS_self: import('vue').DefineComponent<CursorProps, {
40
41
  MotionConfig: typeof MotionConfig;
41
42
  motion: typeof motion;
42
43
  defaultTransition: typeof defaultTransition;
44
+ skipTransition: typeof skipTransition;
45
+ shouldReduceMotion: typeof shouldReduceMotion;
43
46
  state: typeof state;
44
47
  isInView: typeof isInView;
45
48
  x: typeof x;
@@ -1,11 +1,12 @@
1
- import { defineComponent as v, computed as l, createBlock as x, openBlock as h, unref as o, withCtx as n, createVNode as t, mergeProps as b, normalizeStyle as s } from "vue";
1
+ import { defineComponent as v, computed as l, createBlock as h, openBlock as x, unref as o, withCtx as r, createVNode as t, mergeProps as b, normalizeStyle as s } from "vue";
2
2
  import { formatToParts as L } from "./utils/format-parts.mjs";
3
- import { useMotionConfig as C, easeOut as N, LayoutGroup as $, MotionConfig as A, motion as u } from "motion-v";
4
- import r from "./NumberSection.vue.mjs";
3
+ import { useMotionConfig as A, easeOut as C, LayoutGroup as N, MotionConfig as $, motion as u } from "motion-v";
4
+ import n from "./NumberSection.vue.mjs";
5
5
  import { maskHeight as p } from "./config.mjs";
6
6
  import T from "./Mask.vue.mjs";
7
7
  const O = /* @__PURE__ */ v({
8
8
  name: "AnimateNumber",
9
+ inheritAttrs: !1,
9
10
  __name: "AnimateNumber",
10
11
  props: {
11
12
  locales: {},
@@ -16,23 +17,23 @@ const O = /* @__PURE__ */ v({
16
17
  value: {},
17
18
  style: {}
18
19
  },
19
- setup(m) {
20
- const f = {
21
- opacity: { duration: 1, ease: N },
20
+ setup(f) {
21
+ const m = {
22
+ opacity: { duration: 1, ease: C },
22
23
  layout: { type: "spring", duration: 1, bounce: 0 },
23
24
  y: { type: "spring", duration: 1, bounce: 0 }
24
- }, e = m, a = l(() => {
25
+ }, e = f, a = l(() => {
25
26
  const i = e.value;
26
27
  return L(i, { locales: e.locales, format: e.format }, e.prefix, e.suffix);
27
- }), c = C(), d = l(() => e.transition ?? c.value.transition ?? f);
28
+ }), c = A(), d = l(() => e.transition ?? c.value.transition ?? m);
28
29
  function y() {
29
30
  const { format: i, prefix: g, suffix: k, locales: w, value: I, ..._ } = e;
30
31
  return _;
31
32
  }
32
- return (i, g) => (h(), x(o($), null, {
33
- default: n(() => [
34
- t(o(A), { transition: d.value }, {
35
- default: n(() => [
33
+ return (i, g) => (x(), h(o(N), null, {
34
+ default: r(() => [
35
+ t(o($), { transition: d.value }, {
36
+ default: r(() => [
36
37
  t(o(u).div, b({
37
38
  ...i.$attrs,
38
39
  ...y()
@@ -46,7 +47,7 @@ const O = /* @__PURE__ */ v({
46
47
  whiteSpace: "nowrap"
47
48
  }
48
49
  }), {
49
- default: n(() => [
50
+ default: r(() => [
50
51
  t(o(u).div, {
51
52
  layout: "",
52
53
  "aria-label": a.value.formatted,
@@ -58,8 +59,8 @@ const O = /* @__PURE__ */ v({
58
59
  zIndex: -1
59
60
  }
60
61
  }, {
61
- default: n(() => [
62
- t(r, {
62
+ default: r(() => [
63
+ t(n, {
63
64
  style: s({ padding: `calc(${o(p)}/2) 0` }),
64
65
  "aria-hidden": !0,
65
66
  justify: "right",
@@ -68,14 +69,14 @@ const O = /* @__PURE__ */ v({
68
69
  name: "pre"
69
70
  }, null, 8, ["style", "parts"]),
70
71
  t(T, null, {
71
- default: n(() => [
72
- t(r, {
72
+ default: r(() => [
73
+ t(n, {
73
74
  justify: "right",
74
75
  parts: a.value.integer,
75
76
  name: "integer",
76
77
  mode: "popLayout"
77
78
  }, null, 8, ["parts"]),
78
- t(r, {
79
+ t(n, {
79
80
  layout: "position",
80
81
  parts: a.value.fraction,
81
82
  name: "fraction",
@@ -84,7 +85,7 @@ const O = /* @__PURE__ */ v({
84
85
  ]),
85
86
  _: 1
86
87
  }),
87
- t(r, {
88
+ t(n, {
88
89
  style: s({ padding: `calc(${o(p)}/2) 0` }),
89
90
  "aria-hidden": !0,
90
91
  layout: "position",
@@ -1,12 +1,12 @@
1
- import { defineComponent as _, ref as y, watch as k, toRef as j, createBlock as p, openBlock as l, unref as f, normalizeStyle as C, normalizeClass as $, withCtx as x, createElementVNode as B, createTextVNode as E, createVNode as N, createElementBlock as g, Fragment as P, renderList as S } from "vue";
2
- import { motion as W, AnimatePresence as M } from "motion-v";
3
- import { injectSectionContext as V } from "./context.mjs";
4
- import { useIsInitialRender as z } from "./hooks/use-is-initial-render.mjs";
5
- import { getWidthInEm as h } from "./utils/get-width-in-ems.mjs";
6
- import A from "./NumberSymbol.vue.mjs";
7
- import L from "./NumberDigit.vue.mjs";
8
- import { targetWidths as T } from "./utils/target-widths.mjs";
9
- const O = /* @__PURE__ */ _({
1
+ import { defineComponent as j, ref as k, watch as x, toRef as C, createBlock as p, openBlock as u, unref as f, normalizeStyle as W, normalizeClass as $, withCtx as g, createElementVNode as B, createTextVNode as E, createVNode as N, createElementBlock as h, Fragment as P, renderList as S } from "vue";
2
+ import { useDomRef as M, motion as V, AnimatePresence as z, frame as A } from "motion-v";
3
+ import { injectSectionContext as L } from "./context.mjs";
4
+ import { useIsInitialRender as T } from "./hooks/use-is-initial-render.mjs";
5
+ import { getWidthInEm as w } from "./utils/get-width-in-ems.mjs";
6
+ import D from "./NumberSymbol.vue.mjs";
7
+ import F from "./NumberDigit.vue.mjs";
8
+ import { targetWidths as H } from "./utils/target-widths.mjs";
9
+ const Y = /* @__PURE__ */ j({
10
10
  __name: "NumberSection",
11
11
  props: {
12
12
  parts: {},
@@ -15,107 +15,105 @@ const O = /* @__PURE__ */ _({
15
15
  name: {},
16
16
  style: {}
17
17
  },
18
- setup(w) {
19
- const u = w, c = y(), m = y();
20
- function R(n) {
21
- m.value = n == null ? void 0 : n.$el;
22
- }
23
- const r = y(), d = z();
24
- k(() => u.parts.map((n) => n.value).join(""), () => {
25
- if (!r.value)
18
+ setup(I) {
19
+ const m = I, d = k(), y = M(), s = k(), c = T();
20
+ x(() => m.parts, (i) => {
21
+ const r = new Map(i.map((n) => [n.key, { ...n, isPresent: !0 }]));
22
+ a = [...a.filter((n) => !r.get(n.key)).map(
23
+ (n) => ({ ...n, isPresent: !1 })
24
+ ), ...i].sort((n, e) => o.value === "right" ? n.isPresent === e.isPresent ? n.originalIndex - e.originalIndex : n.isPresent ? -1 : 1 : o.value === "left" ? n.isPresent === e.isPresent ? n.originalIndex - e.originalIndex : n.isPresent ? 1 : -1 : n.originalIndex - e.originalIndex);
25
+ }, { flush: "pre" }), x(() => m.parts.map((i) => i.value).join(""), (i, r) => {
26
+ if (!s.value)
26
27
  return;
27
- if (d.current) {
28
- m.value && (m.value.style.width = h(r.value));
28
+ if (c.current) {
29
+ y.value && (y.value.style.width = w(s.value));
29
30
  return;
30
31
  }
31
- const n = Array.from(r.value.children).map((e) => {
32
+ const t = Array.from(s.value.children).map((e) => {
32
33
  if (!(e instanceof HTMLElement))
33
34
  return;
34
35
  if (e.dataset.state === "exiting") {
35
- const I = e.nextSibling;
36
+ const _ = e.nextSibling;
36
37
  return e.remove(), () => {
37
- r.value && r.value.insertBefore(e, I);
38
+ s.value && s.value.insertBefore(e, _);
38
39
  };
39
40
  }
40
- const t = T.get(e);
41
- if (!t)
41
+ const l = H.get(e);
42
+ if (!l)
42
43
  return;
43
- const s = e.style.width;
44
- return e.style.width = t, () => {
45
- e.style.width = s;
44
+ const R = e.style.width;
45
+ return e.style.width = l, () => {
46
+ e.style.width = R;
46
47
  };
47
- }), i = h(r.value);
48
- c.value = i;
49
- for (let e = n.length - 1; e >= 0; e--) {
50
- const t = n[e];
51
- t && t();
48
+ });
49
+ function n() {
50
+ const e = w(s.value);
51
+ d.value = e;
52
+ }
53
+ +i > +(r || 0) ? A.read(n) : n();
54
+ for (let e = t.length - 1; e >= 0; e--) {
55
+ const l = t[e];
56
+ l && l();
52
57
  }
53
58
  }, { immediate: !0, flush: "post" });
54
- const o = j(u, "justify");
55
- V({
59
+ const o = C(m, "justify");
60
+ L({
56
61
  justify: o
57
62
  });
58
- let a = u.parts;
59
- k(() => u.parts, (n) => {
60
- const i = new Map(n.map((t) => [t.key, { ...t, isPresent: !0 }]));
61
- a = [...a.filter((t) => !i.get(t.key)).map(
62
- (t) => ({ ...t, isPresent: !1 })
63
- ), ...n].sort((t, s) => o.value === "right" ? t.isPresent === s.isPresent ? t.originalIndex - s.originalIndex : t.isPresent ? -1 : 1 : o.value === "left" ? t.isPresent === s.isPresent ? t.originalIndex - s.originalIndex : t.isPresent ? 1 : -1 : t.originalIndex - s.originalIndex);
64
- });
65
- function v(n) {
66
- a = a.filter((i) => i.key !== n);
63
+ let a = m.parts;
64
+ function v(i) {
65
+ a = a.filter((r) => r.key !== i);
67
66
  }
68
- return (n, i) => (l(), p(f(W).span, {
69
- ref: R,
70
- class: $(`number-section-${n.name}`),
71
- style: C({
72
- ...n.style,
67
+ return (i, r) => (u(), p(f(V).span, {
68
+ ref: f(y),
69
+ class: $(`number-section-${i.name}`),
70
+ style: W({
71
+ ...i.style,
73
72
  display: "inline-flex",
74
73
  justifyContent: o.value,
75
- width: c.value
74
+ width: d.value
76
75
  }),
77
76
  layout: "position"
78
77
  }, {
79
- default: x(() => [
78
+ default: g(() => [
80
79
  B("span", {
81
80
  ref_key: "measuredRef",
82
- ref: r,
81
+ ref: s,
83
82
  style: {
84
83
  display: "inline-flex",
85
84
  justifyContent: "inherit",
86
85
  position: "relative"
87
86
  }
88
87
  }, [
89
- i[0] || (i[0] = E(" ​ ")),
90
- N(f(M), {
91
- multiple: "",
92
- mode: n.mode,
88
+ r[0] || (r[0] = E(" ​ ")),
89
+ N(f(z), {
90
+ mode: i.mode,
93
91
  "anchor-x": o.value,
94
92
  initial: !1
95
93
  }, {
96
- default: x(() => [
97
- (l(!0), g(P, null, S(f(a), (e) => (l(), g(P, {
98
- key: e.key
94
+ default: g(() => [
95
+ (u(!0), h(P, null, S(f(a), (t) => (u(), h(P, {
96
+ key: t.key
99
97
  }, [
100
- e.type === "integer" || e.type === "fraction" ? (l(), p(L, {
101
- key: e.key,
102
- "part-key": e.key,
98
+ t.type === "integer" || t.type === "fraction" ? (u(), p(F, {
99
+ key: t.key,
100
+ "part-key": t.key,
103
101
  initial: { opacity: 0 },
104
102
  animate: { opacity: 1 },
105
103
  exit: { opacity: 0 },
106
- value: e.value,
107
- "is-present": e.isPresent ?? !0,
108
- "initial-value": f(d).current ? void 0 : 0,
104
+ value: t.value,
105
+ "is-present": t.isPresent ?? !0,
106
+ "initial-value": f(c).current ? void 0 : 0,
109
107
  onRemove: v
110
- }, null, 8, ["part-key", "value", "is-present", "initial-value"])) : (l(), p(A, {
111
- key: e.type === "literal" ? `${e.key}:${e.value}` : e.key,
112
- type: e.type,
113
- "part-key": e.key,
108
+ }, null, 8, ["part-key", "value", "is-present", "initial-value"])) : (u(), p(D, {
109
+ key: t.type === "literal" ? `${t.key}:${t.value}` : t.key,
110
+ type: t.type,
111
+ "part-key": t.key,
114
112
  initial: { opacity: 0 },
115
113
  animate: { opacity: 1 },
116
114
  exit: { opacity: 0 },
117
- value: e.value,
118
- "is-present": e.isPresent ?? !0,
115
+ value: t.value,
116
+ "is-present": t.isPresent ?? !0,
119
117
  onRemove: v
120
118
  }, null, 8, ["type", "part-key", "value", "is-present"]))
121
119
  ], 64))), 128))
@@ -129,5 +127,5 @@ const O = /* @__PURE__ */ _({
129
127
  }
130
128
  });
131
129
  export {
132
- O as default
130
+ Y as default
133
131
  };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as u, createBlock as n, openBlock as a, unref as e, normalizeStyle as d, withCtx as i, createVNode as y, createTextVNode as c, toDisplayString as f } from "vue";
2
- import { motion as l, AnimatePresence as h } from "motion-v";
2
+ import { motion as r, AnimatePresence as h } from "motion-v";
3
3
  import { maskHeight as v } from "./config.mjs";
4
4
  import { useSectionContext as g } from "./context.mjs";
5
5
  import { useAnimate as k } from "./use-animate.mjs";
@@ -13,9 +13,9 @@ const B = /* @__PURE__ */ u({
13
13
  onRemove: { type: Function },
14
14
  style: {}
15
15
  },
16
- setup(r) {
17
- const s = r, { justify: o } = g(), { getRoot: p, handleComplete: m } = k(s);
18
- return (t, x) => (a(), n(e(l).span, {
16
+ setup(s) {
17
+ const l = s, { justify: o } = g(), { getRoot: p, handleComplete: m } = k(l);
18
+ return (t, x) => (a(), n(e(r).span, {
19
19
  ref: e(p),
20
20
  layout: "position",
21
21
  "data-state": t.isPresent ? void 0 : "exiting",
@@ -31,13 +31,12 @@ const B = /* @__PURE__ */ u({
31
31
  }, {
32
32
  default: i(() => [
33
33
  y(e(h), {
34
- multiple: "",
35
34
  mode: "popLayout",
36
35
  "anchor-x": e(o),
37
36
  initial: !1
38
37
  }, {
39
38
  default: i(() => [
40
- (a(), n(e(l).span, {
39
+ (a(), n(e(r).span, {
41
40
  key: t.value,
42
41
  layout: e(o) === "right" ? "position" : !1,
43
42
  initial: { opacity: 0 },
@@ -1,21 +1,23 @@
1
- import { defineComponent as j, toRef as w, useSlots as k, computed as M, createBlock as v, openBlock as S, Teleport as X, createCommentVNode as Y, unref as o, withCtx as l, createVNode as c, mergeProps as H, renderSlot as L } from "vue";
2
- import { useSpring as T, LayoutGroup as N, MotionConfig as O, motion as R, AnimatePresence as A } from "motion-v";
3
- import { useCursorStyles as E } from "./use-cursor-styles.mjs";
4
- import { usePointerPosition as F } from "./hooks/use-pointer-position.mjs";
5
- import { useOffset as G } from "./hooks/use-offset.mjs";
6
- import { useCursorState as q } from "./hooks/use-cursor-state/index.mjs";
7
- import { useCursorIsInView as D } from "./hooks/use-cursor-in-view.mjs";
8
- import { useSnapToTarget as J } from "./hooks/use-snap-to-target.mjs";
9
- import { defaultFollowSpring as K, topLeftPoint as x, centerPoint as Q, autoSize as U, defaultTransition as W } from "./config.mjs";
10
- import { getCursorSize as Z } from "./get-cursor-size.mjs";
11
- import { useHasPointerMoved as _ } from "./hooks/use-has-pointer-moved.mjs";
12
- const mt = /* @__PURE__ */ j({
1
+ import { defineComponent as R, toRef as v, useSlots as V, computed as j, createBlock as T, openBlock as S, Teleport as X, createCommentVNode as Y, unref as t, withCtx as l, createVNode as d, mergeProps as A, renderSlot as H } from "vue";
2
+ import { useReducedMotion as L, useSpring as x, LayoutGroup as N, MotionConfig as O, motion as E, AnimatePresence as F } from "motion-v";
3
+ import { useCursorStyles as G } from "./use-cursor-styles.mjs";
4
+ import { usePointerPosition as q } from "./hooks/use-pointer-position.mjs";
5
+ import { useOffset as D } from "./hooks/use-offset.mjs";
6
+ import { useCursorState as J } from "./hooks/use-cursor-state/index.mjs";
7
+ import { useCursorIsInView as K } from "./hooks/use-cursor-in-view.mjs";
8
+ import { useSnapToTarget as Q } from "./hooks/use-snap-to-target.mjs";
9
+ import { defaultFollowSpring as U, topLeftPoint as C, centerPoint as W, autoSize as Z, skipTransition as _, defaultTransition as ee } from "./config.mjs";
10
+ import { getCursorSize as te } from "./get-cursor-size.mjs";
11
+ import { useHasPointerMoved as oe } from "./hooks/use-has-pointer-moved.mjs";
12
+ const ye = /* @__PURE__ */ R({
13
+ name: "Cursor",
14
+ inheritAttrs: !1,
13
15
  __name: "Cursor",
14
16
  props: {
15
17
  follow: { type: Boolean, default: !1 },
16
- center: { default: ({ follow: a }) => a ? x : Q },
17
- offset: { default: () => x },
18
- spring: { type: [Boolean, Object], default: ({ follow: a }) => a ? K : !1 },
18
+ center: { default: ({ follow: s }) => s ? C : W },
19
+ offset: { default: () => C },
20
+ spring: { type: [Boolean, Object], default: ({ follow: s }) => s ? U : !1 },
19
21
  snapToTarget: { type: Boolean, default: !1 },
20
22
  matchTextSize: { type: Boolean, default: !0 },
21
23
  transition: {},
@@ -24,89 +26,89 @@ const mt = /* @__PURE__ */ j({
24
26
  class: {},
25
27
  show: { type: Boolean, default: !0 }
26
28
  },
27
- setup(a) {
28
- const e = a, z = w(e, "offset");
29
- E(() => e.follow);
30
- const f = F(), i = G(f, z), d = T(i.x, e.spring || void 0), y = T(i.y, e.spring || void 0);
29
+ setup(s) {
30
+ const o = s, z = v(o, "offset"), c = L();
31
+ G(() => !c.value && !o.follow);
32
+ const f = q(), a = D(f, z), y = x(a.x, o.spring || void 0), h = x(a.y, o.spring || void 0);
31
33
  function g() {
32
- const t = i.x.on("change", (r) => {
33
- d.jump(r), t();
34
- }), n = i.y.on("change", (r) => {
35
- y.jump(r), n();
34
+ const e = a.x.on("change", (r) => {
35
+ y.jump(r), e();
36
+ }), n = a.y.on("change", (r) => {
37
+ h.jump(r), n();
36
38
  });
37
39
  }
38
- const s = q(), C = D(g), { x: P, y: B } = J(
39
- e.spring ? { x: d, y } : f,
40
- w(e, "snapToTarget"),
41
- s
42
- ), p = k(), u = M(() => {
40
+ const i = J(), P = K(g), { x: B, y: $ } = Q(
41
+ o.spring ? { x: y, y: h } : f,
42
+ v(o, "snapToTarget"),
43
+ i
44
+ ), u = V(), p = j(() => {
43
45
  var r, m;
44
- const t = (m = (r = p.default) == null ? void 0 : r.call(p)) == null ? void 0 : m.filter(
45
- (h) => h.type !== Symbol.for("v-cmt")
46
+ const e = (m = (r = u.default) == null ? void 0 : r.call(u)) == null ? void 0 : m.filter(
47
+ (w) => w.type !== Symbol.for("v-cmt")
46
48
  );
47
- if (t != null && t.length)
48
- return U;
49
- const n = Z(s.value.type, s.value, {
50
- matchPointerSize: e.snapToTarget,
51
- matchTextSize: e.matchTextSize
49
+ if (e != null && e.length)
50
+ return Z;
51
+ const n = te(i.value.type, i.value, {
52
+ matchPointerSize: o.snapToTarget,
53
+ matchTextSize: o.matchTextSize
52
54
  });
53
55
  return {
54
56
  width: `${n.width}px`,
55
57
  height: `${n.height}px`
56
58
  };
57
- }), $ = _(f, g);
58
- function b(t) {
59
- return (n, r) => `translate(-${t.x * 100}%, -${t.y * 100}%) ${r}`;
59
+ }), M = oe(f, g);
60
+ function b(e) {
61
+ return (n, r) => `translate(-${e.x * 100}%, -${e.y * 100}%) ${r}`;
60
62
  }
61
- function I() {
62
- const { follow: t, center: n, offset: r, spring: m, snapToTarget: h, matchTextSize: tt, ...V } = e;
63
+ function k() {
64
+ const { follow: e, center: n, offset: r, spring: m, snapToTarget: w, matchTextSize: re, ...I } = o;
63
65
  return {
64
- ...V
66
+ ...I
65
67
  };
66
68
  }
67
- return (t, n) => (S(), v(X, { to: "body" }, [
68
- o($) ? (S(), v(o(N), { key: 0 }, {
69
+ return (e, n) => (S(), T(X, { to: "body" }, [
70
+ t(M) ? (S(), T(t(N), { key: 0 }, {
69
71
  default: l(() => [
70
- c(o(O), {
71
- transition: e.transition || o(W)
72
+ d(t(O), {
73
+ transition: t(c) ? t(_) : e.transition || t(ee)
72
74
  }, {
73
75
  default: l(() => [
74
- c(o(R).div, H({
76
+ d(t(E).div, A({
75
77
  layout: "",
76
- "data-motion-cursor": t.follow ? "follow" : "pointer",
78
+ "data-motion-cursor": e.follow ? "follow" : "pointer",
77
79
  "data-framer-portal-id": "motion-cursor",
78
80
  initial: "exit",
79
81
  exit: "exit"
80
82
  }, {
81
- ...t.$attrs,
82
- ...I()
83
+ ...e.$attrs,
84
+ ...k()
83
85
  }, {
84
86
  variants: {
85
87
  default: { opacity: 1, scale: 1 },
86
88
  exit: { opacity: 0, scale: 0 },
87
- pressed: t.follow ? { opacity: 1, scale: 1 } : { opacity: 1, scale: 0.9 },
88
- ...t.variants
89
+ pressed: e.follow ? { opacity: 1, scale: 1 } : { opacity: 1, scale: 0.9 },
90
+ ...e.variants
89
91
  },
90
92
  animate: [
91
93
  "default",
92
- o(s).type,
93
- !o(C) || !t.show ? "exit" : o(s).isPressed ? "pressed" : ""
94
+ t(i).type,
95
+ !t(P) || !e.show ? "exit" : t(i).isPressed ? "pressed" : ""
94
96
  ],
95
- "transform-template": b(t.center),
96
- "data-w": u.value.width,
97
+ "transform-template": b(e.center),
98
+ "data-w": p.value.width,
97
99
  style: {
98
- width: u.value.width,
99
- height: u.value.height,
100
- borderRadius: t.follow ? 0 : 20,
101
- zIndex: t.follow ? 99998 : 99999,
100
+ width: p.value.width,
101
+ height: p.value.height,
102
+ borderRadius: e.follow ? 0 : 20,
103
+ zIndex: e.follow ? 99998 : 99999,
102
104
  willChange: "transform",
103
105
  contain: "layout",
104
106
  overflow: "hidden",
105
- originX: t.center.x,
106
- originY: t.center.y,
107
- ...e.style,
108
- x: o(P),
109
- y: o(B),
107
+ originX: e.center.x,
108
+ originY: e.center.y,
109
+ ...o.style,
110
+ x: t(B),
111
+ y: t($),
110
112
  top: 0,
111
113
  left: 0,
112
114
  position: "fixed",
@@ -114,9 +116,9 @@ const mt = /* @__PURE__ */ j({
114
116
  }
115
117
  }), {
116
118
  default: l(() => [
117
- c(o(A), { multiple: "" }, {
119
+ d(t(F), null, {
118
120
  default: l(() => [
119
- L(t.$slots, "default")
121
+ H(e.$slots, "default")
120
122
  ]),
121
123
  _: 3
122
124
  })
@@ -133,5 +135,5 @@ const mt = /* @__PURE__ */ j({
133
135
  }
134
136
  });
135
137
  export {
136
- mt as default
138
+ ye as default
137
139
  };
@@ -1,8 +1,9 @@
1
- const t = { width: "auto", height: "auto" }, o = { x: 0, y: 0 }, n = { x: 0.5, y: 0.5 }, e = { stiffness: 1e3, damping: 100 }, i = { duration: 0.15, ease: [0.38, 0.12, 0.29, 1] };
1
+ const t = { width: "auto", height: "auto" }, o = { x: 0, y: 0 }, n = { x: 0.5, y: 0.5 }, i = { duration: 0 }, s = { stiffness: 1e3, damping: 100 }, e = { duration: 0.15, ease: [0.38, 0.12, 0.29, 1] };
2
2
  export {
3
3
  t as autoSize,
4
4
  n as centerPoint,
5
- e as defaultFollowSpring,
6
- i as defaultTransition,
5
+ s as defaultFollowSpring,
6
+ e as defaultTransition,
7
+ i as skipTransition,
7
8
  o as topLeftPoint
8
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-plus-vue",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "Motion Plus Vue",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "typings": "./dist/index.d.ts",
27
27
  "peerDependencies": {
28
- "motion-v": ">=0.11.0-beta.5",
28
+ "motion-v": ">=0.13.0-beta.1",
29
29
  "vue": ">=3.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "motion-v": "0.11.0-beta.5",
32
+ "motion-v": "^0.13.0-beta.1",
33
33
  "vue": "^3.5.13"
34
34
  },
35
35
  "size-limit": [