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

theme.keycloak.v2.admin.resources.assets.PaginatingTableToolbar-Cjsz5Jh4.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsxs as F,jsx as u,Fragment as se}from"react/jsx-runtime";import{E as me,a as de,b as ue}from"./EmptyStateFooter-DqmBOP2I.js";import{a as ee,E as fe,b as Pe}from"./EmptyStateActions-DWNUFByn.js";import{o as le,aM as be,_ as oe,m as X,i as W,B as j,cb as he,am as ve,cG as ye,n as Le,K as xe,cH as re,bV as Se,bW as Ce,bX as Ne,bZ as Ie,bY as ke,cd as Oe,aO as Ee,bd as Ae,as as _e,a as pe,a0 as q,a1 as te,a2 as Y,bb as we,co as Te,ar as De}from"./main-C7ps2lmX.js";import*as a from"react";import{useState as Me}from"react";const Fe={name:"AngleDoubleLeftIcon",height:512,width:448,svgPath:"M223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34zm-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34z",yOffset:0,xOffset:0},Re=le(Fe),We={name:"AngleDoubleRightIcon",height:512,width:448,svgPath:"M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z",yOffset:0,xOffset:0},Xe=le(We),Z=({firstIndex:g=0,lastIndex:n=0,itemCount:t=0,itemsTitle:e="items",ofWord:r="of"})=>a.createElement(a.Fragment,null,a.createElement("b",null,g," - ",n)," ",r," ",a.createElement("b",null,t)," ",e);Z.displayName="ToggleTemplate";const v={button:"pf-v5-c-button",dirRtl:"pf-v5-m-dir-rtl",formControl:"pf-v5-c-form-control",menuToggle:"pf-v5-c-menu-toggle",modifiers:{bottom:"pf-m-bottom",static:"pf-m-static",first:"pf-m-first",last:"pf-m-last",sticky:"pf-m-sticky",compact:"pf-m-compact",pageInsets:"pf-m-page-insets",displaySummary:"pf-m-display-summary",displayFull:"pf-m-display-full",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",displaySummaryOnSm:"pf-m-display-summary-on-sm",displayFullOnSm:"pf-m-display-full-on-sm",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",displaySummaryOnMd:"pf-m-display-summary-on-md",displayFullOnMd:"pf-m-display-full-on-md",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",displaySummaryOnLg:"pf-m-display-summary-on-lg",displayFullOnLg:"pf-m-display-full-on-lg",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",displaySummaryOnXl:"pf-m-display-summary-on-xl",displayFullOnXl:"pf-m-display-full-on-xl",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",displaySummaryOn_2xl:"pf-m-display-summary-on-2xl",displayFullOn_2xl:"pf-m-display-full-on-2xl",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"},pagination:"pf-v5-c-pagination",paginationNav:"pf-v5-c-pagination__nav",paginationNavControl:"pf-v5-c-pagination__nav-control",paginationNavPageSelect:"pf-v5-c-pagination__nav-page-select",paginationTotalItems:"pf-v5-c-pagination__total-items",themeDark:"pf-v5-theme-dark"};class $ extends a.Component{constructor(n){super(n),this.handleNewPage=(t,e)=>{const{perPage:r,onSetPage:o}=this.props,p=(e-1)*r,s=e*r;return o(t,e,r,p,s)},this.state={userInputPage:this.props.page}}static parseInteger(n,t){let e=Number.parseInt(n,10);return Number.isNaN(e)||(e=e>t?t:e,e=e<1?1:e),e}onChange(n,t){const e=$.parseInteger(n.currentTarget.value,t);this.setState({userInputPage:Number.isNaN(e)?n.currentTarget.value:e})}onKeyDown(n,t,e,r){const o=["Tab","Backspace","Delete","ArrowLeft","ArrowRight","Home","End","ArrowUp","ArrowDown"];if(n.key===be.Enter){const p=$.parseInteger(this.state.userInputPage,e);r(n,Number.isNaN(p)?t:p),this.handleNewPage(n,Number.isNaN(p)?t:p)}else!/^\d*$/.test(n.key)&&!o.includes(n.key)&&n.preventDefault()}componentDidUpdate(n){this.props.page!==n.page&&this.props.page<=this.props.lastPage&&this.state.userInputPage!==this.props.page&&this.setState({userInputPage:this.props.page})}render(){const n=this.props,{page:t,perPage:e,onSetPage:r,isDisabled:o,itemCount:p,lastPage:s,firstPage:P,pagesTitle:l,pagesTitlePlural:c,toLastPageAriaLabel:i,toNextPageAriaLabel:A,toFirstPageAriaLabel:_,toPreviousPageAriaLabel:O,currPageAriaLabel:K,paginationAriaLabel:S,ofWord:L,onNextClick:d,onPreviousClick:C,onFirstClick:w,onLastClick:x,onPageInput:N,className:R,isCompact:M}=n,B=oe(n,["page","perPage","onSetPage","isDisabled","itemCount","lastPage","firstPage","pagesTitle","pagesTitlePlural","toLastPageAriaLabel","toNextPageAriaLabel","toFirstPageAriaLabel","toPreviousPageAriaLabel","currPageAriaLabel","paginationAriaLabel","ofWord","onNextClick","onPreviousClick","onFirstClick","onLastClick","onPageInput","className","isCompact"]),{userInputPage:G}=this.state;return a.createElement("nav",Object.assign({className:X(v.paginationNav,R),"aria-label":S},B),!M&&a.createElement("div",{className:X(v.paginationNavControl,v.modifiers.first)},a.createElement(W,{variant:j.plain,isDisabled:o||t===P||t===0,"aria-label":_,"data-action":"first",onClick:f=>{w(f,1),this.handleNewPage(f,1),this.setState({userInputPage:1})}},a.createElement(Re,null))),a.createElement("div",{className:v.paginationNavControl},a.createElement(W,{variant:j.plain,isDisabled:o||t===P||t===0,"data-action":"previous",onClick:f=>{const E=t-1>=1?t-1:1;C(f,E),this.handleNewPage(f,E),this.setState({userInputPage:E})},"aria-label":O},a.createElement(he,null))),!M&&a.createElement("div",{className:v.paginationNavPageSelect},a.createElement(ve,{"aria-label":K,type:"number",isDisabled:o||p&&t===P&&t===s&&p>=0||t===0,min:s<=0&&P<=0?0:1,max:s,value:G,onKeyDown:f=>this.onKeyDown(f,t,s,N),onChange:f=>this.onChange(f,s)}),(p||p===0)&&a.createElement("span",{"aria-hidden":"true"},L," ",l?ye(s,l,c):s)),a.createElement("div",{className:v.paginationNavControl},a.createElement(W,{variant:j.plain,isDisabled:o||t===s,"aria-label":A,"data-action":"next",onClick:f=>{const E=t+1<=s?t+1:s;d(f,E),this.handleNewPage(f,E),this.setState({userInputPage:E})}},a.createElement(Le,null))),!M&&a.createElement("div",{className:X(v.paginationNavControl,v.modifiers.last)},a.createElement(W,{variant:j.plain,isDisabled:o||t===s,"aria-label":i,"data-action":"last",onClick:f=>{x(f,s),this.handleNewPage(f,s),this.setState({userInputPage:s})}},a.createElement(Xe,null))))}}$.displayName="Navigation";$.defaultProps={className:"",isDisabled:!1,isCompact:!1,lastPage:0,firstPage:0,pagesTitle:"",pagesTitlePlural:"",toLastPageAriaLabel:"Go to last page",toNextPageAriaLabel:"Go to next page",toFirstPageAriaLabel:"Go to first page",toPreviousPageAriaLabel:"Go to previous page",currPageAriaLabel:"Current page",paginationAriaLabel:"Pagination",ofWord:"of",onNextClick:()=>{},onPreviousClick:()=>{},onFirstClick:()=>{},onLastClick:()=>{},onPageInput:()=>{}};const ce=({className:g,widgetId:n,page:t,itemCount:e,isDisabled:r=!1,minWidth:o,dropDirection:p="down",perPageOptions:s=[],itemsPerPageTitle:P="Items per page",perPageSuffix:l="per page",optionsToggleAriaLabel:c,ofWord:i="of",perPage:A=0,firstIndex:_=0,lastIndex:O=0,isLastFullPageShown:K=!1,itemsTitle:S="items",toggleTemplate:L,onPerPageSelect:d=()=>null})=>{const[C,w]=a.useState(!1),x=a.useRef(null),N=a.useRef(null),R=a.useRef(null),M=()=>{w(b=>!b)},B=()=>{var b;w(y=>!y),(b=x.current)===null||b===void 0||b.focus()},G=(b,y)=>{let m=t;for(;Math.ceil(e/y)1&&e-y*m<0;)m--;const I=(m-1)*y,k=m*y;return d(b,y,m,I,k)};a.useEffect(()=>{const b=m=>{var I,k,T;(C&&(!((I=N.current)===null||I===void 0)&&I.contains(m.target))||!((k=x.current)===null||k===void 0)&&k.contains(m.target))&&(m.key==="Escape"||m.key==="Tab")&&(w(!1),(T=x.current)===null||T===void 0||T.focus())},y=m=>{var I,k,T;C&&(!((I=x.current)===null||I===void 0)&&I.contains(m.target))&&setTimeout(()=>{var h;const D=(h=N?.current)===null||h===void 0?void 0:h.querySelector("li button:not(:disabled)");D&&D.focus()},0),C&&!(!((k=x?.current)===null||k===void 0)&&k.contains(m.target))&&!(!((T=N.current)===null||T===void 0)&&T.contains(m.target))&&w(!1)};return window.addEventListener("keydown",b),window.addEventListener("click",y),()=>{window.removeEventListener("keydown",b),window.removeEventListener("click",y)}},[C,N]);const f=()=>s.map(({value:b,title:y})=>a.createElement(ke,{key:b,"data-action":`per-page-${b}`,isSelected:A===b,onClick:m=>G(m,b)},y,` ${l}`)),E=a.createElement(xe,Object.assign({ref:x,onClick:M},c&&{"aria-label":c},{isDisabled:r||e&&e<=0,isExpanded:C},n&&{id:`${n}-toggle`},{variant:"plainText","aria-haspopup":"listbox"}),L&&typeof L=="string"&&re(L,{firstIndex:_,lastIndex:O,ofWord:i,itemCount:e,itemsTitle:S}),L&&typeof L!="string"&&L({firstIndex:_,lastIndex:O,ofWord:i,itemCount:e,itemsTitle:S}),!L&&a.createElement(Z,{firstIndex:_,lastIndex:O,ofWord:i,itemCount:e,itemsTitle:S})),U=a.createElement(Se,{className:X(g),onSelect:B,ref:N},a.createElement(Ce,null,a.createElement(Ne,null,f())));return a.createElement("div",{ref:R},a.createElement(Ie,{trigger:E,triggerRef:x,popper:U,popperRef:N,isVisible:C,direction:p,appendTo:R.current||void 0,minWidth:o!==void 0?o:"revert"}))};ce.displayName="PaginationOptionsMenu";const ae={name:"--pf-v5-c-pagination__nav-page-select--c-form-control--width-chars",value:"2",var:"var(--pf-v5-c-pagination__nav-page-select--c-form-control--width-chars)"};var z;(function(g){g.bottom="bottom",g.top="top"})(z||(z={}));const ne=[{title:"10",value:10},{title:"20",value:20},{title:"50",value:50},{title:"100",value:100}],$e=(g,n)=>{if(!n)return;const t=String(g).length;t>=3?n.style.setProperty(ae.name,`${t}`):n.style.setProperty(ae.name,"2")},J=g=>{var{children:n,className:t="",variant:e=z.top,isDisabled:r=!1,isCompact:o=!1,isSticky:p=!1,isStatic:s=!1,dropDirection:P,toggleTemplate:l,perPage:c=ne[0].value,titles:i={items:"",page:"",pages:"",itemsPerPage:"Items per page",perPageSuffix:"per page",toFirstPageAriaLabel:"Go to first page",toPreviousPageAriaLabel:"Go to previous page",toLastPageAriaLabel:"Go to last page",toNextPageAriaLabel:"Go to next page",optionsToggleAriaLabel:"",currPageAriaLabel:"Current page",paginationAriaLabel:"Pagination",ofWord:"of"},firstPage:A=1,page:_=1,offset:O=null,isLastFullPageShown:K=!1,itemsStart:S=null,itemsEnd:L=null,itemCount:d,perPageOptions:C=ne,widgetId:w="options-menu",onSetPage:x=()=>{},onPerPageSelect:N=()=>{},onFirstClick:R=()=>{},onPreviousClick:M=()=>{},onNextClick:B=()=>{},onPageInput:G=()=>{},onLastClick:f=()=>{},ouiaId:E,ouiaSafe:U=!0,usePageInsets:b,inset:y}=g,m=oe(g,["children","className","variant","isDisabled","isCompact","isSticky","isStatic","dropDirection","toggleTemplate","perPage","titles","firstPage","page","offset","isLastFullPageShown","itemsStart","itemsEnd","itemCount","perPageOptions","widgetId","onSetPage","onPerPageSelect","onFirstClick","onPreviousClick","onNextClick","onPageInput","onLastClick","ouiaId","ouiaSafe","usePageInsets","inset"]);const I=a.useRef(null),k=()=>d||d===0?Math.ceil(d/c)||0:h+1;a.useEffect(()=>{const ge=I.current;$e(k(),ge)},[c,d]);const T=P||(e==="bottom"&&!s?"up":"down");let h=_;O!==null&&(S=O+1,h=Math.max(Math.ceil(S/c),1),L=O+c);const D=k();let V=(h-1)*c+1,H=h*c;(d||d===0)&&(V=d<=0?0:(h-1)*c+1,h0?h=A:h>D&&(h=D),d>=0&&(H=h===D||d===0?d:h*c));const Q={firstIndex:V,lastIndex:H,itemCount:d,itemsTitle:i.items,ofWord:i.ofWord};return a.createElement("div",Object.assign({ref:I,className:X(v.pagination,e===z.bottom&&v.modifiers.bottom,b&&v.modifiers.pageInsets,Oe(y,v),o&&v.modifiers.compact,s&&v.modifiers.static,p&&v.modifiers.sticky,t)},w&&{id:`${w}-${e}-pagination`},Ee(J.displayName,E,U,e),m),e===z.top&&a.createElement("div",{className:X(v.paginationTotalItems)},l&&typeof l=="string"&&re(l,Q),l&&typeof l!="string"&&l(Q),!l&&a.createElement(Z,{firstIndex:V,lastIndex:H,itemCount:d,itemsTitle:i.items,ofWord:i.ofWord})),C&&C.length>0&&a.createElement(ce,{itemsPerPageTitle:i.itemsPerPage,perPageSuffix:i.perPageSuffix,itemsTitle:o?"":i.items,optionsToggleAriaLabel:i.optionsToggleAriaLabel,perPageOptions:C,firstIndex:S!==null?S:V,lastIndex:L!==null?L:H,ofWord:i.ofWord,isLastFullPageShown:K,itemCount:d,page:h,perPage:c,lastPage:D,onPerPageSelect:N,dropDirection:T,widgetId:`${w}-${e}`,toggleTemplate:l,isDisabled:r}),a.createElement($,{pagesTitle:i.page,pagesTitlePlural:i.pages,toLastPageAriaLabel:i.toLastPageAriaLabel,toPreviousPageAriaLabel:i.toPreviousPageAriaLabel,toNextPageAriaLabel:i.toNextPageAriaLabel,toFirstPageAriaLabel:i.toFirstPageAriaLabel,currPageAriaLabel:i.currPageAriaLabel,paginationAriaLabel:i.paginationAriaLabel,ofWord:i.ofWord,page:d&&d<=0?0:h,perPage:c,itemCount:d,firstPage:S!==null?S:1,lastPage:D,onSetPage:x,onFirstClick:R,onPreviousClick:M,onNextClick:B,onLastClick:f,onPageInput:G,isDisabled:r,isCompact:o}),n)};J.displayName="Pagination";const He=({message:g,instructions:n,onPrimaryAction:t,hasIcon:e=!0,isSearchVariant:r,primaryActionText:o,secondaryActions:p,icon:s,isDisabled:P=!1})=>F(me,{"data-testid":"empty-state",variant:"lg",children:[e&&r?u(ee,{icon:Ae}):e&&u(ee,{icon:s||_e}),u(fe,{titleText:g,headingLevel:"h1"}),u(de,{children:n}),F(ue,{children:[o&&u(W,{"data-testid":`${g.replace(/\W+/g,"-").toLowerCase()}-empty-action`,variant:"primary",onClick:t,isDisabled:P,children:o}),p&&u(Pe,{children:p.map(l=>u(W,{"data-testid":`${l.text.replace(/\W+/g,"-").toLowerCase()}-empty-action`,variant:l.type||j.secondary,onClick:l.onClick,isDisabled:P,children:l.text},l.text))})]})]}),Ke=({toolbarItem:g,subToolbar:n,toolbarItemFooter:t,children:e,searchTypeComponent:r,inputGroupName:o,inputGroupPlaceholder:p,inputGroupOnEnter:s})=>{const{t:P}=pe(),[l,c]=Me(""),i=()=>{l!==""?(c(l),s?.(l)):(c(""),s?.(""))},A=_=>{_.key==="Enter"&&i()};return F(se,{children:[u(q,{children:F(te,{children:[o&&u(Y,{children:F(we,{"data-testid":o,children:[r,p&&u(Te,{"data-testid":"table-search-input",placeholder:p,"aria-label":P("search"),value:l,onChange:(_,O)=>{c(O)},onSearch:i,onKeyDown:A,onClear:()=>{c(""),s?.("")}})]})}),g]})}),n&&u(q,{children:u(te,{children:n})}),u(De,{}),e,u(q,{children:t})]})},ie=({id:g,variant:n="top",count:t,first:e,max:r,onNextClick:o,onPreviousClick:p,onPerPageSelect:s})=>{const{t:P}=pe(),l=Math.round(e/r);return u(J,{widgetId:g,titles:{paginationAriaLabel:`${P("pagination")} ${n} `},isCompact:!0,toggleTemplate:({firstIndex:c,lastIndex:i})=>F("b",{children:[c," - ",i]}),itemCount:t+l*r,page:l+1,perPage:r,onNextClick:(c,i)=>o((i-1)*r),onPreviousClick:(c,i)=>p((i-1)*r),onPerPageSelect:(c,i,A)=>s(A-1,i),variant:n})},Ue=({count:g,searchTypeComponent:n,toolbarItem:t,subToolbar:e,children:r,inputGroupName:o,inputGroupPlaceholder:p,inputGroupOnEnter:s,...P})=>u(Ke,{searchTypeComponent:n,toolbarItem:F(se,{children:[t,u(Y,{variant:"pagination",children:u(ie,{count:g,...P})})]}),subToolbar:e,toolbarItemFooter:g!==0?u(Y,{variant:"pagination",children:u(ie,{count:g,variant:"bottom",...P})}):null,inputGroupName:o,inputGroupPlaceholder:p,inputGroupOnEnter:s,children:r});export{He as L,Ue as P,Ke as T};
//# sourceMappingURL=PaginatingTableToolbar-Cjsz5Jh4.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy