Skip to content

The only tool you need to know what is happening and how to fix it.

7.4 KB
Raw Blame
import"./DsnmJJEf.js";import{j as X,k as it,g as e,l as C,u as l,b as ot,ar as F,p as P,c as _,f as y,d,a as S,s as k,e as G,h as B,x as E,r as N}from"./BKFspo1J.js";import{c as O}from"./CWm9VMfX.js";import{p as o,r as A,s as U}from"./CARHnQ8P.js";import{i as z}from"./COK9M2N0.js";import{d as K}from"./DwMHXN8q.js";import{a as V,d as at,e as Y,j as Z,h as nt,c as L,b as h,m as W}from"./BoImjCaE.js";import{C as lt,R as ct,w as $,S as dt,E as ut,n as ht}from"./R7BU62x2.js";import{c as tt}from"./BXr1Q65P.js";import{S as Q}from"./8zLz30Kn.js";const R=at({component:"tabs",parts:["root","list","trigger","content"]}),j=new lt("Tabs.Root");class q{static create(t){return j.set(new q(t))}opts;attachment;rovingFocusGroup;#t=X(it([]));get triggerIds(){return e(this.#t)}set triggerIds(t){C(this.#t,t,!0)}valueToTriggerId=new Q;valueToContentId=new Q;constructor(t){this.opts=t,this.attachment=V(t.ref),this.rovingFocusGroup=new ct({candidateAttr:R.trigger,rootNode:this.opts.ref,loop:this.opts.loop,orientation:this.opts.orientation})}registerTrigger(t,r){return this.triggerIds.push(t),this.valueToTriggerId.set(r,t),()=>{this.triggerIds=this.triggerIds.filter(i=>i!==t),this.valueToTriggerId.delete(r)}}registerContent(t,r){return this.valueToContentId.set(r,t),()=>{this.valueToContentId.delete(r)}}setValue(t){this.opts.value.current=t}#e=l(()=>({id:this.opts.id.current,"data-orientation":this.opts.orientation.current,[R.root]:"",...this.attachment}));get props(){return e(this.#e)}set props(t){C(this.#e,t)}}class H{static create(t){return new H(t,j.get())}opts;root;attachment;#t=l(()=>this.root.opts.disabled.current);constructor(t,r){this.opts=t,this.root=r,this.attachment=V(t.ref)}#e=l(()=>({id:this.opts.id.current,role:"tablist","aria-orientation":this.root.opts.orientation.current,"data-orientation":this.root.opts.orientation.current,[R.list]:"","data-disabled":Y(e(this.#t)),...this.attachment}));get props(){return e(this.#e)}set props(t){C(this.#e,t)}}class J{static create(t){return new J(t,j.get())}opts;root;attachment;#t=X(0);#e=l(()=>this.root.opts.value.current===this.opts.value.current);#r=l(()=>this.opts.disabled.current||this.root.opts.disabled.current);#o=l(()=>this.root.valueToContentId.get(this.opts.value.current));constructor(t,r){this.opts=t,this.root=r,this.attachment=V(t.ref),$([()=>this.opts.id.current,()=>this.opts.value.current],([i,s])=>this.root.registerTrigger(i,s)),ot(()=>{this.root.triggerIds.length,e(this.#e)||!this.root.opts.value.current?C(this.#t,0):C(this.#t,-1)}),this.onfocus=this.onfocus.bind(this),this.onclick=this.onclick.bind(this),this.onkeydown=this.onkeydown.bind(this)}#s(){this.root.opts.value.current!==this.opts.value.current&&this.root.setValue(this.opts.value.current)}onfocus(t){this.root.opts.activationMode.current!=="automatic"||e(this.#r)||this.#s()}onclick(t){e(this.#r)||this.#s()}onkeydown(t){if(!e(this.#r)){if(t.key===dt||t.key===ut){t.preventDefault(),this.#s();return}this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current,t)}}#i=l(()=>({id:this.opts.id.current,role:"tab","data-state":rt(e(this.#e)),"data-value":this.opts.value.current,"data-orientation":this.root.opts.orientation.current,"data-disabled":Y(e(this.#r)),"aria-selected":nt(e(this.#e)),"aria-controls":e(this.#o),[R.trigger]:"",disabled:Z(e(this.#r)),tabindex:e(this.#t),onclick:this.onclick,onfocus:this.onfocus,onkeydown:this.onkeydown,...this.attachment}));get props(){return e(this.#i)}set props(t){C(this.#i,t)}}class et{static create(t){return new et(t,j.get())}opts;root;attachment;#t=l(()=>this.root.opts.value.current===this.opts.value.current);#e=l(()=>this.root.valueToTriggerId.get(this.opts.value.current));constructor(t,r){this.opts=t,this.root=r,this.attachment=V(t.ref),$([()=>this.opts.id.current,()=>this.opts.value.current],([i,s])=>this.root.registerContent(i,s))}#r=l(()=>({id:this.opts.id.current,role:"tabpanel",hidden:Z(!e(this.#t)),tabindex:0,"data-value":this.opts.value.current,"data-state":rt(e(this.#t)),"aria-labelledby":e(this.#e),"data-orientation":this.root.opts.orientation.current,[R.content]:"",...this.attachment}));get props(){return e(this.#r)}set props(t){C(this.#r,t)}}function rt(u){return u?"active":"inactive"}var vt=G("<div><!></div>");function ft(u,t){const r=F();P(t,!0);let i=o(t,"id",19,()=>L(r)),s=o(t,"ref",15,null),v=o(t,"value",15,""),f=o(t,"onValueChange",3,ht),g=o(t,"orientation",3,"horizontal"),p=o(t,"loop",3,!0),c=o(t,"activationMode",3,"automatic"),I=o(t,"disabled",3,!1),b=A(t,["$$slots","$$events","$$legacy","id","ref","value","onValueChange","orientation","loop","activationMode","disabled","children","child"]);const a=q.create({id:h(()=>i()),value:h(()=>v(),T=>{v(T),f()(T)}),orientation:h(()=>g()),loop:h(()=>p()),activationMode:h(()=>c()),disabled:h(()=>I()),ref:h(()=>s(),T=>s(T))}),m=l(()=>W(b,a.props));var n=_(),w=y(n);{var M=T=>{var x=_(),D=y(x);k(D,()=>t.child,()=>({props:e(m)})),d(T,x)},st=T=>{var x=vt();K(x,()=>({...e(m)}));var D=B(x);k(D,()=>t.children??E),N(x),d(T,x)};z(w,T=>{t.child?T(M):T(st,!1)})}d(u,n),S()}var gt=G("<div><!></div>");function pt(u,t){const r=F();P(t,!0);let i=o(t,"id",19,()=>L(r)),s=o(t,"ref",15,null),v=A(t,["$$slots","$$events","$$legacy","child","children","id","ref"]);const f=H.create({id:h(()=>i()),ref:h(()=>s(),a=>s(a))}),g=l(()=>W(v,f.props));var p=_(),c=y(p);{var I=a=>{var m=_(),n=y(m);k(n,()=>t.child,()=>({props:e(g)})),d(a,m)},b=a=>{var m=gt();K(m,()=>({...e(g)}));var n=B(m);k(n,()=>t.children??E),N(m),d(a,m)};z(c,a=>{t.child?a(I):a(b,!1)})}d(u,p),S()}var mt=G("<button><!></button>");function bt(u,t){const r=F();P(t,!0);let i=o(t,"disabled",3,!1),s=o(t,"id",19,()=>L(r)),v=o(t,"type",3,"button"),f=o(t,"ref",15,null),g=A(t,["$$slots","$$events","$$legacy","child","children","disabled","id","type","value","ref"]);const p=J.create({id:h(()=>s()),disabled:h(()=>i()??!1),value:h(()=>t.value),ref:h(()=>f(),n=>f(n))}),c=l(()=>W(g,p.props,{type:v()}));var I=_(),b=y(I);{var a=n=>{var w=_(),M=y(w);k(M,()=>t.child,()=>({props:e(c)})),d(n,w)},m=n=>{var w=mt();K(w,()=>({...e(c)}));var M=B(w);k(M,()=>t.children??E),N(w),d(n,w)};z(b,n=>{t.child?n(a):n(m,!1)})}d(u,I),S()}function At(u,t){P(t,!0);let r=o(t,"value",15),i=A(t,["$$slots","$$events","$$legacy","value"]);var s=_(),v=y(s);O(v,()=>ft,(f,g)=>{g(f,U(()=>i,{get value(){return r()},set value(p){r(p)}}))}),d(u,s),S()}function Mt(u,t){P(t,!0);let r=o(t,"ref",15,null),i=A(t,["$$slots","$$events","$$legacy","ref","class","children"]);var s=_(),v=y(s);{let f=l(()=>tt("inline-flex h-9 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t.class));O(v,()=>pt,(g,p)=>{p(g,U({get class(){return e(f)}},()=>i,{get ref(){return r()},set ref(c){r(c)},children:(c,I)=>{var b=_(),a=y(b);k(a,()=>t.children??E),d(c,b)},$$slots:{default:!0}}))})}d(u,s),S()}function Rt(u,t){P(t,!0);let r=o(t,"ref",15,null),i=A(t,["$$slots","$$events","$$legacy","ref","class","children"]);var s=_(),v=y(s);{let f=l(()=>tt("inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap ring-offset-background transition-all focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t.class));O(v,()=>bt,(g,p)=>{p(g,U({get class(){return e(f)}},()=>i,{get ref(){return r()},set ref(c){r(c)},children:(c,I)=>{var b=_(),a=y(b);k(a,()=>t.children??E),d(c,b)},$$slots:{default:!0}}))})}d(u,s),S()}export{At as T,Mt as a,Rt as b,et as c};