@brightlocal/ui-components 2.6.1 → 2.8.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/component-meta.json +8 -7
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +184 -109
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +462 -401
- package/dist/index.cjs +1 -1
- package/dist/index.js +151 -153
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +15 -0
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/split-layout.js +40 -38
- package/dist/table.cjs +1 -1
- package/dist/table.js +28 -28
- package/package.json +3 -3
- package/src/blocks/data-table.tsx +598 -366
- package/src/components/split-layout.tsx +19 -2
- package/src/components/table.tsx +1 -1
package/component-meta.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Machine-readable registry of all components in the BrightLocal Design System",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
@@ -1898,14 +1898,15 @@
|
|
|
1898
1898
|
"VirtualizedDataTable",
|
|
1899
1899
|
"useDataTable",
|
|
1900
1900
|
"DataTableColumnHeader",
|
|
1901
|
-
"DataTableRowActions",
|
|
1902
|
-
"DataTableToolbar",
|
|
1903
|
-
"DataTableToolbarLeft",
|
|
1904
|
-
"DataTableToolbarRight",
|
|
1905
1901
|
"DataTableSearch",
|
|
1906
1902
|
"DataTablePagination",
|
|
1903
|
+
"DataTablePaginationRowCount",
|
|
1904
|
+
"DataTablePaginationNav",
|
|
1907
1905
|
"DataTableSelectAllCheckbox",
|
|
1908
|
-
"DataTableSelectRowCheckbox"
|
|
1906
|
+
"DataTableSelectRowCheckbox",
|
|
1907
|
+
"DataTableToolbar",
|
|
1908
|
+
"DataTableToolbarLeft",
|
|
1909
|
+
"DataTableToolbarRight"
|
|
1909
1910
|
],
|
|
1910
1911
|
"compound": true,
|
|
1911
1912
|
"dataHookRequired": true,
|
|
@@ -1921,7 +1922,7 @@
|
|
|
1921
1922
|
"isLoading",
|
|
1922
1923
|
"noResultsMessage"
|
|
1923
1924
|
],
|
|
1924
|
-
"description": "Composable data table built on TanStack Table. Exposes `useDataTable` hook + `DataTable` / `VirtualizedDataTable` renderers + toolbar
|
|
1925
|
+
"description": "Composable data table built on TanStack Table. Exposes `useDataTable` hook + `DataTable` / `VirtualizedDataTable` renderers + toolbar layout + pagination and search helpers."
|
|
1925
1926
|
},
|
|
1926
1927
|
{
|
|
1927
1928
|
"name": "InputList",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ie=require("react"),f=require("@tanstack/react-table"),se=require("@tanstack/react-virtual"),y=require("@brightlocal/icons"),S=require("@brightlocal/ui-components/lib/utils"),q=require("../button.cjs"),H=require("../checkbox.cjs"),M=require("../dropdown-menu.cjs"),A=require("../input-group.cjs"),m=require("../pagination.cjs"),ce=require("../skeleton.cjs"),r=require("../table.cjs");function de(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,l.get?l:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const v=de(ie);function D(a,t,n){const[l,o]=v.useState(t),s=a!==void 0?a:l,i=v.useRef(s);v.useEffect(()=>{i.current=s});const d=a!==void 0,u=v.useCallback(p=>{const g=typeof p=="function"?p(i.current):p;d||o(g),n?.(g)},[d,n]);return[s,u]}function ue(a){const{columns:t,data:n,enableSorting:l=!0,enableGlobalFiltering:o=!1,enableRowSelection:s=!1,enablePagination:i=!1,pageSize:d=10,manualSorting:u=!1,manualFiltering:p=!1,manualPagination:g=!1,rowCount:C,pageCount:b,enableExpanding:c=!1,getSubRows:T,getRowId:j,pagination:x,onPaginationChange:R,sorting:w,onSortingChange:z,globalFilter:P,onGlobalFilterChange:N,rowSelection:k,onRowSelectionChange:h,expanded:I,onExpandedChange:F}=a,[X,Y]=D(x,{pageIndex:0,pageSize:d},R),[Z,ee]=D(w,[],z),[ae,te]=D(P,"",N),[ne,le]=D(k,{},h),[oe,re]=D(I,{},F);return f.useReactTable({data:n,columns:t,getCoreRowModel:f.getCoreRowModel(),...j&&{getRowId:j},...(i||g)&&{onPaginationChange:Y},...i&&{...!g&&{getPaginationRowModel:f.getPaginationRowModel()}},...g&&{manualPagination:!0,...C!=null&&{rowCount:C},...b!=null&&{pageCount:b}},...l&&{...!u&&{getSortedRowModel:f.getSortedRowModel()},onSortingChange:ee,...u&&{manualSorting:!0}},...o&&{...!p&&{getFilteredRowModel:f.getFilteredRowModel()},...p&&{manualFiltering:!0},onGlobalFilterChange:te,globalFilterFn:"includesString"},...s&&{enableRowSelection:!0,onRowSelectionChange:le},...c&&{getExpandedRowModel:f.getExpandedRowModel(),onExpandedChange:re,getSubRows:T},state:{pagination:X,sorting:Z,globalFilter:ae,rowSelection:ne,expanded:oe}})}function V({table:a,dataHook:t,trackingEl:n,trackingLabel:l,isLoading:o=!1,skeletonRowCount:s,noResultsMessage:i="No results.",stickyHeader:d=!1,className:u,footer:p}){const g=a.getVisibleLeafColumns().length,C=s??a.getState().pagination.pageSize??10;return e.jsx("div",{"aria-busy":o||void 0,className:S.cn("border-border rounded-md border",u),"data-hook":t,"data-slot":"data-table-view","data-tracking-el":n,"data-tracking-label":l,children:e.jsxs(r.Table,{dataHook:`${t}-table`,children:[e.jsx(r.TableHeader,{className:S.cn(d&&"bg-background sticky top-0 z-10"),children:a.getHeaderGroups().map(b=>e.jsx(r.TableRow,{children:b.headers.map(c=>{const T=c.column.getCanSort()?c.column.getIsSorted():!1,j=T==="asc"?"ascending":T==="desc"?"descending":c.column.getCanSort()?"none":void 0;return e.jsx(r.TableHead,{"aria-sort":j,colSpan:c.colSpan,children:c.isPlaceholder?null:f.flexRender(c.column.columnDef.header,c.getContext())},c.id)})},b.id))}),e.jsx(r.TableBody,{children:o?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:g,rowCount:C}),e.jsx(r.TableRow,{className:"sr-only",children:e.jsx(r.TableCell,{colSpan:g,children:e.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):e.jsx(e.Fragment,{children:a.getRowModel().rows.length>0?a.getRowModel().rows.map(b=>e.jsx($,{row:b},b.id)):e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:g,children:e.jsx("div",{"aria-live":"polite",role:"status",children:i})})})})}),p]})})}V.displayName="DataTable";function $({row:a}){return e.jsx(r.TableRow,{"data-state":a.getIsSelected()?"selected":void 0,children:a.getVisibleCells().map(t=>e.jsx(r.TableCell,{children:f.flexRender(t.column.columnDef.cell,t.getContext())},t.id))})}function E({rowCount:a,colCount:t}){return e.jsx(e.Fragment,{children:Array.from({length:a}).map((n,l)=>e.jsx(r.TableRow,{children:Array.from({length:t}).map((o,s)=>e.jsx(r.TableCell,{children:e.jsx(ce.Skeleton,{className:"h-4 w-full"})},`skeleton-${l}-${s}`))},`skeleton-${l}`))})}function G({table:a,dataHook:t,trackingEl:n,trackingLabel:l,isLoading:o=!1,skeletonRowCount:s,noResultsMessage:i="No results.",stickyHeader:d=!1,className:u,footer:p,height:g,estimateSize:C=48,overscan:b=5}){const c=a.getVisibleLeafColumns().length,T=s??a.getState().pagination.pageSize??10,j=v.useRef(null),x=a.getRowModel().rows,R=se.useVirtualizer({count:x.length,getScrollElement:()=>j.current,estimateSize:()=>C,overscan:b}),w=R.getVirtualItems(),z=R.getTotalSize(),P=w.length>0?w[0].start:0,N=w.length>0?z-w[w.length-1].end:0;return e.jsx("div",{ref:j,"aria-busy":o||void 0,className:S.cn("border-border overflow-auto rounded-md border",u),"data-hook":t,"data-slot":"data-table-view","data-tracking-el":n,"data-tracking-label":l,style:g!=null?{height:g}:void 0,children:e.jsxs(r.Table,{dataHook:`${t}-table`,children:[e.jsx(r.TableHeader,{className:S.cn(d&&"bg-background sticky top-0 z-10"),children:a.getHeaderGroups().map(k=>e.jsx(r.TableRow,{children:k.headers.map(h=>{const I=h.column.getCanSort()?h.column.getIsSorted():!1,F=I==="asc"?"ascending":I==="desc"?"descending":h.column.getCanSort()?"none":void 0;return e.jsx(r.TableHead,{"aria-sort":F,colSpan:h.colSpan,children:h.isPlaceholder?null:f.flexRender(h.column.columnDef.header,h.getContext())},h.id)})},k.id))}),e.jsx(r.TableBody,{children:o?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:c,rowCount:T}),e.jsx(r.TableRow,{className:"sr-only",children:e.jsx(r.TableCell,{colSpan:c,children:e.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):x.length>0?e.jsxs(e.Fragment,{children:[P>0&&e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:c,style:{height:P}})}),w.map(k=>{const h=x[k.index];return e.jsx($,{row:h},h.id)}),N>0&&e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:c,style:{height:N}})})]}):e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:c,children:e.jsx("div",{"aria-live":"polite",role:"status",children:i})})})}),p]})})}G.displayName="VirtualizedDataTable";function O({column:a,title:t,className:n,dataHook:l,trackingEl:o,trackingLabel:s,align:i="left"}){if(!a.getCanSort())return e.jsx("div",{className:S.cn("text-muted-foreground text-left text-sm leading-normal font-medium",i==="right"&&"text-right",i==="center"&&"text-center",n),"data-hook":l,"data-slot":"data-table-column-header","data-tracking-el":o,"data-tracking-label":s,children:t});const d=a.getIsSorted(),u=d==="desc"?`Sort by ${t}, currently descending`:d==="asc"?`Sort by ${t}, currently ascending`:`Sort by ${t}`;return e.jsx("div",{className:S.cn("flex items-center",i==="right"&&"justify-end",i==="center"&&"justify-center",n),"data-slot":"data-table-column-header","data-tracking-el":o,"data-tracking-label":s,children:e.jsxs(q.Button,{"aria-label":u,className:"text-muted-foreground h-auto p-0 text-sm font-medium",dataHook:l||`column-header-${a.id}`,size:"sm",variant:"ghost",onClick:()=>a.toggleSorting(d==="asc"),children:[e.jsx("span",{"aria-hidden":"true",children:t}),e.jsx("span",{"aria-hidden":"true",className:"flex size-3 items-center justify-center",children:d==="desc"?e.jsx(y.ArrowDown,{size:12}):d==="asc"?e.jsx(y.ArrowUp,{size:12}):e.jsx(y.ArrowUpDown,{size:12})})]})})}O.displayName="DataTableColumnHeader";function L({row:a,dataHook:t,trackingEl:n,trackingLabel:l,ariaLabel:o="Open row actions menu",children:s}){return e.jsxs(M.DropdownMenu,{children:[e.jsx(M.DropdownMenuTrigger,{asChild:!0,"data-slot":"data-table-row-actions",children:e.jsx(q.Button,{"aria-label":o,dataHook:t||`row-actions-${a.id}`,size:"sm",trackingEl:n,trackingLabel:l,variant:"ghost",children:e.jsx(y.Ellipsis,{})})}),e.jsx(M.DropdownMenuContent,{align:"end",dataHook:t?`${t}-menu`:`row-actions-${a.id}-menu`,children:s})]})}L.displayName="DataTableRowActions";function B({dataHook:a,trackingEl:t,trackingLabel:n,className:l,children:o}){return e.jsx("div",{className:S.cn("flex items-center gap-2",l),"data-hook":a,"data-slot":"data-table-toolbar-left","data-tracking-el":t,"data-tracking-label":n,children:o})}B.displayName="DataTableToolbarLeft";function _({dataHook:a,trackingEl:t,trackingLabel:n,className:l,children:o}){return e.jsx("div",{className:S.cn("flex items-center gap-2",l),"data-hook":a,"data-slot":"data-table-toolbar-right","data-tracking-el":t,"data-tracking-label":n,children:o})}_.displayName="DataTableToolbarRight";function U({dataHook:a,trackingEl:t,trackingLabel:n,className:l,children:o}){return e.jsx("div",{className:S.cn("flex flex-wrap items-center justify-between gap-2 py-4",l),"data-hook":a,"data-slot":"data-table-toolbar","data-tracking-el":t,"data-tracking-label":n,children:o})}U.displayName="DataTableToolbar";function J({table:a,ariaLabel:t="Search table",placeholder:n="Search...",...l}){const o=a.getState().globalFilter??"",s=i=>{a.setGlobalFilter(i)};return e.jsxs(A.InputGroup,{...l,children:[e.jsx(A.InputGroupInput,{"aria-label":t,placeholder:n,type:"text",value:o,onChange:i=>s(i.target.value)}),e.jsx(A.InputGroupAddon,{className:"pr-3",children:e.jsx(y.Search,{})})]})}J.displayName="DataTableSearch";function K({table:a,dataHook:t,trackingEl:n,trackingLabel:l,className:o,ariaLabel:s="Table pagination"}){const{pageIndex:i,pageSize:d}=a.getState().pagination,u=a.getRowCount(),p=a.getPageCount(),g=a.getCanPreviousPage(),C=a.getCanNextPage(),b=i+1,c=u===0?0:i*d+1,T=Math.min(b*d,u),j=m.usePagination({page:b,totalPages:p,siblingCount:1,boundaryCount:1});return e.jsxs("div",{className:S.cn("flex items-center justify-end gap-4",o),"data-hook":t,"data-slot":"data-table-pagination","data-tracking-el":n,"data-tracking-label":l,children:[e.jsx("span",{className:"text-muted-foreground text-sm",children:u===0?"0 of 0":`${c}-${T} of ${u}`}),e.jsx(m.Pagination,{ariaLabel:s,className:"mx-0 w-auto justify-end",dataHook:`${t}-nav`,children:e.jsx(m.PaginationContent,{children:j.map((x,R)=>x==="previous"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationPrevious,{disabled:!g,onClick:()=>a.previousPage()})},"previous"):x==="next"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationNext,{disabled:!C,onClick:()=>a.nextPage()})},"next"):x==="ellipsis"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationEllipsis,{})},`ellipsis-${R}`):e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationLink,{isActive:x===b,page:x,onClick:()=>a.setPageIndex(x-1)})},x))})})]})}K.displayName="DataTablePagination";function Q({table:a,dataHook:t,trackingEl:n,trackingLabel:l}){return e.jsx(H.Checkbox,{"aria-label":"Select all",checked:a.getIsAllPageRowsSelected()||a.getIsSomePageRowsSelected()&&"indeterminate",dataHook:t||"select-all-checkbox",trackingEl:n,trackingLabel:l,onCheckedChange:o=>a.toggleAllPageRowsSelected(!!o)})}Q.displayName="DataTableSelectAllCheckbox";function W({row:a,dataHook:t,trackingEl:n,trackingLabel:l}){return e.jsx(H.Checkbox,{"aria-label":"Select row",checked:a.getIsSelected(),dataHook:t||`select-row-${a.id}`,disabled:!a.getCanSelect(),trackingEl:n,trackingLabel:l,onCheckedChange:o=>a.toggleSelected(!!o)})}W.displayName="DataTableSelectRowCheckbox";Object.defineProperty(exports,"createColumnHelper",{enumerable:!0,get:()=>f.createColumnHelper});Object.defineProperty(exports,"flexRender",{enumerable:!0,get:()=>f.flexRender});exports.DataTable=V;exports.DataTableColumnHeader=O;exports.DataTablePagination=K;exports.DataTableRowActions=L;exports.DataTableSearch=J;exports.DataTableSelectAllCheckbox=Q;exports.DataTableSelectRowCheckbox=W;exports.DataTableToolbar=U;exports.DataTableToolbarLeft=B;exports.DataTableToolbarRight=_;exports.VirtualizedDataTable=G;exports.useDataTable=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),de=require("react"),j=require("@tanstack/react-table"),ue=require("@tanstack/react-virtual"),R=require("@brightlocal/icons"),p=require("@brightlocal/ui-components/lib/utils"),A=require("../button.cjs"),q=require("../checkbox.cjs"),N=require("../input-group.cjs"),m=require("../pagination.cjs"),ge=require("../skeleton.cjs"),g=require("../table.cjs");function be(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const t=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(n,o,t.get?t:{enumerable:!0,get:()=>a[o]})}}return n.default=a,Object.freeze(n)}const x=be(de);function P(a,n,o){const[t,i]=x.useState(n),l=a!==void 0?a:t,s=x.useRef(l);x.useEffect(()=>{s.current=l});const c=a!==void 0,d=x.useCallback(r=>{const u=typeof r=="function"?r(s.current):r;c||i(u),o?.(u)},[c,o]);return[l,d]}function xe(a){const{columns:n,data:o,enableSorting:t=!0,enableGlobalFiltering:i=!1,enableRowSelection:l=!1,enablePagination:s=!1,pageSize:c=10,manualSorting:d=!1,manualFiltering:r=!1,manualPagination:u=!1,rowCount:h,pageCount:b,enableExpanding:f=!1,getSubRows:w,getRowId:C,pagination:T,onPaginationChange:v,sorting:S,onSortingChange:z,globalFilter:D,onGlobalFilterChange:k,rowSelection:I,onRowSelectionChange:y,expanded:Y,onExpandedChange:Z}=a,[ee,ae]=P(T,{pageIndex:0,pageSize:c},v),[te,ne]=P(S,[],z),[oe,le]=P(D,"",k),[ie,se]=P(I,{},y),[re,ce]=P(Y,{},Z);return j.useReactTable({data:o,columns:n,getCoreRowModel:j.getCoreRowModel(),...C&&{getRowId:C},...(s||u)&&{onPaginationChange:ae},...s&&{...!u&&{getPaginationRowModel:j.getPaginationRowModel()}},...u&&{manualPagination:!0,...h!=null&&{rowCount:h},...b!=null&&{pageCount:b}},...t&&{...!d&&{getSortedRowModel:j.getSortedRowModel()},onSortingChange:ne,...d&&{manualSorting:!0}},...i&&{...!r&&{getFilteredRowModel:j.getFilteredRowModel()},...r&&{manualFiltering:!0},onGlobalFilterChange:le,globalFilterFn:"includesString"},...l&&{enableRowSelection:!0,onRowSelectionChange:se},...f&&{getExpandedRowModel:j.getExpandedRowModel(),onExpandedChange:ce,getSubRows:w},state:{pagination:ee,sorting:te,globalFilter:oe,rowSelection:ie,expanded:re}})}function H({table:a,dataHook:n,trackingEl:o,trackingLabel:t,isLoading:i=!1,skeletonRowCount:l,noResultsMessage:s="No results.",stickyHeader:c=!1,className:d,footer:r}){const u=a.getVisibleLeafColumns().length,h=l??a.getState().pagination.pageSize??10;return e.jsx("div",{"aria-busy":i||void 0,className:p.cn("border-border overflow-auto rounded-md border",d),"data-hook":n,"data-slot":"data-table-view","data-tracking-el":o,"data-tracking-label":t,children:e.jsxs(g.Table,{dataHook:`${n}-table`,children:[e.jsx(V,{stickyHeader:c,table:a}),e.jsx(g.TableBody,{children:i?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:u,rowCount:h}),e.jsx(g.TableRow,{className:"sr-only",children:e.jsx(g.TableCell,{colSpan:u,children:e.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):e.jsx(e.Fragment,{children:a.getRowModel().rows.length>0?a.getRowModel().rows.map(b=>e.jsx($,{row:b},b.id)):e.jsx(g.TableRow,{children:e.jsx(g.TableCell,{colSpan:u,children:e.jsx("div",{"aria-live":"polite",role:"status",children:s})})})})}),r]})})}H.displayName="DataTable";function V({table:a,stickyHeader:n}){return e.jsx(g.TableHeader,{className:p.cn(n&&"bg-background sticky top-0 z-10"),children:a.getHeaderGroups().map(o=>e.jsx(g.TableRow,{children:o.headers.map(t=>{const i=t.column.getCanSort()?t.column.getIsSorted():!1,l=i==="asc"?"ascending":i==="desc"?"descending":t.column.getCanSort()?"none":void 0;return e.jsx(g.TableHead,{"aria-sort":l,colSpan:t.colSpan,children:t.isPlaceholder?null:j.flexRender(t.column.columnDef.header,t.getContext())},t.id)})},o.id))})}function $({row:a}){return e.jsx(g.TableRow,{"data-state":a.getIsSelected()?"selected":void 0,children:a.getVisibleCells().map(n=>e.jsx(g.TableCell,{children:j.flexRender(n.column.columnDef.cell,n.getContext())},n.id))})}function E({rowCount:a,colCount:n}){return e.jsx(e.Fragment,{children:Array.from({length:a}).map((o,t)=>e.jsx(g.TableRow,{children:Array.from({length:n}).map((i,l)=>e.jsx(g.TableCell,{children:e.jsx(ge.Skeleton,{className:"h-4 w-full"})},`skeleton-${t}-${l}`))},`skeleton-${t}`))})}function G({table:a,dataHook:n,trackingEl:o,trackingLabel:t,isLoading:i=!1,skeletonRowCount:l,noResultsMessage:s="No results.",stickyHeader:c=!1,className:d,footer:r,height:u,estimateSize:h=48,overscan:b=5}){const f=a.getVisibleLeafColumns().length,w=l??a.getState().pagination.pageSize??10,C=x.useRef(null),T=a.getRowModel().rows,v=ue.useVirtualizer({count:T.length,getScrollElement:()=>C.current,estimateSize:()=>h,overscan:b}),S=v.getVirtualItems(),z=v.getTotalSize(),D=S.length>0?S[0].start:0,k=S.length>0?z-S[S.length-1].end:0;return e.jsx("div",{ref:C,"aria-busy":i||void 0,className:p.cn("border-border overflow-auto rounded-md border",d),"data-hook":n,"data-slot":"data-table-view","data-tracking-el":o,"data-tracking-label":t,style:u!=null?{height:u}:void 0,children:e.jsxs(g.Table,{dataHook:`${n}-table`,children:[e.jsx(V,{stickyHeader:c,table:a}),e.jsx(g.TableBody,{children:i?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:f,rowCount:w}),e.jsx(g.TableRow,{className:"sr-only",children:e.jsx(g.TableCell,{colSpan:f,children:e.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):T.length>0?e.jsxs(e.Fragment,{children:[D>0&&e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:f,style:{height:D}})}),S.map(I=>{const y=T[I.index];return e.jsx($,{row:y},y.id)}),k>0&&e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:f,style:{height:k}})})]}):e.jsx(g.TableRow,{children:e.jsx(g.TableCell,{colSpan:f,children:e.jsx("div",{"aria-live":"polite",role:"status",children:s})})})}),r]})})}G.displayName="VirtualizedDataTable";function L({column:a,title:n,className:o,dataHook:t,trackingEl:i,trackingLabel:l,align:s="left"}){if(!a.getCanSort())return e.jsx("div",{className:p.cn("text-muted-foreground text-left text-sm leading-normal font-medium",s==="right"&&"text-right",s==="center"&&"text-center",o),"data-hook":t,"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":l,children:n});const c=a.getIsSorted(),d=c==="desc"?`Sort by ${n}, currently descending`:c==="asc"?`Sort by ${n}, currently ascending`:`Sort by ${n}`;return e.jsx("div",{className:p.cn("flex items-center",s==="right"&&"justify-end",s==="center"&&"justify-center",o),"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":l,children:e.jsxs(A.Button,{"aria-label":d,className:"text-muted-foreground h-auto p-0 text-sm font-medium",dataHook:t||`column-header-${a.id}`,size:"sm",variant:"ghost",onClick:()=>a.toggleSorting(c==="asc"),children:[e.jsx("span",{"aria-hidden":"true",children:n}),e.jsx("span",{"aria-hidden":"true",className:"flex size-3 items-center justify-center",children:c==="desc"?e.jsx(R.ArrowDown,{size:12}):c==="asc"?e.jsx(R.ArrowUp,{size:12}):e.jsx(R.ArrowUpDown,{size:12})})]})})}L.displayName="DataTableColumnHeader";function O({table:a,ariaLabel:n="Search table",placeholder:o="Search...",...t}){const i=a.getState().globalFilter??"",l=s=>{a.setGlobalFilter(s)};return e.jsxs(N.InputGroup,{"data-slot":"data-table-search",...t,children:[e.jsx(N.InputGroupAddon,{className:"pl-3",children:e.jsx(R.Search,{})}),e.jsx(N.InputGroupInput,{"aria-label":n,placeholder:o,type:"text",value:i,onChange:s=>l(s.target.value)}),i&&e.jsx(N.InputGroupAddon,{className:"pr-1",children:e.jsx(A.Button,{"aria-label":"Clear search",className:"h-auto p-1","data-slot":"data-table-search-clear",dataHook:`${t.dataHook}-clear`,variant:"ghost",onClick:()=>l(""),children:e.jsx(R.X,{size:14})})})]})}O.displayName="DataTableSearch";function he(a){const{pageIndex:n,pageSize:o}=a.getState().pagination,t=a.getRowCount(),i=a.getPageCount(),l=a.getCanPreviousPage(),s=a.getCanNextPage(),c=n+1,d=t===0?0:n*o+1,r=Math.min(c*o,t),u=x.useCallback(w=>a.setPageIndex(w-1),[a]),h=x.useCallback(()=>a.nextPage(),[a]),b=x.useCallback(()=>a.previousPage(),[a]),f=x.useCallback(w=>a.setPageSize(w),[a]);return x.useMemo(()=>({pageIndex:n,pageSize:o,totalRows:t,totalPages:i,startRow:d,endRow:r,currentPage:c,canPrev:l,canNext:s,goToPage:u,nextPage:h,previousPage:b,setPageSize:f}),[n,o,t,i,d,r,c,l,s,u,h,b,f])}const F=x.createContext(null);function B(){const a=x.useContext(F);if(!a)throw new Error("DataTablePagination sub-components must be used within <DataTablePagination>");return a}function _({renderText:a,className:n}){const{info:o}=B(),{startRow:t,endRow:i,totalRows:l,pageIndex:s,pageSize:c}=o,d=a?a({startRow:t,endRow:i,totalRows:l,pageIndex:s,pageSize:c}):l===0?null:`${t}-${i} of ${l}`;return d==null?null:e.jsx("span",{className:p.cn("text-muted-foreground text-sm",n),"data-slot":"data-table-pagination-row-count",children:d})}_.displayName="DataTablePaginationRowCount";function M({ariaLabel:a="Table pagination",dataHook:n,className:o}){const{info:t}=B(),i=m.usePagination({page:t.currentPage,totalPages:t.totalPages,siblingCount:1,boundaryCount:1});return e.jsx(m.Pagination,{ariaLabel:a,className:p.cn("mx-0 w-auto justify-end",o),dataHook:n??"pagination-nav",children:e.jsx(m.PaginationContent,{children:i.map((l,s)=>l==="previous"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationPrevious,{disabled:!t.canPrev,onClick:()=>t.previousPage()})},"previous"):l==="next"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationNext,{disabled:!t.canNext,onClick:()=>t.nextPage()})},"next"):l==="ellipsis"?e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationEllipsis,{})},`ellipsis-${s}`):e.jsx(m.PaginationItem,{children:e.jsx(m.PaginationLink,{isActive:l===t.currentPage,page:l,onClick:()=>t.goToPage(l)})},l))})})}M.displayName="DataTablePaginationNav";function U({table:a,dataHook:n,showRowCount:o=!0,renderRowCount:t,trackingEl:i,trackingLabel:l,className:s,ariaLabel:c="Table pagination",children:d}){const r=he(a),u=x.useMemo(()=>({info:r}),[r]),h={"data-hook":n,"data-slot":"data-table-pagination","data-tracking-el":i,"data-tracking-label":l};if(d)return e.jsx(F.Provider,{value:u,children:e.jsx("div",{className:p.cn("flex w-full items-center gap-4",s),...h,children:d})});const b=!o||t===null?null:t?t({startRow:r.startRow,endRow:r.endRow,totalRows:r.totalRows,pageIndex:r.pageIndex,pageSize:r.pageSize}):r.totalRows===0?null:`${r.startRow}-${r.endRow} of ${r.totalRows}`;return e.jsx(F.Provider,{value:u,children:e.jsxs("div",{className:p.cn("flex w-full items-center gap-4",b!=null?"justify-between":"justify-end",s),...h,children:[b!=null&&e.jsx("span",{className:"text-muted-foreground text-sm",children:b}),e.jsx(M,{ariaLabel:c,dataHook:`${n}-nav`})]})})}U.displayName="DataTablePagination";function X({table:a,dataHook:n,trackingEl:o,trackingLabel:t}){return e.jsx(q.Checkbox,{"aria-label":"Select all",checked:a.getIsAllPageRowsSelected()||a.getIsSomePageRowsSelected()&&"indeterminate",dataHook:n||"select-all-checkbox",trackingEl:o,trackingLabel:t,onCheckedChange:i=>a.toggleAllPageRowsSelected(!!i)})}X.displayName="DataTableSelectAllCheckbox";function J({row:a,dataHook:n,trackingEl:o,trackingLabel:t}){return e.jsx(q.Checkbox,{"aria-label":"Select row",checked:a.getIsSelected(),dataHook:n||`select-row-${a.id}`,disabled:!a.getCanSelect(),trackingEl:o,trackingLabel:t,onCheckedChange:i=>a.toggleSelected(!!i)})}J.displayName="DataTableSelectRowCheckbox";function K({dataHook:a,className:n,children:o}){return e.jsx("div",{className:p.cn("flex flex-col gap-3 py-4 sm:flex-row sm:items-center",n),"data-hook":a,"data-slot":"data-table-toolbar",children:o})}K.displayName="DataTableToolbar";function Q({className:a,children:n}){return e.jsx("div",{className:p.cn("flex w-full min-w-0 items-center gap-2 sm:w-auto sm:flex-1",a),"data-slot":"data-table-toolbar-left",children:n})}Q.displayName="DataTableToolbarLeft";function W({className:a,children:n}){return e.jsx("div",{className:p.cn("flex w-full items-center justify-end gap-2 sm:w-auto",a),"data-slot":"data-table-toolbar-right",children:n})}W.displayName="DataTableToolbarRight";exports.DataTable=H;exports.DataTableColumnHeader=L;exports.DataTablePagination=U;exports.DataTablePaginationNav=M;exports.DataTablePaginationRowCount=_;exports.DataTableSearch=O;exports.DataTableSelectAllCheckbox=X;exports.DataTableSelectRowCheckbox=J;exports.DataTableToolbar=K;exports.DataTableToolbarLeft=Q;exports.DataTableToolbarRight=W;exports.VirtualizedDataTable=G;exports.useDataTable=xe;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Column, ColumnDef, ExpandedState, PaginationState, Row, RowSelectionState, SortingState, Table as TanStackTable
|
|
1
|
+
import { Column, ColumnDef, ExpandedState, PaginationState, Row, RowSelectionState, SortingState, Table as TanStackTable } from '@tanstack/react-table';
|
|
2
2
|
import { InputGroup } from '../input-group';
|
|
3
3
|
/**
|
|
4
4
|
* DataTable — composable data table primitives built on TanStack Table.
|
|
@@ -11,9 +11,12 @@ import { InputGroup } from '../input-group';
|
|
|
11
11
|
* - `VirtualizedDataTable`: drop-in alternative to `DataTable` that
|
|
12
12
|
* renders only visible rows via `@tanstack/react-virtual`. Use for large
|
|
13
13
|
* datasets (1 000+ rows) where full DOM rendering is too expensive.
|
|
14
|
-
* - Helpers: `
|
|
15
|
-
* `DataTableColumnHeader`, `
|
|
16
|
-
* `
|
|
14
|
+
* - Helpers: `DataTableSearch`, `DataTablePagination`,
|
|
15
|
+
* `DataTableColumnHeader`, `DataTableSelectAllCheckbox`,
|
|
16
|
+
* `DataTableSelectRowCheckbox`.
|
|
17
|
+
* - Layout: `DataTableToolbar`, `DataTableToolbarLeft`,
|
|
18
|
+
* `DataTableToolbarRight` — responsive flex container for search +
|
|
19
|
+
* pagination above (or below) the table.
|
|
17
20
|
*
|
|
18
21
|
* Block composition example — see `apps/sandbox/components/audit-table.tsx`.
|
|
19
22
|
*/
|
|
@@ -279,100 +282,6 @@ export declare function DataTableColumnHeader<TData, TValue>({ column, title, cl
|
|
|
279
282
|
export declare namespace DataTableColumnHeader {
|
|
280
283
|
var displayName: string;
|
|
281
284
|
}
|
|
282
|
-
/**
|
|
283
|
-
* Props for `DataTableRowActions` — the standard row ellipsis actions menu.
|
|
284
|
-
*/
|
|
285
|
-
export interface DataTableRowActionsProps<TData> {
|
|
286
|
-
/** TanStack row instance (from the `cell` render slot). */
|
|
287
|
-
row: Row<TData>;
|
|
288
|
-
/** Data hook for automated testing. */
|
|
289
|
-
dataHook?: string;
|
|
290
|
-
/** Analytics element identifier. */
|
|
291
|
-
trackingEl?: string;
|
|
292
|
-
/** Analytics label. */
|
|
293
|
-
trackingLabel?: string;
|
|
294
|
-
/** Accessible label for the trigger. @default "Open row actions menu" */
|
|
295
|
-
ariaLabel?: string;
|
|
296
|
-
/** `DropdownMenuItem`s to render inside the menu. */
|
|
297
|
-
children?: React.ReactNode;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Row-level ellipsis dropdown menu. Pass `DropdownMenuItem`s as children.
|
|
301
|
-
*/
|
|
302
|
-
export declare function DataTableRowActions<TData>({ row, dataHook, trackingEl, trackingLabel, ariaLabel, children, }: DataTableRowActionsProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
303
|
-
export declare namespace DataTableRowActions {
|
|
304
|
-
var displayName: string;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Props for the root `DataTableToolbar` container.
|
|
308
|
-
*/
|
|
309
|
-
export interface DataTableToolbarProps {
|
|
310
|
-
/** Data hook for automated testing. */
|
|
311
|
-
dataHook?: string;
|
|
312
|
-
/** Analytics element identifier. */
|
|
313
|
-
trackingEl?: string;
|
|
314
|
-
/** Analytics label. */
|
|
315
|
-
trackingLabel?: string;
|
|
316
|
-
/** Additional class name. */
|
|
317
|
-
className?: string;
|
|
318
|
-
/** Toolbar content — usually `<DataTableToolbarLeft>` / `<DataTableToolbarRight>`. */
|
|
319
|
-
children?: React.ReactNode;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Props for `DataTableToolbarLeft`.
|
|
323
|
-
*/
|
|
324
|
-
export interface DataTableToolbarLeftProps {
|
|
325
|
-
/** Data hook for automated testing. */
|
|
326
|
-
dataHook?: string;
|
|
327
|
-
/** Analytics element identifier. */
|
|
328
|
-
trackingEl?: string;
|
|
329
|
-
/** Analytics label. */
|
|
330
|
-
trackingLabel?: string;
|
|
331
|
-
/** Additional class name. */
|
|
332
|
-
className?: string;
|
|
333
|
-
/** Content to render on the left side. */
|
|
334
|
-
children?: React.ReactNode;
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Props for `DataTableToolbarRight`.
|
|
338
|
-
*/
|
|
339
|
-
export interface DataTableToolbarRightProps {
|
|
340
|
-
/** Data hook for automated testing. */
|
|
341
|
-
dataHook?: string;
|
|
342
|
-
/** Analytics element identifier. */
|
|
343
|
-
trackingEl?: string;
|
|
344
|
-
/** Analytics label. */
|
|
345
|
-
trackingLabel?: string;
|
|
346
|
-
/** Additional class name. */
|
|
347
|
-
className?: string;
|
|
348
|
-
/** Content to render on the right side. */
|
|
349
|
-
children?: React.ReactNode;
|
|
350
|
-
}
|
|
351
|
-
export declare function DataTableToolbarLeft({ dataHook, trackingEl, trackingLabel, className, children, }: DataTableToolbarLeftProps): import("react/jsx-runtime").JSX.Element;
|
|
352
|
-
export declare namespace DataTableToolbarLeft {
|
|
353
|
-
var displayName: string;
|
|
354
|
-
}
|
|
355
|
-
export declare function DataTableToolbarRight({ dataHook, trackingEl, trackingLabel, className, children, }: DataTableToolbarRightProps): import("react/jsx-runtime").JSX.Element;
|
|
356
|
-
export declare namespace DataTableToolbarRight {
|
|
357
|
-
var displayName: string;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Flexible two-column toolbar for composing DataTable UIs.
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* <DataTableToolbar dataHook="toolbar">
|
|
364
|
-
* <DataTableToolbarLeft>
|
|
365
|
-
* <DataTableSearch table={table} dataHook="search" />
|
|
366
|
-
* </DataTableToolbarLeft>
|
|
367
|
-
* <DataTableToolbarRight>
|
|
368
|
-
* <DataTablePagination table={table} dataHook="pagination" />
|
|
369
|
-
* </DataTableToolbarRight>
|
|
370
|
-
* </DataTableToolbar>
|
|
371
|
-
*/
|
|
372
|
-
export declare function DataTableToolbar({ dataHook, trackingEl, trackingLabel, className, children, }: DataTableToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
373
|
-
export declare namespace DataTableToolbar {
|
|
374
|
-
var displayName: string;
|
|
375
|
-
}
|
|
376
285
|
/**
|
|
377
286
|
* Props for `DataTableSearch`.
|
|
378
287
|
*
|
|
@@ -401,6 +310,59 @@ export declare function DataTableSearch<TData>({ table, ariaLabel, placeholder,
|
|
|
401
310
|
export declare namespace DataTableSearch {
|
|
402
311
|
var displayName: string;
|
|
403
312
|
}
|
|
313
|
+
/** Info passed to row-count render functions. */
|
|
314
|
+
export interface RowCountRenderInfo {
|
|
315
|
+
/** First visible row (1-based, 0 when empty). */
|
|
316
|
+
startRow: number;
|
|
317
|
+
/** Last visible row. */
|
|
318
|
+
endRow: number;
|
|
319
|
+
/** Total rows across all pages. */
|
|
320
|
+
totalRows: number;
|
|
321
|
+
/** Current 0-based page index. */
|
|
322
|
+
pageIndex: number;
|
|
323
|
+
/** Number of rows per page. */
|
|
324
|
+
pageSize: number;
|
|
325
|
+
}
|
|
326
|
+
export interface DataTablePaginationRowCountProps {
|
|
327
|
+
/**
|
|
328
|
+
* Render the row-count text. Receives pagination numbers; you control
|
|
329
|
+
* wording, pluralization, and order. Return `null` to hide.
|
|
330
|
+
* @default Renders "{startRow}-{endRow} of {totalRows}" or nothing when empty.
|
|
331
|
+
*/
|
|
332
|
+
renderText?: (info: RowCountRenderInfo) => React.ReactNode;
|
|
333
|
+
/** Additional class name. */
|
|
334
|
+
className?: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Row-count label for `DataTablePagination`.
|
|
338
|
+
*
|
|
339
|
+
* Renders "start–end of total" by default. Pass `renderText` for i18n-friendly
|
|
340
|
+
* custom text with full control over wording, pluralization, and order.
|
|
341
|
+
*
|
|
342
|
+
* Must be rendered inside `<DataTablePagination>`.
|
|
343
|
+
*/
|
|
344
|
+
declare function DataTablePaginationRowCount({ renderText, className, }: DataTablePaginationRowCountProps): import("react/jsx-runtime").JSX.Element | null;
|
|
345
|
+
declare namespace DataTablePaginationRowCount {
|
|
346
|
+
var displayName: string;
|
|
347
|
+
}
|
|
348
|
+
export interface DataTablePaginationNavProps {
|
|
349
|
+
/** Accessible label for the nav landmark. @default "Table pagination" */
|
|
350
|
+
ariaLabel?: string;
|
|
351
|
+
/** Data hook for the nav element. */
|
|
352
|
+
dataHook?: string;
|
|
353
|
+
/** Additional class name. */
|
|
354
|
+
className?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Pagination navigation for `DataTablePagination`.
|
|
358
|
+
*
|
|
359
|
+
* Renders previous/next buttons and page links. Must be rendered inside
|
|
360
|
+
* `<DataTablePagination>`.
|
|
361
|
+
*/
|
|
362
|
+
declare function DataTablePaginationNav({ ariaLabel, dataHook, className, }: DataTablePaginationNavProps): import("react/jsx-runtime").JSX.Element;
|
|
363
|
+
declare namespace DataTablePaginationNav {
|
|
364
|
+
var displayName: string;
|
|
365
|
+
}
|
|
404
366
|
/**
|
|
405
367
|
* Props for `DataTablePagination`.
|
|
406
368
|
*
|
|
@@ -409,34 +371,78 @@ export declare namespace DataTableSearch {
|
|
|
409
371
|
* - Client-side: `enablePagination: true`
|
|
410
372
|
* - Server-side: `manualPagination: true` + `rowCount` (or `pageCount`)
|
|
411
373
|
* + controlled `pagination` / `onPaginationChange`
|
|
374
|
+
*
|
|
375
|
+
* **Compositional mode:** pass children (`DataTablePaginationRowCount`,
|
|
376
|
+
* `DataTablePaginationNav`) for full layout control. Without children the
|
|
377
|
+
* component renders its default layout.
|
|
412
378
|
*/
|
|
413
379
|
export interface DataTablePaginationProps<TData> {
|
|
414
380
|
/** TanStack Table instance. */
|
|
415
381
|
table: TanStackTable<TData>;
|
|
416
382
|
/** Data hook for automated testing (REQUIRED). */
|
|
417
383
|
dataHook: string;
|
|
384
|
+
/**
|
|
385
|
+
* Show the row count text in the default (non-compositional) layout.
|
|
386
|
+
* Ignored when `children` are provided — use `DataTablePaginationRowCount` instead.
|
|
387
|
+
* @default true
|
|
388
|
+
*/
|
|
389
|
+
showRowCount?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Render the row-count text. Receives pagination numbers; you control
|
|
392
|
+
* wording, pluralization, and order. Return `null` to hide.
|
|
393
|
+
* Ignored when `children` are provided — use `DataTablePaginationRowCount` instead.
|
|
394
|
+
* @default Renders "{startRow}-{endRow} of {totalRows}" or nothing when empty.
|
|
395
|
+
*/
|
|
396
|
+
renderRowCount?: ((info: RowCountRenderInfo) => React.ReactNode) | null;
|
|
418
397
|
/** Analytics element identifier. */
|
|
419
398
|
trackingEl?: string;
|
|
420
399
|
/** Analytics label. */
|
|
421
400
|
trackingLabel?: string;
|
|
422
401
|
/** Additional class name. */
|
|
423
402
|
className?: string;
|
|
424
|
-
/** Accessible label for the nav landmark. @default "Table pagination" */
|
|
403
|
+
/** Accessible label for the nav landmark (default layout only). @default "Table pagination" */
|
|
425
404
|
ariaLabel?: string;
|
|
405
|
+
/**
|
|
406
|
+
* Compositional children. When provided, the component acts as a context
|
|
407
|
+
* provider and renders children instead of the default layout.
|
|
408
|
+
* Use `<DataTablePaginationRowCount>` and `<DataTablePaginationNav>`
|
|
409
|
+
* as children.
|
|
410
|
+
*/
|
|
411
|
+
children?: React.ReactNode;
|
|
426
412
|
}
|
|
427
413
|
/**
|
|
428
|
-
* Pagination controls
|
|
414
|
+
* Pagination controls for a DataTable.
|
|
415
|
+
*
|
|
416
|
+
* **Default mode** (no children): renders previous/next/page links and an
|
|
417
|
+
* optional "start–end of total" row count label. Use `renderRowCount` for
|
|
418
|
+
* i18n-friendly text.
|
|
429
419
|
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* `table.getCanNextPage()`, and `table.setPageIndex()`.
|
|
420
|
+
* **Compositional mode** (with children): acts as a context provider.
|
|
421
|
+
* Compose `DataTablePaginationRowCount` and `DataTablePaginationNav`
|
|
422
|
+
* in any order/layout.
|
|
434
423
|
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
424
|
+
* @example
|
|
425
|
+
* // Default mode
|
|
426
|
+
* <DataTablePagination table={table} dataHook="pagination" />
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* // Default mode with i18n
|
|
430
|
+
* <DataTablePagination
|
|
431
|
+
* table={table}
|
|
432
|
+
* dataHook="pagination"
|
|
433
|
+
* renderRowCount={({ startRow, endRow, totalRows }) =>
|
|
434
|
+
* t('pagination.caption', { from: startRow, to: endRow, total: totalRows })
|
|
435
|
+
* }
|
|
436
|
+
* />
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* // Compositional mode
|
|
440
|
+
* <DataTablePagination table={table} dataHook="pagination">
|
|
441
|
+
* <DataTablePaginationRowCount />
|
|
442
|
+
* <DataTablePaginationNav />
|
|
443
|
+
* </DataTablePagination>
|
|
438
444
|
*/
|
|
439
|
-
export declare function DataTablePagination<TData>({ table, dataHook, trackingEl, trackingLabel, className, ariaLabel, }: DataTablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
445
|
+
export declare function DataTablePagination<TData>({ table, dataHook, showRowCount, renderRowCount, trackingEl, trackingLabel, className, ariaLabel, children, }: DataTablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
440
446
|
export declare namespace DataTablePagination {
|
|
441
447
|
var displayName: string;
|
|
442
448
|
}
|
|
@@ -482,6 +488,75 @@ export declare function DataTableSelectRowCheckbox<TData>({ row, dataHook, track
|
|
|
482
488
|
export declare namespace DataTableSelectRowCheckbox {
|
|
483
489
|
var displayName: string;
|
|
484
490
|
}
|
|
485
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Props for `DataTableToolbar` — a responsive flex container for laying out
|
|
493
|
+
* search, filters, pagination, and actions above (or below) a DataTable.
|
|
494
|
+
*/
|
|
495
|
+
export interface DataTableToolbarProps {
|
|
496
|
+
/** Data hook for automated testing (REQUIRED). */
|
|
497
|
+
dataHook: string;
|
|
498
|
+
/** Additional class name (merged after defaults via `cn`). */
|
|
499
|
+
className?: string;
|
|
500
|
+
/** Toolbar contents — typically `DataTableToolbarLeft` and `DataTableToolbarRight`. */
|
|
501
|
+
children: React.ReactNode;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Responsive toolbar container for DataTable companion controls.
|
|
505
|
+
*
|
|
506
|
+
* Stacks vertically on mobile (< 640 px) and switches to a horizontal
|
|
507
|
+
* row on `sm:` and up. Layout-only — no dependency on a TanStack Table
|
|
508
|
+
* instance, so it works for table footers or any search-plus-pagination row.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* <DataTableToolbar dataHook="locations-toolbar">
|
|
512
|
+
* <DataTableToolbarLeft>
|
|
513
|
+
* <DataTableSearch table={table} dataHook="search" />
|
|
514
|
+
* </DataTableToolbarLeft>
|
|
515
|
+
* <DataTableToolbarRight>
|
|
516
|
+
* <DataTablePagination table={table} dataHook="pagination" />
|
|
517
|
+
* </DataTableToolbarRight>
|
|
518
|
+
* </DataTableToolbar>
|
|
519
|
+
*/
|
|
520
|
+
export declare function DataTableToolbar({ dataHook, className, children, }: DataTableToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
521
|
+
export declare namespace DataTableToolbar {
|
|
522
|
+
var displayName: string;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Props for `DataTableToolbarLeft` — the left slot inside a `DataTableToolbar`.
|
|
526
|
+
*/
|
|
527
|
+
export interface DataTableToolbarLeftProps {
|
|
528
|
+
/** Additional class name (merged after defaults via `cn`). */
|
|
529
|
+
className?: string;
|
|
530
|
+
/** Slot contents — typically `DataTableSearch` and filter controls. */
|
|
531
|
+
children: React.ReactNode;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Left slot of `DataTableToolbar`. Grows to fill remaining space on
|
|
535
|
+
* desktop; full-width on mobile. `min-w-0` lets long inputs shrink
|
|
536
|
+
* instead of overflowing on narrow viewports.
|
|
537
|
+
*/
|
|
538
|
+
export declare function DataTableToolbarLeft({ className, children, }: DataTableToolbarLeftProps): import("react/jsx-runtime").JSX.Element;
|
|
539
|
+
export declare namespace DataTableToolbarLeft {
|
|
540
|
+
var displayName: string;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Props for `DataTableToolbarRight` — the right slot inside a `DataTableToolbar`.
|
|
544
|
+
*/
|
|
545
|
+
export interface DataTableToolbarRightProps {
|
|
546
|
+
/** Additional class name (merged after defaults via `cn`). */
|
|
547
|
+
className?: string;
|
|
548
|
+
/** Slot contents — typically `DataTablePagination` or action buttons. */
|
|
549
|
+
children: React.ReactNode;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Right slot of `DataTableToolbar`. Collapses to content width and
|
|
553
|
+
* right-aligns on desktop; full-width with `justify-end` on mobile so
|
|
554
|
+
* pagination controls don't jump when stacking.
|
|
555
|
+
*/
|
|
556
|
+
export declare function DataTableToolbarRight({ className, children, }: DataTableToolbarRightProps): import("react/jsx-runtime").JSX.Element;
|
|
557
|
+
export declare namespace DataTableToolbarRight {
|
|
558
|
+
var displayName: string;
|
|
559
|
+
}
|
|
560
|
+
export { DataTablePaginationRowCount, DataTablePaginationNav };
|
|
486
561
|
export type { Column, ColumnDef, ExpandedState, PaginationState, Row, RowSelectionState, SortingState, TanStackTable, };
|
|
487
562
|
//# sourceMappingURL=data-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/blocks/data-table.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/blocks/data-table.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,KAAK,IAAI,aAAa,EAQ5B,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,UAAU,EAGX,MAAM,2BAA2B,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