@purpurds/tabs 5.12.0 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +1 -1
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.cjs.js.map +1 -1
- package/dist/tabs.es.js +106 -106
- package/dist/tabs.es.js.map +1 -1
- package/package.json +4 -4
package/dist/LICENSE.txt
CHANGED
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"),we=require("react-dom");function ye(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=ye(r);function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),r=require("react"),we=require("react-dom");function ye(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=ye(r);function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce={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 Se=ce.exports;const Te=Ie(Se),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 w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},w.apply(this,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,w({},o,{ref:t}),r.isValidElement(s)?r.cloneElement(s,void 0,i):null)}return r.createElement(K,w({},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,{...Be(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 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 ke(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),I=c(u,$);return r.useEffect(()=>(I.itemMap.set(x,{ref:x,...g}),()=>void I.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((I,A)=>g.indexOf(I.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,w({},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]=ke(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,w({},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),I=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,w({tabIndex:_||A===0?-1:0,"data-orientation":o},b,{ref:m,style:{outline:"none",...e.style},onMouseDown:N(e.onMouseDown,()=>{I.current=!0}),onFocus:N(e.onFocus,C=>{const U=!I.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),B=P.find(h=>h.active),k=P.find(h=>h.id===f),p=[B,k,...P].filter(Boolean).map(h=>h.ref.current);fe(p)}}I.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,w({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&&we.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,w({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,w({asChild:!0},s,{orientation:c.orientation,dir:c.dir,loop:o}),r.createElement(D.div,w({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,w({asChild:!0},i,{focusable:!a,active:b}),r.createElement(D.button,w({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,w({"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,wt=ht;function yt(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})()})(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 w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},w.apply(this,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,w({},o,{ref:t}),r.isValidElement(s)?r.cloneElement(s,void 0,i):null)}return r.createElement(K,w({},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,{...Be(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 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 ke(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,w({},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]=ke(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,w({},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,w({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),B=P.find(h=>h.active),k=P.find(h=>h.id===f),p=[B,k,...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,w({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&&we.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,w({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,w({asChild:!0},s,{orientation:c.orientation,dir:c.dir,loop:o}),r.createElement(D.div,w({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,w({asChild:!0},i,{focusable:!a,active:b}),r.createElement(D.button,w({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,w({"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,wt=ht;function yt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _e={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
|
|
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=yt(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(wt,{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),y="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([y,`${y}--${t}${n?"-negative":""}`,{[`${y}--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)},B=p=>{R&&U($.findIndex(h=>h.props.tabId===p)),a==null||a(ge(p))},k=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(`${y}__scroll-button`,`${y}__scroll-button--${p}`),onClick:()=>k(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&&{[`${y}__wrapper--scroll-end`]:!I.isIntersecting},...Ce&&{[`${y}__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:B,"data-testid":i,className:S,...l,children:E.jsxs("div",{className:M(`${y}__container`),children:[E.jsxs("div",{className:M([`${y}__wrapper`,u]),children:[E.jsxs(Ct,{ref:p=>{_.current=p},className:M(`${y}__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(`${y}__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(`${y}__content-container`),children:r.Children.map($,p=>p)})]})})};he.Content=Rt;exports.Tabs=he;exports.createTabChangeDetailEvent=ge;exports.tabsVariants=Dt;
|
|
10
10
|
//# sourceMappingURL=tabs.cjs.js.map
|