@sth87/shadcn-design-system 0.2.5 → 0.2.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("@tanstack/react-table"),y=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("@tanstack/react-table"),y=require("react"),M=require("./data-table-pagination.cjs"),d=require("../../packages/ui/src/lib/utils.cjs"),n=require("../../packages/ui/src/components/table.cjs"),v=require("../../utils/data-table.cjs"),N=require("./data-table-column-header.cjs");function z({table:s,actionBar:m,children:C,className:S,pagination:i=!0,sticky:c=!0,stickyFooter:R=!1,bordered:k=!0,loading:g,loadingIndicator:P,footer:f,emptyState:H,onRowClick:u,rowClassName:b,renderRow:x,renderCell:h,classNames:o,showTotalCount:q=!0,totalCount:D,...I}){const a=c?{offsetHeader:typeof c=="object"?c.offsetHeader??0:0,offsetScroll:typeof c=="object"?c.offsetScroll:void 0}:null,j=s.getVisibleLeafColumns().length;return e.jsxs("div",{className:d.cn("ds:flex ds:w-full ds:flex-col ds:gap-2.5 ds:relative",S),...I,children:[C,g&&e.jsx("div",{className:d.cn("ds:absolute ds:inset-0 ds:bg-background/50 ds:flex ds:items-center ds:justify-center ds:z-20",o?.loadingOverlay),children:P??"Loading..."}),e.jsxs(n.Table,{className:o?.table,containerClassName:d.cn(k&&"ds:rounded-md ds:border ds:border-border","ds:[scrollbar-width:thin] ds:[scrollbar-color:var(--border)_transparent]","ds:[&::-webkit-scrollbar]:h-1.5 ds:[&::-webkit-scrollbar]:w-1.5","ds:[&::-webkit-scrollbar-track]:bg-transparent","ds:[&::-webkit-scrollbar-thumb]:rounded-full ds:[&::-webkit-scrollbar-thumb]:bg-border","ds:[&::-webkit-scrollbar-thumb:hover]:bg-muted-foreground",g&&"ds:blur-sm",o?.container),containerStyle:a?{maxHeight:`calc(100vh - ${a.offsetScroll??0}px)`}:void 0,children:[e.jsx(n.TableHeader,{children:s.getHeaderGroups().map(t=>e.jsx(n.TableRow,{className:o?.headerRow,children:t.headers.map(l=>e.jsx(n.TableHead,{colSpan:l.colSpan,className:d.cn(o?.headerCell,l.column.getIsPinned()&&"ds:bg-background"),style:{...v.getCommonPinningStyles({column:l.column,withBorder:!0}),...a&&{position:"sticky",top:a.offsetHeader,zIndex:l.column.getIsPinned()?3:2,background:"var(--background)"}},children:l.isPlaceholder?null:l.column.columnDef.header?typeof l.column.columnDef.header=="function"?T.flexRender(l.column.columnDef.header,l.getContext()):e.jsx(N.DataTableColumnHeader,{column:l.column}):null},l.id))},t.id))}),e.jsx(n.TableBody,{className:o?.body,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(t=>{const l=typeof b=="function"?b(t):b,p=e.jsx(n.TableRow,{"data-state":t.getIsSelected()&&"selected",className:d.cn(o?.row,l,u&&"ds:cursor-pointer"),onClick:u?r=>u(t,r):void 0,children:t.getVisibleCells().map(r=>{const w=e.jsx(n.TableCell,{className:d.cn(o?.cell,r.column.getIsPinned()&&"ds:bg-background"),style:{...v.getCommonPinningStyles({column:r.column,withBorder:!0})},children:T.flexRender(r.column.columnDef.cell,r.getContext())},r.id);return h?e.jsx(y.Fragment,{children:h(r,w)},r.id):w})},t.id);return x?e.jsx(y.Fragment,{children:x(t,p)},t.id):p}):e.jsx(n.TableRow,{className:o?.emptyRow,children:e.jsx(n.TableCell,{colSpan:j,className:d.cn("ds:h-24 ds:text-center",o?.emptyCell),children:H??"No results."})})}),f&&e.jsx(n.TableFooter,{children:e.jsx(n.TableRow,{className:o?.footerRow,children:e.jsx(n.TableCell,{colSpan:j,className:o?.footerCell,style:R?{position:"sticky",bottom:0,zIndex:2}:void 0,children:f(s.getRowModel().rows.map(t=>t.original))})})})]}),e.jsxs("div",{className:"ds:flex ds:flex-col ds:gap-2.5",children:[i&&e.jsx(M.DataTablePagination,{showTotalCount:q,totalCount:D,showPageSizeOptions:!0,showRowSelectionCount:!0,table:s,...i===!0?{}:i}),m&&s.getFilteredSelectedRowModel().rows.length>0&&m]})]})}exports.DataTable=z;
|