motion-plus-vue 0.0.2 → 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 +2 -2
- package/dist/components/Cursor/Cursor.d.ts +10 -1
- package/dist/es/components/AnimateNumber/AnimateNumber.vue.mjs +20 -19
- package/dist/es/components/AnimateNumber/NumberSection.vue.mjs +69 -71
- package/dist/es/components/AnimateNumber/NumberSymbol.vue.mjs +5 -6
- package/dist/es/components/Cursor/Cursor.vue.mjs +72 -68
- package/dist/es/components/Cursor/config.mjs +4 -3
- package/package.json +3 -3
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,l){const h=new Intl.NumberFormat(t,i).formatToParts(Number(n));a&&h.unshift({type:"prefix",value:a}),l&&h.push({type:"suffix",value:l});const p=[],m=[],x=[],f=[],v={},o=s=>`${s}:${v[s]=(v[s]??-1)+1}`;let d="",w=!1,C=!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(B=>({type:g,value:parseInt(B)})));break;case"group":m.push({type:g,value:s.value});break;case"decimal":C=!0,x.push({type:g,value:s.value,key:o(g),originalIndex:y++});break;case"fraction":x.push(...s.value.split("").map(B=>({type:g,value:parseInt(B),key:o(g),originalIndex:y++})));break;default:(w||C?f:p).push({type:g,value:s.value,key:o(g),originalIndex:y++})}}const c=[];for(let s=m.length-1;s>=0;s--){const g=o(m[s].type);c.unshift({...m[s],key:g,originalIndex:s})}return{pre:p,integer:c,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(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 a(l){var r;l.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:l}=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(l)},{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(),l=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,c])=>{if(!c)return o.value=0;if(a.current)return e.nextTick(()=>{o.value=y});o.value=y},{immediate:!0});function d(y){var B;if(!r.value||y===v)return;const c=r.value.getBoundingClientRect(),s=(B=f.value)==null?void 0:B.getBoundingClientRect(),g=c.height*(y-v)+(c.top-(s?s.top||0:c.top));u.animate(r.value,{y:[g,0]},l.value.transition)}function w(y){if(a.current&&i===y||!h.value[y])return;const c=z(h.value[y]);f.value&&X.set(f.value,c),p.value=c}e.watch(o,y=>{w(y)},{immediate:!0,flush:"post"}),e.watch(o,(y,c,s)=>{d(y),s(()=>{v=y})},{immediate:!0,flush:"pre"});function C(y){return()=>e.createVNode("span",{key:y,style:{display:"inline-block",padding:`calc(${k}/2) 0`}},[y])}return(y,c)=>(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(C(s-1)),{key:s-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(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(C(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 l(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 C=o.nextSibling;return o.remove(),()=>{r.value&&r.value.insertBefore(o,C)}}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:l,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)}),l=u.useMotionConfig(),r=e.computed(()=>i.transition??l.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
|
|
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;
|
|
@@ -10,7 +10,10 @@ export interface CursorProps {
|
|
|
10
10
|
transition?: MotionProps['transition'];
|
|
11
11
|
variants?: MotionProps['variants'];
|
|
12
12
|
style?: MotionProps['style'];
|
|
13
|
+
class?: string;
|
|
14
|
+
show?: boolean;
|
|
13
15
|
}
|
|
16
|
+
declare const shouldReduceMotion: import('vue').Ref<boolean, boolean>;
|
|
14
17
|
declare const state: import('vue').Ref<import('./hooks/use-cursor-state/types').CursorState, import('./hooks/use-cursor-state/types').CursorState>;
|
|
15
18
|
declare const isInView: import('vue').Ref<boolean, boolean>;
|
|
16
19
|
declare const x: import('motion-v/es').MotionValue<number>, y: import('motion-v/es').MotionValue<number>;
|
|
@@ -24,6 +27,8 @@ declare function reset(): {
|
|
|
24
27
|
transition: MotionProps["transition"];
|
|
25
28
|
variants: MotionProps["variants"];
|
|
26
29
|
style: MotionProps["style"];
|
|
30
|
+
class: string;
|
|
31
|
+
show: boolean;
|
|
27
32
|
};
|
|
28
33
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
29
34
|
declare var __VLS_22: {};
|
|
@@ -36,6 +41,8 @@ declare const __VLS_self: import('vue').DefineComponent<CursorProps, {
|
|
|
36
41
|
MotionConfig: typeof MotionConfig;
|
|
37
42
|
motion: typeof motion;
|
|
38
43
|
defaultTransition: typeof defaultTransition;
|
|
44
|
+
skipTransition: typeof skipTransition;
|
|
45
|
+
shouldReduceMotion: typeof shouldReduceMotion;
|
|
39
46
|
state: typeof state;
|
|
40
47
|
isInView: typeof isInView;
|
|
41
48
|
x: typeof x;
|
|
@@ -47,6 +54,7 @@ declare const __VLS_self: import('vue').DefineComponent<CursorProps, {
|
|
|
47
54
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CursorProps> & Readonly<{}>, {
|
|
48
55
|
offset: Point;
|
|
49
56
|
center: Point;
|
|
57
|
+
show: boolean;
|
|
50
58
|
spring: false | SpringOptions;
|
|
51
59
|
matchTextSize: boolean;
|
|
52
60
|
follow: boolean;
|
|
@@ -55,6 +63,7 @@ declare const __VLS_self: import('vue').DefineComponent<CursorProps, {
|
|
|
55
63
|
declare const __VLS_component: import('vue').DefineComponent<CursorProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CursorProps> & Readonly<{}>, {
|
|
56
64
|
offset: Point;
|
|
57
65
|
center: Point;
|
|
66
|
+
show: boolean;
|
|
58
67
|
spring: false | SpringOptions;
|
|
59
68
|
matchTextSize: boolean;
|
|
60
69
|
follow: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { defineComponent as v, computed as l, createBlock as
|
|
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
|
|
4
|
-
import
|
|
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(
|
|
20
|
-
const
|
|
21
|
-
opacity: { duration: 1, ease:
|
|
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 =
|
|
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 =
|
|
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) => (
|
|
33
|
-
default:
|
|
34
|
-
t(o(
|
|
35
|
-
default:
|
|
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:
|
|
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:
|
|
62
|
-
t(
|
|
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:
|
|
72
|
-
t(
|
|
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(
|
|
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(
|
|
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
|
|
2
|
-
import { motion as
|
|
3
|
-
import { injectSectionContext as
|
|
4
|
-
import { useIsInitialRender as
|
|
5
|
-
import { getWidthInEm as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { targetWidths as
|
|
9
|
-
const
|
|
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(
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 (
|
|
28
|
-
|
|
28
|
+
if (c.current) {
|
|
29
|
+
y.value && (y.value.style.width = w(s.value));
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
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
|
|
36
|
+
const _ = e.nextSibling;
|
|
36
37
|
return e.remove(), () => {
|
|
37
|
-
|
|
38
|
+
s.value && s.value.insertBefore(e, _);
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
41
|
+
const l = H.get(e);
|
|
42
|
+
if (!l)
|
|
42
43
|
return;
|
|
43
|
-
const
|
|
44
|
-
return e.style.width =
|
|
45
|
-
e.style.width =
|
|
44
|
+
const R = e.style.width;
|
|
45
|
+
return e.style.width = l, () => {
|
|
46
|
+
e.style.width = R;
|
|
46
47
|
};
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 =
|
|
55
|
-
|
|
59
|
+
const o = C(m, "justify");
|
|
60
|
+
L({
|
|
56
61
|
justify: o
|
|
57
62
|
});
|
|
58
|
-
let a =
|
|
59
|
-
|
|
60
|
-
|
|
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 (
|
|
69
|
-
ref:
|
|
70
|
-
class: $(`number-section-${
|
|
71
|
-
style:
|
|
72
|
-
...
|
|
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:
|
|
74
|
+
width: d.value
|
|
76
75
|
}),
|
|
77
76
|
layout: "position"
|
|
78
77
|
}, {
|
|
79
|
-
default:
|
|
78
|
+
default: g(() => [
|
|
80
79
|
B("span", {
|
|
81
80
|
ref_key: "measuredRef",
|
|
82
|
-
ref:
|
|
81
|
+
ref: s,
|
|
83
82
|
style: {
|
|
84
83
|
display: "inline-flex",
|
|
85
84
|
justifyContent: "inherit",
|
|
86
85
|
position: "relative"
|
|
87
86
|
}
|
|
88
87
|
}, [
|
|
89
|
-
|
|
90
|
-
N(f(
|
|
91
|
-
|
|
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:
|
|
97
|
-
(
|
|
98
|
-
key:
|
|
94
|
+
default: g(() => [
|
|
95
|
+
(u(!0), h(P, null, S(f(a), (t) => (u(), h(P, {
|
|
96
|
+
key: t.key
|
|
99
97
|
}, [
|
|
100
|
-
|
|
101
|
-
key:
|
|
102
|
-
"part-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:
|
|
107
|
-
"is-present":
|
|
108
|
-
"initial-value": f(
|
|
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"])) : (
|
|
111
|
-
key:
|
|
112
|
-
type:
|
|
113
|
-
"part-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:
|
|
118
|
-
"is-present":
|
|
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
|
-
|
|
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
|
|
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(
|
|
17
|
-
const
|
|
18
|
-
return (t, x) => (a(), n(e(
|
|
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(
|
|
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,110 +1,114 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { useCursorStyles as
|
|
4
|
-
import { usePointerPosition as
|
|
5
|
-
import { useOffset as
|
|
6
|
-
import { useCursorState as
|
|
7
|
-
import { useCursorIsInView as
|
|
8
|
-
import { useSnapToTarget as
|
|
9
|
-
import { defaultFollowSpring as
|
|
10
|
-
import { getCursorSize as
|
|
11
|
-
import { useHasPointerMoved as
|
|
12
|
-
const
|
|
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:
|
|
17
|
-
offset: { default: () =>
|
|
18
|
-
spring: { type: [Boolean, Object], default: ({ follow:
|
|
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: {},
|
|
22
24
|
variants: {},
|
|
23
|
-
style: {}
|
|
25
|
+
style: {},
|
|
26
|
+
class: {},
|
|
27
|
+
show: { type: Boolean, default: !0 }
|
|
24
28
|
},
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const f =
|
|
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);
|
|
29
33
|
function g() {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
}), n =
|
|
33
|
-
|
|
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();
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
),
|
|
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(() => {
|
|
41
45
|
var r, m;
|
|
42
|
-
const
|
|
43
|
-
(
|
|
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")
|
|
44
48
|
);
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
47
|
-
const n =
|
|
48
|
-
matchPointerSize:
|
|
49
|
-
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
|
|
50
54
|
});
|
|
51
55
|
return {
|
|
52
56
|
width: `${n.width}px`,
|
|
53
57
|
height: `${n.height}px`
|
|
54
58
|
};
|
|
55
|
-
}),
|
|
56
|
-
function b(
|
|
57
|
-
return (n, r) => `translate(-${
|
|
59
|
+
}), M = oe(f, g);
|
|
60
|
+
function b(e) {
|
|
61
|
+
return (n, r) => `translate(-${e.x * 100}%, -${e.y * 100}%) ${r}`;
|
|
58
62
|
}
|
|
59
|
-
function
|
|
60
|
-
const { follow:
|
|
63
|
+
function k() {
|
|
64
|
+
const { follow: e, center: n, offset: r, spring: m, snapToTarget: w, matchTextSize: re, ...I } = o;
|
|
61
65
|
return {
|
|
62
|
-
...
|
|
66
|
+
...I
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
|
-
return (
|
|
66
|
-
|
|
69
|
+
return (e, n) => (S(), T(X, { to: "body" }, [
|
|
70
|
+
t(M) ? (S(), T(t(N), { key: 0 }, {
|
|
67
71
|
default: l(() => [
|
|
68
|
-
|
|
69
|
-
transition: e.transition ||
|
|
72
|
+
d(t(O), {
|
|
73
|
+
transition: t(c) ? t(_) : e.transition || t(ee)
|
|
70
74
|
}, {
|
|
71
75
|
default: l(() => [
|
|
72
|
-
|
|
76
|
+
d(t(E).div, A({
|
|
73
77
|
layout: "",
|
|
74
|
-
"data-motion-cursor":
|
|
78
|
+
"data-motion-cursor": e.follow ? "follow" : "pointer",
|
|
75
79
|
"data-framer-portal-id": "motion-cursor",
|
|
76
80
|
initial: "exit",
|
|
77
81
|
exit: "exit"
|
|
78
82
|
}, {
|
|
79
|
-
...
|
|
80
|
-
...
|
|
83
|
+
...e.$attrs,
|
|
84
|
+
...k()
|
|
81
85
|
}, {
|
|
82
86
|
variants: {
|
|
83
87
|
default: { opacity: 1, scale: 1 },
|
|
84
88
|
exit: { opacity: 0, scale: 0 },
|
|
85
|
-
pressed:
|
|
86
|
-
...
|
|
89
|
+
pressed: e.follow ? { opacity: 1, scale: 1 } : { opacity: 1, scale: 0.9 },
|
|
90
|
+
...e.variants
|
|
87
91
|
},
|
|
88
92
|
animate: [
|
|
89
93
|
"default",
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
t(i).type,
|
|
95
|
+
!t(P) || !e.show ? "exit" : t(i).isPressed ? "pressed" : ""
|
|
92
96
|
],
|
|
93
|
-
"transform-template": b(
|
|
94
|
-
"data-w":
|
|
97
|
+
"transform-template": b(e.center),
|
|
98
|
+
"data-w": p.value.width,
|
|
95
99
|
style: {
|
|
96
|
-
width:
|
|
97
|
-
height:
|
|
98
|
-
borderRadius:
|
|
99
|
-
zIndex:
|
|
100
|
+
width: p.value.width,
|
|
101
|
+
height: p.value.height,
|
|
102
|
+
borderRadius: e.follow ? 0 : 20,
|
|
103
|
+
zIndex: e.follow ? 99998 : 99999,
|
|
100
104
|
willChange: "transform",
|
|
101
105
|
contain: "layout",
|
|
102
106
|
overflow: "hidden",
|
|
103
|
-
originX:
|
|
104
|
-
originY:
|
|
105
|
-
...
|
|
106
|
-
x:
|
|
107
|
-
y:
|
|
107
|
+
originX: e.center.x,
|
|
108
|
+
originY: e.center.y,
|
|
109
|
+
...o.style,
|
|
110
|
+
x: t(B),
|
|
111
|
+
y: t($),
|
|
108
112
|
top: 0,
|
|
109
113
|
left: 0,
|
|
110
114
|
position: "fixed",
|
|
@@ -112,9 +116,9 @@ const mt = /* @__PURE__ */ j({
|
|
|
112
116
|
}
|
|
113
117
|
}), {
|
|
114
118
|
default: l(() => [
|
|
115
|
-
|
|
119
|
+
d(t(F), null, {
|
|
116
120
|
default: l(() => [
|
|
117
|
-
|
|
121
|
+
H(e.$slots, "default")
|
|
118
122
|
]),
|
|
119
123
|
_: 3
|
|
120
124
|
})
|
|
@@ -131,5 +135,5 @@ const mt = /* @__PURE__ */ j({
|
|
|
131
135
|
}
|
|
132
136
|
});
|
|
133
137
|
export {
|
|
134
|
-
|
|
138
|
+
ye as default
|
|
135
139
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const t = { width: "auto", height: "auto" }, o = { x: 0, y: 0 }, n = { x: 0.5, y: 0.5 },
|
|
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
|
-
|
|
6
|
-
|
|
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.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.
|
|
28
|
+
"motion-v": ">=0.13.0-beta.1",
|
|
29
29
|
"vue": ">=3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"motion-v": "0.
|
|
32
|
+
"motion-v": "^0.13.0-beta.1",
|
|
33
33
|
"vue": "^3.5.13"
|
|
34
34
|
},
|
|
35
35
|
"size-limit": [
|