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