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