@purpurds/tabs 5.18.3 → 5.19.1

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/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  Name: @purpurds/icon
2
- Version: 5.18.2
2
+ Version: 5.19.0
3
3
  License: AGPL-3.0-only
4
4
  Private: false
5
5
 
package/dist/tabs.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),r=require("react"),ye=require("react-dom");function we(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 oe=we(r);function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce={exports:{}};/*!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),r=require("react"),Ie=require("react-dom");function we(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 ce=we(r);function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var se={exports:{}};/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
- */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var c="",s=0;s<arguments.length;s++){var i=arguments[s];i&&(c=a(c,o.call(this,i)))}return c}function o(c){if(typeof c=="string"||typeof c=="number")return this&&this[c]||c;if(typeof c!="object")return"";if(Array.isArray(c))return n.apply(this,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var s="";for(var i in c)t.call(c,i)&&c[i]&&(s=a(s,this&&this[i]||i));return s}function a(c,s){return s?c?c+" "+s:c+s:c}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(ce);var Ie=ce.exports;const Te=Se(Ie),Ne={"purpur-icon":"_purpur-icon_8u1lq_1","purpur-icon--xxs":"_purpur-icon--xxs_8u1lq_4","purpur-icon--xs":"_purpur-icon--xs_8u1lq_8","purpur-icon--sm":"_purpur-icon--sm_8u1lq_12","purpur-icon--md":"_purpur-icon--md_8u1lq_16","purpur-icon--lg":"_purpur-icon--lg_8u1lq_20","purpur-icon--xl":"_purpur-icon--xl_8u1lq_24"},Re={name:"chevron-left",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M16.175 3.905a.9.9 0 0 1-.08 1.27L8.36 12l7.736 6.825a.9.9 0 0 1-1.191 1.35l-8.5-7.5a.9.9 0 0 1 0-1.35l8.5-7.5a.9.9 0 0 1 1.27.08Z" clip-rule="evenodd"/></svg>',keywords:["chevron-left"],category:"utility"},Ae={name:"chevron-right",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M7.809 3.924a.9.9 0 0 0 .115 1.267L16.094 12l-8.17 6.809a.9.9 0 0 0 1.152 1.382l9-7.5a.9.9 0 0 0 0-1.382l-9-7.5a.9.9 0 0 0-1.267.115Z" clip-rule="evenodd"/></svg>',keywords:["chevron-right"],category:"utility"},Pe=Te.bind(Ne),ne="purpur-icon",Me="md",Oe=e=>e.filter(t=>Object.keys(t).length>=1).map(t=>`${t.name}="${t.value}"`).join(" "),Fe=({content:e="",title:t}={})=>{const n=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},{name:"viewBox",value:"0 0 24 24"},t?{name:"role",value:"img"}:{name:"aria-hidden",value:"true"}],o=t?`<title>${t}</title>`:"";return`<svg ${Oe(n)}>${o}${e}</svg>`},De=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),je=({["data-testid"]:e,svg:t,allyTitle:n,className:o,size:a=Me,...c})=>{const s=Fe({content:De(t.svg),title:n}),i=Pe(o,ne,`${ne}--${a}`);return E.jsx("span",{"aria-label":n,className:i,"data-testid":e,dangerouslySetInnerHTML:{__html:s},...c})};function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},y.apply(null,arguments)}function N(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function Z(e,t=[]){let n=[];function o(c,s){const i=r.createContext(s),l=n.length;n=[...n,s];function u(d){const{scope:m,children:v,...f}=d,$=(m==null?void 0:m[e][l])||i,_=r.useMemo(()=>f,Object.values(f));return r.createElement($.Provider,{value:_},v)}function b(d,m){const v=(m==null?void 0:m[e][l])||i,f=r.useContext(v);if(f)return f;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${c}\``)}return u.displayName=c+"Provider",[u,b]}const a=()=>{const c=n.map(s=>r.createContext(s));return function(i){const l=(i==null?void 0:i[e])||c;return r.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])}};return a.scopeName=e,[o,qe(a,...t)]}function qe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(c){const s=o.reduce((i,{useScope:l,scopeName:u})=>{const d=l(c)[`__scope${u}`];return{...i,...d}},{});return r.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Ve(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function se(...e){return t=>e.forEach(n=>Ve(n,t))}function V(...e){return r.useCallback(se(...e),e)}const L=r.forwardRef((e,t)=>{const{children:n,...o}=e,a=r.Children.toArray(n),c=a.find(Ue);if(c){const s=c.props.children,i=a.map(l=>l===c?r.Children.count(s)>1?r.Children.only(null):r.isValidElement(s)?s.props.children:null:l);return r.createElement(K,y({},o,{ref:t}),r.isValidElement(s)?r.cloneElement(s,void 0,i):null)}return r.createElement(K,y({},o,{ref:t}),n)});L.displayName="Slot";const K=r.forwardRef((e,t)=>{const{children:n,...o}=e;return r.isValidElement(n)?r.cloneElement(n,{...ke(o,n.props),ref:t?se(t,n.ref):n.ref}):r.Children.count(n)>1?r.Children.only(null):null});K.displayName="SlotClone";const Le=({children:e})=>r.createElement(r.Fragment,null,e);function Ue(e){return r.isValidElement(e)&&e.type===Le}function ke(e,t){const n={...t};for(const o in t){const a=e[o],c=t[o];/^on[A-Z]/.test(o)?a&&c?n[o]=(...i)=>{c(...i),a(...i)}:a&&(n[o]=a):o==="style"?n[o]={...a,...c}:o==="className"&&(n[o]=[a,c].filter(Boolean).join(" "))}return{...e,...n}}function Be(e){const t=e+"CollectionProvider",[n,o]=Z(t),[a,c]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:f,children:$}=v,_=r.useRef(null),g=r.useRef(new Map).current;return r.createElement(a,{scope:f,itemMap:g,collectionRef:_},$)},i=e+"CollectionSlot",l=r.forwardRef((v,f)=>{const{scope:$,children:_}=v,g=c(i,$),x=V(f,g.collectionRef);return r.createElement(L,{ref:x},_)}),u=e+"CollectionItemSlot",b="data-radix-collection-item",d=r.forwardRef((v,f)=>{const{scope:$,children:_,...g}=v,x=r.useRef(null),R=V(f,x),S=c(u,$);return r.useEffect(()=>(S.itemMap.set(x,{ref:x,...g}),()=>void S.itemMap.delete(x))),r.createElement(L,{[b]:"",ref:R},_)});function m(v){const f=c(e+"CollectionConsumer",v);return r.useCallback(()=>{const _=f.collectionRef.current;if(!_)return[];const g=Array.from(_.querySelectorAll(`[${b}]`));return Array.from(f.itemMap.values()).sort((S,A)=>g.indexOf(S.ref.current)-g.indexOf(A.ref.current))},[f.collectionRef,f.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},m,o]}const W=globalThis!=null&&globalThis.document?r.useLayoutEffect:()=>{},Ge=oe.useId||(()=>{});let ze=0;function ae(e){const[t,n]=oe.useState(Ge());return W(()=>{e||n(o=>o??String(ze++))},[e]),e||(t?`radix-${t}`:"")}const Ke=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],D=Ke.reduce((e,t)=>{const n=r.forwardRef((o,a)=>{const{asChild:c,...s}=o,i=c?L:t;return r.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),r.createElement(i,y({},s,{ref:a}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function H(e){const t=r.useRef(e);return r.useEffect(()=>{t.current=e}),r.useMemo(()=>(...n)=>{var o;return(o=t.current)===null||o===void 0?void 0:o.call(t,...n)},[])}function ie({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,a]=We({defaultProp:t,onChange:n}),c=e!==void 0,s=c?e:o,i=H(n),l=r.useCallback(u=>{if(c){const d=typeof u=="function"?u(e):u;d!==e&&i(d)}else a(u)},[c,e,a,i]);return[s,l]}function We({defaultProp:e,onChange:t}){const n=r.useState(e),[o]=n,a=r.useRef(o),c=H(t);return r.useEffect(()=>{a.current!==o&&(c(o),a.current=o)},[o,a,c]),n}const Ye=r.createContext(void 0);function ue(e){const t=r.useContext(Ye);return e||t||"ltr"}const z="rovingFocusGroup.onEntryFocus",Ze={bubbles:!1,cancelable:!0},X="RovingFocusGroup",[Y,le,He]=Be(X),[Xe,de]=Z(X,[He]),[Je,Qe]=Xe(X),et=r.forwardRef((e,t)=>r.createElement(Y.Provider,{scope:e.__scopeRovingFocusGroup},r.createElement(Y.Slot,{scope:e.__scopeRovingFocusGroup},r.createElement(tt,y({},e,{ref:t}))))),tt=r.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:a=!1,dir:c,currentTabStopId:s,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:l,onEntryFocus:u,...b}=e,d=r.useRef(null),m=V(t,d),v=ue(c),[f=null,$]=ie({prop:s,defaultProp:i,onChange:l}),[_,g]=r.useState(!1),x=H(u),R=le(n),S=r.useRef(!1),[A,j]=r.useState(0);return r.useEffect(()=>{const C=d.current;if(C)return C.addEventListener(z,x),()=>C.removeEventListener(z,x)},[x]),r.createElement(Je,{scope:n,orientation:o,dir:v,loop:a,currentTabStopId:f,onItemFocus:r.useCallback(C=>$(C),[$]),onItemShiftTab:r.useCallback(()=>g(!0),[]),onFocusableItemAdd:r.useCallback(()=>j(C=>C+1),[]),onFocusableItemRemove:r.useCallback(()=>j(C=>C-1),[])},r.createElement(D.div,y({tabIndex:_||A===0?-1:0,"data-orientation":o},b,{ref:m,style:{outline:"none",...e.style},onMouseDown:N(e.onMouseDown,()=>{S.current=!0}),onFocus:N(e.onFocus,C=>{const U=!S.current;if(C.target===C.currentTarget&&U&&!_){const O=new CustomEvent(z,Ze);if(C.currentTarget.dispatchEvent(O),!O.defaultPrevented){const P=R().filter(h=>h.focusable),k=P.find(h=>h.active),B=P.find(h=>h.id===f),p=[k,B,...P].filter(Boolean).map(h=>h.ref.current);fe(p)}}S.current=!1}),onBlur:N(e.onBlur,()=>g(!1))})))}),nt="RovingFocusGroupItem",rt=r.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:a=!1,tabStopId:c,...s}=e,i=ae(),l=c||i,u=Qe(nt,n),b=u.currentTabStopId===l,d=le(n),{onFocusableItemAdd:m,onFocusableItemRemove:v}=u;return r.useEffect(()=>{if(o)return m(),()=>v()},[o,m,v]),r.createElement(Y.ItemSlot,{scope:n,id:l,focusable:o,active:a},r.createElement(D.span,y({tabIndex:b?0:-1,"data-orientation":u.orientation},s,{ref:t,onMouseDown:N(e.onMouseDown,f=>{o?u.onItemFocus(l):f.preventDefault()}),onFocus:N(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:N(e.onKeyDown,f=>{if(f.key==="Tab"&&f.shiftKey){u.onItemShiftTab();return}if(f.target!==f.currentTarget)return;const $=st(f,u.orientation,u.dir);if($!==void 0){f.preventDefault();let g=d().filter(x=>x.focusable).map(x=>x.ref.current);if($==="last")g.reverse();else if($==="prev"||$==="next"){$==="prev"&&g.reverse();const x=g.indexOf(f.currentTarget);g=u.loop?at(g,x+1):g.slice(x+1)}setTimeout(()=>fe(g))}})})))}),ot={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ct(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function st(e,t,n){const o=ct(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return ot[o]}function fe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function at(e,t){return e.map((n,o)=>e[(t+o)%e.length])}const it=et,ut=rt;function lt(e,t){return r.useReducer((n,o)=>{const a=t[n][o];return a??n},e)}const pe=e=>{const{present:t,children:n}=e,o=dt(t),a=typeof n=="function"?n({present:o.isPresent}):r.Children.only(n),c=V(o.ref,a.ref);return typeof n=="function"||o.isPresent?r.cloneElement(a,{ref:c}):null};pe.displayName="Presence";function dt(e){const[t,n]=r.useState(),o=r.useRef({}),a=r.useRef(e),c=r.useRef("none"),s=e?"mounted":"unmounted",[i,l]=lt(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect(()=>{const u=q(o.current);c.current=i==="mounted"?u:"none"},[i]),W(()=>{const u=o.current,b=a.current;if(b!==e){const m=c.current,v=q(u);e?l("MOUNT"):v==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(b&&m!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,l]),W(()=>{if(t){const u=d=>{const v=q(o.current).includes(d.animationName);d.target===t&&v&&ye.flushSync(()=>l("ANIMATION_END"))},b=d=>{d.target===t&&(c.current=q(o.current))};return t.addEventListener("animationstart",b),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{t.removeEventListener("animationstart",b),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:r.useCallback(u=>{u&&(o.current=getComputedStyle(u)),n(u)},[])}}function q(e){return(e==null?void 0:e.animationName)||"none"}const be="Tabs",[ft,qt]=Z(be,[de]),$e=de(),[pt,J]=ft(be),bt=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:a,defaultValue:c,orientation:s="horizontal",dir:i,activationMode:l="automatic",...u}=e,b=ue(i),[d,m]=ie({prop:o,onChange:a,defaultProp:c});return r.createElement(pt,{scope:n,baseId:ae(),value:d,onValueChange:m,orientation:s,dir:b,activationMode:l},r.createElement(D.div,y({dir:b,"data-orientation":s},u,{ref:t})))}),$t="TabsList",mt=r.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...a}=e,c=J($t,n),s=$e(n);return r.createElement(it,y({asChild:!0},s,{orientation:c.orientation,dir:c.dir,loop:o}),r.createElement(D.div,y({role:"tablist","aria-orientation":c.orientation},a,{ref:t})))}),vt="TabsTrigger",_t=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:a=!1,...c}=e,s=J(vt,n),i=$e(n),l=me(s.baseId,o),u=ve(s.baseId,o),b=o===s.value;return r.createElement(ut,y({asChild:!0},i,{focusable:!a,active:b}),r.createElement(D.button,y({type:"button",role:"tab","aria-selected":b,"aria-controls":u,"data-state":b?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:l},c,{ref:t,onMouseDown:N(e.onMouseDown,d=>{!a&&d.button===0&&d.ctrlKey===!1?s.onValueChange(o):d.preventDefault()}),onKeyDown:N(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(o)}),onFocus:N(e.onFocus,()=>{const d=s.activationMode!=="manual";!b&&!a&&d&&s.onValueChange(o)})})))}),gt="TabsContent",ht=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:a,children:c,...s}=e,i=J(gt,n),l=me(i.baseId,o),u=ve(i.baseId,o),b=o===i.value,d=r.useRef(b);return r.useEffect(()=>{const m=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(m)},[]),r.createElement(pe,{present:a||b},({present:m})=>r.createElement(D.div,y({"data-state":b?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":l,hidden:!m,id:u,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0}}),m&&c))});function me(e,t){return`${e}-trigger-${t}`}function ve(e,t){return`${e}-content-${t}`}const xt=bt,Ct=mt,Et=_t,yt=ht;function wt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _e={exports:{}};/*!
5
+ */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var c="",s=0;s<arguments.length;s++){var i=arguments[s];i&&(c=a(c,o.call(this,i)))}return c}function o(c){if(typeof c=="string"||typeof c=="number")return this&&this[c]||c;if(typeof c!="object")return"";if(Array.isArray(c))return n.apply(this,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var s="";for(var i in c)t.call(c,i)&&c[i]&&(s=a(s,this&&this[i]||i));return s}function a(c,s){return s?c?c+" "+s:c+s:c}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(se);var Te=se.exports;const Ne=Se(Te),Re={"purpur-icon":"_purpur-icon_8u1lq_1","purpur-icon--xxs":"_purpur-icon--xxs_8u1lq_4","purpur-icon--xs":"_purpur-icon--xs_8u1lq_8","purpur-icon--sm":"_purpur-icon--sm_8u1lq_12","purpur-icon--md":"_purpur-icon--md_8u1lq_16","purpur-icon--lg":"_purpur-icon--lg_8u1lq_20","purpur-icon--xl":"_purpur-icon--xl_8u1lq_24"},Ae={name:"chevron-left",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M16.175 3.905a.9.9 0 0 1-.08 1.27L8.36 12l7.736 6.825a.9.9 0 0 1-1.191 1.35l-8.5-7.5a.9.9 0 0 1 0-1.35l8.5-7.5a.9.9 0 0 1 1.27.08Z" clip-rule="evenodd"/></svg>',keywords:["chevron-left"],category:"utility"},Pe={name:"chevron-right",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M7.809 3.924a.9.9 0 0 0 .115 1.267L16.094 12l-8.17 6.809a.9.9 0 0 0 1.152 1.382l9-7.5a.9.9 0 0 0 0-1.382l-9-7.5a.9.9 0 0 0-1.267.115Z" clip-rule="evenodd"/></svg>',keywords:["chevron-right"],category:"utility"},Me=Ne.bind(Re),re="purpur-icon",Oe="md",Fe=e=>e.filter(t=>Object.keys(t).length>=1).map(t=>`${t.name}="${t.value}"`).join(" "),De=({content:e="",title:t}={})=>{const n=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},{name:"viewBox",value:"0 0 24 24"},t?{name:"role",value:"img"}:{name:"aria-hidden",value:"true"}],o=t?`<title>${t}</title>`:"";return`<svg ${Fe(n)}>${o}${e}</svg>`},je=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),qe=({["data-testid"]:e,svg:t,allyTitle:n,className:o,size:a=Oe,...c})=>{const s=De({content:je(t.svg),title:n}),i=Me(o,re,`${re}--${a}`);return E.jsx("span",{"aria-label":n,className:i,"data-testid":e,dangerouslySetInnerHTML:{__html:s},...c})};function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},y.apply(null,arguments)}function N(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function Z(e,t=[]){let n=[];function o(c,s){const i=r.createContext(s),l=n.length;n=[...n,s];function u(f){const{scope:v,children:_,...p}=f,h=(v==null?void 0:v[e][l])||i,m=r.useMemo(()=>p,Object.values(p));return r.createElement(h.Provider,{value:m},_)}function b(f,v){const _=(v==null?void 0:v[e][l])||i,p=r.useContext(_);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${c}\``)}return u.displayName=c+"Provider",[u,b]}const a=()=>{const c=n.map(s=>r.createContext(s));return function(i){const l=(i==null?void 0:i[e])||c;return r.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])}};return a.scopeName=e,[o,Ve(a,...t)]}function Ve(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(c){const s=o.reduce((i,{useScope:l,scopeName:u})=>{const f=l(c)[`__scope${u}`];return{...i,...f}},{});return r.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Le(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ae(...e){return t=>e.forEach(n=>Le(n,t))}function k(...e){return r.useCallback(ae(...e),e)}const B=r.forwardRef((e,t)=>{const{children:n,...o}=e,a=r.Children.toArray(n),c=a.find(ke);if(c){const s=c.props.children,i=a.map(l=>l===c?r.Children.count(s)>1?r.Children.only(null):r.isValidElement(s)?s.props.children:null:l);return r.createElement(K,y({},o,{ref:t}),r.isValidElement(s)?r.cloneElement(s,void 0,i):null)}return r.createElement(K,y({},o,{ref:t}),n)});B.displayName="Slot";const K=r.forwardRef((e,t)=>{const{children:n,...o}=e;return r.isValidElement(n)?r.cloneElement(n,{...Be(o,n.props),ref:t?ae(t,n.ref):n.ref}):r.Children.count(n)>1?r.Children.only(null):null});K.displayName="SlotClone";const Ue=({children:e})=>r.createElement(r.Fragment,null,e);function ke(e){return r.isValidElement(e)&&e.type===Ue}function Be(e,t){const n={...t};for(const o in t){const a=e[o],c=t[o];/^on[A-Z]/.test(o)?a&&c?n[o]=(...i)=>{c(...i),a(...i)}:a&&(n[o]=a):o==="style"?n[o]={...a,...c}:o==="className"&&(n[o]=[a,c].filter(Boolean).join(" "))}return{...e,...n}}function Ge(e){const t=e+"CollectionProvider",[n,o]=Z(t),[a,c]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=_=>{const{scope:p,children:h}=_,m=r.useRef(null),$=r.useRef(new Map).current;return r.createElement(a,{scope:p,itemMap:$,collectionRef:m},h)},i=e+"CollectionSlot",l=r.forwardRef((_,p)=>{const{scope:h,children:m}=_,$=c(i,h),g=k(p,$.collectionRef);return r.createElement(B,{ref:g},m)}),u=e+"CollectionItemSlot",b="data-radix-collection-item",f=r.forwardRef((_,p)=>{const{scope:h,children:m,...$}=_,g=r.useRef(null),R=k(p,g),I=c(u,h);return r.useEffect(()=>(I.itemMap.set(g,{ref:g,...$}),()=>void I.itemMap.delete(g))),r.createElement(B,{[b]:"",ref:R},m)});function v(_){const p=c(e+"CollectionConsumer",_);return r.useCallback(()=>{const m=p.collectionRef.current;if(!m)return[];const $=Array.from(m.querySelectorAll(`[${b}]`));return Array.from(p.itemMap.values()).sort((I,D)=>$.indexOf(I.ref.current)-$.indexOf(D.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},v,o]}const W=globalThis!=null&&globalThis.document?r.useLayoutEffect:()=>{},ze=ce.useId||(()=>{});let Ke=0;function ie(e){const[t,n]=ce.useState(ze());return W(()=>{e||n(o=>o??String(Ke++))},[e]),e||(t?`radix-${t}`:"")}const We=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],F=We.reduce((e,t)=>{const n=r.forwardRef((o,a)=>{const{asChild:c,...s}=o,i=c?B:t;return r.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),r.createElement(i,y({},s,{ref:a}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function H(e){const t=r.useRef(e);return r.useEffect(()=>{t.current=e}),r.useMemo(()=>(...n)=>{var o;return(o=t.current)===null||o===void 0?void 0:o.call(t,...n)},[])}function ue({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,a]=Ye({defaultProp:t,onChange:n}),c=e!==void 0,s=c?e:o,i=H(n),l=r.useCallback(u=>{if(c){const f=typeof u=="function"?u(e):u;f!==e&&i(f)}else a(u)},[c,e,a,i]);return[s,l]}function Ye({defaultProp:e,onChange:t}){const n=r.useState(e),[o]=n,a=r.useRef(o),c=H(t);return r.useEffect(()=>{a.current!==o&&(c(o),a.current=o)},[o,a,c]),n}const Ze=r.createContext(void 0);function le(e){const t=r.useContext(Ze);return e||t||"ltr"}const z="rovingFocusGroup.onEntryFocus",He={bubbles:!1,cancelable:!0},X="RovingFocusGroup",[Y,de,Xe]=Ge(X),[Je,fe]=Z(X,[Xe]),[Qe,et]=Je(X),tt=r.forwardRef((e,t)=>r.createElement(Y.Provider,{scope:e.__scopeRovingFocusGroup},r.createElement(Y.Slot,{scope:e.__scopeRovingFocusGroup},r.createElement(nt,y({},e,{ref:t}))))),nt=r.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:a=!1,dir:c,currentTabStopId:s,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:l,onEntryFocus:u,...b}=e,f=r.useRef(null),v=k(t,f),_=le(c),[p=null,h]=ue({prop:s,defaultProp:i,onChange:l}),[m,$]=r.useState(!1),g=H(u),R=de(n),I=r.useRef(!1),[D,M]=r.useState(0);return r.useEffect(()=>{const x=f.current;if(x)return x.addEventListener(z,g),()=>x.removeEventListener(z,g)},[g]),r.createElement(Qe,{scope:n,orientation:o,dir:_,loop:a,currentTabStopId:p,onItemFocus:r.useCallback(x=>h(x),[h]),onItemShiftTab:r.useCallback(()=>$(!0),[]),onFocusableItemAdd:r.useCallback(()=>M(x=>x+1),[]),onFocusableItemRemove:r.useCallback(()=>M(x=>x-1),[])},r.createElement(F.div,y({tabIndex:m||D===0?-1:0,"data-orientation":o},b,{ref:v,style:{outline:"none",...e.style},onMouseDown:N(e.onMouseDown,()=>{I.current=!0}),onFocus:N(e.onFocus,x=>{const V=!I.current;if(x.target===x.currentTarget&&V&&!m){const j=new CustomEvent(z,He);if(x.currentTarget.dispatchEvent(j),!j.defaultPrevented){const A=R().filter(d=>d.focusable),q=A.find(d=>d.active),G=A.find(d=>d.id===p),L=[q,G,...A].filter(Boolean).map(d=>d.ref.current);pe(L)}}I.current=!1}),onBlur:N(e.onBlur,()=>$(!1))})))}),rt="RovingFocusGroupItem",ot=r.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:a=!1,tabStopId:c,...s}=e,i=ie(),l=c||i,u=et(rt,n),b=u.currentTabStopId===l,f=de(n),{onFocusableItemAdd:v,onFocusableItemRemove:_}=u;return r.useEffect(()=>{if(o)return v(),()=>_()},[o,v,_]),r.createElement(Y.ItemSlot,{scope:n,id:l,focusable:o,active:a},r.createElement(F.span,y({tabIndex:b?0:-1,"data-orientation":u.orientation},s,{ref:t,onMouseDown:N(e.onMouseDown,p=>{o?u.onItemFocus(l):p.preventDefault()}),onFocus:N(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:N(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const h=at(p,u.orientation,u.dir);if(h!==void 0){p.preventDefault();let $=f().filter(g=>g.focusable).map(g=>g.ref.current);if(h==="last")$.reverse();else if(h==="prev"||h==="next"){h==="prev"&&$.reverse();const g=$.indexOf(p.currentTarget);$=u.loop?it($,g+1):$.slice(g+1)}setTimeout(()=>pe($))}})})))}),ct={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function st(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function at(e,t,n){const o=st(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return ct[o]}function pe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function it(e,t){return e.map((n,o)=>e[(t+o)%e.length])}const ut=tt,lt=ot;function dt(e,t){return r.useReducer((n,o)=>{const a=t[n][o];return a??n},e)}const be=e=>{const{present:t,children:n}=e,o=ft(t),a=typeof n=="function"?n({present:o.isPresent}):r.Children.only(n),c=k(o.ref,a.ref);return typeof n=="function"||o.isPresent?r.cloneElement(a,{ref:c}):null};be.displayName="Presence";function ft(e){const[t,n]=r.useState(),o=r.useRef({}),a=r.useRef(e),c=r.useRef("none"),s=e?"mounted":"unmounted",[i,l]=dt(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect(()=>{const u=U(o.current);c.current=i==="mounted"?u:"none"},[i]),W(()=>{const u=o.current,b=a.current;if(b!==e){const v=c.current,_=U(u);e?l("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(b&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,l]),W(()=>{if(t){const u=f=>{const _=U(o.current).includes(f.animationName);f.target===t&&_&&Ie.flushSync(()=>l("ANIMATION_END"))},b=f=>{f.target===t&&(c.current=U(o.current))};return t.addEventListener("animationstart",b),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{t.removeEventListener("animationstart",b),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:r.useCallback(u=>{u&&(o.current=getComputedStyle(u)),n(u)},[])}}function U(e){return(e==null?void 0:e.animationName)||"none"}const $e="Tabs",[pt,Vt]=Z($e,[fe]),me=fe(),[bt,J]=pt($e),$t=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:a,defaultValue:c,orientation:s="horizontal",dir:i,activationMode:l="automatic",...u}=e,b=le(i),[f,v]=ue({prop:o,onChange:a,defaultProp:c});return r.createElement(bt,{scope:n,baseId:ie(),value:f,onValueChange:v,orientation:s,dir:b,activationMode:l},r.createElement(F.div,y({dir:b,"data-orientation":s},u,{ref:t})))}),mt="TabsList",vt=r.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...a}=e,c=J(mt,n),s=me(n);return r.createElement(ut,y({asChild:!0},s,{orientation:c.orientation,dir:c.dir,loop:o}),r.createElement(F.div,y({role:"tablist","aria-orientation":c.orientation},a,{ref:t})))}),_t="TabsTrigger",gt=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:a=!1,...c}=e,s=J(_t,n),i=me(n),l=ve(s.baseId,o),u=_e(s.baseId,o),b=o===s.value;return r.createElement(lt,y({asChild:!0},i,{focusable:!a,active:b}),r.createElement(F.button,y({type:"button",role:"tab","aria-selected":b,"aria-controls":u,"data-state":b?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:l},c,{ref:t,onMouseDown:N(e.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?s.onValueChange(o):f.preventDefault()}),onKeyDown:N(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(o)}),onFocus:N(e.onFocus,()=>{const f=s.activationMode!=="manual";!b&&!a&&f&&s.onValueChange(o)})})))}),ht="TabsContent",xt=r.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:a,children:c,...s}=e,i=J(ht,n),l=ve(i.baseId,o),u=_e(i.baseId,o),b=o===i.value,f=r.useRef(b);return r.useEffect(()=>{const v=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(v)},[]),r.createElement(be,{present:a||b},({present:v})=>r.createElement(F.div,y({"data-state":b?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":l,hidden:!v,id:u,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),v&&c))});function ve(e,t){return`${e}-trigger-${t}`}function _e(e,t){return`${e}-content-${t}`}const Ct=$t,Et=vt,yt=gt,It=xt;function wt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ge={exports:{}};/*!
6
6
  Copyright (c) 2018 Jed Watson.
7
7
  Licensed under the MIT License (MIT), see
8
8
  http://jedwatson.github.io/classnames
9
- */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var c="",s=0;s<arguments.length;s++){var i=arguments[s];i&&(c=a(c,o.call(this,i)))}return c}function o(c){if(typeof c=="string"||typeof c=="number")return this&&this[c]||c;if(typeof c!="object")return"";if(Array.isArray(c))return n.apply(this,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var s="";for(var i in c)t.call(c,i)&&c[i]&&(s=a(s,this&&this[i]||i));return s}function a(c,s){return s?c?c+" "+s:c+s:c}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(_e);var St=_e.exports;const Q=wt(St),It={"purpur-tab-content":"_purpur-tab-content_1x2zs_1"},Tt=Q.bind(It),Nt="purpur-tab-content",Rt=r.forwardRef(({children:e,tabId:t,"data-testid":n,className:o,...a},c)=>E.jsx(yt,{ref:c,className:Tt([Nt,o]),"data-testid":n,value:t,...a,children:e})),At=e=>!!e&&r.isValidElement(e)&&!!e.props.name&&!!e.props.tabId,Pt={"purpur-tab-header":"_purpur-tab-header_18g3c_1","purpur-tab-header--contained":"_purpur-tab-header--contained_18g3c_33","purpur-tab-header--contained-negative":"_purpur-tab-header--contained-negative_18g3c_33","purpur-tab-header--line":"_purpur-tab-header--line_18g3c_36","purpur-tab-header--line-negative":"_purpur-tab-header--line-negative_18g3c_48"},Mt=Q.bind(Pt),re="purpur-tab-header",Ot=r.forwardRef(({index:e,tabId:t,variant:n,negative:o,onFocus:a,"data-testid":c,children:s},i)=>E.jsx(Et,{id:`${t}-trigger`,className:Mt([re,`${re}--${n}${o?"-negative":""}`]),value:t,"data-testid":c,"data-index":e,ref:i,onFocus:a,children:s})),Ft={"purpur-tabs__wrapper":"_purpur-tabs__wrapper_1dpqy_1","purpur-tabs__scroll-button":"_purpur-tabs__scroll-button_1dpqy_9","purpur-tabs__scroll-button--left":"_purpur-tabs__scroll-button--left_1dpqy_63","purpur-tabs__scroll-button--right":"_purpur-tabs__scroll-button--right_1dpqy_66","purpur-tabs__wrapper--scroll-end":"_purpur-tabs__wrapper--scroll-end_1dpqy_69","purpur-tabs__wrapper--scroll-start":"_purpur-tabs__wrapper--scroll-start_1dpqy_72","purpur-tabs--line":"_purpur-tabs--line_1dpqy_75","purpur-tabs--line-negative":"_purpur-tabs--line-negative_1dpqy_75","purpur-tabs__selected-border":"_purpur-tabs__selected-border_1dpqy_83","purpur-tabs--contained":"_purpur-tabs--contained_1dpqy_103","purpur-tabs__list":"_purpur-tabs__list_1dpqy_103","purpur-tabs--contained-negative":"_purpur-tabs--contained-negative_1dpqy_103","purpur-tabs__content-container":"_purpur-tabs__content-container_1dpqy_106","purpur-tabs--fullWidth":"_purpur-tabs--fullWidth_1dpqy_115"},Dt=["line","contained"],ge=e=>new CustomEvent("tabChangeDetail",{detail:{value:e}}),M=Q.bind(Ft),w="purpur-tabs",jt=(e,t)=>{var l;if(typeof(e==null?void 0:e.getBoundingClientRect)!="function"||typeof(t==null?void 0:t.scroll)!="function")return;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),a=t.clientWidth,c=parseInt((l=getComputedStyle(t).borderLeftWidth)==null?void 0:l.split("px")[0],10),s=o.left+(isNaN(c)?0:c);let i;n.right>o.right&&(i=n.left+t.scrollLeft,i=i+n.width-a+a*.1,i=i-s),n.left<o.left&&(i=n.left+t.scrollLeft,i=i-a*.1,i=i-s),i!==void 0&&t.scroll({left:i,behavior:"smooth"})},he=({children:e,variant:t="line",negative:n=!1,fullWidth:o=!1,onChange:a,className:c,defaultValue:s,"data-testid":i,...l})=>{const[u,b]=r.useState({}),[d,m]=r.useState(0),[v,f]=r.useState(0),$=r.Children.toArray(e).filter(At),_=r.useRef(),g=r.useRef(new Array($.length)),x=200,R=t==="line",S=M([w,`${w}--${t}${n?"-negative":""}`,{[`${w}--fullWidth`]:o},c]),A=r.Children.map($,({props:{tabId:p}})=>p),j=()=>{const p=A.findIndex(h=>h===s);return p>=0?p:0},[C,U]=r.useState(j);if(new Set(A).size!==A.length)throw new Error("tabId must be unique");const O=(p,h)=>h||i?`${h||i}-${p}`:void 0,P=()=>{if(!R)return;const p=g.current[C];m((p==null?void 0:p.offsetLeft)||0),f((p==null?void 0:p.getBoundingClientRect().width)||0)},k=p=>{R&&U($.findIndex(h=>h.props.tabId===p)),a==null||a(ge(p))},B=p=>{if(_!=null&&_.current){const{scrollLeft:h}=_.current,F=p==="left"?-x:x;_.current.scroll({left:h+F,behavior:"smooth"})}},G=({side:p})=>E.jsx("button",{className:M(`${w}__scroll-button`,`${w}__scroll-button--${p}`),onClick:()=>B(p),type:"button","aria-hidden":"true",tabIndex:-1,"data-testid":O("scroll-button"),children:E.jsx(je,{svg:p==="left"?Re:Ae,size:"md"})});return r.useEffect(()=>(window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P)}),[]),r.useEffect(()=>{P()},[C,o,$.length,t]),r.useEffect(()=>{const p=T=>{if(T.every(I=>I.isIntersecting)&&T.length===$.length){b({});return}T.forEach(I=>{const te=Number(I.target.getAttribute("data-index")),xe=te===0,Ce=te===$.length-1;b(Ee=>({...Ee,...xe&&{[`${w}__wrapper--scroll-end`]:!I.isIntersecting},...Ce&&{[`${w}__wrapper--scroll-start`]:!I.isIntersecting}}))})},h=new IntersectionObserver(p,{threshold:[.99],root:_.current}),F=g.current;return F.forEach(T=>h.observe(T)),()=>{F.forEach(T=>h.unobserve(T))}},[$.length]),E.jsx(xt,{defaultValue:s??$[0].props.tabId,onValueChange:k,"data-testid":i,className:S,...l,children:E.jsxs("div",{className:M(`${w}__container`),children:[E.jsxs("div",{className:M([`${w}__wrapper`,u]),children:[E.jsxs(Ct,{ref:p=>{_.current=p},className:M(`${w}__list`),children:[r.Children.map($,(p,h)=>{const{name:F,tabId:T,"data-testid":ee}=p.props;return E.jsx(Ot,{"data-testid":O("header",ee),index:h,tabId:T,ref:I=>{I&&(g.current[h]=I)},onFocus:I=>{jt(I.target,_.current)},variant:t,negative:n,children:F})}),R&&E.jsx("div",{className:M(`${w}__selected-border`),style:{width:v,transform:`translateX(${d}px)`},"data-testid":O("selected-border")})]}),E.jsx(G,{side:"left"}),E.jsx(G,{side:"right"})]}),E.jsx("div",{className:M(`${w}__content-container`),children:r.Children.map($,p=>p)})]})})};he.Content=Rt;exports.Tabs=he;exports.createTabChangeDetailEvent=ge;exports.tabsVariants=Dt;
9
+ */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var c="",s=0;s<arguments.length;s++){var i=arguments[s];i&&(c=a(c,o.call(this,i)))}return c}function o(c){if(typeof c=="string"||typeof c=="number")return this&&this[c]||c;if(typeof c!="object")return"";if(Array.isArray(c))return n.apply(this,c);if(c.toString!==Object.prototype.toString&&!c.toString.toString().includes("[native code]"))return c.toString();var s="";for(var i in c)t.call(c,i)&&c[i]&&(s=a(s,this&&this[i]||i));return s}function a(c,s){return s?c?c+" "+s:c+s:c}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(ge);var St=ge.exports;const Q=wt(St),Tt={"purpur-tab-content":"_purpur-tab-content_1x2zs_1"},Nt=Q.bind(Tt),Rt="purpur-tab-content",At=r.forwardRef(({children:e,tabId:t,"data-testid":n,className:o,...a},c)=>E.jsx(It,{ref:c,className:Nt([Rt,o]),"data-testid":n,value:t,...a,children:e})),Pt=e=>!!e&&r.isValidElement(e)&&!!e.props.name&&!!e.props.tabId,Mt={"purpur-tab-header":"_purpur-tab-header_18g3c_1","purpur-tab-header--contained":"_purpur-tab-header--contained_18g3c_33","purpur-tab-header--contained-negative":"_purpur-tab-header--contained-negative_18g3c_33","purpur-tab-header--line":"_purpur-tab-header--line_18g3c_36","purpur-tab-header--line-negative":"_purpur-tab-header--line-negative_18g3c_48"},Ot=Q.bind(Mt),oe="purpur-tab-header",Ft=r.forwardRef(({index:e,tabId:t,variant:n,negative:o,onFocus:a,"data-testid":c,children:s},i)=>E.jsx(yt,{id:`${t}-trigger`,className:Ot([oe,`${oe}--${n}${o?"-negative":""}`]),value:t,"data-testid":c,"data-index":e,ref:i,onFocus:a,children:s})),Dt={"purpur-tabs__wrapper":"_purpur-tabs__wrapper_1dpqy_1","purpur-tabs__scroll-button":"_purpur-tabs__scroll-button_1dpqy_9","purpur-tabs__scroll-button--left":"_purpur-tabs__scroll-button--left_1dpqy_63","purpur-tabs__scroll-button--right":"_purpur-tabs__scroll-button--right_1dpqy_66","purpur-tabs__wrapper--scroll-end":"_purpur-tabs__wrapper--scroll-end_1dpqy_69","purpur-tabs__wrapper--scroll-start":"_purpur-tabs__wrapper--scroll-start_1dpqy_72","purpur-tabs--line":"_purpur-tabs--line_1dpqy_75","purpur-tabs--line-negative":"_purpur-tabs--line-negative_1dpqy_75","purpur-tabs__selected-border":"_purpur-tabs__selected-border_1dpqy_83","purpur-tabs--contained":"_purpur-tabs--contained_1dpqy_103","purpur-tabs__list":"_purpur-tabs__list_1dpqy_103","purpur-tabs--contained-negative":"_purpur-tabs--contained-negative_1dpqy_103","purpur-tabs__content-container":"_purpur-tabs__content-container_1dpqy_106","purpur-tabs--fullWidth":"_purpur-tabs--fullWidth_1dpqy_115"},jt=["line","contained"],he=e=>new CustomEvent("tabChangeDetail",{detail:{value:e}}),P=Q.bind(Dt),w="purpur-tabs",qt=(e,t)=>{var l;if(typeof(e==null?void 0:e.getBoundingClientRect)!="function"||typeof(t==null?void 0:t.scroll)!="function")return;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),a=t.clientWidth,c=parseInt((l=getComputedStyle(t).borderLeftWidth)==null?void 0:l.split("px")[0],10),s=o.left+(isNaN(c)?0:c);let i;n.right>o.right&&(i=n.left+t.scrollLeft,i=i+n.width-a+a*.1,i=i-s),n.left<o.left&&(i=n.left+t.scrollLeft,i=i-a*.1,i=i-s),i!==void 0&&t.scroll({left:i,behavior:"smooth"})},xe=({children:e,variant:t="line",negative:n=!1,fullWidth:o=!1,onChange:a,className:c,defaultValue:s,"data-testid":i,value:l,...u})=>{const[b,f]=r.useState({}),[v,_]=r.useState(0),[p,h]=r.useState(0),m=r.Children.toArray(e).filter(Pt),$=r.useRef(),g=r.useRef(new Array(m.length)),R=200,I=t==="line",D=P([w,`${w}--${t}${n?"-negative":""}`,{[`${w}--fullWidth`]:o},c]),M=r.Children.map(m,({props:{tabId:d}})=>d),x=()=>{const d=M.findIndex(C=>C===s);return d>=0?d:0};r.useEffect(()=>{l&&j(m.findIndex(d=>d.props.tabId===l))},[m,l]);const[V,j]=r.useState(x);if(new Set(M).size!==M.length)throw new Error("tabId must be unique");const A=(d,C)=>C||i?`${C||i}-${d}`:void 0,q=()=>{if(!I)return;const d=g.current[V];_((d==null?void 0:d.offsetLeft)||0),h((d==null?void 0:d.getBoundingClientRect().width)||0)},G=d=>{I&&!l&&j(m.findIndex(C=>C.props.tabId===d)),a==null||a(he(d))},ee=d=>{if($!=null&&$.current){const{scrollLeft:C}=$.current,O=d==="left"?-R:R;$.current.scroll({left:C+O,behavior:"smooth"})}},L=({side:d})=>E.jsx("button",{className:P(`${w}__scroll-button`,`${w}__scroll-button--${d}`),onClick:()=>ee(d),type:"button","aria-hidden":"true",tabIndex:-1,"data-testid":A("scroll-button"),children:E.jsx(qe,{svg:d==="left"?Ae:Pe,size:"md"})});return r.useEffect(()=>(window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q)}),[]),r.useEffect(()=>{q()},[V,o,m.length,t]),r.useEffect(()=>{const d=T=>{if(T.every(S=>S.isIntersecting)&&T.length===m.length){f({});return}T.forEach(S=>{const ne=Number(S.target.getAttribute("data-index")),Ce=ne===0,Ee=ne===m.length-1;f(ye=>({...ye,...Ce&&{[`${w}__wrapper--scroll-end`]:!S.isIntersecting},...Ee&&{[`${w}__wrapper--scroll-start`]:!S.isIntersecting}}))})},C=new IntersectionObserver(d,{threshold:[.99],root:$.current}),O=g.current;return O.forEach(T=>C.observe(T)),()=>{O.forEach(T=>C.unobserve(T))}},[m.length]),E.jsx(Ct,{defaultValue:s??m[0].props.tabId,onValueChange:G,"data-testid":i,className:D,value:l,...u,children:E.jsxs("div",{className:P(`${w}__container`),children:[E.jsxs("div",{className:P([`${w}__wrapper`,b]),children:[E.jsxs(Et,{ref:d=>{$.current=d},className:P(`${w}__list`),children:[r.Children.map(m,(d,C)=>{const{name:O,tabId:T,"data-testid":te}=d.props;return E.jsx(Ft,{"data-testid":A("header",te),index:C,tabId:T,ref:S=>{S&&(g.current[C]=S)},onFocus:S=>{qt(S.target,$.current)},variant:t,negative:n,children:O})}),I&&E.jsx("div",{className:P(`${w}__selected-border`),style:{width:p,transform:`translateX(${v}px)`},"data-testid":A("selected-border")})]}),E.jsx(L,{side:"left"}),E.jsx(L,{side:"right"})]}),E.jsx("div",{className:P(`${w}__content-container`),children:r.Children.map(m,d=>d)})]})})};xe.Content=At;exports.Tabs=xe;exports.createTabChangeDetailEvent=he;exports.tabsVariants=jt;
10
10
  //# sourceMappingURL=tabs.cjs.js.map