UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

2 lines (1 loc) 4.16 kB
"use strict";const s=require("react/jsx-runtime"),T=require("react"),C=require("./index-DwV9MiDB.js"),x=require("./index-DMAkK3b-.js"),A=require("./index-DO-atGp-.js"),p=require("./index-brQs6tgK.js"),E=require("./index-B4SDXrpf.js");require("react-dom");const M=require("./index-CajSSBH7.js"),D=require("./index-Cje7xxa1.js"),F=require("./index-BhY3ui5c.js"),G=require("./index-C7R_tQdV.js");function L(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=L(T);var O=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],g=O.reduce((e,t)=>{const n=M.createSlot(`Primitive.${t}`),o=b.forwardRef((r,c)=>{const{asChild:a,...u}=r,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...u,ref:c})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),m="Tabs",[V]=A.createContextScope(m,[p.createRovingFocusGroupScope]),y=p.createRovingFocusGroupScope(),[k,h]=V(m),w=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:r,defaultValue:c,orientation:a="horizontal",dir:u,activationMode:l="automatic",...f}=e,d=D.useDirection(u),[i,v]=F.useControllableState({prop:o,onChange:r,defaultProp:c??"",caller:m});return s.jsx(k,{scope:n,baseId:G.useId(),value:i,onValueChange:v,orientation:a,dir:d,activationMode:l,children:s.jsx(g.div,{dir:d,"data-orientation":a,...f,ref:t})})});w.displayName=m;var j="TabsList",N=b.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...r}=e,c=h(j,n),a=y(n);return s.jsx(p.Root,{asChild:!0,...a,orientation:c.orientation,dir:c.dir,loop:o,children:s.jsx(g.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:t})})});N.displayName=j;var R="TabsTrigger",S=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:r=!1,...c}=e,a=h(R,n),u=y(n),l=I(a.baseId,o),f=P(a.baseId,o),d=o===a.value;return s.jsx(p.Item,{asChild:!0,...u,focusable:!r,active:d,children:s.jsx(g.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:l,...c,ref:t,onMouseDown:x.composeEventHandlers(e.onMouseDown,i=>{!r&&i.button===0&&i.ctrlKey===!1?a.onValueChange(o):i.preventDefault()}),onKeyDown:x.composeEventHandlers(e.onKeyDown,i=>{[" ","Enter"].includes(i.key)&&a.onValueChange(o)}),onFocus:x.composeEventHandlers(e.onFocus,()=>{const i=a.activationMode!=="manual";!d&&!r&&i&&a.onValueChange(o)})})})});S.displayName=R;var _="TabsContent",$=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:r,children:c,...a}=e,u=h(_,n),l=I(u.baseId,o),f=P(u.baseId,o),d=o===u.value,i=b.useRef(d);return b.useEffect(()=>{const v=requestAnimationFrame(()=>i.current=!1);return()=>cancelAnimationFrame(v)},[]),s.jsx(E.Presence,{present:r||d,children:({present:v})=>s.jsx(g.div,{"data-state":d?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":l,hidden:!v,id:f,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:i.current?"0s":void 0},children:v&&c})})});$.displayName=_;function I(e,t){return`${e}-trigger-${t}`}function P(e,t){return`${e}-content-${t}`}var H=w,K=N,z=S,B=$;const J=H,q=T.createContext({grow:!1}),Q=({className:e,grow:t,...n})=>s.jsx(q.Provider,{value:{grow:t},children:s.jsx(K,{"data-slot":"tabs-list",className:C.cn("inline-flex-center text-muted-foreground h-10 p-1",t&&"w-full",e),...n})}),U=({className:e,...t})=>{const{grow:n}=T.useContext(q);return s.jsx(z,{"data-slot":"tabs-trigger",className:C.cn("inline-flex-center focus-ring border-b-border data-[state=active]:border-b-primary data-[state=active]:text-foreground border-b px-3 py-2 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-xs",n&&"grow",e),...t})},W=({className:e,...t})=>s.jsx(B,{"data-slot":"tabs-content",className:C.cn("focus-ring mt-2",e),...t});exports.Tabs=J;exports.TabsContent=W;exports.TabsList=Q;exports.TabsTrigger=U;