@luanlu/mk-motion 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/dist/a11y/focus-trap.d.ts +10 -0
- package/dist/a11y/keyboard.d.ts +28 -0
- package/dist/components/alert/alert.d.ts +18 -0
- package/dist/components/avatar/avatar.d.ts +31 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +16 -0
- package/dist/components/button/button.d.ts +28 -0
- package/dist/components/card/card.d.ts +19 -0
- package/dist/components/collapse/collapse.d.ts +23 -0
- package/dist/components/dialog/dialog.d.ts +27 -0
- package/dist/components/drawer/drawer.d.ts +21 -0
- package/dist/components/empty/empty.d.ts +14 -0
- package/dist/components/form/checkbox.d.ts +27 -0
- package/dist/components/form/radio.d.ts +32 -0
- package/dist/components/form/select.d.ts +32 -0
- package/dist/components/form/slider.d.ts +31 -0
- package/dist/components/input/input.d.ts +31 -0
- package/dist/components/layout/divider.d.ts +12 -0
- package/dist/components/layout/row.d.ts +14 -0
- package/dist/components/layout/space.d.ts +13 -0
- package/dist/components/loading/loading.d.ts +8 -0
- package/dist/components/menu/menu.d.ts +30 -0
- package/dist/components/message/message.d.ts +10 -0
- package/dist/components/popover/popover.d.ts +31 -0
- package/dist/components/progress/progress.d.ts +25 -0
- package/dist/components/steps/steps.d.ts +22 -0
- package/dist/components/switch/switch.d.ts +23 -0
- package/dist/components/table/table.d.ts +47 -0
- package/dist/components/tabs/tabs.d.ts +30 -0
- package/dist/components/tag/tag.d.ts +24 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/core/animator.d.ts +29 -0
- package/dist/core/timeline.d.ts +14 -0
- package/dist/core/utils.d.ts +13 -0
- package/dist/effects/glitch.d.ts +14 -0
- package/dist/effects/particle.d.ts +17 -0
- package/dist/effects/text-split.d.ts +14 -0
- package/dist/effects/wave-text.d.ts +17 -0
- package/dist/gesture/draggable.d.ts +23 -0
- package/dist/gesture/spring.d.ts +24 -0
- package/dist/index.d.ts +109 -0
- package/dist/interactive/coverflow.d.ts +24 -0
- package/dist/interactive/cursor-trail.d.ts +11 -0
- package/dist/interactive/flip-card.d.ts +18 -0
- package/dist/interactive/magnetic.d.ts +12 -0
- package/dist/micro/hover-lift.d.ts +15 -0
- package/dist/micro/ripple.d.ts +13 -0
- package/dist/mk-motion.js +3194 -0
- package/dist/mk-motion.umd.cjs +149 -0
- package/dist/motion/component-motion.d.ts +43 -0
- package/dist/presets/index.d.ts +20 -0
- package/dist/scroll/scroll-trigger.d.ts +20 -0
- package/dist/style.css +1 -0
- package/dist/text/count-up.d.ts +23 -0
- package/dist/text/typewriter.d.ts +21 -0
- package/dist/theme/theme.d.ts +28 -0
- package/dist/transitions/blur-reveal.d.ts +14 -0
- package/dist/transitions/collapse.d.ts +16 -0
- package/dist/transitions/lazy-image.d.ts +14 -0
- package/dist/transitions/list.d.ts +9 -0
- package/dist/transitions/loading.d.ts +13 -0
- package/dist/transitions/parallax.d.ts +16 -0
- package/dist/transitions/shimmer.d.ts +13 -0
- package/dist/transitions/toast.d.ts +25 -0
- package/dist/types.d.ts +4 -0
- package/package.json +57 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
(function(h,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(h=typeof globalThis<"u"?globalThis:h||self,k(h.MotionKit={}))})(this,function(h){"use strict";var Us=Object.defineProperty;var Bs=(h,k,x)=>k in h?Us(h,k,{enumerable:!0,configurable:!0,writable:!0,value:x}):h[k]=x;var c=(h,k,x)=>Bs(h,typeof k!="symbol"?k+"":k,x);function k(o){return o<1e3?`${o}ms`:`${(o/1e3).toFixed(2).replace(/\.?0+$/,"")}s`}function x(o,t){Object.entries(t).forEach(([e,s])=>{o.style.setProperty(`--mk-${e}`,String(s))})}function Qt(o,t){t.forEach(e=>{o.style.removeProperty(`--mk-${e}`)})}const O={duration:500,easing:"ease",delay:0,iterations:1,direction:"normal",fill:"both"};class P{constructor(t){c(this,"element");c(this,"currentAnimation",null);if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("Animator: element not found")}animate(t,e={}){return new Promise(s=>{const i={...O,...e};x(this.element,{duration:k(i.duration),easing:i.easing});const n=`mk-animated mk-${t}`;this.element.classList.add(...n.split(" "));const r=()=>{this.element.classList.remove(...n.split(" ")),Qt(this.element,["duration","easing"]),s(this)},a=l=>{l.animationName.startsWith("mk-")&&(this.element.removeEventListener("animationend",a),r())};if(i.iterations===1/0||i.iterations<=0){this.element.classList.add("mk-infinite"),s(this);return}this.element.addEventListener("animationend",a)})}waa(t,e={}){return new Promise(s=>{const i={...O,...e};this.currentAnimation=this.element.animate(t,{duration:i.duration,easing:i.easing,delay:i.delay,iterations:i.iterations===1/0?1/0:i.iterations,direction:i.direction,fill:i.fill}),this.currentAnimation.onfinish=()=>s(this),(i.iterations===1/0||i.iterations<=0)&&s(this)})}stop(){return this.currentAnimation&&(this.currentAnimation.cancel(),this.currentAnimation=null),this}reset(){const e=Array.from(this.element.classList).filter(s=>s.startsWith("mk-"));return this.element.classList.remove(...e),this}vars(t){return x(this.element,t),this}}class te{constructor(){c(this,"items",[]);c(this,"running",!1);c(this,"abortController",null)}add(t,e,s){return this.items.push({name:t,target:e,options:s,at:(s==null?void 0:s.at)??this.estimateEndTime()}),this}estimateEndTime(){var s;if(this.items.length===0)return 0;const t=this.items[this.items.length-1],e=((s=t.options)==null?void 0:s.duration)??500;return(t.at??0)+e}async play(){if(this.running)return;this.running=!0,this.abortController=new AbortController;const t=this.abortController.signal,e=this.items.map(s=>new Promise(i=>{var u,p;const n=typeof s.target=="string"?document.querySelector(s.target):s.target;if(!n||t.aborted){i();return}const r=s.at??0,a=((u=s.options)==null?void 0:u.duration)??500,l=((p=s.options)==null?void 0:p.easing)??"ease",d=setTimeout(()=>{if(t.aborted){i();return}const m=`mk-animated mk-${s.name}`,f=n;f.classList.add(...m.split(" ")),f.style.setProperty("--mk-duration",`${a}ms`),f.style.setProperty("--mk-easing",l);const g=v=>{v.animationName.startsWith("mk-")&&(f.removeEventListener("animationend",g),f.classList.remove(...m.split(" ")),f.style.removeProperty("--mk-duration"),f.style.removeProperty("--mk-easing"),i())};f.addEventListener("animationend",g),setTimeout(()=>{f.removeEventListener("animationend",g),f.classList.remove(...m.split(" ")),f.style.removeProperty("--mk-duration"),f.style.removeProperty("--mk-easing"),i()},a+100)},r);t.addEventListener("abort",()=>{clearTimeout(d),i()})}));await Promise.all(e),this.running=!1}stop(){var t;(t=this.abortController)==null||t.abort(),this.running=!1,this.items.forEach(e=>{const s=typeof e.target=="string"?document.querySelector(e.target):e.target;if(s){const i=s,n=`mk-animated mk-${e.name}`;i.classList.remove(...n.split(" ")),i.style.removeProperty("--mk-duration"),i.style.removeProperty("--mk-easing")}})}clear(){return this.stop(),this.items=[],this}}function b(o){return new P(o)}function H(o,t){return b(o).animate("fadeIn",t)}function Y(o,t){return b(o).animate("fadeOut",t)}function X(o,t){return b(o).animate("slideInUp",t)}function U(o,t){return b(o).animate("slideInDown",t)}function B(o,t){return b(o).animate("slideInLeft",t)}function K(o,t){return b(o).animate("slideInRight",t)}function W(o,t){return b(o).animate("slideOutUp",t)}function V(o,t){return b(o).animate("slideOutDown",t)}function j(o,t){return b(o).animate("zoomIn",t)}function G(o,t){return b(o).animate("zoomOut",t)}function J(o,t){return b(o).animate("bounceIn",t)}function Z(o,t){return b(o).animate("bounceOut",t)}function Q(o,t){return b(o).animate("flipInX",t)}function tt(o,t){return b(o).animate("flipInY",t)}function et(o,t){return b(o).animate("shake",t)}function st(o,t){return b(o).animate("pulse",t)}function it(o,t){return b(o).animate("rotateIn",t)}const ee=Object.freeze(Object.defineProperty({__proto__:null,bounceIn:J,bounceOut:Z,fadeIn:H,fadeOut:Y,flipInX:Q,flipInY:tt,pulse:st,rotateIn:it,shake:et,slideInDown:U,slideInLeft:B,slideInRight:K,slideInUp:X,slideOutDown:V,slideOutUp:W,zoomIn:j,zoomOut:G},Symbol.toStringTag,{value:"Module"})),se={threshold:.2,rootMargin:"0px",once:!0,duration:500,easing:"ease"};class nt{constructor(){c(this,"observer",null);c(this,"elements",new Map)}watch(t,e,s={}){const i={...se,...s};let n;return typeof t=="string"?n=Array.from(document.querySelectorAll(t)):Array.isArray(t)?n=t:n=[t],this.observer||(this.observer=new IntersectionObserver(r=>this.handleEntries(r),{threshold:i.threshold,rootMargin:i.rootMargin})),n.forEach(r=>{this.elements.set(r,{name:e,opts:i}),this.observer.observe(r)}),this}handleEntries(t){t.forEach(e=>{var s;if(e.isIntersecting){const i=this.elements.get(e.target);if(!i)return;const n=e.target,r=`mk-animated mk-${i.name}`;n.classList.add(...r.split(" ")),n.style.setProperty("--mk-duration",`${i.opts.duration}ms`),n.style.setProperty("--mk-easing",i.opts.easing);const a=l=>{l.animationName.startsWith("mk-")&&(n.removeEventListener("animationend",a),i.opts.once&&n.classList.remove(...r.split(" ")))};n.addEventListener("animationend",a),i.opts.once&&((s=this.observer)==null||s.unobserve(e.target),this.elements.delete(e.target))}})}destroy(){var t;(t=this.observer)==null||t.disconnect(),this.observer=null,this.elements.clear()}}function ie(o,t,e){return new nt().watch(o,t,e)}const ne={speed:80,cursor:!0,cursorChar:"|"};class ot{constructor(t){c(this,"element");c(this,"originalText","");c(this,"timer",null);c(this,"running",!1);if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("Typewriter: element not found");this.originalText=this.element.textContent??""}async start(t={}){if(this.running)return;this.running=!0;const e={...ne,...t},s=this.originalText||this.element.textContent||"";return this.element.textContent="",e.cursor&&(this.element.style.borderRight="2px solid currentColor",this.element.style.paddingRight="2px",this.startCursorBlink()),new Promise(i=>{let n=0;const r=()=>{var a;if(!this.running){i();return}n<s.length?(this.element.textContent+=s.charAt(n),n++,this.timer=setTimeout(r,e.speed)):(this.running=!1,(a=e.onComplete)==null||a.call(e),i())};r()})}stop(){this.running=!1,this.timer&&(clearTimeout(this.timer),this.timer=null)}reset(){this.stop(),this.element.textContent=this.originalText,this.element.style.borderRight="none",this.element.style.paddingRight="0"}startCursorBlink(){let t=!0;const e=()=>{if(!this.running){this.element.style.borderRightColor="transparent";return}this.element.style.borderRightColor=t?"currentColor":"transparent",t=!t,setTimeout(e,530)};e()}}function oe(o,t){const e=new ot(o);return e.reset(),e.start(t)}const re={duration:2e3,easing:"easeOut",decimals:0,prefix:"",suffix:"",separator:","};class rt{constructor(t){c(this,"element");c(this,"rafId",null);if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("CountUp: element not found")}animateTo(t,e=0,s={}){const i={...re,...s},n=performance.now();return new Promise(r=>{const a=l=>{var f,g;const d=l-n,u=Math.min(d/i.duration,1),p=this.applyEasing(u,i.easing),m=e+(t-e)*p;this.render(m,i),(f=i.onUpdate)==null||f.call(i,m),u<1?this.rafId=requestAnimationFrame(a):(this.render(t,i),(g=i.onComplete)==null||g.call(i),r())};this.rafId=requestAnimationFrame(a)})}stop(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}render(t,e){let s=t.toFixed(e.decimals);if(e.separator){const i=s.split(".");i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,e.separator),s=i.join(".")}this.element.textContent=`${e.prefix}${s}${e.suffix}`}applyEasing(t,e){switch(e){case"easeOut":return 1-Math.pow(1-t,3);case"easeInOut":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;default:return t}}}function ae(o,t,e){return new rt(o).animateTo(t,0,e)}const le={stiffness:170,damping:26,mass:1,precision:.01};function A(o,t={}){const e={...le,...t};let s=0,i=o.from,n,r=!0;const a=()=>{var m;if(!r)return;const l=i-o.to,d=-e.stiffness*l,u=-e.damping*s,p=(d+u)/e.mass;if(s+=p*(1/60),i+=s*(1/60),o.onUpdate(i),Math.abs(l)<e.precision&&Math.abs(s)<e.precision){o.onUpdate(o.to),(m=o.onComplete)==null||m.call(o),r=!1;return}n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>{r=!1,cancelAnimationFrame(n)}}function ce(o,t=1,e){const s=typeof o=="string"?document.querySelector(o):o;if(!s)throw new Error("elasticScale: element not found");const i=getComputedStyle(s).transform;let n=1;if(i!=="none"){const r=new DOMMatrix(i);n=Math.sqrt(r.a*r.a+r.b*r.b)}return A({from:n,to:t,onUpdate:r=>{s.style.transform=`scale(${r})`}},e)}function de(o,t,e,s){const i=typeof o=="string"?document.querySelector(o):o;if(!i)throw new Error("elasticMove: element not found");let n=0,r=0;const a=A({from:0,to:t,onUpdate:d=>{n=d,i.style.transform=`translate3d(${n}px, ${r}px, 0)`}},s),l=A({from:0,to:e,onUpdate:d=>{r=d,i.style.transform=`translate3d(${n}px, ${r}px, 0)`}},s);return()=>{a(),l()}}class he{constructor(t,e={}){c(this,"element");c(this,"options");c(this,"startX",0);c(this,"startY",0);c(this,"currentX",0);c(this,"currentY",0);c(this,"initialTransformX",0);c(this,"initialTransformY",0);c(this,"pointerId",null);c(this,"onPointerDown",t=>{var s,i;if(this.pointerId!==null)return;this.pointerId=t.pointerId,this.element.setPointerCapture(t.pointerId),this.startX=t.clientX,this.startY=t.clientY;const e=getComputedStyle(this.element).transform;if(e!=="none"){const n=new DOMMatrix(e);this.initialTransformX=n.m41,this.initialTransformY=n.m42}else this.initialTransformX=0,this.initialTransformY=0;this.currentX=this.initialTransformX,this.currentY=this.initialTransformY,(i=(s=this.options).onStart)==null||i.call(s,t),this.element.addEventListener("pointermove",this.onPointerMove),this.element.addEventListener("pointerup",this.onPointerUp)});c(this,"onPointerMove",t=>{var r,a;if(t.pointerId!==this.pointerId)return;const e=t.clientX-this.startX,s=t.clientY-this.startY;let i=this.initialTransformX+e,n=this.initialTransformY+s;if(this.options.bounds){const l=typeof this.options.bounds=="string"?document.querySelector(this.options.bounds):this.options.bounds;if(l){const d=l.getBoundingClientRect(),u=this.element.getBoundingClientRect(),p=d.left-u.left+i,m=d.right-u.right+i,f=d.top-u.top+n,g=d.bottom-u.bottom+n;i=Math.max(p,Math.min(m,i)),n=Math.max(f,Math.min(g,n))}}this.options.axis==="x"&&(n=this.initialTransformY),this.options.axis==="y"&&(i=this.initialTransformX),this.currentX=i,this.currentY=n,this.element.style.transform=`translate3d(${i}px, ${n}px, 0)`,(a=(r=this.options).onDrag)==null||a.call(r,i,n)});c(this,"onPointerUp",t=>{var e,s;t.pointerId===this.pointerId&&(this.pointerId=null,this.element.releasePointerCapture(t.pointerId),this.element.removeEventListener("pointermove",this.onPointerMove),this.element.removeEventListener("pointerup",this.onPointerUp),(s=(e=this.options).onEnd)==null||s.call(e,this.currentX,this.currentY))});if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("Draggable: element not found");this.options={axis:e.axis??"both",bounds:e.bounds??null,onStart:e.onStart,onDrag:e.onDrag,onEnd:e.onEnd},this.element.style.touchAction="none",this.element.addEventListener("pointerdown",this.onPointerDown)}destroy(){this.element.removeEventListener("pointerdown",this.onPointerDown),this.pointerId!==null&&(this.element.releasePointerCapture(this.pointerId),this.pointerId=null)}}const at={color:"rgba(255, 255, 255, 0.35)",duration:600,maxScale:2.5};function ue(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("addRipple: element not found");e.style.position="relative",e.style.overflow="hidden";const s={...at,...t},i=n=>{const r=e.getBoundingClientRect(),a=Math.max(r.width,r.height),l=n.clientX-r.left-a/2,d=n.clientY-r.top-a/2,u=document.createElement("span");u.style.cssText=`
|
|
2
|
+
position: absolute;
|
|
3
|
+
border-radius: 50%;
|
|
4
|
+
background: ${s.color};
|
|
5
|
+
width: ${a}px;
|
|
6
|
+
height: ${a}px;
|
|
7
|
+
left: ${l}px;
|
|
8
|
+
top: ${d}px;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
transform: scale(0);
|
|
11
|
+
opacity: 1;
|
|
12
|
+
`,e.appendChild(u);const p=u.animate([{transform:"scale(0)",opacity:1},{transform:`scale(${s.maxScale})`,opacity:0}],{duration:s.duration,easing:"ease-out"});p.onfinish=()=>{u.remove()}};return e.addEventListener("click",i),()=>{e.removeEventListener("click",i)}}function pe(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("rippleEffect: element not found");const s={...at,...t},i=e.getBoundingClientRect(),n=Math.max(i.width,i.height),r=document.createElement("span");return r.style.cssText=`
|
|
13
|
+
position: absolute;
|
|
14
|
+
border-radius: 50%;
|
|
15
|
+
background: ${s.color};
|
|
16
|
+
width: ${n}px;
|
|
17
|
+
height: ${n}px;
|
|
18
|
+
left: ${i.width/2-n/2}px;
|
|
19
|
+
top: ${i.height/2-n/2}px;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
transform: scale(0);
|
|
22
|
+
opacity: 1;
|
|
23
|
+
`,e.style.position="relative",e.style.overflow="hidden",e.appendChild(r),new Promise(a=>{const l=r.animate([{transform:"scale(0)",opacity:1},{transform:`scale(${s.maxScale})`,opacity:0}],{duration:s.duration,easing:"ease-out"});l.onfinish=()=>{r.remove(),a()}})}const me={y:-6,scale:1.02,shadow:"0 12px 24px rgba(0,0,0,0.15)",duration:250,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"};function fe(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("hoverLift: element not found");const s={...me,...t};e.style.transition=`transform ${s.duration}ms ${s.easing}, box-shadow ${s.duration}ms ${s.easing}`;const i=()=>{e.style.transform=`translateY(${s.y}px) scale(${s.scale})`,e.style.boxShadow=s.shadow},n=()=>{e.style.transform="",e.style.boxShadow=""};return e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",n),()=>{e.removeEventListener("mouseenter",i),e.removeEventListener("mouseleave",n),e.style.transition="",e.style.transform="",e.style.boxShadow=""}}function ye(o,t="rgba(56, 189, 248, 0.4)",e){const s=typeof o=="string"?document.querySelector(o):o;if(!s)throw new Error("hoverGlow: element not found");const i=(e==null?void 0:e.duration)??250,n=(e==null?void 0:e.easing)??"ease";s.style.transition=`box-shadow ${i}ms ${n}`;const r=()=>{s.style.boxShadow=`0 0 20px ${t}`},a=()=>{s.style.boxShadow=""};return s.addEventListener("mouseenter",r),s.addEventListener("mouseleave",a),()=>{s.removeEventListener("mouseenter",r),s.removeEventListener("mouseleave",a),s.style.transition="",s.style.boxShadow=""}}const ge={count:30,speed:6,size:6,gravity:.3,fadeOut:!0,duration:1e3};function lt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("particleBurst: element not found");const s={...ge,...t},i=Array.isArray(s.color)?s.color:[s.color??"#38bdf8"],n=e.getBoundingClientRect(),r=n.left+n.width/2,a=n.top+n.height/2,l=[];for(let d=0;d<s.count;d++){const u=Math.PI*2*d/s.count+Math.random()*.5,p=s.speed*(.5+Math.random()*.8),m=document.createElement("div");m.style.cssText=`
|
|
24
|
+
position: fixed;
|
|
25
|
+
left: ${r}px;
|
|
26
|
+
top: ${a}px;
|
|
27
|
+
width: ${s.size}px;
|
|
28
|
+
height: ${s.size}px;
|
|
29
|
+
border-radius: 50%;
|
|
30
|
+
background: ${i[d%i.length]};
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
z-index: 9999;
|
|
33
|
+
`,document.body.appendChild(m),l.push({el:m,vx:Math.cos(u)*p,vy:Math.sin(u)*p,x:r,y:a,life:0,maxLife:s.duration})}return new Promise(d=>{const u=performance.now(),p=m=>{const f=m-u;let g=0;l.forEach(v=>{v.life=f,v.vy+=s.gravity,v.x+=v.vx,v.y+=v.vy;const S=v.life/v.maxLife,Xs=s.fadeOut?1-S:1;S<1&&(g++,v.el.style.transform=`translate(${v.x-r}px, ${v.y-a}px)`,v.el.style.opacity=String(Math.max(0,Xs)))}),g>0?requestAnimationFrame(p):(l.forEach(v=>v.el.remove()),d())};requestAnimationFrame(p)})}function ve(o,t,e={}){const s=document.createElement("div");return s.style.position="fixed",s.style.left=o+"px",s.style.top=t+"px",document.body.appendChild(s),lt(s,e).finally(()=>s.remove())}const be={type:"char",stagger:40,duration:500,animation:"fadeUp"},Ee={fadeUp:{from:"opacity:0;transform:translateY(20px)",to:"opacity:1;transform:translateY(0)"},fadeDown:{from:"opacity:0;transform:translateY(-20px)",to:"opacity:1;transform:translateY(0)"},zoomIn:{from:"opacity:0;transform:scale(0.5)",to:"opacity:1;transform:scale(1)"},rotateIn:{from:"opacity:0;transform:rotate(-180deg)",to:"opacity:1;transform:rotate(0)"},slideLeft:{from:"opacity:0;transform:translateX(-30px)",to:"opacity:1;transform:translateX(0)"}};class ct{constructor(t){c(this,"element");c(this,"originalHTML");if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("TextSplit: element not found");this.originalHTML=this.element.innerHTML}async animate(t={}){const e={...be,...t},s=Ee[e.animation],i=this.element.textContent??"";this.element.innerHTML="",this.element.style.display="inline-block";const n=e.type==="char"?i.split(""):i.split(/(\s+)/),r=[];return n.forEach(a=>{const l=document.createElement("span");l.textContent=a,l.style.display="inline-block",l.style.cssText+=s.from,l.style.transition=`all ${e.duration}ms cubic-bezier(0.34, 1.56, 0.64, 1)`,this.element.appendChild(l),r.push(l)}),this.element.offsetHeight,new Promise(a=>{let l=0;const d=r.length;r.forEach((u,p)=>{setTimeout(()=>{u.style.cssText+=s.to,setTimeout(()=>{l++,l>=d&&a()},e.duration)},p*e.stagger)})})}reset(){this.element.innerHTML=this.originalHTML,this.element.style.display=""}}function ke(o,t){const e=new ct(o);return e.reset(),e.animate(t)}const dt={duration:300,intensity:5,color1:"#ff0040",color2:"#00ffff"};function ht(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("glitch: element not found");const s={...dt,...t},i=Math.min(Math.max(s.intensity,1),10),n=e.style.cssText,r=Math.floor(i*2);return new Promise(a=>{let l=0;const d=s.duration/r,u=()=>{if(l>=r){e.style.cssText=n,e.style.textShadow="",a();return}const p=(Math.random()-.5)*i*4,m=`inset(${Math.random()*80}% 0 ${Math.random()*80}% 0)`,f=`${s.color1} ${p}px 0`,g=`${s.color2} ${-p}px 0`;e.style.transform=`translateX(${p}px)`,e.style.clipPath=m,e.style.textShadow=`${f}, ${g}`,l++,setTimeout(u,d)};u()})}function we(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("glitchLoop: element not found");const s={...dt,...t},i=e.style.cssText;let n=!0;const r=async()=>{n&&(await ht(e,{...s,duration:100+Math.random()*200}),n&&setTimeout(r,200+Math.random()*800))};return r(),()=>{n=!1,e.style.cssText=i,e.style.textShadow="",e.style.clipPath="",e.style.transform=""}}const Ce={amplitude:15,frequency:.3,speed:.08,stagger:.15};class ut{constructor(t){c(this,"element");c(this,"spans",[]);c(this,"rafId",null);c(this,"originalHTML");if(this.element=typeof t=="string"?document.querySelector(t):t,!this.element)throw new Error("WaveText: element not found");this.originalHTML=this.element.innerHTML}start(t={}){this.stop();const e={...Ce,...t},s=this.element.textContent??"";this.element.innerHTML="",this.element.style.display="inline-block";const i=s.split("");this.spans=i.map(a=>{const l=document.createElement("span");return l.textContent=a===" "?" ":a,l.style.display="inline-block",l.style.transition="transform 0.1s linear",this.element.appendChild(l),l});let n=0;const r=()=>{n+=e.speed,this.spans.forEach((a,l)=>{const d=l*e.stagger,u=Math.sin(n+d)*e.amplitude;a.style.transform=`translateY(${u}px)`}),this.rafId=requestAnimationFrame(r)};this.rafId=requestAnimationFrame(r)}stop(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}reset(){this.stop(),this.element.innerHTML=this.originalHTML,this.element.style.display=""}}function xe(o,t){const e=new ut(o);return e.start(t),()=>e.stop()}const Le={speed:.3,direction:"vertical"};function pt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("parallax: element not found");const s={...Le,...t},i=()=>{const n=e.getBoundingClientRect(),r=window.innerHeight,l=(n.top+n.height/2-r/2)*s.speed;s.direction==="vertical"?e.style.transform=`translateY(${l}px)`:e.style.transform=`translateX(${l}px)`};return window.addEventListener("scroll",i,{passive:!0}),i(),()=>{window.removeEventListener("scroll",i),e.style.transform=""}}function _e(o){const t=o.map(e=>pt(e.selector,{speed:e.speed,direction:e.direction}));return()=>t.forEach(e=>e())}const Te={duration:1500,color:"rgba(255,255,255,0.25)",angle:100};function mt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("shimmer: element not found");const s={...Te,...t};e.style.background="#1e293b",e.style.position="relative",e.style.overflow="hidden";const i=document.createElement("div");if(i.style.cssText=`
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0;
|
|
36
|
+
background: linear-gradient(${s.angle}deg, transparent 30%, ${s.color} 50%, transparent 70%);
|
|
37
|
+
background-size: 200% 100%;
|
|
38
|
+
animation: mk-shimmer ${s.duration}ms infinite linear;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
`,!document.getElementById("mk-shimmer-style")){const n=document.createElement("style");n.id="mk-shimmer-style",n.textContent=`
|
|
41
|
+
@keyframes mk-shimmer {
|
|
42
|
+
0% { background-position: 200% 0; }
|
|
43
|
+
100% { background-position: -200% 0; }
|
|
44
|
+
}
|
|
45
|
+
`,document.head.appendChild(n)}return e.appendChild(i),()=>{i.remove(),e.style.background="",e.style.position="",e.style.overflow=""}}function Se(o,t=3,e){const s=typeof o=="string"?document.querySelector(o):o;if(!s)throw new Error("skeleton: container not found");const i=s.innerHTML;s.innerHTML="",s.style.display="flex",s.style.flexDirection="column",s.style.gap="12px";const n=[];for(let r=0;r<t;r++){const a=document.createElement("div");a.style.height=r===0?"24px":"16px",a.style.width=r===t-1?"60%":"100%",a.style.borderRadius="4px",s.appendChild(a),n.push(mt(a,e))}return()=>{n.forEach(r=>r()),s.innerHTML=i,s.style.display="",s.style.flexDirection="",s.style.gap=""}}const ft={duration:800,blurStart:10,stagger:100};function Ae(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("blurReveal: element not found");const s={...ft,...t};return e.style.filter=`blur(${s.blurStart}px)`,e.style.opacity="0",e.style.transition=`filter ${s.duration}ms ease, opacity ${s.duration}ms ease`,e.offsetHeight,new Promise(i=>{e.style.filter="blur(0px)",e.style.opacity="1",setTimeout(()=>{e.style.transition="",i()},s.duration)})}function $e(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("blurRevealChildren: element not found");const s={...ft,...t},i=s.childSelector?Array.from(e.querySelectorAll(s.childSelector)):Array.from(e.children);return i.forEach(n=>{const r=n;r.style.filter=`blur(${s.blurStart}px)`,r.style.opacity="0",r.style.transition=`filter ${s.duration}ms ease, opacity ${s.duration}ms ease`}),e.offsetHeight,new Promise(n=>{let r=0;i.forEach((a,l)=>{setTimeout(()=>{const d=a;d.style.filter="blur(0px)",d.style.opacity="1",setTimeout(()=>{d.style.transition="",r++,r>=i.length&&n()},s.duration)},l*s.stagger)})})}const Me={threshold:.1,rootMargin:"50px",blur:!0,placeholder:"#1e293b"};function yt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("lazyImage: image not found");const s={...Me,...t};if(!e.dataset.src)return console.warn("lazyImage: img 缺少 data-src 属性"),()=>{};e.style.background=s.placeholder,e.style.transition="opacity 0.6s ease, filter 0.6s ease",s.blur?(e.style.filter="blur(8px)",e.style.opacity="0.5"):e.style.opacity="0";const n=new IntersectionObserver(r=>{r.forEach(a=>{if(a.isIntersecting){const l=a.target,d=l.dataset.src,u=new Image;u.onload=()=>{l.src=d,l.style.opacity="1",l.style.filter="blur(0px)",l.style.background=""},u.onerror=()=>{l.style.opacity="1",l.style.filter="blur(0px)"},u.src=d,n.unobserve(l)}})},{threshold:s.threshold,rootMargin:s.rootMargin});return n.observe(e),()=>n.disconnect()}function Ie(o="img[data-src]"){const t=document.querySelectorAll(o),e=Array.from(t).map(s=>yt(s));return()=>e.forEach(s=>s())}const gt={duration:300,easing:"ease-in-out"};function vt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("expand: element not found");const s={...gt,...t};e.style.overflow="hidden",e.style.display="";const i=e.scrollHeight;return e.style.height="0px",e.style.opacity="0",e.style.transition=`height ${s.duration}ms ${s.easing}, opacity ${s.duration}ms ${s.easing}`,new Promise(n=>{requestAnimationFrame(()=>{e.style.height=`${i}px`,e.style.opacity="1",setTimeout(()=>{e.style.height="",e.style.overflow="",e.style.transition="",e.style.opacity="",n()},s.duration)})})}function bt(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("collapse: element not found");const s={...gt,...t},i=e.scrollHeight;return e.style.overflow="hidden",e.style.height=`${i}px`,e.style.transition=`height ${s.duration}ms ${s.easing}, opacity ${s.duration}ms ${s.easing}`,new Promise(n=>{requestAnimationFrame(()=>{e.style.height="0px",e.style.opacity="0",setTimeout(()=>{e.style.display="none",e.style.height="",e.style.overflow="",e.style.transition="",e.style.opacity="",n()},s.duration)})})}async function Ne(o,t){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("toggleCollapse: element not found");return getComputedStyle(e).display==="none"||e.offsetHeight===0?(await vt(e,t),!0):(await bt(e,t),!1)}const Pe={stagger:60,duration:400,animation:"fadeUp"},De={fadeUp:{from:"opacity:0;transform:translate3d(0,16px,0)",to:"opacity:1;transform:translate3d(0,0,0)"},fadeDown:{from:"opacity:0;transform:translate3d(0,-16px,0)",to:"opacity:1;transform:translate3d(0,0,0)"},fadeLeft:{from:"opacity:0;transform:translate3d(16px,0,0)",to:"opacity:1;transform:translate3d(0,0,0)"},fadeRight:{from:"opacity:0;transform:translate3d(-16px,0,0)",to:"opacity:1;transform:translate3d(0,0,0)"},zoom:{from:"opacity:0;transform:scale3d(0.9,0.9,0.9)",to:"opacity:1;transform:scale3d(1,1,1)"}};function qe(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("listStagger: container not found");const s={...Pe,...t},i=De[s.animation],n=Array.from(e.children);return n.forEach(r=>{r.style.cssText+=i.from}),e.offsetHeight,new Promise(r=>{let a=0;n.forEach((l,d)=>{setTimeout(()=>{l.style.transition=`all ${s.duration}ms cubic-bezier(0.25, 0.1, 0.25, 1)`,l.style.cssText+=i.to,setTimeout(()=>{l.style.transition="",a++,a>=n.length&&r()},s.duration)},d*s.stagger)})})}const Et={size:40,color:"#38bdf8",thickness:3};function ze(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("showLoading: element not found");const s={...Et,...t};e.style.position="relative";const i=document.createElement("div");i.className="mk-loading-mask",i.style.cssText=`
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: 0;
|
|
48
|
+
background: rgba(15, 23, 42, 0.7);
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
z-index: 100;
|
|
53
|
+
border-radius: inherit;
|
|
54
|
+
`;const n=document.createElement("div");return n.className="mk-transition mk-spin",n.style.cssText=`
|
|
55
|
+
width: ${s.size}px;
|
|
56
|
+
height: ${s.size}px;
|
|
57
|
+
border: ${s.thickness}px solid rgba(255,255,255,0.1);
|
|
58
|
+
border-top-color: ${s.color};
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
`,i.appendChild(n),e.appendChild(i),()=>{i.remove()}}function Fe(o={}){const t={...Et,...o},e=document.createElement("div");e.style.cssText=`
|
|
61
|
+
position: fixed;
|
|
62
|
+
inset: 0;
|
|
63
|
+
background: rgba(0, 0, 0, 0.5);
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
z-index: 9999;
|
|
68
|
+
`;const s=document.createElement("div");return s.className="mk-transition mk-spin",s.style.cssText=`
|
|
69
|
+
width: ${t.size}px;
|
|
70
|
+
height: ${t.size}px;
|
|
71
|
+
border: ${t.thickness}px solid rgba(255,255,255,0.15);
|
|
72
|
+
border-top-color: ${t.color};
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
`,e.appendChild(s),document.body.appendChild(e),()=>{e.remove()}}const kt={duration:3e3,type:"info",position:"top"},wt={info:{bg:"#38bdf8",icon:"ℹ️"},success:{bg:"#34d399",icon:"✅"},warning:{bg:"#fbbf24",icon:"⚠️"},error:{bg:"#f87171",icon:"❌"}},Ct={top:"top:20px;left:50%;transform:translateX(-50%)","top-right":"top:20px;right:20px","top-left":"top:20px;left:20px",bottom:"bottom:20px;left:50%;transform:translateX(-50%)","bottom-right":"bottom:20px;right:20px","bottom-left":"bottom:20px;left:20px"};function $(o,t={}){const e={...kt,...t},s=wt[e.type],i=Ct[e.position],n=document.createElement("div");n.style.cssText=`
|
|
75
|
+
position: fixed;
|
|
76
|
+
${i};
|
|
77
|
+
background: ${s.bg};
|
|
78
|
+
color: #fff;
|
|
79
|
+
padding: 12px 20px;
|
|
80
|
+
border-radius: 8px;
|
|
81
|
+
font-size: 0.9rem;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 8px;
|
|
85
|
+
z-index: 9999;
|
|
86
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
|
87
|
+
opacity: 0;
|
|
88
|
+
transform: translateY(-20px);
|
|
89
|
+
transition: all 0.3s ease;
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
`,n.innerHTML=`<span>${s.icon}</span><span>${o}</span>`,document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1",n.style.transform=(e.position.startsWith("bottom"),"translateY(0)")});const r=setTimeout(()=>{n.style.opacity="0",n.style.transform=e.position.startsWith("bottom")?"translateY(20px)":"translateY(-20px)",setTimeout(()=>n.remove(),300)},e.duration);return()=>{clearTimeout(r),n.remove()}}function Re(o,t){return $(o,{...t,type:"success"})}function Oe(o,t){return $(o,{...t,type:"error"})}function He(o,t){return $(o,{...t,type:"warning"})}function Ye(o,t,e={}){const s={...kt,...e},i=wt[s.type],n=Ct[s.position],r=document.createElement("div");r.style.cssText=`
|
|
92
|
+
position: fixed;
|
|
93
|
+
${n};
|
|
94
|
+
background: #1e293b;
|
|
95
|
+
border-left: 4px solid ${i.bg};
|
|
96
|
+
color: #e2e8f0;
|
|
97
|
+
padding: 16px 20px;
|
|
98
|
+
border-radius: 8px;
|
|
99
|
+
font-size: 0.9rem;
|
|
100
|
+
z-index: 9999;
|
|
101
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
|
102
|
+
min-width: 280px;
|
|
103
|
+
opacity: 0;
|
|
104
|
+
transform: translateX(30px);
|
|
105
|
+
transition: all 0.3s ease;
|
|
106
|
+
`,r.innerHTML=`
|
|
107
|
+
<div style="font-weight:600;margin-bottom:4px;color:${i.bg};">${i.icon} ${o}</div>
|
|
108
|
+
<div style="color:#94a3b8;font-size:0.85rem;">${t}</div>
|
|
109
|
+
`,document.body.appendChild(r),requestAnimationFrame(()=>{r.style.opacity="1",r.style.transform="translateX(0)"});const a=setTimeout(()=>{r.style.opacity="0",r.style.transform="translateX(30px)",setTimeout(()=>r.remove(),300)},s.duration);return()=>{clearTimeout(a),r.remove()}}const xt={strength:.4,radius:150};function Xe(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("magnetic: element not found");const s={...xt,...t};e.style.transition="transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)";const i=r=>{const a=e.getBoundingClientRect(),l=a.left+a.width/2,d=a.top+a.height/2,u=r.clientX-l,p=r.clientY-d,m=Math.sqrt(u*u+p*p);if(m<s.radius){const f=1-m/s.radius,g=u*s.strength*f,v=p*s.strength*f;e.style.transform=`translate(${g}px, ${v}px)`}else e.style.transform=""},n=()=>{e.style.transform=""};return document.addEventListener("mousemove",i),e.addEventListener("mouseleave",n),()=>{document.removeEventListener("mousemove",i),e.removeEventListener("mouseleave",n),e.style.transform="",e.style.transition=""}}function Ue(o,t={}){const e=typeof o=="string"?document.querySelector(o):o;if(!e)throw new Error("magneticText: element not found");const s=e.textContent??"";e.innerHTML="",e.style.display="inline-block";const i=[];s.split("").forEach(l=>{const d=document.createElement("span");d.textContent=l===" "?" ":l,d.style.display="inline-block",d.style.transition="transform 0.3s ease",e.appendChild(d),i.push(d)});const n={...xt,...t},r=l=>{i.forEach(d=>{const u=d.getBoundingClientRect(),p=u.left+u.width/2,m=u.top+u.height/2,f=l.clientX-p,g=l.clientY-m,v=Math.sqrt(f*f+g*g);if(v<n.radius){const S=1-v/n.radius;d.style.transform=`translate(${f*n.strength*S}px, ${g*n.strength*S}px)`}else d.style.transform=""})},a=()=>{i.forEach(l=>l.style.transform="")};return document.addEventListener("mousemove",r),e.addEventListener("mouseleave",a),()=>{document.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}const Be={perspective:800,rotateY:45,spacing:60,scale:1.15};class Lt{constructor(t,e,s={}){c(this,"container");c(this,"cards");c(this,"currentIndex",0);c(this,"options");if(this.container=typeof t=="string"?document.querySelector(t):t,!this.container)throw new Error("CoverFlow: container not found");this.cards=Array.from(this.container.querySelectorAll(e)),this.options={...Be,...s},this.container.style.perspective=`${this.options.perspective}px`,this.container.style.transformStyle="preserve-3d",this.update()}goTo(t){return this.currentIndex=Math.max(0,Math.min(t,this.cards.length-1)),this.update(),this}next(){return this.goTo(this.currentIndex+1)}prev(){return this.goTo(this.currentIndex-1)}update(){this.cards.forEach((t,e)=>{const s=e-this.currentIndex,i=Math.abs(s);let n=s*this.options.spacing,r=s>0?-this.options.rotateY:this.options.rotateY,a=1,l=this.cards.length-i,d=1;s===0?(r=0,a=this.options.scale,l=this.cards.length+1):i>2?(d=0,l=0):d=1-i*.3,t.style.transition="all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1)",t.style.transform=`translateX(${n}px) rotateY(${r}deg) scale(${a})`,t.style.zIndex=String(l),t.style.opacity=String(d)})}}function Ke(o,t,e){return new Lt(o,t,e)}const We={axis:"y",duration:600,perspective:1e3};class _t{constructor(t,e={}){c(this,"container");c(this,"inner");c(this,"front");c(this,"back");c(this,"flipped",!1);c(this,"options");if(this.container=typeof t=="string"?document.querySelector(t):t,!this.container)throw new Error("FlipCard: container not found");if(this.options={...We,...e},this.container.style.perspective=`${this.options.perspective}px`,this.container.style.cursor="pointer",this.inner=document.createElement("div"),this.inner.style.cssText=`
|
|
110
|
+
position: relative;
|
|
111
|
+
width: 100%;
|
|
112
|
+
height: 100%;
|
|
113
|
+
transform-style: preserve-3d;
|
|
114
|
+
transition: transform ${this.options.duration}ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
115
|
+
`,this.front=this.container.querySelector('[data-flip="front"]'),this.back=this.container.querySelector('[data-flip="back"]'),!this.front||!this.back)throw new Error('FlipCard: 需要包含 data-flip="front" 和 data-flip="back" 的子元素');const s=`
|
|
116
|
+
position: absolute;
|
|
117
|
+
inset: 0;
|
|
118
|
+
backface-visibility: hidden;
|
|
119
|
+
-webkit-backface-visibility: hidden;
|
|
120
|
+
`;this.front.style.cssText+=s,this.back.style.cssText+=s,this.options.axis==="y"?this.back.style.transform="rotateY(180deg)":this.back.style.transform="rotateX(180deg)",this.inner.appendChild(this.front),this.inner.appendChild(this.back),this.container.innerHTML="",this.container.appendChild(this.inner),this.container.addEventListener("click",()=>this.toggle())}toggle(){this.flipped=!this.flipped;const t=this.flipped?180:0;return this.options.axis==="y"?this.inner.style.transform=`rotateY(${t}deg)`:this.inner.style.transform=`rotateX(${t}deg)`,this}flipToFront(){return this.flipped=!1,this.inner.style.transform="",this}flipToBack(){this.flipped=!0;const t=180;return this.options.axis==="y"?this.inner.style.transform=`rotateY(${t}deg)`:this.inner.style.transform=`rotateX(${t}deg)`,this}}function Ve(o,t){return new _t(o,t)}const je={count:15,color:"#38bdf8",size:8,fadeSpeed:.92,smoothing:.15};function Ge(o={}){const t={...je,...o},e=[],s=document.createElement("div");s.style.cssText=`
|
|
121
|
+
position: fixed;
|
|
122
|
+
inset: 0;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
z-index: 9998;
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
`,document.body.appendChild(s);for(let d=0;d<t.count;d++){const u=document.createElement("div");u.style.cssText=`
|
|
127
|
+
position: absolute;
|
|
128
|
+
width: ${t.size}px;
|
|
129
|
+
height: ${t.size}px;
|
|
130
|
+
border-radius: 50%;
|
|
131
|
+
background: ${t.color};
|
|
132
|
+
opacity: 0;
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
`,s.appendChild(u),e.push({el:u,x:-100,y:-100,targetX:-100,targetY:-100,opacity:0})}let i=-100,n=-100,r=!0;const a=d=>{i=d.clientX,n=d.clientY};document.addEventListener("mousemove",a);const l=()=>{r&&(e.forEach((d,u)=>{u===0?(d.targetX=i,d.targetY=n):(d.targetX=e[u-1].x,d.targetY=e[u-1].y),d.x+=(d.targetX-d.x)*t.smoothing,d.y+=(d.targetY-d.y)*t.smoothing,i>0&&(d.opacity=Math.min(1,d.opacity+.1)),d.opacity*=t.fadeSpeed;const p=t.size*(1-u/t.count*.6);d.el.style.transform=`translate(${d.x-p/2}px, ${d.y-p/2}px)`,d.el.style.width=`${p}px`,d.el.style.height=`${p}px`,d.el.style.opacity=String(d.opacity)}),requestAnimationFrame(l))};return requestAnimationFrame(l),()=>{r=!1,document.removeEventListener("mousemove",a),s.remove()}}const Je={enter:"fadeIn",exit:"fadeOut",hover:"none",active:"none",focus:"none",duration:250,delay:0,easing:"cubic-bezier(0.16, 1, 0.3, 1)"};function T(o,t={}){const e={...Je,...t},s=e.enter!=="none"?new P(o):null,i=o.style,n=i.transition;let r=!1;function a(){e.hover!=="none"&&(r=!0,d(!0))}function l(){r&&(r=!1,d(!1))}function d(g){const v=`transform ${e.duration}ms ${e.easing}, box-shadow ${e.duration}ms ${e.easing}`;switch(e.hover){case"lift":i.transition=v,i.transform=g?"translateY(-2px)":"",i.boxShadow=g?"var(--mk-shadow-md)":"";break;case"glow":i.transition=`box-shadow ${e.duration}ms ${e.easing}`,i.boxShadow=g?"var(--mk-shadow-glow)":"";break;case"scale":i.transition=`transform ${e.duration}ms ${e.easing}`,i.transform=g?"scale(1.02)":"";break;case"slideUp":i.transition=v,i.transform=g?"translateY(-4px)":"";break}}function u(){e.active==="press"&&(i.transition=`transform ${e.duration*.5}ms ${e.easing}`,i.transform="scale(0.97)")}function p(){e.active==="press"&&(i.transform=r?e.hover==="lift"?"translateY(-2px)":e.hover==="scale"?"scale(1.02)":"":"")}function m(){e.focus==="ring"&&(i.outline="none",i.boxShadow="0 0 0 2px var(--mk-primary-muted), 0 0 0 4px var(--mk-primary)",i.transition=`box-shadow ${e.duration}ms ${e.easing}`)}function f(){e.focus==="ring"&&(i.boxShadow="")}return o.addEventListener("mouseenter",a),o.addEventListener("mouseleave",l),o.addEventListener("mousedown",u),o.addEventListener("mouseup",p),o.addEventListener("focus",m),o.addEventListener("blur",f),{async playEnter(){!s||e.enter==="none"||await s.animate(e.enter,{duration:e.duration,delay:e.delay})},async playExit(){!s||e.exit==="none"||await s.animate(e.exit,{duration:e.duration})},setHover(g){g?a():l()},destroy(){o.removeEventListener("mouseenter",a),o.removeEventListener("mouseleave",l),o.removeEventListener("mousedown",u),o.removeEventListener("mouseup",p),o.removeEventListener("focus",m),o.removeEventListener("blur",f),i.transition=n,i.transform="",i.boxShadow="",i.outline="",s==null||s.stop()}}}function Ze(o,t,e,s){const i=o.querySelectorAll(t);if(i.length===0)return;const n=(s==null?void 0:s.delay)??100,r=(s==null?void 0:s.stagger)??80,a=(s==null?void 0:s.duration)??400;i.forEach((l,d)=>{const u=l;u.style.opacity="0",setTimeout(()=>{u.style.transition=`opacity ${a}ms ease`,u.style.opacity="1"},n+d*r)})}const Qe=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");class M{constructor(t){c(this,"container");c(this,"previousActiveElement",null);c(this,"listeners",[]);this.container=t}activate(t){this.previousActiveElement=document.activeElement;const e=this.getFocusableElements(),s=t||(e.length>0?e[0]:null);s instanceof HTMLElement&&s.focus();const i=n=>this.handleKeyDown(n);this.container.addEventListener("keydown",i),this.listeners.push(()=>this.container.removeEventListener("keydown",i))}deactivate(){this.listeners.forEach(t=>t()),this.listeners=[],this.previousActiveElement instanceof HTMLElement&&this.previousActiveElement.focus()}getFocusableElements(){return this.container.querySelectorAll(Qe)}handleKeyDown(t){if(t.key!=="Tab")return;const e=Array.from(this.getFocusableElements());if(e.length===0)return;const s=e[0],i=e[e.length-1];t.shiftKey&&document.activeElement===s?(t.preventDefault(),i.focus()):!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),s.focus())}}function w(o,t){const e=s=>{for(const i of t)if(s.key===i.key){i.preventDefault!==!1&&s.preventDefault(),i.handler(s);return}};return o.addEventListener("keydown",e),()=>o.removeEventListener("keydown",e)}const y={Enter:"Enter",Escape:"Escape",Tab:"Tab",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Home:"Home",End:"End",Space:" "};class Tt{constructor(){c(this,"currentTheme","dark");c(this,"listeners",new Set);document.documentElement.setAttribute("data-mk-theme","dark")}setTheme(t){this.currentTheme=t,document.documentElement.setAttribute("data-mk-theme",t),this.listeners.forEach(e=>e(t))}toggle(){this.setTheme(this.currentTheme==="dark"?"light":"dark")}getTheme(){return this.currentTheme}applyCustom(t){const e=document.documentElement;Object.entries(t).forEach(([s,i])=>{e.style.setProperty(`--mk-${s}`,i)})}resetCustom(){const t=document.documentElement;["bg","surface","surface-hover","border","border-hover","primary","primary-hover","primary-active","success","warning","danger","text","text-secondary","text-tertiary"].forEach(s=>t.style.removeProperty(`--mk-${s}`))}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}}const ts=new Tt;class St{constructor(t,e={}){c(this,"el");const s=typeof t=="string"?document.querySelector(t):t;this.el=document.createElement("div"),this.el.className="mk-row",e.justify&&this.el.classList.add(`mk-row--justify-${e.justify}`),e.align&&this.el.classList.add(`mk-row--align-${e.align}`),e.wrap===!1&&this.el.classList.add("mk-row--no-wrap"),e.gutter&&(this.el.style.margin=`0 -${e.gutter/2}px`),s.appendChild(this.el)}addCol(t,e,s){const i=document.createElement("div");return i.className=`mk-col mk-col-${t==="flex"?"flex":t}`,s&&i.classList.add(s),typeof e=="string"?i.innerHTML=e:e&&i.appendChild(e),this.el.appendChild(i),i}destroy(){this.el.remove()}}function es(o,t){return new St(o,t)}class At{constructor(t,e={}){c(this,"el");const s=typeof t=="string"?document.querySelector(t):t;this.el=document.createElement("div"),this.el.className="mk-space",e.direction==="vertical"&&this.el.classList.add("mk-space--vertical"),e.size&&this.el.classList.add(`mk-space--${e.size}`),e.wrap!==!1&&this.el.classList.add("mk-space--wrap"),s.appendChild(this.el)}add(t){if(typeof t=="string"){const e=document.createElement("span");e.innerHTML=t,this.el.appendChild(e)}else this.el.appendChild(t)}destroy(){this.el.remove()}}function ss(o,t){return new At(o,t)}class $t{constructor(t,e={}){c(this,"el");const s=typeof t=="string"?document.querySelector(t):t;this.el=document.createElement("div"),this.el.className="mk-divider",e.direction==="vertical"?this.el.classList.add("mk-divider--vertical"):this.el.classList.add("mk-divider--horizontal"),e.dashed&&this.el.classList.add("mk-divider--dashed"),e.text&&(this.el.textContent=e.text),s.appendChild(this.el)}destroy(){this.el.remove()}}function is(o,t){return new $t(o,t)}class Mt{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"motion",null);const s=typeof t=="string"?document.querySelector(t):t;if(this.options={type:"default",size:"default",...e},this.el=document.createElement("button"),this.el.type="button",this.el.className=this.buildClass(),this.el.disabled=!!this.options.disabled||!!this.options.loading,this.options.icon&&!this.options.text&&this.el.setAttribute("aria-label","Button"),this.updateAriaDisabled(),this.options.loading){this.el.classList.add("is-loading");const i=document.createElement("span");i.className="mk-button__spinner",this.el.appendChild(i)}if(this.options.icon&&!this.options.loading){const i=document.createElement("span");i.textContent=this.options.icon,this.el.appendChild(i)}if(this.options.text){const i=document.createElement("span");i.textContent=this.options.text,this.el.appendChild(i)}this.el.addEventListener("click",i=>{var n,r;this.createRipple(i),(r=(n=this.options).onClick)==null||r.call(n,i)}),s.appendChild(this.el),this.motion=T(this.el,e.motion||{hover:"lift",active:"press",focus:"ring",enter:"fadeIn",duration:200})}buildClass(){const t=["mk-button"];return this.options.type&&this.options.type!=="default"&&t.push(`mk-button--${this.options.type}`),this.options.size&&this.options.size!=="default"&&t.push(`mk-button--${this.options.size}`),this.options.plain&&t.push("is-plain"),this.options.round&&t.push("is-round"),this.options.circle&&t.push("is-circle"),this.options.loading&&t.push("is-loading"),this.options.disabled&&t.push("is-disabled"),t.join(" ")}createRipple(t){const e=this.el.getBoundingClientRect(),s=Math.max(e.width,e.height),i=document.createElement("span");i.className="mk-button__ripple",i.style.width=i.style.height=`${s}px`,i.style.left=`${t.clientX-e.left-s/2}px`,i.style.top=`${t.clientY-e.top-s/2}px`,this.el.appendChild(i),setTimeout(()=>i.remove(),600)}setLoading(t){this.options.loading=t,this.el.classList.toggle("is-loading",t),this.el.disabled=t||!!this.options.disabled,this.updateAriaDisabled();const e=this.el.querySelector(".mk-button__spinner");if(t&&!e){const s=document.createElement("span");s.className="mk-button__spinner",this.el.insertBefore(s,this.el.firstChild)}else!t&&e&&e.remove()}setDisabled(t){this.options.disabled=t,this.el.classList.toggle("is-disabled",t),this.el.disabled=t||!!this.options.loading,this.updateAriaDisabled()}updateAriaDisabled(){this.el.setAttribute("aria-disabled",String(this.el.disabled))}destroy(){var t;(t=this.motion)==null||t.destroy(),this.el.remove()}}function ns(o,t){return new Mt(o,t)}class It{constructor(t,e={}){c(this,"el");c(this,"input");c(this,"options");c(this,"errorMsg");c(this,"motion",null);const s=typeof t=="string"?document.querySelector(t):t;this.options={...e},this.el=document.createElement("div"),this.el.className="mk-input-wrapper";const i=`mk-input-${Math.random().toString(36).slice(2)}`;this.input=document.createElement("input"),this.input.className="mk-input",this.input.id=i,this.input.type=this.options.type||"text",this.input.placeholder=this.options.placeholder||"",this.input.value=this.options.value||"",this.input.disabled=!!this.options.disabled,this.el.appendChild(this.input);const n=document.createElement("span");if(n.className="mk-input__suffix",this.options.clearable){const r=document.createElement("span");r.className="mk-input__suffix-item mk-input__clear",r.innerHTML="✕",r.addEventListener("click",()=>{var a,l;this.input.value="",this.input.focus(),(l=(a=this.options).onInput)==null||l.call(a,""),this.clearError()}),n.appendChild(r)}if(this.options.showPassword&&this.input.type==="password"){const r=document.createElement("span");r.className="mk-input__suffix-item",r.innerHTML="👁",r.title="显示密码";let a=!1;r.addEventListener("click",()=>{a=!a,this.input.type=a?"text":"password",r.innerHTML=a?"🙈":"👁"}),n.appendChild(r)}n.children.length>0&&this.el.appendChild(n),this.errorMsg=document.createElement("span"),this.errorMsg.className="mk-input__errormsg",this.errorMsg.id=`${i}-error`,this.el.appendChild(this.errorMsg),this.input.addEventListener("input",()=>{var r,a;(a=(r=this.options).onInput)==null||a.call(r,this.input.value),this.clearError()}),this.input.addEventListener("keydown",r=>{var a,l;r.key==="Enter"&&((l=(a=this.options).onEnter)==null||l.call(a,this.input.value))}),this.input.addEventListener("blur",()=>{this.validate()}),s.appendChild(this.el),this.motion=T(this.input,e.motion||{focus:"ring",enter:"fadeIn",duration:200})}get value(){return this.input.value}set value(t){this.input.value=t}validate(){if(!this.options.validate)return!0;const t=this.options.validate(this.input.value);return t?(this.showError(t),!1):(this.clearError(),!0)}showError(t){this.el.classList.add("is-error"),this.el.classList.remove("is-success"),this.errorMsg.textContent=t,this.errorMsg.classList.add("show"),this.input.setAttribute("aria-invalid","true"),this.input.setAttribute("aria-describedby",this.errorMsg.id)}showSuccess(){this.el.classList.remove("is-error"),this.el.classList.add("is-success"),this.errorMsg.classList.remove("show")}clearError(){this.el.classList.remove("is-error"),this.errorMsg.classList.remove("show"),this.input.removeAttribute("aria-invalid"),this.input.removeAttribute("aria-describedby")}focus(){this.input.focus()}destroy(){var t;(t=this.motion)==null||t.destroy(),this.el.remove()}}function os(o,t){return new It(o,t)}class Nt{constructor(t,e={}){c(this,"el");c(this,"motion",null);const s=typeof t=="string"?document.querySelector(t):t;if(this.el=document.createElement("div"),this.el.className="mk-card",e.shadow&&(e.shadow==="always"?this.el.classList.add("is-always-shadow"):e.shadow==="hover"&&this.el.classList.add("is-hover-shadow")),e.loading&&this.el.classList.add("is-loading"),e.image){const n=document.createElement("img");n.className="mk-card__image",n.src=e.image,n.alt="",this.el.appendChild(n)}if(e.title){const n=document.createElement("div");n.className="mk-card__header";const r=document.createElement("span");r.className="mk-card__title",r.textContent=e.title,n.appendChild(r),this.el.appendChild(n)}const i=document.createElement("div");if(i.className="mk-card__body",e.body&&(i.innerHTML=e.body),this.el.appendChild(i),e.footer){const n=document.createElement("div");n.className="mk-card__footer",n.textContent=e.footer,this.el.appendChild(n)}s.appendChild(this.el),this.motion=T(this.el,e.motion||{hover:"lift",duration:300})}setLoading(t){this.el.classList.toggle("is-loading",t)}destroy(){var t;(t=this.motion)==null||t.destroy(),this.el.remove()}}function rs(o,t){return new Nt(o,t)}let as=0;class Pt{constructor(t={}){c(this,"overlay");c(this,"dialog");c(this,"options");c(this,"focusTrap");c(this,"escapeCleanup",null);c(this,"confirmBtn");c(this,"titleId");this.options={showClose:!0,showCancel:!0,...t},this.overlay=document.createElement("div"),this.overlay.className="mk-dialog-overlay",this.overlay.style.display="none",this.dialog=document.createElement("div"),this.dialog.className="mk-dialog",this.options.center&&this.dialog.classList.add("is-center"),this.dialog.setAttribute("role","dialog"),this.dialog.setAttribute("aria-modal","true");const e=document.createElement("div");e.className="mk-dialog__header";const s=document.createElement("span");if(s.className="mk-dialog__title",s.textContent=this.options.title||"",this.titleId=`mk-dialog-title-${++as}`,s.id=this.titleId,this.dialog.setAttribute("aria-labelledby",this.titleId),e.appendChild(s),this.options.showClose){const r=document.createElement("span");r.className="mk-dialog__close",r.innerHTML="✕",r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.setAttribute("aria-label","Close"),r.addEventListener("click",()=>this.close()),r.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.close())}),e.appendChild(r)}this.dialog.appendChild(e);const i=document.createElement("div");i.className="mk-dialog__body",typeof this.options.content=="string"?i.innerHTML=this.options.content:this.options.content&&i.appendChild(this.options.content),this.dialog.appendChild(i);const n=document.createElement("div");if(n.className="mk-dialog__footer",this.options.showCancel){const r=document.createElement("button");r.className="mk-button",r.textContent=this.options.cancelText||"取消",r.addEventListener("click",()=>{var a,l;(l=(a=this.options).onCancel)==null||l.call(a),this.close()}),n.appendChild(r)}this.confirmBtn=document.createElement("button"),this.confirmBtn.className="mk-button mk-button--primary",this.confirmBtn.textContent=this.options.confirmText||"确定",this.confirmBtn.addEventListener("click",()=>{var r,a;(a=(r=this.options).onConfirm)==null||a.call(r),this.close()}),n.appendChild(this.confirmBtn),this.dialog.appendChild(n),this.overlay.appendChild(this.dialog),this.overlay.addEventListener("click",r=>{var a,l;r.target===this.overlay&&((l=(a=this.options).onClose)==null||l.call(a),this.close())}),document.body.appendChild(this.overlay),this.focusTrap=new M(this.dialog)}open(){this.overlay.style.display="flex",requestAnimationFrame(()=>{this.overlay.classList.add("is-open"),this.focusTrap.activate(this.confirmBtn),this.escapeCleanup=w(this.dialog,[{key:y.Escape,handler:()=>this.close()}])})}close(){this.overlay.classList.remove("is-open"),this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap.deactivate(),setTimeout(()=>{var t,e;this.overlay.style.display="none",(e=(t=this.options).onClose)==null||e.call(t)},300)}destroy(){this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap.deactivate(),this.overlay.remove()}}function ls(o){return new Pt(o)}class Dt{constructor(t={}){c(this,"overlay");c(this,"drawer");c(this,"options");c(this,"focusTrap");c(this,"escapeCleanup",null);this.options={direction:"right",showClose:!0,...t},this.overlay=document.createElement("div"),this.overlay.className="mk-drawer-overlay",this.overlay.style.display="none",this.drawer=document.createElement("div"),this.drawer.className=`mk-drawer mk-drawer--${this.options.direction}`,this.drawer.setAttribute("role","dialog"),this.drawer.setAttribute("aria-modal","true"),this.options.size&&(this.options.direction==="right"||this.options.direction==="left"?this.drawer.style.width=`${this.options.size}px`:this.drawer.style.height=`${this.options.size}px`);const e=document.createElement("div");e.className="mk-drawer__header";const s=document.createElement("span");if(s.className="mk-drawer__title",s.textContent=this.options.title||"",e.appendChild(s),this.options.showClose){const n=document.createElement("span");n.className="mk-drawer__close",n.innerHTML="✕",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Close"),n.addEventListener("click",()=>this.close()),n.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),this.close())}),e.appendChild(n)}this.drawer.appendChild(e);const i=document.createElement("div");i.className="mk-drawer__body",typeof this.options.content=="string"?i.innerHTML=this.options.content:this.options.content&&i.appendChild(this.options.content),this.drawer.appendChild(i),this.overlay.appendChild(this.drawer),this.overlay.addEventListener("click",n=>{n.target===this.overlay&&this.close()}),document.body.appendChild(this.overlay),this.focusTrap=new M(this.drawer)}open(){this.overlay.style.display="block",requestAnimationFrame(()=>{this.overlay.classList.add("is-open"),this.focusTrap.activate(),this.escapeCleanup=w(this.drawer,[{key:y.Escape,handler:()=>this.close()}])})}close(){this.overlay.classList.remove("is-open"),this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap.deactivate(),setTimeout(()=>{var t,e;this.overlay.style.display="none",(e=(t=this.options).onClose)==null||e.call(t)},300)}destroy(){this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap.deactivate(),this.overlay.remove()}}function cs(o){return new Dt(o)}const ds={success:"✓",warning:"!",error:"✕",info:"i"},hs={success:"#67c23a",warning:"#e6a23c",error:"#f56c6c",info:"#409eff"};let C=null;function us(){return C||(C=document.createElement("div"),C.className="mk-message-container",document.body.appendChild(C)),C}function I(o,t={}){const e={type:"info",duration:3e3,closable:!0,...t},s=document.createElement("div");s.className=`mk-message mk-message--${e.type}`;const i=document.createElement("span");i.className="mk-message__icon",i.style.color=hs[e.type],i.textContent=ds[e.type],s.appendChild(i);const n=document.createElement("span");if(n.className="mk-message__content",n.textContent=o,s.appendChild(n),e.closable){const a=document.createElement("span");a.className="mk-message__close",a.innerHTML="✕",a.addEventListener("click",()=>D(s)),s.appendChild(a)}us().appendChild(s),requestAnimationFrame(()=>s.classList.add("is-show"));const r=setTimeout(()=>D(s),e.duration);return()=>{clearTimeout(r),D(s)}}function D(o){o.classList.remove("is-show"),o.style.opacity="0",o.style.transform="translateY(-20px) scale(0.95)",setTimeout(()=>{o.remove(),C&&C.children.length===0&&(C.remove(),C=null)},300)}function ps(o,t){return I(o,{...t,type:"success"})}function ms(o,t){return I(o,{...t,type:"error"})}function fs(o,t){return I(o,{...t,type:"warning"})}class qt{constructor(t,e={}){c(this,"el");c(this,"core");c(this,"options");c(this,"_value");c(this,"activeLabel");c(this,"_cleanupKey");c(this,"inactiveLabel");const s=typeof t=="string"?document.querySelector(t):t;this.options={value:!1,...e},this._value=this.options.value,this.el=document.createElement("label"),this.el.className="mk-switch",this._value&&this.el.classList.add("is-checked"),this.options.disabled&&this.el.classList.add("is-disabled"),this.el.setAttribute("role","switch"),this.el.setAttribute("aria-checked",String(this._value)),this.options.disabled||this.el.setAttribute("tabindex","0"),this.options.inactiveText&&(this.inactiveLabel=document.createElement("span"),this.inactiveLabel.className="mk-switch__label",this.inactiveLabel.textContent=this.options.inactiveText,this._value||this.inactiveLabel.classList.add("mk-switch__label--active"),this.el.appendChild(this.inactiveLabel)),this.core=document.createElement("div"),this.core.className="mk-switch__core",this.el.appendChild(this.core),this.options.activeText&&(this.activeLabel=document.createElement("span"),this.activeLabel.className="mk-switch__label",this.activeLabel.textContent=this.options.activeText,this._value&&this.activeLabel.classList.add("mk-switch__label--active"),this.el.appendChild(this.activeLabel)),this.el.addEventListener("click",()=>{this.options.disabled||this.toggle()}),this._cleanupKey=w(this.el,[{key:y.Enter,handler:()=>this.toggle()},{key:y.Space,handler:()=>this.toggle()}]),s.appendChild(this.el)}get value(){return this._value}set value(t){var e,s,i,n;this._value!==t&&(this._value=t,this.el.classList.toggle("is-checked",t),this.el.setAttribute("aria-checked",String(t)),(e=this.activeLabel)==null||e.classList.toggle("mk-switch__label--active",t),(s=this.inactiveLabel)==null||s.classList.toggle("mk-switch__label--active",!t),(n=(i=this.options).onChange)==null||n.call(i,t))}toggle(){this.value=!this._value}destroy(){var t;(t=this._cleanupKey)==null||t.call(this),this.el.remove()}}function ys(o,t){return new qt(o,t)}function zt(o={}){const t=document.createElement("div");if(t.className="mk-loading-mask",o.fullscreen)t.classList.add("is-fullscreen"),document.body.appendChild(t);else{const s=typeof o.target=="string"?document.querySelector(o.target):o.target||document.body;s&&s!==document.body&&(s.style.position="relative"),(s||document.body).appendChild(t)}const e=document.createElement("div");if(e.className="mk-loading__spinner",t.appendChild(e),o.text){const s=document.createElement("div");s.className="mk-loading__text",s.textContent=o.text,t.appendChild(s)}return()=>{t.remove()}}function gs(o){return zt({fullscreen:!0,text:o})}class Ft{constructor(t,e){c(this,"el");c(this,"trigger");c(this,"dropdown");c(this,"options");c(this,"_value");c(this,"isOpen",!1);c(this,"_cleanupKey");const s=typeof t=="string"?document.querySelector(t):t;this.options=e,this._value=e.value,this.el=document.createElement("div"),this.el.className="mk-select",this.trigger=document.createElement("div"),this.trigger.className="mk-select__trigger",this.trigger.setAttribute("role","combobox"),this.trigger.setAttribute("aria-haspopup","listbox"),this.trigger.setAttribute("aria-expanded","false"),this.trigger.setAttribute("tabindex","0"),this.trigger.addEventListener("click",()=>this.toggle());const i=document.createElement("span");i.className="mk-select__label",this.updateLabel(i),this.trigger.appendChild(i);const n=document.createElement("span");n.className="mk-select__arrow",n.textContent="▼",this.trigger.appendChild(n),this.dropdown=document.createElement("div"),this.dropdown.className="mk-select__dropdown",this.dropdown.setAttribute("role","listbox"),e.options.forEach(r=>{const a=document.createElement("div");a.className="mk-select__option",a.textContent=r.label,a.setAttribute("role","option"),a.setAttribute("aria-selected",String(r.value===this._value)),r.disabled&&(a.setAttribute("aria-disabled","true"),a.style.opacity="0.4",a.style.pointerEvents="none"),a.addEventListener("click",()=>{this.setValue(r.value),this.close()}),this.dropdown.appendChild(a)}),this.el.appendChild(this.trigger),this.el.appendChild(this.dropdown),s.appendChild(this.el),this._cleanupKey=w(this.trigger,[{key:y.ArrowDown,handler:()=>this.moveSelection(1)},{key:y.ArrowUp,handler:()=>this.moveSelection(-1)},{key:y.Enter,handler:()=>{this.isOpen?this.close():this.open()}},{key:y.Escape,handler:()=>this.close()}]),document.addEventListener("click",r=>{this.el.contains(r.target)||this.close()})}updateLabel(t){const e=this.options.options.find(s=>s.value===this._value);e?(t.textContent=e.label,t.classList.remove("mk-select__placeholder")):(t.textContent=this.options.placeholder||"请选择",t.classList.add("mk-select__placeholder"))}get value(){return this._value}setValue(t){var s,i;this._value=t;const e=this.trigger.querySelector(".mk-select__label");this.updateLabel(e),this.renderOptions(),(i=(s=this.options).onChange)==null||i.call(s,t)}renderOptions(){this.dropdown.querySelectorAll(".mk-select__option").forEach((e,s)=>{const i=this.options.options[s];e.classList.toggle("is-selected",i.value===this._value),e.setAttribute("aria-selected",String(i.value===this._value))})}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.trigger.setAttribute("aria-expanded","true"),this.trigger.classList.add("is-open"),this.dropdown.classList.add("is-open"),this.renderOptions()}close(){this.isOpen=!1,this.trigger.setAttribute("aria-expanded","false"),this.trigger.classList.remove("is-open"),this.dropdown.classList.remove("is-open")}moveSelection(t){this.isOpen||this.open();let s=this.options.options.findIndex(i=>i.value===this._value);for(let i=0;i<this.options.options.length;i++)if(s=(s+t+this.options.options.length)%this.options.options.length,!this.options.options[s].disabled){this.setValue(this.options.options[s].value);return}}destroy(){var t;(t=this._cleanupKey)==null||t.call(this),this.el.remove()}}function vs(o,t){return new Ft(o,t)}class q{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"_checked");c(this,"_cleanupKey");const s=typeof t=="string"?document.querySelector(t):t;this.options={checked:!1,...e},this._checked=this.options.checked,this.el=document.createElement("label"),this.el.className="mk-checkbox",this._checked&&this.el.classList.add("is-checked"),this.options.disabled&&this.el.classList.add("is-disabled"),this.el.setAttribute("role","checkbox"),this.el.setAttribute("aria-checked",String(this._checked)),this.options.disabled||this.el.setAttribute("tabindex","0");const i=document.createElement("span");i.className="mk-checkbox__input";const n=document.createElement("span");if(n.className="mk-checkbox__check",n.textContent="✓",i.appendChild(n),this.el.appendChild(i),this.options.label){const r=document.createElement("span");r.textContent=this.options.label,this.el.appendChild(r)}this.el.addEventListener("click",()=>{this.options.disabled||this.toggle()}),this._cleanupKey=w(this.el,[{key:y.Space,handler:()=>this.toggle()}]),s.appendChild(this.el)}get checked(){return this._checked}set checked(t){var e,s;this._checked=t,this.el.classList.toggle("is-checked",t),this.el.setAttribute("aria-checked",String(t)),(s=(e=this.options).onChange)==null||s.call(e,t)}toggle(){this.checked=!this._checked}destroy(){var t;(t=this._cleanupKey)==null||t.call(this),this.el.remove()}}function bs(o,t){return new q(o,t)}class Es{constructor(t){c(this,"el");c(this,"checkboxes",[]);const e=typeof t=="string"?document.querySelector(t):t;this.el=document.createElement("div"),this.el.className="mk-checkbox-group",e.appendChild(this.el)}add(t){const e=new q(this.el,t);return this.checkboxes.push(e),e}getValues(){return this.checkboxes.map(t=>t.checked)}destroy(){this.el.remove()}}class Rt{constructor(t,e){c(this,"el");c(this,"options");c(this,"_checked");const s=typeof t=="string"?document.querySelector(t):t;this.options={checked:!1,...e},this._checked=this.options.checked,this.el=document.createElement("label"),this.el.className="mk-radio",this._checked&&this.el.classList.add("is-checked"),this.options.disabled&&this.el.classList.add("is-disabled"),this.el.setAttribute("role","radio"),this.el.setAttribute("aria-checked",String(this._checked));const i=document.createElement("span");i.className="mk-radio__input";const n=document.createElement("span");if(n.className="mk-radio__dot",i.appendChild(n),this.el.appendChild(i),this.options.label){const r=document.createElement("span");r.textContent=this.options.label,this.el.appendChild(r)}this.el.addEventListener("click",()=>{var r,a;this.options.disabled||(a=(r=this.options).onChange)==null||a.call(r,this.options.value)}),s.appendChild(this.el)}setChecked(t){this._checked=t,this.el.classList.toggle("is-checked",t),this.el.setAttribute("aria-checked",String(t))}getValue(){return this.options.value}destroy(){this.el.remove()}}class ks{constructor(t,e={}){c(this,"el");c(this,"radios",[]);c(this,"_value");c(this,"_cleanupKey");const s=typeof t=="string"?document.querySelector(t):t;this._value=e.value,this.el=document.createElement("div"),this.el.className="mk-radio-group",this.el.setAttribute("role","radiogroup"),s.appendChild(this.el),this._cleanupKey=w(this.el,[{key:y.ArrowUp,handler:()=>this.focusRadio(-1)},{key:y.ArrowLeft,handler:()=>this.focusRadio(-1)},{key:y.ArrowDown,handler:()=>this.focusRadio(1)},{key:y.ArrowRight,handler:()=>this.focusRadio(1)}])}add(t){const e=new Rt(this.el,{...t,onChange:i=>{this.setValue(i)}}),s=t.value===this._value;return e.setChecked(s),this._value===void 0&&this.radios.length===0?e.el.setAttribute("tabindex","0"):e.el.setAttribute("tabindex",s?"0":"-1"),this.radios.push(e),e}setValue(t){this._value=t,this.radios.forEach(e=>{const s=e.getValue()===t;e.setChecked(s),e.el.setAttribute("tabindex",s?"0":"-1")})}getValue(){return this._value}focusRadio(t){let e=this.radios.findIndex(i=>i.el.getAttribute("tabindex")==="0");e===-1&&(e=this.radios.findIndex(i=>i.el.classList.contains("is-checked"))),e===-1&&(e=0);let s=e;for(let i=0;i<this.radios.length&&(s=(s+t+this.radios.length)%this.radios.length,!!this.radios[s].el.classList.contains("is-disabled"));i++);(s!==e||this.radios.length===1)&&(this.radios.forEach((i,n)=>i.el.setAttribute("tabindex",n===s?"0":"-1")),this.radios[s].el.focus(),this.setValue(this.radios[s].getValue()))}destroy(){var t;(t=this._cleanupKey)==null||t.call(this),this.el.remove()}}class ws{constructor(t,e={}){c(this,"el");c(this,"track");c(this,"fill");c(this,"thumb");c(this,"valueEl");c(this,"options");c(this,"_value");c(this,"dragging",!1);c(this,"_cleanupKey");const s=typeof t=="string"?document.querySelector(t):t;this.options={min:0,max:100,step:1,value:0,showValue:!0,...e},this._value=this.options.value,this.el=document.createElement("div"),this.el.className="mk-slider",this.track=document.createElement("div"),this.track.className="mk-slider__track",this.fill=document.createElement("div"),this.fill.className="mk-slider__fill",this.track.appendChild(this.fill),this.thumb=document.createElement("div"),this.thumb.className="mk-slider__thumb",this.thumb.setAttribute("role","slider"),this.thumb.setAttribute("tabindex","0"),this.track.appendChild(this.thumb),this.el.appendChild(this.track),this.options.showValue&&(this.valueEl=document.createElement("div"),this.valueEl.className="mk-slider__value",this.el.appendChild(this.valueEl)),this.updateUI(),this._cleanupKey=w(this.thumb,[{key:y.ArrowLeft,handler:()=>this.adjustValue(-this.options.step)},{key:y.ArrowRight,handler:()=>this.adjustValue(this.options.step)},{key:y.Home,handler:()=>{this.value=this.options.min}},{key:y.End,handler:()=>{this.value=this.options.max}}]),this.track.addEventListener("mousedown",i=>this.onStart(i.clientX)),this.thumb.addEventListener("mousedown",i=>{i.stopPropagation(),this.onStart(i.clientX)}),document.addEventListener("mousemove",i=>this.onMove(i.clientX)),document.addEventListener("mouseup",()=>this.onEnd()),this.track.addEventListener("touchstart",i=>this.onStart(i.touches[0].clientX),{passive:!0}),document.addEventListener("touchmove",i=>this.onMove(i.touches[0].clientX),{passive:!0}),document.addEventListener("touchend",()=>this.onEnd()),s.appendChild(this.el)}onStart(t){this.dragging=!0,this.updateFromPosition(t)}onMove(t){this.dragging&&this.updateFromPosition(t)}onEnd(){this.dragging=!1}updateFromPosition(t){const e=this.track.getBoundingClientRect(),s=Math.max(0,Math.min(1,(t-e.left)/e.width)),i=this.options.min+s*(this.options.max-this.options.min),n=Math.round(i/this.options.step)*this.options.step;this.value=Math.max(this.options.min,Math.min(this.options.max,n))}get value(){return this._value}set value(t){var e,s;this._value!==t&&(this._value=t,this.updateUI(),(s=(e=this.options).onChange)==null||s.call(e,t))}updateUI(){const t=(this._value-this.options.min)/(this.options.max-this.options.min);this.fill.style.width=`${t*100}%`,this.thumb.style.left=`${t*100}%`,this.valueEl&&(this.valueEl.textContent=String(this._value)),this.updateAria()}updateAria(){this.thumb.setAttribute("aria-valuenow",String(this._value)),this.thumb.setAttribute("aria-valuemin",String(this.options.min)),this.thumb.setAttribute("aria-valuemax",String(this.options.max))}adjustValue(t){this.value=Math.max(this.options.min,Math.min(this.options.max,this._value+t))}destroy(){var t;(t=this._cleanupKey)==null||t.call(this),this.el.remove()}}class Cs{constructor(t,e){c(this,"el");c(this,"table");c(this,"tbody");c(this,"columns");c(this,"data");c(this,"pageSize");c(this,"currentPage",1);c(this,"sortState",null);c(this,"editingRow",null);c(this,"editCache",null);c(this,"filteredData");c(this,"callbacks");const s=typeof t=="string"?document.querySelector(t):t;this.columns=e.columns,this.data=e.data,this.pageSize=e.pageSize||10,this.filteredData=[...this.data],this.callbacks=e,this.el=document.createElement("div"),this.el.className="mk-table-wrapper",this.table=document.createElement("table"),this.table.className="mk-table",this.table.setAttribute("role","table");const i=document.createElement("thead");i.setAttribute("role","rowgroup");const n=document.createElement("tr");n.setAttribute("role","row"),this.columns.forEach(r=>{const a=document.createElement("th");if(a.setAttribute("role","columnheader"),a.textContent=r.title,r.width&&(a.style.width=r.width),r.sortable){a.classList.add("is-sortable"),a.setAttribute("aria-sort","none");const l=document.createElement("span");l.className="mk-table__sort-icon",l.textContent="⇅",a.appendChild(l),a.addEventListener("click",()=>this.handleSort(r.key))}n.appendChild(a)}),i.appendChild(n),this.table.appendChild(i),this.tbody=document.createElement("tbody"),this.tbody.setAttribute("role","rowgroup"),this.table.appendChild(this.tbody),this.el.appendChild(this.table),s.appendChild(this.el),this.render()}getDisplayData(){return this.sortState?[...this.filteredData].sort((e,s)=>{const i=e[this.sortState.key],n=s[this.sortState.key];return i<n?this.sortState.order==="asc"?-1:1:i>n?this.sortState.order==="asc"?1:-1:0}):this.filteredData}handleSort(t){!this.sortState||this.sortState.key!==t?this.sortState={key:t,order:"asc"}:this.sortState.order==="asc"?this.sortState.order="desc":this.sortState=null,this.render()}render(){this.tbody.innerHTML="";const t=this.getDisplayData(),e=(this.currentPage-1)*this.pageSize,s=t.slice(e,e+this.pageSize);if(s.length===0){const i=document.createElement("tr");i.setAttribute("role","row");const n=document.createElement("td");n.setAttribute("role","cell"),n.colSpan=this.columns.length,n.className="mk-table__empty",n.textContent="暂无数据",i.appendChild(n),this.tbody.appendChild(i)}else s.forEach((i,n)=>{const r=e+n,a=document.createElement("tr");a.setAttribute("role","row"),this.editingRow===r&&a.classList.add("is-editing"),a.addEventListener("click",()=>{var l,d;(d=(l=this.callbacks).onRowClick)==null||d.call(l,i,r)}),this.columns.forEach(l=>{const d=document.createElement("td");if(d.setAttribute("role","cell"),this.editingRow===r&&l.editable&&l.key!=="actions"){const u=document.createElement("input");u.className="mk-table__edit-input",u.value=String(this.editCache[l.key]??i[l.key]??""),u.addEventListener("input",p=>{this.editCache[l.key]=p.target.value}),u.addEventListener("keydown",p=>{p.key==="Enter"&&this.saveEdit(),p.key==="Escape"&&this.cancelEdit()}),d.appendChild(u)}else if(l.render){const u=l.render(i[l.key],i,r);u instanceof HTMLElement?d.appendChild(u):typeof u=="string"&&u.includes("<")?d.innerHTML=u:d.textContent=String(u)}else d.textContent=i[l.key]!==void 0?String(i[l.key]):"";a.appendChild(d)}),this.tbody.appendChild(a)});this.renderPagination(t.length),this.updateSortIcons()}updateSortIcons(){const t=this.table.querySelectorAll("th");if(t.forEach(e=>{const s=e.querySelector(".mk-table__sort-icon");s&&(s.classList.remove("is-active"),s.textContent="⇅",e.setAttribute("aria-sort","none"))}),this.sortState){const e=this.columns.findIndex(s=>s.key===this.sortState.key);if(e>=0){const s=t[e],i=s==null?void 0:s.querySelector(".mk-table__sort-icon");i&&(i.classList.add("is-active"),i.textContent=this.sortState.order==="asc"?"↑":"↓"),s&&s.setAttribute("aria-sort",this.sortState.order==="asc"?"ascending":"descending")}}}renderPagination(t){const e=this.el.querySelector(".mk-pagination");e==null||e.remove();const s=Math.max(1,Math.ceil(t/this.pageSize)),i=document.createElement("div");i.className="mk-pagination";const n=document.createElement("span");n.className="mk-pagination__total",n.textContent=`共 ${t} 条`,i.appendChild(n);const r=document.createElement("button");r.className="mk-pagination__btn",r.textContent="‹",r.disabled=this.currentPage<=1,r.addEventListener("click",()=>{this.currentPage>1&&(this.currentPage--,this.render())}),i.appendChild(r);const a=5;let l=Math.max(1,this.currentPage-Math.floor(a/2)),d=Math.min(s,l+a-1);if(d-l+1<a&&(l=Math.max(1,d-a+1)),l>1&&(i.appendChild(this.createPageBtn(1)),l>2)){const m=document.createElement("span");m.className="mk-pagination__btn",m.textContent="...",m.style.cursor="default",i.appendChild(m)}for(let m=l;m<=d;m++)i.appendChild(this.createPageBtn(m));if(d<s){if(d<s-1){const m=document.createElement("span");m.className="mk-pagination__btn",m.textContent="...",m.style.cursor="default",i.appendChild(m)}i.appendChild(this.createPageBtn(s))}const u=document.createElement("button");u.className="mk-pagination__btn",u.textContent="›",u.disabled=this.currentPage>=s,u.addEventListener("click",()=>{this.currentPage<s&&(this.currentPage++,this.render())}),i.appendChild(u);const p=document.createElement("span");p.className="mk-pagination__size",p.innerHTML=`
|
|
135
|
+
每页
|
|
136
|
+
<select>
|
|
137
|
+
<option value="10" ${this.pageSize===10?"selected":""}>10</option>
|
|
138
|
+
<option value="20" ${this.pageSize===20?"selected":""}>20</option>
|
|
139
|
+
<option value="50" ${this.pageSize===50?"selected":""}>50</option>
|
|
140
|
+
</select>
|
|
141
|
+
条
|
|
142
|
+
`,p.querySelector("select").addEventListener("change",m=>{this.pageSize=Number(m.target.value),this.currentPage=1,this.render()}),i.appendChild(p),this.el.appendChild(i)}createPageBtn(t){const e=document.createElement("button");return e.className="mk-pagination__btn",e.textContent=String(t),t===this.currentPage&&e.classList.add("is-active"),e.addEventListener("click",()=>{this.currentPage=t,this.render()}),e}setData(t){this.data=t,this.filteredData=[...t],this.currentPage=1,this.render()}filter(t){this.filteredData=this.data.filter(t),this.currentPage=1,this.render()}clearFilter(){this.filteredData=[...this.data],this.currentPage=1,this.render()}startEdit(t){this.editingRow=t,this.editCache={...this.filteredData[t]},this.render();const e=this.tbody.querySelector(".mk-table__edit-input");e==null||e.focus()}saveEdit(){var t,e;if(this.editingRow!==null&&this.editCache){const s=this.editCache;this.filteredData[this.editingRow]=s;const i=this.data.findIndex((n,r)=>r===this.editingRow||JSON.stringify(n)===JSON.stringify(s));i>=0&&(this.data[i]=s),(e=(t=this.callbacks).onEdit)==null||e.call(t,s,this.editingRow)}this.editingRow=null,this.editCache=null,this.render()}cancelEdit(){this.editingRow=null,this.editCache=null,this.render()}deleteRow(t){var s,i;const e=this.filteredData[t];this.data=this.data.filter(n=>n!==e),this.filteredData=this.filteredData.filter(n=>n!==e),(i=(s=this.callbacks).onDelete)==null||i.call(s,e,t),this.filteredData.length<=(this.currentPage-1)*this.pageSize&&this.currentPage>1&&this.currentPage--,this.render()}destroy(){this.el.remove()}}class Ot{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"motion",null);c(this,"_cleanupCloseKey");const s=typeof t=="string"?document.querySelector(t):t;if(this.options={type:"default",size:"default",...e},this.el=document.createElement("span"),this.el.className=this.buildClass(),this.options.text&&(this.el.textContent=this.options.text),this.options.closable){const i=document.createElement("span");i.className="mk-tag__close",i.innerHTML="×",i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i.setAttribute("aria-label","Close"),i.addEventListener("click",n=>{n.stopPropagation(),this.close()}),this._cleanupCloseKey=w(i,[{key:y.Enter,handler:()=>this.close()},{key:y.Space,handler:()=>this.close()}]),this.el.appendChild(i)}s.appendChild(this.el),this.motion=T(this.el,e.motion||{hover:"scale",enter:"zoomIn",duration:200})}buildClass(){const t=["mk-tag"];return this.options.type&&this.options.type!=="default"&&t.push(`mk-tag--${this.options.type}`),this.options.size&&this.options.size!=="default"&&t.push(`mk-tag--${this.options.size}`),this.options.plain&&t.push("is-plain"),this.options.round&&t.push("is-round"),this.options.closable&&t.push("is-closable"),t.join(" ")}setText(t){if(this.options.text=t,this.options.closable){const e=this.el.querySelector(".mk-tag__close");this.el.childNodes.forEach(s=>{s!==e&&s.remove()}),this.el.insertBefore(document.createTextNode(t),e)}else this.el.textContent=t}close(){var t,e,s;this.el.style.pointerEvents="none",(t=this.motion)==null||t.playExit().then(()=>{this.destroy()}),(s=(e=this.options).onClose)==null||s.call(e)}destroy(){var t,e;(t=this._cleanupCloseKey)==null||t.call(this),(e=this.motion)==null||e.destroy(),this.el.remove()}}function xs(o,t){return new Ot(o,t)}let E=null,z=null,F=null,L=null,N=null,_=null;const Ht="mk-tooltip";function R(){return E||(E=document.createElement("div"),E.className="mk-tooltip",E.id=Ht,E.setAttribute("role","tooltip"),E.style.position="absolute",E.style.zIndex="var(--mk-z-tooltip)",z=document.createElement("div"),z.className="mk-tooltip__arrow",E.appendChild(z),F=document.createElement("div"),F.className="mk-tooltip__content",E.appendChild(F),document.body.appendChild(E)),E}function Ls(o){const e=R().querySelector(".mk-tooltip__content");e.innerHTML="",typeof o=="string"?e.textContent=o:e.appendChild(o)}function _s(o,t,e){const s=R(),i=s.querySelector(".mk-tooltip__arrow"),n=o.getBoundingClientRect(),r=s.getBoundingClientRect(),a=window.scrollX,l=window.scrollY;let d=0,u=0,p="";switch(t){case"top":d=n.top+l-r.height-e,u=n.left+a+n.width/2-r.width/2,p="is-bottom";break;case"bottom":d=n.bottom+l+e,u=n.left+a+n.width/2-r.width/2,p="is-top";break;case"left":d=n.top+l+n.height/2-r.height/2,u=n.left+a-r.width-e,p="is-right";break;case"right":d=n.top+l+n.height/2-r.height/2,u=n.right+a+e,p="is-left";break;default:d=n.top+l-r.height-e,u=n.left+a+n.width/2-r.width/2,p="is-bottom"}const m=8;u<m&&(u=m),u+r.width>window.innerWidth-m&&(u=window.innerWidth-r.width-m),d<m&&(d=m),s.style.top=`${d}px`,s.style.left=`${u}px`,i.className=`mk-tooltip__arrow ${p}`}function Ts(o,t){N&&(clearTimeout(N),N=null),_=o,o.setAttribute("aria-describedby",Ht),Ls(t.content);const e=R();e.classList.remove("is-visible"),e.style.visibility="hidden",e.style.display="block",requestAnimationFrame(()=>{_===o&&(_s(o,t.placement,t.offset),e.style.visibility="visible",e.classList.add("is-visible"))})}function Yt(){E&&(E.classList.remove("is-visible"),N=setTimeout(()=>{E!=null&&E.classList.contains("is-visible")||(E.style.display="none")},200),_&&_.removeAttribute("aria-describedby"),_=null)}function Ss(o,t={}){const e={content:"",placement:"top",delay:150,offset:8,...t},s=()=>{L&&clearTimeout(L),L=setTimeout(()=>{Ts(o,e)},e.delay)},i=()=>{L&&(clearTimeout(L),L=null),Yt()};return o.addEventListener("mouseenter",s),o.addEventListener("mouseleave",i),o.addEventListener("focus",s),o.addEventListener("blur",i),()=>{o.removeEventListener("mouseenter",s),o.removeEventListener("mouseleave",i),o.removeEventListener("focus",s),o.removeEventListener("blur",i),_===o&&Yt()}}let As=0;class Xt{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"headerEl");c(this,"contentEl");c(this,"indicatorEl",null);c(this,"tabItems",[]);c(this,"panels",[]);c(this,"currentIndex");c(this,"tabIdPrefix");const s=typeof t=="string"?document.querySelector(t):t;this.options={type:"line",items:[],activeIndex:0,...e},this.currentIndex=this.options.activeIndex,this.tabIdPrefix=`mk-tabs-${++As}`,this.el=document.createElement("div"),this.el.className=`mk-tabs mk-tabs--${this.options.type}`,this.headerEl=document.createElement("div"),this.headerEl.className="mk-tabs__header",this.headerEl.setAttribute("role","tablist"),this.el.appendChild(this.headerEl),this.contentEl=document.createElement("div"),this.contentEl.className="mk-tabs__content",this.el.appendChild(this.contentEl),this.options.type==="line"&&(this.indicatorEl=document.createElement("div"),this.indicatorEl.className="mk-tabs__indicator",this.headerEl.appendChild(this.indicatorEl)),this.renderTabs(),this.setActive(this.currentIndex,!1),s.appendChild(this.el)}renderTabs(){var t;(t=this.options.items)==null||t.forEach((e,s)=>{const i=`${this.tabIdPrefix}-panel-${s}`,n=`${this.tabIdPrefix}-tab-${s}`,r=document.createElement("button");r.className="mk-tabs__item",r.type="button",r.textContent=e.label,r.id=n,r.setAttribute("role","tab"),r.setAttribute("aria-controls",i),e.disabled&&(r.disabled=!0,r.classList.add("is-disabled")),r.addEventListener("click",()=>{e.disabled||this.setActive(s)}),this.headerEl.appendChild(r),this.tabItems.push(r);const a=document.createElement("div");a.className="mk-tabs__panel",a.id=i,a.setAttribute("role","tabpanel"),a.setAttribute("aria-labelledby",n),e.content&&(typeof e.content=="string"?a.textContent=e.content:a.appendChild(e.content)),this.contentEl.appendChild(a),this.panels.push(a)}),this.headerEl.addEventListener("keydown",e=>{if(![y.ArrowLeft,y.ArrowRight,y.Home,y.End].includes(e.key))return;const s=this.tabItems.filter((l,d)=>{var u,p;return!((p=(u=this.options.items)==null?void 0:u[d])!=null&&p.disabled)}),i=this.tabItems[this.currentIndex];let n=s.indexOf(i);n===-1&&(n=0);let r=n;switch(e.key){case y.ArrowLeft:e.preventDefault(),r=n>0?n-1:s.length-1;break;case y.ArrowRight:e.preventDefault(),r=n<s.length-1?n+1:0;break;case y.Home:e.preventDefault(),r=0;break;case y.End:e.preventDefault(),r=s.length-1;break}const a=s[r];if(a){const l=this.tabItems.indexOf(a);this.setActive(l),a.focus()}})}setActive(t,e=!0){var i,n,r,a;if(t<0||t>=this.tabItems.length||(n=(i=this.options.items)==null?void 0:i[t])!=null&&n.disabled)return;const s=this.currentIndex;this.currentIndex=t,this.tabItems.forEach((l,d)=>{const u=d===t;l.classList.toggle("is-active",u),l.setAttribute("aria-selected",String(u)),l.setAttribute("tabindex",u?"0":"-1")}),this.panels.forEach((l,d)=>{const u=d===t;l.classList.toggle("is-active",u),u?(l.style.display="block",e&&requestAnimationFrame(()=>{l.classList.add("is-entering"),requestAnimationFrame(()=>{l.classList.remove("is-entering")})})):(l.style.display="none",l.classList.remove("is-entering"))}),this.indicatorEl&&this.updateIndicator(),s!==t&&((a=(r=this.options).onChange)==null||a.call(r,t))}updateIndicator(){if(!this.indicatorEl)return;const t=this.tabItems[this.currentIndex];if(!t)return;const e=this.headerEl.getBoundingClientRect(),s=t.getBoundingClientRect();this.indicatorEl.style.left=`${s.left-e.left+this.headerEl.scrollLeft}px`,this.indicatorEl.style.width=`${s.width}px`}getActive(){return this.currentIndex}destroy(){this.el.remove()}}function $s(o,t){return new Xt(o,t)}class Ut{constructor(t,e={}){c(this,"el");c(this,"options");const s=typeof t=="string"?document.querySelector(t):t;if(this.options={size:"default",shape:"circle",...e},this.el=document.createElement("div"),this.el.className=this.buildClass(),this.options.src){const i=document.createElement("img");i.className="mk-avatar__image",i.src=this.options.src,i.alt=this.options.text||"",i.addEventListener("error",()=>this.showFallback()),this.el.appendChild(i)}else this.showFallback();s.appendChild(this.el)}buildClass(){const t=["mk-avatar"];return this.options.size&&this.options.size!=="default"&&t.push(`mk-avatar--${this.options.size}`),this.options.shape&&this.options.shape!=="circle"&&t.push(`mk-avatar--${this.options.shape}`),t.join(" ")}showFallback(){const t=this.el.querySelector(".mk-avatar__image");t&&t.remove();const e=document.createElement("span");e.className="mk-avatar__fallback",this.options.icon?e.textContent=this.options.icon:this.options.text?e.textContent=this.options.text.split(" ").map(s=>s[0]).slice(0,2).join("").toUpperCase():e.textContent="?",this.el.appendChild(e)}setSrc(t){this.options.src=t;const e=this.el.querySelector(".mk-avatar__fallback");e&&e.remove();let s=this.el.querySelector(".mk-avatar__image");s||(s=document.createElement("img"),s.className="mk-avatar__image",s.alt=this.options.text||"",s.addEventListener("error",()=>this.showFallback()),this.el.appendChild(s)),s.src=t}setText(t){this.options.text=t,this.options.src||this.showFallback()}destroy(){this.el.remove()}}function Ms(o,t){return new Ut(o,t)}const Is={info:"ℹ",success:"✓",warning:"⚠",danger:"✕"};class Bt{constructor(t,e={}){c(this,"el");c(this,"options");const s=typeof t=="string"?document.querySelector(t):t;if(this.options={type:"info",showIcon:!0,...e},this.el=document.createElement("div"),this.el.className=this.buildClass(),this.el.setAttribute("role","alert"),this.options.showIcon){const n=document.createElement("span");n.className="mk-alert__icon",n.textContent=Is[this.options.type],this.el.appendChild(n)}const i=document.createElement("div");if(i.className="mk-alert__content",this.options.title){const n=document.createElement("div");n.className="mk-alert__title",n.textContent=this.options.title,i.appendChild(n)}if(this.options.description){const n=document.createElement("div");n.className="mk-alert__description",n.textContent=this.options.description,i.appendChild(n)}if(this.el.appendChild(i),this.options.closable){const n=document.createElement("button");n.className="mk-alert__close",n.setAttribute("aria-label","Close"),n.innerHTML="×",n.addEventListener("click",()=>this.close()),this.el.appendChild(n)}s.appendChild(this.el)}buildClass(){const t=["mk-alert",`mk-alert--${this.options.type}`];return this.options.closable&&t.push("is-closable"),t.join(" ")}close(){this.el.classList.add("is-closing"),this.el.style.pointerEvents="none",this.el.addEventListener("transitionend",()=>{var t,e;this.destroy(),(e=(t=this.options).onClose)==null||e.call(t)},{once:!0})}destroy(){this.el.remove()}}function Ns(o,t){return new Bt(o,t)}class Kt{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"barEl",null);c(this,"textEl",null);c(this,"circleSvg",null);c(this,"circleTrack",null);c(this,"circlePath",null);const s=typeof t=="string"?document.querySelector(t):t;this.options={type:"line",percent:0,showInfo:!0,...e},this.el=document.createElement("div"),this.el.className=this.buildClass(),this.options.type==="line"?this.renderLine():this.renderCircleOrDashboard(),s.appendChild(this.el),requestAnimationFrame(()=>{this.setPercent(this.options.percent)})}buildClass(){const t=["mk-progress",`mk-progress--${this.options.type}`];return this.options.status&&t.push(`is-${this.options.status}`),this.options.showInfo||t.push("is-hide-info"),t.join(" ")}renderLine(){const t=document.createElement("div");t.className="mk-progress__track",this.options.strokeWidth&&(t.style.height=`${this.options.strokeWidth}px`),this.barEl=document.createElement("div"),this.barEl.className="mk-progress__bar",t.appendChild(this.barEl),this.el.appendChild(t),this.options.showInfo&&(this.textEl=document.createElement("span"),this.textEl.className="mk-progress__text",this.el.appendChild(this.textEl))}renderCircleOrDashboard(){const e=this.options.strokeWidth||6,s=(120-e)/2,i=2*Math.PI*s,n=this.options.type==="dashboard",r=n?i*.75:i;this.circleSvg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.circleSvg.setAttribute("width","120"),this.circleSvg.setAttribute("height","120"),this.circleSvg.setAttribute("viewBox","0 0 120 120"),this.circleSvg.classList.add("mk-progress__svg"),this.circleTrack=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.circleTrack.setAttribute("cx",`${120/2}`),this.circleTrack.setAttribute("cy",`${120/2}`),this.circleTrack.setAttribute("r",`${s}`),this.circleTrack.setAttribute("fill","none"),this.circleTrack.setAttribute("stroke-width",`${e}`),this.circleTrack.classList.add("mk-progress__track-circle"),this.circlePath=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.circlePath.setAttribute("cx",`${120/2}`),this.circlePath.setAttribute("cy",`${120/2}`),this.circlePath.setAttribute("r",`${s}`),this.circlePath.setAttribute("fill","none"),this.circlePath.setAttribute("stroke-width",`${e}`),this.circlePath.setAttribute("stroke-linecap","round"),this.circlePath.style.strokeDasharray=`${r} ${i}`,this.circlePath.style.strokeDashoffset=`${r}`,this.circlePath.style.transformOrigin="50% 50%",n?(this.circleTrack.style.transform="rotate(135deg)",this.circleTrack.style.transformOrigin="50% 50%",this.circlePath.style.transform="rotate(135deg)"):(this.circleTrack.style.transform="rotate(-90deg)",this.circleTrack.style.transformOrigin="50% 50%",this.circlePath.style.transform="rotate(-90deg)"),this.circlePath.classList.add("mk-progress__path-circle"),this.circleSvg.appendChild(this.circleTrack),this.circleSvg.appendChild(this.circlePath),this.el.appendChild(this.circleSvg),this.options.showInfo&&(this.textEl=document.createElement("span"),this.textEl.className="mk-progress__text",this.el.appendChild(this.textEl))}setPercent(t){const e=Math.max(0,Math.min(100,t));if(this.options.percent=e,this.options.type==="line"&&this.barEl)this.barEl.style.width=`${e}%`,this.options.color&&(this.barEl.style.background=this.options.color);else if(this.circlePath&&this.circleSvg){const n=(120-(this.options.strokeWidth||6))/2,r=2*Math.PI*n,l=this.options.type==="dashboard"?r*.75:r,d=l-e/100*l;this.circlePath.style.strokeDashoffset=`${d}`,this.options.color&&(this.circlePath.style.stroke=this.options.color)}this.textEl&&(this.textEl.textContent=`${Math.round(e)}%`)}destroy(){this.el.remove()}}function Ps(o,t){return new Kt(o,t)}let Ds=0;class Wt{constructor(t,e){c(this,"el");c(this,"options");c(this,"activeKeys");c(this,"itemEls",[]);const s=typeof t=="string"?document.querySelector(t):t;this.options={accordion:!1,activeKeys:[],...e},this.activeKeys=new Set(this.options.activeKeys),this.el=document.createElement("div"),this.el.className="mk-collapse",this.options.items.forEach((i,n)=>{const r=`mk-collapse-content-${++Ds}`,a=document.createElement("div");a.className="mk-collapse__item",i.disabled&&a.classList.add("is-disabled");const l=document.createElement("div");l.className="mk-collapse__header",l.setAttribute("role","button"),l.setAttribute("tabindex",i.disabled?"-1":"0"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-controls",r);const d=document.createElement("span");d.className="mk-collapse__title",d.textContent=i.title;const u=document.createElement("span");u.className="mk-collapse__arrow",u.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 2l4 4-4 4"/></svg>',l.appendChild(d),l.appendChild(u),a.appendChild(l);const p=document.createElement("div");p.className="mk-collapse__content",p.id=r;const m=document.createElement("div");m.className="mk-collapse__inner",typeof i.content=="string"?m.innerHTML=i.content:m.appendChild(i.content),p.appendChild(m),a.appendChild(p),this.itemEls.push({header:l,content:p,inner:m,arrow:u,contentId:r}),this.el.appendChild(a),i.disabled||(l.addEventListener("click",()=>this.toggle(n)),l.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),this.toggle(n))}))}),s.appendChild(this.el),requestAnimationFrame(()=>{this.itemEls.forEach((i,n)=>{this.updateItemState(n)})})}toggle(t){const e=this.activeKeys.has(t);if(this.options.accordion){const s=Array.from(this.activeKeys);this.activeKeys.clear(),e||this.activeKeys.add(t),s.forEach(i=>this.updateItemState(i)),this.updateItemState(t)}else e?this.activeKeys.delete(t):this.activeKeys.add(t),this.updateItemState(t)}updateItemState(t){const e=this.itemEls[t];if(!e)return;const s=this.activeKeys.has(t),i=e.header.parentElement;e.header.setAttribute("aria-expanded",String(s)),e.arrow.classList.toggle("is-expanded",s),i.classList.toggle("is-active",s),s?e.content.style.maxHeight=`${e.inner.scrollHeight}px`:e.content.style.maxHeight="0px"}setActiveKeys(t){const e=new Set(this.activeKeys);this.activeKeys=new Set(t),e.forEach(s=>this.updateItemState(s)),t.forEach(s=>this.updateItemState(s))}destroy(){this.el.remove()}}function qs(o,t){return new Wt(o,t)}const zs=`<svg viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
143
|
+
<rect x="20" y="30" width="80" height="60" rx="8" stroke="currentColor" stroke-width="1.5" opacity="0.3"/>
|
|
144
|
+
<circle cx="45" cy="55" r="8" fill="currentColor" opacity="0.2"/>
|
|
145
|
+
<rect x="60" y="48" width="28" height="4" rx="2" fill="currentColor" opacity="0.2"/>
|
|
146
|
+
<rect x="60" y="58" width="20" height="4" rx="2" fill="currentColor" opacity="0.15"/>
|
|
147
|
+
<line x1="35" y1="82" x2="85" y2="82" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.15"/>
|
|
148
|
+
<line x1="45" y1="90" x2="75" y2="90" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.1"/>
|
|
149
|
+
</svg>`;class Vt{constructor(t,e={}){c(this,"el");c(this,"options");const s=typeof t=="string"?document.querySelector(t):t;this.options={image:"default",...e},this.el=document.createElement("div"),this.el.className="mk-empty";const i=document.createElement("div");if(i.className="mk-empty__image",this.options.imageStyle&&Object.assign(i.style,this.options.imageStyle),this.options.image==="default")i.innerHTML=zs;else if(this.options.image){const n=document.createElement("img");n.src=this.options.image,n.alt="",i.appendChild(n)}if(this.el.appendChild(i),this.options.description){const n=document.createElement("p");n.className="mk-empty__description",n.textContent=this.options.description,this.el.appendChild(n)}s.appendChild(this.el)}setDescription(t){this.options.description=t;let e=this.el.querySelector(".mk-empty__description");e||(e=document.createElement("p"),e.className="mk-empty__description",this.el.appendChild(e)),e.textContent=t}destroy(){this.el.remove()}}function Fs(o,t){return new Vt(o,t)}class jt{constructor(t,e={}){c(this,"el");c(this,"options");c(this,"popoverEl",null);c(this,"arrowEl",null);c(this,"contentEl",null);c(this,"showTimer",null);c(this,"hideTimer",null);c(this,"isVisible",!1);c(this,"cleanupFns",[]);c(this,"focusTrap",null);c(this,"escapeCleanup",null);if(this.options={placement:"top",trigger:"hover",offset:8,...e},this.el=document.createElement("div"),this.el.style.display="contents",this.buildPopover(),this.options.trigger==="click"){const s=n=>{n.stopPropagation(),this.toggle()};t.addEventListener("click",s),this.cleanupFns.push(()=>t.removeEventListener("click",s));const i=n=>{this.isVisible&&this.popoverEl&&!this.popoverEl.contains(n.target)&&n.target!==t&&this.hide()};document.addEventListener("click",i),this.cleanupFns.push(()=>document.removeEventListener("click",i))}else{const s=()=>{this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null),this.showTimer=setTimeout(()=>this.show(),150)},i=()=>{this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null),this.hideTimer=setTimeout(()=>this.hide(),150)};if(t.addEventListener("mouseenter",s),t.addEventListener("mouseleave",i),t.addEventListener("focus",s),t.addEventListener("blur",i),this.cleanupFns.push(()=>t.removeEventListener("mouseenter",s)),this.cleanupFns.push(()=>t.removeEventListener("mouseleave",i)),this.cleanupFns.push(()=>t.removeEventListener("focus",s)),this.cleanupFns.push(()=>t.removeEventListener("blur",i)),this.popoverEl){const n=()=>{this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)},r=()=>{this.hideTimer=setTimeout(()=>this.hide(),150)};this.popoverEl.addEventListener("mouseenter",n),this.popoverEl.addEventListener("mouseleave",r),this.cleanupFns.push(()=>this.popoverEl.removeEventListener("mouseenter",n)),this.cleanupFns.push(()=>this.popoverEl.removeEventListener("mouseleave",r))}}t.appendChild(this.el)}buildPopover(){if(this.popoverEl=document.createElement("div"),this.popoverEl.className="mk-popover",this.popoverEl.style.position="absolute",this.popoverEl.style.zIndex="var(--mk-z-popover)",this.popoverEl.setAttribute("role",this.options.trigger==="click"?"dialog":"tooltip"),this.options.trigger==="click"&&this.popoverEl.setAttribute("tabindex","-1"),this.options.width&&(this.popoverEl.style.width=`${this.options.width}px`),this.arrowEl=document.createElement("div"),this.arrowEl.className="mk-popover__arrow",this.popoverEl.appendChild(this.arrowEl),this.options.title){const t=document.createElement("div");t.className="mk-popover__title",t.textContent=this.options.title,this.popoverEl.appendChild(t)}this.contentEl=document.createElement("div"),this.contentEl.className="mk-popover__content",typeof this.options.content=="string"?this.contentEl.textContent=this.options.content:this.options.content&&this.contentEl.appendChild(this.options.content),this.popoverEl.appendChild(this.contentEl),document.body.appendChild(this.popoverEl)}position(){if(!this.popoverEl||!this.arrowEl)return;const e=this.el.parentElement.getBoundingClientRect(),s=this.popoverEl.getBoundingClientRect(),i=window.scrollX,n=window.scrollY,r=this.options.offset;let a=0,l=0,d="";switch(this.options.placement){case"top":a=e.top+n-s.height-r,l=e.left+i+e.width/2-s.width/2,d="is-bottom";break;case"bottom":a=e.bottom+n+r,l=e.left+i+e.width/2-s.width/2,d="is-top";break;case"left":a=e.top+n+e.height/2-s.height/2,l=e.left+i-s.width-r,d="is-right";break;case"right":a=e.top+n+e.height/2-s.height/2,l=e.right+i+r,d="is-left";break;default:a=e.top+n-s.height-r,l=e.left+i+e.width/2-s.width/2,d="is-bottom"}const u=8;l<u&&(l=u),l+s.width>window.innerWidth-u&&(l=window.innerWidth-s.width-u),a<u&&(a=u),this.popoverEl.style.top=`${a}px`,this.popoverEl.style.left=`${l}px`,this.arrowEl.className=`mk-popover__arrow ${d}`}show(){this.popoverEl&&(this.isVisible=!0,this.popoverEl.classList.remove("is-visible"),this.popoverEl.style.visibility="hidden",this.popoverEl.style.display="block",requestAnimationFrame(()=>{this.isVisible&&(this.position(),this.popoverEl.style.visibility="visible",this.popoverEl.classList.add("is-visible"),this.options.trigger==="click"&&(this.focusTrap||(this.focusTrap=new M(this.popoverEl)),this.focusTrap.activate(this.popoverEl),this.escapeCleanup=w(this.popoverEl,[{key:y.Escape,handler:()=>this.hide()}])))}))}hide(){this.popoverEl&&(this.isVisible=!1,this.popoverEl.classList.remove("is-visible"),this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap&&this.focusTrap.deactivate(),this.hideTimer=setTimeout(()=>{this.isVisible||(this.popoverEl.style.display="none")},200))}toggle(){this.isVisible?this.hide():this.show()}setContent(t){this.contentEl&&(this.contentEl.innerHTML="",typeof t=="string"?this.contentEl.textContent=t:this.contentEl.appendChild(t))}destroy(){var t;this.cleanupFns.forEach(e=>e()),this.cleanupFns=[],this.showTimer&&clearTimeout(this.showTimer),this.hideTimer&&clearTimeout(this.hideTimer),this.escapeCleanup&&(this.escapeCleanup(),this.escapeCleanup=null),this.focusTrap&&this.focusTrap.deactivate(),(t=this.popoverEl)==null||t.remove(),this.el.remove()}}function Rs(o,t){return new jt(o,t)}class Gt{constructor(t,e){c(this,"el");c(this,"options");c(this,"openeds");c(this,"activeIndex");const s=typeof t=="string"?document.querySelector(t):t;this.options={mode:"vertical",collapse:!1,...e},this.openeds=new Set(e.defaultOpeneds||[]),this.activeIndex=e.defaultActive||"",this.el=document.createElement("ul"),this.el.className=`mk-menu mk-menu--${this.options.mode}`,this.options.collapse&&this.el.classList.add("is-collapse"),this.el.setAttribute("role","menu"),this.render(),s.appendChild(this.el),this.setupKeyboard()}render(){this.el.innerHTML="",this.options.items.forEach(t=>{this.el.appendChild(this.renderItem(t,0))})}renderItem(t,e){const s=t.children&&t.children.length>0,i=this.openeds.has(t.index),n=this.activeIndex===t.index,r=this.options.collapse&&this.options.mode==="vertical",a=document.createElement("li");a.className="mk-menu-item",t.disabled&&a.classList.add("is-disabled"),n&&a.classList.add("is-active"),s&&a.classList.add("has-children"),i&&a.classList.add("is-open"),a.style.paddingLeft=r?"0":`${16+e*16}px`;const l=document.createElement("div");if(l.className="mk-menu-item__title",l.style.cursor=t.disabled?"not-allowed":"pointer",l.setAttribute("role","menuitem"),l.setAttribute("tabindex",t.disabled?"-1":"0"),t.disabled&&l.setAttribute("aria-disabled","true"),s&&(l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded",String(i))),t.icon){const u=document.createElement("span");u.className="mk-menu-item__icon",u.textContent=t.icon,l.appendChild(u)}const d=document.createElement("span");if(d.className="mk-menu-item__text",d.textContent=t.label,l.appendChild(d),s&&!r){const u=document.createElement("span");u.className="mk-menu-item__arrow",u.textContent="›",l.appendChild(u)}if(l.addEventListener("click",()=>{var u,p,m,f,g,v;t.disabled||(s?(i?(this.openeds.delete(t.index),(p=(u=this.options).onClose)==null||p.call(u,t.index)):(this.openeds.add(t.index),(f=(m=this.options).onOpen)==null||f.call(m,t.index)),this.render()):(this.activeIndex=t.index,(v=(g=this.options).onSelect)==null||v.call(g,t.index),this.render()))}),a.appendChild(l),s&&!r){const u=document.createElement("ul");u.className="mk-menu-submenu",i&&u.classList.add("is-open"),u.setAttribute("role","menu"),t.children.forEach(p=>{u.appendChild(this.renderItem(p,e+1))}),a.appendChild(u)}return a}setupKeyboard(){this.el.addEventListener("keydown",t=>{var a,l;const e=document.activeElement;if(!(e!=null&&e.classList.contains("mk-menu-item__title")))return;const i=e.parentElement.parentElement,n=Array.from(i.children).filter(d=>d.classList.contains("mk-menu-item")).map(d=>d.querySelector(".mk-menu-item__title")).filter(Boolean),r=n.indexOf(e);switch(t.key){case y.ArrowDown:t.preventDefault(),(a=n[r+1])==null||a.focus();break;case y.ArrowUp:t.preventDefault(),(l=n[r-1])==null||l.focus();break;case y.Enter:case y.Space:t.preventDefault(),e.click();break;case y.Escape:t.preventDefault();const d=i.closest(".mk-menu-item");if(d&&i!==this.el){const u=d.querySelector(".mk-menu-item__title");u&&u.getAttribute("aria-expanded")==="true"&&(u.click(),u.focus())}break}})}destroy(){this.el.remove()}}function Os(o,t){return new Gt(o,t)}class Jt{constructor(t,e){c(this,"el");const s=typeof t=="string"?document.querySelector(t):t;this.el=document.createElement("nav"),this.el.className="mk-breadcrumb",this.el.setAttribute("aria-label","breadcrumb");const i=e.separator??"/";e.items.forEach((n,r)=>{const a=r===e.items.length-1;if(r>0){const l=document.createElement("span");l.className="mk-breadcrumb__separator",typeof i=="string"?l.textContent=i:i instanceof HTMLElement&&l.appendChild(i),this.el.appendChild(l)}if(a){const l=document.createElement("span");l.className="mk-breadcrumb__item is-current",l.setAttribute("aria-current","page"),l.textContent=n.label,this.el.appendChild(l)}else{const l=document.createElement(n.href?"a":"span");l.className="mk-breadcrumb__item is-link",n.href&&(l.href=n.href),l.textContent=n.label,l.style.cursor=n.onClick||n.href?"pointer":"default",n.onClick&&l.addEventListener("click",n.onClick),this.el.appendChild(l)}}),s.appendChild(this.el)}destroy(){this.el.remove()}}function Hs(o,t){return new Jt(o,t)}class Zt{constructor(t,e){c(this,"el");c(this,"options");const s=typeof t=="string"?document.querySelector(t):t;this.options={direction:"horizontal",current:0,size:"default",...e},this.el=document.createElement("div"),this.el.className=`mk-steps mk-steps--${this.options.direction}`,this.options.size==="small"&&this.el.classList.add("mk-steps--small"),this.render(),s.appendChild(this.el)}render(){this.el.innerHTML="";const{items:t,current:e=0,direction:s}=this.options;t.forEach((i,n)=>{const r=document.createElement("div");r.className="mk-step";const a=i.status??(n<e?"finish":n===e?"process":"wait");r.classList.add(`is-${a}`),n===t.length-1&&r.classList.add("is-last");const l=document.createElement("div");l.className="mk-step__head";const d=document.createElement("div");d.className="mk-step__line",s==="vertical"&&(d.style.width="1px",d.style.height="100%",d.style.left="15px",d.style.top="30px"),l.appendChild(d);const u=document.createElement("div");u.className="mk-step__icon",a==="finish"?u.textContent=i.icon||"✓":a==="error"?u.textContent=i.icon||"✕":u.textContent=i.icon||String(n+1),l.appendChild(u);const p=document.createElement("div");p.className="mk-step__main";const m=document.createElement("div");if(m.className="mk-step__title",m.textContent=i.title,p.appendChild(m),i.description){const f=document.createElement("div");f.className="mk-step__description",f.textContent=i.description,p.appendChild(f)}r.appendChild(l),r.appendChild(p),this.el.appendChild(r)})}setCurrent(t){this.options.current=t,this.render()}destroy(){this.el.remove()}}function Ys(o,t){return new Zt(o,t)}h.Animator=P,h.CountUp=rt,h.CoverFlow=Lt,h.Draggable=he,h.FlipCard=_t,h.FocusTrap=M,h.Keys=y,h.MkAlert=Bt,h.MkAvatar=Ut,h.MkBreadcrumb=Jt,h.MkButton=Mt,h.MkCard=Nt,h.MkCheckbox=q,h.MkCheckboxGroup=Es,h.MkCollapse=Wt,h.MkDialog=Pt,h.MkDivider=$t,h.MkDrawer=Dt,h.MkEmpty=Vt,h.MkInput=It,h.MkMenu=Gt,h.MkPopover=jt,h.MkProgress=Kt,h.MkRadio=Rt,h.MkRadioGroup=ks,h.MkRow=St,h.MkSelect=Ft,h.MkSlider=ws,h.MkSpace=At,h.MkSteps=Zt,h.MkSwitch=qt,h.MkTable=Cs,h.MkTabs=Xt,h.MkTag=Ot,h.ScrollTrigger=nt,h.TextSplit=ct,h.ThemeManager=Tt,h.Timeline=te,h.Typewriter=ot,h.WaveText=ut,h.addRipple=ue,h.blurReveal=Ae,h.blurRevealChildren=$e,h.bounceIn=J,h.bounceOut=Z,h.collapse=bt,h.countUp=ae,h.createAlert=Ns,h.createAvatar=Ms,h.createBreadcrumb=Hs,h.createButton=ns,h.createCard=rs,h.createCheckbox=bs,h.createCollapse=qs,h.createCoverFlow=Ke,h.createDialog=ls,h.createDivider=is,h.createDrawer=cs,h.createEmpty=Fs,h.createFlipCard=Ve,h.createInput=os,h.createMenu=Os,h.createPopover=Rs,h.createProgress=Ps,h.createRow=es,h.createSelect=vs,h.createSpace=ss,h.createSteps=Ys,h.createSwitch=ys,h.createTabs=$s,h.createTag=xs,h.createTooltip=Ss,h.cursorTrail=Ge,h.elasticMove=de,h.elasticScale=ce,h.expand=vt,h.fadeIn=H,h.fadeOut=Y,h.flipInX=Q,h.flipInY=tt,h.fullscreenLoading=Fe,h.glitch=ht,h.glitchLoop=we,h.hoverGlow=ye,h.hoverLift=fe,h.lazyImage=yt,h.lazyImages=Ie,h.listStagger=qe,h.magnetic=Xe,h.magneticText=Ue,h.message=I,h.messageError=ms,h.messageSuccess=ps,h.messageWarning=fs,h.notify=Ye,h.onKey=w,h.parallax=pt,h.parallaxGroup=_e,h.particleAt=ve,h.particleBurst=lt,h.presets=ee,h.pulse=st,h.rippleEffect=pe,h.rotateIn=it,h.scrollAnimate=ie,h.shake=et,h.shimmer=mt,h.showComponentLoading=zt,h.showFullscreenLoading=gs,h.showLoading=ze,h.skeleton=Se,h.slideInDown=U,h.slideInLeft=B,h.slideInRight=K,h.slideInUp=X,h.slideOutDown=V,h.slideOutUp=W,h.splitText=ke,h.spring=A,h.staggerEnter=Ze,h.theme=ts,h.toast=$,h.toastError=Oe,h.toastSuccess=Re,h.toastWarning=He,h.toggleCollapse=Ne,h.typewrite=oe,h.waveText=xe,h.withMotion=T,h.zoomIn=j,h.zoomOut=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AnimationName } from '../core/utils.ts';
|
|
2
|
+
|
|
3
|
+
export type MicroAnimation = 'lift' | 'glow' | 'scale' | 'slideUp' | 'none';
|
|
4
|
+
export interface MotionOptions {
|
|
5
|
+
/** Mount entrance animation */
|
|
6
|
+
enter?: 'fadeIn' | 'slideInUp' | 'slideInDown' | 'slideInLeft' | 'slideInRight' | 'zoomIn' | 'bounceIn' | 'none';
|
|
7
|
+
/** Unmount exit animation */
|
|
8
|
+
exit?: 'fadeOut' | 'slideOutUp' | 'slideOutDown' | 'zoomOut' | 'none';
|
|
9
|
+
/** Hover micro-interaction */
|
|
10
|
+
hover?: MicroAnimation;
|
|
11
|
+
/** Active/press micro-interaction */
|
|
12
|
+
active?: 'press' | 'none';
|
|
13
|
+
/** Focus ring animation */
|
|
14
|
+
focus?: 'ring' | 'none';
|
|
15
|
+
/** Duration in ms */
|
|
16
|
+
duration?: number;
|
|
17
|
+
/** Delay in ms */
|
|
18
|
+
delay?: number;
|
|
19
|
+
/** Easing */
|
|
20
|
+
easing?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Attach motion behaviors to a DOM element.
|
|
24
|
+
* Returns controller to play enter/exit and manage state animations.
|
|
25
|
+
*/
|
|
26
|
+
export declare function withMotion(el: HTMLElement, options?: MotionOptions): {
|
|
27
|
+
/** Play entrance animation */
|
|
28
|
+
playEnter(): Promise<void>;
|
|
29
|
+
/** Play exit animation. Returns a Promise that resolves when animation completes. */
|
|
30
|
+
playExit(): Promise<void>;
|
|
31
|
+
/** Programmatically set hover state */
|
|
32
|
+
setHover(active: boolean): void;
|
|
33
|
+
/** Clean up all listeners and styles */
|
|
34
|
+
destroy(): void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Stagger children entrance animation.
|
|
38
|
+
*/
|
|
39
|
+
export declare function staggerEnter(container: HTMLElement, selector: string, _animation?: AnimationName, options?: {
|
|
40
|
+
duration?: number;
|
|
41
|
+
stagger?: number;
|
|
42
|
+
delay?: number;
|
|
43
|
+
}): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnimationOptions } from '../core/utils.ts';
|
|
2
|
+
import { Animator } from '../core/animator.ts';
|
|
3
|
+
|
|
4
|
+
export declare function fadeIn(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
5
|
+
export declare function fadeOut(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
6
|
+
export declare function slideInUp(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
7
|
+
export declare function slideInDown(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
8
|
+
export declare function slideInLeft(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
9
|
+
export declare function slideInRight(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
10
|
+
export declare function slideOutUp(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
11
|
+
export declare function slideOutDown(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
12
|
+
export declare function zoomIn(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
13
|
+
export declare function zoomOut(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
14
|
+
export declare function bounceIn(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
15
|
+
export declare function bounceOut(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
16
|
+
export declare function flipInX(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
17
|
+
export declare function flipInY(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
18
|
+
export declare function shake(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
19
|
+
export declare function pulse(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
20
|
+
export declare function rotateIn(el: HTMLElement | string, opts?: AnimationOptions): Promise<Animator>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnimationName } from '../core/utils.ts';
|
|
2
|
+
|
|
3
|
+
export interface ScrollTriggerOptions {
|
|
4
|
+
threshold?: number;
|
|
5
|
+
rootMargin?: string;
|
|
6
|
+
once?: boolean;
|
|
7
|
+
duration?: number;
|
|
8
|
+
easing?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ScrollTrigger {
|
|
11
|
+
private observer;
|
|
12
|
+
private elements;
|
|
13
|
+
watch(selector: string | Element | Element[], animationName: AnimationName, options?: ScrollTriggerOptions): this;
|
|
14
|
+
private handleEntries;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 快捷方法:为选择器下的所有元素添加滚动触发动画
|
|
19
|
+
*/
|
|
20
|
+
export declare function scrollAnimate(selector: string | Element | Element[], animationName: AnimationName, options?: ScrollTriggerOptions): ScrollTrigger;
|