@purpurds/tabs 3.2.0 → 3.3.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 +1 -2
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.cjs.js.map +1 -1
- package/dist/tabs.es.js +57 -57
- package/dist/tabs.es.js.map +1 -1
- package/dist/tabs.system.js +3 -3
- package/dist/tabs.system.js.map +1 -1
- package/dist/tabs.utils.d.ts +0 -1
- package/dist/tabs.utils.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/tabs.system.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
System.register(["react","react/jsx-runtime","react-dom"],function(Q,Wt){"use strict";var z,K,C,ee,D,E,A,U,W,fe,v,pe,te,R,P,
|
|
1
|
+
System.register(["react","react/jsx-runtime","react-dom"],function(Q,Wt){"use strict";var z,K,C,ee,D,E,A,U,W,fe,v,pe,te,R,P,F,be,$e,ve;return{setters:[_=>{z=_.createContext,K=_.useMemo,C=_.createElement,ee=_.useContext,D=_.useCallback,E=_.forwardRef,A=_.Children,U=_.isValidElement,W=_.cloneElement,fe=_.Fragment,v=_.default,pe=_.useLayoutEffect,te=_,R=_.useEffect,P=_.useRef,F=_.useState,be=_.useReducer},_=>{$e=_.jsx},_=>{ve=_.flushSync}],execute:function(){function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var me={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 r="",c=0;c<arguments.length;c++){var a=arguments[c];a&&(r=s(r,o.call(this,a)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var c="";for(var a in r)t.call(r,a)&&r[a]&&(c=s(c,this&&this[a]||a));return c}function s(r,c){return c?r?r+" "+c:r+c:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(me);var Me=me.exports;const Oe=_(Me),Fe={"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"},De={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"},qe={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"},Le=Oe.bind(Fe),_e="purpur-icon",Ve="md",Ue=e=>e.filter(t=>Object.keys(t).length>=1).map(t=>`${t.name}="${t.value}"`).join(" "),Be=({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 ${Ue(n)}>${o}${e}</svg>`},je=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),ke=({["data-testid"]:e,svg:t,allyTitle:n,className:o="",size:s=Ve,...r})=>{const c=Be({content:je(t.svg),title:n}),a=Le(o,_e,`${_e}--${s}`);return $e("span",{"aria-label":n,className:a,"data-testid":e,dangerouslySetInnerHTML:{__html:c},...r})};function S(){return S=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},S.apply(this,arguments)}function F(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function ne(e,t=[]){let n=[];function o(r,c){const a=z(c),u=n.length;n=[...n,c];function i(l){const{scope:$,children:g,...d}=l,b=($==null?void 0:$[e][u])||a,h=K(()=>d,Object.values(d));return C(b.Provider,{value:h},g)}function f(l,$){const g=($==null?void 0:$[e][u])||a,d=ee(g);if(d)return d;if(c!==void 0)return c;throw new Error(`\`${l}\` must be used within \`${r}\``)}return i.displayName=r+"Provider",[i,f]}const s=()=>{const r=n.map(c=>z(c));return function(a){const u=(a==null?void 0:a[e])||r;return K(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return s.scopeName=e,[o,Ge(s,...t)]}function Ge(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(r){const c=o.reduce((a,{useScope:u,scopeName:i})=>{const l=u(r)[`__scope${i}`];return{...a,...l}},{});return K(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function Ke(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ge(...e){return t=>e.forEach(n=>Ke(n,t))}function Z(...e){return D(ge(...e),e)}const Y=E((e,t)=>{const{children:n,...o}=e,s=A.toArray(n),r=s.find(We);if(r){const c=r.props.children,a=s.map(u=>u===r?A.count(c)>1?A.only(null):U(c)?c.props.children:null:u);return C(re,S({},o,{ref:t}),U(c)?W(c,void 0,a):null)}return C(re,S({},o,{ref:t}),n)});Y.displayName="Slot";const re=E((e,t)=>{const{children:n,...o}=e;return U(n)?W(n,{...Ze(o,n.props),ref:t?ge(t,n.ref):n.ref}):A.count(n)>1?A.only(null):null});re.displayName="SlotClone";const ze=({children:e})=>C(fe,null,e);function We(e){return U(e)&&e.type===ze}function Ze(e,t){const n={...t};for(const o in t){const s=e[o],r=t[o];/^on[A-Z]/.test(o)?s&&r?n[o]=(...a)=>{r(...a),s(...a)}:s&&(n[o]=s):o==="style"?n[o]={...s,...r}:o==="className"&&(n[o]=[s,r].filter(Boolean).join(" "))}return{...e,...n}}function Ye(e){const t=e+"CollectionProvider",[n,o]=ne(t),[s,r]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=g=>{const{scope:d,children:b}=g,h=v.useRef(null),m=v.useRef(new Map).current;return v.createElement(s,{scope:d,itemMap:m,collectionRef:h},b)},a=e+"CollectionSlot",u=v.forwardRef((g,d)=>{const{scope:b,children:h}=g,m=r(a,b),x=Z(d,m.collectionRef);return v.createElement(Y,{ref:x},h)}),i=e+"CollectionItemSlot",f="data-radix-collection-item",l=v.forwardRef((g,d)=>{const{scope:b,children:h,...m}=g,x=v.useRef(null),q=Z(d,x),M=r(i,b);return v.useEffect(()=>(M.itemMap.set(x,{ref:x,...m}),()=>void M.itemMap.delete(x))),v.createElement(Y,{[f]:"",ref:q},h)});function $(g){const d=r(e+"CollectionConsumer",g);return v.useCallback(()=>{const h=d.collectionRef.current;if(!h)return[];const m=Array.from(h.querySelectorAll(`[${f}]`));return Array.from(d.itemMap.values()).sort((M,j)=>m.indexOf(M.ref.current)-m.indexOf(j.ref.current))},[d.collectionRef,d.itemMap])}return[{Provider:c,Slot:u,ItemSlot:l},$,o]}const oe=globalThis!=null&&globalThis.document?pe:()=>{},He=te.useId||(()=>{});let Xe=0;function he(e){const[t,n]=te.useState(He());return oe(()=>{e||n(o=>o??String(Xe++))},[e]),e||(t?`radix-${t}`:"")}const B=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,t)=>{const n=E((o,s)=>{const{asChild:r,...c}=o,a=r?Y:t;return R(()=>{window[Symbol.for("radix-ui")]=!0},[]),C(a,S({},c,{ref:s}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function ce(e){const t=P(e);return R(()=>{t.current=e}),K(()=>(...n)=>{var o;return(o=t.current)===null||o===void 0?void 0:o.call(t,...n)},[])}function Ce({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,s]=Je({defaultProp:t,onChange:n}),r=e!==void 0,c=r?e:o,a=ce(n),u=D(i=>{if(r){const l=typeof i=="function"?i(e):i;l!==e&&a(l)}else s(i)},[r,e,s,a]);return[c,u]}function Je({defaultProp:e,onChange:t}){const n=O(e),[o]=n,s=P(o),r=ce(t);return R(()=>{s.current!==o&&(r(o),s.current=o)},[o,s,r]),n}const Qe=z(void 0);function xe(e){const t=ee(Qe);return e||t||"ltr"}const se="rovingFocusGroup.onEntryFocus",et={bubbles:!1,cancelable:!0},ae="RovingFocusGroup",[ie,ye,tt]=Ye(ae),[nt,Ie]=ne(ae,[tt]),[rt,ot]=nt(ae),ct=E((e,t)=>C(ie.Provider,{scope:e.__scopeRovingFocusGroup},C(ie.Slot,{scope:e.__scopeRovingFocusGroup},C(st,S({},e,{ref:t}))))),st=E((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:s=!1,dir:r,currentTabStopId:c,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:i,...f}=e,l=P(null),$=Z(t,l),g=xe(r),[d=null,b]=Ce({prop:c,defaultProp:a,onChange:u}),[h,m]=O(!1),x=ce(i),q=ye(n),M=P(!1),[j,k]=O(0);return R(()=>{const y=l.current;if(y)return y.addEventListener(se,x),()=>y.removeEventListener(se,x)},[x]),C(rt,{scope:n,orientation:o,dir:g,loop:s,currentTabStopId:d,onItemFocus:D(y=>b(y),[b]),onItemShiftTab:D(()=>m(!0),[]),onFocusableItemAdd:D(()=>k(y=>y+1),[]),onFocusableItemRemove:D(()=>k(y=>y-1),[])},C(B.div,S({tabIndex:h||j===0?-1:0,"data-orientation":o},f,{ref:$,style:{outline:"none",...e.style},onMouseDown:F(e.onMouseDown,()=>{M.current=!0}),onFocus:F(e.onFocus,y=>{const de=!M.current;if(y.target===y.currentTarget&&de&&!h){const X=new CustomEvent(se,et);if(y.currentTarget.dispatchEvent(X),!X.defaultPrevented){const G=q().filter(I=>I.focusable),p=G.find(I=>I.active),w=G.find(I=>I.id===d),J=[p,w,...G].filter(Boolean).map(I=>I.ref.current);Se(J)}}M.current=!1}),onBlur:F(e.onBlur,()=>m(!1))})))}),at="RovingFocusGroupItem",it=E((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:s=!1,tabStopId:r,...c}=e,a=he(),u=r||a,i=ot(at,n),f=i.currentTabStopId===u,l=ye(n),{onFocusableItemAdd:$,onFocusableItemRemove:g}=i;return R(()=>{if(o)return $(),()=>g()},[o,$,g]),C(ie.ItemSlot,{scope:n,id:u,focusable:o,active:s},C(B.span,S({tabIndex:f?0:-1,"data-orientation":i.orientation},c,{ref:t,onMouseDown:F(e.onMouseDown,d=>{o?i.onItemFocus(u):d.preventDefault()}),onFocus:F(e.onFocus,()=>i.onItemFocus(u)),onKeyDown:F(e.onKeyDown,d=>{if(d.key==="Tab"&&d.shiftKey){i.onItemShiftTab();return}if(d.target!==d.currentTarget)return;const b=dt(d,i.orientation,i.dir);if(b!==void 0){d.preventDefault();let m=l().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")m.reverse();else if(b==="prev"||b==="next"){b==="prev"&&m.reverse();const x=m.indexOf(d.currentTarget);m=i.loop?ft(m,x+1):m.slice(x+1)}setTimeout(()=>Se(m))}})})))}),ut={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lt(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dt(e,t,n){const o=lt(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return ut[o]}function Se(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ft(e,t){return e.map((n,o)=>e[(t+o)%e.length])}const pt=ct,bt=it;function $t(e,t){return be((n,o)=>{const s=t[n][o];return s??n},e)}const we=e=>{const{present:t,children:n}=e,o=vt(t),s=typeof n=="function"?n({present:o.isPresent}):A.only(n),r=Z(o.ref,s.ref);return typeof n=="function"||o.isPresent?W(s,{ref:r}):null};we.displayName="Presence";function vt(e){const[t,n]=O(),o=P({}),s=P(e),r=P("none"),c=e?"mounted":"unmounted",[a,u]=$t(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return R(()=>{const i=H(o.current);r.current=a==="mounted"?i:"none"},[a]),oe(()=>{const i=o.current,f=s.current;if(f!==e){const $=r.current,g=H(i);e?u("MOUNT"):g==="none"||(i==null?void 0:i.display)==="none"?u("UNMOUNT"):u(f&&$!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,u]),oe(()=>{if(t){const i=l=>{const g=H(o.current).includes(l.animationName);l.target===t&&g&&ve(()=>u("ANIMATION_END"))},f=l=>{l.target===t&&(r.current=H(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",i),t.addEventListener("animationend",i),()=>{t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",i),t.removeEventListener("animationend",i)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:D(i=>{i&&(o.current=getComputedStyle(i)),n(i)},[])}}function H(e){return(e==null?void 0:e.animationName)||"none"}const Ee="Tabs",[mt,Yt]=ne(Ee,[Ie]),Te=Ie(),[_t,ue]=mt(Ee),gt=E((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:s,defaultValue:r,orientation:c="horizontal",dir:a,activationMode:u="automatic",...i}=e,f=xe(a),[l,$]=Ce({prop:o,onChange:s,defaultProp:r});return C(_t,{scope:n,baseId:he(),value:l,onValueChange:$,orientation:c,dir:f,activationMode:u},C(B.div,S({dir:f,"data-orientation":c},i,{ref:t})))}),ht="TabsList",Ct=E((e,t)=>{const{__scopeTabs:n,loop:o=!0,...s}=e,r=ue(ht,n),c=Te(n);return C(pt,S({asChild:!0},c,{orientation:r.orientation,dir:r.dir,loop:o}),C(B.div,S({role:"tablist","aria-orientation":r.orientation},s,{ref:t})))}),xt="TabsTrigger",yt=E((e,t)=>{const{__scopeTabs:n,value:o,disabled:s=!1,...r}=e,c=ue(xt,n),a=Te(n),u=Ne(c.baseId,o),i=Ae(c.baseId,o),f=o===c.value;return C(bt,S({asChild:!0},a,{focusable:!s,active:f}),C(B.button,S({type:"button",role:"tab","aria-selected":f,"aria-controls":i,"data-state":f?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:u},r,{ref:t,onMouseDown:F(e.onMouseDown,l=>{!s&&l.button===0&&l.ctrlKey===!1?c.onValueChange(o):l.preventDefault()}),onKeyDown:F(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&c.onValueChange(o)}),onFocus:F(e.onFocus,()=>{const l=c.activationMode!=="manual";!f&&!s&&l&&c.onValueChange(o)})})))}),It="TabsContent",St=E((e,t)=>{const{__scopeTabs:n,value:o,forceMount:s,children:r,...c}=e,a=ue(It,n),u=Ne(a.baseId,o),i=Ae(a.baseId,o),f=o===a.value,l=P(f);return R(()=>{const $=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame($)},[]),C(we,{present:s||f},({present:$})=>C(B.div,S({"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!$,id:i,tabIndex:0},c,{ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0}}),$&&r))});function Ne(e,t){return`${e}-trigger-${t}`}function Ae(e,t){return`${e}-content-${t}`}const wt=gt,Et=Ct,Tt=yt,Nt=St;function At(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Re={exports:{}};/*!
|
|
5
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",c=0;c<arguments.length;c++){var a=arguments[c];a&&(r=s(r,o.call(this,a)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var c="";for(var a in r)t.call(r,a)&&r[a]&&(c=s(c,this&&this[a]||a));return c}function s(r,c){return c?r?r+" "+c:r+c:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(me);var Me=me.exports;const Fe=_(Me),Oe={"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"},De={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"},qe={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"},Le=Fe.bind(Oe),_e="purpur-icon",Ve="md",Ue=e=>e.filter(t=>Object.keys(t).length>=1).map(t=>`${t.name}="${t.value}"`).join(" "),je=({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 ${Ue(n)}>${o}${e}</svg>`},Be=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),ke=({["data-testid"]:e,svg:t,allyTitle:n,className:o="",size:s=Ve,...r})=>{const c=je({content:Be(t.svg),title:n}),a=Le(o,_e,`${_e}--${s}`);return $e("span",{"aria-label":n,className:a,"data-testid":e,dangerouslySetInnerHTML:{__html:c},...r})};function S(){return S=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},S.apply(this,arguments)}function O(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function ne(e,t=[]){let n=[];function o(r,c){const a=z(c),u=n.length;n=[...n,c];function i(l){const{scope:$,children:g,...d}=l,b=($==null?void 0:$[e][u])||a,h=K(()=>d,Object.values(d));return C(b.Provider,{value:h},g)}function f(l,$){const g=($==null?void 0:$[e][u])||a,d=ee(g);if(d)return d;if(c!==void 0)return c;throw new Error(`\`${l}\` must be used within \`${r}\``)}return i.displayName=r+"Provider",[i,f]}const s=()=>{const r=n.map(c=>z(c));return function(a){const u=(a==null?void 0:a[e])||r;return K(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return s.scopeName=e,[o,Ge(s,...t)]}function Ge(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(r){const c=o.reduce((a,{useScope:u,scopeName:i})=>{const l=u(r)[`__scope${i}`];return{...a,...l}},{});return K(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function Ke(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ge(...e){return t=>e.forEach(n=>Ke(n,t))}function H(...e){return D(ge(...e),e)}const Y=E((e,t)=>{const{children:n,...o}=e,s=A.toArray(n),r=s.find(We);if(r){const c=r.props.children,a=s.map(u=>u===r?A.count(c)>1?A.only(null):U(c)?c.props.children:null:u);return C(re,S({},o,{ref:t}),U(c)?W(c,void 0,a):null)}return C(re,S({},o,{ref:t}),n)});Y.displayName="Slot";const re=E((e,t)=>{const{children:n,...o}=e;return U(n)?W(n,{...He(o,n.props),ref:t?ge(t,n.ref):n.ref}):A.count(n)>1?A.only(null):null});re.displayName="SlotClone";const ze=({children:e})=>C(fe,null,e);function We(e){return U(e)&&e.type===ze}function He(e,t){const n={...t};for(const o in t){const s=e[o],r=t[o];/^on[A-Z]/.test(o)?s&&r?n[o]=(...a)=>{r(...a),s(...a)}:s&&(n[o]=s):o==="style"?n[o]={...s,...r}:o==="className"&&(n[o]=[s,r].filter(Boolean).join(" "))}return{...e,...n}}function Ye(e){const t=e+"CollectionProvider",[n,o]=ne(t),[s,r]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=g=>{const{scope:d,children:b}=g,h=v.useRef(null),m=v.useRef(new Map).current;return v.createElement(s,{scope:d,itemMap:m,collectionRef:h},b)},a=e+"CollectionSlot",u=v.forwardRef((g,d)=>{const{scope:b,children:h}=g,m=r(a,b),x=H(d,m.collectionRef);return v.createElement(Y,{ref:x},h)}),i=e+"CollectionItemSlot",f="data-radix-collection-item",l=v.forwardRef((g,d)=>{const{scope:b,children:h,...m}=g,x=v.useRef(null),q=H(d,x),M=r(i,b);return v.useEffect(()=>(M.itemMap.set(x,{ref:x,...m}),()=>void M.itemMap.delete(x))),v.createElement(Y,{[f]:"",ref:q},h)});function $(g){const d=r(e+"CollectionConsumer",g);return v.useCallback(()=>{const h=d.collectionRef.current;if(!h)return[];const m=Array.from(h.querySelectorAll(`[${f}]`));return Array.from(d.itemMap.values()).sort((M,B)=>m.indexOf(M.ref.current)-m.indexOf(B.ref.current))},[d.collectionRef,d.itemMap])}return[{Provider:c,Slot:u,ItemSlot:l},$,o]}const oe=globalThis!=null&&globalThis.document?pe:()=>{},Ze=te.useId||(()=>{});let Xe=0;function he(e){const[t,n]=te.useState(Ze());return oe(()=>{e||n(o=>o??String(Xe++))},[e]),e||(t?`radix-${t}`:"")}const j=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,t)=>{const n=E((o,s)=>{const{asChild:r,...c}=o,a=r?Y:t;return R(()=>{window[Symbol.for("radix-ui")]=!0},[]),C(a,S({},c,{ref:s}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function ce(e){const t=P(e);return R(()=>{t.current=e}),K(()=>(...n)=>{var o;return(o=t.current)===null||o===void 0?void 0:o.call(t,...n)},[])}function Ce({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,s]=Je({defaultProp:t,onChange:n}),r=e!==void 0,c=r?e:o,a=ce(n),u=D(i=>{if(r){const l=typeof i=="function"?i(e):i;l!==e&&a(l)}else s(i)},[r,e,s,a]);return[c,u]}function Je({defaultProp:e,onChange:t}){const n=F(e),[o]=n,s=P(o),r=ce(t);return R(()=>{s.current!==o&&(r(o),s.current=o)},[o,s,r]),n}const Qe=z(void 0);function xe(e){const t=ee(Qe);return e||t||"ltr"}const se="rovingFocusGroup.onEntryFocus",et={bubbles:!1,cancelable:!0},ae="RovingFocusGroup",[ie,ye,tt]=Ye(ae),[nt,Ie]=ne(ae,[tt]),[rt,ot]=nt(ae),ct=E((e,t)=>C(ie.Provider,{scope:e.__scopeRovingFocusGroup},C(ie.Slot,{scope:e.__scopeRovingFocusGroup},C(st,S({},e,{ref:t}))))),st=E((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:s=!1,dir:r,currentTabStopId:c,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:i,...f}=e,l=P(null),$=H(t,l),g=xe(r),[d=null,b]=Ce({prop:c,defaultProp:a,onChange:u}),[h,m]=F(!1),x=ce(i),q=ye(n),M=P(!1),[B,k]=F(0);return R(()=>{const y=l.current;if(y)return y.addEventListener(se,x),()=>y.removeEventListener(se,x)},[x]),C(rt,{scope:n,orientation:o,dir:g,loop:s,currentTabStopId:d,onItemFocus:D(y=>b(y),[b]),onItemShiftTab:D(()=>m(!0),[]),onFocusableItemAdd:D(()=>k(y=>y+1),[]),onFocusableItemRemove:D(()=>k(y=>y-1),[])},C(j.div,S({tabIndex:h||B===0?-1:0,"data-orientation":o},f,{ref:$,style:{outline:"none",...e.style},onMouseDown:O(e.onMouseDown,()=>{M.current=!0}),onFocus:O(e.onFocus,y=>{const de=!M.current;if(y.target===y.currentTarget&&de&&!h){const X=new CustomEvent(se,et);if(y.currentTarget.dispatchEvent(X),!X.defaultPrevented){const G=q().filter(I=>I.focusable),p=G.find(I=>I.active),w=G.find(I=>I.id===d),J=[p,w,...G].filter(Boolean).map(I=>I.ref.current);Se(J)}}M.current=!1}),onBlur:O(e.onBlur,()=>m(!1))})))}),at="RovingFocusGroupItem",it=E((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:s=!1,tabStopId:r,...c}=e,a=he(),u=r||a,i=ot(at,n),f=i.currentTabStopId===u,l=ye(n),{onFocusableItemAdd:$,onFocusableItemRemove:g}=i;return R(()=>{if(o)return $(),()=>g()},[o,$,g]),C(ie.ItemSlot,{scope:n,id:u,focusable:o,active:s},C(j.span,S({tabIndex:f?0:-1,"data-orientation":i.orientation},c,{ref:t,onMouseDown:O(e.onMouseDown,d=>{o?i.onItemFocus(u):d.preventDefault()}),onFocus:O(e.onFocus,()=>i.onItemFocus(u)),onKeyDown:O(e.onKeyDown,d=>{if(d.key==="Tab"&&d.shiftKey){i.onItemShiftTab();return}if(d.target!==d.currentTarget)return;const b=dt(d,i.orientation,i.dir);if(b!==void 0){d.preventDefault();let m=l().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")m.reverse();else if(b==="prev"||b==="next"){b==="prev"&&m.reverse();const x=m.indexOf(d.currentTarget);m=i.loop?ft(m,x+1):m.slice(x+1)}setTimeout(()=>Se(m))}})})))}),ut={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lt(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dt(e,t,n){const o=lt(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return ut[o]}function Se(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ft(e,t){return e.map((n,o)=>e[(t+o)%e.length])}const pt=ct,bt=it;function $t(e,t){return be((n,o)=>{const s=t[n][o];return s??n},e)}const we=e=>{const{present:t,children:n}=e,o=vt(t),s=typeof n=="function"?n({present:o.isPresent}):A.only(n),r=H(o.ref,s.ref);return typeof n=="function"||o.isPresent?W(s,{ref:r}):null};we.displayName="Presence";function vt(e){const[t,n]=F(),o=P({}),s=P(e),r=P("none"),c=e?"mounted":"unmounted",[a,u]=$t(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return R(()=>{const i=Z(o.current);r.current=a==="mounted"?i:"none"},[a]),oe(()=>{const i=o.current,f=s.current;if(f!==e){const $=r.current,g=Z(i);e?u("MOUNT"):g==="none"||(i==null?void 0:i.display)==="none"?u("UNMOUNT"):u(f&&$!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,u]),oe(()=>{if(t){const i=l=>{const g=Z(o.current).includes(l.animationName);l.target===t&&g&&ve(()=>u("ANIMATION_END"))},f=l=>{l.target===t&&(r.current=Z(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",i),t.addEventListener("animationend",i),()=>{t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",i),t.removeEventListener("animationend",i)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:D(i=>{i&&(o.current=getComputedStyle(i)),n(i)},[])}}function Z(e){return(e==null?void 0:e.animationName)||"none"}const Ee="Tabs",[mt,Yt]=ne(Ee,[Ie]),Te=Ie(),[_t,ue]=mt(Ee),gt=E((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:s,defaultValue:r,orientation:c="horizontal",dir:a,activationMode:u="automatic",...i}=e,f=xe(a),[l,$]=Ce({prop:o,onChange:s,defaultProp:r});return C(_t,{scope:n,baseId:he(),value:l,onValueChange:$,orientation:c,dir:f,activationMode:u},C(j.div,S({dir:f,"data-orientation":c},i,{ref:t})))}),ht="TabsList",Ct=E((e,t)=>{const{__scopeTabs:n,loop:o=!0,...s}=e,r=ue(ht,n),c=Te(n);return C(pt,S({asChild:!0},c,{orientation:r.orientation,dir:r.dir,loop:o}),C(j.div,S({role:"tablist","aria-orientation":r.orientation},s,{ref:t})))}),xt="TabsTrigger",yt=E((e,t)=>{const{__scopeTabs:n,value:o,disabled:s=!1,...r}=e,c=ue(xt,n),a=Te(n),u=Ne(c.baseId,o),i=Ae(c.baseId,o),f=o===c.value;return C(bt,S({asChild:!0},a,{focusable:!s,active:f}),C(j.button,S({type:"button",role:"tab","aria-selected":f,"aria-controls":i,"data-state":f?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:u},r,{ref:t,onMouseDown:O(e.onMouseDown,l=>{!s&&l.button===0&&l.ctrlKey===!1?c.onValueChange(o):l.preventDefault()}),onKeyDown:O(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&c.onValueChange(o)}),onFocus:O(e.onFocus,()=>{const l=c.activationMode!=="manual";!f&&!s&&l&&c.onValueChange(o)})})))}),It="TabsContent",St=E((e,t)=>{const{__scopeTabs:n,value:o,forceMount:s,children:r,...c}=e,a=ue(It,n),u=Ne(a.baseId,o),i=Ae(a.baseId,o),f=o===a.value,l=P(f);return R(()=>{const $=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame($)},[]),C(we,{present:s||f},({present:$})=>C(j.div,S({"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!$,id:i,tabIndex:0},c,{ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0}}),$&&r))});function Ne(e,t){return`${e}-trigger-${t}`}function Ae(e,t){return`${e}-content-${t}`}const wt=gt,Et=Ct,Tt=yt,Nt=St;function At(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Re={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 r="",c=0;c<arguments.length;c++){var a=arguments[c];a&&(r=s(r,o.call(this,a)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var c="";for(var a in r)t.call(r,a)&&r[a]&&(c=s(c,this&&this[a]||a));return c}function s(r,c){return c?r?r+" "+c:r+c:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Re);var Rt=Re.exports;const le=At(Rt),Pt={"purpur-tab-content":"_purpur-tab-content_rbfjg_1"},Mt=le.bind(Pt),
|
|
9
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",c=0;c<arguments.length;c++){var a=arguments[c];a&&(r=s(r,o.call(this,a)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var c="";for(var a in r)t.call(r,a)&&r[a]&&(c=s(c,this&&this[a]||a));return c}function s(r,c){return c?r?r+" "+c:r+c:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Re);var Rt=Re.exports;const le=At(Rt),Pt={"purpur-tab-content":"_purpur-tab-content_rbfjg_1"},Mt=le.bind(Pt),Ft="purpur-tab-content",Ot=E(({children:e,tabId:t,"data-testid":n,className:o,...s},r)=>v.createElement(Nt,{ref:r,className:Mt([Ft,o]),"data-testid":n,value:t,...s},e)),Dt=e=>!!e&&U(e)&&!!e.props.name&&!!e.props.tabId,qt={"purpur-tab-header":"_purpur-tab-header_1hk4f_1","purpur-tab-header--contained":"_purpur-tab-header--contained_1hk4f_32","purpur-tab-header--contained-negative":"_purpur-tab-header--contained-negative_1hk4f_32","purpur-tab-header--line":"_purpur-tab-header--line_1hk4f_35","purpur-tab-header--line-negative":"_purpur-tab-header--line-negative_1hk4f_47"},Lt=le.bind(qt),Pe="purpur-tab-header",Vt=E(({index:e,tabId:t,variant:n,onFocus:o,"data-testid":s,children:r},c)=>v.createElement(Tt,{id:`${t}-trigger`,className:Lt([Pe,`${Pe}--${n}`]),value:t,"data-testid":s,"data-index":e,ref:c,onFocus:o},r)),Ut={"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"},Zt=Q("tabsVariants",["line","line-negative","contained","contained-negative"]),jt=Q("createTabChangeDetailEvent",e=>new CustomEvent("tabChangeDetail",{detail:{value:e}})),L=le.bind(Ut),T="purpur-tabs",Bt=(e,t)=>{var u;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(),s=t.clientWidth,r=parseInt((u=getComputedStyle(t).borderLeftWidth)==null?void 0:u.split("px")[0],10),c=o.left+(isNaN(r)?0:r);let a;n.right>o.right&&(a=n.left+t.scrollLeft,a=a+n.width-s+s*.1,a=a-c),n.left<o.left&&(a=n.left+t.scrollLeft,a=a-s*.1,a=a-c),a!==void 0&&t.scroll({left:a,behavior:"smooth"})},kt=Q("Tabs",({children:e,variant:t="line",fullWidth:n=!1,onChange:o,className:s,"data-testid":r,...c})=>{const[a,u]=F(0),[i,f]=F({}),[l,$]=F(0),[g,d]=F(0),b=A.toArray(e).filter(Dt),h=P(),m=P(new Array(b.length)),x=200,q=t==="line"||t==="line-negative",M=L([T,`${T}--${t}`,{[`${T}--fullWidth`]:n},s]),B=A.map(b,({props:{tabId:p}})=>p);if(new Set(B).size!==B.length)throw new Error("tabId must be unique");const k=(p,w)=>w||r?`${w||r}-${p}`:void 0,y=()=>{if(!q)return;const p=m.current[a];$((p==null?void 0:p.offsetLeft)||0),d((p==null?void 0:p.getBoundingClientRect().width)||0)},de=p=>{q&&u(b.findIndex(w=>w.props.tabId===p)),o==null||o(jt(p))},X=p=>{if(h!=null&&h.current){const{scrollLeft:w}=h.current,N=p==="left"?-x:x;h.current.scroll({left:w+N,behavior:"smooth"})}},G=({side:p})=>v.createElement("button",{className:L(`${T}__scroll-button`,`${T}__scroll-button--${p}`),onClick:()=>X(p),type:"button","aria-hidden":"true",tabIndex:-1,"data-testid":k("scroll-button")},v.createElement(ke,{svg:p==="left"?De:qe,size:"md"}));return R(()=>(window.addEventListener("resize",y),()=>{window.removeEventListener("resize",y)}),[]),R(()=>{y()},[a,n,b,t]),R(()=>{const p=N=>{if(N.every(I=>I.isIntersecting)&&N.length===b.length){f({});return}N.forEach(I=>{const V=Number(I.target.getAttribute("data-index")),Gt=V===0,Kt=V===b.length-1;f(zt=>({...zt,...Gt&&{[`${T}__wrapper--scroll-end`]:!I.isIntersecting},...Kt&&{[`${T}__wrapper--scroll-start`]:!I.isIntersecting}}))})},w=new IntersectionObserver(p,{threshold:[.99],root:h.current});return m.current.forEach(N=>w.observe(N)),()=>{m.current.forEach(N=>w.unobserve(N))}},[b.length]),v.createElement(wt,{defaultValue:b[0].props.tabId,onValueChange:de,"data-testid":r,className:M,...c},v.createElement("div",{className:L(`${T}__container`)},v.createElement("div",{className:L([`${T}__wrapper`,i])},v.createElement(Et,{ref:p=>{h.current=p},className:L(`${T}__list`)},A.map(b,(p,w)=>{const{name:N,tabId:J,"data-testid":I}=p.props;return v.createElement(Vt,{"data-testid":k("header",I),index:w,tabId:J,ref:V=>{V&&(m.current[w]=V)},onFocus:V=>{Bt(V.target,h.current)},variant:t},N)}),q&&v.createElement("div",{className:L(`${T}__selected-border`),style:{width:g,transform:`translateX(${l}px)`},"data-testid":k("selected-border")})),v.createElement(G,{side:"left"}),v.createElement(G,{side:"right"})),v.createElement("div",{className:L(`${T}__content-container`)},A.map(b,p=>p))))});kt.Content=Ot}}});
|
|
10
10
|
//# sourceMappingURL=tabs.system.js.map
|