@stacksjs/components 0.2.63 → 0.2.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion-pt8j917s.stx +146 -0
- package/dist/AccordionItem-hbhzx63p.stx +37 -0
- package/dist/{Checkbox-zgdmy3p5.stx → Checkbox-aqmq4cqv.stx} +3 -1
- package/dist/{Dialog-hczpexs4.stx → Dialog-y5rz2vrq.stx} +5 -1
- package/dist/{Drawer-xhevp5cw.stx → Drawer-hrz7qcyp.stx} +4 -1
- package/dist/Notification-03vfh3k6.stx +117 -0
- package/dist/{NumberInput-drnvtqej.stx → NumberInput-g41gmd2c.stx} +2 -1
- package/dist/{Pagination-n3d31cns.stx → Pagination-wtgxmzey.stx} +3 -1
- package/dist/{PasswordInput-n02x6053.stx → PasswordInput-4rsq1gwb.stx} +2 -1
- package/dist/{Progress-yxcntr4x.stx → Progress-9dhakbh4.stx} +2 -1
- package/dist/{Radio-cgjv2hb2.stx → Radio-djtb5dpc.stx} +2 -1
- package/dist/{Select-28y0pg83.stx → Select-1vnd0brz.stx} +2 -1
- package/dist/{SidebarSection-npt9h265.stx → SidebarSection-g195cb4f.stx} +2 -1
- package/dist/{Switch-r5t5w04w.stx → Switch-p1bcr9ks.stx} +3 -1
- package/dist/TabPanel-5htevsq6.stx +25 -0
- package/dist/Tabs-79brys99.stx +202 -0
- package/dist/{TextInput-kf084763.stx → TextInput-g0vaz0pe.stx} +4 -1
- package/dist/{Textarea-xg4rr2xz.stx → Textarea-96kawv5c.stx} +2 -1
- package/dist/{Tooltip-m0tqd72e.stx → Tooltip-y61h04gp.stx} +2 -1
- package/dist/index.js +3909 -15
- package/dist/ui/accordion/Accordion.stx +9 -1
- package/dist/ui/accordion/AccordionItem.stx +7 -0
- package/dist/ui/accordion/index.d.ts +32 -2
- package/dist/ui/input/NumberInput.stx +1 -1
- package/dist/ui/input/TextInput.stx +1 -1
- package/dist/ui/notification/Notification.stx +10 -8
- package/dist/ui/select/Select.stx +1 -1
- package/dist/ui/tabs/TabPanel.stx +9 -0
- package/dist/ui/tabs/Tabs.stx +140 -0
- package/dist/ui/tabs/index.d.ts +32 -1
- package/dist/ui/textarea/Textarea.stx +1 -1
- package/package.json +3 -3
- package/src/ui/accordion/Accordion.stx +90 -32
- package/src/ui/accordion/AccordionItem.stx +37 -0
- package/src/ui/accordion/index.ts +35 -2
- package/src/ui/checkbox/Checkbox.stx +3 -1
- package/src/ui/dialog/Dialog.stx +5 -1
- package/src/ui/drawer/Drawer.stx +4 -1
- package/src/ui/input/NumberInput.stx +2 -1
- package/src/ui/input/PasswordInput.stx +2 -1
- package/src/ui/input/TextInput.stx +4 -1
- package/src/ui/notification/Notification.stx +65 -26
- package/src/ui/pagination/Pagination.stx +3 -1
- package/src/ui/progress/Progress.stx +2 -1
- package/src/ui/radio/Radio.stx +2 -1
- package/src/ui/select/Select.stx +2 -1
- package/src/ui/sidebar/SidebarSection.stx +2 -1
- package/src/ui/switch/Switch.stx +3 -1
- package/src/ui/tabs/TabPanel.stx +25 -0
- package/src/ui/tabs/Tabs.stx +108 -32
- package/src/ui/tabs/index.ts +35 -1
- package/src/ui/textarea/Textarea.stx +2 -1
- package/src/ui/tooltip/Tooltip.stx +2 -1
- package/dist/Accordion-19x8q4rj.stx +0 -88
- package/dist/Notification-tb9b525s.stx +0 -78
- package/dist/Tabs-bzvvn4ke.stx +0 -126
package/dist/index.js
CHANGED
|
@@ -1,19 +1,3913 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`)}`)}return{valid:i.length===0,errors:i}}function P(e,t,s){return(r)=>Le(e,r,t,s)}function xa(e,t,s="value"){if(!R)return;if(!t.validate(e,s,"assertion"))throw Error(t.message(e,s,"assertion"))}function ba(e,t,s="value"){if(!R)return;if(!t.validate(e,s,"warning"))console.warn(t.message(e,s,"warning"))}var Me="./Button-1vknasy3.stx";var Te={variant:l.oneOf(["primary","secondary","outline","ghost","danger"]),size:l.oneOf(["xs","sm","md","lg","xl"]),disabled:l.boolean,loading:l.boolean,type:l.oneOf(["button","submit","reset"]),fullWidth:l.boolean,leftIcon:l.string,rightIcon:l.string,className:l.string,onClick:l.func},ya=P("Button",Te);function wa(e){return re(e,"Button","onClick")}function Ca(e){if(e&&!["primary","secondary","outline","ghost","danger"].includes(e))throw T.invalidProp("Button","variant",e,["primary","secondary","outline","ghost","danger"])}function ka(e){if(e&&!["xs","sm","md","lg","xl"].includes(e))throw T.invalidProp("Button","size",e,["xs","sm","md","lg","xl"])}var Be="./Calendar-reny0et7.stx";var je="./Card-c1g1fd1w.stx";var He="./Checkbox-zgdmy3p5.stx";var Re="./Combobox-fdkr6cdq.stx";var _e="./ComboboxButton-g76stp1e.stx";var Ue="./ComboboxInput-z1293bbh.stx";var Ge="./ComboboxOption-hmxt3gte.stx";var Ze="./ComboboxOptions-sq5360ae.stx";var Xe="./CommandPalette-36mxf05w.stx";var et="./CommandPaletteItem-mvk6q7a2.stx";var st="./Dialog-hczpexs4.stx";var ot="./DialogBackdrop-rxax3sec.stx";var it="./DialogDescription-76prd1m2.stx";var lt="./DialogPanel-44d8jeqy.stx";var ct="./DialogTitle-x0r6k8x9.stx";var ut="./Drawer-xhevp5cw.stx";var xt="./Dropdown-vvhemtc0.stx";var ft="./DropdownButton-wcz67dxy.stx";var vt="./DropdownItem-c7rz08e5.stx";var yt="./DropdownItems-1sxnd5qn.stx";var Ct="./Form-mas630hy.stx";var kt={action:l.string,method:l.oneOf(["GET","POST","PUT","DELETE","PATCH"]),validationSchema:l.object,initialValues:l.object,validateOnChange:l.boolean,validateOnBlur:l.boolean,onSubmit:l.func,onError:l.func,className:l.string},Ci=P("Form",kt);var St="./Image-yhxcvgzs.stx";var Nt="./EmailInput-vak3kkmk.stx";var Dt="./NumberInput-drnvtqej.stx";var Lt="./PasswordInput-n02x6053.stx";var Mt="./SearchInput-pdx7agn0.stx";var Ot="./TextInput-kf084763.stx";var Bt={value:l.string,onChange:l.func,placeholder:l.string,disabled:l.boolean,readonly:l.boolean,size:l.oneOf(["sm","md","lg"]),error:l.boolean,label:l.string,helperText:l.string,required:l.boolean,className:l.string,inputClassName:l.string},qt={value:l.string,onChange:l.func,placeholder:l.string,disabled:l.boolean,readonly:l.boolean,size:l.oneOf(["sm","md","lg"]),error:l.boolean,label:l.string,helperText:l.string,required:l.boolean,className:l.string,inputClassName:l.string,leftIcon:l.string,rightIcon:l.string,clearable:l.boolean,maxLength:l.number,showCount:l.boolean},jt={value:l.string,onChange:l.func,placeholder:l.string,disabled:l.boolean,readonly:l.boolean,size:l.oneOf(["sm","md","lg"]),error:l.boolean,label:l.string,helperText:l.string,required:l.boolean,className:l.string,inputClassName:l.string,min:l.number,max:l.number,step:l.number,showControls:l.boolean},At={value:l.string,onChange:l.func,placeholder:l.string,disabled:l.boolean,readonly:l.boolean,size:l.oneOf(["sm","md","lg"]),error:l.boolean,label:l.string,helperText:l.string,required:l.boolean,className:l.string,inputClassName:l.string,showStrength:l.boolean},Ht={value:l.string,onChange:l.func,placeholder:l.string,disabled:l.boolean,readonly:l.boolean,size:l.oneOf(["sm","md","lg"]),error:l.boolean,label:l.string,helperText:l.string,required:l.boolean,className:l.string,inputClassName:l.string,onSearch:l.func,loading:l.boolean},Ti=P("TextInput",qt),Oi=P("EmailInput",Bt),Bi=P("PasswordInput",At),qi=P("NumberInput",jt),ji=P("SearchInput",Ht);var Rt="./Listbox-q49tnr90.stx";var _t="./ListboxButton-keb8gm0q.stx";var Ut="./ListboxLabel-7mymt1b8.stx";var Gt="./ListboxOption-e0dtv1gc.stx";var Zt="./ListboxOptions-ejkatcfg.stx";var Xt="./Navigator-rk2a5wvk.stx";var es="./Notification-tb9b525s.stx";var ss="./Pagination-n3d31cns.stx";var os="./Checkout-agt0ngpw.stx";var is="./DefaultPaymentMethod-shhf6aap.stx";var ls="./PaymentMethods-x4vrx9yb.stx";var cs="./SubscriptionCheckout-zy2ycrmw.stx";var us="./Popover-et2q44m7.stx";var xs="./PopoverButton-mffzc9pr.stx";var fs="./PopoverPanel-054yh38h.stx";var vs="./Portal-1vf14s4x.stx";var ys="./Progress-yxcntr4x.stx";var Cs="./Radio-cgjv2hb2.stx";var $s="./RadioGroup-qxmnm3xm.stx";var zs="./RadioGroupDescription-yej78fak.stx";var Is="./RadioGroupLabel-7mymt1b8.stx";var Ps="./RadioGroupOption-s1d6r221.stx";var Es="./Select-28y0pg83.stx";var Ts="./Sidebar-0jzasrmt.stx";var Bs="./SidebarSection-npt9h265.stx";var js="./SidebarItem-h53sgqzz.stx";var Hs="./SidebarHeader-ywpmx14d.stx";var Rs="./SidebarFooter-zsfsgcxb.stx";var _s="./Skeleton-v1pwa8nr.stx";var Us="./Spinner-7dahavkd.stx";var Gs="./Stepper-rgbk76hd.stx";var Zs="./StepperStep-wxgembat.stx";class W{storage;namespace;watchers=new Map;encryptionKey="stx-storage-key";constructor(e="local",t=""){if(this.storage=e==="local"?globalThis.localStorage:globalThis.sessionStorage,this.namespace=t,typeof window<"u")window.addEventListener("storage",this.handleStorageEvent.bind(this))}handleStorageEvent(e){if(!e.key)return;let t=this.namespace&&e.key.startsWith(`${this.namespace}:`)?e.key.slice(this.namespace.length+1):e.key,s=this.watchers.get(t);if(s){let r=e.oldValue?JSON.parse(e.oldValue).value:null,o=e.newValue?JSON.parse(e.newValue).value:null;s.forEach((a)=>a(o,r,t))}}encrypt(e){let t="";for(let s=0;s<e.length;s++)t+=String.fromCharCode(e.charCodeAt(s)^this.encryptionKey.charCodeAt(s%this.encryptionKey.length));return btoa(t)}decrypt(e){try{let t=atob(e),s="";for(let r=0;r<t.length;r++)s+=String.fromCharCode(t.charCodeAt(r)^this.encryptionKey.charCodeAt(r%this.encryptionKey.length));return s}catch{return e}}compress(e){if(e.length<100)return e;let t={},s=256,r=[],o="";for(let a=0;a<e.length;a++){let i=e.charAt(a),n=o+i;if(t[n]!==void 0)o=n;else r.push(o.length>1?t[o]:o.charCodeAt(0)),t[n]=s++,o=i}if(o!=="")r.push(o.length>1?t[o]:o.charCodeAt(0));return JSON.stringify(r)}decompress(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return e;let s={},r=256,o=String.fromCharCode(t[0]),a=o;for(let i=1;i<t.length;i++){let n=t[i],d;if(s[n]!==void 0)d=s[n];else if(n===r)d=o+o.charAt(0);else return e;a+=d,s[r++]=o+d.charAt(0),o=d}return a}catch{return e}}getKey(e){return this.namespace?`${this.namespace}:${e}`:e}set(e,t,s){let r=this.getKey(e),o=this.get(e),a={value:t,timestamp:Date.now(),expire:s?.expire,encrypted:s?.encrypt||!1,compressed:s?.compress||!1};try{let i=JSON.stringify(a);if(s?.compress)i=this.compress(i);if(s?.encrypt)i=this.encrypt(i);this.storage.setItem(r,i),this.notifyWatchers(e,t,o)}catch(i){console.error("Storage set error:",i)}}get(e){let t=this.getKey(e);try{let s=this.storage.getItem(t);if(!s)return null;if(s.match(/^[A-Z0-9+/]+=*$/i))try{s=this.decrypt(s)}catch{}if(s.startsWith("["))try{s=this.decompress(s)}catch{}let r=JSON.parse(s);if(r.expire&&Date.now()-r.timestamp>r.expire)return this.remove(e),null;return r.value}catch(s){return console.error("Storage get error:",s),null}}watch(e,t){if(!this.watchers.has(e))this.watchers.set(e,new Set);return this.watchers.get(e).add(t),()=>{let s=this.watchers.get(e);if(s){if(s.delete(t),s.size===0)this.watchers.delete(e)}}}notifyWatchers(e,t,s){let r=this.watchers.get(e);if(r)r.forEach((o)=>o(t,s,e))}remove(e){let t=this.getKey(e),s=this.get(e);this.storage.removeItem(t),this.notifyWatchers(e,null,s)}clear(){if(this.namespace)this.keys().forEach((t)=>this.remove(t));else this.storage.clear()}has(e){return this.get(e)!==null}keys(){let e=Object.keys(this.storage);if(this.namespace){let t=`${this.namespace}:`;return e.filter((s)=>s.startsWith(t)).map((s)=>s.slice(t.length))}return e}size(){return this.keys().length}getQuota(){if("storage"in navigator&&"estimate"in navigator.storage)return null;try{let e=0;for(let s=0;s<this.storage.length;s++){let r=this.storage.key(s);if(r){let o=this.storage.getItem(r)||"";e+=r.length+o.length}}let t=5242880;return{usage:e*2,quota:t,percentage:e*2/t*100}}catch{return null}}setMany(e,t){Object.entries(e).forEach(([s,r])=>{this.set(s,r,t)})}getMany(e){let t={};return e.forEach((s)=>{t[s]=this.get(s)}),t}removeMany(e){e.forEach((t)=>this.remove(t))}}var ml={local:new W("local"),session:new W("session")};function vl(e="local",t){return new W(e,t)}var Xs="./Switch-r5t5w04w.stx";var er="./Table-6cx8az9h.stx";var sr="./TableBody-wf6t13j9.stx";var or="./TableCell-ntx0edbn.stx";var ir="./TableHead-3k4hnm2k.stx";var lr="./TableHeader-0eyzbqpz.stx";var cr="./TableRow-z09p2ebf.stx";var ur="./Tabs-bzvvn4ke.stx";var xr="./Teleport-tsx4bt4n.stx";var fr="./Textarea-xg4rr2xz.stx";var vr="./Tooltip-m0tqd72e.stx";var yr="./Transition-7smenaz8.stx";var Cr="./Video-84j4pv6h.stx";var $r="./VirtualList-fa7v5a3h.stx";var zr="./VirtualTable-f9crbfjr.stx";var Nr=0;function oe(e="a11y"){return`${e}-${++Nr}-${Date.now()}`}function id(e,t,s={}){let{visible:r=!1,id:o=oe("label")}=s,a=document.createElement(r?"label":"span");if(a.id=o,a.textContent=e,!r)Object.assign(a.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"});if(t)if(t.setAttribute("aria-labelledby",o),t.parentElement)t.parentElement.insertBefore(a,t);else document.body.appendChild(a);return o}function nd(e,t){let s=oe("desc"),r=document.createElement("span");if(r.id=s,r.textContent=e,Object.assign(r.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),t)if(t.setAttribute("aria-describedby",s),t.parentElement)t.parentElement.insertBefore(r,t);else document.body.appendChild(r);return s}function ld(e,t="polite"){let s=document.createElement("div");s.setAttribute("role","status"),s.setAttribute("aria-live",t),s.setAttribute("aria-atomic","true"),Object.assign(s.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(s),setTimeout(()=>{s.textContent=e},100),setTimeout(()=>{s.parentNode?.removeChild(s)},1000)}function K(e){let t=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(e.querySelectorAll(t)).filter((s)=>s.offsetParent!==null)}function dd(e,t={}){let{initialFocus:s,returnFocus:r,escapeDeactivates:o=!0,clickOutsideDeactivates:a=!0,allowOutsideClick:i=!1,onActivate:n,onDeactivate:d}=t,c=!1,g=!1,p=null,f=(v)=>{if(g)return;if(o&&v.key==="Escape"){v.preventDefault(),h();return}if(v.key==="Tab"){let C=K(e);if(C.length===0){v.preventDefault();return}let I=C[0],E=C[C.length-1];if(v.shiftKey){if(document.activeElement===I)v.preventDefault(),E.focus()}else if(document.activeElement===E)v.preventDefault(),I.focus()}},x=(v)=>{if(g)return;if(!e.contains(v.target)){if(typeof i==="function"){if(!i(v)&&a)h()}else if(!i&&a)h()}};function y(){if(c)return;c=!0,p=document.activeElement;let v=s||K(e)[0];if(v&&typeof v.focus==="function")v.focus();document.addEventListener("keydown",f),document.addEventListener("click",x),n?.()}function h(){if(!c)return;c=!1;let v=r||p;if(v&&typeof v.focus==="function")v.focus();document.removeEventListener("keydown",f),document.removeEventListener("click",x),d?.()}function $(){g=!0}function m(){g=!1}return{activate:y,deactivate:h,pause:$,unpause:m}}function cd(e,t={}){let{selector:s='[role="option"], [role="menuitem"], [role="tab"], button',initialIndex:r=0,orientation:o="both",loop:a=!0,onFocusChange:i}=t,n=r,d=()=>{return Array.from(e.querySelectorAll(s))},c=(p)=>{let f=d();if(p<0||p>=f.length)return;f.forEach((x,y)=>{if(y===p){if(x.setAttribute("tabindex","0"),typeof x.focus==="function")x.focus()}else x.setAttribute("tabindex","-1")}),n=p,i?.(p,f[p])},g=(p)=>{let x=d().length-1,y=!1,h=n;switch(p.key){case"ArrowRight":if(o==="horizontal"||o==="both"){if(h=n+1,h>x)h=a?0:x;y=!0}break;case"ArrowLeft":if(o==="horizontal"||o==="both"){if(h=n-1,h<0)h=a?x:0;y=!0}break;case"ArrowDown":if(o==="vertical"||o==="both"){if(h=n+1,h>x)h=a?0:x;y=!0}break;case"ArrowUp":if(o==="vertical"||o==="both"){if(h=n-1,h<0)h=a?x:0;y=!0}break;case"Home":h=0,y=!0;break;case"End":h=x,y=!0;break}if(y)p.preventDefault(),c(h)};return c(r),e.addEventListener("keydown",g),()=>{e.removeEventListener("keydown",g)}}var pd={Enter:"Enter",Space:" ",Escape:"Escape",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Tab:"Tab",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown"};function ud(e){return document.activeElement===e}function gd(e,t){let s=t||document.activeElement,r=K(document.body),o=r.indexOf(s);if(o===-1)return;let a=e==="next"?o+1:o-1,i=r[a];if(i)i.focus()}function xd(e){if(e.getAttribute("aria-hidden")==="true")return!1;let t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden")return!1;return!0}var bd={setExpanded(e,t){e.setAttribute("aria-expanded",String(t))},setSelected(e,t){e.setAttribute("aria-selected",String(t))},setChecked(e,t){e.setAttribute("aria-checked",String(t))},setDisabled(e,t){if(e.setAttribute("aria-disabled",String(t)),t)e.setAttribute("tabindex","-1");else e.removeAttribute("tabindex")},setHidden(e,t){if(t)e.setAttribute("aria-hidden","true");else e.removeAttribute("aria-hidden")},setPressed(e,t){e.setAttribute("aria-pressed",String(t))},setInvalid(e,t){e.setAttribute("aria-invalid",String(t))},setRequired(e,t){e.setAttribute("aria-required",String(t))},setLive(e,t){e.setAttribute("aria-live",t)},setBusy(e,t){e.setAttribute("aria-busy",String(t))}};function fd(e){let t=document.createElement("span");return t.textContent=e,t.className="sr-only",Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),t}function md(){if(typeof window.matchMedia==="function")return window.matchMedia("(prefers-reduced-motion: reduce)").matches;return!1}function vd(){if(typeof window.matchMedia==="function")return window.matchMedia("(prefers-contrast: high)").matches;return!1}function hd(){if(typeof window.matchMedia==="function"){if(window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark";if(window.matchMedia("(prefers-color-scheme: light)").matches)return"light"}return null}function yd(e,t="Skip to main content"){let s=document.createElement("a");return s.href=`#${e}`,s.textContent=t,s.className="skip-link",Object.assign(s.style,{position:"absolute",top:"-40px",left:"0",background:"#000",color:"#fff",padding:"8px",textDecoration:"none",zIndex:"100"}),s.addEventListener("focus",()=>{s.style.top="0"}),s.addEventListener("blur",()=>{s.style.top="-40px"}),s}function wd(e){let t=[],s=(r)=>{let o=e.getAttribute(r);if(o){let a=o.split(" ");for(let i of a)if(!document.getElementById(i))t.push(`${r} references non-existent ID: ${i}`)}};return s("aria-labelledby"),s("aria-describedby"),s("aria-controls"),s("aria-owns"),s("aria-activedescendant"),t}var Ir=(e,t,s,r)=>{return s*e/r+t},Dr=(e,t,s,r)=>{return e/=r,s*e*e+t},Pr=(e,t,s,r)=>{return e/=r,-s*e*(e-2)+t},Lr=(e,t,s,r)=>{if(e/=r/2,e<1)return s/2*e*e+t;return e--,-s/2*(e*(e-2)-1)+t},Er=(e,t,s,r)=>{return e/=r,s*e*e*e+t},Mr=(e,t,s,r)=>{return e/=r,e--,s*(e*e*e+1)+t},Tr=(e,t,s,r)=>{if(e/=r/2,e<1)return s/2*e*e*e+t;return e-=2,s/2*(e*e*e+2)+t},Or=(e,t,s,r)=>{return e/=r,s*e*e*e*e+t},Br=(e,t,s,r)=>{return e/=r,e--,-s*(e*e*e*e-1)+t},qr=(e,t,s,r)=>{if(e/=r/2,e<1)return s/2*e*e*e*e+t;return e-=2,-s/2*(e*e*e*e-2)+t},jr=(e,t,s,r)=>{return e/=r,s*e*e*e*e*e+t},Ar=(e,t,s,r)=>{return e/=r,e--,s*(e*e*e*e*e+1)+t},Hr=(e,t,s,r)=>{if(e/=r/2,e<1)return s/2*e*e*e*e*e+t;return e-=2,s/2*(e*e*e*e*e+2)+t},Vr=(e,t,s,r)=>{return-s*Math.cos(e/r*(Math.PI/2))+s+t},Rr=(e,t,s,r)=>{return s*Math.sin(e/r*(Math.PI/2))+t},Wr=(e,t,s,r)=>{return-s/2*(Math.cos(Math.PI*e/r)-1)+t},_r=(e,t,s,r)=>{return e===0?t:s*2**(10*(e/r-1))+t},Fr=(e,t,s,r)=>{return e===r?t+s:s*(-(2**(-10*e/r))+1)+t},Ur=(e,t,s,r)=>{if(e===0)return t;if(e===r)return t+s;if(e/=r/2,e<1)return s/2*2**(10*(e-1))+t;return e--,s/2*(-(2**(-10*e))+2)+t},Yr=(e,t,s,r)=>{return e/=r,-s*(Math.sqrt(1-e*e)-1)+t},Gr=(e,t,s,r)=>{return e/=r,e--,s*Math.sqrt(1-e*e)+t},Jr=(e,t,s,r)=>{if(e/=r/2,e<1)return-s/2*(Math.sqrt(1-e*e)-1)+t;return e-=2,s/2*(Math.sqrt(1-e*e)+1)+t},Zr=(e,t,s,r)=>{let o=1.70158,a=0,i=s;if(e===0)return t;if(e/=r,e===1)return t+s;if(!a)a=r*0.3;if(i<Math.abs(s))i=s,o=a/4;else o=a/(2*Math.PI)*Math.asin(s/i);return e-=1,-(i*2**(10*e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t},Kr=(e,t,s,r)=>{let o=1.70158,a=0,i=s;if(e===0)return t;if(e/=r,e===1)return t+s;if(!a)a=r*0.3;if(i<Math.abs(s))i=s,o=a/4;else o=a/(2*Math.PI)*Math.asin(s/i);return i*2**(-10*e)*Math.sin((e*r-o)*(2*Math.PI)/a)+s+t},Xr=(e,t,s,r)=>{let o=1.70158,a=0,i=s;if(e===0)return t;if(e/=r/2,e===2)return t+s;if(!a)a=r*0.44999999999999996;if(i<Math.abs(s))i=s,o=a/4;else o=a/(2*Math.PI)*Math.asin(s/i);if(e<1)return e-=1,-0.5*(i*2**(10*e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t;return e-=1,i*2**(-10*e)*Math.sin((e*r-o)*(2*Math.PI)/a)*0.5+s+t},Qr=(e,t,s,r)=>{return e/=r,s*e*e*(2.70158*e-1.70158)+t},eo=(e,t,s,r)=>{return e/=r,e--,s*(e*e*(2.70158*e+1.70158)+1)+t},to=(e,t,s,r)=>{let o=1.70158;if(e/=r/2,e<1)return o*=1.525,s/2*(e*e*((o+1)*e-o))+t;return e-=2,o*=1.525,s/2*(e*e*((o+1)*e+o)+2)+t},X=(e,t,s,r)=>{if(e/=r,e<0.36363636363636365)return s*(7.5625*e*e)+t;else if(e<0.7272727272727273)return e-=0.5454545454545454,s*(7.5625*e*e+0.75)+t;else if(e<0.9090909090909091)return e-=0.8181818181818182,s*(7.5625*e*e+0.9375)+t;else return e-=0.9545454545454546,s*(7.5625*e*e+0.984375)+t},ae=(e,t,s,r)=>{return s-X(r-e,0,s,r)+t},so=(e,t,s,r)=>{if(e<r/2)return ae(e*2,0,s,r)*0.5+t;return X(e*2-r,0,s,r)*0.5+s*0.5+t},kd={linear:Ir,easeInQuad:Dr,easeOutQuad:Pr,easeInOutQuad:Lr,easeInCubic:Er,easeOutCubic:Mr,easeInOutCubic:Tr,easeInQuart:Or,easeOutQuart:Br,easeInOutQuart:qr,easeInQuint:jr,easeOutQuint:Ar,easeInOutQuint:Hr,easeInSine:Vr,easeOutSine:Rr,easeInOutSine:Wr,easeInExpo:_r,easeOutExpo:Fr,easeInOutExpo:Ur,easeInCirc:Yr,easeOutCirc:Gr,easeInOutCirc:Jr,easeInElastic:Zr,easeOutElastic:Kr,easeInOutElastic:Xr,easeInBack:Qr,easeOutBack:eo,easeInOutBack:to,easeInBounce:ae,easeOutBounce:X,easeInOutBounce:so};function ro(e,t={}){let{duration:s="1s",timing:r="ease",delay:o="0s",iteration:a="1",direction:i="normal",fill:n="both",playState:d="running"}=t;return`${e} ${s} ${r} ${o} ${a} ${i} ${n} ${d}`}function ie(e,t,s={}){e.style.animation=ro(t,s)}function Sd(e){e.style.animation=""}function oo(e){return new Promise((t)=>{let s=()=>{e.removeEventListener("animationend",s),t()};e.addEventListener("animationend",s)})}function zd(e,t,s={}){let{stagger:r=100,...o}=s;e.forEach((a,i)=>{let n=`${i*r}ms`;ie(a,t,{...o,delay:n})})}async function Nd(e,t){for(let s of t)ie(e,s.name,s.options),await oo(e)}var Id={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",slideInUp:"animate-slide-in-up",slideInDown:"animate-slide-in-down",slideInLeft:"animate-slide-in-left",slideInRight:"animate-slide-in-right",zoomIn:"animate-zoom-in",zoomOut:"animate-zoom-out",bounce:"animate-bounce",spin:"animate-spin",ping:"animate-ping",pulse:"animate-pulse"};function Dd(e,t,s=1000){return new Promise((r)=>{e.classList.add(t),setTimeout(()=>{e.classList.remove(t),r()},s)})}function Pd(e,t){let s=`
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
// ../../../../../../../tmp/stx-components-build-cWp3vr/stubs/stub-0.js
|
|
3
|
+
var stub_0_default = { __stx: true, src: "./components/CodeBlock.stx" };
|
|
4
|
+
// ../../../../../../../tmp/stx-components-build-cWp3vr/stubs/stub-1.js
|
|
5
|
+
var stub_1_default = { __stx: true, src: "./components/Footer.stx" };
|
|
6
|
+
// ../../../../../../../tmp/stx-components-build-cWp3vr/stubs/stub-2.js
|
|
7
|
+
var stub_2_default = { __stx: true, src: "./components/Hero.stx" };
|
|
8
|
+
// ../../../../../../../tmp/stx-components-build-cWp3vr/stubs/stub-3.js
|
|
9
|
+
var stub_3_default = { __stx: true, src: "./components/Installation.stx" };
|
|
10
|
+
// src/composables/useCopyCode.ts
|
|
11
|
+
function useCopyCode(options) {
|
|
12
|
+
const { code, onSuccess, onError, timeout = 2000 } = options;
|
|
13
|
+
let copied = false;
|
|
14
|
+
let timeoutId = null;
|
|
15
|
+
const reset = () => {
|
|
16
|
+
copied = false;
|
|
17
|
+
if (timeoutId) {
|
|
18
|
+
clearTimeout(timeoutId);
|
|
19
|
+
timeoutId = null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const copy = async () => {
|
|
23
|
+
try {
|
|
24
|
+
if (!navigator.clipboard) {
|
|
25
|
+
throw new Error("Clipboard API not available");
|
|
26
|
+
}
|
|
27
|
+
await navigator.clipboard.writeText(code);
|
|
28
|
+
copied = true;
|
|
29
|
+
onSuccess?.();
|
|
30
|
+
timeoutId = setTimeout(() => {
|
|
31
|
+
copied = false;
|
|
32
|
+
timeoutId = null;
|
|
33
|
+
}, timeout);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
const err = error instanceof Error ? error : new Error("Failed to copy code");
|
|
36
|
+
onError?.(err);
|
|
37
|
+
console.error("Failed to copy code:", err);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
copied,
|
|
42
|
+
copy,
|
|
43
|
+
reset
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function copyToClipboard(text) {
|
|
47
|
+
try {
|
|
48
|
+
await navigator.clipboard.writeText(text);
|
|
49
|
+
return true;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("Failed to copy to clipboard:", error);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/composables/useDarkMode.ts
|
|
57
|
+
function getSystemTheme() {
|
|
58
|
+
if (typeof window === "undefined")
|
|
59
|
+
return "light";
|
|
60
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
61
|
+
}
|
|
62
|
+
function getEffectiveTheme(theme) {
|
|
63
|
+
return theme === "system" ? getSystemTheme() : theme;
|
|
64
|
+
}
|
|
65
|
+
function useDarkMode(options = {}) {
|
|
66
|
+
const { storageKey = "theme", defaultTheme = "system" } = options;
|
|
67
|
+
let theme = defaultTheme;
|
|
68
|
+
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
69
|
+
const stored = localStorage.getItem(storageKey);
|
|
70
|
+
if (stored)
|
|
71
|
+
theme = stored;
|
|
72
|
+
}
|
|
73
|
+
const isDark = getEffectiveTheme(theme) === "dark";
|
|
74
|
+
const applyTheme = (newTheme) => {
|
|
75
|
+
const effective = getEffectiveTheme(newTheme);
|
|
76
|
+
if (typeof document !== "undefined") {
|
|
77
|
+
if (effective === "dark") {
|
|
78
|
+
document.documentElement.classList.add("dark");
|
|
79
|
+
} else {
|
|
80
|
+
document.documentElement.classList.remove("dark");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (typeof localStorage !== "undefined") {
|
|
84
|
+
localStorage.setItem(storageKey, newTheme);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const setTheme = (newTheme) => {
|
|
88
|
+
theme = newTheme;
|
|
89
|
+
applyTheme(newTheme);
|
|
90
|
+
};
|
|
91
|
+
const toggle = () => {
|
|
92
|
+
const currentEffective = getEffectiveTheme(theme);
|
|
93
|
+
const newTheme = currentEffective === "dark" ? "light" : "dark";
|
|
94
|
+
setTheme(newTheme);
|
|
95
|
+
};
|
|
96
|
+
applyTheme(theme);
|
|
97
|
+
if (typeof window !== "undefined" && theme === "system") {
|
|
98
|
+
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (_e) => {
|
|
99
|
+
if (theme === "system") {
|
|
100
|
+
applyTheme("system");
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
isDark,
|
|
106
|
+
theme,
|
|
107
|
+
toggle,
|
|
108
|
+
setTheme
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/composables/useSEO.ts
|
|
113
|
+
function setTitle(title, template) {
|
|
114
|
+
if (typeof document === "undefined")
|
|
115
|
+
return;
|
|
116
|
+
document.title = template ? template.replace("%s", title) : title;
|
|
117
|
+
}
|
|
118
|
+
function setMeta(name, content, isProperty = false) {
|
|
119
|
+
if (typeof document === "undefined")
|
|
120
|
+
return;
|
|
121
|
+
const attribute = isProperty ? "property" : "name";
|
|
122
|
+
let meta = document.querySelector(`meta[${attribute}="${name}"]`);
|
|
123
|
+
if (!meta) {
|
|
124
|
+
meta = document.createElement("meta");
|
|
125
|
+
meta.setAttribute(attribute, name);
|
|
126
|
+
document.head.appendChild(meta);
|
|
127
|
+
}
|
|
128
|
+
meta.setAttribute("content", content);
|
|
129
|
+
}
|
|
130
|
+
function setLink(rel, href) {
|
|
131
|
+
if (typeof document === "undefined")
|
|
132
|
+
return;
|
|
133
|
+
let link = document.querySelector(`link[rel="${rel}"]`);
|
|
134
|
+
if (!link) {
|
|
135
|
+
link = document.createElement("link");
|
|
136
|
+
link.setAttribute("rel", rel);
|
|
137
|
+
document.head.appendChild(link);
|
|
138
|
+
}
|
|
139
|
+
link.setAttribute("href", href);
|
|
140
|
+
}
|
|
141
|
+
function useSEO(options) {
|
|
142
|
+
const {
|
|
143
|
+
title,
|
|
144
|
+
description,
|
|
145
|
+
author,
|
|
146
|
+
keywords,
|
|
147
|
+
ogImage,
|
|
148
|
+
ogImageWidth,
|
|
149
|
+
ogImageHeight,
|
|
150
|
+
twitterCard = "summary_large_image",
|
|
151
|
+
twitterSite,
|
|
152
|
+
twitterCreator,
|
|
153
|
+
canonical
|
|
154
|
+
} = options;
|
|
155
|
+
if (title) {
|
|
156
|
+
setTitle(title);
|
|
157
|
+
setMeta("og:title", title, true);
|
|
158
|
+
setMeta("twitter:title", title);
|
|
159
|
+
}
|
|
160
|
+
if (description) {
|
|
161
|
+
setMeta("description", description);
|
|
162
|
+
setMeta("og:description", description, true);
|
|
163
|
+
setMeta("twitter:description", description);
|
|
164
|
+
}
|
|
165
|
+
if (author) {
|
|
166
|
+
setMeta("author", author);
|
|
167
|
+
}
|
|
168
|
+
if (keywords && keywords.length > 0) {
|
|
169
|
+
setMeta("keywords", keywords.join(", "));
|
|
170
|
+
}
|
|
171
|
+
if (ogImage) {
|
|
172
|
+
setMeta("og:image", ogImage, true);
|
|
173
|
+
setMeta("twitter:image", ogImage);
|
|
174
|
+
}
|
|
175
|
+
if (ogImageWidth) {
|
|
176
|
+
setMeta("og:image:width", ogImageWidth, true);
|
|
177
|
+
}
|
|
178
|
+
if (ogImageHeight) {
|
|
179
|
+
setMeta("og:image:height", ogImageHeight, true);
|
|
180
|
+
}
|
|
181
|
+
setMeta("twitter:card", twitterCard);
|
|
182
|
+
if (twitterSite) {
|
|
183
|
+
setMeta("twitter:site", twitterSite);
|
|
184
|
+
}
|
|
185
|
+
if (twitterCreator) {
|
|
186
|
+
setMeta("twitter:creator", twitterCreator);
|
|
187
|
+
}
|
|
188
|
+
if (canonical) {
|
|
189
|
+
setLink("canonical", canonical);
|
|
190
|
+
}
|
|
191
|
+
setMeta("og:type", "website", true);
|
|
192
|
+
if (typeof window !== "undefined") {
|
|
193
|
+
setMeta("og:url", window.location.href, true);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function generateSEOTags(options) {
|
|
197
|
+
const tags = [];
|
|
198
|
+
const {
|
|
199
|
+
title,
|
|
200
|
+
description,
|
|
201
|
+
author,
|
|
202
|
+
keywords,
|
|
203
|
+
ogImage,
|
|
204
|
+
ogImageWidth,
|
|
205
|
+
ogImageHeight,
|
|
206
|
+
twitterCard = "summary_large_image",
|
|
207
|
+
twitterSite,
|
|
208
|
+
twitterCreator,
|
|
209
|
+
canonical
|
|
210
|
+
} = options;
|
|
211
|
+
if (title) {
|
|
212
|
+
tags.push(`<title>${escapeHtml(title)}</title>`);
|
|
213
|
+
tags.push(`<meta property="og:title" content="${escapeHtml(title)}" />`);
|
|
214
|
+
tags.push(`<meta name="twitter:title" content="${escapeHtml(title)}" />`);
|
|
215
|
+
}
|
|
216
|
+
if (description) {
|
|
217
|
+
tags.push(`<meta name="description" content="${escapeHtml(description)}" />`);
|
|
218
|
+
tags.push(`<meta property="og:description" content="${escapeHtml(description)}" />`);
|
|
219
|
+
tags.push(`<meta name="twitter:description" content="${escapeHtml(description)}" />`);
|
|
220
|
+
}
|
|
221
|
+
if (author) {
|
|
222
|
+
tags.push(`<meta name="author" content="${escapeHtml(author)}" />`);
|
|
223
|
+
}
|
|
224
|
+
if (keywords && keywords.length > 0) {
|
|
225
|
+
tags.push(`<meta name="keywords" content="${escapeHtml(keywords.join(", "))}" />`);
|
|
226
|
+
}
|
|
227
|
+
if (ogImage) {
|
|
228
|
+
tags.push(`<meta property="og:image" content="${escapeHtml(ogImage)}" />`);
|
|
229
|
+
tags.push(`<meta name="twitter:image" content="${escapeHtml(ogImage)}" />`);
|
|
230
|
+
}
|
|
231
|
+
if (ogImageWidth) {
|
|
232
|
+
tags.push(`<meta property="og:image:width" content="${escapeHtml(ogImageWidth)}" />`);
|
|
233
|
+
}
|
|
234
|
+
if (ogImageHeight) {
|
|
235
|
+
tags.push(`<meta property="og:image:height" content="${escapeHtml(ogImageHeight)}" />`);
|
|
236
|
+
}
|
|
237
|
+
tags.push(`<meta name="twitter:card" content="${escapeHtml(twitterCard)}" />`);
|
|
238
|
+
if (twitterSite) {
|
|
239
|
+
tags.push(`<meta name="twitter:site" content="${escapeHtml(twitterSite)}" />`);
|
|
240
|
+
}
|
|
241
|
+
if (twitterCreator) {
|
|
242
|
+
tags.push(`<meta name="twitter:creator" content="${escapeHtml(twitterCreator)}" />`);
|
|
243
|
+
}
|
|
244
|
+
if (canonical) {
|
|
245
|
+
tags.push(`<link rel="canonical" href="${escapeHtml(canonical)}" />`);
|
|
246
|
+
}
|
|
247
|
+
tags.push('<meta property="og:type" content="website" />');
|
|
248
|
+
return tags.join(`
|
|
249
|
+
`);
|
|
250
|
+
}
|
|
251
|
+
function escapeHtml(str) {
|
|
252
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/composables/utilities/useClickOutside.ts
|
|
256
|
+
function useClickOutside(elementRef, callback, options = {}) {
|
|
257
|
+
const { enabled = true, ignore = [] } = options;
|
|
258
|
+
const handleClick = (event) => {
|
|
259
|
+
if (!enabled || !elementRef)
|
|
260
|
+
return;
|
|
261
|
+
const target = event.target;
|
|
262
|
+
if (!elementRef.contains(target)) {
|
|
263
|
+
const shouldIgnore = ignore.some((selector) => {
|
|
264
|
+
const elements = document.querySelectorAll(selector);
|
|
265
|
+
return Array.from(elements).some((el) => el.contains(target));
|
|
266
|
+
});
|
|
267
|
+
if (!shouldIgnore) {
|
|
268
|
+
callback(event);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
if (typeof document !== "undefined") {
|
|
273
|
+
document.addEventListener("mousedown", handleClick);
|
|
274
|
+
document.addEventListener("touchstart", handleClick);
|
|
275
|
+
}
|
|
276
|
+
return () => {
|
|
277
|
+
if (typeof document !== "undefined") {
|
|
278
|
+
document.removeEventListener("mousedown", handleClick);
|
|
279
|
+
document.removeEventListener("touchstart", handleClick);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/composables/utilities/useFocusTrap.ts
|
|
285
|
+
function useFocusTrap(containerRef, options = {}) {
|
|
286
|
+
const {
|
|
287
|
+
enabled = true,
|
|
288
|
+
initialFocus = null,
|
|
289
|
+
returnFocus = true,
|
|
290
|
+
fallbackFocus = null
|
|
291
|
+
} = options;
|
|
292
|
+
let previouslyFocusedElement = null;
|
|
293
|
+
let isActive = false;
|
|
294
|
+
function getFocusableElements() {
|
|
295
|
+
if (!containerRef)
|
|
296
|
+
return [];
|
|
297
|
+
const focusableSelectors = [
|
|
298
|
+
"a[href]",
|
|
299
|
+
"button:not([disabled])",
|
|
300
|
+
"textarea:not([disabled])",
|
|
301
|
+
"input:not([disabled])",
|
|
302
|
+
"select:not([disabled])",
|
|
303
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
304
|
+
].join(",");
|
|
305
|
+
return Array.from(containerRef.querySelectorAll(focusableSelectors));
|
|
306
|
+
}
|
|
307
|
+
function handleTab(event) {
|
|
308
|
+
if (!enabled || !isActive || !containerRef)
|
|
309
|
+
return;
|
|
310
|
+
const focusableElements = getFocusableElements();
|
|
311
|
+
if (focusableElements.length === 0) {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const firstElement = focusableElements[0];
|
|
316
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
317
|
+
if (event.shiftKey) {
|
|
318
|
+
if (document.activeElement === firstElement || document.activeElement === containerRef) {
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
lastElement.focus();
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
if (document.activeElement === lastElement) {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
firstElement.focus();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function handleEscape(event) {
|
|
330
|
+
if (event.key === "Escape" && enabled && isActive) {
|
|
331
|
+
deactivate();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function activate() {
|
|
335
|
+
if (!enabled || !containerRef || isActive)
|
|
336
|
+
return;
|
|
337
|
+
previouslyFocusedElement = document.activeElement;
|
|
338
|
+
if (initialFocus) {
|
|
339
|
+
initialFocus.focus();
|
|
340
|
+
} else {
|
|
341
|
+
const focusableElements = getFocusableElements();
|
|
342
|
+
if (focusableElements.length > 0) {
|
|
343
|
+
focusableElements[0].focus();
|
|
344
|
+
} else if (fallbackFocus) {
|
|
345
|
+
fallbackFocus.focus();
|
|
346
|
+
} else {
|
|
347
|
+
containerRef.focus();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
document.addEventListener("keydown", handleTab);
|
|
351
|
+
document.addEventListener("keydown", handleEscape);
|
|
352
|
+
isActive = true;
|
|
353
|
+
}
|
|
354
|
+
function deactivate() {
|
|
355
|
+
if (!isActive)
|
|
356
|
+
return;
|
|
357
|
+
document.removeEventListener("keydown", handleTab);
|
|
358
|
+
document.removeEventListener("keydown", handleEscape);
|
|
359
|
+
if (returnFocus && previouslyFocusedElement) {
|
|
360
|
+
previouslyFocusedElement.focus();
|
|
361
|
+
}
|
|
362
|
+
isActive = false;
|
|
363
|
+
}
|
|
364
|
+
return { activate, deactivate };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/composables/utilities/useKeyboard.ts
|
|
368
|
+
function useKeyboard(handlers, options = {}) {
|
|
369
|
+
const {
|
|
370
|
+
enabled = true,
|
|
371
|
+
preventDefault = true,
|
|
372
|
+
stopPropagation = false,
|
|
373
|
+
target = typeof document !== "undefined" ? document : null
|
|
374
|
+
} = options;
|
|
375
|
+
const handlerArray = Array.isArray(handlers) ? handlers : [handlers];
|
|
376
|
+
const handleKeydown = (event) => {
|
|
377
|
+
if (!enabled)
|
|
378
|
+
return;
|
|
379
|
+
handlerArray.forEach((handler) => {
|
|
380
|
+
const keys = Array.isArray(handler.key) ? handler.key : [handler.key];
|
|
381
|
+
const keyMatches = keys.some((k) => k.toLowerCase() === event.key.toLowerCase());
|
|
382
|
+
if (!keyMatches)
|
|
383
|
+
return;
|
|
384
|
+
if (handler.ctrl !== undefined && handler.ctrl !== event.ctrlKey)
|
|
385
|
+
return;
|
|
386
|
+
if (handler.shift !== undefined && handler.shift !== event.shiftKey)
|
|
387
|
+
return;
|
|
388
|
+
if (handler.alt !== undefined && handler.alt !== event.altKey)
|
|
389
|
+
return;
|
|
390
|
+
if (handler.meta !== undefined && handler.meta !== event.metaKey)
|
|
391
|
+
return;
|
|
392
|
+
if (preventDefault)
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
if (stopPropagation)
|
|
395
|
+
event.stopPropagation();
|
|
396
|
+
handler.handler(event);
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
if (target) {
|
|
400
|
+
target.addEventListener("keydown", handleKeydown);
|
|
401
|
+
}
|
|
402
|
+
return () => {
|
|
403
|
+
if (target) {
|
|
404
|
+
target.removeEventListener("keydown", handleKeydown);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
var KeyboardShortcuts = {
|
|
409
|
+
ESCAPE: "Escape",
|
|
410
|
+
ENTER: "Enter",
|
|
411
|
+
SPACE: " ",
|
|
412
|
+
TAB: "Tab",
|
|
413
|
+
ARROW_UP: "ArrowUp",
|
|
414
|
+
ARROW_DOWN: "ArrowDown",
|
|
415
|
+
ARROW_LEFT: "ArrowLeft",
|
|
416
|
+
ARROW_RIGHT: "ArrowRight",
|
|
417
|
+
HOME: "Home",
|
|
418
|
+
END: "End",
|
|
419
|
+
PAGE_UP: "PageUp",
|
|
420
|
+
PAGE_DOWN: "PageDown"
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/composables/utilities/useLocalStorage.ts
|
|
424
|
+
function useLocalStorage(key, initialValue, options = {}) {
|
|
425
|
+
const {
|
|
426
|
+
serializer = JSON.stringify,
|
|
427
|
+
deserializer = JSON.parse,
|
|
428
|
+
onError = console.error
|
|
429
|
+
} = options;
|
|
430
|
+
let storedValue = initialValue;
|
|
431
|
+
try {
|
|
432
|
+
if (typeof window !== "undefined") {
|
|
433
|
+
const item = window.localStorage.getItem(key);
|
|
434
|
+
if (item !== null) {
|
|
435
|
+
storedValue = deserializer(item);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
} catch (error) {
|
|
439
|
+
onError(error);
|
|
440
|
+
}
|
|
441
|
+
let value = storedValue;
|
|
442
|
+
const listeners = new Set;
|
|
443
|
+
function setValue(newValue) {
|
|
444
|
+
try {
|
|
445
|
+
const valueToStore = typeof newValue === "function" ? newValue(value) : newValue;
|
|
446
|
+
value = valueToStore;
|
|
447
|
+
if (typeof window !== "undefined") {
|
|
448
|
+
window.localStorage.setItem(key, serializer(valueToStore));
|
|
449
|
+
}
|
|
450
|
+
listeners.forEach((listener) => listener(valueToStore));
|
|
451
|
+
} catch (error) {
|
|
452
|
+
onError(error);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function removeValue() {
|
|
456
|
+
try {
|
|
457
|
+
value = initialValue;
|
|
458
|
+
if (typeof window !== "undefined") {
|
|
459
|
+
window.localStorage.removeItem(key);
|
|
460
|
+
}
|
|
461
|
+
listeners.forEach((listener) => listener(initialValue));
|
|
462
|
+
} catch (error) {
|
|
463
|
+
onError(error);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (typeof window !== "undefined") {
|
|
467
|
+
const handleStorageChange = (event) => {
|
|
468
|
+
if (event.key === key && event.newValue !== null) {
|
|
469
|
+
try {
|
|
470
|
+
const newValue = deserializer(event.newValue);
|
|
471
|
+
value = newValue;
|
|
472
|
+
listeners.forEach((listener) => listener(newValue));
|
|
473
|
+
} catch (error) {
|
|
474
|
+
onError(error);
|
|
475
|
+
}
|
|
476
|
+
} else if (event.key === key && event.newValue === null) {
|
|
477
|
+
value = initialValue;
|
|
478
|
+
listeners.forEach((listener) => listener(initialValue));
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
window.addEventListener("storage", handleStorageChange);
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
value,
|
|
485
|
+
setValue,
|
|
486
|
+
removeValue
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// src/composables/utilities/useMediaQuery.ts
|
|
491
|
+
function useMediaQuery(query, options = {}) {
|
|
492
|
+
const { defaultValue = false } = options;
|
|
493
|
+
let matches = defaultValue;
|
|
494
|
+
let mediaQueryList = null;
|
|
495
|
+
if (typeof window !== "undefined" && "matchMedia" in window) {
|
|
496
|
+
mediaQueryList = window.matchMedia(query);
|
|
497
|
+
matches = mediaQueryList.matches;
|
|
498
|
+
const handleChange = (event) => {
|
|
499
|
+
matches = event.matches;
|
|
500
|
+
};
|
|
501
|
+
if (mediaQueryList.addEventListener) {
|
|
502
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
503
|
+
} else {
|
|
504
|
+
mediaQueryList.addListener(handleChange);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function updateMatches() {
|
|
508
|
+
if (mediaQueryList) {
|
|
509
|
+
matches = mediaQueryList.matches;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return { matches, updateMatches };
|
|
513
|
+
}
|
|
514
|
+
var Breakpoints = {
|
|
515
|
+
xs: "(min-width: 320px)",
|
|
516
|
+
sm: "(min-width: 640px)",
|
|
517
|
+
md: "(min-width: 768px)",
|
|
518
|
+
lg: "(min-width: 1024px)",
|
|
519
|
+
xl: "(min-width: 1280px)",
|
|
520
|
+
"2xl": "(min-width: 1536px)",
|
|
521
|
+
mobile: "(max-width: 767px)",
|
|
522
|
+
tablet: "(min-width: 768px) and (max-width: 1023px)",
|
|
523
|
+
desktop: "(min-width: 1024px)",
|
|
524
|
+
dark: "(prefers-color-scheme: dark)",
|
|
525
|
+
light: "(prefers-color-scheme: light)",
|
|
526
|
+
reducedMotion: "(prefers-reduced-motion: reduce)",
|
|
527
|
+
portrait: "(orientation: portrait)",
|
|
528
|
+
landscape: "(orientation: landscape)"
|
|
529
|
+
};
|
|
530
|
+
function useBreakpoint(breakpoint) {
|
|
531
|
+
return useMediaQuery(Breakpoints[breakpoint]);
|
|
532
|
+
}
|
|
533
|
+
function useIsMobile() {
|
|
534
|
+
return useMediaQuery(Breakpoints.mobile);
|
|
535
|
+
}
|
|
536
|
+
function useIsDesktop() {
|
|
537
|
+
return useMediaQuery(Breakpoints.desktop);
|
|
538
|
+
}
|
|
539
|
+
function useIsDarkMode() {
|
|
540
|
+
return useMediaQuery(Breakpoints.dark);
|
|
541
|
+
}
|
|
542
|
+
function usePrefersReducedMotion() {
|
|
543
|
+
return useMediaQuery(Breakpoints.reducedMotion);
|
|
544
|
+
}
|
|
545
|
+
// src/ui/accordion/Accordion.stx
|
|
546
|
+
var Accordion_default = "./Accordion-pt8j917s.stx";
|
|
547
|
+
// src/ui/accordion/AccordionItem.stx
|
|
548
|
+
var AccordionItem_default = "./AccordionItem-hbhzx63p.stx";
|
|
549
|
+
// src/ui/audio/Audio.stx
|
|
550
|
+
var Audio_default = "./Audio-hjywk3qc.stx";
|
|
551
|
+
// src/ui/auth/Login.stx
|
|
552
|
+
var Login_default = "./Login-gepemsth.stx";
|
|
553
|
+
// src/ui/auth/Signup.stx
|
|
554
|
+
var Signup_default = "./Signup-hxm5hwkr.stx";
|
|
555
|
+
// src/ui/auth/TwoFactorChallenge.stx
|
|
556
|
+
var TwoFactorChallenge_default = "./TwoFactorChallenge-y5m3nk79.stx";
|
|
557
|
+
// src/ui/avatar/Avatar.stx
|
|
558
|
+
var Avatar_default = "./Avatar-h3jmwcq0.stx";
|
|
559
|
+
// src/ui/badge/Badge.stx
|
|
560
|
+
var Badge_default = "./Badge-k8dy3d53.stx";
|
|
561
|
+
// src/ui/breadcrumb/Breadcrumb.stx
|
|
562
|
+
var Breadcrumb_default = "./Breadcrumb-7f7s4d02.stx";
|
|
563
|
+
// src/utils/error-handling.ts
|
|
564
|
+
import process from "process";
|
|
565
|
+
var DOCS_BASE_URL = "https://stacksjs.com/components";
|
|
566
|
+
|
|
567
|
+
class ComponentError extends Error {
|
|
568
|
+
component;
|
|
569
|
+
context;
|
|
570
|
+
constructor(component, message, context = {}) {
|
|
571
|
+
const fullMessage = ComponentError.formatMessage(component, message, context);
|
|
572
|
+
super(fullMessage);
|
|
573
|
+
this.name = "ComponentError";
|
|
574
|
+
this.component = component;
|
|
575
|
+
this.context = { component, ...context };
|
|
576
|
+
if (Error.captureStackTrace) {
|
|
577
|
+
Error.captureStackTrace(this, ComponentError);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
static formatMessage(component, message, context) {
|
|
581
|
+
let formatted = `[${component}] ${message}`;
|
|
582
|
+
if (context.prop) {
|
|
583
|
+
formatted += `
|
|
584
|
+
Prop: "${context.prop}"`;
|
|
585
|
+
}
|
|
586
|
+
if (context.received !== undefined) {
|
|
587
|
+
formatted += `
|
|
588
|
+
Received: ${JSON.stringify(context.received)}`;
|
|
589
|
+
}
|
|
590
|
+
if (context.expected !== undefined) {
|
|
591
|
+
const expected = Array.isArray(context.expected) ? context.expected.map((v) => JSON.stringify(v)).join(", ") : JSON.stringify(context.expected);
|
|
592
|
+
formatted += `
|
|
593
|
+
Expected: ${expected}`;
|
|
594
|
+
}
|
|
595
|
+
if (context.details) {
|
|
596
|
+
formatted += `
|
|
597
|
+
Details: ${context.details}`;
|
|
598
|
+
}
|
|
599
|
+
if (context.docsUrl) {
|
|
600
|
+
formatted += `
|
|
601
|
+
Documentation: ${context.docsUrl}`;
|
|
602
|
+
} else if (component) {
|
|
603
|
+
formatted += `
|
|
604
|
+
Documentation: ${DOCS_BASE_URL}/${component.toLowerCase()}`;
|
|
605
|
+
}
|
|
606
|
+
return formatted;
|
|
607
|
+
}
|
|
608
|
+
toJSON() {
|
|
609
|
+
return {
|
|
610
|
+
name: this.name,
|
|
611
|
+
message: this.message,
|
|
612
|
+
component: this.component,
|
|
613
|
+
context: this.context,
|
|
614
|
+
stack: this.stack
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
var ErrorTypes = {
|
|
619
|
+
invalidProp(component, prop, received, expected) {
|
|
620
|
+
return new ComponentError(component, `Invalid prop value for "${prop}"`, {
|
|
621
|
+
prop,
|
|
622
|
+
received,
|
|
623
|
+
expected,
|
|
624
|
+
details: Array.isArray(expected) ? `The "${prop}" prop must be one of the allowed values` : `The "${prop}" prop does not match the expected type`
|
|
625
|
+
});
|
|
626
|
+
},
|
|
627
|
+
requiredProp(component, prop) {
|
|
628
|
+
return new ComponentError(component, `Required prop "${prop}" is missing`, {
|
|
629
|
+
prop,
|
|
630
|
+
details: `The "${prop}" prop is required for ${component} to function correctly`
|
|
631
|
+
});
|
|
632
|
+
},
|
|
633
|
+
invalidType(component, prop, received, expected) {
|
|
634
|
+
return new ComponentError(component, `Invalid type for prop "${prop}"`, {
|
|
635
|
+
prop,
|
|
636
|
+
received: typeof received,
|
|
637
|
+
expected,
|
|
638
|
+
details: `Expected "${prop}" to be of type ${expected}, but received ${typeof received}`
|
|
639
|
+
});
|
|
640
|
+
},
|
|
641
|
+
componentNotFound(componentName) {
|
|
642
|
+
return new ComponentError("ComponentLoader", `Component "${componentName}" not found`, {
|
|
643
|
+
component: componentName,
|
|
644
|
+
details: "Make sure the component is properly imported and registered"
|
|
645
|
+
});
|
|
646
|
+
},
|
|
647
|
+
invalidChildren(component, received, expected) {
|
|
648
|
+
return new ComponentError(component, "Invalid children", {
|
|
649
|
+
received: typeof received,
|
|
650
|
+
expected,
|
|
651
|
+
details: `${component} expects ${expected} as children`
|
|
652
|
+
});
|
|
653
|
+
},
|
|
654
|
+
stateUpdate(component, stateName, error) {
|
|
655
|
+
return new ComponentError(component, `Failed to update state "${stateName}"`, {
|
|
656
|
+
details: error.message
|
|
657
|
+
});
|
|
658
|
+
},
|
|
659
|
+
eventHandler(component, eventName, error) {
|
|
660
|
+
return new ComponentError(component, `Error in "${eventName}" event handler`, {
|
|
661
|
+
details: error.message
|
|
662
|
+
});
|
|
663
|
+
},
|
|
664
|
+
render(component, error) {
|
|
665
|
+
return new ComponentError(component, "Failed to render component", {
|
|
666
|
+
details: error.message
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
var errorHandler = null;
|
|
671
|
+
function setErrorHandler(handler) {
|
|
672
|
+
errorHandler = handler;
|
|
673
|
+
}
|
|
674
|
+
function clearErrorHandler() {
|
|
675
|
+
errorHandler = null;
|
|
676
|
+
}
|
|
677
|
+
function handleError(error, options = {}) {
|
|
678
|
+
const { throwError = true, logError = true } = options;
|
|
679
|
+
if (logError && process.env.NODE_ENV !== "production") {
|
|
680
|
+
console.error("Component Error:", error);
|
|
681
|
+
if (error instanceof ComponentError) {
|
|
682
|
+
console.group("Error Details");
|
|
683
|
+
console.log("Component:", error.component);
|
|
684
|
+
console.log("Context:", error.context);
|
|
685
|
+
console.groupEnd();
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (errorHandler) {
|
|
689
|
+
try {
|
|
690
|
+
errorHandler(error);
|
|
691
|
+
} catch (handlerError) {
|
|
692
|
+
console.error("Error in error handler:", handlerError);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
if (throwError) {
|
|
696
|
+
throw error;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function wrapErrorHandler(fn, component, eventName) {
|
|
700
|
+
return (...args) => {
|
|
701
|
+
try {
|
|
702
|
+
const result = fn(...args);
|
|
703
|
+
if (result instanceof Promise) {
|
|
704
|
+
return result.catch((error) => {
|
|
705
|
+
const wrappedError = ErrorTypes.eventHandler(component, eventName, error);
|
|
706
|
+
handleError(wrappedError, { throwError: false });
|
|
707
|
+
throw wrappedError;
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return result;
|
|
711
|
+
} catch (error) {
|
|
712
|
+
const wrappedError = ErrorTypes.eventHandler(component, eventName, error);
|
|
713
|
+
handleError(wrappedError, { throwError: false });
|
|
714
|
+
throw wrappedError;
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function assert(condition, error) {
|
|
719
|
+
if (!condition) {
|
|
720
|
+
throw error;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function warn(component, message, context = {}) {
|
|
724
|
+
if (process.env.NODE_ENV === "production") {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const fullMessage = ComponentError.formatMessage(component, message, context);
|
|
728
|
+
console.warn(`\u26A0\uFE0F ${fullMessage}`);
|
|
729
|
+
}
|
|
730
|
+
function devAssert(condition, error) {
|
|
731
|
+
if (process.env.NODE_ENV === "production") {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
assert(condition, error);
|
|
735
|
+
}
|
|
736
|
+
function createDebugger(component) {
|
|
737
|
+
const isDebug = typeof process !== "undefined" && process.env.DEBUG === "true";
|
|
738
|
+
return {
|
|
739
|
+
log(...args) {
|
|
740
|
+
if (isDebug) {
|
|
741
|
+
console.log(`[${component}]`, ...args);
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
warn(message, context) {
|
|
745
|
+
warn(component, message, context);
|
|
746
|
+
},
|
|
747
|
+
error(message, context) {
|
|
748
|
+
const error = new ComponentError(component, message, context);
|
|
749
|
+
handleError(error, { throwError: false });
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function errorBoundary(component, renderFn, fallback) {
|
|
754
|
+
try {
|
|
755
|
+
return renderFn();
|
|
756
|
+
} catch (error) {
|
|
757
|
+
const wrappedError = ErrorTypes.render(component, error);
|
|
758
|
+
handleError(wrappedError, { throwError: false });
|
|
759
|
+
return fallback;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/utils/prop-validation.ts
|
|
764
|
+
import process2 from "process";
|
|
765
|
+
var isDevelopment = process2.env.NODE_ENV !== "production";
|
|
766
|
+
|
|
767
|
+
class Validator {
|
|
768
|
+
validate;
|
|
769
|
+
message;
|
|
770
|
+
isRequired;
|
|
771
|
+
constructor(validate, message, isRequired = false) {
|
|
772
|
+
this.validate = validate;
|
|
773
|
+
this.message = message;
|
|
774
|
+
this.isRequired = isRequired;
|
|
775
|
+
}
|
|
776
|
+
get required() {
|
|
777
|
+
return new Validator(this.validate, this.message, true);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
var PropTypes = {
|
|
781
|
+
string: new Validator((value) => typeof value === "string", (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`string\`.`),
|
|
782
|
+
number: new Validator((value) => typeof value === "number" && !Number.isNaN(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`number\`.`),
|
|
783
|
+
boolean: new Validator((value) => typeof value === "boolean", (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`boolean\`.`),
|
|
784
|
+
func: new Validator((value) => typeof value === "function", (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`function\`.`),
|
|
785
|
+
object: new Validator((value) => typeof value === "object" && value !== null && !Array.isArray(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`object\`.`),
|
|
786
|
+
array: new Validator((value) => Array.isArray(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of type \`${typeof value}\` supplied to \`${componentName}\`, expected \`array\`.`),
|
|
787
|
+
any: new Validator(() => true, () => ""),
|
|
788
|
+
oneOf(validValues) {
|
|
789
|
+
return new Validator((value) => validValues.includes(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected one of [${validValues.map((v) => JSON.stringify(v)).join(", ")}].`);
|
|
790
|
+
},
|
|
791
|
+
oneOfType(validators) {
|
|
792
|
+
return new Validator((value, propName, componentName) => validators.some((v) => v.validate(value, propName, componentName)), (_value, propName, componentName) => `Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected one of the specified types.`);
|
|
793
|
+
},
|
|
794
|
+
arrayOf(validator) {
|
|
795
|
+
return new Validator((value, propName, componentName) => {
|
|
796
|
+
if (!Array.isArray(value))
|
|
797
|
+
return false;
|
|
798
|
+
return value.every((item, index) => validator.validate(item, `${propName}[${index}]`, componentName));
|
|
799
|
+
}, (_value, propName, componentName) => `Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected array of specified type.`);
|
|
800
|
+
},
|
|
801
|
+
shape(shape) {
|
|
802
|
+
return new Validator((value, propName, componentName) => {
|
|
803
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
804
|
+
return false;
|
|
805
|
+
for (const [key, validator] of Object.entries(shape)) {
|
|
806
|
+
if (validator.isRequired && !(key in value))
|
|
807
|
+
return false;
|
|
808
|
+
if (key in value && !validator.validate(value[key], `${propName}.${key}`, componentName))
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
return true;
|
|
812
|
+
}, (_value, propName, componentName) => `Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected object matching specified shape.`);
|
|
813
|
+
},
|
|
814
|
+
instanceOf(expectedClass) {
|
|
815
|
+
return new Validator((value) => value instanceof expectedClass, (_value, propName, componentName) => `Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected instance of \`${expectedClass.name}\`.`);
|
|
816
|
+
},
|
|
817
|
+
custom(validatorFn, errorMessage) {
|
|
818
|
+
const messageGenerator = typeof errorMessage === "string" ? () => errorMessage : errorMessage;
|
|
819
|
+
return new Validator(validatorFn, messageGenerator);
|
|
820
|
+
},
|
|
821
|
+
min(min) {
|
|
822
|
+
return new Validator((value) => typeof value === "number" && value >= min, (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected value >= ${min}.`);
|
|
823
|
+
},
|
|
824
|
+
max(max) {
|
|
825
|
+
return new Validator((value) => typeof value === "number" && value <= max, (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected value <= ${max}.`);
|
|
826
|
+
},
|
|
827
|
+
range(min, max) {
|
|
828
|
+
return new Validator((value) => typeof value === "number" && value >= min && value <= max, (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected value between ${min} and ${max}.`);
|
|
829
|
+
},
|
|
830
|
+
pattern(pattern) {
|
|
831
|
+
return new Validator((value) => typeof value === "string" && pattern.test(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected value matching pattern ${pattern}.`);
|
|
832
|
+
},
|
|
833
|
+
email: new Validator((value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value), (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected valid email address.`),
|
|
834
|
+
url: new Validator((value) => {
|
|
835
|
+
if (typeof value !== "string")
|
|
836
|
+
return false;
|
|
837
|
+
try {
|
|
838
|
+
const _url = new URL(value);
|
|
839
|
+
return true;
|
|
840
|
+
} catch {
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
}, (value, propName, componentName) => `Invalid prop \`${propName}\` of value \`${value}\` supplied to \`${componentName}\`, expected valid URL.`)
|
|
844
|
+
};
|
|
845
|
+
function validateProps(componentName, props, schema, options = {}) {
|
|
846
|
+
const { throwOnError = false, logWarnings = isDevelopment } = options;
|
|
847
|
+
const errors = [];
|
|
848
|
+
if (!isDevelopment) {
|
|
849
|
+
return { valid: true, errors: [] };
|
|
850
|
+
}
|
|
851
|
+
for (const [propName, validator] of Object.entries(schema)) {
|
|
852
|
+
const propValue = props[propName];
|
|
853
|
+
const isUndefined = propValue === undefined;
|
|
854
|
+
if (validator.isRequired && isUndefined) {
|
|
855
|
+
const error = `Required prop \`${propName}\` was not specified in \`${componentName}\`.`;
|
|
856
|
+
errors.push(error);
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
if (isUndefined)
|
|
860
|
+
continue;
|
|
861
|
+
if (!validator.validate(propValue, propName, componentName)) {
|
|
862
|
+
const error = validator.message(propValue, propName, componentName);
|
|
863
|
+
errors.push(error);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (errors.length > 0) {
|
|
867
|
+
if (logWarnings) {
|
|
868
|
+
console.group(`\u26A0\uFE0F Prop validation failed for \`${componentName}\``);
|
|
869
|
+
errors.forEach((error) => console.warn(error));
|
|
870
|
+
console.groupEnd();
|
|
871
|
+
}
|
|
872
|
+
if (throwOnError) {
|
|
873
|
+
throw new Error(`Prop validation failed for \`${componentName}\`:
|
|
874
|
+
${errors.join(`
|
|
875
|
+
`)}`);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return {
|
|
879
|
+
valid: errors.length === 0,
|
|
880
|
+
errors
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function createPropValidator(componentName, schema, options) {
|
|
884
|
+
return (props) => validateProps(componentName, props, schema, options);
|
|
885
|
+
}
|
|
886
|
+
function assertProp(value, validator, name = "value") {
|
|
887
|
+
if (!isDevelopment)
|
|
888
|
+
return;
|
|
889
|
+
if (!validator.validate(value, name, "assertion")) {
|
|
890
|
+
throw new Error(validator.message(value, name, "assertion"));
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
function warnProp(value, validator, name = "value") {
|
|
894
|
+
if (!isDevelopment)
|
|
895
|
+
return;
|
|
896
|
+
if (!validator.validate(value, name, "warning")) {
|
|
897
|
+
console.warn(validator.message(value, name, "warning"));
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// src/ui/button/Button.stx
|
|
902
|
+
var Button_default = "./Button-1vknasy3.stx";
|
|
903
|
+
|
|
904
|
+
// src/ui/button/index.ts
|
|
905
|
+
var buttonPropSchema = {
|
|
906
|
+
variant: PropTypes.oneOf(["primary", "secondary", "outline", "ghost", "danger"]),
|
|
907
|
+
size: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"]),
|
|
908
|
+
disabled: PropTypes.boolean,
|
|
909
|
+
loading: PropTypes.boolean,
|
|
910
|
+
type: PropTypes.oneOf(["button", "submit", "reset"]),
|
|
911
|
+
fullWidth: PropTypes.boolean,
|
|
912
|
+
leftIcon: PropTypes.string,
|
|
913
|
+
rightIcon: PropTypes.string,
|
|
914
|
+
className: PropTypes.string,
|
|
915
|
+
onClick: PropTypes.func
|
|
916
|
+
};
|
|
917
|
+
var validateButtonProps = createPropValidator("Button", buttonPropSchema);
|
|
918
|
+
function createSafeClickHandler(handler) {
|
|
919
|
+
return wrapErrorHandler(handler, "Button", "onClick");
|
|
920
|
+
}
|
|
921
|
+
function validateVariant(variant) {
|
|
922
|
+
if (variant && !["primary", "secondary", "outline", "ghost", "danger"].includes(variant)) {
|
|
923
|
+
throw ErrorTypes.invalidProp("Button", "variant", variant, ["primary", "secondary", "outline", "ghost", "danger"]);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function validateSize(size) {
|
|
927
|
+
if (size && !["xs", "sm", "md", "lg", "xl"].includes(size)) {
|
|
928
|
+
throw ErrorTypes.invalidProp("Button", "size", size, ["xs", "sm", "md", "lg", "xl"]);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
// src/ui/calendar/Calendar.stx
|
|
932
|
+
var Calendar_default = "./Calendar-reny0et7.stx";
|
|
933
|
+
// src/ui/card/Card.stx
|
|
934
|
+
var Card_default = "./Card-c1g1fd1w.stx";
|
|
935
|
+
// src/ui/checkbox/Checkbox.stx
|
|
936
|
+
var Checkbox_default = "./Checkbox-aqmq4cqv.stx";
|
|
937
|
+
// src/ui/combobox/Combobox.stx
|
|
938
|
+
var Combobox_default = "./Combobox-fdkr6cdq.stx";
|
|
939
|
+
// src/ui/combobox/ComboboxButton.stx
|
|
940
|
+
var ComboboxButton_default = "./ComboboxButton-g76stp1e.stx";
|
|
941
|
+
// src/ui/combobox/ComboboxInput.stx
|
|
942
|
+
var ComboboxInput_default = "./ComboboxInput-z1293bbh.stx";
|
|
943
|
+
// src/ui/combobox/ComboboxOption.stx
|
|
944
|
+
var ComboboxOption_default = "./ComboboxOption-hmxt3gte.stx";
|
|
945
|
+
// src/ui/combobox/ComboboxOptions.stx
|
|
946
|
+
var ComboboxOptions_default = "./ComboboxOptions-sq5360ae.stx";
|
|
947
|
+
// src/ui/command-palette/CommandPalette.stx
|
|
948
|
+
var CommandPalette_default = "./CommandPalette-36mxf05w.stx";
|
|
949
|
+
// src/ui/command-palette/CommandPaletteItem.stx
|
|
950
|
+
var CommandPaletteItem_default = "./CommandPaletteItem-mvk6q7a2.stx";
|
|
951
|
+
// src/ui/dialog/Dialog.stx
|
|
952
|
+
var Dialog_default = "./Dialog-y5rz2vrq.stx";
|
|
953
|
+
// src/ui/dialog/DialogBackdrop.stx
|
|
954
|
+
var DialogBackdrop_default = "./DialogBackdrop-rxax3sec.stx";
|
|
955
|
+
// src/ui/dialog/DialogDescription.stx
|
|
956
|
+
var DialogDescription_default = "./DialogDescription-76prd1m2.stx";
|
|
957
|
+
// src/ui/dialog/DialogPanel.stx
|
|
958
|
+
var DialogPanel_default = "./DialogPanel-44d8jeqy.stx";
|
|
959
|
+
// src/ui/dialog/DialogTitle.stx
|
|
960
|
+
var DialogTitle_default = "./DialogTitle-x0r6k8x9.stx";
|
|
961
|
+
// src/ui/drawer/Drawer.stx
|
|
962
|
+
var Drawer_default = "./Drawer-hrz7qcyp.stx";
|
|
963
|
+
// src/ui/dropdown/Dropdown.stx
|
|
964
|
+
var Dropdown_default = "./Dropdown-vvhemtc0.stx";
|
|
965
|
+
// src/ui/dropdown/DropdownButton.stx
|
|
966
|
+
var DropdownButton_default = "./DropdownButton-wcz67dxy.stx";
|
|
967
|
+
// src/ui/dropdown/DropdownItem.stx
|
|
968
|
+
var DropdownItem_default = "./DropdownItem-c7rz08e5.stx";
|
|
969
|
+
// src/ui/dropdown/DropdownItems.stx
|
|
970
|
+
var DropdownItems_default = "./DropdownItems-1sxnd5qn.stx";
|
|
971
|
+
// src/ui/form/Form.stx
|
|
972
|
+
var Form_default = "./Form-mas630hy.stx";
|
|
973
|
+
|
|
974
|
+
// src/ui/form/index.ts
|
|
975
|
+
var formPropSchema = {
|
|
976
|
+
action: PropTypes.string,
|
|
977
|
+
method: PropTypes.oneOf(["GET", "POST", "PUT", "DELETE", "PATCH"]),
|
|
978
|
+
validationSchema: PropTypes.object,
|
|
979
|
+
initialValues: PropTypes.object,
|
|
980
|
+
validateOnChange: PropTypes.boolean,
|
|
981
|
+
validateOnBlur: PropTypes.boolean,
|
|
982
|
+
onSubmit: PropTypes.func,
|
|
983
|
+
onError: PropTypes.func,
|
|
984
|
+
className: PropTypes.string
|
|
985
|
+
};
|
|
986
|
+
var validateFormProps = createPropValidator("Form", formPropSchema);
|
|
987
|
+
// src/ui/image/Image.stx
|
|
988
|
+
var Image_default = "./Image-yhxcvgzs.stx";
|
|
989
|
+
// src/ui/input/EmailInput.stx
|
|
990
|
+
var EmailInput_default = "./EmailInput-vak3kkmk.stx";
|
|
991
|
+
// src/ui/input/NumberInput.stx
|
|
992
|
+
var NumberInput_default = "./NumberInput-g41gmd2c.stx";
|
|
993
|
+
// src/ui/input/PasswordInput.stx
|
|
994
|
+
var PasswordInput_default = "./PasswordInput-4rsq1gwb.stx";
|
|
995
|
+
// src/ui/input/SearchInput.stx
|
|
996
|
+
var SearchInput_default = "./SearchInput-pdx7agn0.stx";
|
|
997
|
+
// src/ui/input/TextInput.stx
|
|
998
|
+
var TextInput_default = "./TextInput-g0vaz0pe.stx";
|
|
999
|
+
|
|
1000
|
+
// src/ui/input/index.ts
|
|
1001
|
+
var baseInputPropSchema = {
|
|
1002
|
+
value: PropTypes.string,
|
|
1003
|
+
onChange: PropTypes.func,
|
|
1004
|
+
placeholder: PropTypes.string,
|
|
1005
|
+
disabled: PropTypes.boolean,
|
|
1006
|
+
readonly: PropTypes.boolean,
|
|
1007
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
1008
|
+
error: PropTypes.boolean,
|
|
1009
|
+
label: PropTypes.string,
|
|
1010
|
+
helperText: PropTypes.string,
|
|
1011
|
+
required: PropTypes.boolean,
|
|
1012
|
+
className: PropTypes.string,
|
|
1013
|
+
inputClassName: PropTypes.string
|
|
1014
|
+
};
|
|
1015
|
+
var textInputPropSchema = {
|
|
1016
|
+
value: PropTypes.string,
|
|
1017
|
+
onChange: PropTypes.func,
|
|
1018
|
+
placeholder: PropTypes.string,
|
|
1019
|
+
disabled: PropTypes.boolean,
|
|
1020
|
+
readonly: PropTypes.boolean,
|
|
1021
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
1022
|
+
error: PropTypes.boolean,
|
|
1023
|
+
label: PropTypes.string,
|
|
1024
|
+
helperText: PropTypes.string,
|
|
1025
|
+
required: PropTypes.boolean,
|
|
1026
|
+
className: PropTypes.string,
|
|
1027
|
+
inputClassName: PropTypes.string,
|
|
1028
|
+
leftIcon: PropTypes.string,
|
|
1029
|
+
rightIcon: PropTypes.string,
|
|
1030
|
+
clearable: PropTypes.boolean,
|
|
1031
|
+
maxLength: PropTypes.number,
|
|
1032
|
+
showCount: PropTypes.boolean
|
|
1033
|
+
};
|
|
1034
|
+
var numberInputPropSchema = {
|
|
1035
|
+
value: PropTypes.string,
|
|
1036
|
+
onChange: PropTypes.func,
|
|
1037
|
+
placeholder: PropTypes.string,
|
|
1038
|
+
disabled: PropTypes.boolean,
|
|
1039
|
+
readonly: PropTypes.boolean,
|
|
1040
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
1041
|
+
error: PropTypes.boolean,
|
|
1042
|
+
label: PropTypes.string,
|
|
1043
|
+
helperText: PropTypes.string,
|
|
1044
|
+
required: PropTypes.boolean,
|
|
1045
|
+
className: PropTypes.string,
|
|
1046
|
+
inputClassName: PropTypes.string,
|
|
1047
|
+
min: PropTypes.number,
|
|
1048
|
+
max: PropTypes.number,
|
|
1049
|
+
step: PropTypes.number,
|
|
1050
|
+
showControls: PropTypes.boolean
|
|
1051
|
+
};
|
|
1052
|
+
var passwordInputPropSchema = {
|
|
1053
|
+
value: PropTypes.string,
|
|
1054
|
+
onChange: PropTypes.func,
|
|
1055
|
+
placeholder: PropTypes.string,
|
|
1056
|
+
disabled: PropTypes.boolean,
|
|
1057
|
+
readonly: PropTypes.boolean,
|
|
1058
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
1059
|
+
error: PropTypes.boolean,
|
|
1060
|
+
label: PropTypes.string,
|
|
1061
|
+
helperText: PropTypes.string,
|
|
1062
|
+
required: PropTypes.boolean,
|
|
1063
|
+
className: PropTypes.string,
|
|
1064
|
+
inputClassName: PropTypes.string,
|
|
1065
|
+
showStrength: PropTypes.boolean
|
|
1066
|
+
};
|
|
1067
|
+
var searchInputPropSchema = {
|
|
1068
|
+
value: PropTypes.string,
|
|
1069
|
+
onChange: PropTypes.func,
|
|
1070
|
+
placeholder: PropTypes.string,
|
|
1071
|
+
disabled: PropTypes.boolean,
|
|
1072
|
+
readonly: PropTypes.boolean,
|
|
1073
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
1074
|
+
error: PropTypes.boolean,
|
|
1075
|
+
label: PropTypes.string,
|
|
1076
|
+
helperText: PropTypes.string,
|
|
1077
|
+
required: PropTypes.boolean,
|
|
1078
|
+
className: PropTypes.string,
|
|
1079
|
+
inputClassName: PropTypes.string,
|
|
1080
|
+
onSearch: PropTypes.func,
|
|
1081
|
+
loading: PropTypes.boolean
|
|
1082
|
+
};
|
|
1083
|
+
var validateTextInputProps = createPropValidator("TextInput", textInputPropSchema);
|
|
1084
|
+
var validateEmailInputProps = createPropValidator("EmailInput", baseInputPropSchema);
|
|
1085
|
+
var validatePasswordInputProps = createPropValidator("PasswordInput", passwordInputPropSchema);
|
|
1086
|
+
var validateNumberInputProps = createPropValidator("NumberInput", numberInputPropSchema);
|
|
1087
|
+
var validateSearchInputProps = createPropValidator("SearchInput", searchInputPropSchema);
|
|
1088
|
+
// src/ui/listbox/Listbox.stx
|
|
1089
|
+
var Listbox_default = "./Listbox-q49tnr90.stx";
|
|
1090
|
+
// src/ui/listbox/ListboxButton.stx
|
|
1091
|
+
var ListboxButton_default = "./ListboxButton-keb8gm0q.stx";
|
|
1092
|
+
// src/ui/listbox/ListboxLabel.stx
|
|
1093
|
+
var ListboxLabel_default = "./ListboxLabel-7mymt1b8.stx";
|
|
1094
|
+
// src/ui/listbox/ListboxOption.stx
|
|
1095
|
+
var ListboxOption_default = "./ListboxOption-e0dtv1gc.stx";
|
|
1096
|
+
// src/ui/listbox/ListboxOptions.stx
|
|
1097
|
+
var ListboxOptions_default = "./ListboxOptions-ejkatcfg.stx";
|
|
1098
|
+
// src/ui/navigator/Navigator.stx
|
|
1099
|
+
var Navigator_default = "./Navigator-rk2a5wvk.stx";
|
|
1100
|
+
// src/ui/notification/Notification.stx
|
|
1101
|
+
var Notification_default = "./Notification-03vfh3k6.stx";
|
|
1102
|
+
// src/ui/pagination/Pagination.stx
|
|
1103
|
+
var Pagination_default = "./Pagination-wtgxmzey.stx";
|
|
1104
|
+
// src/ui/payment/Checkout.stx
|
|
1105
|
+
var Checkout_default = "./Checkout-agt0ngpw.stx";
|
|
1106
|
+
// src/ui/payment/DefaultPaymentMethod.stx
|
|
1107
|
+
var DefaultPaymentMethod_default = "./DefaultPaymentMethod-shhf6aap.stx";
|
|
1108
|
+
// src/ui/payment/PaymentMethods.stx
|
|
1109
|
+
var PaymentMethods_default = "./PaymentMethods-x4vrx9yb.stx";
|
|
1110
|
+
// src/ui/payment/SubscriptionCheckout.stx
|
|
1111
|
+
var SubscriptionCheckout_default = "./SubscriptionCheckout-zy2ycrmw.stx";
|
|
1112
|
+
// src/ui/popover/Popover.stx
|
|
1113
|
+
var Popover_default = "./Popover-et2q44m7.stx";
|
|
1114
|
+
// src/ui/popover/PopoverButton.stx
|
|
1115
|
+
var PopoverButton_default = "./PopoverButton-mffzc9pr.stx";
|
|
1116
|
+
// src/ui/popover/PopoverPanel.stx
|
|
1117
|
+
var PopoverPanel_default = "./PopoverPanel-054yh38h.stx";
|
|
1118
|
+
// src/ui/portal/Portal.stx
|
|
1119
|
+
var Portal_default = "./Portal-1vf14s4x.stx";
|
|
1120
|
+
// src/ui/progress/Progress.stx
|
|
1121
|
+
var Progress_default = "./Progress-9dhakbh4.stx";
|
|
1122
|
+
// src/ui/radio/Radio.stx
|
|
1123
|
+
var Radio_default = "./Radio-djtb5dpc.stx";
|
|
1124
|
+
// src/ui/radio-group/RadioGroup.stx
|
|
1125
|
+
var RadioGroup_default = "./RadioGroup-qxmnm3xm.stx";
|
|
1126
|
+
// src/ui/radio-group/RadioGroupDescription.stx
|
|
1127
|
+
var RadioGroupDescription_default = "./RadioGroupDescription-yej78fak.stx";
|
|
1128
|
+
// src/ui/radio-group/RadioGroupLabel.stx
|
|
1129
|
+
var RadioGroupLabel_default = "./RadioGroupLabel-7mymt1b8.stx";
|
|
1130
|
+
// src/ui/radio-group/RadioGroupOption.stx
|
|
1131
|
+
var RadioGroupOption_default = "./RadioGroupOption-s1d6r221.stx";
|
|
1132
|
+
// src/ui/select/Select.stx
|
|
1133
|
+
var Select_default = "./Select-1vnd0brz.stx";
|
|
1134
|
+
// src/ui/sidebar/Sidebar.stx
|
|
1135
|
+
var Sidebar_default = "./Sidebar-0jzasrmt.stx";
|
|
1136
|
+
// src/ui/sidebar/SidebarSection.stx
|
|
1137
|
+
var SidebarSection_default = "./SidebarSection-g195cb4f.stx";
|
|
1138
|
+
// src/ui/sidebar/SidebarItem.stx
|
|
1139
|
+
var SidebarItem_default = "./SidebarItem-h53sgqzz.stx";
|
|
1140
|
+
// src/ui/sidebar/SidebarHeader.stx
|
|
1141
|
+
var SidebarHeader_default = "./SidebarHeader-ywpmx14d.stx";
|
|
1142
|
+
// src/ui/sidebar/SidebarFooter.stx
|
|
1143
|
+
var SidebarFooter_default = "./SidebarFooter-zsfsgcxb.stx";
|
|
1144
|
+
// src/ui/skeleton/Skeleton.stx
|
|
1145
|
+
var Skeleton_default = "./Skeleton-v1pwa8nr.stx";
|
|
1146
|
+
// src/ui/spinner/Spinner.stx
|
|
1147
|
+
var Spinner_default = "./Spinner-7dahavkd.stx";
|
|
1148
|
+
// src/ui/stepper/Stepper.stx
|
|
1149
|
+
var Stepper_default = "./Stepper-rgbk76hd.stx";
|
|
1150
|
+
// src/ui/stepper/StepperStep.stx
|
|
1151
|
+
var StepperStep_default = "./StepperStep-wxgembat.stx";
|
|
1152
|
+
// src/ui/storage/index.ts
|
|
1153
|
+
class StorageManager {
|
|
1154
|
+
storage;
|
|
1155
|
+
namespace;
|
|
1156
|
+
watchers = new Map;
|
|
1157
|
+
encryptionKey = "stx-storage-key";
|
|
1158
|
+
constructor(type = "local", namespace = "") {
|
|
1159
|
+
this.storage = type === "local" ? globalThis.localStorage : globalThis.sessionStorage;
|
|
1160
|
+
this.namespace = namespace;
|
|
1161
|
+
if (typeof window !== "undefined") {
|
|
1162
|
+
window.addEventListener("storage", this.handleStorageEvent.bind(this));
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
handleStorageEvent(event) {
|
|
1166
|
+
if (!event.key)
|
|
1167
|
+
return;
|
|
1168
|
+
const key = this.namespace && event.key.startsWith(`${this.namespace}:`) ? event.key.slice(this.namespace.length + 1) : event.key;
|
|
1169
|
+
const callbacks = this.watchers.get(key);
|
|
1170
|
+
if (callbacks) {
|
|
1171
|
+
const oldValue = event.oldValue ? JSON.parse(event.oldValue).value : null;
|
|
1172
|
+
const newValue = event.newValue ? JSON.parse(event.newValue).value : null;
|
|
1173
|
+
callbacks.forEach((callback) => callback(newValue, oldValue, key));
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
encrypt(data) {
|
|
1177
|
+
let result = "";
|
|
1178
|
+
for (let i = 0;i < data.length; i++) {
|
|
1179
|
+
result += String.fromCharCode(data.charCodeAt(i) ^ this.encryptionKey.charCodeAt(i % this.encryptionKey.length));
|
|
1180
|
+
}
|
|
1181
|
+
return btoa(result);
|
|
1182
|
+
}
|
|
1183
|
+
decrypt(data) {
|
|
1184
|
+
try {
|
|
1185
|
+
const decoded = atob(data);
|
|
1186
|
+
let result = "";
|
|
1187
|
+
for (let i = 0;i < decoded.length; i++) {
|
|
1188
|
+
result += String.fromCharCode(decoded.charCodeAt(i) ^ this.encryptionKey.charCodeAt(i % this.encryptionKey.length));
|
|
1189
|
+
}
|
|
1190
|
+
return result;
|
|
1191
|
+
} catch {
|
|
1192
|
+
return data;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
compress(data) {
|
|
1196
|
+
if (data.length < 100)
|
|
1197
|
+
return data;
|
|
1198
|
+
const dict = {};
|
|
1199
|
+
let dictSize = 256;
|
|
1200
|
+
const result = [];
|
|
1201
|
+
let w = "";
|
|
1202
|
+
for (let i = 0;i < data.length; i++) {
|
|
1203
|
+
const c = data.charAt(i);
|
|
1204
|
+
const wc = w + c;
|
|
1205
|
+
if (dict[wc] !== undefined) {
|
|
1206
|
+
w = wc;
|
|
1207
|
+
} else {
|
|
1208
|
+
result.push(w.length > 1 ? dict[w] : w.charCodeAt(0));
|
|
1209
|
+
dict[wc] = dictSize++;
|
|
1210
|
+
w = c;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
if (w !== "") {
|
|
1214
|
+
result.push(w.length > 1 ? dict[w] : w.charCodeAt(0));
|
|
1215
|
+
}
|
|
1216
|
+
return JSON.stringify(result);
|
|
1217
|
+
}
|
|
1218
|
+
decompress(data) {
|
|
1219
|
+
try {
|
|
1220
|
+
const compressed = JSON.parse(data);
|
|
1221
|
+
if (!Array.isArray(compressed))
|
|
1222
|
+
return data;
|
|
1223
|
+
const dict = {};
|
|
1224
|
+
let dictSize = 256;
|
|
1225
|
+
let w = String.fromCharCode(compressed[0]);
|
|
1226
|
+
let result = w;
|
|
1227
|
+
for (let i = 1;i < compressed.length; i++) {
|
|
1228
|
+
const k = compressed[i];
|
|
1229
|
+
let entry;
|
|
1230
|
+
if (dict[k] !== undefined) {
|
|
1231
|
+
entry = dict[k];
|
|
1232
|
+
} else if (k === dictSize) {
|
|
1233
|
+
entry = w + w.charAt(0);
|
|
1234
|
+
} else {
|
|
1235
|
+
return data;
|
|
1236
|
+
}
|
|
1237
|
+
result += entry;
|
|
1238
|
+
dict[dictSize++] = w + entry.charAt(0);
|
|
1239
|
+
w = entry;
|
|
1240
|
+
}
|
|
1241
|
+
return result;
|
|
1242
|
+
} catch {
|
|
1243
|
+
return data;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
getKey(key) {
|
|
1247
|
+
return this.namespace ? `${this.namespace}:${key}` : key;
|
|
1248
|
+
}
|
|
1249
|
+
set(key, value, options) {
|
|
1250
|
+
const fullKey = this.getKey(key);
|
|
1251
|
+
const oldValue = this.get(key);
|
|
1252
|
+
const data = {
|
|
1253
|
+
value,
|
|
1254
|
+
timestamp: Date.now(),
|
|
1255
|
+
expire: options?.expire,
|
|
1256
|
+
encrypted: options?.encrypt || false,
|
|
1257
|
+
compressed: options?.compress || false
|
|
1258
|
+
};
|
|
1259
|
+
try {
|
|
1260
|
+
let serialized = JSON.stringify(data);
|
|
1261
|
+
if (options?.compress) {
|
|
1262
|
+
serialized = this.compress(serialized);
|
|
1263
|
+
}
|
|
1264
|
+
if (options?.encrypt) {
|
|
1265
|
+
serialized = this.encrypt(serialized);
|
|
1266
|
+
}
|
|
1267
|
+
this.storage.setItem(fullKey, serialized);
|
|
1268
|
+
this.notifyWatchers(key, value, oldValue);
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
console.error("Storage set error:", error);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
get(key) {
|
|
1274
|
+
const fullKey = this.getKey(key);
|
|
1275
|
+
try {
|
|
1276
|
+
let item = this.storage.getItem(fullKey);
|
|
1277
|
+
if (!item)
|
|
1278
|
+
return null;
|
|
1279
|
+
if (item.match(/^[A-Z0-9+/]+=*$/i)) {
|
|
1280
|
+
try {
|
|
1281
|
+
item = this.decrypt(item);
|
|
1282
|
+
} catch {}
|
|
1283
|
+
}
|
|
1284
|
+
if (item.startsWith("[")) {
|
|
1285
|
+
try {
|
|
1286
|
+
item = this.decompress(item);
|
|
1287
|
+
} catch {}
|
|
1288
|
+
}
|
|
1289
|
+
const data = JSON.parse(item);
|
|
1290
|
+
if (data.expire && Date.now() - data.timestamp > data.expire) {
|
|
1291
|
+
this.remove(key);
|
|
1292
|
+
return null;
|
|
1293
|
+
}
|
|
1294
|
+
return data.value;
|
|
1295
|
+
} catch (error) {
|
|
1296
|
+
console.error("Storage get error:", error);
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
watch(key, callback) {
|
|
1301
|
+
if (!this.watchers.has(key)) {
|
|
1302
|
+
this.watchers.set(key, new Set);
|
|
1303
|
+
}
|
|
1304
|
+
this.watchers.get(key).add(callback);
|
|
1305
|
+
return () => {
|
|
1306
|
+
const callbacks = this.watchers.get(key);
|
|
1307
|
+
if (callbacks) {
|
|
1308
|
+
callbacks.delete(callback);
|
|
1309
|
+
if (callbacks.size === 0) {
|
|
1310
|
+
this.watchers.delete(key);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
notifyWatchers(key, newValue, oldValue) {
|
|
1316
|
+
const callbacks = this.watchers.get(key);
|
|
1317
|
+
if (callbacks) {
|
|
1318
|
+
callbacks.forEach((callback) => callback(newValue, oldValue, key));
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
remove(key) {
|
|
1322
|
+
const fullKey = this.getKey(key);
|
|
1323
|
+
const oldValue = this.get(key);
|
|
1324
|
+
this.storage.removeItem(fullKey);
|
|
1325
|
+
this.notifyWatchers(key, null, oldValue);
|
|
1326
|
+
}
|
|
1327
|
+
clear() {
|
|
1328
|
+
if (this.namespace) {
|
|
1329
|
+
const keys = this.keys();
|
|
1330
|
+
keys.forEach((key) => this.remove(key));
|
|
1331
|
+
} else {
|
|
1332
|
+
this.storage.clear();
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
has(key) {
|
|
1336
|
+
return this.get(key) !== null;
|
|
1337
|
+
}
|
|
1338
|
+
keys() {
|
|
1339
|
+
const allKeys = Object.keys(this.storage);
|
|
1340
|
+
if (this.namespace) {
|
|
1341
|
+
const prefix = `${this.namespace}:`;
|
|
1342
|
+
return allKeys.filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));
|
|
1343
|
+
}
|
|
1344
|
+
return allKeys;
|
|
1345
|
+
}
|
|
1346
|
+
size() {
|
|
1347
|
+
return this.keys().length;
|
|
1348
|
+
}
|
|
1349
|
+
getQuota() {
|
|
1350
|
+
if ("storage" in navigator && "estimate" in navigator.storage) {
|
|
1351
|
+
return null;
|
|
1352
|
+
}
|
|
1353
|
+
try {
|
|
1354
|
+
let totalSize = 0;
|
|
1355
|
+
for (let i = 0;i < this.storage.length; i++) {
|
|
1356
|
+
const key = this.storage.key(i);
|
|
1357
|
+
if (key) {
|
|
1358
|
+
const value = this.storage.getItem(key) || "";
|
|
1359
|
+
totalSize += key.length + value.length;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
const estimatedQuota = 5 * 1024 * 1024;
|
|
1363
|
+
return {
|
|
1364
|
+
usage: totalSize * 2,
|
|
1365
|
+
quota: estimatedQuota,
|
|
1366
|
+
percentage: totalSize * 2 / estimatedQuota * 100
|
|
1367
|
+
};
|
|
1368
|
+
} catch {
|
|
1369
|
+
return null;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
setMany(items, options) {
|
|
1373
|
+
Object.entries(items).forEach(([key, value]) => {
|
|
1374
|
+
this.set(key, value, options);
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
getMany(keys) {
|
|
1378
|
+
const result = {};
|
|
1379
|
+
keys.forEach((key) => {
|
|
1380
|
+
result[key] = this.get(key);
|
|
1381
|
+
});
|
|
1382
|
+
return result;
|
|
1383
|
+
}
|
|
1384
|
+
removeMany(keys) {
|
|
1385
|
+
keys.forEach((key) => this.remove(key));
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
var storage = {
|
|
1389
|
+
local: new StorageManager("local"),
|
|
1390
|
+
session: new StorageManager("session")
|
|
1391
|
+
};
|
|
1392
|
+
function createStorage(type = "local", namespace) {
|
|
1393
|
+
return new StorageManager(type, namespace);
|
|
1394
|
+
}
|
|
1395
|
+
// src/ui/switch/Switch.stx
|
|
1396
|
+
var Switch_default = "./Switch-p1bcr9ks.stx";
|
|
1397
|
+
// src/ui/table/Table.stx
|
|
1398
|
+
var Table_default = "./Table-6cx8az9h.stx";
|
|
1399
|
+
// src/ui/table/TableBody.stx
|
|
1400
|
+
var TableBody_default = "./TableBody-wf6t13j9.stx";
|
|
1401
|
+
// src/ui/table/TableCell.stx
|
|
1402
|
+
var TableCell_default = "./TableCell-ntx0edbn.stx";
|
|
1403
|
+
// src/ui/table/TableHead.stx
|
|
1404
|
+
var TableHead_default = "./TableHead-3k4hnm2k.stx";
|
|
1405
|
+
// src/ui/table/TableHeader.stx
|
|
1406
|
+
var TableHeader_default = "./TableHeader-0eyzbqpz.stx";
|
|
1407
|
+
// src/ui/table/TableRow.stx
|
|
1408
|
+
var TableRow_default = "./TableRow-z09p2ebf.stx";
|
|
1409
|
+
// src/ui/tabs/TabPanel.stx
|
|
1410
|
+
var TabPanel_default = "./TabPanel-5htevsq6.stx";
|
|
1411
|
+
// src/ui/tabs/Tabs.stx
|
|
1412
|
+
var Tabs_default = "./Tabs-79brys99.stx";
|
|
1413
|
+
// src/ui/teleport/Teleport.stx
|
|
1414
|
+
var Teleport_default = "./Teleport-tsx4bt4n.stx";
|
|
1415
|
+
// src/ui/textarea/Textarea.stx
|
|
1416
|
+
var Textarea_default = "./Textarea-96kawv5c.stx";
|
|
1417
|
+
// src/ui/tooltip/Tooltip.stx
|
|
1418
|
+
var Tooltip_default = "./Tooltip-y61h04gp.stx";
|
|
1419
|
+
// src/ui/transition/Transition.stx
|
|
1420
|
+
var Transition_default = "./Transition-7smenaz8.stx";
|
|
1421
|
+
// src/ui/video/Video.stx
|
|
1422
|
+
var Video_default = "./Video-84j4pv6h.stx";
|
|
1423
|
+
// src/ui/virtual-list/VirtualList.stx
|
|
1424
|
+
var VirtualList_default = "./VirtualList-fa7v5a3h.stx";
|
|
1425
|
+
// src/ui/virtual-table/VirtualTable.stx
|
|
1426
|
+
var VirtualTable_default = "./VirtualTable-f9crbfjr.stx";
|
|
1427
|
+
// src/utils/accessibility.ts
|
|
1428
|
+
var idCounter = 0;
|
|
1429
|
+
function generateId(prefix = "a11y") {
|
|
1430
|
+
return `${prefix}-${++idCounter}-${Date.now()}`;
|
|
1431
|
+
}
|
|
1432
|
+
function createAriaLabel(text, element, options = {}) {
|
|
1433
|
+
const { visible = false, id = generateId("label") } = options;
|
|
1434
|
+
const label = document.createElement(visible ? "label" : "span");
|
|
1435
|
+
label.id = id;
|
|
1436
|
+
label.textContent = text;
|
|
1437
|
+
if (!visible) {
|
|
1438
|
+
Object.assign(label.style, {
|
|
1439
|
+
position: "absolute",
|
|
1440
|
+
width: "1px",
|
|
1441
|
+
height: "1px",
|
|
1442
|
+
padding: "0",
|
|
1443
|
+
margin: "-1px",
|
|
1444
|
+
overflow: "hidden",
|
|
1445
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1446
|
+
whiteSpace: "nowrap",
|
|
1447
|
+
border: "0"
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
if (element) {
|
|
1451
|
+
element.setAttribute("aria-labelledby", id);
|
|
1452
|
+
if (element.parentElement) {
|
|
1453
|
+
element.parentElement.insertBefore(label, element);
|
|
1454
|
+
} else {
|
|
1455
|
+
document.body.appendChild(label);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
return id;
|
|
1459
|
+
}
|
|
1460
|
+
function createAriaDescription(text, element) {
|
|
1461
|
+
const id = generateId("desc");
|
|
1462
|
+
const description = document.createElement("span");
|
|
1463
|
+
description.id = id;
|
|
1464
|
+
description.textContent = text;
|
|
1465
|
+
Object.assign(description.style, {
|
|
1466
|
+
position: "absolute",
|
|
1467
|
+
width: "1px",
|
|
1468
|
+
height: "1px",
|
|
1469
|
+
padding: "0",
|
|
1470
|
+
margin: "-1px",
|
|
1471
|
+
overflow: "hidden",
|
|
1472
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1473
|
+
whiteSpace: "nowrap",
|
|
1474
|
+
border: "0"
|
|
1475
|
+
});
|
|
1476
|
+
if (element) {
|
|
1477
|
+
element.setAttribute("aria-describedby", id);
|
|
1478
|
+
if (element.parentElement) {
|
|
1479
|
+
element.parentElement.insertBefore(description, element);
|
|
1480
|
+
} else {
|
|
1481
|
+
document.body.appendChild(description);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
return id;
|
|
1485
|
+
}
|
|
1486
|
+
function announceToScreenReader(message, priority = "polite") {
|
|
1487
|
+
const announcement = document.createElement("div");
|
|
1488
|
+
announcement.setAttribute("role", "status");
|
|
1489
|
+
announcement.setAttribute("aria-live", priority);
|
|
1490
|
+
announcement.setAttribute("aria-atomic", "true");
|
|
1491
|
+
Object.assign(announcement.style, {
|
|
1492
|
+
position: "absolute",
|
|
1493
|
+
width: "1px",
|
|
1494
|
+
height: "1px",
|
|
1495
|
+
padding: "0",
|
|
1496
|
+
margin: "-1px",
|
|
1497
|
+
overflow: "hidden",
|
|
1498
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1499
|
+
whiteSpace: "nowrap",
|
|
1500
|
+
border: "0"
|
|
1501
|
+
});
|
|
1502
|
+
document.body.appendChild(announcement);
|
|
1503
|
+
setTimeout(() => {
|
|
1504
|
+
announcement.textContent = message;
|
|
1505
|
+
}, 100);
|
|
1506
|
+
setTimeout(() => {
|
|
1507
|
+
announcement.parentNode?.removeChild(announcement);
|
|
1508
|
+
}, 1000);
|
|
1509
|
+
}
|
|
1510
|
+
function getFocusableElements(container) {
|
|
1511
|
+
const selector = [
|
|
1512
|
+
"a[href]",
|
|
1513
|
+
"area[href]",
|
|
1514
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
1515
|
+
"select:not([disabled])",
|
|
1516
|
+
"textarea:not([disabled])",
|
|
1517
|
+
"button:not([disabled])",
|
|
1518
|
+
"iframe",
|
|
1519
|
+
"object",
|
|
1520
|
+
"embed",
|
|
1521
|
+
"[contenteditable]",
|
|
1522
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
1523
|
+
].join(",");
|
|
1524
|
+
return Array.from(container.querySelectorAll(selector)).filter((element) => element.offsetParent !== null);
|
|
1525
|
+
}
|
|
1526
|
+
function createFocusTrap(container, options = {}) {
|
|
1527
|
+
const {
|
|
1528
|
+
initialFocus,
|
|
1529
|
+
returnFocus,
|
|
1530
|
+
escapeDeactivates = true,
|
|
1531
|
+
clickOutsideDeactivates = true,
|
|
1532
|
+
allowOutsideClick = false,
|
|
1533
|
+
onActivate,
|
|
1534
|
+
onDeactivate
|
|
1535
|
+
} = options;
|
|
1536
|
+
let isActive = false;
|
|
1537
|
+
let isPaused = false;
|
|
1538
|
+
let previouslyFocused = null;
|
|
1539
|
+
const handleKeyDown = (event) => {
|
|
1540
|
+
if (isPaused)
|
|
1541
|
+
return;
|
|
1542
|
+
if (escapeDeactivates && event.key === "Escape") {
|
|
1543
|
+
event.preventDefault();
|
|
1544
|
+
deactivate();
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
if (event.key === "Tab") {
|
|
1548
|
+
const focusableElements = getFocusableElements(container);
|
|
1549
|
+
if (focusableElements.length === 0) {
|
|
1550
|
+
event.preventDefault();
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
const firstElement = focusableElements[0];
|
|
1554
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
1555
|
+
if (event.shiftKey) {
|
|
1556
|
+
if (document.activeElement === firstElement) {
|
|
1557
|
+
event.preventDefault();
|
|
1558
|
+
lastElement.focus();
|
|
1559
|
+
}
|
|
1560
|
+
} else {
|
|
1561
|
+
if (document.activeElement === lastElement) {
|
|
1562
|
+
event.preventDefault();
|
|
1563
|
+
firstElement.focus();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
const handleClickOutside = (event) => {
|
|
1569
|
+
if (isPaused)
|
|
1570
|
+
return;
|
|
1571
|
+
if (!container.contains(event.target)) {
|
|
1572
|
+
if (typeof allowOutsideClick === "function") {
|
|
1573
|
+
if (!allowOutsideClick(event) && clickOutsideDeactivates) {
|
|
1574
|
+
deactivate();
|
|
1575
|
+
}
|
|
1576
|
+
} else if (!allowOutsideClick && clickOutsideDeactivates) {
|
|
1577
|
+
deactivate();
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
function activate() {
|
|
1582
|
+
if (isActive)
|
|
1583
|
+
return;
|
|
1584
|
+
isActive = true;
|
|
1585
|
+
previouslyFocused = document.activeElement;
|
|
1586
|
+
const elementToFocus = initialFocus || getFocusableElements(container)[0];
|
|
1587
|
+
if (elementToFocus && typeof elementToFocus.focus === "function") {
|
|
1588
|
+
elementToFocus.focus();
|
|
1589
|
+
}
|
|
1590
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1591
|
+
document.addEventListener("click", handleClickOutside);
|
|
1592
|
+
onActivate?.();
|
|
1593
|
+
}
|
|
1594
|
+
function deactivate() {
|
|
1595
|
+
if (!isActive)
|
|
1596
|
+
return;
|
|
1597
|
+
isActive = false;
|
|
1598
|
+
const elementToFocus = returnFocus || previouslyFocused;
|
|
1599
|
+
if (elementToFocus && typeof elementToFocus.focus === "function") {
|
|
1600
|
+
elementToFocus.focus();
|
|
1601
|
+
}
|
|
1602
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
1603
|
+
document.removeEventListener("click", handleClickOutside);
|
|
1604
|
+
onDeactivate?.();
|
|
1605
|
+
}
|
|
1606
|
+
function pause() {
|
|
1607
|
+
isPaused = true;
|
|
1608
|
+
}
|
|
1609
|
+
function unpause() {
|
|
1610
|
+
isPaused = false;
|
|
1611
|
+
}
|
|
1612
|
+
return {
|
|
1613
|
+
activate,
|
|
1614
|
+
deactivate,
|
|
1615
|
+
pause,
|
|
1616
|
+
unpause
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
function createRovingTabindex(container, options = {}) {
|
|
1620
|
+
const {
|
|
1621
|
+
selector = '[role="option"], [role="menuitem"], [role="tab"], button',
|
|
1622
|
+
initialIndex = 0,
|
|
1623
|
+
orientation = "both",
|
|
1624
|
+
loop = true,
|
|
1625
|
+
onFocusChange
|
|
1626
|
+
} = options;
|
|
1627
|
+
let currentIndex = initialIndex;
|
|
1628
|
+
const getItems = () => {
|
|
1629
|
+
return Array.from(container.querySelectorAll(selector));
|
|
1630
|
+
};
|
|
1631
|
+
const setFocusedIndex = (index) => {
|
|
1632
|
+
const items = getItems();
|
|
1633
|
+
if (index < 0 || index >= items.length)
|
|
1634
|
+
return;
|
|
1635
|
+
items.forEach((item, i) => {
|
|
1636
|
+
if (i === index) {
|
|
1637
|
+
item.setAttribute("tabindex", "0");
|
|
1638
|
+
if (typeof item.focus === "function") {
|
|
1639
|
+
item.focus();
|
|
1640
|
+
}
|
|
1641
|
+
} else {
|
|
1642
|
+
item.setAttribute("tabindex", "-1");
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
currentIndex = index;
|
|
1646
|
+
onFocusChange?.(index, items[index]);
|
|
1647
|
+
};
|
|
1648
|
+
const handleKeyDown = (event) => {
|
|
1649
|
+
const items = getItems();
|
|
1650
|
+
const maxIndex = items.length - 1;
|
|
1651
|
+
let handled = false;
|
|
1652
|
+
let newIndex = currentIndex;
|
|
1653
|
+
switch (event.key) {
|
|
1654
|
+
case "ArrowRight":
|
|
1655
|
+
if (orientation === "horizontal" || orientation === "both") {
|
|
1656
|
+
newIndex = currentIndex + 1;
|
|
1657
|
+
if (newIndex > maxIndex) {
|
|
1658
|
+
newIndex = loop ? 0 : maxIndex;
|
|
1659
|
+
}
|
|
1660
|
+
handled = true;
|
|
1661
|
+
}
|
|
1662
|
+
break;
|
|
1663
|
+
case "ArrowLeft":
|
|
1664
|
+
if (orientation === "horizontal" || orientation === "both") {
|
|
1665
|
+
newIndex = currentIndex - 1;
|
|
1666
|
+
if (newIndex < 0) {
|
|
1667
|
+
newIndex = loop ? maxIndex : 0;
|
|
1668
|
+
}
|
|
1669
|
+
handled = true;
|
|
1670
|
+
}
|
|
1671
|
+
break;
|
|
1672
|
+
case "ArrowDown":
|
|
1673
|
+
if (orientation === "vertical" || orientation === "both") {
|
|
1674
|
+
newIndex = currentIndex + 1;
|
|
1675
|
+
if (newIndex > maxIndex) {
|
|
1676
|
+
newIndex = loop ? 0 : maxIndex;
|
|
1677
|
+
}
|
|
1678
|
+
handled = true;
|
|
1679
|
+
}
|
|
1680
|
+
break;
|
|
1681
|
+
case "ArrowUp":
|
|
1682
|
+
if (orientation === "vertical" || orientation === "both") {
|
|
1683
|
+
newIndex = currentIndex - 1;
|
|
1684
|
+
if (newIndex < 0) {
|
|
1685
|
+
newIndex = loop ? maxIndex : 0;
|
|
1686
|
+
}
|
|
1687
|
+
handled = true;
|
|
1688
|
+
}
|
|
1689
|
+
break;
|
|
1690
|
+
case "Home":
|
|
1691
|
+
newIndex = 0;
|
|
1692
|
+
handled = true;
|
|
1693
|
+
break;
|
|
1694
|
+
case "End":
|
|
1695
|
+
newIndex = maxIndex;
|
|
1696
|
+
handled = true;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
if (handled) {
|
|
1700
|
+
event.preventDefault();
|
|
1701
|
+
setFocusedIndex(newIndex);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
setFocusedIndex(initialIndex);
|
|
1705
|
+
container.addEventListener("keydown", handleKeyDown);
|
|
1706
|
+
return () => {
|
|
1707
|
+
container.removeEventListener("keydown", handleKeyDown);
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
var KeyboardKeys = {
|
|
1711
|
+
Enter: "Enter",
|
|
1712
|
+
Space: " ",
|
|
1713
|
+
Escape: "Escape",
|
|
1714
|
+
ArrowUp: "ArrowUp",
|
|
1715
|
+
ArrowDown: "ArrowDown",
|
|
1716
|
+
ArrowLeft: "ArrowLeft",
|
|
1717
|
+
ArrowRight: "ArrowRight",
|
|
1718
|
+
Tab: "Tab",
|
|
1719
|
+
Home: "Home",
|
|
1720
|
+
End: "End",
|
|
1721
|
+
PageUp: "PageUp",
|
|
1722
|
+
PageDown: "PageDown"
|
|
1723
|
+
};
|
|
1724
|
+
function hasFocus(element) {
|
|
1725
|
+
return document.activeElement === element;
|
|
1726
|
+
}
|
|
1727
|
+
function moveFocus(direction, from) {
|
|
1728
|
+
const activeElement = from || document.activeElement;
|
|
1729
|
+
const focusableElements = getFocusableElements(document.body);
|
|
1730
|
+
const currentIndex = focusableElements.indexOf(activeElement);
|
|
1731
|
+
if (currentIndex === -1)
|
|
1732
|
+
return;
|
|
1733
|
+
const nextIndex = direction === "next" ? currentIndex + 1 : currentIndex - 1;
|
|
1734
|
+
const nextElement = focusableElements[nextIndex];
|
|
1735
|
+
if (nextElement) {
|
|
1736
|
+
nextElement.focus();
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function isVisibleToScreenReader(element) {
|
|
1740
|
+
if (element.getAttribute("aria-hidden") === "true") {
|
|
1741
|
+
return false;
|
|
1742
|
+
}
|
|
1743
|
+
const style = window.getComputedStyle(element);
|
|
1744
|
+
if (style.display === "none" || style.visibility === "hidden") {
|
|
1745
|
+
return false;
|
|
1746
|
+
}
|
|
1747
|
+
return true;
|
|
1748
|
+
}
|
|
1749
|
+
var aria = {
|
|
1750
|
+
setExpanded(element, expanded) {
|
|
1751
|
+
element.setAttribute("aria-expanded", String(expanded));
|
|
1752
|
+
},
|
|
1753
|
+
setSelected(element, selected) {
|
|
1754
|
+
element.setAttribute("aria-selected", String(selected));
|
|
1755
|
+
},
|
|
1756
|
+
setChecked(element, checked) {
|
|
1757
|
+
element.setAttribute("aria-checked", String(checked));
|
|
1758
|
+
},
|
|
1759
|
+
setDisabled(element, disabled) {
|
|
1760
|
+
element.setAttribute("aria-disabled", String(disabled));
|
|
1761
|
+
if (disabled) {
|
|
1762
|
+
element.setAttribute("tabindex", "-1");
|
|
1763
|
+
} else {
|
|
1764
|
+
element.removeAttribute("tabindex");
|
|
1765
|
+
}
|
|
1766
|
+
},
|
|
1767
|
+
setHidden(element, hidden) {
|
|
1768
|
+
if (hidden) {
|
|
1769
|
+
element.setAttribute("aria-hidden", "true");
|
|
1770
|
+
} else {
|
|
1771
|
+
element.removeAttribute("aria-hidden");
|
|
1772
|
+
}
|
|
1773
|
+
},
|
|
1774
|
+
setPressed(element, pressed) {
|
|
1775
|
+
element.setAttribute("aria-pressed", String(pressed));
|
|
1776
|
+
},
|
|
1777
|
+
setInvalid(element, invalid) {
|
|
1778
|
+
element.setAttribute("aria-invalid", String(invalid));
|
|
1779
|
+
},
|
|
1780
|
+
setRequired(element, required) {
|
|
1781
|
+
element.setAttribute("aria-required", String(required));
|
|
1782
|
+
},
|
|
1783
|
+
setLive(element, live) {
|
|
1784
|
+
element.setAttribute("aria-live", live);
|
|
1785
|
+
},
|
|
1786
|
+
setBusy(element, busy) {
|
|
1787
|
+
element.setAttribute("aria-busy", String(busy));
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
function createScreenReaderText(text) {
|
|
1791
|
+
const span = document.createElement("span");
|
|
1792
|
+
span.textContent = text;
|
|
1793
|
+
span.className = "sr-only";
|
|
1794
|
+
Object.assign(span.style, {
|
|
1795
|
+
position: "absolute",
|
|
1796
|
+
width: "1px",
|
|
1797
|
+
height: "1px",
|
|
1798
|
+
padding: "0",
|
|
1799
|
+
margin: "-1px",
|
|
1800
|
+
overflow: "hidden",
|
|
1801
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1802
|
+
whiteSpace: "nowrap",
|
|
1803
|
+
border: "0"
|
|
1804
|
+
});
|
|
1805
|
+
return span;
|
|
1806
|
+
}
|
|
1807
|
+
function prefersReducedMotion() {
|
|
1808
|
+
if (typeof window.matchMedia === "function") {
|
|
1809
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1810
|
+
}
|
|
1811
|
+
return false;
|
|
1812
|
+
}
|
|
1813
|
+
function prefersHighContrast() {
|
|
1814
|
+
if (typeof window.matchMedia === "function") {
|
|
1815
|
+
return window.matchMedia("(prefers-contrast: high)").matches;
|
|
1816
|
+
}
|
|
1817
|
+
return false;
|
|
1818
|
+
}
|
|
1819
|
+
function getColorSchemePreference() {
|
|
1820
|
+
if (typeof window.matchMedia === "function") {
|
|
1821
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
1822
|
+
return "dark";
|
|
1823
|
+
}
|
|
1824
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
1825
|
+
return "light";
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return null;
|
|
1829
|
+
}
|
|
1830
|
+
function createSkipLink(targetId, text = "Skip to main content") {
|
|
1831
|
+
const link = document.createElement("a");
|
|
1832
|
+
link.href = `#${targetId}`;
|
|
1833
|
+
link.textContent = text;
|
|
1834
|
+
link.className = "skip-link";
|
|
1835
|
+
Object.assign(link.style, {
|
|
1836
|
+
position: "absolute",
|
|
1837
|
+
top: "-40px",
|
|
1838
|
+
left: "0",
|
|
1839
|
+
background: "#000",
|
|
1840
|
+
color: "#fff",
|
|
1841
|
+
padding: "8px",
|
|
1842
|
+
textDecoration: "none",
|
|
1843
|
+
zIndex: "100"
|
|
1844
|
+
});
|
|
1845
|
+
link.addEventListener("focus", () => {
|
|
1846
|
+
link.style.top = "0";
|
|
1847
|
+
});
|
|
1848
|
+
link.addEventListener("blur", () => {
|
|
1849
|
+
link.style.top = "-40px";
|
|
1850
|
+
});
|
|
1851
|
+
return link;
|
|
1852
|
+
}
|
|
1853
|
+
function validateAriaRelationships(element) {
|
|
1854
|
+
const errors = [];
|
|
1855
|
+
const checkAttribute = (attr) => {
|
|
1856
|
+
const value = element.getAttribute(attr);
|
|
1857
|
+
if (value) {
|
|
1858
|
+
const ids = value.split(" ");
|
|
1859
|
+
for (const id of ids) {
|
|
1860
|
+
if (!document.getElementById(id)) {
|
|
1861
|
+
errors.push(`${attr} references non-existent ID: ${id}`);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
checkAttribute("aria-labelledby");
|
|
1867
|
+
checkAttribute("aria-describedby");
|
|
1868
|
+
checkAttribute("aria-controls");
|
|
1869
|
+
checkAttribute("aria-owns");
|
|
1870
|
+
checkAttribute("aria-activedescendant");
|
|
1871
|
+
return errors;
|
|
1872
|
+
}
|
|
1873
|
+
// src/utils/animation/easing.ts
|
|
1874
|
+
var linear = (t, b, c, d) => {
|
|
1875
|
+
return c * t / d + b;
|
|
1876
|
+
};
|
|
1877
|
+
var easeInQuad = (t, b, c, d) => {
|
|
1878
|
+
t /= d;
|
|
1879
|
+
return c * t * t + b;
|
|
1880
|
+
};
|
|
1881
|
+
var easeOutQuad = (t, b, c, d) => {
|
|
1882
|
+
t /= d;
|
|
1883
|
+
return -c * t * (t - 2) + b;
|
|
1884
|
+
};
|
|
1885
|
+
var easeInOutQuad = (t, b, c, d) => {
|
|
1886
|
+
t /= d / 2;
|
|
1887
|
+
if (t < 1)
|
|
1888
|
+
return c / 2 * t * t + b;
|
|
1889
|
+
t--;
|
|
1890
|
+
return -c / 2 * (t * (t - 2) - 1) + b;
|
|
1891
|
+
};
|
|
1892
|
+
var easeInCubic = (t, b, c, d) => {
|
|
1893
|
+
t /= d;
|
|
1894
|
+
return c * t * t * t + b;
|
|
1895
|
+
};
|
|
1896
|
+
var easeOutCubic = (t, b, c, d) => {
|
|
1897
|
+
t /= d;
|
|
1898
|
+
t--;
|
|
1899
|
+
return c * (t * t * t + 1) + b;
|
|
1900
|
+
};
|
|
1901
|
+
var easeInOutCubic = (t, b, c, d) => {
|
|
1902
|
+
t /= d / 2;
|
|
1903
|
+
if (t < 1)
|
|
1904
|
+
return c / 2 * t * t * t + b;
|
|
1905
|
+
t -= 2;
|
|
1906
|
+
return c / 2 * (t * t * t + 2) + b;
|
|
1907
|
+
};
|
|
1908
|
+
var easeInQuart = (t, b, c, d) => {
|
|
1909
|
+
t /= d;
|
|
1910
|
+
return c * t * t * t * t + b;
|
|
1911
|
+
};
|
|
1912
|
+
var easeOutQuart = (t, b, c, d) => {
|
|
1913
|
+
t /= d;
|
|
1914
|
+
t--;
|
|
1915
|
+
return -c * (t * t * t * t - 1) + b;
|
|
1916
|
+
};
|
|
1917
|
+
var easeInOutQuart = (t, b, c, d) => {
|
|
1918
|
+
t /= d / 2;
|
|
1919
|
+
if (t < 1)
|
|
1920
|
+
return c / 2 * t * t * t * t + b;
|
|
1921
|
+
t -= 2;
|
|
1922
|
+
return -c / 2 * (t * t * t * t - 2) + b;
|
|
1923
|
+
};
|
|
1924
|
+
var easeInQuint = (t, b, c, d) => {
|
|
1925
|
+
t /= d;
|
|
1926
|
+
return c * t * t * t * t * t + b;
|
|
1927
|
+
};
|
|
1928
|
+
var easeOutQuint = (t, b, c, d) => {
|
|
1929
|
+
t /= d;
|
|
1930
|
+
t--;
|
|
1931
|
+
return c * (t * t * t * t * t + 1) + b;
|
|
1932
|
+
};
|
|
1933
|
+
var easeInOutQuint = (t, b, c, d) => {
|
|
1934
|
+
t /= d / 2;
|
|
1935
|
+
if (t < 1)
|
|
1936
|
+
return c / 2 * t * t * t * t * t + b;
|
|
1937
|
+
t -= 2;
|
|
1938
|
+
return c / 2 * (t * t * t * t * t + 2) + b;
|
|
1939
|
+
};
|
|
1940
|
+
var easeInSine = (t, b, c, d) => {
|
|
1941
|
+
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
|
|
1942
|
+
};
|
|
1943
|
+
var easeOutSine = (t, b, c, d) => {
|
|
1944
|
+
return c * Math.sin(t / d * (Math.PI / 2)) + b;
|
|
1945
|
+
};
|
|
1946
|
+
var easeInOutSine = (t, b, c, d) => {
|
|
1947
|
+
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
|
|
1948
|
+
};
|
|
1949
|
+
var easeInExpo = (t, b, c, d) => {
|
|
1950
|
+
return t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;
|
|
1951
|
+
};
|
|
1952
|
+
var easeOutExpo = (t, b, c, d) => {
|
|
1953
|
+
return t === d ? b + c : c * (-(2 ** (-10 * t / d)) + 1) + b;
|
|
1954
|
+
};
|
|
1955
|
+
var easeInOutExpo = (t, b, c, d) => {
|
|
1956
|
+
if (t === 0)
|
|
1957
|
+
return b;
|
|
1958
|
+
if (t === d)
|
|
1959
|
+
return b + c;
|
|
1960
|
+
t /= d / 2;
|
|
1961
|
+
if (t < 1)
|
|
1962
|
+
return c / 2 * 2 ** (10 * (t - 1)) + b;
|
|
1963
|
+
t--;
|
|
1964
|
+
return c / 2 * (-(2 ** (-10 * t)) + 2) + b;
|
|
1965
|
+
};
|
|
1966
|
+
var easeInCirc = (t, b, c, d) => {
|
|
1967
|
+
t /= d;
|
|
1968
|
+
return -c * (Math.sqrt(1 - t * t) - 1) + b;
|
|
1969
|
+
};
|
|
1970
|
+
var easeOutCirc = (t, b, c, d) => {
|
|
1971
|
+
t /= d;
|
|
1972
|
+
t--;
|
|
1973
|
+
return c * Math.sqrt(1 - t * t) + b;
|
|
1974
|
+
};
|
|
1975
|
+
var easeInOutCirc = (t, b, c, d) => {
|
|
1976
|
+
t /= d / 2;
|
|
1977
|
+
if (t < 1)
|
|
1978
|
+
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
|
|
1979
|
+
t -= 2;
|
|
1980
|
+
return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
|
|
1981
|
+
};
|
|
1982
|
+
var easeInElastic = (t, b, c, d) => {
|
|
1983
|
+
let s = 1.70158;
|
|
1984
|
+
let p = 0;
|
|
1985
|
+
let a = c;
|
|
1986
|
+
if (t === 0)
|
|
1987
|
+
return b;
|
|
1988
|
+
t /= d;
|
|
1989
|
+
if (t === 1)
|
|
1990
|
+
return b + c;
|
|
1991
|
+
if (!p)
|
|
1992
|
+
p = d * 0.3;
|
|
1993
|
+
if (a < Math.abs(c)) {
|
|
1994
|
+
a = c;
|
|
1995
|
+
s = p / 4;
|
|
1996
|
+
} else {
|
|
1997
|
+
s = p / (2 * Math.PI) * Math.asin(c / a);
|
|
1998
|
+
}
|
|
1999
|
+
t -= 1;
|
|
2000
|
+
return -(a * 2 ** (10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
|
2001
|
+
};
|
|
2002
|
+
var easeOutElastic = (t, b, c, d) => {
|
|
2003
|
+
let s = 1.70158;
|
|
2004
|
+
let p = 0;
|
|
2005
|
+
let a = c;
|
|
2006
|
+
if (t === 0)
|
|
2007
|
+
return b;
|
|
2008
|
+
t /= d;
|
|
2009
|
+
if (t === 1)
|
|
2010
|
+
return b + c;
|
|
2011
|
+
if (!p)
|
|
2012
|
+
p = d * 0.3;
|
|
2013
|
+
if (a < Math.abs(c)) {
|
|
2014
|
+
a = c;
|
|
2015
|
+
s = p / 4;
|
|
2016
|
+
} else {
|
|
2017
|
+
s = p / (2 * Math.PI) * Math.asin(c / a);
|
|
2018
|
+
}
|
|
2019
|
+
return a * 2 ** (-10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
|
|
2020
|
+
};
|
|
2021
|
+
var easeInOutElastic = (t, b, c, d) => {
|
|
2022
|
+
let s = 1.70158;
|
|
2023
|
+
let p = 0;
|
|
2024
|
+
let a = c;
|
|
2025
|
+
if (t === 0)
|
|
2026
|
+
return b;
|
|
2027
|
+
t /= d / 2;
|
|
2028
|
+
if (t === 2)
|
|
2029
|
+
return b + c;
|
|
2030
|
+
if (!p)
|
|
2031
|
+
p = d * (0.3 * 1.5);
|
|
2032
|
+
if (a < Math.abs(c)) {
|
|
2033
|
+
a = c;
|
|
2034
|
+
s = p / 4;
|
|
2035
|
+
} else {
|
|
2036
|
+
s = p / (2 * Math.PI) * Math.asin(c / a);
|
|
2037
|
+
}
|
|
2038
|
+
if (t < 1) {
|
|
2039
|
+
t -= 1;
|
|
2040
|
+
return -0.5 * (a * 2 ** (10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
|
2041
|
+
}
|
|
2042
|
+
t -= 1;
|
|
2043
|
+
return a * 2 ** (-10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b;
|
|
2044
|
+
};
|
|
2045
|
+
var easeInBack = (t, b, c, d) => {
|
|
2046
|
+
const s = 1.70158;
|
|
2047
|
+
t /= d;
|
|
2048
|
+
return c * t * t * ((s + 1) * t - s) + b;
|
|
2049
|
+
};
|
|
2050
|
+
var easeOutBack = (t, b, c, d) => {
|
|
2051
|
+
const s = 1.70158;
|
|
2052
|
+
t /= d;
|
|
2053
|
+
t--;
|
|
2054
|
+
return c * (t * t * ((s + 1) * t + s) + 1) + b;
|
|
2055
|
+
};
|
|
2056
|
+
var easeInOutBack = (t, b, c, d) => {
|
|
2057
|
+
let s = 1.70158;
|
|
2058
|
+
t /= d / 2;
|
|
2059
|
+
if (t < 1) {
|
|
2060
|
+
s *= 1.525;
|
|
2061
|
+
return c / 2 * (t * t * ((s + 1) * t - s)) + b;
|
|
2062
|
+
}
|
|
2063
|
+
t -= 2;
|
|
2064
|
+
s *= 1.525;
|
|
2065
|
+
return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b;
|
|
2066
|
+
};
|
|
2067
|
+
var easeOutBounce = (t, b, c, d) => {
|
|
2068
|
+
t /= d;
|
|
2069
|
+
if (t < 1 / 2.75) {
|
|
2070
|
+
return c * (7.5625 * t * t) + b;
|
|
2071
|
+
} else if (t < 2 / 2.75) {
|
|
2072
|
+
t -= 1.5 / 2.75;
|
|
2073
|
+
return c * (7.5625 * t * t + 0.75) + b;
|
|
2074
|
+
} else if (t < 2.5 / 2.75) {
|
|
2075
|
+
t -= 2.25 / 2.75;
|
|
2076
|
+
return c * (7.5625 * t * t + 0.9375) + b;
|
|
2077
|
+
} else {
|
|
2078
|
+
t -= 2.625 / 2.75;
|
|
2079
|
+
return c * (7.5625 * t * t + 0.984375) + b;
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2082
|
+
var easeInBounce = (t, b, c, d) => {
|
|
2083
|
+
return c - easeOutBounce(d - t, 0, c, d) + b;
|
|
2084
|
+
};
|
|
2085
|
+
var easeInOutBounce = (t, b, c, d) => {
|
|
2086
|
+
if (t < d / 2)
|
|
2087
|
+
return easeInBounce(t * 2, 0, c, d) * 0.5 + b;
|
|
2088
|
+
return easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
|
2089
|
+
};
|
|
2090
|
+
var Easing = {
|
|
2091
|
+
linear,
|
|
2092
|
+
easeInQuad,
|
|
2093
|
+
easeOutQuad,
|
|
2094
|
+
easeInOutQuad,
|
|
2095
|
+
easeInCubic,
|
|
2096
|
+
easeOutCubic,
|
|
2097
|
+
easeInOutCubic,
|
|
2098
|
+
easeInQuart,
|
|
2099
|
+
easeOutQuart,
|
|
2100
|
+
easeInOutQuart,
|
|
2101
|
+
easeInQuint,
|
|
2102
|
+
easeOutQuint,
|
|
2103
|
+
easeInOutQuint,
|
|
2104
|
+
easeInSine,
|
|
2105
|
+
easeOutSine,
|
|
2106
|
+
easeInOutSine,
|
|
2107
|
+
easeInExpo,
|
|
2108
|
+
easeOutExpo,
|
|
2109
|
+
easeInOutExpo,
|
|
2110
|
+
easeInCirc,
|
|
2111
|
+
easeOutCirc,
|
|
2112
|
+
easeInOutCirc,
|
|
2113
|
+
easeInElastic,
|
|
2114
|
+
easeOutElastic,
|
|
2115
|
+
easeInOutElastic,
|
|
2116
|
+
easeInBack,
|
|
2117
|
+
easeOutBack,
|
|
2118
|
+
easeInOutBack,
|
|
2119
|
+
easeInBounce,
|
|
2120
|
+
easeOutBounce,
|
|
2121
|
+
easeInOutBounce
|
|
2122
|
+
};
|
|
2123
|
+
|
|
2124
|
+
// src/utils/animation/helpers.ts
|
|
2125
|
+
function cssAnimation(name, options = {}) {
|
|
2126
|
+
const {
|
|
2127
|
+
duration = "1s",
|
|
2128
|
+
timing = "ease",
|
|
2129
|
+
delay = "0s",
|
|
2130
|
+
iteration = "1",
|
|
2131
|
+
direction = "normal",
|
|
2132
|
+
fill = "both",
|
|
2133
|
+
playState = "running"
|
|
2134
|
+
} = options;
|
|
2135
|
+
return `${name} ${duration} ${timing} ${delay} ${iteration} ${direction} ${fill} ${playState}`;
|
|
2136
|
+
}
|
|
2137
|
+
function applyAnimation(element, animationName, options = {}) {
|
|
2138
|
+
element.style.animation = cssAnimation(animationName, options);
|
|
2139
|
+
}
|
|
2140
|
+
function removeAnimation(element) {
|
|
2141
|
+
element.style.animation = "";
|
|
2142
|
+
}
|
|
2143
|
+
function waitForAnimation(element) {
|
|
2144
|
+
return new Promise((resolve) => {
|
|
2145
|
+
const handleAnimationEnd = () => {
|
|
2146
|
+
element.removeEventListener("animationend", handleAnimationEnd);
|
|
2147
|
+
resolve();
|
|
2148
|
+
};
|
|
2149
|
+
element.addEventListener("animationend", handleAnimationEnd);
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
function staggerAnimation(elements, animationName, options = {}) {
|
|
2153
|
+
const { stagger = 100, ...animationOptions } = options;
|
|
2154
|
+
elements.forEach((element, index) => {
|
|
2155
|
+
const delay = `${index * stagger}ms`;
|
|
2156
|
+
applyAnimation(element, animationName, {
|
|
2157
|
+
...animationOptions,
|
|
2158
|
+
delay
|
|
2159
|
+
});
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
async function sequenceAnimations(element, animations) {
|
|
2163
|
+
for (const animation of animations) {
|
|
2164
|
+
applyAnimation(element, animation.name, animation.options);
|
|
2165
|
+
await waitForAnimation(element);
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
var AnimationClasses = {
|
|
2169
|
+
fadeIn: "animate-fade-in",
|
|
2170
|
+
fadeOut: "animate-fade-out",
|
|
2171
|
+
slideInUp: "animate-slide-in-up",
|
|
2172
|
+
slideInDown: "animate-slide-in-down",
|
|
2173
|
+
slideInLeft: "animate-slide-in-left",
|
|
2174
|
+
slideInRight: "animate-slide-in-right",
|
|
2175
|
+
zoomIn: "animate-zoom-in",
|
|
2176
|
+
zoomOut: "animate-zoom-out",
|
|
2177
|
+
bounce: "animate-bounce",
|
|
2178
|
+
spin: "animate-spin",
|
|
2179
|
+
ping: "animate-ping",
|
|
2180
|
+
pulse: "animate-pulse"
|
|
2181
|
+
};
|
|
2182
|
+
function animateWithClass(element, animationClass, duration = 1000) {
|
|
2183
|
+
return new Promise((resolve) => {
|
|
2184
|
+
element.classList.add(animationClass);
|
|
2185
|
+
setTimeout(() => {
|
|
2186
|
+
element.classList.remove(animationClass);
|
|
2187
|
+
resolve();
|
|
2188
|
+
}, duration);
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function createKeyframes(name, frames) {
|
|
2192
|
+
const keyframesRule = `
|
|
2193
|
+
@keyframes ${name} {
|
|
2194
|
+
${Object.entries(frames).map(([percentage, styles]) => {
|
|
2195
|
+
const styleString = Object.entries(styles).map(([prop, value]) => `${prop}: ${value};`).join(" ");
|
|
2196
|
+
return `${percentage} { ${styleString} }`;
|
|
2197
|
+
}).join(`
|
|
14
2198
|
`)}
|
|
15
2199
|
}
|
|
16
|
-
`,r=document.createElement("style");r.textContent=s,document.head.appendChild(r)}function ao(e,t,s={}){if(typeof e.animate!=="function")return console.warn("Web Animations API not supported"),null;let{duration:r=1000,easing:o="ease",delay:a=0,iterations:i=1,direction:n="normal",fill:d="both"}=s;return e.animate([...t],{duration:r,easing:o,delay:a,iterations:i,direction:n,fill:d})}var io={fadeIn:[{offset:0,opacity:0},{offset:1,opacity:1}],fadeOut:[{offset:0,opacity:1},{offset:1,opacity:0}],slideInUp:[{offset:0,transform:"translateY(100%)",opacity:0},{offset:1,transform:"translateY(0)",opacity:1}],slideInDown:[{offset:0,transform:"translateY(-100%)",opacity:0},{offset:1,transform:"translateY(0)",opacity:1}],slideInLeft:[{offset:0,transform:"translateX(-100%)",opacity:0},{offset:1,transform:"translateX(0)",opacity:1}],slideInRight:[{offset:0,transform:"translateX(100%)",opacity:0},{offset:1,transform:"translateX(0)",opacity:1}],slideOutUp:[{offset:0,transform:"translateY(0)",opacity:1},{offset:1,transform:"translateY(-100%)",opacity:0}],slideOutDown:[{offset:0,transform:"translateY(0)",opacity:1},{offset:1,transform:"translateY(100%)",opacity:0}],slideOutLeft:[{offset:0,transform:"translateX(0)",opacity:1},{offset:1,transform:"translateX(-100%)",opacity:0}],slideOutRight:[{offset:0,transform:"translateX(0)",opacity:1},{offset:1,transform:"translateX(100%)",opacity:0}],zoomIn:[{offset:0,transform:"scale(0)",opacity:0},{offset:0.5,opacity:1},{offset:1,transform:"scale(1)"}],zoomOut:[{offset:0,transform:"scale(1)",opacity:1},{offset:0.5,opacity:1},{offset:1,transform:"scale(0)",opacity:0}],rotate:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(360deg)"}],bounce:[{offset:0,transform:"translateY(0)"},{offset:0.2,transform:"translateY(0)"},{offset:0.4,transform:"translateY(-30px)"},{offset:0.43,transform:"translateY(-30px)"},{offset:0.53,transform:"translateY(0)"},{offset:0.7,transform:"translateY(-15px)"},{offset:0.8,transform:"translateY(0)"},{offset:0.9,transform:"translateY(-4px)"},{offset:1,transform:"translateY(0)"}],pulse:[{offset:0,transform:"scale(1)"},{offset:0.5,transform:"scale(1.05)"},{offset:1,transform:"scale(1)"}],shake:[{offset:0,transform:"translateX(0)"},{offset:0.1,transform:"translateX(-10px)"},{offset:0.2,transform:"translateX(10px)"},{offset:0.3,transform:"translateX(-10px)"},{offset:0.4,transform:"translateX(10px)"},{offset:0.5,transform:"translateX(-10px)"},{offset:0.6,transform:"translateX(10px)"},{offset:0.7,transform:"translateX(-10px)"},{offset:0.8,transform:"translateX(10px)"},{offset:0.9,transform:"translateX(-10px)"},{offset:1,transform:"translateX(0)"}],swing:[{offset:0,transform:"rotate(0deg)"},{offset:0.2,transform:"rotate(15deg)"},{offset:0.4,transform:"rotate(-10deg)"},{offset:0.6,transform:"rotate(5deg)"},{offset:0.8,transform:"rotate(-5deg)"},{offset:1,transform:"rotate(0deg)"}],flip:[{offset:0,transform:"perspective(400px) rotateY(0)",animationTimingFunction:"ease-out"},{offset:0.4,transform:"perspective(400px) translateZ(150px) rotateY(170deg)",animationTimingFunction:"ease-out"},{offset:0.5,transform:"perspective(400px) translateZ(150px) rotateY(190deg)",animationTimingFunction:"ease-in"},{offset:0.8,transform:"perspective(400px) rotateY(360deg)",animationTimingFunction:"ease-in"},{offset:1,transform:"perspective(400px)",animationTimingFunction:"ease-in"}],rubberBand:[{offset:0,transform:"scale(1)"},{offset:0.3,transform:"scaleX(1.25) scaleY(0.75)"},{offset:0.4,transform:"scaleX(0.75) scaleY(1.25)"},{offset:0.5,transform:"scaleX(1.15) scaleY(0.85)"},{offset:0.65,transform:"scaleX(0.95) scaleY(1.05)"},{offset:0.75,transform:"scaleX(1.05) scaleY(0.95)"},{offset:1,transform:"scale(1)"}],heartbeat:[{offset:0,transform:"scale(1)"},{offset:0.14,transform:"scale(1.3)"},{offset:0.28,transform:"scale(1)"},{offset:0.42,transform:"scale(1.3)"},{offset:0.7,transform:"scale(1)"}]};function Ed(e,t,s={}){return ao(e,io[t],s)}import{createHighlighter as no}from"ts-syntax-highlighter";var Q=null;async function lo(){if(!Q)Q=await no({theme:"github-light"});return Q}async function Od(e,t={}){let{theme:s="auto",language:r="typescript",lineNumbers:o=!1,wrapLines:a=!0}=t,i=await lo(),n=s==="auto"?globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches?"github-dark":"github-light":s==="dark"?"github-dark":"github-light",d=await i.highlight(e,r);return{html:typeof d==="string"?d:String(d),language:r,theme:n}}function Bd(e){if(e.includes("<!DOCTYPE")||e.includes("<html"))return"html";if(e.includes("<?php"))return"php";if(e.includes("import")&&e.includes("from"))return"typescript";if(e.includes("function")||e.includes("const"))return"javascript";if(e.includes("{")&&e.includes("}"))return"json";if(e.includes("$")&&e.includes("|"))return"bash";if(e.includes("#")&&e.includes("##"))return"markdown";return"typescript"}function qd(e,t){return`<div class="${t?`rounded-md overflow-auto text-sm leading-relaxed font-mono ${t}`:"rounded-md overflow-auto text-sm leading-relaxed font-mono"}">${e}</div>`}var L=null,co=(e)=>{return e===1?0:1};function _(e,t){return t.split(".").reduce((s,r)=>s?.[r],e)}function ee(e,t={}){return e.replace(/\{(\w+)\}/g,(s,r)=>{return t[r]!==void 0?String(t[r]):s})}function Ad(e){let{locale:t,fallbackLocale:s="en",messages:r,pluralRules:o={},dateTimeFormats:a={},numberFormats:i={},missing:n,warnMissing:d=!0}=e;function c(m,v={}){let C=_(r[t],m);if(C===void 0&&s)C=_(r[s],m);if(C===void 0){if(n){let I=n(t,m);if(I)return ee(I,v)}if(d&&typeof console<"u")console.warn(`[i18n] Missing translation for key "${m}" in locale "${t}"`);return m}if(typeof C==="string")return ee(C,v);return String(C)}function g(m,v,C={}){let I=c(m,{...C,count:v});if(I.includes("|")){let E=I.split("|").map((J)=>J.trim()),Y=(o[t]||co)(v,t),G=E[Y]||E[E.length-1];return ee(G,{...C,count:v})}return I}function p(m,v="default"){let C=typeof m==="number"?new Date(m):m,I=a[v]||a.default||{};return new Intl.DateTimeFormat(t,I).format(C)}function f(m,v="default"){let C=i[v]||i.default||{};return new Intl.NumberFormat(t,C).format(m)}function x(m){if(_(r[t],m)!==void 0)return!0;if(s)return _(r[s],m)!==void 0;return!1}function y(m){if(!r[m]){console.warn(`[i18n] Locale "${m}" not found. Available locales: ${Object.keys(r).join(", ")}`);return}t=m}function h(m,v){if(!r[m])r[m]={};r[m]={...r[m],...v}}function $(m){delete r[m]}return{get locale(){return t},get availableLocales(){return Object.keys(r)},setLocale:y,t:c,tc:g,d:p,n:f,te:x,addMessages:h,removeLocale:$}}function Hd(e){L=e}function Vd(){return L}function Rd(e,t){if(!L)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),e;return L.t(e,t)}function Wd(e,t,s){if(!L)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),e;return L.tc(e,t,s)}function _d(e,t){if(!L)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),String(e);return L.d(e,t)}function Fd(e,t){if(!L)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),String(e);return L.n(e,t)}var Ud={en:(e)=>e===1?0:1,de:(e)=>e===1?0:1,nl:(e)=>e===1?0:1,sv:(e)=>e===1?0:1,fr:(e)=>e===0||e===1?0:1,pt_BR:(e)=>e===0||e===1?0:1,ru:(e)=>{if(e%10===1&&e%100!==11)return 0;if(e%10>=2&&e%10<=4&&(e%100<10||e%100>=20))return 1;return 2},pl:(e)=>{if(e===1)return 0;if(e%10>=2&&e%10<=4&&(e%100<10||e%100>=20))return 1;return 2},cs:(e)=>{if(e===1)return 0;if(e>=2&&e<=4)return 1;return 2},ar:(e)=>{if(e===0)return 0;if(e===1)return 1;if(e===2)return 2;if(e%100>=3&&e%100<=10)return 3;if(e%100>=11)return 4;return 5},ja:()=>0,ko:()=>0,zh:()=>0,th:()=>0,vi:()=>0},Yd={short:{year:"numeric",month:"numeric",day:"numeric"},long:{year:"numeric",month:"long",day:"numeric"},full:{weekday:"long",year:"numeric",month:"long",day:"numeric"},time:{hour:"numeric",minute:"numeric"},datetime:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}},Gd={decimal:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2},currency:{style:"currency",currency:"USD"},percent:{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2},compact:{notation:"compact"}};function Jd(e){let t=["ar","he","fa","ur","yi"],s=e.split("-")[0].toLowerCase();return t.includes(s)}async function Zd(e,t){try{return await t()}catch(s){return console.error(`[i18n] Failed to load messages for locale "${e}":`,s),{}}}var Kd={en:{common:{loading:"Loading...",error:"Error",retry:"Retry",cancel:"Cancel",confirm:"Confirm",close:"Close",save:"Save",delete:"Delete",edit:"Edit",search:"Search",clear:"Clear",submit:"Submit",reset:"Reset"},form:{required:"This field is required",invalid:"Invalid value",tooShort:"Value is too short (minimum {min} characters)",tooLong:"Value is too long (maximum {max} characters)",invalidEmail:"Invalid email address",invalidUrl:"Invalid URL"},pagination:{previous:"Previous",next:"Next",page:"Page {page}",of:"of {total}"}},es:{common:{loading:"Cargando...",error:"Error",retry:"Reintentar",cancel:"Cancelar",confirm:"Confirmar",close:"Cerrar",save:"Guardar",delete:"Eliminar",edit:"Editar",search:"Buscar",clear:"Limpiar",submit:"Enviar",reset:"Restablecer"},form:{required:"Este campo es obligatorio",invalid:"Valor inv\xE1lido",tooShort:"El valor es demasiado corto (m\xEDnimo {min} caracteres)",tooLong:"El valor es demasiado largo (m\xE1ximo {max} caracteres)",invalidEmail:"Direcci\xF3n de correo electr\xF3nico inv\xE1lida",invalidUrl:"URL inv\xE1lida"},pagination:{previous:"Anterior",next:"Siguiente",page:"P\xE1gina {page}",of:"de {total}"}},fr:{common:{loading:"Chargement...",error:"Erreur",retry:"R\xE9essayer",cancel:"Annuler",confirm:"Confirmer",close:"Fermer",save:"Enregistrer",delete:"Supprimer",edit:"Modifier",search:"Rechercher",clear:"Effacer",submit:"Soumettre",reset:"R\xE9initialiser"},form:{required:"Ce champ est obligatoire",invalid:"Valeur invalide",tooShort:"La valeur est trop courte (minimum {min} caract\xE8res)",tooLong:"La valeur est trop longue (maximum {max} caract\xE8res)",invalidEmail:"Adresse e-mail invalide",invalidUrl:"URL invalide"},pagination:{previous:"Pr\xE9c\xE9dent",next:"Suivant",page:"Page {page}",of:"sur {total}"}}};function Qd(e={}){let{max:t=10,ttl:s=0,include:r,exclude:o,hooks:a,debug:i=!1}=e,n=new Map,d=0,c=0;function g(...u){if(i)console.log("[KeepAlive]",...u)}function p(u){if(o){if(o instanceof RegExp&&o.test(u))return!1;if(Array.isArray(o)&&o.includes(u))return!1}if(r){if(r instanceof RegExp&&!r.test(u))return!1;if(Array.isArray(r)&&!r.includes(u))return!1}return!0}function f(u){if(!s||!u.expiresAt)return!1;return Date.now()>u.expiresAt}function x(u){let b=n.get(u);if(b)b.lastAccessedAt=Date.now(),b.accessCount++,b.instance.lastAccessedAt=b.lastAccessedAt,n.delete(u),n.set(u,b),g(`Touched: ${u} (access count: ${b.accessCount})`)}function y(){if(n.size===0)return!1;let u=n.keys().next().value;if(!u)return!1;let b=n.get(u);if(b){g(`Evicting LRU: ${u}`);let w=b.instance.hooks;if(w?.onDeactivate)w.onDeactivate(b.instance);if(a?.onDeactivate)a.onDeactivate(b.instance);return n.delete(u),!0}return!1}function h(u,b,w){if(!p(b.type))return g(`Type not cacheable: ${b.type}`),b;if(n.size>=t)y();let D=Date.now(),A={instance:{...b,hooks:w||b.hooks,createdAt:b.createdAt||D,lastAccessedAt:D},accessCount:0,createdAt:D,lastAccessedAt:D,expiresAt:s?D+s:void 0};if(n.set(u,A),g(`Cached: ${u} (size: ${n.size}/${t})`),w?.onMount)w.onMount(A.instance);if(a?.onMount)a.onMount(A.instance);return A.instance}function $(u){let b=n.get(u);if(!b)return c++,g(`Miss: ${u}`),null;if(f(b))return g(`Expired: ${u}`),n.delete(u),c++,null;return d++,x(u),g(`Hit: ${u}`),b.instance}function m(u){let b=n.get(u);if(!b)return!1;if(f(b))return n.delete(u),!1;return!0}function v(u){let b=n.get(u);if(!b)return!1;g(`Removing: ${u}`);let w=b.instance.hooks;if(w?.onUnmount)w.onUnmount(b.instance);if(a?.onUnmount)a.onUnmount(b.instance);return n.delete(u)}function C(){g("Clearing cache"),n.forEach((u)=>{let b=u.instance.hooks;if(b?.onUnmount)b.onUnmount(u.instance);if(a?.onUnmount)a.onUnmount(u.instance)}),n.clear(),d=0,c=0}function I(){let u=0,b=Date.now();for(let[w,D]of n.entries())if(f(D))g(`Pruning expired: ${w}`),v(w),u++;while(n.size>t)if(y())u++;else break;if(u>0)g(`Pruned ${u} entries`);return u}function E(u){let b=$(u);if(!b)return null;g(`Activating: ${u}`);let w=b.hooks;if(w?.onActivate)w.onActivate(b);if(a?.onActivate)a.onActivate(b);if(b.state&&w?.onRestore)w.onRestore(b,b.state);return b}function se(u){let b=n.get(u);if(!b)return!1;g(`Deactivating: ${u}`);let w=b.instance,D=w.hooks;if(D?.onSave)w.state=D.onSave(w);if(D?.onDeactivate)D.onDeactivate(w);if(a?.onDeactivate)a.onDeactivate(w);return!0}function Y(){let u=d+c;return{hits:d,misses:c,size:n.size,max:t,hitRate:u>0?d/u:0,keys:Array.from(n.keys())}}function G(){return Array.from(n.keys())}function J(){return n.size}return{cache:h,get:$,has:m,remove:v,clear:C,prune:I,activate:E,deactivate:se,getStats:Y,keys:G,size:J}}function ec(e){let t=new Map;return{set(s,r){if(t.has(s))t.delete(s);if(t.set(s,r),t.size>e){let o=t.keys().next().value;if(o)t.delete(o)}},get(s){if(!t.has(s))return;let r=t.get(s);return t.delete(s),t.set(s,r),r},has(s){return t.has(s)},delete(s){return t.delete(s)},clear(){t.clear()},get size(){return t.size},keys(){return Array.from(t.keys())},values(){return Array.from(t.values())},forEach(s){t.forEach(s)}}}function tc(){let e=new Map;return{save(t,s){e.set(t,JSON.parse(JSON.stringify(s)))},restore(t){let s=e.get(t);return s?JSON.parse(JSON.stringify(s)):null},has(t){return e.has(t)},remove(t){return e.delete(t)},clear(){e.clear()},keys(){return Array.from(e.keys())},get size(){return e.size}}}function sc(e,t={}){let{maxSize:s=100,reset:r}=t,o=[];return{acquire(){if(o.length>0)return o.pop();return e()},release(a){if(o.length<s){if(r)r(a);o.push(a)}},clear(){o.length=0},get size(){return o.length},get maxSize(){return s}}}var M=new Map;async function F(e,t){let s=t||e.toString();if(M.has(s))return M.get(s);let r=e();M.set(s,r);try{return await r}catch(o){throw M.delete(s),o}}function oc(e,t={}){let{retryAttempts:s=3,retryDelay:r=1000,onLoading:o,onLoaded:a,onError:i}=t,n="idle",d,c,g=async(p=0)=>{try{if(n==="loading"||n==="loaded"){if(d)return d}n="loading",o?.();let f=await F(e);return d=f,n="loaded",a?.(f),f}catch(f){let x=f;if(p<s)return await new Promise((y)=>setTimeout(y,r*(p+1))),g(p+1);throw n="error",c=x,i?.(x),x}};return{get state(){return n},get module(){return d},get error(){return c},load:()=>g(),preload:()=>g()}}function po(e,t,s={}){if(!e)return console.warn("lazyLoad: element is null"),()=>{};let{root:r=null,rootMargin:o="0px",threshold:a=0.01,placeholder:i,errorContent:n,onLoading:d,onLoaded:c,onError:g}=s,p=!1,f=null;if(i)if(typeof i==="string")e.innerHTML=i;else e.innerHTML="",e.appendChild(i);return f=new IntersectionObserver(async(y)=>{for(let h of y)if(h.isIntersecting&&!p){p=!0,f?.disconnect();try{d?.();let $=await F(t);if(c?.($),$&&typeof $.default?.render==="function"){let m=await $.default.render();e.innerHTML=m}}catch($){let m=$;if(g?.(m),n)if(typeof n==="string")e.innerHTML=n;else e.innerHTML="",e.appendChild(n);else e.innerHTML=`<div style="color: red;">Failed to load component: ${m.message}</div>`}}},{root:r,rootMargin:o,threshold:a}),f.observe(e),()=>{f?.disconnect(),f=null}}function ac(e,t,s={}){let r=[],o=Array.from(e);for(let a of o){let i=typeof t==="function"&&t.length>0?()=>t(a):t,n=po(a,i,s);r.push(n)}return()=>{r.forEach((a)=>a())}}function uo(e){return F(e)}function ic(e){return Promise.all(e.map((t)=>uo(t)))}function nc(e){if(e)M.delete(e);else M.clear()}function lc(){return{size:M.size,keys:Array.from(M.keys())}}function dc(e){return{async load(t){let s=e[t];if(!s)throw Error(`No route found for path: ${t}`);return F(s,`route:${t}`)},async preload(t){return this.load(t)},async preloadRoutes(t){return Promise.all(t.map((s)=>this.preload(s)))}}}function go(e,t,s={}){if(!e)return()=>{};let{root:r=null,rootMargin:o="50px",threshold:a=0.01,placeholder:i,onLoading:n,onLoaded:d,onError:c}=s;if(i&&typeof i==="string")e.src=i;let g=!1,p=null;return p=new IntersectionObserver((x)=>{for(let y of x)if(y.isIntersecting&&!g)g=!0,p?.disconnect(),n?.(),e.src=t,e.addEventListener("load",()=>{d?.(e),e.classList.add("loaded")},{once:!0}),e.addEventListener("error",(h)=>{let $=Error(`Failed to load image: ${t}`);c?.($),e.classList.add("error")},{once:!0})},{root:r,rootMargin:o,threshold:a}),p.observe(e),()=>{p?.disconnect(),p=null}}function cc(e=document,t={}){let s=e.querySelectorAll("img[data-lazy-src]"),r=[];return s.forEach((o)=>{let a=o.getAttribute("data-lazy-src");if(a){let i=go(o,a,t);r.push(i)}}),()=>{r.forEach((o)=>o())}}var te={colors:{primary:"#3b82f6",secondary:"#8b5cf6",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#06b6d4",gray:"#6b7280",white:"#ffffff",black:"#000000"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{light:"300",normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.75"}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem","4xl":"6rem"},borderRadius:{none:"0",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",none:"none"},components:{button:{borderRadius:"0.375rem",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:"500"},input:{borderRadius:"0.375rem",padding:"0.5rem 0.75rem",fontSize:"0.875rem",borderWidth:"1px"},card:{borderRadius:"0.5rem",padding:"1.5rem",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"}}};function ne(e,t){let s={...e};for(let r in t)if(t[r]instanceof Object&&r in e)s[r]=ne(e[r],t[r]);else s[r]=t[r];return s}function j(e){return ne(te,e)}var U=te;function uc(){return U}function xo(e){let t=[];if(e.colors)Object.entries(e.colors).forEach(([s,r])=>{if(r)t.push(`--color-${s}: ${r};`)});if(e.typography?.fontFamily)Object.entries(e.typography.fontFamily).forEach(([s,r])=>{if(r)t.push(`--font-${s}: ${r};`)});if(e.typography?.fontSize)Object.entries(e.typography.fontSize).forEach(([s,r])=>{if(r)t.push(`--text-${s}: ${r};`)});if(e.typography?.fontWeight)Object.entries(e.typography.fontWeight).forEach(([s,r])=>{if(r)t.push(`--font-weight-${s}: ${r};`)});if(e.typography?.lineHeight)Object.entries(e.typography.lineHeight).forEach(([s,r])=>{if(r)t.push(`--leading-${s}: ${r};`)});if(e.spacing)Object.entries(e.spacing).forEach(([s,r])=>{if(r)t.push(`--spacing-${s}: ${r};`)});if(e.borderRadius)Object.entries(e.borderRadius).forEach(([s,r])=>{if(r)t.push(`--radius-${s}: ${r};`)});if(e.shadows)Object.entries(e.shadows).forEach(([s,r])=>{if(r)t.push(`--shadow-${s}: ${r};`)});if(e.components?.button)Object.entries(e.components.button).forEach(([s,r])=>{if(r)t.push(`--button-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r};`)});if(e.components?.input)Object.entries(e.components.input).forEach(([s,r])=>{if(r)t.push(`--input-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r};`)});if(e.components?.card)Object.entries(e.components.card).forEach(([s,r])=>{if(r)t.push(`--card-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r};`)});return`:root {
|
|
17
|
-
|
|
2200
|
+
`;
|
|
2201
|
+
const styleSheet = document.createElement("style");
|
|
2202
|
+
styleSheet.textContent = keyframesRule;
|
|
2203
|
+
document.head.appendChild(styleSheet);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
// src/utils/animation/keyframes.ts
|
|
2207
|
+
function createKeyframeAnimation(element, keyframes, options = {}) {
|
|
2208
|
+
if (typeof element.animate !== "function") {
|
|
2209
|
+
console.warn("Web Animations API not supported");
|
|
2210
|
+
return null;
|
|
2211
|
+
}
|
|
2212
|
+
const {
|
|
2213
|
+
duration = 1000,
|
|
2214
|
+
easing = "ease",
|
|
2215
|
+
delay = 0,
|
|
2216
|
+
iterations = 1,
|
|
2217
|
+
direction = "normal",
|
|
2218
|
+
fill = "both"
|
|
2219
|
+
} = options;
|
|
2220
|
+
return element.animate([...keyframes], {
|
|
2221
|
+
duration,
|
|
2222
|
+
easing,
|
|
2223
|
+
delay,
|
|
2224
|
+
iterations,
|
|
2225
|
+
direction,
|
|
2226
|
+
fill
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
var KeyframeAnimations = {
|
|
2230
|
+
fadeIn: [
|
|
2231
|
+
{ offset: 0, opacity: 0 },
|
|
2232
|
+
{ offset: 1, opacity: 1 }
|
|
2233
|
+
],
|
|
2234
|
+
fadeOut: [
|
|
2235
|
+
{ offset: 0, opacity: 1 },
|
|
2236
|
+
{ offset: 1, opacity: 0 }
|
|
2237
|
+
],
|
|
2238
|
+
slideInUp: [
|
|
2239
|
+
{ offset: 0, transform: "translateY(100%)", opacity: 0 },
|
|
2240
|
+
{ offset: 1, transform: "translateY(0)", opacity: 1 }
|
|
2241
|
+
],
|
|
2242
|
+
slideInDown: [
|
|
2243
|
+
{ offset: 0, transform: "translateY(-100%)", opacity: 0 },
|
|
2244
|
+
{ offset: 1, transform: "translateY(0)", opacity: 1 }
|
|
2245
|
+
],
|
|
2246
|
+
slideInLeft: [
|
|
2247
|
+
{ offset: 0, transform: "translateX(-100%)", opacity: 0 },
|
|
2248
|
+
{ offset: 1, transform: "translateX(0)", opacity: 1 }
|
|
2249
|
+
],
|
|
2250
|
+
slideInRight: [
|
|
2251
|
+
{ offset: 0, transform: "translateX(100%)", opacity: 0 },
|
|
2252
|
+
{ offset: 1, transform: "translateX(0)", opacity: 1 }
|
|
2253
|
+
],
|
|
2254
|
+
slideOutUp: [
|
|
2255
|
+
{ offset: 0, transform: "translateY(0)", opacity: 1 },
|
|
2256
|
+
{ offset: 1, transform: "translateY(-100%)", opacity: 0 }
|
|
2257
|
+
],
|
|
2258
|
+
slideOutDown: [
|
|
2259
|
+
{ offset: 0, transform: "translateY(0)", opacity: 1 },
|
|
2260
|
+
{ offset: 1, transform: "translateY(100%)", opacity: 0 }
|
|
2261
|
+
],
|
|
2262
|
+
slideOutLeft: [
|
|
2263
|
+
{ offset: 0, transform: "translateX(0)", opacity: 1 },
|
|
2264
|
+
{ offset: 1, transform: "translateX(-100%)", opacity: 0 }
|
|
2265
|
+
],
|
|
2266
|
+
slideOutRight: [
|
|
2267
|
+
{ offset: 0, transform: "translateX(0)", opacity: 1 },
|
|
2268
|
+
{ offset: 1, transform: "translateX(100%)", opacity: 0 }
|
|
2269
|
+
],
|
|
2270
|
+
zoomIn: [
|
|
2271
|
+
{ offset: 0, transform: "scale(0)", opacity: 0 },
|
|
2272
|
+
{ offset: 0.5, opacity: 1 },
|
|
2273
|
+
{ offset: 1, transform: "scale(1)" }
|
|
2274
|
+
],
|
|
2275
|
+
zoomOut: [
|
|
2276
|
+
{ offset: 0, transform: "scale(1)", opacity: 1 },
|
|
2277
|
+
{ offset: 0.5, opacity: 1 },
|
|
2278
|
+
{ offset: 1, transform: "scale(0)", opacity: 0 }
|
|
2279
|
+
],
|
|
2280
|
+
rotate: [
|
|
2281
|
+
{ offset: 0, transform: "rotate(0deg)" },
|
|
2282
|
+
{ offset: 1, transform: "rotate(360deg)" }
|
|
2283
|
+
],
|
|
2284
|
+
bounce: [
|
|
2285
|
+
{ offset: 0, transform: "translateY(0)" },
|
|
2286
|
+
{ offset: 0.2, transform: "translateY(0)" },
|
|
2287
|
+
{ offset: 0.4, transform: "translateY(-30px)" },
|
|
2288
|
+
{ offset: 0.43, transform: "translateY(-30px)" },
|
|
2289
|
+
{ offset: 0.53, transform: "translateY(0)" },
|
|
2290
|
+
{ offset: 0.7, transform: "translateY(-15px)" },
|
|
2291
|
+
{ offset: 0.8, transform: "translateY(0)" },
|
|
2292
|
+
{ offset: 0.9, transform: "translateY(-4px)" },
|
|
2293
|
+
{ offset: 1, transform: "translateY(0)" }
|
|
2294
|
+
],
|
|
2295
|
+
pulse: [
|
|
2296
|
+
{ offset: 0, transform: "scale(1)" },
|
|
2297
|
+
{ offset: 0.5, transform: "scale(1.05)" },
|
|
2298
|
+
{ offset: 1, transform: "scale(1)" }
|
|
2299
|
+
],
|
|
2300
|
+
shake: [
|
|
2301
|
+
{ offset: 0, transform: "translateX(0)" },
|
|
2302
|
+
{ offset: 0.1, transform: "translateX(-10px)" },
|
|
2303
|
+
{ offset: 0.2, transform: "translateX(10px)" },
|
|
2304
|
+
{ offset: 0.3, transform: "translateX(-10px)" },
|
|
2305
|
+
{ offset: 0.4, transform: "translateX(10px)" },
|
|
2306
|
+
{ offset: 0.5, transform: "translateX(-10px)" },
|
|
2307
|
+
{ offset: 0.6, transform: "translateX(10px)" },
|
|
2308
|
+
{ offset: 0.7, transform: "translateX(-10px)" },
|
|
2309
|
+
{ offset: 0.8, transform: "translateX(10px)" },
|
|
2310
|
+
{ offset: 0.9, transform: "translateX(-10px)" },
|
|
2311
|
+
{ offset: 1, transform: "translateX(0)" }
|
|
2312
|
+
],
|
|
2313
|
+
swing: [
|
|
2314
|
+
{ offset: 0, transform: "rotate(0deg)" },
|
|
2315
|
+
{ offset: 0.2, transform: "rotate(15deg)" },
|
|
2316
|
+
{ offset: 0.4, transform: "rotate(-10deg)" },
|
|
2317
|
+
{ offset: 0.6, transform: "rotate(5deg)" },
|
|
2318
|
+
{ offset: 0.8, transform: "rotate(-5deg)" },
|
|
2319
|
+
{ offset: 1, transform: "rotate(0deg)" }
|
|
2320
|
+
],
|
|
2321
|
+
flip: [
|
|
2322
|
+
{ offset: 0, transform: "perspective(400px) rotateY(0)", animationTimingFunction: "ease-out" },
|
|
2323
|
+
{ offset: 0.4, transform: "perspective(400px) translateZ(150px) rotateY(170deg)", animationTimingFunction: "ease-out" },
|
|
2324
|
+
{ offset: 0.5, transform: "perspective(400px) translateZ(150px) rotateY(190deg)", animationTimingFunction: "ease-in" },
|
|
2325
|
+
{ offset: 0.8, transform: "perspective(400px) rotateY(360deg)", animationTimingFunction: "ease-in" },
|
|
2326
|
+
{ offset: 1, transform: "perspective(400px)", animationTimingFunction: "ease-in" }
|
|
2327
|
+
],
|
|
2328
|
+
rubberBand: [
|
|
2329
|
+
{ offset: 0, transform: "scale(1)" },
|
|
2330
|
+
{ offset: 0.3, transform: "scaleX(1.25) scaleY(0.75)" },
|
|
2331
|
+
{ offset: 0.4, transform: "scaleX(0.75) scaleY(1.25)" },
|
|
2332
|
+
{ offset: 0.5, transform: "scaleX(1.15) scaleY(0.85)" },
|
|
2333
|
+
{ offset: 0.65, transform: "scaleX(0.95) scaleY(1.05)" },
|
|
2334
|
+
{ offset: 0.75, transform: "scaleX(1.05) scaleY(0.95)" },
|
|
2335
|
+
{ offset: 1, transform: "scale(1)" }
|
|
2336
|
+
],
|
|
2337
|
+
heartbeat: [
|
|
2338
|
+
{ offset: 0, transform: "scale(1)" },
|
|
2339
|
+
{ offset: 0.14, transform: "scale(1.3)" },
|
|
2340
|
+
{ offset: 0.28, transform: "scale(1)" },
|
|
2341
|
+
{ offset: 0.42, transform: "scale(1.3)" },
|
|
2342
|
+
{ offset: 0.7, transform: "scale(1)" }
|
|
2343
|
+
]
|
|
2344
|
+
};
|
|
2345
|
+
function animate(element, animationName, options = {}) {
|
|
2346
|
+
return createKeyframeAnimation(element, KeyframeAnimations[animationName], options);
|
|
2347
|
+
}
|
|
2348
|
+
// src/utils/highlighter.ts
|
|
2349
|
+
import { createHighlighter } from "ts-syntax-highlighter";
|
|
2350
|
+
var highlighterInstance = null;
|
|
2351
|
+
async function getHighlighter() {
|
|
2352
|
+
if (!highlighterInstance) {
|
|
2353
|
+
highlighterInstance = await createHighlighter({
|
|
2354
|
+
theme: "github-light"
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
return highlighterInstance;
|
|
2358
|
+
}
|
|
2359
|
+
async function highlight(code, options = {}) {
|
|
2360
|
+
const {
|
|
2361
|
+
theme = "auto",
|
|
2362
|
+
language = "typescript",
|
|
2363
|
+
lineNumbers: _lineNumbers = false,
|
|
2364
|
+
wrapLines: _wrapLines = true
|
|
2365
|
+
} = options;
|
|
2366
|
+
const highlighter = await getHighlighter();
|
|
2367
|
+
const effectiveTheme = theme === "auto" ? globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? "github-dark" : "github-light" : theme === "dark" ? "github-dark" : "github-light";
|
|
2368
|
+
const html = await highlighter.highlight(code, language);
|
|
2369
|
+
return {
|
|
2370
|
+
html: typeof html === "string" ? html : String(html),
|
|
2371
|
+
language,
|
|
2372
|
+
theme: effectiveTheme
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
function detectLanguage(code) {
|
|
2376
|
+
if (code.includes("<!DOCTYPE") || code.includes("<html"))
|
|
2377
|
+
return "html";
|
|
2378
|
+
if (code.includes("<?php"))
|
|
2379
|
+
return "php";
|
|
2380
|
+
if (code.includes("import") && code.includes("from"))
|
|
2381
|
+
return "typescript";
|
|
2382
|
+
if (code.includes("function") || code.includes("const"))
|
|
2383
|
+
return "javascript";
|
|
2384
|
+
if (code.includes("{") && code.includes("}"))
|
|
2385
|
+
return "json";
|
|
2386
|
+
if (code.includes("$") && code.includes("|"))
|
|
2387
|
+
return "bash";
|
|
2388
|
+
if (code.includes("#") && code.includes("##"))
|
|
2389
|
+
return "markdown";
|
|
2390
|
+
return "typescript";
|
|
2391
|
+
}
|
|
2392
|
+
function applyHeadwindClasses(html, additionalClasses) {
|
|
2393
|
+
const baseClasses = "rounded-md overflow-auto text-sm leading-relaxed font-mono";
|
|
2394
|
+
const classes = additionalClasses ? `${baseClasses} ${additionalClasses}` : baseClasses;
|
|
2395
|
+
return `<div class="${classes}">${html}</div>`;
|
|
2396
|
+
}
|
|
2397
|
+
// src/utils/i18n.ts
|
|
2398
|
+
var globalI18n = null;
|
|
2399
|
+
var defaultPluralRule = (count) => {
|
|
2400
|
+
return count === 1 ? 0 : 1;
|
|
2401
|
+
};
|
|
2402
|
+
function getNestedProperty(obj, path) {
|
|
2403
|
+
return path.split(".").reduce((current, key) => current?.[key], obj);
|
|
2404
|
+
}
|
|
2405
|
+
function interpolate(template, params = {}) {
|
|
2406
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => {
|
|
2407
|
+
return params[key] !== undefined ? String(params[key]) : match;
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
function createI18n(config) {
|
|
2411
|
+
let {
|
|
2412
|
+
locale,
|
|
2413
|
+
fallbackLocale = "en",
|
|
2414
|
+
messages,
|
|
2415
|
+
pluralRules = {},
|
|
2416
|
+
dateTimeFormats = {},
|
|
2417
|
+
numberFormats = {},
|
|
2418
|
+
missing,
|
|
2419
|
+
warnMissing = true
|
|
2420
|
+
} = config;
|
|
2421
|
+
function t(key, params = {}) {
|
|
2422
|
+
let translation = getNestedProperty(messages[locale], key);
|
|
2423
|
+
if (translation === undefined && fallbackLocale) {
|
|
2424
|
+
translation = getNestedProperty(messages[fallbackLocale], key);
|
|
2425
|
+
}
|
|
2426
|
+
if (translation === undefined) {
|
|
2427
|
+
if (missing) {
|
|
2428
|
+
const result = missing(locale, key);
|
|
2429
|
+
if (result) {
|
|
2430
|
+
return interpolate(result, params);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
if (warnMissing && typeof console !== "undefined") {
|
|
2434
|
+
console.warn(`[i18n] Missing translation for key "${key}" in locale "${locale}"`);
|
|
2435
|
+
}
|
|
2436
|
+
return key;
|
|
2437
|
+
}
|
|
2438
|
+
if (typeof translation === "string") {
|
|
2439
|
+
return interpolate(translation, params);
|
|
2440
|
+
}
|
|
2441
|
+
return String(translation);
|
|
2442
|
+
}
|
|
2443
|
+
function tc(key, count, params = {}) {
|
|
2444
|
+
const translation = t(key, { ...params, count });
|
|
2445
|
+
if (translation.includes("|")) {
|
|
2446
|
+
const forms = translation.split("|").map((s) => s.trim());
|
|
2447
|
+
const pluralRule = pluralRules[locale] || defaultPluralRule;
|
|
2448
|
+
const index = pluralRule(count, locale);
|
|
2449
|
+
const form = forms[index] || forms[forms.length - 1];
|
|
2450
|
+
return interpolate(form, { ...params, count });
|
|
2451
|
+
}
|
|
2452
|
+
return translation;
|
|
2453
|
+
}
|
|
2454
|
+
function d(date, format = "default") {
|
|
2455
|
+
const dateObj = typeof date === "number" ? new Date(date) : date;
|
|
2456
|
+
const formatOptions = dateTimeFormats[format] || dateTimeFormats.default || {};
|
|
2457
|
+
return new Intl.DateTimeFormat(locale, formatOptions).format(dateObj);
|
|
2458
|
+
}
|
|
2459
|
+
function n(value, format = "default") {
|
|
2460
|
+
const formatOptions = numberFormats[format] || numberFormats.default || {};
|
|
2461
|
+
return new Intl.NumberFormat(locale, formatOptions).format(value);
|
|
2462
|
+
}
|
|
2463
|
+
function te(key) {
|
|
2464
|
+
const translation = getNestedProperty(messages[locale], key);
|
|
2465
|
+
if (translation !== undefined) {
|
|
2466
|
+
return true;
|
|
2467
|
+
}
|
|
2468
|
+
if (fallbackLocale) {
|
|
2469
|
+
const fallbackTranslation = getNestedProperty(messages[fallbackLocale], key);
|
|
2470
|
+
return fallbackTranslation !== undefined;
|
|
2471
|
+
}
|
|
2472
|
+
return false;
|
|
2473
|
+
}
|
|
2474
|
+
function setLocale(newLocale) {
|
|
2475
|
+
if (!messages[newLocale]) {
|
|
2476
|
+
console.warn(`[i18n] Locale "${newLocale}" not found. Available locales: ${Object.keys(messages).join(", ")}`);
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
locale = newLocale;
|
|
2480
|
+
}
|
|
2481
|
+
function addMessages(addLocale, newMessages) {
|
|
2482
|
+
if (!messages[addLocale]) {
|
|
2483
|
+
messages[addLocale] = {};
|
|
2484
|
+
}
|
|
2485
|
+
messages[addLocale] = {
|
|
2486
|
+
...messages[addLocale],
|
|
2487
|
+
...newMessages
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
function removeLocale(removeLocale2) {
|
|
2491
|
+
delete messages[removeLocale2];
|
|
2492
|
+
}
|
|
2493
|
+
return {
|
|
2494
|
+
get locale() {
|
|
2495
|
+
return locale;
|
|
2496
|
+
},
|
|
2497
|
+
get availableLocales() {
|
|
2498
|
+
return Object.keys(messages);
|
|
2499
|
+
},
|
|
2500
|
+
setLocale,
|
|
2501
|
+
t,
|
|
2502
|
+
tc,
|
|
2503
|
+
d,
|
|
2504
|
+
n,
|
|
2505
|
+
te,
|
|
2506
|
+
addMessages,
|
|
2507
|
+
removeLocale
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
function setI18n(i18n) {
|
|
2511
|
+
globalI18n = i18n;
|
|
2512
|
+
}
|
|
2513
|
+
function getI18n() {
|
|
2514
|
+
return globalI18n;
|
|
2515
|
+
}
|
|
2516
|
+
function t(key, params) {
|
|
2517
|
+
if (!globalI18n) {
|
|
2518
|
+
console.warn("[i18n] No global i18n instance set. Call setI18n() first.");
|
|
2519
|
+
return key;
|
|
2520
|
+
}
|
|
2521
|
+
return globalI18n.t(key, params);
|
|
2522
|
+
}
|
|
2523
|
+
function tc(key, count, params) {
|
|
2524
|
+
if (!globalI18n) {
|
|
2525
|
+
console.warn("[i18n] No global i18n instance set. Call setI18n() first.");
|
|
2526
|
+
return key;
|
|
2527
|
+
}
|
|
2528
|
+
return globalI18n.tc(key, count, params);
|
|
2529
|
+
}
|
|
2530
|
+
function d(date, format) {
|
|
2531
|
+
if (!globalI18n) {
|
|
2532
|
+
console.warn("[i18n] No global i18n instance set. Call setI18n() first.");
|
|
2533
|
+
return String(date);
|
|
2534
|
+
}
|
|
2535
|
+
return globalI18n.d(date, format);
|
|
2536
|
+
}
|
|
2537
|
+
function n(value, format) {
|
|
2538
|
+
if (!globalI18n) {
|
|
2539
|
+
console.warn("[i18n] No global i18n instance set. Call setI18n() first.");
|
|
2540
|
+
return String(value);
|
|
2541
|
+
}
|
|
2542
|
+
return globalI18n.n(value, format);
|
|
2543
|
+
}
|
|
2544
|
+
var pluralRules = {
|
|
2545
|
+
en: (count) => count === 1 ? 0 : 1,
|
|
2546
|
+
de: (count) => count === 1 ? 0 : 1,
|
|
2547
|
+
nl: (count) => count === 1 ? 0 : 1,
|
|
2548
|
+
sv: (count) => count === 1 ? 0 : 1,
|
|
2549
|
+
fr: (count) => count === 0 || count === 1 ? 0 : 1,
|
|
2550
|
+
pt_BR: (count) => count === 0 || count === 1 ? 0 : 1,
|
|
2551
|
+
ru: (count) => {
|
|
2552
|
+
if (count % 10 === 1 && count % 100 !== 11)
|
|
2553
|
+
return 0;
|
|
2554
|
+
if (count % 10 >= 2 && count % 10 <= 4 && (count % 100 < 10 || count % 100 >= 20))
|
|
2555
|
+
return 1;
|
|
2556
|
+
return 2;
|
|
2557
|
+
},
|
|
2558
|
+
pl: (count) => {
|
|
2559
|
+
if (count === 1)
|
|
2560
|
+
return 0;
|
|
2561
|
+
if (count % 10 >= 2 && count % 10 <= 4 && (count % 100 < 10 || count % 100 >= 20))
|
|
2562
|
+
return 1;
|
|
2563
|
+
return 2;
|
|
2564
|
+
},
|
|
2565
|
+
cs: (count) => {
|
|
2566
|
+
if (count === 1)
|
|
2567
|
+
return 0;
|
|
2568
|
+
if (count >= 2 && count <= 4)
|
|
2569
|
+
return 1;
|
|
2570
|
+
return 2;
|
|
2571
|
+
},
|
|
2572
|
+
ar: (count) => {
|
|
2573
|
+
if (count === 0)
|
|
2574
|
+
return 0;
|
|
2575
|
+
if (count === 1)
|
|
2576
|
+
return 1;
|
|
2577
|
+
if (count === 2)
|
|
2578
|
+
return 2;
|
|
2579
|
+
if (count % 100 >= 3 && count % 100 <= 10)
|
|
2580
|
+
return 3;
|
|
2581
|
+
if (count % 100 >= 11)
|
|
2582
|
+
return 4;
|
|
2583
|
+
return 5;
|
|
2584
|
+
},
|
|
2585
|
+
ja: () => 0,
|
|
2586
|
+
ko: () => 0,
|
|
2587
|
+
zh: () => 0,
|
|
2588
|
+
th: () => 0,
|
|
2589
|
+
vi: () => 0
|
|
2590
|
+
};
|
|
2591
|
+
var dateTimeFormats = {
|
|
2592
|
+
short: {
|
|
2593
|
+
year: "numeric",
|
|
2594
|
+
month: "numeric",
|
|
2595
|
+
day: "numeric"
|
|
2596
|
+
},
|
|
2597
|
+
long: {
|
|
2598
|
+
year: "numeric",
|
|
2599
|
+
month: "long",
|
|
2600
|
+
day: "numeric"
|
|
2601
|
+
},
|
|
2602
|
+
full: {
|
|
2603
|
+
weekday: "long",
|
|
2604
|
+
year: "numeric",
|
|
2605
|
+
month: "long",
|
|
2606
|
+
day: "numeric"
|
|
2607
|
+
},
|
|
2608
|
+
time: {
|
|
2609
|
+
hour: "numeric",
|
|
2610
|
+
minute: "numeric"
|
|
2611
|
+
},
|
|
2612
|
+
datetime: {
|
|
2613
|
+
year: "numeric",
|
|
2614
|
+
month: "numeric",
|
|
2615
|
+
day: "numeric",
|
|
2616
|
+
hour: "numeric",
|
|
2617
|
+
minute: "numeric"
|
|
2618
|
+
}
|
|
2619
|
+
};
|
|
2620
|
+
var numberFormats = {
|
|
2621
|
+
decimal: {
|
|
2622
|
+
style: "decimal",
|
|
2623
|
+
minimumFractionDigits: 2,
|
|
2624
|
+
maximumFractionDigits: 2
|
|
2625
|
+
},
|
|
2626
|
+
currency: {
|
|
2627
|
+
style: "currency",
|
|
2628
|
+
currency: "USD"
|
|
2629
|
+
},
|
|
2630
|
+
percent: {
|
|
2631
|
+
style: "percent",
|
|
2632
|
+
minimumFractionDigits: 0,
|
|
2633
|
+
maximumFractionDigits: 2
|
|
2634
|
+
},
|
|
2635
|
+
compact: {
|
|
2636
|
+
notation: "compact"
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
function isRTL(locale) {
|
|
2640
|
+
const rtlLocales = ["ar", "he", "fa", "ur", "yi"];
|
|
2641
|
+
const lang = locale.split("-")[0].toLowerCase();
|
|
2642
|
+
return rtlLocales.includes(lang);
|
|
2643
|
+
}
|
|
2644
|
+
async function loadLocaleMessages(locale, loadFn) {
|
|
2645
|
+
try {
|
|
2646
|
+
return await loadFn();
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
console.error(`[i18n] Failed to load messages for locale "${locale}":`, error);
|
|
2649
|
+
return {};
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
var componentMessages = {
|
|
2653
|
+
en: {
|
|
2654
|
+
common: {
|
|
2655
|
+
loading: "Loading...",
|
|
2656
|
+
error: "Error",
|
|
2657
|
+
retry: "Retry",
|
|
2658
|
+
cancel: "Cancel",
|
|
2659
|
+
confirm: "Confirm",
|
|
2660
|
+
close: "Close",
|
|
2661
|
+
save: "Save",
|
|
2662
|
+
delete: "Delete",
|
|
2663
|
+
edit: "Edit",
|
|
2664
|
+
search: "Search",
|
|
2665
|
+
clear: "Clear",
|
|
2666
|
+
submit: "Submit",
|
|
2667
|
+
reset: "Reset"
|
|
2668
|
+
},
|
|
2669
|
+
form: {
|
|
2670
|
+
required: "This field is required",
|
|
2671
|
+
invalid: "Invalid value",
|
|
2672
|
+
tooShort: "Value is too short (minimum {min} characters)",
|
|
2673
|
+
tooLong: "Value is too long (maximum {max} characters)",
|
|
2674
|
+
invalidEmail: "Invalid email address",
|
|
2675
|
+
invalidUrl: "Invalid URL"
|
|
2676
|
+
},
|
|
2677
|
+
pagination: {
|
|
2678
|
+
previous: "Previous",
|
|
2679
|
+
next: "Next",
|
|
2680
|
+
page: "Page {page}",
|
|
2681
|
+
of: "of {total}"
|
|
2682
|
+
}
|
|
2683
|
+
},
|
|
2684
|
+
es: {
|
|
2685
|
+
common: {
|
|
2686
|
+
loading: "Cargando...",
|
|
2687
|
+
error: "Error",
|
|
2688
|
+
retry: "Reintentar",
|
|
2689
|
+
cancel: "Cancelar",
|
|
2690
|
+
confirm: "Confirmar",
|
|
2691
|
+
close: "Cerrar",
|
|
2692
|
+
save: "Guardar",
|
|
2693
|
+
delete: "Eliminar",
|
|
2694
|
+
edit: "Editar",
|
|
2695
|
+
search: "Buscar",
|
|
2696
|
+
clear: "Limpiar",
|
|
2697
|
+
submit: "Enviar",
|
|
2698
|
+
reset: "Restablecer"
|
|
2699
|
+
},
|
|
2700
|
+
form: {
|
|
2701
|
+
required: "Este campo es obligatorio",
|
|
2702
|
+
invalid: "Valor inv\xE1lido",
|
|
2703
|
+
tooShort: "El valor es demasiado corto (m\xEDnimo {min} caracteres)",
|
|
2704
|
+
tooLong: "El valor es demasiado largo (m\xE1ximo {max} caracteres)",
|
|
2705
|
+
invalidEmail: "Direcci\xF3n de correo electr\xF3nico inv\xE1lida",
|
|
2706
|
+
invalidUrl: "URL inv\xE1lida"
|
|
2707
|
+
},
|
|
2708
|
+
pagination: {
|
|
2709
|
+
previous: "Anterior",
|
|
2710
|
+
next: "Siguiente",
|
|
2711
|
+
page: "P\xE1gina {page}",
|
|
2712
|
+
of: "de {total}"
|
|
2713
|
+
}
|
|
2714
|
+
},
|
|
2715
|
+
fr: {
|
|
2716
|
+
common: {
|
|
2717
|
+
loading: "Chargement...",
|
|
2718
|
+
error: "Erreur",
|
|
2719
|
+
retry: "R\xE9essayer",
|
|
2720
|
+
cancel: "Annuler",
|
|
2721
|
+
confirm: "Confirmer",
|
|
2722
|
+
close: "Fermer",
|
|
2723
|
+
save: "Enregistrer",
|
|
2724
|
+
delete: "Supprimer",
|
|
2725
|
+
edit: "Modifier",
|
|
2726
|
+
search: "Rechercher",
|
|
2727
|
+
clear: "Effacer",
|
|
2728
|
+
submit: "Soumettre",
|
|
2729
|
+
reset: "R\xE9initialiser"
|
|
2730
|
+
},
|
|
2731
|
+
form: {
|
|
2732
|
+
required: "Ce champ est obligatoire",
|
|
2733
|
+
invalid: "Valeur invalide",
|
|
2734
|
+
tooShort: "La valeur est trop courte (minimum {min} caract\xE8res)",
|
|
2735
|
+
tooLong: "La valeur est trop longue (maximum {max} caract\xE8res)",
|
|
2736
|
+
invalidEmail: "Adresse e-mail invalide",
|
|
2737
|
+
invalidUrl: "URL invalide"
|
|
2738
|
+
},
|
|
2739
|
+
pagination: {
|
|
2740
|
+
previous: "Pr\xE9c\xE9dent",
|
|
2741
|
+
next: "Suivant",
|
|
2742
|
+
page: "Page {page}",
|
|
2743
|
+
of: "sur {total}"
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2747
|
+
// src/utils/keep-alive.ts
|
|
2748
|
+
function createKeepAlive(options = {}) {
|
|
2749
|
+
const {
|
|
2750
|
+
max = 10,
|
|
2751
|
+
ttl = 0,
|
|
2752
|
+
include,
|
|
2753
|
+
exclude,
|
|
2754
|
+
hooks: globalHooks,
|
|
2755
|
+
debug = false
|
|
2756
|
+
} = options;
|
|
2757
|
+
const cache = new Map;
|
|
2758
|
+
let hits = 0;
|
|
2759
|
+
let misses = 0;
|
|
2760
|
+
function log(...args) {
|
|
2761
|
+
if (debug) {
|
|
2762
|
+
console.log("[KeepAlive]", ...args);
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
function shouldCache(type) {
|
|
2766
|
+
if (exclude) {
|
|
2767
|
+
if (exclude instanceof RegExp && exclude.test(type)) {
|
|
2768
|
+
return false;
|
|
2769
|
+
}
|
|
2770
|
+
if (Array.isArray(exclude) && exclude.includes(type)) {
|
|
2771
|
+
return false;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
if (include) {
|
|
2775
|
+
if (include instanceof RegExp && !include.test(type)) {
|
|
2776
|
+
return false;
|
|
2777
|
+
}
|
|
2778
|
+
if (Array.isArray(include) && !include.includes(type)) {
|
|
2779
|
+
return false;
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
return true;
|
|
2783
|
+
}
|
|
2784
|
+
function isExpired(entry) {
|
|
2785
|
+
if (!ttl || !entry.expiresAt) {
|
|
2786
|
+
return false;
|
|
2787
|
+
}
|
|
2788
|
+
return Date.now() > entry.expiresAt;
|
|
2789
|
+
}
|
|
2790
|
+
function touch(key) {
|
|
2791
|
+
const entry = cache.get(key);
|
|
2792
|
+
if (entry) {
|
|
2793
|
+
entry.lastAccessedAt = Date.now();
|
|
2794
|
+
entry.accessCount++;
|
|
2795
|
+
entry.instance.lastAccessedAt = entry.lastAccessedAt;
|
|
2796
|
+
cache.delete(key);
|
|
2797
|
+
cache.set(key, entry);
|
|
2798
|
+
log(`Touched: ${key} (access count: ${entry.accessCount})`);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
function evictLRU() {
|
|
2802
|
+
if (cache.size === 0) {
|
|
2803
|
+
return false;
|
|
2804
|
+
}
|
|
2805
|
+
const firstKey = cache.keys().next().value;
|
|
2806
|
+
if (!firstKey) {
|
|
2807
|
+
return false;
|
|
2808
|
+
}
|
|
2809
|
+
const entry = cache.get(firstKey);
|
|
2810
|
+
if (entry) {
|
|
2811
|
+
log(`Evicting LRU: ${firstKey}`);
|
|
2812
|
+
const hooks = entry.instance.hooks;
|
|
2813
|
+
if (hooks?.onDeactivate) {
|
|
2814
|
+
hooks.onDeactivate(entry.instance);
|
|
2815
|
+
}
|
|
2816
|
+
if (globalHooks?.onDeactivate) {
|
|
2817
|
+
globalHooks.onDeactivate(entry.instance);
|
|
2818
|
+
}
|
|
2819
|
+
cache.delete(firstKey);
|
|
2820
|
+
return true;
|
|
2821
|
+
}
|
|
2822
|
+
return false;
|
|
2823
|
+
}
|
|
2824
|
+
function cacheComponent(key, instance, hooks) {
|
|
2825
|
+
if (!shouldCache(instance.type)) {
|
|
2826
|
+
log(`Type not cacheable: ${instance.type}`);
|
|
2827
|
+
return instance;
|
|
2828
|
+
}
|
|
2829
|
+
if (cache.size >= max) {
|
|
2830
|
+
evictLRU();
|
|
2831
|
+
}
|
|
2832
|
+
const now = Date.now();
|
|
2833
|
+
const entry = {
|
|
2834
|
+
instance: {
|
|
2835
|
+
...instance,
|
|
2836
|
+
hooks: hooks || instance.hooks,
|
|
2837
|
+
createdAt: instance.createdAt || now,
|
|
2838
|
+
lastAccessedAt: now
|
|
2839
|
+
},
|
|
2840
|
+
accessCount: 0,
|
|
2841
|
+
createdAt: now,
|
|
2842
|
+
lastAccessedAt: now,
|
|
2843
|
+
expiresAt: ttl ? now + ttl : undefined
|
|
2844
|
+
};
|
|
2845
|
+
cache.set(key, entry);
|
|
2846
|
+
log(`Cached: ${key} (size: ${cache.size}/${max})`);
|
|
2847
|
+
if (hooks?.onMount) {
|
|
2848
|
+
hooks.onMount(entry.instance);
|
|
2849
|
+
}
|
|
2850
|
+
if (globalHooks?.onMount) {
|
|
2851
|
+
globalHooks.onMount(entry.instance);
|
|
2852
|
+
}
|
|
2853
|
+
return entry.instance;
|
|
2854
|
+
}
|
|
2855
|
+
function get(key) {
|
|
2856
|
+
const entry = cache.get(key);
|
|
2857
|
+
if (!entry) {
|
|
2858
|
+
misses++;
|
|
2859
|
+
log(`Miss: ${key}`);
|
|
2860
|
+
return null;
|
|
2861
|
+
}
|
|
2862
|
+
if (isExpired(entry)) {
|
|
2863
|
+
log(`Expired: ${key}`);
|
|
2864
|
+
cache.delete(key);
|
|
2865
|
+
misses++;
|
|
2866
|
+
return null;
|
|
2867
|
+
}
|
|
2868
|
+
hits++;
|
|
2869
|
+
touch(key);
|
|
2870
|
+
log(`Hit: ${key}`);
|
|
2871
|
+
return entry.instance;
|
|
2872
|
+
}
|
|
2873
|
+
function has(key) {
|
|
2874
|
+
const entry = cache.get(key);
|
|
2875
|
+
if (!entry) {
|
|
2876
|
+
return false;
|
|
2877
|
+
}
|
|
2878
|
+
if (isExpired(entry)) {
|
|
2879
|
+
cache.delete(key);
|
|
2880
|
+
return false;
|
|
2881
|
+
}
|
|
2882
|
+
return true;
|
|
2883
|
+
}
|
|
2884
|
+
function remove(key) {
|
|
2885
|
+
const entry = cache.get(key);
|
|
2886
|
+
if (!entry) {
|
|
2887
|
+
return false;
|
|
2888
|
+
}
|
|
2889
|
+
log(`Removing: ${key}`);
|
|
2890
|
+
const hooks = entry.instance.hooks;
|
|
2891
|
+
if (hooks?.onUnmount) {
|
|
2892
|
+
hooks.onUnmount(entry.instance);
|
|
2893
|
+
}
|
|
2894
|
+
if (globalHooks?.onUnmount) {
|
|
2895
|
+
globalHooks.onUnmount(entry.instance);
|
|
2896
|
+
}
|
|
2897
|
+
return cache.delete(key);
|
|
2898
|
+
}
|
|
2899
|
+
function clear() {
|
|
2900
|
+
log("Clearing cache");
|
|
2901
|
+
cache.forEach((entry) => {
|
|
2902
|
+
const hooks = entry.instance.hooks;
|
|
2903
|
+
if (hooks?.onUnmount) {
|
|
2904
|
+
hooks.onUnmount(entry.instance);
|
|
2905
|
+
}
|
|
2906
|
+
if (globalHooks?.onUnmount) {
|
|
2907
|
+
globalHooks.onUnmount(entry.instance);
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
cache.clear();
|
|
2911
|
+
hits = 0;
|
|
2912
|
+
misses = 0;
|
|
2913
|
+
}
|
|
2914
|
+
function prune() {
|
|
2915
|
+
let pruned = 0;
|
|
2916
|
+
const _now = Date.now();
|
|
2917
|
+
for (const [key, entry] of cache.entries()) {
|
|
2918
|
+
if (isExpired(entry)) {
|
|
2919
|
+
log(`Pruning expired: ${key}`);
|
|
2920
|
+
remove(key);
|
|
2921
|
+
pruned++;
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
while (cache.size > max) {
|
|
2925
|
+
if (evictLRU()) {
|
|
2926
|
+
pruned++;
|
|
2927
|
+
} else {
|
|
2928
|
+
break;
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
if (pruned > 0) {
|
|
2932
|
+
log(`Pruned ${pruned} entries`);
|
|
2933
|
+
}
|
|
2934
|
+
return pruned;
|
|
2935
|
+
}
|
|
2936
|
+
function activate(key) {
|
|
2937
|
+
const instance = get(key);
|
|
2938
|
+
if (!instance) {
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
log(`Activating: ${key}`);
|
|
2942
|
+
const hooks = instance.hooks;
|
|
2943
|
+
if (hooks?.onActivate) {
|
|
2944
|
+
hooks.onActivate(instance);
|
|
2945
|
+
}
|
|
2946
|
+
if (globalHooks?.onActivate) {
|
|
2947
|
+
globalHooks.onActivate(instance);
|
|
2948
|
+
}
|
|
2949
|
+
if (instance.state && hooks?.onRestore) {
|
|
2950
|
+
hooks.onRestore(instance, instance.state);
|
|
2951
|
+
}
|
|
2952
|
+
return instance;
|
|
2953
|
+
}
|
|
2954
|
+
function deactivate(key) {
|
|
2955
|
+
const entry = cache.get(key);
|
|
2956
|
+
if (!entry) {
|
|
2957
|
+
return false;
|
|
2958
|
+
}
|
|
2959
|
+
log(`Deactivating: ${key}`);
|
|
2960
|
+
const instance = entry.instance;
|
|
2961
|
+
const hooks = instance.hooks;
|
|
2962
|
+
if (hooks?.onSave) {
|
|
2963
|
+
instance.state = hooks.onSave(instance);
|
|
2964
|
+
}
|
|
2965
|
+
if (hooks?.onDeactivate) {
|
|
2966
|
+
hooks.onDeactivate(instance);
|
|
2967
|
+
}
|
|
2968
|
+
if (globalHooks?.onDeactivate) {
|
|
2969
|
+
globalHooks.onDeactivate(instance);
|
|
2970
|
+
}
|
|
2971
|
+
return true;
|
|
2972
|
+
}
|
|
2973
|
+
function getStats() {
|
|
2974
|
+
const total = hits + misses;
|
|
2975
|
+
return {
|
|
2976
|
+
hits,
|
|
2977
|
+
misses,
|
|
2978
|
+
size: cache.size,
|
|
2979
|
+
max,
|
|
2980
|
+
hitRate: total > 0 ? hits / total : 0,
|
|
2981
|
+
keys: Array.from(cache.keys())
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
function keys() {
|
|
2985
|
+
return Array.from(cache.keys());
|
|
2986
|
+
}
|
|
2987
|
+
function size() {
|
|
2988
|
+
return cache.size;
|
|
2989
|
+
}
|
|
2990
|
+
return {
|
|
2991
|
+
cache: cacheComponent,
|
|
2992
|
+
get,
|
|
2993
|
+
has,
|
|
2994
|
+
remove,
|
|
2995
|
+
clear,
|
|
2996
|
+
prune,
|
|
2997
|
+
activate,
|
|
2998
|
+
deactivate,
|
|
2999
|
+
getStats,
|
|
3000
|
+
keys,
|
|
3001
|
+
size
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
function createLRUCache(maxSize) {
|
|
3005
|
+
const cache = new Map;
|
|
3006
|
+
return {
|
|
3007
|
+
set(key, value) {
|
|
3008
|
+
if (cache.has(key)) {
|
|
3009
|
+
cache.delete(key);
|
|
3010
|
+
}
|
|
3011
|
+
cache.set(key, value);
|
|
3012
|
+
if (cache.size > maxSize) {
|
|
3013
|
+
const firstKey = cache.keys().next().value;
|
|
3014
|
+
if (firstKey) {
|
|
3015
|
+
cache.delete(firstKey);
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
},
|
|
3019
|
+
get(key) {
|
|
3020
|
+
if (!cache.has(key)) {
|
|
3021
|
+
return;
|
|
3022
|
+
}
|
|
3023
|
+
const value = cache.get(key);
|
|
3024
|
+
cache.delete(key);
|
|
3025
|
+
cache.set(key, value);
|
|
3026
|
+
return value;
|
|
3027
|
+
},
|
|
3028
|
+
has(key) {
|
|
3029
|
+
return cache.has(key);
|
|
3030
|
+
},
|
|
3031
|
+
delete(key) {
|
|
3032
|
+
return cache.delete(key);
|
|
3033
|
+
},
|
|
3034
|
+
clear() {
|
|
3035
|
+
cache.clear();
|
|
3036
|
+
},
|
|
3037
|
+
get size() {
|
|
3038
|
+
return cache.size;
|
|
3039
|
+
},
|
|
3040
|
+
keys() {
|
|
3041
|
+
return Array.from(cache.keys());
|
|
3042
|
+
},
|
|
3043
|
+
values() {
|
|
3044
|
+
return Array.from(cache.values());
|
|
3045
|
+
},
|
|
3046
|
+
forEach(callback) {
|
|
3047
|
+
cache.forEach(callback);
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
function createStateManager() {
|
|
3052
|
+
const states = new Map;
|
|
3053
|
+
return {
|
|
3054
|
+
save(key, state) {
|
|
3055
|
+
states.set(key, JSON.parse(JSON.stringify(state)));
|
|
3056
|
+
},
|
|
3057
|
+
restore(key) {
|
|
3058
|
+
const state = states.get(key);
|
|
3059
|
+
return state ? JSON.parse(JSON.stringify(state)) : null;
|
|
3060
|
+
},
|
|
3061
|
+
has(key) {
|
|
3062
|
+
return states.has(key);
|
|
3063
|
+
},
|
|
3064
|
+
remove(key) {
|
|
3065
|
+
return states.delete(key);
|
|
3066
|
+
},
|
|
3067
|
+
clear() {
|
|
3068
|
+
states.clear();
|
|
3069
|
+
},
|
|
3070
|
+
keys() {
|
|
3071
|
+
return Array.from(states.keys());
|
|
3072
|
+
},
|
|
3073
|
+
get size() {
|
|
3074
|
+
return states.size;
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
3078
|
+
function createComponentPool(factory, options = {}) {
|
|
3079
|
+
const { maxSize = 100, reset } = options;
|
|
3080
|
+
const pool = [];
|
|
3081
|
+
return {
|
|
3082
|
+
acquire() {
|
|
3083
|
+
if (pool.length > 0) {
|
|
3084
|
+
return pool.pop();
|
|
3085
|
+
}
|
|
3086
|
+
return factory();
|
|
3087
|
+
},
|
|
3088
|
+
release(instance) {
|
|
3089
|
+
if (pool.length < maxSize) {
|
|
3090
|
+
if (reset) {
|
|
3091
|
+
reset(instance);
|
|
3092
|
+
}
|
|
3093
|
+
pool.push(instance);
|
|
3094
|
+
}
|
|
3095
|
+
},
|
|
3096
|
+
clear() {
|
|
3097
|
+
pool.length = 0;
|
|
3098
|
+
},
|
|
3099
|
+
get size() {
|
|
3100
|
+
return pool.length;
|
|
3101
|
+
},
|
|
3102
|
+
get maxSize() {
|
|
3103
|
+
return maxSize;
|
|
3104
|
+
}
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
// src/utils/lazy-loading.ts
|
|
3108
|
+
var moduleCache = new Map;
|
|
3109
|
+
async function lazyLoadModule(importFn, cacheKey) {
|
|
3110
|
+
const key = cacheKey || importFn.toString();
|
|
3111
|
+
if (moduleCache.has(key)) {
|
|
3112
|
+
return moduleCache.get(key);
|
|
3113
|
+
}
|
|
3114
|
+
const promise = importFn();
|
|
3115
|
+
moduleCache.set(key, promise);
|
|
3116
|
+
try {
|
|
3117
|
+
return await promise;
|
|
3118
|
+
} catch (error) {
|
|
3119
|
+
moduleCache.delete(key);
|
|
3120
|
+
throw error;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
function lazyLoadComponent(importFn, options = {}) {
|
|
3124
|
+
const {
|
|
3125
|
+
retryAttempts = 3,
|
|
3126
|
+
retryDelay = 1000,
|
|
3127
|
+
onLoading,
|
|
3128
|
+
onLoaded,
|
|
3129
|
+
onError
|
|
3130
|
+
} = options;
|
|
3131
|
+
let state = "idle";
|
|
3132
|
+
let module;
|
|
3133
|
+
let error;
|
|
3134
|
+
const loadWithRetry = async (attempt = 0) => {
|
|
3135
|
+
try {
|
|
3136
|
+
if (state === "loading" || state === "loaded") {
|
|
3137
|
+
if (module) {
|
|
3138
|
+
return module;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
state = "loading";
|
|
3142
|
+
onLoading?.();
|
|
3143
|
+
const loaded = await lazyLoadModule(importFn);
|
|
3144
|
+
module = loaded;
|
|
3145
|
+
state = "loaded";
|
|
3146
|
+
onLoaded?.(loaded);
|
|
3147
|
+
return loaded;
|
|
3148
|
+
} catch (err) {
|
|
3149
|
+
const loadError = err;
|
|
3150
|
+
if (attempt < retryAttempts) {
|
|
3151
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
3152
|
+
return loadWithRetry(attempt + 1);
|
|
3153
|
+
}
|
|
3154
|
+
state = "error";
|
|
3155
|
+
error = loadError;
|
|
3156
|
+
onError?.(loadError);
|
|
3157
|
+
throw loadError;
|
|
3158
|
+
}
|
|
3159
|
+
};
|
|
3160
|
+
return {
|
|
3161
|
+
get state() {
|
|
3162
|
+
return state;
|
|
3163
|
+
},
|
|
3164
|
+
get module() {
|
|
3165
|
+
return module;
|
|
3166
|
+
},
|
|
3167
|
+
get error() {
|
|
3168
|
+
return error;
|
|
3169
|
+
},
|
|
3170
|
+
load: () => loadWithRetry(),
|
|
3171
|
+
preload: () => loadWithRetry()
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
function lazyLoad(element, importFn, options = {}) {
|
|
3175
|
+
if (!element) {
|
|
3176
|
+
console.warn("lazyLoad: element is null");
|
|
3177
|
+
return () => {};
|
|
3178
|
+
}
|
|
3179
|
+
const {
|
|
3180
|
+
root = null,
|
|
3181
|
+
rootMargin = "0px",
|
|
3182
|
+
threshold = 0.01,
|
|
3183
|
+
placeholder,
|
|
3184
|
+
errorContent,
|
|
3185
|
+
onLoading,
|
|
3186
|
+
onLoaded,
|
|
3187
|
+
onError
|
|
3188
|
+
} = options;
|
|
3189
|
+
let hasLoaded = false;
|
|
3190
|
+
let observer = null;
|
|
3191
|
+
if (placeholder) {
|
|
3192
|
+
if (typeof placeholder === "string") {
|
|
3193
|
+
element.innerHTML = placeholder;
|
|
3194
|
+
} else {
|
|
3195
|
+
element.innerHTML = "";
|
|
3196
|
+
element.appendChild(placeholder);
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
const handleIntersection = async (entries) => {
|
|
3200
|
+
for (const entry of entries) {
|
|
3201
|
+
if (entry.isIntersecting && !hasLoaded) {
|
|
3202
|
+
hasLoaded = true;
|
|
3203
|
+
observer?.disconnect();
|
|
3204
|
+
try {
|
|
3205
|
+
onLoading?.();
|
|
3206
|
+
const module = await lazyLoadModule(importFn);
|
|
3207
|
+
onLoaded?.(module);
|
|
3208
|
+
if (module && typeof module.default?.render === "function") {
|
|
3209
|
+
const content = await module.default.render();
|
|
3210
|
+
element.innerHTML = content;
|
|
3211
|
+
}
|
|
3212
|
+
} catch (error) {
|
|
3213
|
+
const loadError = error;
|
|
3214
|
+
onError?.(loadError);
|
|
3215
|
+
if (errorContent) {
|
|
3216
|
+
if (typeof errorContent === "string") {
|
|
3217
|
+
element.innerHTML = errorContent;
|
|
3218
|
+
} else {
|
|
3219
|
+
element.innerHTML = "";
|
|
3220
|
+
element.appendChild(errorContent);
|
|
3221
|
+
}
|
|
3222
|
+
} else {
|
|
3223
|
+
element.innerHTML = `<div style="color: red;">Failed to load component: ${loadError.message}</div>`;
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
observer = new IntersectionObserver(handleIntersection, {
|
|
3230
|
+
root,
|
|
3231
|
+
rootMargin,
|
|
3232
|
+
threshold
|
|
3233
|
+
});
|
|
3234
|
+
observer.observe(element);
|
|
3235
|
+
return () => {
|
|
3236
|
+
observer?.disconnect();
|
|
3237
|
+
observer = null;
|
|
3238
|
+
};
|
|
3239
|
+
}
|
|
3240
|
+
function lazyLoadAll(elements, importFn, options = {}) {
|
|
3241
|
+
const cleanupFunctions = [];
|
|
3242
|
+
const elementsArray = Array.from(elements);
|
|
3243
|
+
for (const element of elementsArray) {
|
|
3244
|
+
const importFunction = typeof importFn === "function" && importFn.length > 0 ? () => importFn(element) : importFn;
|
|
3245
|
+
const cleanup = lazyLoad(element, importFunction, options);
|
|
3246
|
+
cleanupFunctions.push(cleanup);
|
|
3247
|
+
}
|
|
3248
|
+
return () => {
|
|
3249
|
+
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
3250
|
+
};
|
|
3251
|
+
}
|
|
3252
|
+
function preloadModule(importFn) {
|
|
3253
|
+
return lazyLoadModule(importFn);
|
|
3254
|
+
}
|
|
3255
|
+
function preloadModules(importFns) {
|
|
3256
|
+
return Promise.all(importFns.map((fn) => preloadModule(fn)));
|
|
3257
|
+
}
|
|
3258
|
+
function clearModuleCache(cacheKey) {
|
|
3259
|
+
if (cacheKey) {
|
|
3260
|
+
moduleCache.delete(cacheKey);
|
|
3261
|
+
} else {
|
|
3262
|
+
moduleCache.clear();
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
function getCacheStats() {
|
|
3266
|
+
return {
|
|
3267
|
+
size: moduleCache.size,
|
|
3268
|
+
keys: Array.from(moduleCache.keys())
|
|
3269
|
+
};
|
|
3270
|
+
}
|
|
3271
|
+
function createRouteLoader(routes) {
|
|
3272
|
+
return {
|
|
3273
|
+
async load(path) {
|
|
3274
|
+
const importFn = routes[path];
|
|
3275
|
+
if (!importFn) {
|
|
3276
|
+
throw new Error(`No route found for path: ${path}`);
|
|
3277
|
+
}
|
|
3278
|
+
return lazyLoadModule(importFn, `route:${path}`);
|
|
3279
|
+
},
|
|
3280
|
+
async preload(path) {
|
|
3281
|
+
return this.load(path);
|
|
3282
|
+
},
|
|
3283
|
+
async preloadRoutes(paths) {
|
|
3284
|
+
return Promise.all(paths.map((path) => this.preload(path)));
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
}
|
|
3288
|
+
function lazyLoadImage(img, src, options = {}) {
|
|
3289
|
+
if (!img) {
|
|
3290
|
+
return () => {};
|
|
3291
|
+
}
|
|
3292
|
+
const {
|
|
3293
|
+
root = null,
|
|
3294
|
+
rootMargin = "50px",
|
|
3295
|
+
threshold = 0.01,
|
|
3296
|
+
placeholder,
|
|
3297
|
+
onLoading,
|
|
3298
|
+
onLoaded,
|
|
3299
|
+
onError
|
|
3300
|
+
} = options;
|
|
3301
|
+
if (placeholder && typeof placeholder === "string") {
|
|
3302
|
+
img.src = placeholder;
|
|
3303
|
+
}
|
|
3304
|
+
let hasLoaded = false;
|
|
3305
|
+
let observer = null;
|
|
3306
|
+
const handleIntersection = (entries) => {
|
|
3307
|
+
for (const entry of entries) {
|
|
3308
|
+
if (entry.isIntersecting && !hasLoaded) {
|
|
3309
|
+
hasLoaded = true;
|
|
3310
|
+
observer?.disconnect();
|
|
3311
|
+
onLoading?.();
|
|
3312
|
+
img.src = src;
|
|
3313
|
+
img.addEventListener("load", () => {
|
|
3314
|
+
onLoaded?.(img);
|
|
3315
|
+
img.classList.add("loaded");
|
|
3316
|
+
}, { once: true });
|
|
3317
|
+
img.addEventListener("error", (_event) => {
|
|
3318
|
+
const error = new Error(`Failed to load image: ${src}`);
|
|
3319
|
+
onError?.(error);
|
|
3320
|
+
img.classList.add("error");
|
|
3321
|
+
}, { once: true });
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
};
|
|
3325
|
+
observer = new IntersectionObserver(handleIntersection, {
|
|
3326
|
+
root,
|
|
3327
|
+
rootMargin,
|
|
3328
|
+
threshold
|
|
3329
|
+
});
|
|
3330
|
+
observer.observe(img);
|
|
3331
|
+
return () => {
|
|
3332
|
+
observer?.disconnect();
|
|
3333
|
+
observer = null;
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
function lazyLoadImages(container = document, options = {}) {
|
|
3337
|
+
const images = container.querySelectorAll("img[data-lazy-src]");
|
|
3338
|
+
const cleanupFunctions = [];
|
|
3339
|
+
images.forEach((img) => {
|
|
3340
|
+
const src = img.getAttribute("data-lazy-src");
|
|
3341
|
+
if (src) {
|
|
3342
|
+
const cleanup = lazyLoadImage(img, src, options);
|
|
3343
|
+
cleanupFunctions.push(cleanup);
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
return () => {
|
|
3347
|
+
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
// src/utils/theme.ts
|
|
3351
|
+
var defaultTheme = {
|
|
3352
|
+
colors: {
|
|
3353
|
+
primary: "#3b82f6",
|
|
3354
|
+
secondary: "#8b5cf6",
|
|
3355
|
+
success: "#10b981",
|
|
3356
|
+
warning: "#f59e0b",
|
|
3357
|
+
danger: "#ef4444",
|
|
3358
|
+
info: "#06b6d4",
|
|
3359
|
+
gray: "#6b7280",
|
|
3360
|
+
white: "#ffffff",
|
|
3361
|
+
black: "#000000"
|
|
3362
|
+
},
|
|
3363
|
+
typography: {
|
|
3364
|
+
fontFamily: {
|
|
3365
|
+
sans: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
3366
|
+
serif: 'Georgia, Cambria, "Times New Roman", Times, serif',
|
|
3367
|
+
mono: 'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
3368
|
+
},
|
|
3369
|
+
fontSize: {
|
|
3370
|
+
xs: "0.75rem",
|
|
3371
|
+
sm: "0.875rem",
|
|
3372
|
+
base: "1rem",
|
|
3373
|
+
lg: "1.125rem",
|
|
3374
|
+
xl: "1.25rem",
|
|
3375
|
+
"2xl": "1.5rem",
|
|
3376
|
+
"3xl": "1.875rem",
|
|
3377
|
+
"4xl": "2.25rem"
|
|
3378
|
+
},
|
|
3379
|
+
fontWeight: {
|
|
3380
|
+
light: "300",
|
|
3381
|
+
normal: "400",
|
|
3382
|
+
medium: "500",
|
|
3383
|
+
semibold: "600",
|
|
3384
|
+
bold: "700"
|
|
3385
|
+
},
|
|
3386
|
+
lineHeight: {
|
|
3387
|
+
tight: "1.25",
|
|
3388
|
+
normal: "1.5",
|
|
3389
|
+
relaxed: "1.75"
|
|
3390
|
+
}
|
|
3391
|
+
},
|
|
3392
|
+
spacing: {
|
|
3393
|
+
xs: "0.25rem",
|
|
3394
|
+
sm: "0.5rem",
|
|
3395
|
+
md: "1rem",
|
|
3396
|
+
lg: "1.5rem",
|
|
3397
|
+
xl: "2rem",
|
|
3398
|
+
"2xl": "3rem",
|
|
3399
|
+
"3xl": "4rem",
|
|
3400
|
+
"4xl": "6rem"
|
|
3401
|
+
},
|
|
3402
|
+
borderRadius: {
|
|
3403
|
+
none: "0",
|
|
3404
|
+
sm: "0.125rem",
|
|
3405
|
+
md: "0.375rem",
|
|
3406
|
+
lg: "0.5rem",
|
|
3407
|
+
full: "9999px"
|
|
3408
|
+
},
|
|
3409
|
+
shadows: {
|
|
3410
|
+
sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
3411
|
+
md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
3412
|
+
lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
3413
|
+
xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
3414
|
+
"2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
3415
|
+
none: "none"
|
|
3416
|
+
},
|
|
3417
|
+
components: {
|
|
3418
|
+
button: {
|
|
3419
|
+
borderRadius: "0.375rem",
|
|
3420
|
+
padding: "0.5rem 1rem",
|
|
3421
|
+
fontSize: "0.875rem",
|
|
3422
|
+
fontWeight: "500"
|
|
3423
|
+
},
|
|
3424
|
+
input: {
|
|
3425
|
+
borderRadius: "0.375rem",
|
|
3426
|
+
padding: "0.5rem 0.75rem",
|
|
3427
|
+
fontSize: "0.875rem",
|
|
3428
|
+
borderWidth: "1px"
|
|
3429
|
+
},
|
|
3430
|
+
card: {
|
|
3431
|
+
borderRadius: "0.5rem",
|
|
3432
|
+
padding: "1.5rem",
|
|
3433
|
+
shadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)"
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
};
|
|
3437
|
+
function deepMerge(target, source) {
|
|
3438
|
+
const output = { ...target };
|
|
3439
|
+
for (const key in source) {
|
|
3440
|
+
if (source[key] instanceof Object && key in target) {
|
|
3441
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
3442
|
+
} else {
|
|
3443
|
+
output[key] = source[key];
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
return output;
|
|
3447
|
+
}
|
|
3448
|
+
function createTheme(customTheme) {
|
|
3449
|
+
return deepMerge(defaultTheme, customTheme);
|
|
3450
|
+
}
|
|
3451
|
+
var currentTheme = defaultTheme;
|
|
3452
|
+
function getTheme() {
|
|
3453
|
+
return currentTheme;
|
|
3454
|
+
}
|
|
3455
|
+
function themeToCSSProperties(theme) {
|
|
3456
|
+
const cssVars = [];
|
|
3457
|
+
if (theme.colors) {
|
|
3458
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
|
3459
|
+
if (value)
|
|
3460
|
+
cssVars.push(`--color-${key}: ${value};`);
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
if (theme.typography?.fontFamily) {
|
|
3464
|
+
Object.entries(theme.typography.fontFamily).forEach(([key, value]) => {
|
|
3465
|
+
if (value)
|
|
3466
|
+
cssVars.push(`--font-${key}: ${value};`);
|
|
3467
|
+
});
|
|
3468
|
+
}
|
|
3469
|
+
if (theme.typography?.fontSize) {
|
|
3470
|
+
Object.entries(theme.typography.fontSize).forEach(([key, value]) => {
|
|
3471
|
+
if (value)
|
|
3472
|
+
cssVars.push(`--text-${key}: ${value};`);
|
|
3473
|
+
});
|
|
3474
|
+
}
|
|
3475
|
+
if (theme.typography?.fontWeight) {
|
|
3476
|
+
Object.entries(theme.typography.fontWeight).forEach(([key, value]) => {
|
|
3477
|
+
if (value)
|
|
3478
|
+
cssVars.push(`--font-weight-${key}: ${value};`);
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
if (theme.typography?.lineHeight) {
|
|
3482
|
+
Object.entries(theme.typography.lineHeight).forEach(([key, value]) => {
|
|
3483
|
+
if (value)
|
|
3484
|
+
cssVars.push(`--leading-${key}: ${value};`);
|
|
3485
|
+
});
|
|
3486
|
+
}
|
|
3487
|
+
if (theme.spacing) {
|
|
3488
|
+
Object.entries(theme.spacing).forEach(([key, value]) => {
|
|
3489
|
+
if (value)
|
|
3490
|
+
cssVars.push(`--spacing-${key}: ${value};`);
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
if (theme.borderRadius) {
|
|
3494
|
+
Object.entries(theme.borderRadius).forEach(([key, value]) => {
|
|
3495
|
+
if (value)
|
|
3496
|
+
cssVars.push(`--radius-${key}: ${value};`);
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
if (theme.shadows) {
|
|
3500
|
+
Object.entries(theme.shadows).forEach(([key, value]) => {
|
|
3501
|
+
if (value)
|
|
3502
|
+
cssVars.push(`--shadow-${key}: ${value};`);
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
if (theme.components?.button) {
|
|
3506
|
+
Object.entries(theme.components.button).forEach(([key, value]) => {
|
|
3507
|
+
if (value)
|
|
3508
|
+
cssVars.push(`--button-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`);
|
|
3509
|
+
});
|
|
3510
|
+
}
|
|
3511
|
+
if (theme.components?.input) {
|
|
3512
|
+
Object.entries(theme.components.input).forEach(([key, value]) => {
|
|
3513
|
+
if (value)
|
|
3514
|
+
cssVars.push(`--input-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`);
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
if (theme.components?.card) {
|
|
3518
|
+
Object.entries(theme.components.card).forEach(([key, value]) => {
|
|
3519
|
+
if (value)
|
|
3520
|
+
cssVars.push(`--card-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`);
|
|
3521
|
+
});
|
|
3522
|
+
}
|
|
3523
|
+
return `:root {
|
|
3524
|
+
${cssVars.join(`
|
|
18
3525
|
`)}
|
|
19
|
-
}
|
|
3526
|
+
}`;
|
|
3527
|
+
}
|
|
3528
|
+
function applyTheme(theme, target) {
|
|
3529
|
+
currentTheme = theme;
|
|
3530
|
+
if (typeof document === "undefined")
|
|
3531
|
+
return;
|
|
3532
|
+
const element = target || document.documentElement;
|
|
3533
|
+
if (theme.colors) {
|
|
3534
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
|
3535
|
+
if (value)
|
|
3536
|
+
element.style.setProperty(`--color-${key}`, value);
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
if (theme.typography?.fontFamily) {
|
|
3540
|
+
Object.entries(theme.typography.fontFamily).forEach(([key, value]) => {
|
|
3541
|
+
if (value)
|
|
3542
|
+
element.style.setProperty(`--font-${key}`, value);
|
|
3543
|
+
});
|
|
3544
|
+
}
|
|
3545
|
+
if (theme.typography?.fontSize) {
|
|
3546
|
+
Object.entries(theme.typography.fontSize).forEach(([key, value]) => {
|
|
3547
|
+
if (value)
|
|
3548
|
+
element.style.setProperty(`--text-${key}`, value);
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
if (theme.typography?.fontWeight) {
|
|
3552
|
+
Object.entries(theme.typography.fontWeight).forEach(([key, value]) => {
|
|
3553
|
+
if (value)
|
|
3554
|
+
element.style.setProperty(`--font-weight-${key}`, value);
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
if (theme.typography?.lineHeight) {
|
|
3558
|
+
Object.entries(theme.typography.lineHeight).forEach(([key, value]) => {
|
|
3559
|
+
if (value)
|
|
3560
|
+
element.style.setProperty(`--leading-${key}`, value);
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
3563
|
+
if (theme.spacing) {
|
|
3564
|
+
Object.entries(theme.spacing).forEach(([key, value]) => {
|
|
3565
|
+
if (value)
|
|
3566
|
+
element.style.setProperty(`--spacing-${key}`, value);
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
if (theme.borderRadius) {
|
|
3570
|
+
Object.entries(theme.borderRadius).forEach(([key, value]) => {
|
|
3571
|
+
if (value)
|
|
3572
|
+
element.style.setProperty(`--radius-${key}`, value);
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
if (theme.shadows) {
|
|
3576
|
+
Object.entries(theme.shadows).forEach(([key, value]) => {
|
|
3577
|
+
if (value)
|
|
3578
|
+
element.style.setProperty(`--shadow-${key}`, value);
|
|
3579
|
+
});
|
|
3580
|
+
}
|
|
3581
|
+
if (theme.components?.button) {
|
|
3582
|
+
Object.entries(theme.components.button).forEach(([key, value]) => {
|
|
3583
|
+
if (value)
|
|
3584
|
+
element.style.setProperty(`--button-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`, value);
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
if (theme.components?.input) {
|
|
3588
|
+
Object.entries(theme.components.input).forEach(([key, value]) => {
|
|
3589
|
+
if (value)
|
|
3590
|
+
element.style.setProperty(`--input-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`, value);
|
|
3591
|
+
});
|
|
3592
|
+
}
|
|
3593
|
+
if (theme.components?.card) {
|
|
3594
|
+
Object.entries(theme.components.card).forEach(([key, value]) => {
|
|
3595
|
+
if (value)
|
|
3596
|
+
element.style.setProperty(`--card-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`, value);
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
function useTheme() {
|
|
3601
|
+
return currentTheme;
|
|
3602
|
+
}
|
|
3603
|
+
function getThemeValue(path) {
|
|
3604
|
+
const keys = path.split(".");
|
|
3605
|
+
let value = currentTheme;
|
|
3606
|
+
for (const key of keys) {
|
|
3607
|
+
if (value && typeof value === "object" && key in value) {
|
|
3608
|
+
value = value[key];
|
|
3609
|
+
} else {
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
return value;
|
|
3614
|
+
}
|
|
3615
|
+
var themePresets = {
|
|
3616
|
+
default: defaultTheme,
|
|
3617
|
+
purple: createTheme({
|
|
3618
|
+
colors: {
|
|
3619
|
+
primary: "#8b5cf6",
|
|
3620
|
+
secondary: "#a78bfa"
|
|
3621
|
+
}
|
|
3622
|
+
}),
|
|
3623
|
+
green: createTheme({
|
|
3624
|
+
colors: {
|
|
3625
|
+
primary: "#10b981",
|
|
3626
|
+
secondary: "#34d399"
|
|
3627
|
+
}
|
|
3628
|
+
}),
|
|
3629
|
+
orange: createTheme({
|
|
3630
|
+
colors: {
|
|
3631
|
+
primary: "#f97316",
|
|
3632
|
+
secondary: "#fb923c"
|
|
3633
|
+
}
|
|
3634
|
+
}),
|
|
3635
|
+
dark: createTheme({
|
|
3636
|
+
colors: {
|
|
3637
|
+
primary: "#60a5fa",
|
|
3638
|
+
secondary: "#a78bfa",
|
|
3639
|
+
gray: "#9ca3af",
|
|
3640
|
+
white: "#1f2937",
|
|
3641
|
+
black: "#f9fafb"
|
|
3642
|
+
}
|
|
3643
|
+
}),
|
|
3644
|
+
minimal: createTheme({
|
|
3645
|
+
borderRadius: {
|
|
3646
|
+
none: "0",
|
|
3647
|
+
sm: "0",
|
|
3648
|
+
md: "0.125rem",
|
|
3649
|
+
lg: "0.25rem",
|
|
3650
|
+
full: "0.25rem"
|
|
3651
|
+
},
|
|
3652
|
+
shadows: {
|
|
3653
|
+
sm: "none",
|
|
3654
|
+
md: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
3655
|
+
lg: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
|
|
3656
|
+
xl: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
|
|
3657
|
+
"2xl": "0 10px 15px -3px rgba(0, 0, 0, 0.1)",
|
|
3658
|
+
none: "none"
|
|
3659
|
+
}
|
|
3660
|
+
})
|
|
3661
|
+
};
|
|
3662
|
+
function generateThemeCSS(theme) {
|
|
3663
|
+
return themeToCSSProperties(theme);
|
|
3664
|
+
}
|
|
3665
|
+
export {
|
|
3666
|
+
wrapErrorHandler,
|
|
3667
|
+
warnProp,
|
|
3668
|
+
warn,
|
|
3669
|
+
waitForAnimation,
|
|
3670
|
+
validateVariant,
|
|
3671
|
+
validateTextInputProps,
|
|
3672
|
+
validateSize,
|
|
3673
|
+
validateSearchInputProps,
|
|
3674
|
+
validateProps,
|
|
3675
|
+
validatePasswordInputProps,
|
|
3676
|
+
validateNumberInputProps,
|
|
3677
|
+
validateFormProps,
|
|
3678
|
+
validateEmailInputProps,
|
|
3679
|
+
validateButtonProps,
|
|
3680
|
+
validateAriaRelationships,
|
|
3681
|
+
useTheme,
|
|
3682
|
+
useSEO,
|
|
3683
|
+
usePrefersReducedMotion,
|
|
3684
|
+
useMediaQuery,
|
|
3685
|
+
useLocalStorage,
|
|
3686
|
+
useKeyboard,
|
|
3687
|
+
useIsMobile,
|
|
3688
|
+
useIsDesktop,
|
|
3689
|
+
useIsDarkMode,
|
|
3690
|
+
useFocusTrap,
|
|
3691
|
+
useDarkMode,
|
|
3692
|
+
useCopyCode,
|
|
3693
|
+
useClickOutside,
|
|
3694
|
+
useBreakpoint,
|
|
3695
|
+
themeToCSSProperties,
|
|
3696
|
+
themePresets,
|
|
3697
|
+
textInputPropSchema,
|
|
3698
|
+
tc,
|
|
3699
|
+
t,
|
|
3700
|
+
storage,
|
|
3701
|
+
staggerAnimation,
|
|
3702
|
+
setTitle,
|
|
3703
|
+
setMeta,
|
|
3704
|
+
setLink,
|
|
3705
|
+
setI18n,
|
|
3706
|
+
setErrorHandler,
|
|
3707
|
+
sequenceAnimations,
|
|
3708
|
+
removeAnimation,
|
|
3709
|
+
preloadModules,
|
|
3710
|
+
preloadModule,
|
|
3711
|
+
prefersReducedMotion,
|
|
3712
|
+
prefersHighContrast,
|
|
3713
|
+
pluralRules,
|
|
3714
|
+
numberInputPropSchema,
|
|
3715
|
+
numberFormats,
|
|
3716
|
+
n,
|
|
3717
|
+
moveFocus,
|
|
3718
|
+
loadLocaleMessages,
|
|
3719
|
+
linear,
|
|
3720
|
+
lazyLoadModule,
|
|
3721
|
+
lazyLoadImages,
|
|
3722
|
+
lazyLoadImage,
|
|
3723
|
+
lazyLoadComponent,
|
|
3724
|
+
lazyLoadAll,
|
|
3725
|
+
lazyLoad,
|
|
3726
|
+
isVisibleToScreenReader,
|
|
3727
|
+
isRTL,
|
|
3728
|
+
highlight,
|
|
3729
|
+
hasFocus,
|
|
3730
|
+
handleError,
|
|
3731
|
+
getThemeValue,
|
|
3732
|
+
getTheme,
|
|
3733
|
+
getSystemTheme,
|
|
3734
|
+
getI18n,
|
|
3735
|
+
getHighlighter,
|
|
3736
|
+
getFocusableElements,
|
|
3737
|
+
getEffectiveTheme,
|
|
3738
|
+
getColorSchemePreference,
|
|
3739
|
+
getCacheStats,
|
|
3740
|
+
generateThemeCSS,
|
|
3741
|
+
generateSEOTags,
|
|
3742
|
+
generateId,
|
|
3743
|
+
formPropSchema,
|
|
3744
|
+
errorBoundary,
|
|
3745
|
+
easeOutSine,
|
|
3746
|
+
easeOutQuint,
|
|
3747
|
+
easeOutQuart,
|
|
3748
|
+
easeOutQuad,
|
|
3749
|
+
easeOutExpo,
|
|
3750
|
+
easeOutElastic,
|
|
3751
|
+
easeOutCubic,
|
|
3752
|
+
easeOutCirc,
|
|
3753
|
+
easeOutBounce,
|
|
3754
|
+
easeOutBack,
|
|
3755
|
+
easeInSine,
|
|
3756
|
+
easeInQuint,
|
|
3757
|
+
easeInQuart,
|
|
3758
|
+
easeInQuad,
|
|
3759
|
+
easeInOutSine,
|
|
3760
|
+
easeInOutQuint,
|
|
3761
|
+
easeInOutQuart,
|
|
3762
|
+
easeInOutQuad,
|
|
3763
|
+
easeInOutExpo,
|
|
3764
|
+
easeInOutElastic,
|
|
3765
|
+
easeInOutCubic,
|
|
3766
|
+
easeInOutCirc,
|
|
3767
|
+
easeInOutBounce,
|
|
3768
|
+
easeInOutBack,
|
|
3769
|
+
easeInExpo,
|
|
3770
|
+
easeInElastic,
|
|
3771
|
+
easeInCubic,
|
|
3772
|
+
easeInCirc,
|
|
3773
|
+
easeInBounce,
|
|
3774
|
+
easeInBack,
|
|
3775
|
+
devAssert,
|
|
3776
|
+
detectLanguage,
|
|
3777
|
+
defaultTheme,
|
|
3778
|
+
dateTimeFormats,
|
|
3779
|
+
d,
|
|
3780
|
+
cssAnimation,
|
|
3781
|
+
createTheme,
|
|
3782
|
+
createStorage,
|
|
3783
|
+
createStateManager,
|
|
3784
|
+
createSkipLink,
|
|
3785
|
+
createScreenReaderText,
|
|
3786
|
+
createSafeClickHandler,
|
|
3787
|
+
createRovingTabindex,
|
|
3788
|
+
createRouteLoader,
|
|
3789
|
+
createPropValidator,
|
|
3790
|
+
createLRUCache,
|
|
3791
|
+
createKeyframes,
|
|
3792
|
+
createKeyframeAnimation,
|
|
3793
|
+
createKeepAlive,
|
|
3794
|
+
createI18n,
|
|
3795
|
+
createFocusTrap,
|
|
3796
|
+
createDebugger,
|
|
3797
|
+
createComponentPool,
|
|
3798
|
+
createAriaLabel,
|
|
3799
|
+
createAriaDescription,
|
|
3800
|
+
copyToClipboard,
|
|
3801
|
+
componentMessages,
|
|
3802
|
+
clearModuleCache,
|
|
3803
|
+
clearErrorHandler,
|
|
3804
|
+
buttonPropSchema,
|
|
3805
|
+
assertProp,
|
|
3806
|
+
assert,
|
|
3807
|
+
aria,
|
|
3808
|
+
applyTheme,
|
|
3809
|
+
applyHeadwindClasses,
|
|
3810
|
+
applyAnimation,
|
|
3811
|
+
announceToScreenReader,
|
|
3812
|
+
animateWithClass,
|
|
3813
|
+
animate,
|
|
3814
|
+
VirtualTable_default as VirtualTable,
|
|
3815
|
+
VirtualList_default as VirtualList,
|
|
3816
|
+
Video_default as Video,
|
|
3817
|
+
TwoFactorChallenge_default as TwoFactorChallenge,
|
|
3818
|
+
Transition_default as Transition,
|
|
3819
|
+
Tooltip_default as Tooltip,
|
|
3820
|
+
Textarea_default as Textarea,
|
|
3821
|
+
TextInput_default as TextInput,
|
|
3822
|
+
Teleport_default as Teleport,
|
|
3823
|
+
Tabs_default as Tabs,
|
|
3824
|
+
TableRow_default as TableRow,
|
|
3825
|
+
TableHeader_default as TableHeader,
|
|
3826
|
+
TableHead_default as TableHead,
|
|
3827
|
+
TableCell_default as TableCell,
|
|
3828
|
+
TableBody_default as TableBody,
|
|
3829
|
+
Table_default as Table,
|
|
3830
|
+
TabPanel_default as TabPanel,
|
|
3831
|
+
Switch_default as Switch,
|
|
3832
|
+
SubscriptionCheckout_default as SubscriptionCheckout,
|
|
3833
|
+
StorageManager,
|
|
3834
|
+
StepperStep_default as StepperStep,
|
|
3835
|
+
Stepper_default as Stepper,
|
|
3836
|
+
Spinner_default as Spinner,
|
|
3837
|
+
Skeleton_default as Skeleton,
|
|
3838
|
+
Signup_default as Signup,
|
|
3839
|
+
SidebarSection_default as SidebarSection,
|
|
3840
|
+
SidebarItem_default as SidebarItem,
|
|
3841
|
+
SidebarHeader_default as SidebarHeader,
|
|
3842
|
+
SidebarFooter_default as SidebarFooter,
|
|
3843
|
+
Sidebar_default as Sidebar,
|
|
3844
|
+
Select_default as Select,
|
|
3845
|
+
SearchInput_default as SearchInput,
|
|
3846
|
+
RadioGroupOption_default as RadioGroupOption,
|
|
3847
|
+
RadioGroupLabel_default as RadioGroupLabel,
|
|
3848
|
+
RadioGroupDescription_default as RadioGroupDescription,
|
|
3849
|
+
RadioGroup_default as RadioGroup,
|
|
3850
|
+
Radio_default as Radio,
|
|
3851
|
+
PropTypes,
|
|
3852
|
+
Progress_default as Progress,
|
|
3853
|
+
Portal_default as Portal,
|
|
3854
|
+
PopoverPanel_default as PopoverPanel,
|
|
3855
|
+
PopoverButton_default as PopoverButton,
|
|
3856
|
+
Popover_default as Popover,
|
|
3857
|
+
PaymentMethods_default as PaymentMethods,
|
|
3858
|
+
PasswordInput_default as PasswordInput,
|
|
3859
|
+
Pagination_default as Pagination,
|
|
3860
|
+
NumberInput_default as NumberInput,
|
|
3861
|
+
Notification_default as Notification,
|
|
3862
|
+
Navigator_default as Navigator,
|
|
3863
|
+
Login_default as Login,
|
|
3864
|
+
ListboxOptions_default as ListboxOptions,
|
|
3865
|
+
ListboxOption_default as ListboxOption,
|
|
3866
|
+
ListboxLabel_default as ListboxLabel,
|
|
3867
|
+
ListboxButton_default as ListboxButton,
|
|
3868
|
+
Listbox_default as Listbox,
|
|
3869
|
+
KeyframeAnimations,
|
|
3870
|
+
KeyboardShortcuts,
|
|
3871
|
+
KeyboardKeys,
|
|
3872
|
+
stub_3_default as Installation,
|
|
3873
|
+
Image_default as Image,
|
|
3874
|
+
stub_2_default as Hero,
|
|
3875
|
+
Form_default as Form,
|
|
3876
|
+
stub_1_default as Footer,
|
|
3877
|
+
ErrorTypes,
|
|
3878
|
+
EmailInput_default as EmailInput,
|
|
3879
|
+
Easing,
|
|
3880
|
+
DropdownItems_default as DropdownItems,
|
|
3881
|
+
DropdownItem_default as DropdownItem,
|
|
3882
|
+
DropdownButton_default as DropdownButton,
|
|
3883
|
+
Dropdown_default as Dropdown,
|
|
3884
|
+
Drawer_default as Drawer,
|
|
3885
|
+
DialogTitle_default as DialogTitle,
|
|
3886
|
+
DialogPanel_default as DialogPanel,
|
|
3887
|
+
DialogDescription_default as DialogDescription,
|
|
3888
|
+
DialogBackdrop_default as DialogBackdrop,
|
|
3889
|
+
Dialog_default as Dialog,
|
|
3890
|
+
DefaultPaymentMethod_default as DefaultPaymentMethod,
|
|
3891
|
+
ComponentError,
|
|
3892
|
+
CommandPaletteItem_default as CommandPaletteItem,
|
|
3893
|
+
CommandPalette_default as CommandPalette,
|
|
3894
|
+
ComboboxOptions_default as ComboboxOptions,
|
|
3895
|
+
ComboboxOption_default as ComboboxOption,
|
|
3896
|
+
ComboboxInput_default as ComboboxInput,
|
|
3897
|
+
ComboboxButton_default as ComboboxButton,
|
|
3898
|
+
Combobox_default as Combobox,
|
|
3899
|
+
stub_0_default as CodeBlock,
|
|
3900
|
+
Checkout_default as Checkout,
|
|
3901
|
+
Checkbox_default as Checkbox,
|
|
3902
|
+
Card_default as Card,
|
|
3903
|
+
Calendar_default as Calendar,
|
|
3904
|
+
Button_default as Button,
|
|
3905
|
+
Breakpoints,
|
|
3906
|
+
Breadcrumb_default as Breadcrumb,
|
|
3907
|
+
Badge_default as Badge,
|
|
3908
|
+
Avatar_default as Avatar,
|
|
3909
|
+
Audio_default as Audio,
|
|
3910
|
+
AnimationClasses,
|
|
3911
|
+
AccordionItem_default as AccordionItem,
|
|
3912
|
+
Accordion_default as Accordion
|
|
3913
|
+
};
|