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

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

There is a newer version: 25.0.1
Show newest version
import{n as Q,r as a,ak as re,_ as ee,k as T,B as k,l as F,bw as ge,bW as me,m as ce,bX as te,E as de,G as ue,bY as fe,bR as Pe,bZ as he,bf as xe,b_ as Ce,by as Ie,b$ as be,j as P,aB as Te,T as ye,u as Ne}from"./index-f33eb656.js";import{P as Se}from"./plus-circle-icon-2ea0b4ed.js";import{E as ve,a as Oe}from"./EmptyStateBody-de699127.js";import{E as V,a as _e}from"./EmptyStateSecondaryActions-7a33984f.js";import{T as ke}from"./TableToolbar-8e38cfad.js";import{b as Y}from"./ToolbarContent-f1a19b22.js";const Me={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},Ee=Q(Me),De=Ee,Le={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},we=Q(Le),Fe=we;const x={divider:"pf-c-divider",modifiers:{plain:"pf-m-plain",text:"pf-m-text",active:"pf-m-active",expanded:"pf-m-expanded",disabled:"pf-m-disabled",top:"pf-m-top",alignRight:"pf-m-align-right",static:"pf-m-static"},optionsMenu:"pf-c-options-menu",optionsMenuGroup:"pf-c-options-menu__group",optionsMenuGroupTitle:"pf-c-options-menu__group-title",optionsMenuMenu:"pf-c-options-menu__menu",optionsMenuMenuItem:"pf-c-options-menu__menu-item",optionsMenuMenuItemIcon:"pf-c-options-menu__menu-item-icon",optionsMenuToggle:"pf-c-options-menu__toggle",optionsMenuToggleButton:"pf-c-options-menu__toggle-button",optionsMenuToggleButtonIcon:"pf-c-options-menu__toggle-button-icon",optionsMenuToggleIcon:"pf-c-options-menu__toggle-icon",optionsMenuToggleText:"pf-c-options-menu__toggle-text",themeDark:"pf-theme-dark"},z=({firstIndex:m=0,lastIndex:t=0,itemCount:e=0,itemsTitle:n="items",ofWord:o="of"})=>a.createElement(a.Fragment,null,a.createElement("b",null,m," - ",t)," ",o," ",a.createElement("b",null,e)," ",n);z.displayName="ToggleTemplate";const f={button:"pf-c-button",formControl:"pf-c-form-control",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"},optionsMenu:"pf-c-options-menu",optionsMenuToggle:"pf-c-options-menu__toggle",pagination:"pf-c-pagination",paginationNav:"pf-c-pagination__nav",paginationNavControl:"pf-c-pagination__nav-control",paginationNavPageSelect:"pf-c-pagination__nav-page-select",paginationTotalItems:"pf-c-pagination__total-items",themeDark:"pf-theme-dark"};class M extends a.Component{constructor(t){super(t),this.handleNewPage=(e,n)=>{const{perPage:o,onSetPage:i}=this.props,l=(n-1)*o,s=n*o;return i(e,n,o,l,s)},this.state={userInputPage:this.props.page}}static parseInteger(t,e){let n=Number.parseInt(t,10);return Number.isNaN(n)||(n=n>e?e:n,n=n<1?1:n),n}onChange(t,e){const n=M.parseInteger(t.target.value,e);this.setState({userInputPage:Number.isNaN(n)?t.target.value:n})}onKeyDown(t,e,n,o){if(t.key===re.Enter){const i=M.parseInteger(this.state.userInputPage,n);o(t,Number.isNaN(i)?e:i),this.handleNewPage(t,Number.isNaN(i)?e:i)}}componentDidUpdate(t){this.props.page!==t.page&&this.props.page<=this.props.lastPage&&this.state.userInputPage!==this.props.page&&this.setState({userInputPage:this.props.page})}render(){const t=this.props,{page:e,perPage:n,onSetPage:o,isDisabled:i,itemCount:l,lastPage:s,firstPage:p,pagesTitle:g,pagesTitlePlural:r,toLastPage:d,toNextPage:y,toFirstPage:I,toPreviousPage:S,currPage:c,paginationTitle:C,ofWord:v,onNextClick:O,onPreviousClick:_,onFirstClick:D,onLastClick:b,onPageInput:X,className:A,isCompact:L}=t,G=ee(t,["page","perPage","onSetPage","isDisabled","itemCount","lastPage","firstPage","pagesTitle","pagesTitlePlural","toLastPage","toNextPage","toFirstPage","toPreviousPage","currPage","paginationTitle","ofWord","onNextClick","onPreviousClick","onFirstClick","onLastClick","onPageInput","className","isCompact"]),{userInputPage:B}=this.state;return a.createElement("nav",Object.assign({className:T(f.paginationNav,A),"aria-label":C},G),!L&&a.createElement("div",{className:T(f.paginationNavControl,f.modifiers.first)},a.createElement(k,{variant:F.plain,isDisabled:i||e===p||e===0,"aria-label":I,"data-action":"first",onClick:u=>{D(u,1),this.handleNewPage(u,1),this.setState({userInputPage:1})}},a.createElement(De,null))),a.createElement("div",{className:f.paginationNavControl},a.createElement(k,{variant:F.plain,isDisabled:i||e===p||e===0,"data-action":"previous",onClick:u=>{const N=e-1>=1?e-1:1;_(u,N),this.handleNewPage(u,N),this.setState({userInputPage:N})},"aria-label":S},a.createElement(ge,null))),!L&&a.createElement("div",{className:f.paginationNavPageSelect},a.createElement("input",{className:T(f.formControl),"aria-label":c,type:"number",disabled:i||l&&e===p&&e===s&&l>=0||e===0,min:s<=0&&p<=0?0:1,max:s,value:B,onKeyDown:u=>this.onKeyDown(u,e,s,X),onChange:u=>this.onChange(u,s)}),(l||l===0)&&a.createElement("span",{"aria-hidden":"true"},v," ",g?me(s,g,r):s)),a.createElement("div",{className:f.paginationNavControl},a.createElement(k,{variant:F.plain,isDisabled:i||e===s,"aria-label":y,"data-action":"next",onClick:u=>{const N=e+1<=s?e+1:s;O(u,N),this.handleNewPage(u,N),this.setState({userInputPage:N})}},a.createElement(ce,null))),!L&&a.createElement("div",{className:T(f.paginationNavControl,f.modifiers.last)},a.createElement(k,{variant:F.plain,isDisabled:i||e===s,"aria-label":d,"data-action":"last",onClick:u=>{b(u,s),this.handleNewPage(u,s),this.setState({userInputPage:s})}},a.createElement(Fe,null))))}}M.displayName="Navigation";M.defaultProps={className:"",isDisabled:!1,isCompact:!1,lastPage:0,firstPage:0,pagesTitle:"",pagesTitlePlural:"",toLastPage:"Go to last page",toNextPage:"Go to next page",toFirstPage:"Go to first page",toPreviousPage:"Go to previous page",currPage:"Current page",paginationTitle:"Pagination",ofWord:"of",onNextClick:()=>{},onPreviousClick:()=>{},onFirstClick:()=>{},onLastClick:()=>{},onPageInput:()=>{}};const ne=({itemsTitle:m="items",optionsToggle:t,itemsPerPageTitle:e="Items per page",ofWord:n="of",firstIndex:o=0,lastIndex:i=0,itemCount:l,widgetId:s="",showToggle:p=!0,onToggle:g=C=>{},isOpen:r=!1,isDisabled:d=!1,parentRef:y=null,toggleTemplate:I,onEnter:S=null,perPageComponent:c="div"})=>{const C=c==="div",v=T(x.optionsMenuToggle,d&&x.modifiers.disabled,x.modifiers.plain,x.modifiers.text),O=typeof I=="string"?te(I,{firstIndex:o,lastIndex:i,ofWord:n,itemCount:l,itemsTitle:m}):a.createElement(I,{firstIndex:o,lastIndex:i,ofWord:n,itemCount:l,itemsTitle:m}),_=p&&a.createElement(a.Fragment,null,C&&a.createElement("span",{className:T(x.optionsMenuToggleText)},O),a.createElement(de,Object.assign({onEnter:S,"aria-label":C?t||"Items per page":t,onToggle:g,isDisabled:d||l&&l<=0,isOpen:r},s&&{id:`${s}-toggle`},{className:C?x.optionsMenuToggleButton:v,parentRef:y,"aria-haspopup":"listbox"}),!C&&O));return C?a.createElement("div",{className:v},_):_};ne.displayName="OptionsToggle";class W extends a.Component{constructor(t){super(t),this.parentRef=a.createRef(),this.onToggle=e=>{this.setState({isOpen:e})},this.onSelect=()=>{this.setState(e=>({isOpen:!e.isOpen}))},this.handleNewPerPage=(e,n)=>{const{page:o,onPerPageSelect:i,itemCount:l,defaultToFullPage:s}=this.props;let p=o;for(;Math.ceil(l/n)1&&l-n*p<0;)p--;const g=(p-1)*n,r=p*n;return i(e,n,p,g,r)},this.renderItems=()=>{const{perPageOptions:e,perPage:n,perPageSuffix:o}=this.props;return e.map(({value:i,title:l})=>a.createElement(ue,{key:i,component:"button","data-action":`per-page-${i}`,className:T(n===i&&"pf-m-selected"),onClick:s=>this.handleNewPerPage(s,i)},l,` ${o}`,n===i&&a.createElement("div",{className:T(x.optionsMenuMenuItemIcon)},a.createElement(fe,null))))},this.state={isOpen:!1}}render(){const{widgetId:t,isDisabled:e,itemsPerPageTitle:n,dropDirection:o,optionsToggle:i,perPageOptions:l,toggleTemplate:s,firstIndex:p,lastIndex:g,itemCount:r,itemsTitle:d,ofWord:y,perPageComponent:I}=this.props,{isOpen:S}=this.state;return a.createElement(Pe.Provider,{value:Object.assign(Object.assign({},t&&{id:t}),{onSelect:this.onSelect,toggleIndicatorClass:I==="div"?x.optionsMenuToggleButtonIcon:x.optionsMenuToggleIcon,toggleTextClass:x.optionsMenuToggleText,menuClass:x.optionsMenuMenu,itemClass:x.optionsMenuMenuItem,toggleClass:" ",baseClass:x.optionsMenu,disabledClass:x.modifiers.disabled,menuComponent:"ul",baseComponent:"div",ouiaComponentType:W.displayName})},a.createElement(he,{direction:o,isOpen:S,toggle:a.createElement(ne,{optionsToggle:i,itemsPerPageTitle:n,showToggle:l&&l.length>0,onToggle:this.onToggle,isOpen:S,widgetId:t,firstIndex:p,lastIndex:g,itemCount:r,itemsTitle:d,ofWord:y,toggleTemplate:s,parentRef:this.parentRef.current,isDisabled:e,perPageComponent:I}),dropdownItems:this.renderItems(),isPlain:!0}))}}W.displayName="PaginationOptionsMenu";W.defaultProps={className:"",widgetId:"",isDisabled:!1,dropDirection:xe.down,perPageOptions:[],itemsPerPageTitle:"Items per page",perPageSuffix:"per page",optionsToggle:"",ofWord:"of",perPage:0,firstIndex:0,lastIndex:0,defaultToFullPage:!1,itemsTitle:"items",toggleTemplate:z,onPerPageSelect:()=>null,perPageComponent:"div"};const je={name:"--pf-c-pagination__nav-page-select--c-form-control--width-chars",value:"2",var:"var(--pf-c-pagination__nav-page-select--c-form-control--width-chars)"},Z=je;var j;(function(m){m.bottom="bottom",m.top="top"})(j||(j={}));const q=[{title:"10",value:10},{title:"20",value:20},{title:"50",value:50},{title:"100",value:100}],H=(m,t)=>{if(!t)return;const e=String(m).length;e>=3?t.style.setProperty(Z.name,`${e}`):t.style.setProperty(Z.name,"2")};class E extends a.Component{constructor(){super(...arguments),this.paginationRef=a.createRef(),this.state={ouiaStateId:Ce(E.displayName,this.props.variant)}}getLastPage(){const{itemCount:t,perPage:e,page:n}=this.props;return t||t===0?Math.ceil(t/e)||0:n+1}componentDidMount(){const t=this.paginationRef.current;H(this.getLastPage(),t)}componentDidUpdate(t){const e=this.paginationRef.current;(t.perPage!==this.props.perPage||t.itemCount!==this.props.itemCount)&&H(this.getLastPage(),e)}render(){const t=this.props,{children:e,className:n,variant:o,isDisabled:i,isCompact:l,isStatic:s,isSticky:p,perPage:g,titles:r,firstPage:d,page:y,offset:I,defaultToFullPage:S,itemCount:c,itemsStart:C,itemsEnd:v,perPageOptions:O,dropDirection:_,widgetId:D,toggleTemplate:b,onSetPage:X,onPerPageSelect:A,onFirstClick:L,onPreviousClick:G,onNextClick:B,onPageInput:u,onLastClick:N,ouiaId:K,ouiaSafe:ae,perPageComponent:ie,usePageInsets:se,inset:oe}=t,le=ee(t,["children","className","variant","isDisabled","isCompact","isStatic","isSticky","perPage","titles","firstPage","page","offset","defaultToFullPage","itemCount","itemsStart","itemsEnd","perPageOptions","dropDirection","widgetId","toggleTemplate","onSetPage","onPerPageSelect","onFirstClick","onPreviousClick","onNextClick","onPageInput","onLastClick","ouiaId","ouiaSafe","perPageComponent","usePageInsets","inset"]),pe=_||(o==="bottom"&&!s?"up":"down");let h=y;!h&&I&&(h=Math.ceil(I/g)),h===0&&!c&&(h=1);const w=this.getLastPage();let R=(h-1)*g+1,$=h*g;(c||c===0)&&(R=c<=0?0:(h-1)*g+1,h0?h=d:h>w&&(h=w),c>=0&&($=h===w||c===0?c:h*g));const U={firstIndex:R,lastIndex:$,itemCount:c,itemsTitle:r.items,ofWord:r.ofWord};return a.createElement("div",Object.assign({ref:this.paginationRef,className:T(f.pagination,o===j.bottom&&f.modifiers.bottom,se&&f.modifiers.pageInsets,Ie(oe,f),l&&f.modifiers.compact,s&&f.modifiers.static,p&&f.modifiers.sticky,n)},D&&{id:`${D}-${o}-pagination`},be(E.displayName,K!==void 0?K:this.state.ouiaStateId,ae),le),o===j.top&&a.createElement("div",{className:T(f.paginationTotalItems)},b&&typeof b=="string"&&te(b,U),b&&typeof b!="string"&&b(U),!b&&a.createElement(z,{firstIndex:R,lastIndex:$,itemCount:c,itemsTitle:r.items,ofWord:r.ofWord})),a.createElement(W,{itemsPerPageTitle:r.itemsPerPage,perPageSuffix:r.perPageSuffix,itemsTitle:l?"":r.items,optionsToggle:r.optionsToggle,perPageOptions:O,firstIndex:C!==null?C:R,lastIndex:v!==null?v:$,ofWord:r.ofWord,defaultToFullPage:S,itemCount:c,page:h,perPage:g,lastPage:w,onPerPageSelect:A,dropDirection:pe,widgetId:`${D}-${o}`,toggleTemplate:b,isDisabled:i,perPageComponent:ie}),a.createElement(M,{pagesTitle:r.page,pagesTitlePlural:r.pages,toLastPage:r.toLastPage,toPreviousPage:r.toPreviousPage,toNextPage:r.toNextPage,toFirstPage:r.toFirstPage,currPage:r.currPage,paginationTitle:r.paginationTitle,ofWord:r.ofWord,page:c&&c<=0?0:h,perPage:g,itemCount:c,firstPage:C!==null?C:1,lastPage:w,onSetPage:X,onFirstClick:L,onPreviousClick:G,onNextClick:B,onLastClick:N,onPageInput:u,isDisabled:i,isCompact:l}),e)}}E.displayName="Pagination";E.defaultProps={children:null,className:"",variant:j.top,isDisabled:!1,isCompact:!1,isSticky:!1,perPage:q[0].value,titles:{items:"",page:"",pages:"",itemsPerPage:"Items per page",perPageSuffix:"per page",toFirstPage:"Go to first page",toPreviousPage:"Go to previous page",toLastPage:"Go to last page",toNextPage:"Go to next page",optionsToggle:"",currPage:"Current page",paginationTitle:"Pagination",ofWord:"of"},firstPage:1,page:0,offset:0,defaultToFullPage:!1,itemsStart:null,itemsEnd:null,perPageOptions:q,widgetId:"options-menu",onSetPage:()=>{},onPerPageSelect:()=>{},onFirstClick:()=>{},onPreviousClick:()=>{},onNextClick:()=>{},onPageInput:()=>{},onLastClick:()=>{},ouiaSafe:!0,perPageComponent:"div"};const Be=({message:m,instructions:t,onPrimaryAction:e,hasIcon:n=!0,isSearchVariant:o,primaryActionText:i,secondaryActions:l,icon:s})=>P.jsxs(ve,{"data-testid":"empty-state",variant:"large",children:[n&&o?P.jsx(V,{icon:Te}):n&&P.jsx(V,{icon:s||Se}),P.jsx(ye,{headingLevel:"h1",size:"lg",children:m}),P.jsx(Oe,{children:t}),i&&P.jsx(k,{"data-testid":`${m.replace(/\W+/g,"-").toLowerCase()}-empty-action`,variant:"primary",onClick:e,children:i}),l&&P.jsx(_e,{children:l.map(p=>P.jsx(k,{"data-testid":`${p.text.replace(/\W+/g,"-").toLowerCase()}-empty-action`,variant:p.type||F.secondary,onClick:p.onClick,children:p.text},p.text))})]}),J=({id:m,variant:t="top",count:e,first:n,max:o,onNextClick:i,onPreviousClick:l,onPerPageSelect:s})=>{const{t:p}=Ne("user-federation"),g=Math.round(n/o);return P.jsx(E,{widgetId:m,titles:{paginationTitle:`${p("pagination")} ${t} `},isCompact:!0,toggleTemplate:({firstIndex:r,lastIndex:d})=>P.jsxs("b",{children:[r," - ",d]}),itemCount:e+g*o,page:g+1,perPage:o,onNextClick:(r,d)=>i((d-1)*o),onPreviousClick:(r,d)=>l((d-1)*o),onPerPageSelect:(r,d,y)=>s(y-1,d),variant:t})},ze=({count:m,searchTypeComponent:t,toolbarItem:e,subToolbar:n,children:o,inputGroupName:i,inputGroupPlaceholder:l,inputGroupOnEnter:s,...p})=>P.jsx(ke,{searchTypeComponent:t,toolbarItem:P.jsxs(P.Fragment,{children:[e,P.jsx(Y,{variant:"pagination",children:P.jsx(J,{count:m,...p})})]}),subToolbar:n,toolbarItemFooter:m!==0?P.jsx(Y,{children:P.jsx(J,{count:m,variant:"bottom",...p})}):null,inputGroupName:i,inputGroupPlaceholder:l,inputGroupOnEnter:s,children:o});export{Be as L,ze as P};
//# sourceMappingURL=PaginatingTableToolbar-2e41cd99.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy