@ansible/ansible-ui-framework 0.0.632 → 0.0.633

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,6 +40,7 @@ export type PageTableProps<T extends object> = {
40
40
  emptyStateButtonIcon?: React.ReactNode;
41
41
  emptyStateButtonText?: string | null;
42
42
  emptyStateButtonClick?: () => void;
43
+ emptyStateVariant?: 'default' | 'light' | 'dark' | 'darker';
43
44
  showSelect?: boolean;
44
45
  disableTableView?: boolean;
45
46
  disableListView?: boolean;
package/index.js CHANGED
@@ -9658,7 +9658,7 @@ function Js(t) {
9658
9658
  ),
9659
9659
  /* @__PURE__ */ f.jsx(Mr, { headingLevel: "h2", size: "lg", children: t.errorStateTitle }),
9660
9660
  /* @__PURE__ */ f.jsx(Pi, { children: n.message })
9661
- ] }) }) : s === 0 && Object.keys(r ?? {}).length === 0 ? /* @__PURE__ */ f.jsx(nr, { children: /* @__PURE__ */ f.jsxs(ji, { variant: Na.large, style: { paddingTop: 48 }, children: [
9661
+ ] }) }) : s === 0 && Object.keys(r ?? {}).length === 0 ? /* @__PURE__ */ f.jsx(nr, { variant: t.emptyStateVariant || "default", children: /* @__PURE__ */ f.jsxs(ji, { variant: Na.large, style: { paddingTop: 48 }, children: [
9662
9662
  /* @__PURE__ */ f.jsx(Oi, { icon: t.emptyStateIcon ?? Zd }),
9663
9663
  /* @__PURE__ */ f.jsx(Mr, { headingLevel: "h4", size: "lg", children: t.emptyStateTitle }),
9664
9664
  t.emptyStateDescription && /* @__PURE__ */ f.jsx(Pi, { children: t.emptyStateDescription }),
package/index.umd.cjs CHANGED
@@ -134,7 +134,7 @@ See https://s-c.sh/2BAXzed for more info.`),window["__styled-components-init__"]
134
134
  flex-grow: 1;
135
135
  `,Gm=kr.span`
136
136
  opacity: 0.7;
137
- `;function Ym(t){if(!t)return!1;for(const e of t)if(e.type==="bulk")return!0;return!1}function Yl(t){const{itemCount:e,page:r,perPage:n,setPage:s,setPerPage:i,toolbarFilters:o,selectedItems:a,filters:l,setFilters:c,clearAllFilters:d,openColumnModal:h,bottomBorder:u}=t,m=Ft("md"),{viewType:p,setViewType:y}=t;let{toolbarActions:b}=t;b=b??[];const T=S.useCallback((C,D)=>s(D),[s]),j=S.useCallback((C,D)=>i(D),[i]),_=o!==void 0,w=b!==void 0&&b.length>0,x=t.showSelect===!0||a!==void 0&&b&&b.find(C=>Ye.bulk===C.type),z=x||_||w,[R,O]=S.useState(()=>o&&(o==null?void 0:o.length)>0?o[0].key:"");let E=0;return t.disableTableView||E++,t.disableCardView||E++,t.disableListView||E++,z?e===void 0?f.jsx(v.Toolbar,{className:"border-bottom dark-2",style:{paddingBottom:m?void 0:8,paddingTop:m?void 0:8},children:f.jsx(v.ToolbarContent,{children:f.jsx(v.ToolbarItem,{style:{width:"100%"},children:f.jsx(v.Skeleton,{height:"36px"})})})}):f.jsx(v.Toolbar,{clearAllFilters:d,className:"dark-2 page-table-toolbar",style:{paddingBottom:m?void 0:8,paddingTop:m?void 0:8,borderBottom:u?"thin solid var(--pf-global--BorderColor--100)":void 0},children:f.jsxs(v.ToolbarContent,{children:[x&&f.jsx(v.ToolbarGroup,{children:f.jsx(v.ToolbarItem,{variant:"bulk-select",children:f.jsx(Gl,{...t})})}),o&&o.length>0&&f.jsx(v.ToolbarToggleGroup,{toggleIcon:f.jsx(Fe.FilterIcon,{}),breakpoint:"md",children:f.jsxs(v.ToolbarGroup,{variant:"filter-group",children:[f.jsx(v.ToolbarItem,{children:f.jsx(fr,{id:"filter",onSelect:(C,D)=>O(D.toString()),value:R,placeholderText:"",children:o.map(C=>f.jsx(v.SelectOption,{value:C.key,children:f.jsxs(v.Flex,{spaceItems:{default:"spaceItemsNone"},alignItems:{default:"alignItemsCenter"},flexWrap:{default:"nowrap"},children:[f.jsx(v.FlexItem,{style:{paddingLeft:4,paddingRight:8},children:f.jsx(Fe.FilterIcon,{})}),f.jsx(v.FlexItem,{children:C.label})]})},C.key))})}),f.jsx(v.ToolbarItem,{children:f.jsx(Zm,{id:"filter-input",filter:o.find(C=>C.key===R),addFilter:C=>{let D=l==null?void 0:l[R];D||(D=[]),D.includes(C)||D.push(C),c==null||c({...l,[R]:D})},removeFilter:C=>{let D=l==null?void 0:l[R];D||(D=[]),D=D.filter(F=>F!==C),c==null||c({...l,[R]:D})},values:(l==null?void 0:l[R])??[]})}),o.map(C=>{const D=(l==null?void 0:l[C.key])??[];return f.jsx(v.ToolbarFilter,{categoryName:C.label,chips:D.map(F=>{var V;return"options"in C?((V=C.options.find(G=>G.value===F))==null?void 0:V.label)??F:F}),deleteChip:(F,V)=>{c==null||c(G=>{const K={...G};V=typeof V=="string"?V:V.key;let J=G[C.key];return J&&(J=J.filter(re=>re!==V),J.length===0?delete K[C.key]:K[C.key]=J),K})},deleteChipGroup:()=>{c==null||c(F=>{const V={...F};return delete V[C.key],V})},showToolbarItem:!1,children:f.jsx(f.Fragment,{})},C.label)})]})}),f.jsx(v.ToolbarGroup,{variant:"button-group",children:f.jsx(rn,{actions:b,selectedItems:a,wrapper:v.ToolbarItem})}),f.jsx(Hm,{}),f.jsxs(v.ToolbarGroup,{variant:"button-group",children:[!t.disableColumnManagement&&h&&p==="table"&&f.jsx(v.ToolbarItem,{children:f.jsx(v.Tooltip,{content:"Manage columns",children:f.jsx(v.Button,{variant:"plain",icon:f.jsx(Fe.ColumnsIcon,{}),onClick:h})})}),E>1&&f.jsx(v.ToolbarItem,{children:f.jsx(v.ToggleGroup,{"aria-label":"table view toggle",children:[!t.disableTableView&&ft.Table,!t.disableListView&&ft.List,!t.disableCardView&&ft.Cards].filter(C=>C).map(C=>{switch(C){case ft.Cards:return f.jsx(v.Tooltip,{content:"Card view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.ThLargeIcon,{}),isSelected:p===ft.Cards,onClick:()=>y==null?void 0:y(ft.Cards),"aria-label":"card view"})},C);case ft.List:return f.jsx(v.Tooltip,{content:"List view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.ListIcon,{}),isSelected:p===ft.List,onClick:()=>y==null?void 0:y(ft.List),"aria-label":"list view"})},C);case ft.Table:return f.jsx(v.Tooltip,{content:"Table view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.TableIcon,{}),isSelected:p===ft.Table,onClick:()=>y==null?void 0:y(ft.Table),"aria-label":"table view"})},C)}})})})]}),f.jsx(v.ToolbarItem,{visibility:{default:"hidden","2xl":"visible"},children:f.jsx(v.Pagination,{variant:v.PaginationVariant.top,isCompact:!0,itemCount:e,perPage:n,page:r,onSetPage:T,onPerPageSelect:j,style:{marginTop:-8,marginBottom:-8}})})]})}):f.jsx(S.Fragment,{})}function Zm(t){const{filter:e}=t;switch(e==null?void 0:e.type){case"string":return f.jsx(Km,{...t,placeholder:e.placeholder});case"select":return f.jsx(Jm,{...t,options:e.options,placeholder:e.placeholder})}return f.jsx(f.Fragment,{})}function Km(t){const[e,r]=S.useState("");return f.jsxs(v.InputGroup,{children:[f.jsxs(v.TextInputGroup,{style:{minWidth:220},children:[f.jsx(v.TextInputGroupMain,{id:t.id,value:e,onChange:(n,s)=>{r(typeof n=="string"?n:s)},onKeyUp:n=>{e&&n.key==="Enter"&&(t.addFilter(e),r(""))},placeholder:t.placeholder}),e!==""&&f.jsx(v.TextInputGroupUtilities,{children:f.jsx(v.Button,{variant:"plain","aria-label":"clear filter",onClick:()=>r(""),style:{opacity:e?void 0:0},tabIndex:-1,children:f.jsx(Fe.TimesIcon,{})})})]}),f.jsx(v.Button,{variant:e?"primary":"control","aria-label":"apply filter",onClick:()=>{t.addFilter(e),r("")},tabIndex:-1,isDisabled:!e,children:f.jsx(Fe.ArrowRightIcon,{})})]})}function Jm(t){const[e]=pt(),{addFilter:r,removeFilter:n,options:s,values:i}=t,[o,a]=S.useState(!1),l=S.useCallback((d,h)=>{i.includes(h.toString())?n(h.toString()):r(h.toString())},[r,n,i]),c=i;return f.jsx(f.Fragment,{children:f.jsx(v.Select,{variant:v.SelectVariant.checkbox,isOpen:o,onToggle:a,selections:c,onSelect:l,placeholderText:i.length?e.selectedText:f.jsx(Gm,{children:t.placeholder}),children:s.map(d=>f.jsx(v.SelectOption,{id:d.value,value:d.value,children:d.label},d.value))})})}function vn(t){const{toolbarActions:e,filters:r,error:n,itemCount:s,disableBodyPadding:i}=t,{openColumnModal:o,columnModal:a,managedColumns:l}=Lh(t.tableColumns),c=t.showSelect||(e==null?void 0:e.find(y=>Ye.bulk===y.type))!==void 0,d=!t.disableTableView,h=!t.disableListView,[u,m]=S.useState(()=>t.defaultTableView??(d?ft.Table:h?ft.List:ft.Cards)),p=Ft("md")&&i!==!0;return n?f.jsx("div",{className:"dark-2",style:{height:"100%"},children:f.jsxs(v.EmptyState,{variant:v.EmptyStateVariant.small,style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:Fe.ExclamationCircleIcon,color:"var(--pf-global--danger-color--100)"}),f.jsx(v.Title,{headingLevel:"h2",size:"lg",children:t.errorStateTitle}),f.jsx(v.EmptyStateBody,{children:n.message})]})}):s===0&&Object.keys(r??{}).length===0?f.jsx(v.PageSection,{children:f.jsxs(v.EmptyState,{variant:v.EmptyStateVariant.large,style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:t.emptyStateIcon??Fe.PlusCircleIcon}),f.jsx(v.Title,{headingLevel:"h4",size:"lg",children:t.emptyStateTitle}),t.emptyStateDescription&&f.jsx(v.EmptyStateBody,{children:t.emptyStateDescription}),t.emptyStateButtonClick&&f.jsx(v.Button,{variant:"primary",onClick:t.emptyStateButtonClick,icon:t.emptyStateButtonIcon?t.emptyStateButtonIcon:null,children:t.emptyStateButtonText})]})}):s===void 0?f.jsx(v.PageSection,{isFilled:!0,variant:"light",children:f.jsx(v.Bullseye,{children:f.jsx(v.Spinner,{})})}):f.jsxs(f.Fragment,{children:[f.jsx(Yl,{...t,openColumnModal:o,showSelect:c,viewType:u,setViewType:m,bottomBorder:!0}),u===ft.Table&&f.jsx(Rs,{disablePadding:i,children:f.jsx(Xm,{...t,tableColumns:l})}),u===ft.List&&f.jsx(Cn,{children:f.jsx(v.PageSection,{padding:{default:"noPadding",md:"padding"},children:f.jsx("div",{style:{borderLeft:p?"thin solid var(--pf-global--BorderColor--100)":void 0,borderRight:p?"thin solid var(--pf-global--BorderColor--100)":void 0},children:f.jsx(Wm,{...t,showSelect:c})})})}),u===ft.Cards&&f.jsx(Cn,{children:f.jsx(Hl,{...t,showSelect:c})}),(!t.autoHidePagination||(t.itemCount??0)>t.perPage)&&f.jsx(Bh,{...t,topBorder:!0}),a]})}function Xm(t){const{tableColumns:e,pageItems:r,selectItem:n,unselectItem:s,isSelected:i,isSelectMultiple:o,keyFn:a,rowActions:l,toolbarActions:c,itemCount:d,perPage:h,clearAllFilters:u,onSelect:m,unselectAll:p,expandedRow:y}=t,[b]=pt(),T=t.showSelect||(c==null?void 0:c.find(O=>Ye.bulk===O.type))!==void 0,j=S.useRef(null),[_,w]=S.useState({left:0,right:0,top:0,bottom:0}),x=S.useCallback(O=>{O&&w({top:O.scrollTop,bottom:O.scrollHeight-O.clientHeight-O.scrollTop,left:O.scrollLeft,right:O.scrollWidth-O.clientWidth-O.scrollLeft})},[]),z=S.useCallback(O=>x(O.currentTarget),[x]);Pn(j,()=>x(j.current)),S.useEffect(()=>x(j.current),[x]);const R=Ur();return f.jsxs("div",{className:"pf-c-scroll-inner-wrapper",style:{height:"100%",marginBottom:-1},ref:j,onScroll:z,children:[f.jsxs(Le.TableComposable,{"aria-label":"Simple table",variant:t.compact||R.tableLayout==="compact"?"compact":void 0,gridBreakPoint:"",isStickyHeader:!0,children:[d===void 0?f.jsx(Le.Thead,{children:f.jsx(Le.Tr,{children:f.jsx(Le.Th,{children:f.jsx(v.Skeleton,{})})})}):f.jsx(Qm,{...t,showSelect:T,scrollLeft:_.left>0,scrollRight:_.right>1,tableColumns:e,onSelect:m}),f.jsx(Le.Tbody,{children:d===void 0?new Array(h).fill(0).map((O,E)=>f.jsx(Le.Tr,{children:f.jsx(Le.Td,{children:f.jsx("div",{style:{paddingTop:5,paddingBottom:5},children:f.jsx(v.Skeleton,{height:"27px"})})})},E)):r===void 0?new Array(Math.min(h,d)).fill(0).map((O,E)=>f.jsxs(Le.Tr,{children:[T&&f.jsx(Le.Td,{}),f.jsx(Le.Td,{colSpan:e.length,children:f.jsx("div",{style:{paddingTop:5,paddingBottom:5},children:f.jsx(v.Skeleton,{height:"27px"})})})]},E)):r==null?void 0:r.map((O,E)=>f.jsx(ep,{columns:e,item:O,isItemSelected:i==null?void 0:i(O),isSelectMultiple:o,selectItem:n,unselectItem:s,rowActions:l,rowIndex:E,showSelect:T,scrollLeft:_.left>0,scrollRight:_.right>1,unselectAll:p,onSelect:m,expandedRow:y},a?a(O):E))})]}),d===0&&f.jsxs(v.EmptyState,{style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:Fe.SearchIcon}),f.jsx(v.Title,{headingLevel:"h2",size:"lg",children:b.noResultsFound}),f.jsx(v.EmptyStateBody,{children:b.noResultsMatchCriteria}),u&&f.jsx(v.EmptyStateSecondaryActions,{children:f.jsx(v.Button,{variant:"primary",onClick:u,children:b.clearAllFilters})})]})]})}function Qm(t){const{tableColumns:e,rowActions:r,sort:n,setSort:s,sortDirection:i,setSortDirection:o,showSelect:a,onSelect:l,expandedRow:c}=t,d=S.useCallback((h,u)=>{if(u.sort)return{onSort:(m,p,y)=>{u.sort&&(s==null||s(u.sort),o==null||o(y))},sortBy:{index:u.sort===n?h:void 0,direction:u.sort===n?i:void 0,defaultDirection:u.defaultSortDirection},columnIndex:h}},[s,o,n,i]);return f.jsx(Le.Thead,{children:f.jsxs(Le.Tr,{className:"light dark-2",children:[c&&f.jsx(Le.Th,{style:{padding:0,backgroundColor:"inherit"}}),(a||l)&&f.jsx(Le.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft,style:{backgroundColor:"inherit"},children:" "}),e.filter(h=>h.enabled!==!1).map((h,u)=>f.jsx(Le.Th,{sort:d(u,h),style:{minWidth:h.minWidth===0?"1%":h.minWidth!==void 0?h.minWidth:void 0,maxWidth:h.maxWidth!==void 0?h.maxWidth:void 0,backgroundColor:"inherit"},children:h.header},h.header)),r!==void 0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,backgroundColor:"inherit",zIndex:302},className:t.scrollRight?"pf-m-border-left":void 0,children:" "})]})})}function ep(t){const{columns:e,selectItem:r,unselectItem:n,isItemSelected:s,isSelectMultiple:i,item:o,rowActions:a,rowIndex:l,showSelect:c,onSelect:d,expandedRow:h}=t,[u,m]=S.useState(!1),p=Ur(),y=h==null?void 0:h(o);return f.jsxs(f.Fragment,{children:[f.jsxs(Le.Tr,{className:s?"selected":void 0,isRowSelected:u,style:{boxShadow:"unset",borderBottom:u?"unset":void 0},children:[h&&f.jsx(Le.Td,{expand:y?{rowIndex:l,isExpanded:u,onToggle:()=>m(b=>!b)}:void 0,style:{paddingLeft:y?8:4}}),c&&f.jsx(Le.Th,{select:s!==void 0?{onSelect:(b,T)=>{T?r==null||r(o):n==null||n(o)},isSelected:s}:void 0,isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),d&&f.jsx(Le.Td,{select:{rowIndex:l,onSelect:(b,T)=>{T?r==null||r(o):n==null||n(o)},isSelected:s??!1,variant:i?"checkbox":"radio"},isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),f.jsx(tp,{columns:e,item:o,rowActions:a,scrollLeft:t.scrollLeft,scrollRight:t.scrollRight})]}),h&&u&&y&&f.jsxs(Le.Tr,{className:s?"selected":void 0,isExpanded:u,style:{boxShadow:"unset"},children:[f.jsx(Le.Td,{}),c&&f.jsx(Le.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),d&&f.jsx(Le.Td,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),f.jsx(Le.Td,{colSpan:e.filter(b=>b.enabled!==!1).length,style:{paddingBottom:p.tableLayout==="compact"?12:24,paddingTop:0},children:f.jsx(Le.CollapseColumn,{children:y})}),a!==void 0&&a.length>0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0},className:t.scrollRight?"pf-m-border-left":void 0,children:" "})]})]})}function tp(t){const{columns:e,item:r,rowActions:n}=t,[s,i]=S.useState(!1);return f.jsxs(S.Fragment,{children:[e.filter(o=>o.enabled!==!1).map(o=>f.jsx(Le.Td,{dataLabel:o.header,modifier:"nowrap",style:{width:o.minWidth===0?"0%":void 0},children:f.jsx(bt,{item:r,column:o})},o.header)),n!==void 0&&n.length>0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,zIndex:s?301:void 0},className:t.scrollRight?"pf-m-border-left":void 0,children:f.jsx(rn,{actions:n,selectedItem:r,position:v.DropdownPosition.right,iconOnly:!0,onOpen:i})})]})}var Zl=(t=>(t[t.description=0]="description",t[t.hidden=1]="hidden",t[t.count=2]="count",t))(Zl||{});function bt(t){const{item:e,column:r}=t;if(!r)return f.jsx(f.Fragment,{});switch(r.type){case"text":return f.jsx(li,{text:r.value(e)});case"labels":return f.jsx(pl,{labels:r.value(e)??[]});case"description":return f.jsx(li,{text:r.value(e)});case"count":return f.jsx(f.Fragment,{children:r.value(e)??"-"});case"datetime":return f.jsx(ml,{value:r.value(e)});default:return f.jsx(f.Fragment,{children:r.cell(e)})}}function Si(t,e,r){var n,s,i,o,a;e==null&&(e=100);function l(){var d=Date.now()-o;d<e&&d>=0?n=setTimeout(l,e-d):(n=null,r||(a=t.apply(i,s),i=s=null))}var c=function(){i=this,s=arguments,o=Date.now();var d=r&&!n;return n||(n=setTimeout(l,e)),d&&(a=t.apply(i,s),i=s=null),a};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(a=t.apply(i,s),i=s=null,clearTimeout(n),n=null)},c}Si.debounce=Si;var rp=Si;function np(t,e,r){const{selectedItems:n,selectItem:s,unselectItem:i,isSelected:o,selectItems:a,unselectAll:l,allSelected:c}=Kl(t,e),{sorted:d,sort:h,setSort:u}=Ei(t),{filtered:m,setFilterFn:p}=$i(d,e),{searched:y,search:b,setSearch:T,setSearchFn:j}=sp(m,e,r==null?void 0:r.search),{paged:_,page:w,setPage:x,perPage:z,setPerPage:R}=bn(y),O=S.useCallback(()=>a(_),[_,a]),E=S.useCallback(()=>a(y),[y,a]);return S.useMemo(()=>({allSelected:c,filtered:m,isSelected:o,page:w,paged:_,perPage:z,search:b,searched:y,selectAll:E,selectItem:s,selectPage:O,selectedItems:n,setFilterFn:p,setPage:x,setPerPage:R,setSearch:T,setSearchFn:j,setSort:u,sort:h,sorted:d,unselectAll:l,unselectItem:i}),[c,m,o,w,_,z,b,y,E,s,O,n,p,x,R,T,j,u,h,d,l,i])}function Kl(t,e){const[r,n]=S.useState({});S.useEffect(()=>{n(m=>{let p=!1;return t.forEach(y=>{const b=e(y);m[b]&&m[b]!==y&&(p=!0,m[b]=y)}),p?{...m}:m})},[t,e]);const s=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]!==m&&(p={...p},p[y]=m),p})},[e]),i=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]&&(p={...p},delete p[y]),p})},[e]),o=S.useCallback(m=>{const p=e(m);return r[p]!==void 0},[e,r]),a=S.useCallback(m=>{n(p=>{p={...p};for(const y of m){const b=e(y);p[b]=y}return p})},[e]),l=S.useCallback(()=>a(t),[t,a]),c=S.useCallback(m=>{for(const p of m)i(p)},[i]),d=S.useCallback(()=>{n(m=>Object.keys(m).length>0?{}:m)},[]),h=S.useMemo(()=>Object.values(r),[r]),u=S.useMemo(()=>h.length===t.length,[t.length,h.length]);return S.useMemo(()=>({selectedItems:h,selectItem:s,unselectItem:i,isSelected:o,selectItems:a,selectAll:l,unselectAll:d,allSelected:u,keyFn:e,unselectItems:c}),[u,o,e,l,s,a,h,d,i,c])}function Jl(t,e){const[r,n]=S.useState({});S.useEffect(()=>{n(m=>{let p=!1;const y=t?t.reduce((j,_)=>{const w=e(_);return j[w]=_,m[w]&&m[w]!==_&&(p=!0,m[w]=_),j},{}):{},b={};for(const j in m)y[j]||(b[j]=!0);const T=Object.keys(b);if(T.length){p=!0;for(const j of T)delete m[j]}return p?{...m}:m})},[t,e]);const s=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]!==m&&(p={...p},p[y]=m),p})},[e]),i=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]&&(p={...p},delete p[y]),p})},[e]),o=S.useCallback(m=>{for(const p of m)i(p)},[i]),a=S.useCallback(m=>{const p=e(m);return r[p]!==void 0},[e,r]),l=S.useCallback(m=>{n(p=>{p={...p};for(const y of m){const b=e(y);p[b]=y}return p})},[e]),c=S.useCallback(()=>{l(t??[])},[t,l]),d=S.useCallback(()=>{n(m=>Object.keys(m).length>0?{}:m)},[]),h=S.useMemo(()=>Object.values(r),[r]),u=S.useMemo(()=>h.length===(t==null?void 0:t.length),[t,h.length]);return S.useMemo(()=>({selectedItems:h,selectItem:s,unselectItem:i,isSelected:a,selectItems:l,selectAll:c,unselectAll:d,allSelected:u,keyFn:e,unselectItems:o}),[u,a,e,c,s,l,h,d,i,o])}function Ei(t){const[e,r]=S.useState(),{direction:n,sortFn:s}=e??{},i=S.useMemo(()=>t?s?n==="asc"?[...t.sort(s)]:[...t.sort(s).reverse()]:t:[],[n,t,s]);return S.useMemo(()=>({sorted:i,sort:e,setSort:r}),[e,i])}function $i(t,e){const r=S.useRef({map:{}}),[n,s]=S.useState(),i=S.useCallback(c=>s(()=>c),[]),[o,a]=S.useState([]);S.useEffect(()=>{r.current.map={}},[n]);const l=S.useCallback(c=>{const d=e(c);let h=r.current.map[d];return h?h.item!==c&&(h.item=c,h.passes=n?n(c):!0):(h={item:c,passes:n?n(c):!0},r.current.map[d]=h),h.passes},[n,e]);return S.useEffect(()=>{a(n?t.filter(l):t)},[t,n,l]),S.useMemo(function(){return{filtered:o,setFilterFn:i}},[o,i])}function sp(t,e,r){const n=S.useRef({map:{}}),[s,i]=S.useState(),o=S.useCallback(m=>i(()=>m),[]),[a,l]=S.useState([]),[c,d]=S.useState(r??""),h=S.useCallback(rp(m=>d(m),200),[]);S.useEffect(()=>{n.current.map={}},[c,s]);const u=S.useCallback(m=>{const p=e(m);let y=n.current.map[p];return y?y.item!==m&&(y.item=m,y.score=s?s(m,c):0):(y={item:m,score:s?s(m,c):0},n.current.map[p]=y),y},[e,s,c]);return S.useEffect(()=>{l(s&&c?t.map(u).filter(m=>m.score<.5).sort((m,p)=>m.score-p.score).map(m=>m.item):t)},[c,t,s,u]),S.useMemo(function(){return{searched:a,search:c,setSearch:h,setSearchFn:o}},[a,c,h,o])}function bn(t){const[e,r]=S.useState([]),[n,s]=S.useState(1),[i,o]=S.useState(10);return S.useEffect(()=>{r(a=>{const l=t.slice((n-1)*i,n*i);if(a.length!==l.length)return l;let c=0;for(const d of l)if(a[c++]!==d)return l;return a})},[n,i,t]),S.useEffect(()=>{n>Math.ceil(t.length/i)&&s(1)},[n,i,t.length]),S.useMemo(()=>({paged:e,page:n,setPage:s,perPage:i,setPerPage:o}),[n,e,i])}function ip(t){const{title:e,items:r,keyFn:n,actionColumns:s,actionFn:i,onComplete:o,onClose:a,processingText:l,isDanger:c}=t,[d]=pt(),[h,u]=S.useState(!0),[m,p]=S.useState(!1),[y,b]=S.useState(0),[T,j]=S.useState(""),[_,w]=S.useState(),[x]=S.useState(()=>new AbortController),[z,R]=Kt(),O=S.useCallback(()=>{p(!0),x.abort(),u(!1),w(K=>{const J={...K};for(const re of r){const se=n(re);J[se]===void 0&&(J[se]="Cancelled")}return J})},[x,r,n]),E=S.useCallback(()=>{R(void 0),a==null||a()},[a,R]);S.useEffect(()=>{async function K(){const J=hu(5);let re=0;const se=[];await Promise.all(r.map(I=>J(async()=>{if(x.signal.aborted)return;const $=n(I);try{await i(I,x.signal),x.signal.aborted||w(L=>({...L??{},[$]:null})),se.push(I)}catch(L){if(!x.signal.aborted){if(L instanceof Error){const q=L.message;w(Z=>({...Z??{},[$]:q}))}else w(q=>({...q??{},[$]:"Unknown error"}));j(d.errorText)}}finally{x.signal.aborted||b(++re)}}))),x.signal.aborted||u(!1),o==null||o(se)}K()},[x,i,r,n,o,d.errorText]);const{paged:C,page:D,perPage:F,setPage:V,setPerPage:G}=bn(r);return f.jsxs(v.Modal,{titleIconVariant:c?"warning":void 0,title:e,variant:v.ModalVariant.medium,isOpen:!0,onClose:()=>{O(),E()},actions:h?[f.jsx(v.Button,{variant:"link",onClick:O,children:d.cancelText},"cancel")]:[f.jsx(v.Button,{variant:"secondary",onClick:E,children:d.closeText},"close")],hasNoBodyWrapper:!0,children:[f.jsx(v.ModalBoxBody,{style:{paddingBottom:0,paddingLeft:0,paddingRight:0},children:f.jsx("div",{style:{display:"flex",flexDirection:"column",maxHeight:560,overflow:"hidden",borderTop:"thin solid var(--pf-global--BorderColor--100)"},children:f.jsx(vn,{pageItems:[...C],itemCount:r.length,tableColumns:[...s,{header:"Status",cell:K=>{const J=n(K),re=_==null?void 0:_[J];return re===void 0?f.jsxs("span",{style:{color:Ss},children:[f.jsx(Fe.PendingIcon,{}),"  ",d.pendingText]}):re===null?f.jsxs("span",{style:{color:ws},children:[f.jsx(Fe.CheckCircleIcon,{}),"  ",d.successText]}):f.jsxs("span",{style:{color:xs},children:[f.jsx(Fe.ExclamationCircleIcon,{}),"  ",_==null?void 0:_[J]]})}}],keyFn:n,page:D,perPage:F,setPage:V,setPerPage:G,compact:!0,errorStateTitle:"",emptyStateTitle:"No items",autoHidePagination:!0,disableBodyPadding:!0},"status")})}),f.jsx(v.ModalBoxBody,{style:{paddingTop:0},children:f.jsx(v.Progress,{value:y/r.length*100,title:x.signal.aborted?d.canceledText:T?d.errorText:h?l??d.processingText:d.successText,size:v.ProgressSize.lg,variant:T||m?v.ProgressVariant.danger:y===r.length?v.ProgressVariant.success:void 0})})]})}function Xl(){const[t,e]=Kt(),[r,n]=S.useState();return S.useEffect(()=>{if(r){const s=()=>{var i;n(void 0),(i=r.onClose)==null||i.call(r)};e(f.jsx(ip,{...r,onClose:s}))}else e(void 0)},[r,e]),n}function Ql(t,e){if(t==null&&e==null)return 0;if(t==null)return 1;if(e==null)return-1;if(typeof t=="string"){if(typeof e=="string")return wn(t,e);if(typeof e=="number")return wn(t,e.toString())}else if(typeof t=="number"){if(typeof e=="number")return ec(t,e);if(typeof e=="string")return wn(t.toString(),e)}return 0}function wn(t,e){return t==null&&e==null?0:t==null?1:e==null||t<e?-1:t>e?1:0}function ec(t,e){return t==null&&e==null?0:t==null?1:e==null||t<e?-1:t>e?1:0}const op=kr.div`
137
+ `;function Ym(t){if(!t)return!1;for(const e of t)if(e.type==="bulk")return!0;return!1}function Yl(t){const{itemCount:e,page:r,perPage:n,setPage:s,setPerPage:i,toolbarFilters:o,selectedItems:a,filters:l,setFilters:c,clearAllFilters:d,openColumnModal:h,bottomBorder:u}=t,m=Ft("md"),{viewType:p,setViewType:y}=t;let{toolbarActions:b}=t;b=b??[];const T=S.useCallback((C,D)=>s(D),[s]),j=S.useCallback((C,D)=>i(D),[i]),_=o!==void 0,w=b!==void 0&&b.length>0,x=t.showSelect===!0||a!==void 0&&b&&b.find(C=>Ye.bulk===C.type),z=x||_||w,[R,O]=S.useState(()=>o&&(o==null?void 0:o.length)>0?o[0].key:"");let E=0;return t.disableTableView||E++,t.disableCardView||E++,t.disableListView||E++,z?e===void 0?f.jsx(v.Toolbar,{className:"border-bottom dark-2",style:{paddingBottom:m?void 0:8,paddingTop:m?void 0:8},children:f.jsx(v.ToolbarContent,{children:f.jsx(v.ToolbarItem,{style:{width:"100%"},children:f.jsx(v.Skeleton,{height:"36px"})})})}):f.jsx(v.Toolbar,{clearAllFilters:d,className:"dark-2 page-table-toolbar",style:{paddingBottom:m?void 0:8,paddingTop:m?void 0:8,borderBottom:u?"thin solid var(--pf-global--BorderColor--100)":void 0},children:f.jsxs(v.ToolbarContent,{children:[x&&f.jsx(v.ToolbarGroup,{children:f.jsx(v.ToolbarItem,{variant:"bulk-select",children:f.jsx(Gl,{...t})})}),o&&o.length>0&&f.jsx(v.ToolbarToggleGroup,{toggleIcon:f.jsx(Fe.FilterIcon,{}),breakpoint:"md",children:f.jsxs(v.ToolbarGroup,{variant:"filter-group",children:[f.jsx(v.ToolbarItem,{children:f.jsx(fr,{id:"filter",onSelect:(C,D)=>O(D.toString()),value:R,placeholderText:"",children:o.map(C=>f.jsx(v.SelectOption,{value:C.key,children:f.jsxs(v.Flex,{spaceItems:{default:"spaceItemsNone"},alignItems:{default:"alignItemsCenter"},flexWrap:{default:"nowrap"},children:[f.jsx(v.FlexItem,{style:{paddingLeft:4,paddingRight:8},children:f.jsx(Fe.FilterIcon,{})}),f.jsx(v.FlexItem,{children:C.label})]})},C.key))})}),f.jsx(v.ToolbarItem,{children:f.jsx(Zm,{id:"filter-input",filter:o.find(C=>C.key===R),addFilter:C=>{let D=l==null?void 0:l[R];D||(D=[]),D.includes(C)||D.push(C),c==null||c({...l,[R]:D})},removeFilter:C=>{let D=l==null?void 0:l[R];D||(D=[]),D=D.filter(F=>F!==C),c==null||c({...l,[R]:D})},values:(l==null?void 0:l[R])??[]})}),o.map(C=>{const D=(l==null?void 0:l[C.key])??[];return f.jsx(v.ToolbarFilter,{categoryName:C.label,chips:D.map(F=>{var V;return"options"in C?((V=C.options.find(G=>G.value===F))==null?void 0:V.label)??F:F}),deleteChip:(F,V)=>{c==null||c(G=>{const K={...G};V=typeof V=="string"?V:V.key;let J=G[C.key];return J&&(J=J.filter(re=>re!==V),J.length===0?delete K[C.key]:K[C.key]=J),K})},deleteChipGroup:()=>{c==null||c(F=>{const V={...F};return delete V[C.key],V})},showToolbarItem:!1,children:f.jsx(f.Fragment,{})},C.label)})]})}),f.jsx(v.ToolbarGroup,{variant:"button-group",children:f.jsx(rn,{actions:b,selectedItems:a,wrapper:v.ToolbarItem})}),f.jsx(Hm,{}),f.jsxs(v.ToolbarGroup,{variant:"button-group",children:[!t.disableColumnManagement&&h&&p==="table"&&f.jsx(v.ToolbarItem,{children:f.jsx(v.Tooltip,{content:"Manage columns",children:f.jsx(v.Button,{variant:"plain",icon:f.jsx(Fe.ColumnsIcon,{}),onClick:h})})}),E>1&&f.jsx(v.ToolbarItem,{children:f.jsx(v.ToggleGroup,{"aria-label":"table view toggle",children:[!t.disableTableView&&ft.Table,!t.disableListView&&ft.List,!t.disableCardView&&ft.Cards].filter(C=>C).map(C=>{switch(C){case ft.Cards:return f.jsx(v.Tooltip,{content:"Card view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.ThLargeIcon,{}),isSelected:p===ft.Cards,onClick:()=>y==null?void 0:y(ft.Cards),"aria-label":"card view"})},C);case ft.List:return f.jsx(v.Tooltip,{content:"List view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.ListIcon,{}),isSelected:p===ft.List,onClick:()=>y==null?void 0:y(ft.List),"aria-label":"list view"})},C);case ft.Table:return f.jsx(v.Tooltip,{content:"Table view",position:"top-end",enableFlip:!1,children:f.jsx(v.ToggleGroupItem,{icon:f.jsx(Fe.TableIcon,{}),isSelected:p===ft.Table,onClick:()=>y==null?void 0:y(ft.Table),"aria-label":"table view"})},C)}})})})]}),f.jsx(v.ToolbarItem,{visibility:{default:"hidden","2xl":"visible"},children:f.jsx(v.Pagination,{variant:v.PaginationVariant.top,isCompact:!0,itemCount:e,perPage:n,page:r,onSetPage:T,onPerPageSelect:j,style:{marginTop:-8,marginBottom:-8}})})]})}):f.jsx(S.Fragment,{})}function Zm(t){const{filter:e}=t;switch(e==null?void 0:e.type){case"string":return f.jsx(Km,{...t,placeholder:e.placeholder});case"select":return f.jsx(Jm,{...t,options:e.options,placeholder:e.placeholder})}return f.jsx(f.Fragment,{})}function Km(t){const[e,r]=S.useState("");return f.jsxs(v.InputGroup,{children:[f.jsxs(v.TextInputGroup,{style:{minWidth:220},children:[f.jsx(v.TextInputGroupMain,{id:t.id,value:e,onChange:(n,s)=>{r(typeof n=="string"?n:s)},onKeyUp:n=>{e&&n.key==="Enter"&&(t.addFilter(e),r(""))},placeholder:t.placeholder}),e!==""&&f.jsx(v.TextInputGroupUtilities,{children:f.jsx(v.Button,{variant:"plain","aria-label":"clear filter",onClick:()=>r(""),style:{opacity:e?void 0:0},tabIndex:-1,children:f.jsx(Fe.TimesIcon,{})})})]}),f.jsx(v.Button,{variant:e?"primary":"control","aria-label":"apply filter",onClick:()=>{t.addFilter(e),r("")},tabIndex:-1,isDisabled:!e,children:f.jsx(Fe.ArrowRightIcon,{})})]})}function Jm(t){const[e]=pt(),{addFilter:r,removeFilter:n,options:s,values:i}=t,[o,a]=S.useState(!1),l=S.useCallback((d,h)=>{i.includes(h.toString())?n(h.toString()):r(h.toString())},[r,n,i]),c=i;return f.jsx(f.Fragment,{children:f.jsx(v.Select,{variant:v.SelectVariant.checkbox,isOpen:o,onToggle:a,selections:c,onSelect:l,placeholderText:i.length?e.selectedText:f.jsx(Gm,{children:t.placeholder}),children:s.map(d=>f.jsx(v.SelectOption,{id:d.value,value:d.value,children:d.label},d.value))})})}function vn(t){const{toolbarActions:e,filters:r,error:n,itemCount:s,disableBodyPadding:i}=t,{openColumnModal:o,columnModal:a,managedColumns:l}=Lh(t.tableColumns),c=t.showSelect||(e==null?void 0:e.find(y=>Ye.bulk===y.type))!==void 0,d=!t.disableTableView,h=!t.disableListView,[u,m]=S.useState(()=>t.defaultTableView??(d?ft.Table:h?ft.List:ft.Cards)),p=Ft("md")&&i!==!0;return n?f.jsx("div",{className:"dark-2",style:{height:"100%"},children:f.jsxs(v.EmptyState,{variant:v.EmptyStateVariant.small,style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:Fe.ExclamationCircleIcon,color:"var(--pf-global--danger-color--100)"}),f.jsx(v.Title,{headingLevel:"h2",size:"lg",children:t.errorStateTitle}),f.jsx(v.EmptyStateBody,{children:n.message})]})}):s===0&&Object.keys(r??{}).length===0?f.jsx(v.PageSection,{variant:t.emptyStateVariant||"default",children:f.jsxs(v.EmptyState,{variant:v.EmptyStateVariant.large,style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:t.emptyStateIcon??Fe.PlusCircleIcon}),f.jsx(v.Title,{headingLevel:"h4",size:"lg",children:t.emptyStateTitle}),t.emptyStateDescription&&f.jsx(v.EmptyStateBody,{children:t.emptyStateDescription}),t.emptyStateButtonClick&&f.jsx(v.Button,{variant:"primary",onClick:t.emptyStateButtonClick,icon:t.emptyStateButtonIcon?t.emptyStateButtonIcon:null,children:t.emptyStateButtonText})]})}):s===void 0?f.jsx(v.PageSection,{isFilled:!0,variant:"light",children:f.jsx(v.Bullseye,{children:f.jsx(v.Spinner,{})})}):f.jsxs(f.Fragment,{children:[f.jsx(Yl,{...t,openColumnModal:o,showSelect:c,viewType:u,setViewType:m,bottomBorder:!0}),u===ft.Table&&f.jsx(Rs,{disablePadding:i,children:f.jsx(Xm,{...t,tableColumns:l})}),u===ft.List&&f.jsx(Cn,{children:f.jsx(v.PageSection,{padding:{default:"noPadding",md:"padding"},children:f.jsx("div",{style:{borderLeft:p?"thin solid var(--pf-global--BorderColor--100)":void 0,borderRight:p?"thin solid var(--pf-global--BorderColor--100)":void 0},children:f.jsx(Wm,{...t,showSelect:c})})})}),u===ft.Cards&&f.jsx(Cn,{children:f.jsx(Hl,{...t,showSelect:c})}),(!t.autoHidePagination||(t.itemCount??0)>t.perPage)&&f.jsx(Bh,{...t,topBorder:!0}),a]})}function Xm(t){const{tableColumns:e,pageItems:r,selectItem:n,unselectItem:s,isSelected:i,isSelectMultiple:o,keyFn:a,rowActions:l,toolbarActions:c,itemCount:d,perPage:h,clearAllFilters:u,onSelect:m,unselectAll:p,expandedRow:y}=t,[b]=pt(),T=t.showSelect||(c==null?void 0:c.find(O=>Ye.bulk===O.type))!==void 0,j=S.useRef(null),[_,w]=S.useState({left:0,right:0,top:0,bottom:0}),x=S.useCallback(O=>{O&&w({top:O.scrollTop,bottom:O.scrollHeight-O.clientHeight-O.scrollTop,left:O.scrollLeft,right:O.scrollWidth-O.clientWidth-O.scrollLeft})},[]),z=S.useCallback(O=>x(O.currentTarget),[x]);Pn(j,()=>x(j.current)),S.useEffect(()=>x(j.current),[x]);const R=Ur();return f.jsxs("div",{className:"pf-c-scroll-inner-wrapper",style:{height:"100%",marginBottom:-1},ref:j,onScroll:z,children:[f.jsxs(Le.TableComposable,{"aria-label":"Simple table",variant:t.compact||R.tableLayout==="compact"?"compact":void 0,gridBreakPoint:"",isStickyHeader:!0,children:[d===void 0?f.jsx(Le.Thead,{children:f.jsx(Le.Tr,{children:f.jsx(Le.Th,{children:f.jsx(v.Skeleton,{})})})}):f.jsx(Qm,{...t,showSelect:T,scrollLeft:_.left>0,scrollRight:_.right>1,tableColumns:e,onSelect:m}),f.jsx(Le.Tbody,{children:d===void 0?new Array(h).fill(0).map((O,E)=>f.jsx(Le.Tr,{children:f.jsx(Le.Td,{children:f.jsx("div",{style:{paddingTop:5,paddingBottom:5},children:f.jsx(v.Skeleton,{height:"27px"})})})},E)):r===void 0?new Array(Math.min(h,d)).fill(0).map((O,E)=>f.jsxs(Le.Tr,{children:[T&&f.jsx(Le.Td,{}),f.jsx(Le.Td,{colSpan:e.length,children:f.jsx("div",{style:{paddingTop:5,paddingBottom:5},children:f.jsx(v.Skeleton,{height:"27px"})})})]},E)):r==null?void 0:r.map((O,E)=>f.jsx(ep,{columns:e,item:O,isItemSelected:i==null?void 0:i(O),isSelectMultiple:o,selectItem:n,unselectItem:s,rowActions:l,rowIndex:E,showSelect:T,scrollLeft:_.left>0,scrollRight:_.right>1,unselectAll:p,onSelect:m,expandedRow:y},a?a(O):E))})]}),d===0&&f.jsxs(v.EmptyState,{style:{paddingTop:48},children:[f.jsx(v.EmptyStateIcon,{icon:Fe.SearchIcon}),f.jsx(v.Title,{headingLevel:"h2",size:"lg",children:b.noResultsFound}),f.jsx(v.EmptyStateBody,{children:b.noResultsMatchCriteria}),u&&f.jsx(v.EmptyStateSecondaryActions,{children:f.jsx(v.Button,{variant:"primary",onClick:u,children:b.clearAllFilters})})]})]})}function Qm(t){const{tableColumns:e,rowActions:r,sort:n,setSort:s,sortDirection:i,setSortDirection:o,showSelect:a,onSelect:l,expandedRow:c}=t,d=S.useCallback((h,u)=>{if(u.sort)return{onSort:(m,p,y)=>{u.sort&&(s==null||s(u.sort),o==null||o(y))},sortBy:{index:u.sort===n?h:void 0,direction:u.sort===n?i:void 0,defaultDirection:u.defaultSortDirection},columnIndex:h}},[s,o,n,i]);return f.jsx(Le.Thead,{children:f.jsxs(Le.Tr,{className:"light dark-2",children:[c&&f.jsx(Le.Th,{style:{padding:0,backgroundColor:"inherit"}}),(a||l)&&f.jsx(Le.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft,style:{backgroundColor:"inherit"},children:" "}),e.filter(h=>h.enabled!==!1).map((h,u)=>f.jsx(Le.Th,{sort:d(u,h),style:{minWidth:h.minWidth===0?"1%":h.minWidth!==void 0?h.minWidth:void 0,maxWidth:h.maxWidth!==void 0?h.maxWidth:void 0,backgroundColor:"inherit"},children:h.header},h.header)),r!==void 0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,backgroundColor:"inherit",zIndex:302},className:t.scrollRight?"pf-m-border-left":void 0,children:" "})]})})}function ep(t){const{columns:e,selectItem:r,unselectItem:n,isItemSelected:s,isSelectMultiple:i,item:o,rowActions:a,rowIndex:l,showSelect:c,onSelect:d,expandedRow:h}=t,[u,m]=S.useState(!1),p=Ur(),y=h==null?void 0:h(o);return f.jsxs(f.Fragment,{children:[f.jsxs(Le.Tr,{className:s?"selected":void 0,isRowSelected:u,style:{boxShadow:"unset",borderBottom:u?"unset":void 0},children:[h&&f.jsx(Le.Td,{expand:y?{rowIndex:l,isExpanded:u,onToggle:()=>m(b=>!b)}:void 0,style:{paddingLeft:y?8:4}}),c&&f.jsx(Le.Th,{select:s!==void 0?{onSelect:(b,T)=>{T?r==null||r(o):n==null||n(o)},isSelected:s}:void 0,isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),d&&f.jsx(Le.Td,{select:{rowIndex:l,onSelect:(b,T)=>{T?r==null||r(o):n==null||n(o)},isSelected:s??!1,variant:i?"checkbox":"radio"},isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),f.jsx(tp,{columns:e,item:o,rowActions:a,scrollLeft:t.scrollLeft,scrollRight:t.scrollRight})]}),h&&u&&y&&f.jsxs(Le.Tr,{className:s?"selected":void 0,isExpanded:u,style:{boxShadow:"unset"},children:[f.jsx(Le.Td,{}),c&&f.jsx(Le.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),d&&f.jsx(Le.Td,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:t.scrollLeft}),f.jsx(Le.Td,{colSpan:e.filter(b=>b.enabled!==!1).length,style:{paddingBottom:p.tableLayout==="compact"?12:24,paddingTop:0},children:f.jsx(Le.CollapseColumn,{children:y})}),a!==void 0&&a.length>0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0},className:t.scrollRight?"pf-m-border-left":void 0,children:" "})]})]})}function tp(t){const{columns:e,item:r,rowActions:n}=t,[s,i]=S.useState(!1);return f.jsxs(S.Fragment,{children:[e.filter(o=>o.enabled!==!1).map(o=>f.jsx(Le.Td,{dataLabel:o.header,modifier:"nowrap",style:{width:o.minWidth===0?"0%":void 0},children:f.jsx(bt,{item:r,column:o})},o.header)),n!==void 0&&n.length>0&&f.jsx(Le.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,zIndex:s?301:void 0},className:t.scrollRight?"pf-m-border-left":void 0,children:f.jsx(rn,{actions:n,selectedItem:r,position:v.DropdownPosition.right,iconOnly:!0,onOpen:i})})]})}var Zl=(t=>(t[t.description=0]="description",t[t.hidden=1]="hidden",t[t.count=2]="count",t))(Zl||{});function bt(t){const{item:e,column:r}=t;if(!r)return f.jsx(f.Fragment,{});switch(r.type){case"text":return f.jsx(li,{text:r.value(e)});case"labels":return f.jsx(pl,{labels:r.value(e)??[]});case"description":return f.jsx(li,{text:r.value(e)});case"count":return f.jsx(f.Fragment,{children:r.value(e)??"-"});case"datetime":return f.jsx(ml,{value:r.value(e)});default:return f.jsx(f.Fragment,{children:r.cell(e)})}}function Si(t,e,r){var n,s,i,o,a;e==null&&(e=100);function l(){var d=Date.now()-o;d<e&&d>=0?n=setTimeout(l,e-d):(n=null,r||(a=t.apply(i,s),i=s=null))}var c=function(){i=this,s=arguments,o=Date.now();var d=r&&!n;return n||(n=setTimeout(l,e)),d&&(a=t.apply(i,s),i=s=null),a};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(a=t.apply(i,s),i=s=null,clearTimeout(n),n=null)},c}Si.debounce=Si;var rp=Si;function np(t,e,r){const{selectedItems:n,selectItem:s,unselectItem:i,isSelected:o,selectItems:a,unselectAll:l,allSelected:c}=Kl(t,e),{sorted:d,sort:h,setSort:u}=Ei(t),{filtered:m,setFilterFn:p}=$i(d,e),{searched:y,search:b,setSearch:T,setSearchFn:j}=sp(m,e,r==null?void 0:r.search),{paged:_,page:w,setPage:x,perPage:z,setPerPage:R}=bn(y),O=S.useCallback(()=>a(_),[_,a]),E=S.useCallback(()=>a(y),[y,a]);return S.useMemo(()=>({allSelected:c,filtered:m,isSelected:o,page:w,paged:_,perPage:z,search:b,searched:y,selectAll:E,selectItem:s,selectPage:O,selectedItems:n,setFilterFn:p,setPage:x,setPerPage:R,setSearch:T,setSearchFn:j,setSort:u,sort:h,sorted:d,unselectAll:l,unselectItem:i}),[c,m,o,w,_,z,b,y,E,s,O,n,p,x,R,T,j,u,h,d,l,i])}function Kl(t,e){const[r,n]=S.useState({});S.useEffect(()=>{n(m=>{let p=!1;return t.forEach(y=>{const b=e(y);m[b]&&m[b]!==y&&(p=!0,m[b]=y)}),p?{...m}:m})},[t,e]);const s=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]!==m&&(p={...p},p[y]=m),p})},[e]),i=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]&&(p={...p},delete p[y]),p})},[e]),o=S.useCallback(m=>{const p=e(m);return r[p]!==void 0},[e,r]),a=S.useCallback(m=>{n(p=>{p={...p};for(const y of m){const b=e(y);p[b]=y}return p})},[e]),l=S.useCallback(()=>a(t),[t,a]),c=S.useCallback(m=>{for(const p of m)i(p)},[i]),d=S.useCallback(()=>{n(m=>Object.keys(m).length>0?{}:m)},[]),h=S.useMemo(()=>Object.values(r),[r]),u=S.useMemo(()=>h.length===t.length,[t.length,h.length]);return S.useMemo(()=>({selectedItems:h,selectItem:s,unselectItem:i,isSelected:o,selectItems:a,selectAll:l,unselectAll:d,allSelected:u,keyFn:e,unselectItems:c}),[u,o,e,l,s,a,h,d,i,c])}function Jl(t,e){const[r,n]=S.useState({});S.useEffect(()=>{n(m=>{let p=!1;const y=t?t.reduce((j,_)=>{const w=e(_);return j[w]=_,m[w]&&m[w]!==_&&(p=!0,m[w]=_),j},{}):{},b={};for(const j in m)y[j]||(b[j]=!0);const T=Object.keys(b);if(T.length){p=!0;for(const j of T)delete m[j]}return p?{...m}:m})},[t,e]);const s=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]!==m&&(p={...p},p[y]=m),p})},[e]),i=S.useCallback(m=>{n(p=>{const y=e(m);return p[y]&&(p={...p},delete p[y]),p})},[e]),o=S.useCallback(m=>{for(const p of m)i(p)},[i]),a=S.useCallback(m=>{const p=e(m);return r[p]!==void 0},[e,r]),l=S.useCallback(m=>{n(p=>{p={...p};for(const y of m){const b=e(y);p[b]=y}return p})},[e]),c=S.useCallback(()=>{l(t??[])},[t,l]),d=S.useCallback(()=>{n(m=>Object.keys(m).length>0?{}:m)},[]),h=S.useMemo(()=>Object.values(r),[r]),u=S.useMemo(()=>h.length===(t==null?void 0:t.length),[t,h.length]);return S.useMemo(()=>({selectedItems:h,selectItem:s,unselectItem:i,isSelected:a,selectItems:l,selectAll:c,unselectAll:d,allSelected:u,keyFn:e,unselectItems:o}),[u,a,e,c,s,l,h,d,i,o])}function Ei(t){const[e,r]=S.useState(),{direction:n,sortFn:s}=e??{},i=S.useMemo(()=>t?s?n==="asc"?[...t.sort(s)]:[...t.sort(s).reverse()]:t:[],[n,t,s]);return S.useMemo(()=>({sorted:i,sort:e,setSort:r}),[e,i])}function $i(t,e){const r=S.useRef({map:{}}),[n,s]=S.useState(),i=S.useCallback(c=>s(()=>c),[]),[o,a]=S.useState([]);S.useEffect(()=>{r.current.map={}},[n]);const l=S.useCallback(c=>{const d=e(c);let h=r.current.map[d];return h?h.item!==c&&(h.item=c,h.passes=n?n(c):!0):(h={item:c,passes:n?n(c):!0},r.current.map[d]=h),h.passes},[n,e]);return S.useEffect(()=>{a(n?t.filter(l):t)},[t,n,l]),S.useMemo(function(){return{filtered:o,setFilterFn:i}},[o,i])}function sp(t,e,r){const n=S.useRef({map:{}}),[s,i]=S.useState(),o=S.useCallback(m=>i(()=>m),[]),[a,l]=S.useState([]),[c,d]=S.useState(r??""),h=S.useCallback(rp(m=>d(m),200),[]);S.useEffect(()=>{n.current.map={}},[c,s]);const u=S.useCallback(m=>{const p=e(m);let y=n.current.map[p];return y?y.item!==m&&(y.item=m,y.score=s?s(m,c):0):(y={item:m,score:s?s(m,c):0},n.current.map[p]=y),y},[e,s,c]);return S.useEffect(()=>{l(s&&c?t.map(u).filter(m=>m.score<.5).sort((m,p)=>m.score-p.score).map(m=>m.item):t)},[c,t,s,u]),S.useMemo(function(){return{searched:a,search:c,setSearch:h,setSearchFn:o}},[a,c,h,o])}function bn(t){const[e,r]=S.useState([]),[n,s]=S.useState(1),[i,o]=S.useState(10);return S.useEffect(()=>{r(a=>{const l=t.slice((n-1)*i,n*i);if(a.length!==l.length)return l;let c=0;for(const d of l)if(a[c++]!==d)return l;return a})},[n,i,t]),S.useEffect(()=>{n>Math.ceil(t.length/i)&&s(1)},[n,i,t.length]),S.useMemo(()=>({paged:e,page:n,setPage:s,perPage:i,setPerPage:o}),[n,e,i])}function ip(t){const{title:e,items:r,keyFn:n,actionColumns:s,actionFn:i,onComplete:o,onClose:a,processingText:l,isDanger:c}=t,[d]=pt(),[h,u]=S.useState(!0),[m,p]=S.useState(!1),[y,b]=S.useState(0),[T,j]=S.useState(""),[_,w]=S.useState(),[x]=S.useState(()=>new AbortController),[z,R]=Kt(),O=S.useCallback(()=>{p(!0),x.abort(),u(!1),w(K=>{const J={...K};for(const re of r){const se=n(re);J[se]===void 0&&(J[se]="Cancelled")}return J})},[x,r,n]),E=S.useCallback(()=>{R(void 0),a==null||a()},[a,R]);S.useEffect(()=>{async function K(){const J=hu(5);let re=0;const se=[];await Promise.all(r.map(I=>J(async()=>{if(x.signal.aborted)return;const $=n(I);try{await i(I,x.signal),x.signal.aborted||w(L=>({...L??{},[$]:null})),se.push(I)}catch(L){if(!x.signal.aborted){if(L instanceof Error){const q=L.message;w(Z=>({...Z??{},[$]:q}))}else w(q=>({...q??{},[$]:"Unknown error"}));j(d.errorText)}}finally{x.signal.aborted||b(++re)}}))),x.signal.aborted||u(!1),o==null||o(se)}K()},[x,i,r,n,o,d.errorText]);const{paged:C,page:D,perPage:F,setPage:V,setPerPage:G}=bn(r);return f.jsxs(v.Modal,{titleIconVariant:c?"warning":void 0,title:e,variant:v.ModalVariant.medium,isOpen:!0,onClose:()=>{O(),E()},actions:h?[f.jsx(v.Button,{variant:"link",onClick:O,children:d.cancelText},"cancel")]:[f.jsx(v.Button,{variant:"secondary",onClick:E,children:d.closeText},"close")],hasNoBodyWrapper:!0,children:[f.jsx(v.ModalBoxBody,{style:{paddingBottom:0,paddingLeft:0,paddingRight:0},children:f.jsx("div",{style:{display:"flex",flexDirection:"column",maxHeight:560,overflow:"hidden",borderTop:"thin solid var(--pf-global--BorderColor--100)"},children:f.jsx(vn,{pageItems:[...C],itemCount:r.length,tableColumns:[...s,{header:"Status",cell:K=>{const J=n(K),re=_==null?void 0:_[J];return re===void 0?f.jsxs("span",{style:{color:Ss},children:[f.jsx(Fe.PendingIcon,{}),"  ",d.pendingText]}):re===null?f.jsxs("span",{style:{color:ws},children:[f.jsx(Fe.CheckCircleIcon,{}),"  ",d.successText]}):f.jsxs("span",{style:{color:xs},children:[f.jsx(Fe.ExclamationCircleIcon,{}),"  ",_==null?void 0:_[J]]})}}],keyFn:n,page:D,perPage:F,setPage:V,setPerPage:G,compact:!0,errorStateTitle:"",emptyStateTitle:"No items",autoHidePagination:!0,disableBodyPadding:!0},"status")})}),f.jsx(v.ModalBoxBody,{style:{paddingTop:0},children:f.jsx(v.Progress,{value:y/r.length*100,title:x.signal.aborted?d.canceledText:T?d.errorText:h?l??d.processingText:d.successText,size:v.ProgressSize.lg,variant:T||m?v.ProgressVariant.danger:y===r.length?v.ProgressVariant.success:void 0})})]})}function Xl(){const[t,e]=Kt(),[r,n]=S.useState();return S.useEffect(()=>{if(r){const s=()=>{var i;n(void 0),(i=r.onClose)==null||i.call(r)};e(f.jsx(ip,{...r,onClose:s}))}else e(void 0)},[r,e]),n}function Ql(t,e){if(t==null&&e==null)return 0;if(t==null)return 1;if(e==null)return-1;if(typeof t=="string"){if(typeof e=="string")return wn(t,e);if(typeof e=="number")return wn(t,e.toString())}else if(typeof t=="number"){if(typeof e=="number")return ec(t,e);if(typeof e=="string")return wn(t.toString(),e)}return 0}function wn(t,e){return t==null&&e==null?0:t==null?1:e==null||t<e?-1:t>e?1:0}function ec(t,e){return t==null&&e==null?0:t==null?1:e==null||t<e?-1:t>e?1:0}const op=kr.div`
138
138
  display: flex;
139
139
  flex-direction: column;
140
140
  max-height: 560px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "A framework for building applications using PatternFly.",
4
- "version": "0.0.632",
4
+ "version": "0.0.633",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",