@szum-tech/design-system
Version:
Szum-Tech design system with tailwindcss support
1 lines • 3.05 kB
JavaScript
;var chunkD5PAWOAZ_cjs=require('./chunk-D5PAWOAZ.cjs'),t=require('react'),react=require('motion/react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var t__namespace=/*#__PURE__*/_interopNamespace(t);var q={blinking:{opacity:[0,0,1,1],transition:{duration:1,repeat:1/0,repeatDelay:0,ease:"linear",times:[0,.5,.5,1]}}},z={fadeIn:{hidden:{opacity:0,y:10},show:{opacity:1,y:0},exit:{opacity:0}},blurIn:{hidden:{opacity:0,filter:"blur(4px)"},show:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},blurInUp:{hidden:{opacity:0,y:20,filter:"blur(4px)"},show:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-20,filter:"blur(4px)"}},blurInDown:{hidden:{opacity:0,y:-20,filter:"blur(4px)"},show:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:20,filter:"blur(4px)"}},slideUp:{hidden:{opacity:0,y:20},show:{opacity:1,y:0},exit:{opacity:0,y:-20}},slideDown:{hidden:{opacity:0,y:-20},show:{opacity:1,y:0},exit:{opacity:0,y:20}},slideLeft:{hidden:{opacity:0,x:20},show:{opacity:1,x:0},exit:{opacity:0,x:-20}},slideRight:{hidden:{opacity:0,x:-20},show:{opacity:1,x:0},exit:{opacity:0,x:20}},scaleUp:{hidden:{opacity:0,scale:.8},show:{opacity:1,scale:1},exit:{opacity:0,scale:1.2}},scaleDown:{hidden:{opacity:0,scale:1.2},show:{opacity:1,scale:1},exit:{opacity:0,scale:.8}}};function K({text:T,texts:e,speed:p=100,delay:c=0,showCursor:b=true,cursorClassName:I="",cursor:V="|",loop:l=false,pauseDuration:y=2e3,className:R,onComplete:u,startOnView:a=true,once:o=false,animation:A="fadeIn",inViewMargin:S,...C}){let d=t__namespace.useRef(null),M=react.useInView(d,{once:o,margin:S}),[U,D]=t__namespace.useState(false),[v,m]=t__namespace.useState(""),[n,x]=t__namespace.useState(0),[f,N]=t__namespace.useState(false),[P,k]=t__namespace.useState(0),h=!a||M&&(!o||!U),s=(e&&e.length>0?e:[T])[P]??"";t__namespace.useEffect(()=>{if(!h)return;let i=setTimeout(()=>{N(true),D(true);},c);return ()=>clearTimeout(i)},[c,h]),t__namespace.useEffect(()=>{if(f){if(n<s.length){let i=setTimeout(()=>{m(s.slice(0,n+1)),x(n+1);},p);return ()=>clearTimeout(i)}else if(u?.(),l&&e&&e.length>1){let i=setTimeout(()=>{m(""),x(0),k(H=>(H+1)%e.length);},y);return ()=>clearTimeout(i)}}},[n,s,f,p,l,e,y,u]);let E=z[A],O=react.motion.span;return jsxRuntime.jsx(O,{ref:d,variants:E,initial:"hidden",whileInView:a?"show":void 0,animate:a?void 0:"show",exit:"exit",className:chunkD5PAWOAZ_cjs.a("whitespace-pre-wrap",R),viewport:{once:o},"data-slot":"typing-text",...C,children:jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[v,b&&jsxRuntime.jsx(react.motion.span,{variants:q,animate:"blinking",className:chunkD5PAWOAZ_cjs.a("text-foreground ms-1 inline-block w-px font-normal select-none",I),children:V})]})})}exports.a=K;