@ansible/ansible-ui-framework 2.4.669 → 2.4.670

Sign up to get free protection for your applications and to get access to all the features.
package/index.umd.cjs CHANGED
@@ -411,7 +411,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
411
411
  align-items: baseline;
412
412
  `;function Fve(e){const{item:t,itemToCardFn:n,isSelected:r,selectItem:i,unselectItem:a,itemActions:o,showSelect:l,defaultCardSubtitle:s}=e,c=x.useMemo(()=>n(t),[t,n]),u=!!(r!=null&&r(t)),f=x.useCallback(()=>{r!=null&&r(t)?a==null||a(t):i==null||i(t)},[r,t,i,a]),d=o!==void 0&&o.length>0,h=l||d;return p.jsxs(T.Card,{id:c.id,ouiaId:c.id,isFlat:!0,isLarge:!0,isRounded:!0,isSelectable:u,isSelected:u,style:{transition:"box-shadow 0.25s",cursor:"default",maxWidth:"100%"},children:[p.jsx(T.CardHeader,{...h&&{actions:{actions:p.jsxs(p.Fragment,{children:[o&&o.length&&p.jsx(Oo,{actions:o,position:Fn.right,selectedItem:t,iconOnly:!0,collapse:"always"}),l&&p.jsx(T.Checkbox,{isChecked:r==null?void 0:r(t),onChange:f,id:"check-1"})]}),hasNoOffset:!1,className:void 0}},style:{display:"flex",flexWrap:"nowrap",maxWidth:"100%"},children:p.jsxs(kve,{children:[p.jsxs(jve,{children:[c.iconAboveTitle?null:c.icon&&p.jsx(gs,{size:"xl",children:c.icon}),p.jsxs($ve,{children:[c.iconAboveTitle?p.jsx(Pve,{children:c.icon&&p.jsx(gs,{size:"xl",children:c.icon})}):null,p.jsx(T.CardTitle,{children:p.jsx(T.Truncate,{content:c.title})}),c.subtitle?p.jsx(T.Text,{component:"small",style:{opacity:.7},children:c.subtitle}):s&&p.jsx(T.Text,{component:"small",style:{opacity:.7},children:s})]})]}),c.badge&&c.badgeTooltip&&p.jsx(T.FlexItem,{children:p.jsx("div",{onClick:m=>m.stopPropagation(),children:p.jsx(T.Popover,{headerContent:c.badgeTooltipTitle,bodyContent:c.badgeTooltip,children:p.jsx(T.Label,{color:c.badgeColor,children:c.badge})})})}),c.badge&&!c.badgeTooltip&&p.jsx(T.FlexItem,{children:p.jsx(T.Label,{color:c.badgeColor,children:c.badge})})]})}),c.cardBody,c.labels&&p.jsx(T.CardFooter,{children:p.jsx(Dve,{children:p.jsx(Mve,{children:c.labels&&p.jsx(T.LabelGroup,{numLabels:999,children:c.labels.map(m=>p.jsx(T.Label,{color:m.color,icon:m.icon,variant:m.variant,children:p.jsx(T.Truncate,{content:m.label,style:{minWidth:0}})},m.label))})})})}),c.alertTitle&&p.jsx(T.Alert,{title:c.alertTitle,isInline:!0,variant:c.alertVariant,children:c.alertContent})]},c.id??c.title)}function Nve(e,t){const n=x.useMemo(()=>{let c,u,f;const d=[];let h;const m=[];for(const g of e)if(g.card!=="hidden")switch(g.type){case"description":f||(f=g);break;case"labels":h||(h=g);break;case"count":d.push(g);break;default:switch(g.card){case"name":c=g;break;case"subtitle":u=g;break;case"description":f=g;break;default:m.push(g);break}break}return{nameColumn:c,subtitleColumn:u,descriptionColumn:f,countColumns:d,cardColumns:m,labelColumn:h}},[e]),{nameColumn:r,subtitleColumn:i,descriptionColumn:a,countColumns:o,cardColumns:l,labelColumn:s}=n;return x.useMemo(()=>c=>{var h,m;let u=!!a;a!=null&&a.value&&!a.value(c)&&(u=!1);const f=l.filter(g=>!g.value||g.value(c)),d={id:t(c),icon:(h=r==null?void 0:r.icon)==null?void 0:h.call(r,c),title:p.jsx(nn,{column:r,item:c}),subtitle:i&&(!i.value||i.value(c))&&p.jsx(nn,{column:i,item:c}),cardBody:p.jsx(T.CardBody,{children:p.jsxs(T.DescriptionList,{isCompact:!0,children:[u&&a&&p.jsx(gc,{children:a.type==="description"?p.jsx("div",{children:a.value(c)}):p.jsx(nn,{column:a,item:c})},a.id??a.header),f.map(g=>p.jsx(gc,{label:g.header,children:p.jsx(nn,{column:g,item:c})},g.id??g.header)),o.length>0&&p.jsx(gc,{children:p.jsx(Ive,{children:o.map((g,y)=>p.jsxs(Lve,{children:[p.jsx(nn,{column:g,item:c}),p.jsx(Ave,{children:g.header})]},y))})},"count-columns")]})}),labels:s&&((m=s.value(c))==null?void 0:m.map(g=>({label:g})))};return!u&&f.length===0&&o.length===0&&(d.cardBody=void 0),d},[l,o,a,s,r,i,t])}function Uy(e){const{keyFn:t,pageItems:n,tableColumns:r,isSelected:i,selectItem:a,unselectItem:o,rowActions:l,showSelect:s,defaultSubtitle:c}=e,u=Nve(r,t),f=x.useMemo(()=>p.jsx(Eve,{size:400,children:n==null?void 0:n.map(d=>p.jsx(Fve,{item:d,itemToCardFn:u,isSelected:i,selectItem:a,unselectItem:o,itemActions:l,showSelect:s,defaultCardSubtitle:c},t(d)))}),[n,t,u,i,a,o,l,s,c]);return p.jsx(T.PageSection,{style:{flexGrow:1},children:f})}function qk(e){const{keyFn:t,pageItems:n,tableColumns:r,isSelected:i,selectItem:a,unselectItem:o,rowActions:l,defaultSubtitle:s,showSelect:c}=e,u=Rve(r,t,i,a,o,l,s,c);return p.jsx(T.DataList,{"aria-label":"TODO",style:{marginTop:-1,maxWidth:"100%",overflow:"hidden"},children:n==null?void 0:n.map(u)})}function Rve(e,t,n,r,i,a,o,l){const s=x.useMemo(()=>{let _,b,S;const C=[];let w;const E=[],A=[];for(const k of e)if(k.list!=="hidden")switch(k.type){case"description":S||(S=k);break;case"labels":w||(w=k);break;case"count":C.push(k);break;default:switch(k.list){case"name":_=k;break;case"subtitle":b=k;break;case"description":S=k;break;case"secondary":A.push(k);break;default:E.push(k);break}break}return{nameColumn:_,subtitleColumn:b,descriptionColumn:S,countColumns:C,primaryColumns:E,secondaryColumns:A,labelColumn:w}},[e]),c=x.useCallback(_=>{n!=null&&n(_)?i==null||i(_):r==null||r(_)},[n,r,i]),{nameColumn:u,subtitleColumn:f,descriptionColumn:d,countColumns:h,primaryColumns:m,secondaryColumns:g,labelColumn:y}=s;return x.useCallback(_=>{const b=t(_),S=n==null?void 0:n(_);return p.jsx(T.DataListItem,{"aria-labelledby":`data-list-${b}`,isExpanded:S,children:p.jsxs(T.DataListItemRow,{children:[l&&p.jsx(T.DataListCheck,{"aria-labelledby":`data-list-check-${b}`,name:`data-list-check-${b}`,isChecked:n==null?void 0:n(_),onClick:()=>c(_)}),p.jsx(T.DataListItemCells,{dataListCells:[p.jsx(T.DataListCell,{width:5,children:p.jsx(T.Flex,{children:p.jsxs(T.Stack,{hasGutter:!0,children:[p.jsxs(T.Flex,{alignItems:{default:"alignItemsCenter"},children:[(u==null?void 0:u.icon)&&p.jsx(gs,{size:"xl",children:u==null?void 0:u.icon(_)}),p.jsxs(T.Stack,{children:[p.jsx(T.Title,{headingLevel:"h2",style:{marginTop:-4,fontWeight:"bold"},children:p.jsx("span",{id:`data-list-${b}`,children:p.jsx(nn,{column:u,item:_})})}),f?p.jsx(T.Text,{component:"small",style:{opacity:.7},children:p.jsx(nn,{column:f,item:_})}):o&&p.jsx(T.Text,{component:"small",style:{opacity:.7},children:o})]})]}),(d||m.length>0||h.length>0||y)&&p.jsxs(T.DescriptionList,{isCompact:!0,children:[d&&(!d.value||d.value(_))&&p.jsx(T.DescriptionListGroup,{children:p.jsx(T.DescriptionListDescription,{children:p.jsx(nn,{column:d,item:_})})},d.header),m.map(C=>C.value&&!C.value(_)?p.jsx(p.Fragment,{}):p.jsxs(T.DescriptionListGroup,{children:[p.jsx(T.DescriptionListTerm,{style:{whiteSpace:"nowrap",opacity:.6},children:C.header}),p.jsx(T.DescriptionListDescription,{children:p.jsx(nn,{column:C,item:_})})]},C.header)),h.length>0&&p.jsx(T.DescriptionListGroup,{children:p.jsx(T.DescriptionListDescription,{children:p.jsx("div",{style:{display:"flex",gap:16,marginTop:8,flexWrap:"wrap"},children:h.map((C,w)=>p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[p.jsx(nn,{column:C,item:_}),p.jsx("small",{style:{opacity:.7},children:C.header})]},w))})})},"counts"),y&&p.jsx(T.DescriptionListGroup,{children:p.jsx(T.DescriptionListDescription,{children:p.jsx(nn,{column:y,item:_})})},y.header)]})]})})},"primary"),g.length>0?p.jsx(T.DataListCell,{children:p.jsx(T.DescriptionList,{isCompact:!0,children:g.map(C=>C.value&&!C.value(_)?p.jsx(p.Fragment,{}):p.jsxs(T.DescriptionListGroup,{children:[p.jsx(T.DescriptionListTerm,{style:{whiteSpace:"nowrap",opacity:.6},children:C.header}),p.jsx(T.DescriptionListDescription,{children:p.jsx(nn,{column:C,item:_})})]},C.header))})},"secondary"):null]}),a&&p.jsx(T.DataListAction,{"aria-labelledby":"check-action-item1 check-action-action1",id:"check-action-action1","aria-label":"Actions",isPlainButtonAction:!0,style:{whiteSpace:"nowrap"},children:p.jsx(Oo,{actions:a,position:Fn.right,selectedItem:_,iconOnly:!0,collapse:"always"})})]})},b)},[t,n,l,u,f,o,m,d,h,y,g,a,c])}const zve=Ve.div`
413
413
  height: 100%;
414
- `;function yc(e){const{id:t,toolbarActions:n,filterState:r,error:i,itemCount:a}=e,{openColumnManagement:o,managedColumns:l}=Cve((t??"")+"-columns",e.tableColumns,e.disableTableView,e.disableListView,e.disableCardView),s=e.showSelect||(n==null?void 0:n.find(y=>"selection"in y&&y.selection===yt.Multiple))!==void 0,c=!e.disableTableView,u=!e.disableListView,[f,d]=x.useState(()=>{switch(e.id?localStorage.getItem(e.id+"-view"):void 0){case"table":return st.Table;case"list":return st.List;case"cards":return st.Cards}return e.defaultTableView??(c?st.Table:u?st.List:st.Cards)}),h=x.useCallback(y=>{d(y),e.id&&localStorage.setItem(e.id+"-view",y)},[e.id]),m=fve(e.tableColumns);if(i)return p.jsx(mve,{titleProp:e.errorStateTitle,message:i.message});if(a===0&&Object.keys(r??{}).length===0)return p.jsx(gve,{title:e.emptyStateTitle,description:e.emptyStateDescription,button:e.emptyStateButtonClick&&p.jsx(T.Button,{variant:"primary",onClick:e.emptyStateButtonClick,icon:e.emptyStateButtonIcon?e.emptyStateButtonIcon:null,children:e.emptyStateButtonText})||e.emptyStateActions&&p.jsx(T.Flex,{justifyContent:{default:"justifyContentCenter"},children:p.jsx(Oo,{actions:e.emptyStateActions})})});let g=e.topContent;return g&&(g=p.jsx(T.PageSection,{variant:"light",padding:{default:"noPadding"},style:{borderBottom:"thin solid var(--pf-v5-global--BorderColor--100)"},children:e.topContent})),p.jsxs(p.Fragment,{children:[p.jsx(Uk,{...e,openColumnModal:e.id?o:void 0,showSelect:s,viewType:f,setViewType:h,sortOptions:m}),f===st.Table&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,!e.hideTable&&p.jsx(Yk,{...e,tableColumns:l})]}):p.jsxs(p.Fragment,{children:[g,!e.hideTable&&p.jsx(Yk,{...e,tableColumns:l})]})}),f===st.List&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,p.jsx(T.PageSection,{padding:{default:"noPadding"},children:!e.hideTable&&p.jsx(qk,{...e,showSelect:s,tableColumns:l})})]}):p.jsxs(p.Fragment,{children:[g,p.jsx(ea,{children:p.jsx(T.PageSection,{padding:{default:"noPadding"},children:!e.hideTable&&p.jsx(qk,{...e,showSelect:s,tableColumns:l})})})]})}),f===st.Cards&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,!e.hideTable&&p.jsx(Uy,{...e,showSelect:s,tableColumns:l})]}):p.jsxs(p.Fragment,{children:[g,p.jsx(ea,{children:!e.hideTable&&p.jsx(Uy,{...e,showSelect:s,tableColumns:l})})]})}),!e.disablePagination&&(!e.autoHidePagination||(e.itemCount??0)>e.perPage)&&p.jsx(Tve,{...e,topBorder:!0})]})}function Yk(e){const{pageItems:t,selectItem:n,unselectItem:r,isSelected:i,isSelectMultiple:a,keyFn:o,rowActions:l,toolbarActions:s,itemCount:c,clearAllFilters:u,onSelect:f,unselectAll:d,maxSelections:h}=e,m=Ly(e.tableColumns),g=Mk(e.tableColumns),y=Ik(e.tableColumns),_=x.useMemo(()=>{const P=[];if(g.length)for(const $ of g)"value"in $?P.push(j=>{var ee;const B=(ee=$.value)==null?void 0:ee.call($,j);if(B)return p.jsx("div",{children:B},$.id??$.header)}):P.push(j=>$.cell(j));return y.length&&P.push($=>p.jsx(Lk,{item:$,columns:y,disablePadding:!0,numberOfColumns:"multiple"},o($))),e.expandedRow&&P.push(e.expandedRow),P.length===0?void 0:P.length===1?P[0]:$=>p.jsx(T.Stack,{hasGutter:!0,style:{gap:12},children:P.map(j=>j($))})},[g,y,o,e.expandedRow]),[b]=Tt(),S=e.showSelect||(s==null?void 0:s.find(P=>"selection"in P&&P.selection===yt.Multiple))!==void 0,C=x.useRef(null),[w,E]=x.useState({left:0,right:0,top:0,bottom:0}),A=x.useCallback(P=>{P&&E({top:P.scrollTop,bottom:P.scrollHeight-P.clientHeight-P.scrollTop,left:P.scrollLeft,right:P.scrollWidth-P.clientWidth-P.scrollLeft})},[]),k=x.useCallback(P=>A(P.currentTarget),[A]);Lo(C,()=>A(C.current)),x.useEffect(()=>A(C.current),[A]);const D=To();let I;return e.itemCount===void 0||t===void 0?I=p.jsx(Ove,{}):I=p.jsxs(p.Fragment,{children:[p.jsxs(ze.Table,{"aria-label":"Simple table",ouiaId:"simple-table",variant:e.compact||D.tableLayout==="compact"?"compact":void 0,gridBreakPoint:"",isStickyHeader:!0,className:"page-table",children:[p.jsx(Bve,{...e,showSelect:S,scrollLeft:w.left>0,scrollRight:w.right>1,tableColumns:m,onSelect:f,expandedRow:_}),p.jsx(ze.Tbody,{children:t.map((P,M)=>p.jsx(Wve,{columns:m,item:P,isItemSelected:i==null?void 0:i(P),isSelectMultiple:a,selectItem:n,unselectItem:r,rowActions:l,rowIndex:M,showSelect:S,scrollLeft:w.left>0,scrollRight:w.right>1,unselectAll:d,onSelect:f,expandedRow:_,isLastRow:M===t.length-1,disableLastRowBorder:e.disableLastRowBorder,maxSelections:h,selectedItems:e.selectedItems},o?o(P):M))})]}),c===0&&p.jsxs(T.EmptyState,{isFullHeight:!0,children:[p.jsx(T.EmptyStateHeader,{titleText:p.jsx(p.Fragment,{children:b.noResultsFound}),icon:p.jsx(T.EmptyStateIcon,{icon:Ce.SearchIcon}),headingLevel:"h2"}),p.jsx(T.EmptyStateBody,{children:b.noResultsMatchCriteria}),p.jsx(T.EmptyStateFooter,{children:u&&p.jsx(T.EmptyStateActions,{children:p.jsx(T.Button,{variant:"primary",onClick:u,children:b.clearAllFilters})})})]})]}),e.scrollTopContent||(I=p.jsx(zve,{className:"pf-v5-c-scroll-inner-wrapper",ref:C,onScroll:k,style:{backgroundColor:"var(--pf-v5-global--BackgroundColor--100)"},children:I})),I}function Bve(e){const{tableColumns:t,rowActions:n,sort:r,setSort:i,sortDirection:a,setSortDirection:o,showSelect:l,onSelect:s,expandedRow:c}=e,u=x.useCallback((f,d)=>{if(d.sort)return{onSort:(h,m,g)=>{d.sort&&(i==null||i(d.sort),o==null||o(g))},sortBy:{index:d.sort===r?f:void 0,direction:d.sort===r?a:void 0,defaultDirection:d.defaultSortDirection},columnIndex:f}},[i,o,r,a]);return p.jsx(ze.Thead,{children:p.jsxs(ze.Tr,{className:"bg-lighten",children:[c&&p.jsx(ze.Th,{style:{padding:0},className:"bg-lighten"}),(l||s)&&p.jsx(ze.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"selections-column-header",className:e.scrollLeft?"bg-lighten-2 border-left":"bg-lighten",children:" "}),t.map((f,d)=>p.jsx(ze.Th,{sort:u(d,f),modifier:"nowrap",style:{minWidth:f.minWidth===0?"1%":f.minWidth!==void 0?f.minWidth:void 0,maxWidth:f.maxWidth!==void 0?f.maxWidth:void 0},"data-cy":vi(f.header+"-column-header"),className:"bg-lighten",children:f.header},f.header)),n!==void 0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,zIndex:302},className:e.scrollRight?"pf-m-border-left bg-lighten-2":"bg-lighten","data-cy":"action-column-header",children:" "})]})})}function Wve(e){const{columns:t,unselectAll:n,selectItem:r,unselectItem:i,isItemSelected:a,isSelectMultiple:o,item:l,rowActions:s,rowIndex:c,showSelect:u,onSelect:f,expandedRow:d,disableLastRowBorder:h,maxSelections:m,selectedItems:g}=e,[y,_]=x.useState(!1),b=To(),S=d==null?void 0:d(l),C=x.useCallback(w=>(g==null?void 0:g.length)===m?!(g!=null&&g.includes(w)):!1,[m,g]);return p.jsxs(p.Fragment,{children:[p.jsxs(ze.Tr,{isRowSelected:a,style:{boxShadow:"unset",borderBottom:y||e.isLastRow&&h?"unset":void 0},"data-cy":"id"in l&&(typeof l.id=="string"||typeof l.id=="number")?`row-id-${l.id.toString()}`:`row-${c}`,children:[d&&p.jsx(ze.Td,{expand:S?{rowIndex:c,isExpanded:y,onToggle:()=>_(w=>!w)}:void 0,style:{paddingLeft:S?8:4},"data-cy":"expand-column-cell"}),u&&p.jsx(ze.Th,{select:a!==void 0?{onSelect:(w,E)=>{E?r==null||r(l):i==null||i(l)},isSelected:a,isDisabled:m&&g?C(l):!1}:void 0,isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"checkbox-column-cell",className:e.scrollLeft?"bg-lighten":void 0}),f&&p.jsx(ze.Td,{select:{rowIndex:c,onSelect:()=>{o||n==null||n(),r==null||r(l),f==null||f(l)},isSelected:a??!1,variant:o?"checkbox":"radio",isDisabled:m&&g?C(l):!1},isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"checkbox-column-cell",className:e.scrollLeft?"bg-lighten":void 0}),p.jsx(Vve,{columns:t,item:l,rowActions:s,scrollLeft:e.scrollLeft,scrollRight:e.scrollRight})]}),d&&y&&S&&p.jsxs(ze.Tr,{isRowSelected:a,isExpanded:y,style:{boxShadow:"unset"},children:[p.jsx(ze.Td,{}),u&&p.jsx(ze.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft}),f&&p.jsx(ze.Td,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft}),p.jsx(ze.Td,{colSpan:t.length,style:{paddingBottom:b.tableLayout==="compact"?12:24,paddingTop:0},children:p.jsx(ze.CollapseColumn,{children:S})}),s!==void 0&&s.length>0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0},className:e.scrollRight?"pf-m-border-left bg-lighten":void 0,children:" "})]})]})}function Vve(e){const{columns:t,item:n,rowActions:r}=e,[i,a]=x.useState(!1);return p.jsxs(x.Fragment,{children:[t.map(o=>p.jsx(ze.Td,{dataLabel:o.header,modifier:"nowrap",style:{width:o.minWidth===0?"0%":void 0},"data-cy":vi(o.header+"-column-cell"),children:p.jsx(nn,{item:n,column:o})},o.header)),r!==void 0&&r.length>0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:8,zIndex:i?400:void 0},"data-cy":"actions-column-cell",className:e.scrollRight?"pf-m-border-left bg-lighten":void 0,children:p.jsx(Oo,{actions:r,selectedItem:n,position:Fn.right,iconOnly:!0,onOpen:a})})]})}function Kk(e){const{title:t,items:n,keyFn:r,actionColumns:i,actionFn:a,onComplete:o,onClose:l,processingText:s,isDanger:c}=e,{t:u}=ut(),[f]=Tt(),[d,h]=x.useState(!0),[m,g]=x.useState(!1),[y,_]=x.useState(0),[b,S]=x.useState(""),[C,w]=x.useState(),E=rve(),[A,k]=Hr(),D=x.useCallback(()=>{g(!0),E.abort(),h(!1),w($=>{const j={...$};for(const B of n){const ee=r(B);j[ee]===void 0&&(j[ee]=u("Cancelled"))}return j})},[E,n,r,u]),I=x.useCallback(()=>{k(void 0),l==null||l()},[l,k]);x.useEffect(()=>{async function $(){const j=nve(5);let B=0;const ee=[];await Promise.all(n.map(J=>j(async()=>{if(E.signal.aborted)return;const X=r(J);try{await a(J,E.signal),E.signal.aborted||w(Q=>({...Q??{},[X]:null})),ee.push(J)}catch(Q){if(!E.signal.aborted){if(Q instanceof Error){const V=Q.message;w(Z=>({...Z??{},[X]:V}))}else w(V=>({...V??{},[X]:u("Unknown error")}));S(f.errorText)}}finally{E.signal.aborted||_(++B)}}))),E.signal.aborted||h(!1),o==null||o(ee)}$()},[E,a,n,r,o,f.errorText,u]);const P=vc(n),M=Fy(i);return p.jsxs(T.Modal,{titleIconVariant:c?"warning":void 0,title:t,ouiaId:t,"aria-label":t,variant:T.ModalVariant.medium,isOpen:!0,onClose:()=>{D(),I()},actions:d?[p.jsx(T.Button,{variant:"link",onClick:D,children:f.cancelText},"cancel")]:[p.jsx(T.Button,{variant:"secondary",onClick:I,children:f.closeText},"close")],hasNoBodyWrapper:!0,children:[p.jsx(T.ModalBoxBody,{style:{paddingBottom:0,paddingLeft:0,paddingRight:0},children:p.jsx("div",{style:{display:"flex",flexDirection:"column",maxHeight:560,overflow:"hidden",borderTop:"thin solid var(--pf-v5-global--BorderColor--100)"},children:p.jsx(yc,{pageItems:[...P.paged],itemCount:n.length,tableColumns:[...M,{header:u("Status"),cell:$=>{const j=r($),B=C==null?void 0:C[j];return B===void 0?p.jsxs("span",{style:{color:mp},children:[p.jsx(Ce.PendingIcon,{}),"  ",f.pendingText]}):B===null?p.jsxs("span",{style:{color:dp},children:[p.jsx(Ce.CheckCircleIcon,{}),"  ",f.successText]}):p.jsxs("span",{style:{color:hp},children:[p.jsx(Ce.ExclamationCircleIcon,{}),"  ",C==null?void 0:C[j]]})}}],keyFn:r,compact:!0,errorStateTitle:"",emptyStateTitle:u("No items"),autoHidePagination:!0,disableBodyPadding:!0,...P},"status")})}),p.jsx(T.ModalBoxBody,{style:{paddingTop:0},children:p.jsx(T.Progress,{"data-cy":"progress",value:y/n.length*100,title:E.signal.aborted?f.canceledText:b?f.errorText:d?s??f.processingText:f.successText,size:T.ProgressSize.lg,variant:b||m?T.ProgressVariant.danger:y===n.length?T.ProgressVariant.success:void 0})})]})}function Xk(){const[e,t]=Hr(),[n,r]=x.useState();return x.useEffect(()=>{if(n){const i=()=>{var a;r(void 0),(a=n.onClose)==null||a.call(n)};t(p.jsx(Kk,{...n,onClose:i}))}else t(void 0)},[n,t]),r}function Zk(e,t){if(e==null&&t==null)return 0;if(e==null)return 1;if(t==null)return-1;if(typeof e=="string"){if(typeof t=="string")return bc(e,t);if(typeof t=="number")return bc(e,t.toString())}else if(typeof e=="number"){if(typeof t=="number")return Jk(e,t);if(typeof t=="string")return bc(e.toString(),t)}return 0}function bc(e,t){return e==null&&t==null?0:e==null?1:t==null||e<t?-1:e>t?1:0}function Jk(e,t){return e==null&&t==null?0:e==null?1:t==null||e<t?-1:e>t?1:0}const Hve=Ve.div`
414
+ `;function yc(e){const{id:t,toolbarActions:n,filterState:r,error:i,itemCount:a}=e,{openColumnManagement:o,managedColumns:l}=Cve((t??"")+"-columns",e.tableColumns,e.disableTableView,e.disableListView,e.disableCardView),s=e.showSelect||(n==null?void 0:n.find(y=>"selection"in y&&y.selection===yt.Multiple))!==void 0,c=!e.disableTableView,u=!e.disableListView,[f,d]=x.useState(()=>{switch(e.id?localStorage.getItem(e.id+"-view"):void 0){case"table":return st.Table;case"list":return st.List;case"cards":return st.Cards}return e.defaultTableView??(c?st.Table:u?st.List:st.Cards)}),h=x.useCallback(y=>{d(y),e.id&&localStorage.setItem(e.id+"-view",y)},[e.id]),m=fve(e.tableColumns);if(i)return p.jsx(mve,{titleProp:e.errorStateTitle,message:i.message});if(a===0&&Object.keys(r??{}).length===0)return p.jsx(gve,{title:e.emptyStateTitle,description:e.emptyStateDescription,button:e.emptyStateButtonClick&&p.jsx(T.Button,{variant:"primary",onClick:e.emptyStateButtonClick,icon:e.emptyStateButtonIcon?e.emptyStateButtonIcon:null,children:e.emptyStateButtonText})||e.emptyStateActions&&p.jsx(T.Flex,{justifyContent:{default:"justifyContentCenter"},children:p.jsx(Oo,{actions:e.emptyStateActions})})});let g=e.topContent;return g&&(g=p.jsx(T.PageSection,{variant:"light",padding:{default:"noPadding"},style:{borderBottom:"thin solid var(--pf-v5-global--BorderColor--100)"},children:e.topContent})),p.jsxs(p.Fragment,{children:[p.jsx(Uk,{...e,openColumnModal:e.id?o:void 0,showSelect:s,viewType:f,setViewType:h,sortOptions:m}),f===st.Table&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,!e.hideTable&&p.jsx(Yk,{...e,tableColumns:l})]}):p.jsxs(p.Fragment,{children:[g,!e.hideTable&&p.jsx(Yk,{...e,tableColumns:l})]})}),f===st.List&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,p.jsx(T.PageSection,{padding:{default:"noPadding"},children:!e.hideTable&&p.jsx(qk,{...e,showSelect:s,tableColumns:l})})]}):p.jsxs(p.Fragment,{children:[g,p.jsx(ea,{children:p.jsx(T.PageSection,{padding:{default:"noPadding"},children:!e.hideTable&&p.jsx(qk,{...e,showSelect:s,tableColumns:l})})})]})}),f===st.Cards&&p.jsx(p.Fragment,{children:e.scrollTopContent?p.jsxs(ea,{children:[g,!e.hideTable&&p.jsx(Uy,{...e,showSelect:s,tableColumns:l})]}):p.jsxs(p.Fragment,{children:[g,p.jsx(ea,{children:!e.hideTable&&p.jsx(Uy,{...e,showSelect:s,tableColumns:l})})]})}),!e.disablePagination&&(!e.autoHidePagination||(e.itemCount??0)>e.perPage)&&p.jsx(Tve,{...e,topBorder:!0})]})}function Yk(e){const{pageItems:t,selectItem:n,unselectItem:r,isSelected:i,isSelectMultiple:a,keyFn:o,rowActions:l,toolbarActions:s,itemCount:c,clearAllFilters:u,onSelect:f,unselectAll:d,maxSelections:h}=e,m=Ly(e.tableColumns),g=Mk(e.tableColumns),y=Ik(e.tableColumns),_=x.useMemo(()=>{const P=[];if(g.length)for(const $ of g)"value"in $?P.push(j=>{var ee;const B=(ee=$.value)==null?void 0:ee.call($,j);if(B)return p.jsx("div",{children:B},$.id??$.header)}):P.push(j=>$.cell(j));return y.length&&P.push($=>p.jsx(Lk,{item:$,columns:y,disablePadding:!0,numberOfColumns:"multiple"},o($))),e.expandedRow&&P.push(e.expandedRow),P.length===0?void 0:P.length===1?P[0]:$=>p.jsx(T.Stack,{hasGutter:!0,style:{gap:12},children:P.map(j=>j($))})},[g,y,o,e.expandedRow]),[b]=Tt(),S=e.showSelect||(s==null?void 0:s.find(P=>"selection"in P&&P.selection===yt.Multiple))!==void 0,C=x.useRef(null),[w,E]=x.useState({left:0,right:0,top:0,bottom:0}),A=x.useCallback(P=>{P&&E({top:P.scrollTop,bottom:P.scrollHeight-P.clientHeight-P.scrollTop,left:P.scrollLeft,right:P.scrollWidth-P.clientWidth-P.scrollLeft})},[]),k=x.useCallback(P=>A(P.currentTarget),[A]);Lo(C,()=>A(C.current)),x.useEffect(()=>A(C.current),[A]);const D=To();let I;return e.itemCount===void 0||t===void 0?I=p.jsx(Ove,{}):I=p.jsxs(p.Fragment,{children:[p.jsxs(ze.Table,{"aria-label":"Simple table",ouiaId:"simple-table",variant:e.compact||D.tableLayout==="compact"?"compact":void 0,gridBreakPoint:"",isStickyHeader:!0,className:"page-table",children:[p.jsx(Bve,{...e,showSelect:S,scrollLeft:w.left>0,scrollRight:w.right>1,tableColumns:m,onSelect:f,expandedRow:_}),p.jsx(ze.Tbody,{children:t.map((P,M)=>p.jsx(Wve,{columns:m,item:P,isItemSelected:i==null?void 0:i(P),isSelectMultiple:a,selectItem:n,unselectItem:r,rowActions:l,rowIndex:M,showSelect:S,scrollLeft:w.left>0,scrollRight:w.right>1,unselectAll:d,onSelect:f,expandedRow:_,isLastRow:M===t.length-1,disableLastRowBorder:e.disableLastRowBorder,maxSelections:h,selectedItems:e.selectedItems},o?o(P):M))})]}),c===0&&p.jsxs(T.EmptyState,{isFullHeight:!0,children:[p.jsx(T.EmptyStateHeader,{titleText:p.jsx(p.Fragment,{children:b.noResultsFound}),icon:p.jsx(T.EmptyStateIcon,{icon:Ce.SearchIcon}),headingLevel:"h2"}),p.jsx(T.EmptyStateBody,{children:b.noResultsMatchCriteria}),p.jsx(T.EmptyStateFooter,{children:u&&p.jsx(T.EmptyStateActions,{children:p.jsx(T.Button,{variant:"primary",onClick:u,children:b.clearAllFilters})})})]})]}),e.scrollTopContent||(I=p.jsx(zve,{className:"pf-v5-c-scroll-inner-wrapper",ref:C,onScroll:k,style:{backgroundColor:"var(--pf-v5-global--BackgroundColor--100)"},children:I})),I}function Bve(e){const{tableColumns:t,rowActions:n,sort:r,setSort:i,sortDirection:a,setSortDirection:o,showSelect:l,onSelect:s,expandedRow:c}=e,u=x.useCallback((f,d)=>{if(d.sort)return{onSort:(h,m,g)=>{d.sort&&(i==null||i(d.sort),o==null||o(g))},sortBy:{index:d.sort===r?f:void 0,direction:d.sort===r?a:void 0,defaultDirection:d.defaultSortDirection},columnIndex:f}},[i,o,r,a]);return p.jsx(ze.Thead,{children:p.jsxs(ze.Tr,{className:"bg-lighten",children:[c&&p.jsx(ze.Th,{style:{padding:0},className:"bg-lighten"}),(l||s)&&p.jsx(ze.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"selections-column-header",className:e.scrollLeft?"bg-lighten-2 border-left":"bg-lighten",children:" "}),t.map((f,d)=>p.jsx(ze.Th,{sort:u(d,f),modifier:"nowrap",style:{minWidth:f.minWidth===0?"1%":f.minWidth!==void 0?f.minWidth:void 0,maxWidth:f.maxWidth!==void 0?f.maxWidth:void 0},"data-cy":vi(f.header+"-column-header"),className:"bg-lighten",children:f.header},f.header)),n!==void 0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0,zIndex:302},className:e.scrollRight?"pf-m-border-left bg-lighten-2":"bg-lighten","data-cy":"action-column-header",children:" "})]})})}function Wve(e){const{columns:t,unselectAll:n,selectItem:r,unselectItem:i,isItemSelected:a,isSelectMultiple:o,item:l,rowActions:s,rowIndex:c,showSelect:u,onSelect:f,expandedRow:d,disableLastRowBorder:h,maxSelections:m,selectedItems:g}=e,[y,_]=x.useState(!1),b=To(),S=d==null?void 0:d(l),C=x.useCallback(w=>(g==null?void 0:g.length)===m?!(g!=null&&g.includes(w)):!1,[m,g]);return p.jsxs(p.Fragment,{children:[p.jsxs(ze.Tr,{style:{boxShadow:"unset",borderBottom:y||e.isLastRow&&h?"unset":void 0},"data-cy":"id"in l&&(typeof l.id=="string"||typeof l.id=="number")?`row-id-${l.id.toString()}`:`row-${c}`,children:[d&&p.jsx(ze.Td,{expand:S?{rowIndex:c,isExpanded:y,onToggle:()=>_(w=>!w)}:void 0,style:{paddingLeft:S?8:4},"data-cy":"expand-column-cell"}),u&&p.jsx(ze.Th,{select:a!==void 0?{onSelect:(w,E)=>{E?r==null||r(l):i==null||i(l)},isSelected:a,isDisabled:m&&g?C(l):!1}:void 0,isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"checkbox-column-cell",className:e.scrollLeft?"bg-lighten":void 0}),f&&p.jsx(ze.Td,{select:{rowIndex:c,onSelect:()=>{o||n==null||n(),r==null||r(l),f==null||f(l)},isSelected:a??!1,variant:o?"checkbox":"radio",isDisabled:m&&g?C(l):!1},isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft,"data-cy":"checkbox-column-cell",className:e.scrollLeft?"bg-lighten":void 0}),p.jsx(Vve,{columns:t,item:l,rowActions:s,scrollLeft:e.scrollLeft,scrollRight:e.scrollRight})]}),d&&y&&S&&p.jsxs(ze.Tr,{isExpanded:y,style:{boxShadow:"unset"},children:[p.jsx(ze.Td,{}),u&&p.jsx(ze.Th,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft}),f&&p.jsx(ze.Td,{isStickyColumn:!0,stickyMinWidth:"0px",hasRightBorder:e.scrollLeft}),p.jsx(ze.Td,{colSpan:t.length,style:{paddingBottom:b.tableLayout==="compact"?12:24,paddingTop:0},children:p.jsx(ze.CollapseColumn,{children:S})}),s!==void 0&&s.length>0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:0},className:e.scrollRight?"pf-m-border-left bg-lighten":void 0,children:" "})]})]})}function Vve(e){const{columns:t,item:n,rowActions:r}=e,[i,a]=x.useState(!1);return p.jsxs(x.Fragment,{children:[t.map(o=>p.jsx(ze.Td,{dataLabel:o.header,modifier:"nowrap",style:{width:o.minWidth===0?"0%":void 0},"data-cy":vi(o.header+"-column-cell"),children:p.jsx(nn,{item:n,column:o})},o.header)),r!==void 0&&r.length>0&&p.jsx(ze.Td,{isActionCell:!0,isStickyColumn:!0,stickyMinWidth:"0px",style:{right:0,padding:0,paddingRight:8,zIndex:i?400:void 0},"data-cy":"actions-column-cell",className:e.scrollRight?"pf-m-border-left bg-lighten":void 0,children:p.jsx(Oo,{actions:r,selectedItem:n,position:Fn.right,iconOnly:!0,onOpen:a})})]})}function Kk(e){const{title:t,items:n,keyFn:r,actionColumns:i,actionFn:a,onComplete:o,onClose:l,processingText:s,isDanger:c}=e,{t:u}=ut(),[f]=Tt(),[d,h]=x.useState(!0),[m,g]=x.useState(!1),[y,_]=x.useState(0),[b,S]=x.useState(""),[C,w]=x.useState(),E=rve(),[A,k]=Hr(),D=x.useCallback(()=>{g(!0),E.abort(),h(!1),w($=>{const j={...$};for(const B of n){const ee=r(B);j[ee]===void 0&&(j[ee]=u("Cancelled"))}return j})},[E,n,r,u]),I=x.useCallback(()=>{k(void 0),l==null||l()},[l,k]);x.useEffect(()=>{async function $(){const j=nve(5);let B=0;const ee=[];await Promise.all(n.map(J=>j(async()=>{if(E.signal.aborted)return;const X=r(J);try{await a(J,E.signal),E.signal.aborted||w(Q=>({...Q??{},[X]:null})),ee.push(J)}catch(Q){if(!E.signal.aborted){if(Q instanceof Error){const V=Q.message;w(Z=>({...Z??{},[X]:V}))}else w(V=>({...V??{},[X]:u("Unknown error")}));S(f.errorText)}}finally{E.signal.aborted||_(++B)}}))),E.signal.aborted||h(!1),o==null||o(ee)}$()},[E,a,n,r,o,f.errorText,u]);const P=vc(n),M=Fy(i);return p.jsxs(T.Modal,{titleIconVariant:c?"warning":void 0,title:t,ouiaId:t,"aria-label":t,variant:T.ModalVariant.medium,isOpen:!0,onClose:()=>{D(),I()},actions:d?[p.jsx(T.Button,{variant:"link",onClick:D,children:f.cancelText},"cancel")]:[p.jsx(T.Button,{variant:"secondary",onClick:I,children:f.closeText},"close")],hasNoBodyWrapper:!0,children:[p.jsx(T.ModalBoxBody,{style:{paddingBottom:0,paddingLeft:0,paddingRight:0},children:p.jsx("div",{style:{display:"flex",flexDirection:"column",maxHeight:560,overflow:"hidden",borderTop:"thin solid var(--pf-v5-global--BorderColor--100)"},children:p.jsx(yc,{pageItems:[...P.paged],itemCount:n.length,tableColumns:[...M,{header:u("Status"),cell:$=>{const j=r($),B=C==null?void 0:C[j];return B===void 0?p.jsxs("span",{style:{color:mp},children:[p.jsx(Ce.PendingIcon,{}),"  ",f.pendingText]}):B===null?p.jsxs("span",{style:{color:dp},children:[p.jsx(Ce.CheckCircleIcon,{}),"  ",f.successText]}):p.jsxs("span",{style:{color:hp},children:[p.jsx(Ce.ExclamationCircleIcon,{}),"  ",C==null?void 0:C[j]]})}}],keyFn:r,compact:!0,errorStateTitle:"",emptyStateTitle:u("No items"),autoHidePagination:!0,disableBodyPadding:!0,...P},"status")})}),p.jsx(T.ModalBoxBody,{style:{paddingTop:0},children:p.jsx(T.Progress,{"data-cy":"progress",value:y/n.length*100,title:E.signal.aborted?f.canceledText:b?f.errorText:d?s??f.processingText:f.successText,size:T.ProgressSize.lg,variant:b||m?T.ProgressVariant.danger:y===n.length?T.ProgressVariant.success:void 0})})]})}function Xk(){const[e,t]=Hr(),[n,r]=x.useState();return x.useEffect(()=>{if(n){const i=()=>{var a;r(void 0),(a=n.onClose)==null||a.call(n)};t(p.jsx(Kk,{...n,onClose:i}))}else t(void 0)},[n,t]),r}function Zk(e,t){if(e==null&&t==null)return 0;if(e==null)return 1;if(t==null)return-1;if(typeof e=="string"){if(typeof t=="string")return bc(e,t);if(typeof t=="number")return bc(e,t.toString())}else if(typeof e=="number"){if(typeof t=="number")return Jk(e,t);if(typeof t=="string")return bc(e.toString(),t)}return 0}function bc(e,t){return e==null&&t==null?0:e==null?1:t==null||e<t?-1:e>t?1:0}function Jk(e,t){return e==null&&t==null?0:e==null?1:t==null||e<t?-1:e>t?1:0}const Hve=Ve.div`
415
415
  display: flex;
416
416
  flex-direction: column;
417
417
  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": "2.4.669",
4
+ "version": "2.4.670",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",