All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.Tabs-CMdqT4Cg.js Maven / Gradle / Ivy

import{_ as I,dn as z,m as g,i as G,I as ye,c3 as we,n as Y,bY as Le,bV as Ce,bW as Be,bX as Ie,bZ as Ae,dp as D,dq as _e,ch as oe,dr as ie,bU as Ne,cd as re,cf as ke,cc as ce,cb as Ke,H as Re}from"./main-C7ps2lmX.js";import*as e from"react";import h from"react";const l={button:"pf-v5-c-button",dirRtl:"pf-v5-m-dir-rtl",modifiers:{fill:"pf-m-fill",scrollable:"pf-m-scrollable",noBorderBottom:"pf-m-no-border-bottom",box:"pf-m-box",vertical:"pf-m-vertical",current:"pf-m-current",colorSchemeLight_300:"pf-m-color-scheme--light-300",expandable:"pf-m-expandable",nonExpandable:"pf-m-non-expandable",expandableOnSm:"pf-m-expandable-on-sm",nonExpandableOnSm:"pf-m-non-expandable-on-sm",expandableOnMd:"pf-m-expandable-on-md",nonExpandableOnMd:"pf-m-non-expandable-on-md",expandableOnLg:"pf-m-expandable-on-lg",nonExpandableOnLg:"pf-m-non-expandable-on-lg",expandableOnXl:"pf-m-expandable-on-xl",nonExpandableOnXl:"pf-m-non-expandable-on-xl",expandableOn_2xl:"pf-m-expandable-on-2xl",nonExpandableOn_2xl:"pf-m-non-expandable-on-2xl",expanded:"pf-m-expanded",secondary:"pf-m-secondary",pageInsets:"pf-m-page-insets",overflow:"pf-m-overflow",action:"pf-m-action",active:"pf-m-active",disabled:"pf-m-disabled",ariaDisabled:"pf-m-aria-disabled",insetNone:"pf-m-inset-none",insetSm:"pf-m-inset-sm",insetMd:"pf-m-inset-md",insetLg:"pf-m-inset-lg",insetXl:"pf-m-inset-xl",inset_2xl:"pf-m-inset-2xl",insetNoneOnSm:"pf-m-inset-none-on-sm",insetSmOnSm:"pf-m-inset-sm-on-sm",insetMdOnSm:"pf-m-inset-md-on-sm",insetLgOnSm:"pf-m-inset-lg-on-sm",insetXlOnSm:"pf-m-inset-xl-on-sm",inset_2xlOnSm:"pf-m-inset-2xl-on-sm",insetNoneOnMd:"pf-m-inset-none-on-md",insetSmOnMd:"pf-m-inset-sm-on-md",insetMdOnMd:"pf-m-inset-md-on-md",insetLgOnMd:"pf-m-inset-lg-on-md",insetXlOnMd:"pf-m-inset-xl-on-md",inset_2xlOnMd:"pf-m-inset-2xl-on-md",insetNoneOnLg:"pf-m-inset-none-on-lg",insetSmOnLg:"pf-m-inset-sm-on-lg",insetMdOnLg:"pf-m-inset-md-on-lg",insetLgOnLg:"pf-m-inset-lg-on-lg",insetXlOnLg:"pf-m-inset-xl-on-lg",inset_2xlOnLg:"pf-m-inset-2xl-on-lg",insetNoneOnXl:"pf-m-inset-none-on-xl",insetSmOnXl:"pf-m-inset-sm-on-xl",insetMdOnXl:"pf-m-inset-md-on-xl",insetLgOnXl:"pf-m-inset-lg-on-xl",insetXlOnXl:"pf-m-inset-xl-on-xl",inset_2xlOnXl:"pf-m-inset-2xl-on-xl",insetNoneOn_2xl:"pf-m-inset-none-on-2xl",insetSmOn_2xl:"pf-m-inset-sm-on-2xl",insetMdOn_2xl:"pf-m-inset-md-on-2xl",insetLgOn_2xl:"pf-m-inset-lg-on-2xl",insetXlOn_2xl:"pf-m-inset-xl-on-2xl",inset_2xlOn_2xl:"pf-m-inset-2xl-on-2xl"},tabs:"pf-v5-c-tabs",tabsAdd:"pf-v5-c-tabs__add",tabsItem:"pf-v5-c-tabs__item",tabsItemAction:"pf-v5-c-tabs__item-action",tabsItemActionIcon:"pf-v5-c-tabs__item-action-icon",tabsItemIcon:"pf-v5-c-tabs__item-icon",tabsItemText:"pf-v5-c-tabs__item-text",tabsLink:"pf-v5-c-tabs__link",tabsLinkToggleIcon:"pf-v5-c-tabs__link-toggle-icon",tabsList:"pf-v5-c-tabs__list",tabsScrollButton:"pf-v5-c-tabs__scroll-button",tabsToggle:"pf-v5-c-tabs__toggle",tabsToggleButton:"pf-v5-c-tabs__toggle-button",tabsToggleIcon:"pf-v5-c-tabs__toggle-icon",tabsToggleText:"pf-v5-c-tabs__toggle-text",themeDark:"pf-v5-theme-dark"},J=f=>{var{children:a,tabContentRef:t,ouiaId:n,parentInnerRef:o,ouiaSafe:i}=f,s=I(f,["children","tabContentRef","ouiaId","parentInnerRef","ouiaSafe"]);const m=s.href?"a":"button";return e.createElement(m,Object.assign({},!s.href&&{type:"button"},{ref:o},z(J.displayName,n,i),s),a)};J.displayName="TabButton";const F=e.createContext({variant:"default",mountOnEnter:!1,unmountOnExit:!1,localActiveKey:"",uniqueId:"",handleTabClick:()=>null,handleTabClose:void 0}),Me=F.Provider,De=F.Consumer,je=f=>{var{children:a,className:t,onClick:n,isDisabled:o,"aria-label":i="Tab action",innerRef:s,ouiaId:m,ouiaSafe:r}=f,d=I(f,["children","className","onClick","isDisabled","aria-label","innerRef","ouiaId","ouiaSafe"]);return e.createElement("span",{className:g(l.tabsItemAction,t)},e.createElement(G,Object.assign({ref:s,type:"button",variant:"plain","aria-label":i,onClick:n,isDisabled:o},z(Q.displayName,m,r),d),e.createElement("span",{className:g(l.tabsItemActionIcon)},a)))},Q=e.forwardRef((f,a)=>e.createElement(je,Object.assign({},f,{innerRef:a})));Q.displayName="TabAction";const $e=f=>{var{title:a,eventKey:t,tabContentRef:n,id:o,tabContentId:i,className:s="",ouiaId:m,isDisabled:r,isAriaDisabled:d,inoperableEvents:v=["onClick","onKeyPress"],href:u,innerRef:S,tooltip:E,closeButtonAriaLabel:R,isCloseDisabled:B=!1,actions:w}=f,A=I(f,["title","eventKey","tabContentRef","id","tabContentId","className","ouiaId","isDisabled","isAriaDisabled","inoperableEvents","href","innerRef","tooltip","closeButtonAriaLabel","isCloseDisabled","actions"]);const O=v.reduce((y,P)=>Object.assign(Object.assign({},y),{[P]:H=>{H.preventDefault()}}),{}),{mountOnEnter:_,localActiveKey:L,unmountOnExit:N,uniqueId:k,handleTabClick:M,handleTabClose:C}=e.useContext(F);let c=i?`${i}`:`pf-tab-section-${t}-${o||k}`;(_||N)&&t!==L&&(c=void 0);const p=!u,x=()=>{if(r)return p?null:-1;if(d)return null},T=e.createElement(J,Object.assign({parentInnerRef:S,className:g(l.tabsLink,r&&u&&l.modifiers.disabled,d&&l.modifiers.ariaDisabled),disabled:p?r:null,"aria-disabled":r||d,tabIndex:x(),onClick:y=>M(y,t,n)},d?O:null,{id:`pf-tab-${t}-${o||k}`,"aria-controls":c,tabContentRef:n,ouiaId:m,href:u,role:"tab","aria-selected":t===L},A),a);return e.createElement("li",{className:g(l.tabsItem,t===L&&l.modifiers.current,(C||w)&&l.modifiers.action,(r||d)&&l.modifiers.disabled,s),role:"presentation"},E?e.createElement(ye,Object.assign({},E.props),T):T,w&&w,C!==void 0&&e.createElement(Q,{"aria-label":R||"Close tab",onClick:y=>C(y,t,n),isDisabled:B},e.createElement(we,null)))},Ve=e.forwardRef((f,a)=>e.createElement($e,Object.assign({innerRef:a},f)));Ve.displayName="Tab";const Z={modifiers:{light_300:"pf-m-light-300",padding:"pf-m-padding"},tabContent:"pf-v5-c-tab-content",tabContentBody:"pf-v5-c-tab-content__body"},de={default:"",light300:Z.modifiers.light_300},Xe=f=>{var{id:a,activeKey:t,"aria-label":n,child:o,children:i,className:s,eventKey:m,innerRef:r,ouiaId:d,ouiaSafe:v}=f,u=I(f,["id","activeKey","aria-label","child","children","className","eventKey","innerRef","ouiaId","ouiaSafe"]);if(i||o){let S;return n?S=null:S=i?`${a}`:`pf-tab-${o.props.eventKey}-${a}`,e.createElement(De,null,({variant:E})=>e.createElement("section",Object.assign({ref:r,hidden:i?null:o.props.eventKey!==t,className:i?g(Z.tabContent,s,de[E]):g(Z.tabContent,o.props.className,de[E]),id:i?a:`pf-tab-section-${o.props.eventKey}-${a}`,"aria-label":n,"aria-labelledby":S,role:"tabpanel",tabIndex:0},z("TabContent",d,v),u),i||o.props.children))}return null},ze=e.forwardRef((f,a)=>e.createElement(Xe,Object.assign({},f,{innerRef:a}))),fe=f=>{var{children:a,className:t=""}=f,n=I(f,["children","className"]);return e.createElement("span",Object.assign({className:g(l.tabsItemText,t)},n),a)};fe.displayName="TabTitleText";const me=f=>{var{className:a,overflowingTabs:t=[],showTabCount:n,defaultTitleText:o="More",toggleAriaLabel:i,zIndex:s=9999}=f,m=I(f,["className","overflowingTabs","showTabCount","defaultTitleText","toggleAriaLabel","zIndex"]);const r=h.useRef(),d=h.useRef(),v=h.useRef(),[u,S]=h.useState(!1),{localActiveKey:E,handleTabClick:R}=h.useContext(F),B=()=>{S(!1),d.current.focus()},w=c=>{var p;const x=(p=r?.current)===null||p===void 0?void 0:p.contains(c.target);u&&x&&c.key==="Escape"&&B()},A=c=>{var p,x;const T=!(!((p=r?.current)===null||p===void 0)&&p.contains(c.target)),y=!(!((x=d?.current)===null||x===void 0)&&x.contains(c.target));u&&T&&y&&B()};h.useEffect(()=>(window.addEventListener("click",A),window.addEventListener("keydown",w),()=>{window.removeEventListener("click",A),window.removeEventListener("keydown",w)}),[u,r,d]);const O=t.find(c=>c.eventKey===E),_=O?.title?O.title:o,L=()=>{S(c=>!c),setTimeout(()=>{if(r?.current){const c=r.current.querySelector("li > button,input:not(:disabled)");c&&c.focus()}},0)},N=h.createElement("li",Object.assign({className:g(l.tabsItem,l.modifiers.overflow,O&&l.modifiers.current,a),role:"presentation",ref:v},m),h.createElement("button",{type:"button",className:g(l.tabsLink,u&&l.modifiers.expanded),onClick:()=>L(),"aria-label":i,"aria-haspopup":"menu","aria-expanded":u,role:"tab",ref:d},h.createElement(fe,null,_,n&&_===o&&` (${t.length})`),h.createElement("span",{className:l.tabsLinkToggleIcon},h.createElement(Y,null)))),k=t.map(c=>h.createElement(Le,{key:c.eventKey,itemId:c.eventKey,isSelected:E===c.eventKey},c.title)),M=(c,p)=>{B();const x=t.find(T=>T.eventKey===p).tabContentRef;R(c,p,x)},C=h.createElement(Ce,{ref:r,onSelect:(c,p)=>M(c,p)},h.createElement(Be,null,h.createElement(Ie,null,k)));return h.createElement(h.Fragment,null,N,h.createElement(Ae,{triggerRef:d,popper:C,popperRef:r,isVisible:u,minWidth:"revert",appendTo:v.current,zIndex:s}))};me.displayName="OverflowTab";var X;(function(f){f.div="div",f.nav="nav"})(X||(X={}));const Fe={default:"",light300:l.modifiers.colorSchemeLight_300};class j extends e.Component{constructor(a){super(a),this.tabList=e.createRef(),this.leftScrollButtonRef=e.createRef(),this.direction="ltr",this.scrollTimeout=null,this.countOverflowingElements=t=>Array.from(t.children).filter(o=>!D(t,o)).length,this.handleScrollButtons=()=>{const{isOverflowHorizontal:t}=this.props;clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{const n=this.tabList.current;let o=!0,i=!0,s=!1,m=0;if(n&&!this.props.isVertical&&!t){const r=!D(n,n.firstChild),d=!D(n,n.lastChild);s=r||d,o=!r,i=!d}t&&(m=this.countOverflowingElements(n)),this.setState({enableScrollButtons:s,disableBackScrollButton:o,disableForwardScrollButton:i,overflowingTabCount:m})},100)},this.scrollBack=()=>{if(this.tabList.current){const t=this.tabList.current,n=Array.from(t.children);let o,i,s;for(s=0;s{if(this.tabList.current){const t=this.tabList.current,n=Array.from(t.children);let o,i;for(let s=n.length-1;s>=0&&!o;s--)D(t,n[s])&&(o=n[s],i=n[s+1]);i&&(this.direction==="ltr"?t.scrollLeft+=i.scrollWidth:t.scrollLeft-=i.scrollWidth)}},this.hideScrollButtons=()=>{const{enableScrollButtons:t,renderScrollButtons:n,showScrollButtons:o}=this.state;!t&&!o&&n&&this.setState({renderScrollButtons:!1})},this.state={enableScrollButtons:!1,showScrollButtons:!1,renderScrollButtons:!1,disableBackScrollButton:!0,disableForwardScrollButton:!0,shownKeys:this.props.defaultActiveKey!==void 0?[this.props.defaultActiveKey]:[this.props.activeKey],uncontrolledActiveKey:this.props.defaultActiveKey,uncontrolledIsExpandedLocal:this.props.defaultIsExpanded,ouiaStateId:_e(j.displayName),overflowingTabCount:0},this.props.isVertical&&this.props.expandable!==void 0&&!this.props.toggleAriaLabel&&!this.props.toggleText&&console.error("Tabs:","toggleAriaLabel or the toggleText prop is required to make the toggle button accessible")}handleTabClick(a,t,n){const{shownKeys:o}=this.state,{onSelect:i,defaultActiveKey:s}=this.props;s!==void 0?this.setState({uncontrolledActiveKey:t}):i(a,t),n&&(e.Children.toArray(this.props.children).filter(m=>e.isValidElement(m)).filter(({props:m})=>m.tabContentRef&&m.tabContentRef.current).forEach(m=>m.props.tabContentRef.current.hidden=!0),n.current&&(n.current.hidden=!1)),this.props.mountOnEnter&&this.setState({shownKeys:o.concat(t)})}componentDidMount(){this.props.isVertical||(oe&&window.addEventListener("resize",this.handleScrollButtons,!1),this.direction=ie(this.tabList.current),this.handleScrollButtons())}componentWillUnmount(){var a;this.props.isVertical||oe&&window.removeEventListener("resize",this.handleScrollButtons,!1),clearTimeout(this.scrollTimeout),(a=this.leftScrollButtonRef.current)===null||a===void 0||a.removeEventListener("transitionend",this.hideScrollButtons)}componentDidUpdate(a,t){const{activeKey:n,mountOnEnter:o,isOverflowHorizontal:i,children:s}=this.props,{shownKeys:m,overflowingTabCount:r,enableScrollButtons:d}=this.state;a.activeKey!==n&&o&&m.indexOf(n)<0&&this.setState({shownKeys:m.concat(n)}),a.children&&s&&e.Children.toArray(a.children).length!==e.Children.toArray(s).length&&this.handleScrollButtons();const v=this.countOverflowingElements(this.tabList.current);i&&v&&this.setState({overflowingTabCount:v+r}),!t.enableScrollButtons&&d?(this.setState({renderScrollButtons:!0}),setTimeout(()=>{var u;(u=this.leftScrollButtonRef.current)===null||u===void 0||u.addEventListener("transitionend",this.hideScrollButtons),this.setState({showScrollButtons:!0})},100)):t.enableScrollButtons&&!d&&this.setState({showScrollButtons:!1}),this.direction=ie(this.tabList.current)}render(){const a=this.props,{className:t,children:n,activeKey:o,defaultActiveKey:i,id:s,isFilled:m,isSecondary:r,isVertical:d,isBox:v,hasNoBorderBottom:u,leftScrollAriaLabel:S,rightScrollAriaLabel:E,backScrollAriaLabel:R,forwardScrollAriaLabel:B,"aria-label":w,component:A,ouiaId:O,ouiaSafe:_,mountOnEnter:L,unmountOnExit:N,usePageInsets:k,inset:M,variant:C,expandable:c,isExpanded:p,defaultIsExpanded:x,toggleText:T,toggleAriaLabel:y,addButtonAriaLabel:P,onToggle:H,onClose:be,onAdd:ee,isOverflowHorizontal:$}=a,ue=I(a,["className","children","activeKey","defaultActiveKey","id","isFilled","isSecondary","isVertical","isBox","hasNoBorderBottom","leftScrollAriaLabel","rightScrollAriaLabel","backScrollAriaLabel","forwardScrollAriaLabel","aria-label","component","ouiaId","ouiaSafe","mountOnEnter","unmountOnExit","usePageInsets","inset","variant","expandable","isExpanded","defaultIsExpanded","toggleText","toggleAriaLabel","addButtonAriaLabel","onToggle","onClose","onAdd","isOverflowHorizontal"]),{showScrollButtons:pe,renderScrollButtons:te,disableBackScrollButton:ne,disableForwardScrollButton:le,shownKeys:he,uncontrolledActiveKey:ge,uncontrolledIsExpandedLocal:ve,overflowingTabCount:W}=this.state,K=e.Children.toArray(n).filter(b=>e.isValidElement(b)).filter(({props:b})=>!b.isHidden),xe=K.slice(0,K.length-W),Se=K.slice(K.length-W).map(b=>b.props),ae=s||Ne(),Ee=A===X.nav?"nav":"div",q=i!==void 0?ge:o,U=x!==void 0?ve:p,Oe=(b,V)=>{p===void 0?this.setState({uncontrolledIsExpandedLocal:V}):H(b,V)},se=$&&W>0,Te=typeof $=="object"?Object.assign({},$):{};return e.createElement(Me,{value:{variant:C,mountOnEnter:L,unmountOnExit:N,localActiveKey:q,uniqueId:ae,handleTabClick:(...b)=>this.handleTabClick(...b),handleTabClose:be}},e.createElement(Ee,Object.assign({"aria-label":w,className:g(l.tabs,m&&l.modifiers.fill,r&&l.modifiers.secondary,d&&l.modifiers.vertical,d&&c&&re(c,l),d&&c&&U&&l.modifiers.expanded,v&&l.modifiers.box,pe&&l.modifiers.scrollable,k&&l.modifiers.pageInsets,u&&l.modifiers.noBorderBottom,re(M,l),Fe[C],se&&l.modifiers.overflow,t)},z(j.displayName,O!==void 0?O:this.state.ouiaStateId,_),{id:s&&s},ue),c&&d&&e.createElement(ke,null,b=>e.createElement("div",{className:g(l.tabsToggle)},e.createElement("div",{className:g(l.tabsToggleButton)},e.createElement(G,{onClick:V=>Oe(V,!U),variant:"plain","aria-label":y,"aria-expanded":U,id:`${b}-button`,"aria-labelledby":`${b}-text ${b}-button`},e.createElement("span",{className:g(l.tabsToggleIcon)},e.createElement(Y,{"arian-hidden":"true"})),T&&e.createElement("span",{className:g(l.tabsToggleText),id:`${b}-text`},T))))),te&&e.createElement("button",{type:"button",className:g(l.tabsScrollButton,r&&ce.modifiers.secondary),"aria-label":R||S,onClick:this.scrollBack,disabled:ne,"aria-hidden":ne,ref:this.leftScrollButtonRef},e.createElement(Ke,null)),e.createElement("ul",{className:g(l.tabsList),ref:this.tabList,onScroll:this.handleScrollButtons,role:"tablist"},$?xe:K,se&&e.createElement(me,Object.assign({overflowingTabs:Se},Te))),te&&e.createElement("button",{type:"button",className:g(l.tabsScrollButton,r&&ce.modifiers.secondary),"aria-label":B||E,onClick:this.scrollForward,disabled:le,"aria-hidden":le},e.createElement(Y,null)),ee!==void 0&&e.createElement("span",{className:g(l.tabsAdd)},e.createElement(G,{variant:"plain","aria-label":P||"Add tab",onClick:ee},e.createElement(Re,null)))),K.filter(b=>b.props.children&&!(N&&b.props.eventKey!==q)&&!(L&&he.indexOf(b.props.eventKey)===-1)).map(b=>e.createElement(ze,{key:b.props.eventKey,activeKey:q,child:b,id:b.props.id||ae,ouiaId:b.props.ouiaId})))}}j.displayName="Tabs";j.defaultProps={activeKey:0,onSelect:()=>{},isFilled:!1,isSecondary:!1,isVertical:!1,isBox:!1,hasNoBorderBottom:!1,leftScrollAriaLabel:"Scroll left",backScrollAriaLabel:"Scroll back",rightScrollAriaLabel:"Scroll right",forwardScrollAriaLabel:"Scroll forward",component:X.div,mountOnEnter:!1,unmountOnExit:!1,ouiaSafe:!0,variant:"default",onToggle:(f,a)=>{}};export{j as T,Ve as a,fe as b,ze as c,X as d};
//# sourceMappingURL=Tabs-CMdqT4Cg.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy