@brightlocal/ui-components 2.2.0 → 2.3.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/AI_USAGE.md +1 -1
- package/README.md +3 -3
- package/component-meta.json +54 -10
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +380 -196
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +452 -449
- package/dist/callout.cjs +1 -0
- package/dist/callout.d.ts +51 -0
- package/dist/callout.d.ts.map +1 -0
- package/dist/callout.js +114 -0
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +40 -4
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +156 -101
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +436 -426
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +1 -1
- package/dist/sheet.d.ts +1 -1
- package/package.json +1 -1
- package/src/blocks/data-table.tsx +865 -679
- package/src/components/callout.tsx +182 -0
- package/src/components/carousel.tsx +121 -3
- package/src/components/input-group.tsx +1 -1
- package/src/index.ts +1 -0
package/AI_USAGE.md
CHANGED
|
@@ -63,7 +63,7 @@ import { Input } from "@brightlocal/ui-components/input";
|
|
|
63
63
|
import { Dialog, DialogContent, DialogTrigger, DialogTitle } from "@brightlocal/ui-components/dialog";
|
|
64
64
|
import { Card, CardHeader, CardContent } from "@brightlocal/ui-components/card";
|
|
65
65
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
66
|
-
import { DataTable } from "@brightlocal/ui-components/blocks/data-table";
|
|
66
|
+
import { DataTable, useDataTable } from "@brightlocal/ui-components/blocks/data-table";
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
### Wrong — Barrel imports
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ pnpm add @brightlocal/tokens
|
|
|
24
24
|
|
|
25
25
|
## Components
|
|
26
26
|
|
|
27
|
-
This package includes
|
|
27
|
+
This package includes 63 components and 3 blocks built on Radix UI primitives and other React libraries. All components are fully typed with TypeScript and follow BrightLocal's design system patterns.
|
|
28
28
|
|
|
29
29
|
### Layout Components
|
|
30
30
|
|
|
@@ -91,7 +91,7 @@ This package includes 62 components and 3 blocks built on Radix UI primitives an
|
|
|
91
91
|
|
|
92
92
|
### Block Components
|
|
93
93
|
|
|
94
|
-
- **DataTable** - Complex data table with sorting, filtering, and pagination
|
|
94
|
+
- **DataTable** - Complex data table with sorting, filtering, and pagination (composable `useDataTable` hook + `DataTable` renderer + helpers)
|
|
95
95
|
- **InputList** - Editable list of text items with add/remove, paste support, and validation
|
|
96
96
|
- **Sidebar** - Complex sidebar navigation with collapsible support
|
|
97
97
|
|
|
@@ -341,7 +341,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
341
341
|
| Path pattern | Example |
|
|
342
342
|
|---|---|
|
|
343
343
|
| `@brightlocal/ui-components/{component}` | `/button`, `/input`, `/dialog`, `/select` |
|
|
344
|
-
| `@brightlocal/ui-components/blocks/{block}` | `/blocks/data-table`, `/blocks/sidebar` |
|
|
344
|
+
| `@brightlocal/ui-components/blocks/{block}` | `/blocks/data-table`, `/blocks/sidebar`, `/blocks/input-list` |
|
|
345
345
|
| `@brightlocal/ui-components/hooks/{hook}` | `/hooks/use-mobile` |
|
|
346
346
|
| `@brightlocal/ui-components/lib/{util}` | `/lib/utils` |
|
|
347
347
|
|
package/component-meta.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Machine-readable registry of all components in the BrightLocal Design System",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
@@ -210,6 +210,35 @@
|
|
|
210
210
|
],
|
|
211
211
|
"description": "Date selection calendar (wraps react-day-picker)"
|
|
212
212
|
},
|
|
213
|
+
{
|
|
214
|
+
"name": "Callout",
|
|
215
|
+
"import": "@brightlocal/ui-components/callout",
|
|
216
|
+
"category": "display",
|
|
217
|
+
"exports": [
|
|
218
|
+
"Callout",
|
|
219
|
+
"CalloutHeading",
|
|
220
|
+
"CalloutCitation"
|
|
221
|
+
],
|
|
222
|
+
"compound": true,
|
|
223
|
+
"dataHookRequired": true,
|
|
224
|
+
"variants": {
|
|
225
|
+
"variant": [
|
|
226
|
+
"primary",
|
|
227
|
+
"purple",
|
|
228
|
+
"blue",
|
|
229
|
+
"green"
|
|
230
|
+
],
|
|
231
|
+
"pointer": [
|
|
232
|
+
"top",
|
|
233
|
+
"bottom",
|
|
234
|
+
"left",
|
|
235
|
+
"right",
|
|
236
|
+
"none"
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
"props": [],
|
|
240
|
+
"description": "Speech bubble callout for highlighting key statements or quotes"
|
|
241
|
+
},
|
|
213
242
|
{
|
|
214
243
|
"name": "Card",
|
|
215
244
|
"import": "@brightlocal/ui-components/card",
|
|
@@ -247,7 +276,8 @@
|
|
|
247
276
|
"CarouselContent",
|
|
248
277
|
"CarouselItem",
|
|
249
278
|
"CarouselPrevious",
|
|
250
|
-
"CarouselNext"
|
|
279
|
+
"CarouselNext",
|
|
280
|
+
"CarouselDots"
|
|
251
281
|
],
|
|
252
282
|
"compound": true,
|
|
253
283
|
"dataHookRequired": true,
|
|
@@ -1407,20 +1437,34 @@
|
|
|
1407
1437
|
"import": "@brightlocal/ui-components/blocks/data-table",
|
|
1408
1438
|
"category": "block",
|
|
1409
1439
|
"exports": [
|
|
1410
|
-
"DataTable"
|
|
1440
|
+
"DataTable",
|
|
1441
|
+
"VirtualizedDataTable",
|
|
1442
|
+
"useDataTable",
|
|
1443
|
+
"DataTableColumnHeader",
|
|
1444
|
+
"DataTableRowActions",
|
|
1445
|
+
"DataTableToolbar",
|
|
1446
|
+
"DataTableToolbarLeft",
|
|
1447
|
+
"DataTableToolbarRight",
|
|
1448
|
+
"DataTableSearch",
|
|
1449
|
+
"DataTablePagination",
|
|
1450
|
+
"DataTableSelectAllCheckbox",
|
|
1451
|
+
"DataTableSelectRowCheckbox"
|
|
1411
1452
|
],
|
|
1412
|
-
"compound":
|
|
1453
|
+
"compound": true,
|
|
1413
1454
|
"dataHookRequired": true,
|
|
1414
1455
|
"variants": {},
|
|
1415
1456
|
"props": [
|
|
1416
1457
|
"columns",
|
|
1417
1458
|
"data",
|
|
1418
|
-
"
|
|
1419
|
-
"
|
|
1420
|
-
"
|
|
1421
|
-
"
|
|
1422
|
-
|
|
1423
|
-
|
|
1459
|
+
"enableSorting",
|
|
1460
|
+
"enableGlobalFiltering",
|
|
1461
|
+
"enableRowSelection",
|
|
1462
|
+
"enablePagination",
|
|
1463
|
+
"pageSize",
|
|
1464
|
+
"isLoading",
|
|
1465
|
+
"noResultsMessage"
|
|
1466
|
+
],
|
|
1467
|
+
"description": "Composable data table built on TanStack Table. Exposes `useDataTable` hook + `DataTable` / `VirtualizedDataTable` renderers + toolbar, pagination, and search helpers."
|
|
1424
1468
|
},
|
|
1425
1469
|
{
|
|
1426
1470
|
"name": "InputList",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Xe=require("react"),c=require("@tanstack/react-table"),S=require("@brightlocal/icons"),j=require("@brightlocal/ui-components/lib/utils"),X=require("../button.cjs"),Y=require("../checkbox.cjs"),_=require("../input-group.cjs"),Ye=require("../skeleton.cjs"),B=require("../dropdown-menu.cjs"),u=require("../table.cjs"),b=require("../pagination.cjs");function Ze(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(l,o,s.get?s:{enumerable:!0,get:()=>n[o]})}}return l.default=n,Object.freeze(l)}const r=Ze(Xe);function et({columns:n,data:l,dataHook:o,trackingEl:s,trackingLabel:i,enableRowSelection:f=!1,enableSorting:d=!0,enableFiltering:g=!1,enableGlobalFiltering:p=!1,enablePagination:w=!1,enableColumnPinning:C=!1,enableRowPinning:x=!1,enableColumnOrdering:T=!1,enableGrouping:h=!1,enableExpanding:k=!1,enableFaceting:re=!1,pageSize:U=10,noResultsMessage:ce="No results.",isLoading:de=!1,skeletonRowCount:ue,getSubRows:ge,sorting:be,onSortingChange:y,columnFilters:fe,onColumnFiltersChange:P,globalFilter:xe,onGlobalFilterChange:D,rowSelection:me,onRowSelectionChange:M,columnOrder:he,onColumnOrderChange:I,columnPinning:pe,onColumnPinningChange:N,rowPinning:we,onRowPinningChange:F,grouping:je,onGroupingChange:v,expanded:Ce,onExpandedChange:V,className:Se,renderToolbar:W,renderFooter:J,renderPagination:K},Re){const[Te,ke]=r.useState([]),[ye,Pe]=r.useState([]),[De,Me]=r.useState(""),[Ie,Ne]=r.useState({}),[Fe,ve]=r.useState([]),[Ve,$e]=r.useState({}),[qe,Ae]=r.useState({}),[Oe,Ge]=r.useState([]),[He,ze]=r.useState({}),$=be??Te,q=fe??ye,A=xe??De,O=me??Ie,G=he??Fe,H=pe??Ve,z=we??qe,E=je??Oe,L=Ce??He,Ee=r.useCallback(t=>{const a=typeof t=="function"?t($):t;y?y(a):ke(a)},[$,y]),Le=r.useCallback(t=>{const a=typeof t=="function"?t(q):t;P?P(a):Pe(a)},[q,P]),_e=r.useCallback(t=>{const a=typeof t=="function"?t(A):t;D?D(a):Me(a)},[A,D]),Be=r.useCallback(t=>{const a=typeof t=="function"?t(O):t;M?M(a):Ne(a)},[O,M]),Ue=r.useCallback(t=>{const a=typeof t=="function"?t(G):t;I?I(a):ve(a)},[G,I]),We=r.useCallback(t=>{const a=typeof t=="function"?t(H):t;N?N(a):$e(a)},[H,N]),Je=r.useCallback(t=>{const a=typeof t=="function"?t(z):t;F?F(a):Ae(a)},[z,F]),Ke=r.useCallback(t=>{const a=typeof t=="function"?t(E):t;v?v(a):Ge(a)},[E,v]),Q=r.useCallback(t=>{const a=typeof t=="function"?t(L):t;V?V(a):ze(a)},[L,V]),m=c.useReactTable({data:l,columns:n,getCoreRowModel:c.getCoreRowModel(),...w&&{getPaginationRowModel:c.getPaginationRowModel(),initialState:{pagination:{pageSize:U}}},...d&&{getSortedRowModel:c.getSortedRowModel(),onSortingChange:Ee},...g&&{getFilteredRowModel:c.getFilteredRowModel(),onColumnFiltersChange:Le},...p&&{getFilteredRowModel:c.getFilteredRowModel(),onGlobalFilterChange:_e,globalFilterFn:"includesString"},...f&&{enableRowSelection:!0,onRowSelectionChange:Be},...T&&{onColumnOrderChange:Ue},...C&&{onColumnPinningChange:We},...x&&{enableRowPinning:!0,onRowPinningChange:Je,keepPinnedRows:!0},...h&&{getGroupedRowModel:c.getGroupedRowModel(),getExpandedRowModel:c.getExpandedRowModel(),onGroupingChange:Ke,onExpandedChange:Q},...k&&{getExpandedRowModel:c.getExpandedRowModel(),onExpandedChange:Q,getSubRows:ge},...re&&{getFacetedRowModel:c.getFacetedRowModel(),getFacetedUniqueValues:c.getFacetedUniqueValues(),getFacetedMinMaxValues:c.getFacetedMinMaxValues()},state:{sorting:$,columnFilters:q,globalFilter:A,rowSelection:O,columnOrder:G,columnPinning:H,rowPinning:z,grouping:E,expanded:L}});return e.jsxs("div",{ref:Re,className:Se,"data-hook":o,"data-slot":"data-table","data-tracking-el":s,"data-tracking-label":i,children:[W&&W(m),e.jsxs(u.Table,{dataHook:`${o}-table`,children:[e.jsx(u.TableHeader,{children:m.getHeaderGroups().map(t=>e.jsx(u.TableRow,{children:t.headers.map(a=>e.jsx(u.TableHead,{colSpan:a.colSpan,children:a.isPlaceholder?null:c.flexRender(a.column.columnDef.header,a.getContext())},a.id))},t.id))}),e.jsx(u.TableBody,{children:de?Array.from({length:ue??U}).map((t,a)=>e.jsx(u.TableRow,{children:m.getVisibleLeafColumns().map((tt,Qe)=>e.jsx(u.TableCell,{children:e.jsx(Ye.Skeleton,{className:"h-4 w-full"})},`skeleton-${a}-${Qe}`))},`skeleton-${a}`)):e.jsxs(e.Fragment,{children:[x&&m.getTopRows().map(t=>e.jsx(u.TableRow,{"data-state":t.getIsSelected()&&"selected",children:t.getVisibleCells().map(a=>e.jsx(u.TableCell,{children:c.flexRender(a.column.columnDef.cell,a.getContext())},a.id))},t.id)),m.getRowModel().rows?.length?m.getRowModel().rows.map(t=>e.jsx(u.TableRow,{"data-state":t.getIsSelected()&&"selected",children:t.getVisibleCells().map(a=>e.jsx(u.TableCell,{children:c.flexRender(a.column.columnDef.cell,a.getContext())},a.id))},t.id)):e.jsx(u.TableRow,{children:e.jsx(u.TableCell,{colSpan:m.getVisibleLeafColumns().length,children:ce})}),x&&m.getBottomRows().map(t=>e.jsx(u.TableRow,{"data-state":t.getIsSelected()&&"selected",children:t.getVisibleCells().map(a=>e.jsx(u.TableCell,{children:c.flexRender(a.column.columnDef.cell,a.getContext())},a.id))},t.id))]})}),J&&J(m)]}),K&&K(m)]})}const Z=r.forwardRef(et);Z.displayName="DataTable";function ee({column:n,title:l,className:o,dataHook:s,trackingEl:i,trackingLabel:f,align:d="left"}){if(!n.getCanSort())return e.jsx("div",{className:j.cn("text-muted-foreground text-left text-sm leading-normal font-medium",d==="right"&&"text-right",d==="center"&&"text-center",o),"data-hook":s,"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":f,children:l});const g=n.getIsSorted(),p=g==="desc"?`Sort by ${l}, currently descending`:g==="asc"?`Sort by ${l}, currently ascending`:`Sort by ${l}`;return e.jsx("div",{className:j.cn("flex items-center",d==="right"&&"justify-end",d==="center"&&"justify-center",o),"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":f,children:e.jsxs(X.Button,{"aria-label":p,className:j.cn("text-muted-foreground h-auto p-0 text-sm font-medium"),dataHook:s||`column-header-${n.id}`,size:"sm",variant:"ghost",onClick:()=>n.toggleSorting(g==="asc"),children:[e.jsx("span",{"aria-hidden":"true",children:l}),e.jsx("span",{"aria-hidden":"true",className:"flex size-3 items-center justify-center",children:g==="desc"?e.jsx(S.ArrowDown,{size:12}):g==="asc"?e.jsx(S.ArrowUp,{size:12}):e.jsx(S.ArrowUpDown,{size:12})})]})})}ee.displayName="DataTableColumnHeader";function te({row:n,dataHook:l,trackingEl:o,trackingLabel:s,ariaLabel:i="Open row actions menu",children:f}){return e.jsxs(B.DropdownMenu,{children:[e.jsx(B.DropdownMenuTrigger,{asChild:!0,"data-slot":"data-table-row-actions",children:e.jsx(X.Button,{"aria-label":i,dataHook:l||`row-actions-${n.id}`,size:"sm",trackingEl:o,trackingLabel:s,variant:"ghost",children:e.jsx(S.Ellipsis,{})})}),e.jsx(B.DropdownMenuContent,{align:"end",dataHook:`${l}-menu`,children:f})]})}te.displayName="DataTableRowActions";function R({dataHook:n,trackingEl:l,trackingLabel:o,className:s,children:i}){return e.jsx("div",{className:j.cn("flex flex-wrap items-center justify-between gap-2 py-4",s),"data-hook":n,"data-slot":"data-table-toolbar","data-tracking-el":l,"data-tracking-label":o,children:i})}function ae({dataHook:n,trackingEl:l,trackingLabel:o,className:s,children:i}){return e.jsx("div",{className:j.cn("flex items-center gap-2",s),"data-hook":n,"data-slot":"data-table-toolbar-left","data-tracking-el":l,"data-tracking-label":o,children:i})}ae.displayName="DataTableToolbar.Left";function ne({dataHook:n,trackingEl:l,trackingLabel:o,className:s,children:i}){return e.jsx("div",{className:j.cn("flex items-center gap-2",s),"data-hook":n,"data-slot":"data-table-toolbar-right","data-tracking-el":l,"data-tracking-label":o,children:i})}ne.displayName="DataTableToolbar.Right";R.Left=ae;R.Right=ne;R.displayName="DataTableToolbar";function le({table:n,dataHook:l,trackingEl:o,trackingLabel:s,ariaLabel:i="Search table",placeholder:f="Search...",column:d,width:g,className:p}){const w=d?n.getColumn(d)?.getFilterValue()??"":n.getState().globalFilter??"",C=x=>{d?n.getColumn(d)?.setFilterValue(x):n.setGlobalFilter(x)};return e.jsx("div",{className:j.cn(!g&&"w-full max-w-sm",p),"data-slot":"data-table-search",style:g?{width:g,minWidth:g}:void 0,children:e.jsxs(_.InputGroup,{className:"rounded-full",dataHook:l,children:[e.jsx(_.InputGroupInput,{"aria-label":i,placeholder:f,trackingEl:o,trackingLabel:s,type:"text",value:w,onChange:x=>C(x.target.value)}),e.jsx(_.InputGroupAddon,{className:"pr-3",children:e.jsx(S.Search,{})})]})})}le.displayName="DataTableSearch";function oe({table:n,dataHook:l,trackingEl:o,trackingLabel:s,className:i,ariaLabel:f="Table pagination"}){const d=n.getState().pagination.pageIndex+1,g=n.getPageCount(),p=n.getState().pagination.pageSize,w=n.getFilteredRowModel().rows.length,C=w===0?0:(d-1)*p+1,x=Math.min(d*p,w),T=b.usePagination({page:d,totalPages:g,siblingCount:1,boundaryCount:1});return e.jsxs("div",{className:j.cn("flex items-center justify-end gap-4",i),"data-hook":l,"data-slot":"data-table-pagination","data-tracking-el":o,"data-tracking-label":s,children:[e.jsx("span",{className:"text-muted-foreground text-sm",children:w===0?"0 of 0":`${C}-${x} of ${w}`}),e.jsx(b.Pagination,{ariaLabel:f,className:"mx-0 w-auto justify-end",dataHook:`${l}-nav`,children:e.jsx(b.PaginationContent,{children:T.map((h,k)=>h==="previous"?e.jsx(b.PaginationItem,{children:e.jsx(b.PaginationPrevious,{disabled:!n.getCanPreviousPage(),onClick:()=>n.previousPage()})},"previous"):h==="next"?e.jsx(b.PaginationItem,{children:e.jsx(b.PaginationNext,{disabled:!n.getCanNextPage(),onClick:()=>n.nextPage()})},"next"):h==="ellipsis"?e.jsx(b.PaginationItem,{children:e.jsx(b.PaginationEllipsis,{})},`ellipsis-${k}`):e.jsx(b.PaginationItem,{children:e.jsx(b.PaginationLink,{isActive:h===d,page:h,onClick:()=>n.setPageIndex(h-1)})},h))})})]})}oe.displayName="DataTablePagination";function se({table:n,dataHook:l,trackingEl:o,trackingLabel:s}){return e.jsx(Y.Checkbox,{"aria-label":"Select all",checked:n.getIsAllPageRowsSelected()||n.getIsSomePageRowsSelected()&&"indeterminate",dataHook:l||"select-all-checkbox",trackingEl:o,trackingLabel:s,onCheckedChange:i=>n.toggleAllPageRowsSelected(!!i)})}se.displayName="DataTableSelectAllCheckbox";function ie({row:n,dataHook:l,trackingEl:o,trackingLabel:s}){return e.jsx(Y.Checkbox,{"aria-label":"Select row",checked:n.getIsSelected(),dataHook:l||`select-row-${n.id}`,disabled:!n.getCanSelect(),trackingEl:o,trackingLabel:s,onCheckedChange:i=>n.toggleSelected(!!i)})}ie.displayName="DataTableSelectRowCheckbox";Object.defineProperty(exports,"createColumnHelper",{enumerable:!0,get:()=>c.createColumnHelper});Object.defineProperty(exports,"flexRender",{enumerable:!0,get:()=>c.flexRender});exports.DataTable=Z;exports.DataTableColumnHeader=ee;exports.DataTablePagination=oe;exports.DataTableRowActions=te;exports.DataTableSearch=le;exports.DataTableSelectAllCheckbox=se;exports.DataTableSelectRowCheckbox=ie;exports.DataTableToolbar=R;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),re=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"),i=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(re);function D(a,t,n){const[l,o]=v.useState(t),s=a!==void 0?a:l,r=v.useRef(s);v.useEffect(()=>{r.current=s});const d=a!==void 0,u=v.useCallback(p=>{const g=typeof p=="function"?p(r.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:r=!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,ie]=D(I,{},F);return f.useReactTable({data:n,columns:t,getCoreRowModel:f.getCoreRowModel(),...j&&{getRowId:j},...(r||g)&&{onPaginationChange:Y},...r&&{...!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:ie,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:r="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(u),"data-hook":t,"data-slot":"data-table-view","data-tracking-el":n,"data-tracking-label":l,children:e.jsxs(i.Table,{dataHook:`${t}-table`,children:[e.jsx(i.TableHeader,{className:S.cn(d&&"bg-background sticky top-0 z-10"),children:a.getHeaderGroups().map(b=>e.jsx(i.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(i.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(i.TableBody,{children:o?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:g,rowCount:C}),e.jsx(i.TableRow,{className:"sr-only",children:e.jsx(i.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(i.TableRow,{children:e.jsx(i.TableCell,{colSpan:g,children:e.jsx("div",{"aria-live":"polite",role:"status",children:r})})})})}),p]})})}V.displayName="DataTable";function $({row:a}){return e.jsx(i.TableRow,{"data-state":a.getIsSelected()?"selected":void 0,children:a.getVisibleCells().map(t=>e.jsx(i.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(i.TableRow,{children:Array.from({length:t}).map((o,s)=>e.jsx(i.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:r="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("overflow-auto",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(i.Table,{dataHook:`${t}-table`,children:[e.jsx(i.TableHeader,{className:S.cn(d&&"bg-background sticky top-0 z-10"),children:a.getHeaderGroups().map(k=>e.jsx(i.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(i.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(i.TableBody,{children:o?e.jsxs(e.Fragment,{children:[e.jsx(E,{colCount:c,rowCount:T}),e.jsx(i.TableRow,{className:"sr-only",children:e.jsx(i.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(i.TableRow,{children:e.jsx(i.TableCell,{colSpan:c,children:e.jsx("div",{"aria-live":"polite",role:"status",children:r})})})}),p]})})}G.displayName="VirtualizedDataTable";function O({column:a,title:t,className:n,dataHook:l,trackingEl:o,trackingLabel:s,align:r="left"}){if(!a.getCanSort())return e.jsx("div",{className:S.cn("text-muted-foreground text-left text-sm leading-normal font-medium",r==="right"&&"text-right",r==="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",r==="right"&&"justify-end",r==="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=r=>{a.setGlobalFilter(r)};return e.jsxs(A.InputGroup,{...l,children:[e.jsx(A.InputGroupInput,{"aria-label":t,placeholder:n,type:"text",value:o,onChange:r=>s(r.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:r,pageSize:d}=a.getState().pagination,u=a.getRowCount(),p=a.getPageCount(),g=a.getCanPreviousPage(),C=a.getCanNextPage(),b=r+1,c=u===0?0:r*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;
|