zaravand-ui 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Dialog/Dialog.cjs +1 -1
- package/dist/components/Dialog/Dialog.js +1 -1
- package/dist/components/Input/Input.formatting.cjs +1 -1
- package/dist/components/Input/Input.formatting.js +35 -17
- package/dist/components/Input/Input.interface.d.cts +5 -1
- package/dist/components/Input/Input.interface.d.ts +5 -1
- package/dist/components/OtpInput/OtpInput.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.d.cts +10 -0
- package/dist/components/OtpInput/OtpInput.d.ts +10 -0
- package/dist/components/OtpInput/OtpInput.interface.d.cts +49 -0
- package/dist/components/OtpInput/OtpInput.interface.d.ts +49 -0
- package/dist/components/OtpInput/OtpInput.js +150 -0
- package/dist/components/OtpInput/OtpInput.variant.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.variant.d.cts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.d.ts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.js +15 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.d.cts +4 -1
- package/dist/components/Select/Select.d.ts +4 -1
- package/dist/components/Select/Select.interface.d.cts +15 -1
- package/dist/components/Select/Select.interface.d.ts +15 -1
- package/dist/components/Select/Select.js +697 -566
- package/dist/components/Table/Table.cjs +1 -1
- package/dist/components/Table/Table.constants.cjs +1 -1
- package/dist/components/Table/Table.constants.d.cts +1 -0
- package/dist/components/Table/Table.constants.d.ts +1 -0
- package/dist/components/Table/Table.constants.js +2 -2
- package/dist/components/Table/Table.interface.d.cts +39 -0
- package/dist/components/Table/Table.interface.d.ts +39 -0
- package/dist/components/Table/Table.js +522 -421
- package/dist/components/Table/Table.utils.cjs +1 -1
- package/dist/components/Table/Table.utils.d.cts +10 -1
- package/dist/components/Table/Table.utils.d.ts +10 -1
- package/dist/components/Table/Table.utils.js +23 -1
- package/dist/components/Table/Table.variant.cjs +1 -1
- package/dist/components/Table/Table.variant.d.cts +5 -0
- package/dist/components/Table/Table.variant.d.ts +5 -0
- package/dist/components/Table/Table.variant.js +17 -11
- package/dist/components/Table/TableActiveFilters.cjs +1 -0
- package/dist/components/Table/TableActiveFilters.d.cts +12 -0
- package/dist/components/Table/TableActiveFilters.d.ts +12 -0
- package/dist/components/Table/TableActiveFilters.js +55 -0
- package/dist/components/Table/TableColumnFilter.cjs +1 -0
- package/dist/components/Table/TableColumnFilter.d.cts +20 -0
- package/dist/components/Table/TableColumnFilter.d.ts +20 -0
- package/dist/components/Table/TableColumnFilter.js +100 -0
- package/dist/components/Table/TableEmptyState.cjs +1 -1
- package/dist/components/Table/TableEmptyState.d.cts +1 -1
- package/dist/components/Table/TableEmptyState.d.ts +1 -1
- package/dist/components/Table/TableEmptyState.js +16 -7
- package/dist/components/Table/TableFilterRegistry.cjs +1 -0
- package/dist/components/Table/TableFilterRegistry.d.cts +13 -0
- package/dist/components/Table/TableFilterRegistry.d.ts +13 -0
- package/dist/components/Table/TableFilterRegistry.js +5 -0
- package/dist/components/Table/TableSkeletonRows.cjs +1 -1
- package/dist/components/Table/TableSkeletonRows.js +7 -7
- package/dist/components/Table/TableSortToggle.cjs +1 -1
- package/dist/components/Table/TableSortToggle.js +8 -8
- package/dist/components/Table/hooks/useTableFilter.cjs +1 -0
- package/dist/components/Table/hooks/useTableFilter.d.cts +18 -0
- package/dist/components/Table/hooks/useTableFilter.d.ts +18 -0
- package/dist/components/Table/hooks/useTableFilter.js +49 -0
- package/dist/components/Uploader/Uploader.variant.cjs +1 -1
- package/dist/components/Uploader/Uploader.variant.d.cts +1 -1
- package/dist/components/Uploader/Uploader.variant.d.ts +1 -1
- package/dist/components/Uploader/Uploader.variant.js +1 -1
- package/dist/components/VerticalTabs/VerticalTabs.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.cts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.ts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.cts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.ts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.js +196 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.cts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.ts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.js +48 -0
- package/dist/components/shared/responsiveScale.cjs +1 -1
- package/dist/components/shared/responsiveScale.d.cts +3 -1
- package/dist/components/shared/responsiveScale.d.ts +3 -1
- package/dist/components/shared/responsiveScale.js +2 -2
- package/dist/config/messages.cjs +1 -1
- package/dist/config/messages.d.cts +8 -0
- package/dist/config/messages.d.ts +8 -0
- package/dist/config/messages.js +12 -2
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +19 -16
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/localizeDigits/localizeDigits.cjs`),r=require(`../../lib/utils.cjs`),i=require(`../shared/responsiveScale.cjs`),a=require(`../Button/Button.cjs`),o=require(`../shared/ActionSheet.cjs`),s=require(`../shared/FieldClearButton.cjs`),c=require(`../shared/IconActionButton.cjs`),ee=require(`../shared/useExclusiveAction.cjs`),te=require(`../shared/useStickyToolbar.cjs`),ne=require(`../shared/viewport.cjs`),re=require(`../Select/Select.cjs`),ie=require(`./Table.variant.cjs`),ae=require(`./TableEmptyState.cjs`),oe=require(`./TablePaginationControls.cjs`),l=require(`./Table.constants.cjs`),u=require(`./TableParts.cjs`),d=require(`./Table.utils.cjs`),se=require(`./TableSkeletonRows.cjs`),ce=require(`./TableSortToggle.cjs`),le=require(`./hooks/useTablePagination.cjs`),ue=require(`./hooks/useTableCardLabels.cjs`),de=require(`./hooks/useTableSearch.cjs`),fe=require(`./hooks/useTableSort.cjs`);let f=require(`react`);f=e.__toESM(f,1);let p=require(`react/jsx-runtime`),m=require(`lucide-react`);var pe=f.forwardRef(function({className:e,containerClassName:pe,loading:h=!1,isMutating:g=!1,stickyHeaderOnScroll:me=!0,maxVisibleRowsBeforeScroll:he,allowInfiniteMode:ge=!0,stickyToolbar:_e=!0,schema:_,data:v,setData:ve,onAdd:y,onImportExcel:b,onEdit:x,onDelete:S,onPrint:C,onPreviewPrint:w,actions:ye,onCellSelectChange:T,getRowId:E,showNumberRow:be=!1,showColumnBorder:xe=!1,showRowBorder:Se=!1,toolbarExtra:Ce,children:we},Te){let{messages:D,digits:O,dir:Ee}=t.useZuiConfig(),De=f.useMemo(()=>({digits:O,messages:D}),[O,D]),k=f.Children.count(we)>0,A=ne.useIsMobileViewport(),Oe=f.useRef(null),ke=f.useMemo(()=>r.mergeRefs(Te,Oe),[Te]);ue.useTableCardLabels(Oe,k);let j=f.useMemo(()=>_.columns.filter(e=>e.view),[_.columns]),Ae=f.useMemo(()=>j.filter(e=>e.sortable),[j]),M=typeof y==`function`,N=typeof b==`function`,P=typeof x==`function`,F=typeof S==`function`,I=typeof C==`function`,L=typeof w==`function`,R=ye??[],je=R.length>0,z=_.searchable??!1,B=be&&!k,Me=Ce!=null&&Ce!==!1,Ne=_.pagination,Pe=Ne?.onSearchChange,Fe=typeof Pe==`function`,V=P||F||je,{rowNumberColumnStyle:Ie,columnStyleByKey:Le,actionsColumnStyle:Re}=f.useMemo(()=>d.resolveColumnWidthPercentages(j,B,V),[V,B,j]),ze=f.useMemo(()=>{let e=_.columns.map(e=>{if(e.type!==`select`&&e.type!==`radio`)return[e.key,[]];if(Array.isArray(e.options)&&e.options.length>0)return[e.key,e.options];if(e.optionsSource)return[e.key,[]];let t=new Set;return v.forEach(n=>{let r=n[e.key];if(typeof r==`string`||typeof r==`number`){let e=String(r).trim();e.length>0&&t.add(e)}}),[e.key,Array.from(t).map(e=>({value:e,label:e}))]});return Object.fromEntries(e)},[v,_.columns]),[Be,H]=ee.useExclusiveAction(),[Ve,He]=f.useState(!1),[Ue,We]=f.useState(!1),[Ge,Ke]=f.useState({open:!1,actions:[]}),U=g||Be,qe=f.useCallback(async()=>{g||!y||await H(y)},[g,y,H]),Je=f.useCallback(async()=>{g||!b||await H(b)},[g,b,H]),W=f.useCallback(async(e,t,n,r)=>{g||await H(()=>e({row:t,rowIndex:n,rowId:r??d.resolveSafeRowId(t,n,E)}))},[E,g,H]),Ye=f.useCallback(async(e,t,n)=>{x&&await W(x,e,t,n)},[x,W]),Xe=f.useCallback(async(e,t,n)=>{S&&await W(S,e,t,n)},[S,W]),Ze=f.useCallback(async(e,t,n,r)=>{await W(e.onClick,t,n,r)},[W]),Qe=f.useCallback(async(e,t,n,r,i)=>{if(g)return;let a=i.trim(),o=a.length>0?a:null;if(e[r]===o)return;let s=n??d.resolveSafeRowId(e,t,E),c={...e,[r]:o};await H(async()=>{try{if(T&&await T({row:c,previousRow:e,rowIndex:t,rowId:s,columnKey:r,value:a})===!1)return;ve(e=>d.replaceRowByIdentifier(e,t,s,E,c))}catch{return}})},[E,g,T,H,ve]),$e=f.useCallback((e,t,n)=>{let i=e=>(0,p.jsx)(`span`,{className:r.cn(`zui:inline-flex`,s.CLEAR_ICON_CLASS,`zui:[&>svg]:size-full`),children:e}),a=[];P&&a.push({key:`edit`,label:D.common.edit,icon:i((0,p.jsx)(m.Pencil,{"aria-hidden":`true`})),onSelect:()=>void Ye(e,t,n)}),R.forEach((r,o)=>{a.push({key:`custom-${o}`,label:r.tooltip,icon:i(r.icon),onSelect:()=>void Ze(r,e,t,n)})}),F&&a.push({key:`delete`,label:D.common.delete,icon:i((0,p.jsx)(m.Trash2,{"aria-hidden":`true`})),danger:!0,onSelect:()=>void Xe(e,t,n)}),Ke({open:!0,actions:a})},[Ze,Xe,Ye,D.common.delete,D.common.edit,R,F,P]),{searchTerm:et,normalizedSearchTerm:tt,filteredRows:nt,handleSearchInputChange:rt}=de.useTableSearch({data:v,visibleColumns:j,showSearchInput:z,hasRemoteSearchHandler:Fe,onSearchChange:Pe,getRowId:E,cellFormatOptions:De}),{sortedRows:G,activeSort:K,handleSortToggle:it,handleSortClear:at}=fe.useTableSort({rows:nt,columns:_.columns,sortConfig:_.sort}),ot=f.useCallback(async()=>{C&&await C({rows:G.map(({row:e})=>e),columns:j})},[C,G,j]),st=f.useCallback(async()=>{w&&await w({rows:G.map(({row:e})=>e),columns:j})},[w,G,j]),{pagingMode:q,currentPage:ct,totalPages:lt,resolvedPageSize:ut,visibleRows:J,showPagingModeToggle:Y,shouldRenderPagination:dt,shouldRenderInfiniteMode:ft,canLoadMoreInInfiniteMode:pt,shouldUseRemotePaging:mt,shouldUseScrollableRows:ht,tableScrollViewportRef:gt,tableScrollViewportStyle:_t,handlePageChange:vt,handlePagingModeToggle:yt,handleTableScrollViewport:bt,isInfiniteRequestPending:xt}=le.useTablePagination({hasChildren:k,filteredRows:G,paginationConfig:Ne,loading:h,isRowActionBusy:U,searchKey:tt,sortKey:K?`${K.sortKey}:${K.direction}`:``,maxVisibleRowsBeforeScroll:he,allowInfiniteMode:ge}),X=ht&&me,St=f.useMemo(()=>d.resolveLoadingRowsCount(_.pagination?.pageSize,v.length),[v.length,_.pagination?.pageSize]),Ct=h&&(J.length===0||mt&&q===`pagination`),wt=ft&&h&&J.length>0,Tt=ft&&J.length>0,Et=Tt&&(h||xt),Dt=Tt&&pt&&!h&&!xt,Ot=Tt&&!pt&&!h&&!xt,kt=Math.min(St,Math.max(1,Math.min(ut,3))),Z=h||U,At=+!!P+R.length+ +!!F,jt=q===`pagination`?D.table.switchToInfinite:D.table.switchToPagination,Mt=M||N||Y||I||L,Q=A&&!k&&Ae.length>0,$=!k&&(z||Mt||Q),Nt=f.useRef(null),Pt=f.useRef(null);te.useStickyToolbar(Nt,Pt,A&&_e&&$);let Ft=f.useMemo(()=>{let e=e=>(0,p.jsx)(e,{className:s.CLEAR_ICON_CLASS,"aria-hidden":`true`}),t=Ae.map(t=>{let r=K?.sortKey===t.key?K.direction:void 0,i=n.localizeDigits(t.label,O);return{key:t.key,label:r===void 0?i:`${i} (${r===`asc`?D.table.sortAscending:D.table.sortDescending})`,icon:e(r===`asc`?m.ArrowUp:r===`desc`?m.ArrowDown:m.ArrowUpDown),active:r!==void 0,onSelect:()=>it(t.key)}});return K&&t.push({key:`clear-sort`,label:D.table.sortDefault,icon:e(m.RotateCcw),onSelect:at}),t},[K,O,at,it,D.table.sortAscending,D.table.sortDefault,D.table.sortDescending,Ae]),It=f.useMemo(()=>{let e=e=>(0,p.jsx)(e,{className:s.CLEAR_ICON_CLASS,"aria-hidden":`true`});return[M?{key:`add`,label:D.common.add,icon:e(m.Plus),onSelect:()=>void qe()}:null,N?{key:`import`,label:D.table.importExcel,icon:e(m.FileSpreadsheet),onSelect:()=>void Je()}:null,I?{key:`print`,label:D.table.print,icon:e(m.Printer),onSelect:()=>void ot()}:null,L?{key:`preview-print`,label:D.table.printPreview,icon:e(m.Eye),onSelect:()=>void st()}:null,Y?{key:`paging-mode`,label:jt,icon:e(q===`pagination`?m.Infinity:m.Rows3),onSelect:yt}:null].filter(e=>e!==null)},[qe,Je,yt,st,ot,D.common.add,D.table.importExcel,D.table.print,D.table.printPreview,q,jt,M,N,Y,L,I]),Lt=A&&(It.length>0||Q),Rt=A&&It.length>1,zt=Me&&$&&z,Bt=Me&&$&&!z,Vt=Me&&!$,Ht=(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra`,className:r.cn(`zui:flex zui:w-full zui:items-center`,i.CONTROL_HEIGHT_SM),children:Ce});return(0,p.jsxs)(`div`,{"data-slot":`table-container`,dir:Ee,className:r.cn(ie.tableContainerVariants(),pe),children:[Vt?(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra-row`,className:`zui:mb-3`,children:Ht}):null,$?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{ref:Pt,"aria-hidden":`true`,"data-slot":`table-sticky-sentinel`}),(0,p.jsxs)(`div`,{ref:Nt,"data-slot":`table-sticky-toolbar`,"data-sticky-toolbar":A&&_e?`true`:void 0,className:`zui:mb-3`,children:[zt?(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra-row`,className:`zui:mb-2`,children:Ht}):null,(0,p.jsx)(c.ListToolbar,{"data-slot":`table-controls`,searchSlot:`table-search-input`,actionsSlot:`table-add-action`,inlineActionsOnMobile:Lt,search:z?{value:et,onChange:rt,placeholder:D.common.searchPlaceholder,ariaLabel:D.table.searchAriaLabel,disabled:U}:void 0,leading:Bt?Ht:void 0,actions:Q||Rt||Mt?(0,p.jsxs)(p.Fragment,{children:[Q?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-sort-button`,label:D.table.sortBy,disabled:Z,onClick:()=>We(!0),icon:(0,p.jsx)(m.ArrowUpDown,{"aria-hidden":`true`})}):null,Rt?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-toolbar-menu-button`,label:D.table.actions,disabled:Z,onClick:()=>He(!0),icon:(0,p.jsx)(m.EllipsisVertical,{"aria-hidden":`true`})}):Mt?(0,p.jsxs)(p.Fragment,{children:[Y?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-paging-mode-toggle-button`,label:jt,disabled:Z,onClick:yt,icon:q===`pagination`?(0,p.jsx)(m.Infinity,{className:l.pagingToggleIconClassName,"aria-hidden":`true`}):(0,p.jsx)(m.Rows3,{className:l.pagingToggleIconClassName,"aria-hidden":`true`})}):null,L?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-action-preview-print-button`,label:D.table.printPreview,disabled:Z,onClick:()=>void st(),icon:(0,p.jsx)(m.Eye,{})}):null,I?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-action-print-button`,label:D.table.print,disabled:Z,onClick:()=>void ot(),icon:(0,p.jsx)(m.Printer,{})}):null,N?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-action-import-excel-button`,label:D.table.importExcel,disabled:Z,onClick:()=>void Je(),icon:(0,p.jsx)(m.FileSpreadsheet,{})}):null,M?(0,p.jsx)(c.ToolbarIconButton,{"data-slot":`table-action-add-button`,label:D.common.add,disabled:Z,onClick:()=>void qe(),icon:(0,p.jsx)(m.Plus,{})}):null]}):null]}):void 0})]}),Q?(0,p.jsx)(o.default,{open:Ue,onOpenChange:We,actions:Ft,label:D.table.sortBy}):null,Rt?(0,p.jsx)(o.default,{open:Ve,onOpenChange:He,actions:It.map(e=>({...e,disabled:Z})),label:D.table.actions}):null]}):null,(0,p.jsx)(`div`,{ref:gt,"data-slot":`table-scroll-viewport`,className:r.cn(`zui:relative zui:w-full zui:min-w-0 zui:overflow-x-auto zui-radius-xs zui:bg-[var(--zui-color-surface)] zui:shadow-[0_4px_14px_-12px_var(--zui-effect-shadow-ink-35)]`,ht?`zui:overflow-y-auto`:void 0),style:_t,onScroll:bt,children:(0,p.jsx)(`table`,{ref:ke,"data-slot":`table`,className:r.cn(ie.tableVariants({showColumnBorder:xe,showRowBorder:Se}),e),dir:Ee,children:k?we:j.length===0?(0,p.jsx)(u.TableBody,{children:(0,p.jsx)(u.TableRow,{children:(0,p.jsx)(u.TableCell,{className:`zui:py-7 zui:text-center zui:text-[var(--zui-color-text)]`,children:D.table.noColumns})})}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`colgroup`,{children:[B?(0,p.jsx)(`col`,{style:Ie}):null,j.map(e=>(0,p.jsx)(`col`,{style:Le[e.key]},`col-${e.key}`)),V?(0,p.jsx)(`col`,{style:Re}):null]}),(0,p.jsx)(u.TableHeader,{children:(0,p.jsxs)(u.TableRow,{children:[B?(0,p.jsx)(u.TableHead,{align:`center`,className:r.cn(l.rowNumberColumnClassName,X?l.stickyHeaderCellClassName:void 0),children:D.table.rowNumber}):null,j.map(e=>{if(!e.sortable)return(0,p.jsx)(u.TableHead,{align:e.align,className:X?l.stickyHeaderCellClassName:void 0,children:n.localizeDigits(e.label,O)},`head-${e.key}`);let t=K?.sortKey===e.key?K.direction:void 0;return(0,p.jsx)(u.TableHead,{align:e.align,className:X?l.stickyHeaderCellClassName:void 0,"aria-sort":d.resolveAriaSort(t),children:(0,p.jsxs)(`span`,{className:`zui:inline-flex zui:items-center zui:gap-2`,children:[n.localizeDigits(e.label,O),(0,p.jsx)(ce.default,{columnLabel:e.label,direction:t,onToggle:()=>it(e.key)})]})},`head-${e.key}`)}),V?(0,p.jsx)(u.TableHead,{align:`center`,className:r.cn(l.actionsColumnClassName,l.actionsColumnStickyClassName,X?l.stickyHeaderCellClassName:void 0),children:D.table.actions}):null]})}),(0,p.jsx)(u.TableBody,{children:Ct?(0,p.jsx)(se.default,{count:St,keyPrefix:`loading`,showRowNumbers:B,columns:j,actionsCount:At}):J.length===0?(0,p.jsx)(ae.default,{colSpan:j.length+ +!!V+ +!!B,showSearchInput:z,normalizedSearchTerm:tt}):(0,p.jsxs)(p.Fragment,{children:[J.map(({row:e,rowIndex:t,rowId:i},o)=>{let s=i===void 0?`row-${t}`:`row-id-${String(i)}`,ee=dt?(ct-1)*ut+o+1:o+1;return(0,p.jsxs)(u.TableRow,{children:[B?(0,p.jsx)(u.TableCell,{align:`center`,className:l.rowNumberColumnClassName,"data-label":D.table.rowNumber,children:n.localizeDigits(String(ee),O)}):null,j.map(r=>{let a=`cell-${r.key}-${s}`;if(r.viewType===`select`){let o=ze[r.key]??[],s=e[r.key],c=typeof s==`string`||typeof s==`number`?String(s):``;return(0,p.jsx)(u.TableCell,{align:r.align,"data-label":n.localizeDigits(r.label,O),children:(0,p.jsx)(re.default,{disabled:U||o.length===0&&!r.optionsSource,placeholder:d.resolvePlaceholder(r),options:o,remoteOptions:r.optionsSource,value:c,onValueChange:n=>{let a=Array.isArray(n)?n[0]??``:n;Qe(e,t,i,r.key,a)}})},a)}return(0,p.jsx)(u.TableCell,{align:r.align,"data-label":n.localizeDigits(r.label,O),children:d.formatCellValue(e[r.key],r,De)},a)}),V?(0,p.jsx)(u.TableCell,{align:`center`,"data-cell":`actions`,className:r.cn(l.actionsColumnClassName,l.actionsColumnStickyClassName),children:A?(0,p.jsx)(a.default,{"data-slot":`table-row-actions-button`,kind:`cancel`,fullWidth:!0,label:D.table.actions,disabled:U,onClick:()=>$e(e,t,i)}):(0,p.jsxs)(`div`,{"data-slot":`table-row-actions`,className:`zui:flex zui:items-center zui:justify-center zui:gap-0.5`,children:[P?(0,p.jsx)(c.IconActionButton,{"data-slot":`table-action-edit-button`,label:D.common.edit,icon:(0,p.jsx)(m.Pencil,{className:l.actionIconClassName,"aria-hidden":`true`}),disabled:U,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-text-primary)]`),onClick:()=>void Ye(e,t,i)}):null,R.map((n,a)=>(0,p.jsx)(c.IconActionButton,{"data-slot":`table-action-custom-button`,label:n.tooltip,icon:n.icon,disabled:U,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-text-primary)]`),onClick:()=>void Ze(n,e,t,i)},`${n.tooltip}-${a}`)),F?(0,p.jsx)(c.IconActionButton,{"data-slot":`table-action-delete-button`,label:D.common.delete,icon:(0,p.jsx)(m.Trash2,{className:l.actionIconClassName,"aria-hidden":`true`}),disabled:U,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-status-danger)]`),onClick:()=>void Xe(e,t,i)}):null]})}):null]},s)}),wt?(0,p.jsx)(se.default,{count:kt,keyPrefix:`infinite-loading`,showRowNumbers:B,columns:j,actionsCount:At}):null]})})]})})}),A&&V?(0,p.jsx)(o.default,{open:Ge.open,onOpenChange:e=>Ke(t=>({...t,open:e})),actions:Ge.actions,label:D.table.actions}):null,(0,p.jsx)(oe.default,{shouldRenderInfiniteMode:ft,shouldShowInfiniteLoadingStatus:Et,shouldShowInfiniteReadyStatus:Dt,shouldShowInfiniteCompletedStatus:Ot,shouldRenderPagination:dt,loading:h,isRowActionBusy:U,currentPage:ct,totalPages:lt,onPageChange:vt})]})});pe.displayName=`Table`,exports.default=pe;
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/localizeDigits/localizeDigits.cjs`),r=require(`../../lib/utils.cjs`),i=require(`../shared/responsiveScale.cjs`),a=require(`../shared/ActionSheet.cjs`),o=require(`../shared/FieldClearButton.cjs`),s=require(`../shared/IconActionButton.cjs`),c=require(`../shared/useExclusiveAction.cjs`),ee=require(`../shared/useStickyToolbar.cjs`),te=require(`../shared/viewport.cjs`),ne=require(`../Select/Select.cjs`),l=require(`./Table.constants.cjs`),u=require(`./Table.utils.cjs`),re=require(`./Table.variant.cjs`),ie=require(`./TableActiveFilters.cjs`),ae=require(`./TableFilterRegistry.cjs`),oe=require(`./TableColumnFilter.cjs`),se=require(`./TableEmptyState.cjs`),ce=require(`./TablePaginationControls.cjs`),d=require(`./TableParts.cjs`),le=require(`./TableSkeletonRows.cjs`),ue=require(`./TableSortToggle.cjs`),de=require(`./hooks/useTablePagination.cjs`),fe=require(`./hooks/useTableCardLabels.cjs`),pe=require(`./hooks/useTableFilter.cjs`),me=require(`./hooks/useTableSearch.cjs`),he=require(`./hooks/useTableSort.cjs`);let f=require(`react`);f=e.__toESM(f,1);let p=require(`react/jsx-runtime`),m=require(`lucide-react`);function ge(e){let t=e.target.closest(`button, a, input, textarea, select, label, [role="button"], [role="combobox"], [role="checkbox"]`);return t!==null&&e.currentTarget.contains(t)}var _e=f.forwardRef(function({className:e,containerClassName:_e,loading:h=!1,isMutating:g=!1,stickyHeaderOnScroll:ve=!0,maxVisibleRowsBeforeScroll:ye,allowInfiniteMode:be=!0,stickyToolbar:xe=!0,schema:_,data:v,setData:Se,onAdd:Ce,onImportExcel:we,onEdit:y,onDelete:b,onPrint:x,onPreviewPrint:S,actions:Te,onCellSelectChange:Ee,getRowId:C,showNumberRow:De=!1,showColumnBorder:Oe=!1,showRowBorder:ke=!1,toolbarExtra:Ae,children:je},Me){let{messages:w,digits:T,dir:E}=t.useZuiConfig(),D=f.useMemo(()=>({digits:T,messages:w}),[T,w]),O=f.Children.count(je)>0,[Ne,Pe]=f.useState({}),Fe=f.useMemo(()=>({register:e=>Pe(t=>({...t,[e.column.key]:e})),unregister:e=>Pe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e)))}),[]),Ie=Object.values(Ne),k=te.useIsMobileViewport(),Le=f.useRef(null),Re=f.useMemo(()=>r.mergeRefs(Me,Le),[Me]);fe.useTableCardLabels(Le,O);let A=f.useMemo(()=>_.columns.filter(e=>e.view),[_.columns]),ze=f.useMemo(()=>A.filter(e=>e.sortable),[A]),j=f.useMemo(()=>A.filter(e=>e.filterable),[A]),Be=typeof Ce==`function`,Ve=typeof we==`function`,M=typeof y==`function`,N=typeof b==`function`,P=typeof x==`function`,F=typeof S==`function`,I=Te??[],He=I.length>0,L=_.searchable??!1,R=De&&!O,Ue=Ae!=null&&Ae!==!1,We=_.pagination,Ge=We?.onSearchChange,Ke=typeof Ge==`function`,qe=M||N||He,z=qe&&!k,{rowNumberColumnStyle:Je,columnStyleByKey:Ye,actionsColumnStyle:Xe}=f.useMemo(()=>u.resolveColumnWidthPercentages(A,R,z),[z,R,A]),Ze=f.useMemo(()=>{let e=_.columns.map(e=>{if(e.type!==`select`&&e.type!==`radio`)return[e.key,[]];if(Array.isArray(e.options)&&e.options.length>0)return[e.key,e.options];if(e.optionsSource)return[e.key,[]];let t=new Set;return v.forEach(n=>{let r=n[e.key];if(typeof r==`string`||typeof r==`number`){let e=String(r).trim();e.length>0&&t.add(e)}}),[e.key,Array.from(t).map(e=>({value:e,label:e}))]});return Object.fromEntries(e)},[v,_.columns]),[Qe,B]=c.useExclusiveAction(),[$e,et]=f.useState(!1),[tt,nt]=f.useState(!1),[rt,it]=f.useState(!1),[at,ot]=f.useState(null),[st,ct]=f.useState(!1),[lt,ut]=f.useState({open:!1,actions:[]}),V=g||Qe,dt=f.useCallback(async()=>{g||!Ce||await B(Ce)},[g,Ce,B]),ft=f.useCallback(async()=>{g||!we||await B(we)},[g,we,B]),H=f.useCallback(async(e,t,n,r)=>{g||await B(()=>e({row:t,rowIndex:n,rowId:r??u.resolveSafeRowId(t,n,C)}))},[C,g,B]),pt=f.useCallback(async(e,t,n)=>{y&&await H(y,e,t,n)},[y,H]),mt=f.useCallback(async(e,t,n)=>{b&&await H(b,e,t,n)},[b,H]),ht=f.useCallback(async(e,t,n,r)=>{await H(e.onClick,t,n,r)},[H]),gt=f.useCallback(async(e,t,n,r,i)=>{if(g)return;let a=i.trim(),o=a.length>0?a:null;if(e[r]===o)return;let s=n??u.resolveSafeRowId(e,t,C),c={...e,[r]:o};await B(async()=>{try{if(Ee&&await Ee({row:c,previousRow:e,rowIndex:t,rowId:s,columnKey:r,value:a})===!1)return;Se(e=>u.replaceRowByIdentifier(e,t,s,C,c))}catch{return}})},[C,g,Ee,B,Se]),_t=f.useCallback((e,t,n)=>{let i=e=>(0,p.jsx)(`span`,{className:r.cn(`zui:inline-flex`,o.CLEAR_ICON_CLASS,`zui:[&>svg]:size-full`),children:e}),a=[];M&&a.push({key:`edit`,label:w.common.edit,icon:i((0,p.jsx)(m.Pencil,{"aria-hidden":`true`})),onSelect:()=>void pt(e,t,n)}),I.forEach((r,o)=>{a.push({key:`custom-${o}`,label:r.tooltip,icon:i(r.icon),onSelect:()=>void ht(r,e,t,n)})}),N&&a.push({key:`delete`,label:w.common.delete,icon:i((0,p.jsx)(m.Trash2,{"aria-hidden":`true`})),danger:!0,onSelect:()=>void mt(e,t,n)}),ut({open:!0,actions:a})},[ht,mt,pt,w.common.delete,w.common.edit,I,N,M]),{searchTerm:vt,normalizedSearchTerm:yt,filteredRows:bt,handleSearchInputChange:xt}=me.useTableSearch({data:v,visibleColumns:A,showSearchInput:L,hasRemoteSearchHandler:Ke,onSearchChange:Ge,getRowId:C,cellFormatOptions:D}),{filteredRows:St,filterValues:U,activeFilterCount:Ct,filterKey:wt,handleFilterChange:Tt,handleFilterClear:Et}=pe.useTableFilter({rows:bt,columns:_.columns,filterConfig:_.filter}),W=f.useMemo(()=>Object.fromEntries(j.map(e=>[e.key,u.resolveFilterOptions(e,v,D)])),[D,v,j]),{sortedRows:G,activeSort:K,handleSortToggle:Dt,handleSortClear:Ot}=he.useTableSort({rows:St,columns:_.columns,sortConfig:_.sort}),kt=f.useCallback(async()=>{x&&await x({rows:G.map(({row:e})=>e),columns:A})},[x,G,A]),At=f.useCallback(async()=>{S&&await S({rows:G.map(({row:e})=>e),columns:A})},[S,G,A]),{pagingMode:q,currentPage:jt,totalPages:Mt,resolvedPageSize:Nt,visibleRows:J,showPagingModeToggle:Pt,shouldRenderPagination:Ft,shouldRenderInfiniteMode:It,canLoadMoreInInfiniteMode:Lt,shouldUseRemotePaging:Rt,shouldUseScrollableRows:zt,tableScrollViewportRef:Bt,tableScrollViewportStyle:Vt,handlePageChange:Ht,handlePagingModeToggle:Ut,handleTableScrollViewport:Wt,isInfiniteRequestPending:Gt}=de.useTablePagination({hasChildren:O,filteredRows:G,paginationConfig:We,loading:h,isRowActionBusy:V,searchKey:`${yt}|${wt}`,sortKey:K?`${K.sortKey}:${K.direction}`:``,maxVisibleRowsBeforeScroll:ye,allowInfiniteMode:be}),Kt=zt&&ve,qt=f.useMemo(()=>u.resolveLoadingRowsCount(_.pagination?.pageSize,v.length),[v.length,_.pagination?.pageSize]),Jt=h&&(J.length===0||Rt&&q===`pagination`),Yt=It&&h&&J.length>0,Xt=It&&J.length>0,Zt=Xt&&(h||Gt),Qt=Xt&&Lt&&!h&&!Gt,$t=Xt&&!Lt&&!h&&!Gt,en=Math.min(qt,Math.max(1,Math.min(Nt,3))),Y=h||V,tn=k?0:+!!M+I.length+ +!!N,nn=q===`pagination`?w.table.switchToInfinite:w.table.switchToPagination,rn=Be||Ve||Pt||P||F,X=k&&!O&&ze.length>0,Z=k&&!O&&j.length>0,Q=!O&&(L||rn||X||Z),an=f.useRef(null),on=f.useRef(null);ee.useStickyToolbar(an,on,k&&xe&&Q);let sn=f.useMemo(()=>{let e=e=>(0,p.jsx)(e,{className:o.CLEAR_ICON_CLASS,"aria-hidden":`true`}),t=ze.map(t=>{let r=K?.sortKey===t.key?K.direction:void 0,i=n.localizeDigits(t.label,T);return{key:t.key,label:r===void 0?i:`${i} (${r===`asc`?w.table.sortAscending:w.table.sortDescending})`,icon:e(r===`asc`?m.ArrowUp:r===`desc`?m.ArrowDown:m.ArrowUpDown),active:r!==void 0,onSelect:()=>Dt(t.key)}});return K&&t.push({key:`clear-sort`,label:w.table.sortDefault,icon:e(m.RotateCcw),onSelect:Ot}),t},[K,T,Ot,Dt,w.table.sortAscending,w.table.sortDefault,w.table.sortDescending,ze]),cn=f.useCallback(e=>{ot(e),ct(!0)},[]),ln=f.useMemo(()=>j.map(e=>{let t=U[e.key],r=t!==void 0&&!u.isEmptyFilterValue(t),i=n.localizeDigits(e.label,T),a=r?n.localizeDigits(u.resolveFilterText(t,W[e.key]??[]),T):``;return{key:e.key,label:r?`${i}: ${a}`:i,icon:(0,p.jsx)(m.Funnel,{className:o.CLEAR_ICON_CLASS,fill:r?`currentColor`:`none`,"aria-hidden":`true`}),active:r,onSelect:()=>cn(e.key)}}),[T,W,U,j,cn]),$=j.find(e=>e.key===at),un=f.useMemo(()=>{let e=e=>(0,p.jsx)(e,{className:o.CLEAR_ICON_CLASS,"aria-hidden":`true`});return[Be?{key:`add`,label:w.common.add,icon:e(m.Plus),onSelect:()=>void dt()}:null,Ve?{key:`import`,label:w.table.importExcel,icon:e(m.FileSpreadsheet),onSelect:()=>void ft()}:null,P?{key:`print`,label:w.table.print,icon:e(m.Printer),onSelect:()=>void kt()}:null,F?{key:`preview-print`,label:w.table.printPreview,icon:e(m.Eye),onSelect:()=>void At()}:null,Pt?{key:`paging-mode`,label:nn,icon:e(q===`pagination`?m.Infinity:m.Rows3),onSelect:Ut}:null].filter(e=>e!==null)},[dt,ft,Ut,At,kt,w.common.add,w.table.importExcel,w.table.print,w.table.printPreview,q,nn,Be,Ve,Pt,F,P]),dn=k&&(un.length>0||X||Z),fn=k&&un.length>1,pn=Ue&&Q&&L,mn=Ue&&Q&&!L,hn=Ue&&!Q,gn=(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra`,className:r.cn(`zui:flex zui:w-full zui:items-center`,i.CONTROL_HEIGHT_SM),children:Ae});return(0,p.jsxs)(`div`,{"data-slot":`table-container`,dir:E,className:r.cn(re.tableContainerVariants(),_e),children:[O?(0,p.jsx)(ie.default,{columns:Ie.map(e=>e.column),values:Object.fromEntries(Ie.flatMap(e=>e.value?[[e.column.key,e.value]]:[])),optionsByColumn:Object.fromEntries(Ie.map(e=>[e.column.key,e.options])),onRemove:e=>Ne[e]?.onChange(void 0)}):(0,p.jsx)(ie.default,{columns:A,values:U,optionsByColumn:W,onRemove:e=>Tt(e,void 0),onSelect:k?cn:void 0}),hn?(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra-row`,className:`zui:mb-3`,children:gn}):null,Q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{ref:on,"aria-hidden":`true`,"data-slot":`table-sticky-sentinel`}),(0,p.jsxs)(`div`,{ref:an,"data-slot":`table-sticky-toolbar`,"data-sticky-toolbar":k&&xe?`true`:void 0,className:`zui:mb-3`,children:[pn?(0,p.jsx)(`div`,{"data-slot":`table-toolbar-extra-row`,className:`zui:mb-2`,children:gn}):null,(0,p.jsx)(s.ListToolbar,{"data-slot":`table-controls`,searchSlot:`table-search-input`,actionsSlot:`table-add-action`,inlineActionsOnMobile:dn,search:L?{value:vt,onChange:xt,placeholder:w.common.searchPlaceholder,ariaLabel:w.table.searchAriaLabel,disabled:V}:void 0,leading:mn?gn:void 0,actions:X||Z||fn||rn?(0,p.jsxs)(p.Fragment,{children:[X?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-sort-button`,label:w.table.sortBy,disabled:Y,onClick:()=>nt(!0),icon:(0,p.jsx)(m.ArrowUpDown,{"aria-hidden":`true`})}):null,Z?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-filter-button`,label:w.table.filterBy,disabled:Y,onClick:()=>it(!0),icon:(0,p.jsxs)(`span`,{className:`zui:relative zui:inline-flex`,children:[(0,p.jsx)(m.Funnel,{fill:Ct>0?`currentColor`:`none`,"aria-hidden":`true`}),Ct>0?(0,p.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`table-filter-active-dot`,className:`zui:absolute zui:-end-1 zui:-top-1 zui:size-2 zui:rounded-full zui:bg-[var(--zui-theme-action-primary)] zui:ring-2 zui:ring-[var(--zui-color-surface)]`}):null]})}):null,fn?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-toolbar-menu-button`,label:w.table.actions,disabled:Y,onClick:()=>et(!0),icon:(0,p.jsx)(m.EllipsisVertical,{"aria-hidden":`true`})}):rn?(0,p.jsxs)(p.Fragment,{children:[Pt?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-paging-mode-toggle-button`,label:nn,disabled:Y,onClick:Ut,icon:q===`pagination`?(0,p.jsx)(m.Infinity,{className:l.pagingToggleIconClassName,"aria-hidden":`true`}):(0,p.jsx)(m.Rows3,{className:l.pagingToggleIconClassName,"aria-hidden":`true`})}):null,F?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-action-preview-print-button`,label:w.table.printPreview,disabled:Y,onClick:()=>void At(),icon:(0,p.jsx)(m.Eye,{})}):null,P?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-action-print-button`,label:w.table.print,disabled:Y,onClick:()=>void kt(),icon:(0,p.jsx)(m.Printer,{})}):null,Ve?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-action-import-excel-button`,label:w.table.importExcel,disabled:Y,onClick:()=>void ft(),icon:(0,p.jsx)(m.FileSpreadsheet,{})}):null,Be?(0,p.jsx)(s.ToolbarIconButton,{"data-slot":`table-action-add-button`,label:w.common.add,disabled:Y,onClick:()=>void dt(),icon:(0,p.jsx)(m.Plus,{})}):null]}):null]}):void 0})]}),X?(0,p.jsx)(a.default,{open:tt,onOpenChange:nt,actions:sn,label:w.table.sortBy}):null,Z?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a.default,{open:rt,onOpenChange:it,actions:ln,label:w.table.filterBy}),$?(0,p.jsx)(oe.TableColumnFilterSheet,{column:$,value:U[$.key],onChange:e=>Tt($.key,e),options:W[$.key]??[],open:st,onOpenChange:ct},$.key):null]}):null,fn?(0,p.jsx)(a.default,{open:$e,onOpenChange:et,actions:un.map(e=>({...e,disabled:Y})),label:w.table.actions}):null]}):null,(0,p.jsx)(`div`,{ref:Bt,"data-slot":`table-scroll-viewport`,className:r.cn(`zui:relative zui:w-full zui:min-w-0 zui:overflow-x-auto zui-radius-xs zui:bg-[var(--zui-color-surface)] zui:shadow-[0_4px_14px_-12px_var(--zui-effect-shadow-ink-35)]`,zt?`zui:overflow-y-auto`:void 0),style:Vt,onScroll:Wt,children:(0,p.jsx)(`table`,{ref:Re,"data-slot":`table`,className:r.cn(re.tableVariants({showColumnBorder:Oe,showRowBorder:ke}),e),dir:E,children:O?(0,p.jsx)(ae.TableFilterRegistryContext.Provider,{value:Fe,children:je}):A.length===0?(0,p.jsx)(d.TableBody,{children:(0,p.jsx)(d.TableRow,{children:(0,p.jsx)(d.TableCell,{className:`zui:py-7 zui:text-center zui:text-[var(--zui-color-text)]`,children:w.table.noColumns})})}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`colgroup`,{children:[R?(0,p.jsx)(`col`,{style:Je}):null,A.map(e=>(0,p.jsx)(`col`,{style:Ye[e.key]},`col-${e.key}`)),z?(0,p.jsx)(`col`,{style:Xe}):null]}),(0,p.jsx)(d.TableHeader,{children:(0,p.jsxs)(d.TableRow,{children:[R?(0,p.jsx)(d.TableHead,{align:`center`,className:r.cn(l.rowNumberColumnClassName,Kt?l.stickyHeaderCellClassName:void 0),children:w.table.rowNumber}):null,A.map(e=>{let t=e.sortable&&K?.sortKey===e.key?K.direction:void 0,r=e.sortable?(0,p.jsx)(ue.default,{columnLabel:e.label,direction:t,onToggle:()=>Dt(e.key)}):null,i=e.filterable?(0,p.jsx)(oe.default,{column:e,value:U[e.key],onChange:t=>Tt(e.key,t),options:W[e.key]??[]}):null;return(0,p.jsx)(d.TableHead,{align:e.align,className:Kt?l.stickyHeaderCellClassName:void 0,"aria-sort":e.sortable?u.resolveAriaSort(t):void 0,children:e.sortable||e.filterable?(0,p.jsxs)(`span`,{className:`zui:inline-flex zui:items-center zui:gap-2`,children:[n.localizeDigits(e.label,T),(0,p.jsxs)(`span`,{className:`zui:inline-flex zui:items-center`,children:[E===`rtl`?r:i,E===`rtl`?i:r]})]}):n.localizeDigits(e.label,T)},`head-${e.key}`)}),z?(0,p.jsx)(d.TableHead,{align:`center`,className:r.cn(l.actionsColumnClassName,l.actionsColumnStickyClassName,Kt?l.stickyHeaderCellClassName:void 0),children:w.table.actions}):null]})}),(0,p.jsx)(d.TableBody,{children:Jt?(0,p.jsx)(le.default,{count:qt,keyPrefix:`loading`,showRowNumbers:R,columns:A,actionsCount:tn}):J.length===0?(0,p.jsx)(se.default,{colSpan:A.length+ +!!z+ +!!R,showSearchInput:L,normalizedSearchTerm:yt,hasActiveFilters:Ct>0,onClearFilters:Et}):(0,p.jsxs)(p.Fragment,{children:[J.map(({row:e,rowIndex:t,rowId:i},a)=>{let o=i===void 0?`row-${t}`:`row-id-${String(i)}`,c=Ft?(jt-1)*Nt+a+1:a+1;return(0,p.jsxs)(d.TableRow,{...k&&qe?{tabIndex:0,"aria-haspopup":`dialog`,"data-actionable":`true`,onClick:n=>{ge(n)||_t(e,t,i)},onKeyDown:n=>{n.target===n.currentTarget&&(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),_t(e,t,i))}}:{},children:[R?(0,p.jsx)(d.TableCell,{align:`center`,className:l.rowNumberColumnClassName,"data-label":w.table.rowNumber,children:n.localizeDigits(String(c),T)}):null,A.map(r=>{let a=`cell-${r.key}-${o}`;if(r.viewType===`select`){let o=Ze[r.key]??[],s=e[r.key],c=typeof s==`string`||typeof s==`number`?String(s):``;return(0,p.jsx)(d.TableCell,{align:r.align,"data-label":n.localizeDigits(r.label,T),children:(0,p.jsx)(ne.default,{disabled:V||o.length===0&&!r.optionsSource,placeholder:u.resolvePlaceholder(r),options:o,remoteOptions:r.optionsSource,value:c,onValueChange:n=>{let a=Array.isArray(n)?n[0]??``:n;gt(e,t,i,r.key,a)}})},a)}return(0,p.jsx)(d.TableCell,{align:r.align,"data-label":n.localizeDigits(r.label,T),children:u.formatCellValue(e[r.key],r,D)},a)}),z?(0,p.jsx)(d.TableCell,{align:`center`,"data-cell":`actions`,className:r.cn(l.actionsColumnClassName,l.actionsColumnStickyClassName),children:(0,p.jsxs)(`div`,{"data-slot":`table-row-actions`,className:`zui:flex zui:items-center zui:justify-center zui:gap-0.5`,children:[M?(0,p.jsx)(s.IconActionButton,{"data-slot":`table-action-edit-button`,label:w.common.edit,icon:(0,p.jsx)(m.Pencil,{className:l.actionIconClassName,"aria-hidden":`true`}),disabled:V,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-text-primary)]`),onClick:()=>void pt(e,t,i)}):null,I.map((n,a)=>(0,p.jsx)(s.IconActionButton,{"data-slot":`table-action-custom-button`,label:n.tooltip,icon:n.icon,disabled:V,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-text-primary)]`),onClick:()=>void ht(n,e,t,i)},`${n.tooltip}-${a}`)),N?(0,p.jsx)(s.IconActionButton,{"data-slot":`table-action-delete-button`,label:w.common.delete,icon:(0,p.jsx)(m.Trash2,{className:l.actionIconClassName,"aria-hidden":`true`}),disabled:V,className:r.cn(l.rowActionButtonClassName,`zui:text-[var(--zui-theme-status-danger)]`),onClick:()=>void mt(e,t,i)}):null]})}):null]},o)}),Yt?(0,p.jsx)(le.default,{count:en,keyPrefix:`infinite-loading`,showRowNumbers:R,columns:A,actionsCount:tn}):null]})})]})})}),k&&qe?(0,p.jsx)(a.default,{open:lt.open,onOpenChange:e=>ut(t=>({...t,open:e})),actions:lt.actions,label:w.table.actions}):null,(0,p.jsx)(ce.default,{shouldRenderInfiniteMode:It,shouldShowInfiniteLoadingStatus:Zt,shouldShowInfiniteReadyStatus:Qt,shouldShowInfiniteCompletedStatus:$t,shouldRenderPagination:Ft,loading:h,isRowActionBusy:V,currentPage:jt,totalPages:Mt,onPageChange:Ht})]})});_e.displayName=`Table`,exports.default=_e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`zui:size-4`,t=`zui:size-6`,n=`zui:inline-flex zui:size-9 zui:items-center zui:justify-center zui:rounded-md zui:border zui:border-[var(--zui-theme-border-default)] zui:bg-transparent zui:transition zui:hover:bg-[var(--zui-theme-bg-surface)] zui:disabled:pointer-events-none zui:disabled:opacity-45 zui:cursor-pointer zui:border-0 zui:bg-transparent zui:shadow-none zui:hover:bg-transparent zui:hover:shadow-none zui:active:bg-transparent zui:focus-visible:ring-0 zui:disabled:cursor-not-allowed`,r=`zui:px-3`,i=`zui:sticky zui:end-0 zui:z-10`,a=`zui:px-3`,o=`zui:sticky zui:top-0 zui:z-20 zui:bg-[var(--zui-color-primary)]`,s=`zui:h-4 zui:w-2.5`;exports.actionIconClassName=e,exports.actionsColumnClassName=r,exports.actionsColumnStickyClassName=i,exports.pagingToggleIconClassName=t,exports.rowActionButtonClassName=n,exports.rowNumberColumnClassName=a,exports.sortIconClassName=s,exports.stickyHeaderCellClassName=o;
|
|
1
|
+
var e=`zui:size-4`,t=`zui:size-6`,n=`zui:inline-flex zui:size-9 zui:items-center zui:justify-center zui:rounded-md zui:border zui:border-[var(--zui-theme-border-default)] zui:bg-transparent zui:transition zui:hover:bg-[var(--zui-theme-bg-surface)] zui:disabled:pointer-events-none zui:disabled:opacity-45 zui:cursor-pointer zui:border-0 zui:bg-transparent zui:shadow-none zui:hover:bg-transparent zui:hover:shadow-none zui:active:bg-transparent zui:focus-visible:ring-0 zui:disabled:cursor-not-allowed`,r=`zui:px-3`,i=`zui:sticky zui:end-0 zui:z-10`,a=`zui:px-3`,o=`zui:sticky zui:top-0 zui:z-20 zui:bg-[var(--zui-color-primary)]`,s=`zui:h-4 zui:w-2.5`,c=`zui:size-4`;exports.actionIconClassName=e,exports.actionsColumnClassName=r,exports.actionsColumnStickyClassName=i,exports.filterIconClassName=c,exports.pagingToggleIconClassName=t,exports.rowActionButtonClassName=n,exports.rowNumberColumnClassName=a,exports.sortIconClassName=s,exports.stickyHeaderCellClassName=o;
|
|
@@ -16,3 +16,4 @@ export declare const infiniteScrollViewportPrefetchDistancePx: number;
|
|
|
16
16
|
export declare const defaultLoadingRowsCount = 6;
|
|
17
17
|
export declare const maxLoadingRowsCount = 12;
|
|
18
18
|
export declare const sortIconClassName = "zui:h-4 zui:w-2.5";
|
|
19
|
+
export declare const filterIconClassName = "zui:size-4";
|
|
@@ -16,3 +16,4 @@ export declare const infiniteScrollViewportPrefetchDistancePx: number;
|
|
|
16
16
|
export declare const defaultLoadingRowsCount = 6;
|
|
17
17
|
export declare const maxLoadingRowsCount = 12;
|
|
18
18
|
export declare const sortIconClassName = "zui:h-4 zui:w-2.5";
|
|
19
|
+
export declare const filterIconClassName = "zui:size-4";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/components/Table/Table.constants.ts
|
|
2
|
-
var e = "zui:size-4", t = "zui:size-6", n = "zui:inline-flex zui:size-9 zui:items-center zui:justify-center zui:rounded-md zui:border zui:border-[var(--zui-theme-border-default)] zui:bg-transparent zui:transition zui:hover:bg-[var(--zui-theme-bg-surface)] zui:disabled:pointer-events-none zui:disabled:opacity-45 zui:cursor-pointer zui:border-0 zui:bg-transparent zui:shadow-none zui:hover:bg-transparent zui:hover:shadow-none zui:active:bg-transparent zui:focus-visible:ring-0 zui:disabled:cursor-not-allowed", r = "zui:px-3", i = "zui:sticky zui:end-0 zui:z-10", a = "zui:px-3", o = "zui:sticky zui:top-0 zui:z-20 zui:bg-[var(--zui-color-primary)]", s = "zui:h-4 zui:w-2.5";
|
|
2
|
+
var e = "zui:size-4", t = "zui:size-6", n = "zui:inline-flex zui:size-9 zui:items-center zui:justify-center zui:rounded-md zui:border zui:border-[var(--zui-theme-border-default)] zui:bg-transparent zui:transition zui:hover:bg-[var(--zui-theme-bg-surface)] zui:disabled:pointer-events-none zui:disabled:opacity-45 zui:cursor-pointer zui:border-0 zui:bg-transparent zui:shadow-none zui:hover:bg-transparent zui:hover:shadow-none zui:active:bg-transparent zui:focus-visible:ring-0 zui:disabled:cursor-not-allowed", r = "zui:px-3", i = "zui:sticky zui:end-0 zui:z-10", a = "zui:px-3", o = "zui:sticky zui:top-0 zui:z-20 zui:bg-[var(--zui-color-primary)]", s = "zui:h-4 zui:w-2.5", c = "zui:size-4";
|
|
3
3
|
//#endregion
|
|
4
|
-
export { e as actionIconClassName, r as actionsColumnClassName, i as actionsColumnStickyClassName, t as pagingToggleIconClassName, n as rowActionButtonClassName, a as rowNumberColumnClassName, s as sortIconClassName, o as stickyHeaderCellClassName };
|
|
4
|
+
export { e as actionIconClassName, r as actionsColumnClassName, i as actionsColumnStickyClassName, c as filterIconClassName, t as pagingToggleIconClassName, n as rowActionButtonClassName, a as rowNumberColumnClassName, s as sortIconClassName, o as stickyHeaderCellClassName };
|
|
@@ -106,6 +106,36 @@ export type TableSchemaColumn = {
|
|
|
106
106
|
* for controlling/observing the active sort key and direction.
|
|
107
107
|
*/
|
|
108
108
|
sortable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* When true, renders a filter button in this column's header that opens the
|
|
111
|
+
* same dropdown as `Select` (multi-select, with search for long lists) to
|
|
112
|
+
* pick the values the column may have. The options are `options` /
|
|
113
|
+
* `optionsSource` of the column, or else the distinct values found in `data`.
|
|
114
|
+
* See `TableSchema.filter` for controlling/observing the filters.
|
|
115
|
+
*/
|
|
116
|
+
filterable?: boolean;
|
|
117
|
+
};
|
|
118
|
+
/** The chosen values of a column; a row stays when its value is one of them. */
|
|
119
|
+
export type TableFilterValue = string[];
|
|
120
|
+
/** Active filters by column key. A column without a filter has no entry. */
|
|
121
|
+
export type TableFilterValues = Record<string, TableFilterValue>;
|
|
122
|
+
export type TableSchemaFilter = {
|
|
123
|
+
/**
|
|
124
|
+
* The active filters. Only meaningful for remote filtering (when
|
|
125
|
+
* `onFilterChange` is provided), where it makes the filters controlled —
|
|
126
|
+
* for example to keep them in the URL. In local filtering the table tracks
|
|
127
|
+
* them itself.
|
|
128
|
+
*/
|
|
129
|
+
values?: TableFilterValues;
|
|
130
|
+
/**
|
|
131
|
+
* Provided for remote filtering: called with all active filters whenever one
|
|
132
|
+
* changes. When provided, the table stops filtering rows itself and expects
|
|
133
|
+
* the parent to fetch `data` accordingly (same contract as
|
|
134
|
+
* `TableSchemaSort.onSortChange`). Give the column `options` or
|
|
135
|
+
* `optionsSource` too: the options found in `data` are only those of the
|
|
136
|
+
* rows loaded so far.
|
|
137
|
+
*/
|
|
138
|
+
onFilterChange?: (values: TableFilterValues) => void;
|
|
109
139
|
};
|
|
110
140
|
export type TableSchemaSort = {
|
|
111
141
|
/**
|
|
@@ -152,6 +182,7 @@ export type TableSchema = {
|
|
|
152
182
|
searchable?: boolean;
|
|
153
183
|
pagination?: TableSchemaPagination;
|
|
154
184
|
sort?: TableSchemaSort;
|
|
185
|
+
filter?: TableSchemaFilter;
|
|
155
186
|
};
|
|
156
187
|
export type TableVisibleRow = {
|
|
157
188
|
row: DynamicTableRow;
|
|
@@ -274,5 +305,13 @@ export type TableEmptyStateProps = {
|
|
|
274
305
|
colSpan: number;
|
|
275
306
|
showSearchInput: boolean;
|
|
276
307
|
normalizedSearchTerm: string;
|
|
308
|
+
hasActiveFilters?: boolean;
|
|
309
|
+
onClearFilters?: () => void;
|
|
310
|
+
};
|
|
311
|
+
export type TableColumnFilterProps = {
|
|
312
|
+
column: Pick<TableSchemaColumn, "key" | "label" | "optionsSource">;
|
|
313
|
+
value: TableFilterValue | undefined;
|
|
314
|
+
onChange: (value: TableFilterValue | undefined) => void;
|
|
315
|
+
options: TableSelectOption[];
|
|
277
316
|
};
|
|
278
317
|
export {};
|
|
@@ -106,6 +106,36 @@ export type TableSchemaColumn = {
|
|
|
106
106
|
* for controlling/observing the active sort key and direction.
|
|
107
107
|
*/
|
|
108
108
|
sortable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* When true, renders a filter button in this column's header that opens the
|
|
111
|
+
* same dropdown as `Select` (multi-select, with search for long lists) to
|
|
112
|
+
* pick the values the column may have. The options are `options` /
|
|
113
|
+
* `optionsSource` of the column, or else the distinct values found in `data`.
|
|
114
|
+
* See `TableSchema.filter` for controlling/observing the filters.
|
|
115
|
+
*/
|
|
116
|
+
filterable?: boolean;
|
|
117
|
+
};
|
|
118
|
+
/** The chosen values of a column; a row stays when its value is one of them. */
|
|
119
|
+
export type TableFilterValue = string[];
|
|
120
|
+
/** Active filters by column key. A column without a filter has no entry. */
|
|
121
|
+
export type TableFilterValues = Record<string, TableFilterValue>;
|
|
122
|
+
export type TableSchemaFilter = {
|
|
123
|
+
/**
|
|
124
|
+
* The active filters. Only meaningful for remote filtering (when
|
|
125
|
+
* `onFilterChange` is provided), where it makes the filters controlled —
|
|
126
|
+
* for example to keep them in the URL. In local filtering the table tracks
|
|
127
|
+
* them itself.
|
|
128
|
+
*/
|
|
129
|
+
values?: TableFilterValues;
|
|
130
|
+
/**
|
|
131
|
+
* Provided for remote filtering: called with all active filters whenever one
|
|
132
|
+
* changes. When provided, the table stops filtering rows itself and expects
|
|
133
|
+
* the parent to fetch `data` accordingly (same contract as
|
|
134
|
+
* `TableSchemaSort.onSortChange`). Give the column `options` or
|
|
135
|
+
* `optionsSource` too: the options found in `data` are only those of the
|
|
136
|
+
* rows loaded so far.
|
|
137
|
+
*/
|
|
138
|
+
onFilterChange?: (values: TableFilterValues) => void;
|
|
109
139
|
};
|
|
110
140
|
export type TableSchemaSort = {
|
|
111
141
|
/**
|
|
@@ -152,6 +182,7 @@ export type TableSchema = {
|
|
|
152
182
|
searchable?: boolean;
|
|
153
183
|
pagination?: TableSchemaPagination;
|
|
154
184
|
sort?: TableSchemaSort;
|
|
185
|
+
filter?: TableSchemaFilter;
|
|
155
186
|
};
|
|
156
187
|
export type TableVisibleRow = {
|
|
157
188
|
row: DynamicTableRow;
|
|
@@ -274,5 +305,13 @@ export type TableEmptyStateProps = {
|
|
|
274
305
|
colSpan: number;
|
|
275
306
|
showSearchInput: boolean;
|
|
276
307
|
normalizedSearchTerm: string;
|
|
308
|
+
hasActiveFilters?: boolean;
|
|
309
|
+
onClearFilters?: () => void;
|
|
310
|
+
};
|
|
311
|
+
export type TableColumnFilterProps = {
|
|
312
|
+
column: Pick<TableSchemaColumn, "key" | "label" | "optionsSource">;
|
|
313
|
+
value: TableFilterValue | undefined;
|
|
314
|
+
onChange: (value: TableFilterValue | undefined) => void;
|
|
315
|
+
options: TableSelectOption[];
|
|
277
316
|
};
|
|
278
317
|
export {};
|