@stackshift-ui/data-table 1.0.0-beta.8 → 1.0.0-beta.9
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/chunk-2YVCA56U.mjs +1 -0
- package/dist/chunk-3EYN2AKU.mjs +1 -0
- package/dist/chunk-4II4GOHT.mjs +1 -0
- package/dist/chunk-URJGIMUX.mjs +1 -0
- package/dist/chunk-VTWRQFOH.mjs +1 -0
- package/dist/data-table-column-header.d.ts +10 -0
- package/dist/data-table-column-header.js +1 -0
- package/dist/data-table-column-header.mjs +1 -0
- package/dist/data-table-pagination.d.ts +9 -0
- package/dist/data-table-pagination.js +1 -0
- package/dist/data-table-pagination.mjs +1 -0
- package/dist/data-table-view-options.d.ts +7 -0
- package/dist/data-table-view-options.js +2 -0
- package/dist/data-table-view-options.mjs +2 -0
- package/dist/data-table.d.ts +13 -0
- package/dist/data-table.js +2 -0
- package/dist/data-table.mjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.js +47 -0
- package/dist/setupTests.mjs +47 -0
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DefaultComponent as r,useStackShiftUIComponents as c}from"@stackshift-ui/system";import{ChevronLeft as g,ChevronRight as m,ChevronsLeft as p,ChevronsRight as d}from"lucide-react";import{Button as s}from"@stackshift-ui/button";import{Select as u,SelectContent as f,SelectItem as x,SelectTrigger as v,SelectValue as C}from"@stackshift-ui/select";import{jsx as t,jsxs as a}from"react/jsx-runtime";var o="DataTablePagination";function N({table:e,...i}){let{[o]:l=r}=c();return a(l,{className:"flex items-center justify-between px-2",...i,children:[a("div",{className:"text-muted-foreground flex-1 text-sm",children:[e.getFilteredSelectedRowModel().rows.length," of"," ",e.getFilteredRowModel().rows.length," row(s) selected."]}),a("div",{className:"flex items-center space-x-6 lg:space-x-8",children:[a("div",{className:"flex items-center space-x-2",children:[t("p",{className:"text-sm font-medium",children:"Rows per page"}),a(u,{value:`${e.getState().pagination.pageSize}`,onValueChange:n=>{e.setPageSize(Number(n))},children:[t(v,{className:"h-8 w-[70px]",children:t(C,{placeholder:e.getState().pagination.pageSize})}),t(f,{side:"top",children:[10,20,25,30,40,50].map(n=>t(x,{value:`${n}`,children:n},n))})]})]}),a("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",e.getState().pagination.pageIndex+1," of ",e.getPageCount()]}),a("div",{className:"flex items-center space-x-2",children:[a(s,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[t("span",{className:"sr-only",children:"Go to first page"}),t(p,{})]}),a(s,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[t("span",{className:"sr-only",children:"Go to previous page"}),t(g,{})]}),a(s,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[t("span",{className:"sr-only",children:"Go to next page"}),t(m,{})]}),a(s,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[t("span",{className:"sr-only",children:"Go to last page"}),t(d,{})]})]})]})]})}N.displayName=o;export{N as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var l=(a,b,c,e)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&f(a,d,{get:()=>b[d],enumerable:!(e=h(b,d))||e.enumerable});return a};var o=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Button as d}from"@stackshift-ui/button";import{DropdownMenu as D,DropdownMenuContent as g,DropdownMenuItem as n,DropdownMenuSeparator as C,DropdownMenuTrigger as T}from"@stackshift-ui/dropdown-menu";import{cn as i,DefaultComponent as f,useStackShiftUIComponents as w}from"@stackshift-ui/system";import{ArrowDown as l,ArrowUp as m,ChevronsUpDown as c,EyeOff as M}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";var u="DataTableColumnHeader";function S({column:o,title:a,className:r,...s}){let{[u]:p=f}=w();return o.getCanSort()?e(p,{className:i("flex items-center gap-2",r),...s,children:t(D,{children:[e(T,{asChild:!0,children:t(d,{variant:"ghost",size:"sm",className:"data-[state=open]:bg-accent -ml-3 h-8",children:[e("span",{children:a}),o.getIsSorted()==="desc"?e(l,{}):o.getIsSorted()==="asc"?e(m,{}):e(c,{})]})}),t(g,{align:"start",children:[t(n,{onClick:()=>o.toggleSorting(!1),children:[e(m,{}),"Asc"]}),t(n,{onClick:()=>o.toggleSorting(!0),children:[e(l,{}),"Desc"]}),e(C,{}),t(n,{onClick:()=>o.toggleVisibility(!1),children:[e(M,{}),"Hide"]})]})]})}):e(p,{className:i(r),...s,children:a})}S.displayName=u;export{S as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DropdownMenuTrigger as l}from"@stackshift-ui/dropdown-menu";import{Settings2 as s}from"lucide-react";import{Button as d}from"@stackshift-ui/button";import{DropdownMenu as m,DropdownMenuCheckboxItem as u,DropdownMenuContent as D,DropdownMenuLabel as g,DropdownMenuSeparator as w}from"@stackshift-ui/dropdown-menu";import{DefaultComponent as f,useStackShiftUIComponents as C}from"@stackshift-ui/system";import{jsx as o,jsxs as n}from"react/jsx-runtime";var t="DataTableViewOptions";function c({table:a,...i}){let{[t]:r=f}=C();return o(r,{...i,children:n(m,{children:[o(l,{asChild:!0,children:n(d,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[o(s,{}),"View"]})}),n(D,{align:"end",className:"w-[150px]",children:[o(g,{children:"Toggle columns"}),o(w,{}),a.getAllColumns().filter(e=>typeof e.accessorFn!="undefined"&&e.getCanHide()).map(e=>o(u,{className:"capitalize",checked:e.getIsVisible(),onCheckedChange:p=>e.toggleVisibility(!!p),children:e.id},e.id))]})]})})}c.displayName=t;export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"./chunk-2YVCA56U.mjs";import{DefaultComponent as S,useStackShiftUIComponents as x}from"@stackshift-ui/system";import{Table as y,TableBody as M,TableCell as m,TableHead as h,TableHeader as F,TableRow as n}from"@stackshift-ui/table";import{flexRender as d,getCoreRowModel as N,getFilteredRowModel as P,getPaginationRowModel as H,getSortedRowModel as V,useReactTable as k}from"@tanstack/react-table";import{useState as r}from"react";import{jsx as e,jsxs as T}from"react/jsx-runtime";var g="DataTable";function v({columns:i,data:u,...b}){var s;let{[g]:c=S}=x(),[p,f]=r([]),[C,w]=r({}),[D,R]=r([]),a=k({data:u,columns:i,getCoreRowModel:N(),getPaginationRowModel:H(),onSortingChange:f,getSortedRowModel:V(),onRowSelectionChange:w,onColumnFiltersChange:R,getFilteredRowModel:P(),state:{sorting:p,rowSelection:C,columnFilters:D}});return T(c,{className:"relative w-full h-full flex flex-col gap-2",...b,children:[e("div",{className:"rounded-md border",children:T(y,{children:[e(F,{children:a.getHeaderGroups().map(o=>e(n,{children:o.headers.map(t=>e(h,{children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},o.id))}),e(M,{children:(s=a.getRowModel().rows)!=null&&s.length?a.getRowModel().rows.map(o=>e(n,{"data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(t=>e(m,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},o.id)):e(n,{children:e(m,{colSpan:i.length,className:"h-24 text-center",children:"No results."})})})]})}),e("div",{className:"w-full h-fit py-10",children:e(l,{table:a})})]})}v.displayName=g;export{v as a};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Column } from "@tanstack/react-table";
|
|
2
|
+
interface DataTableColumnHeaderProps<TData, TValue> extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
column: Column<TData, TValue>;
|
|
4
|
+
title: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function DataTableColumnHeader<TData, TValue>({ column, title, className, ...props }: DataTableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace DataTableColumnHeader {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var s in t)l(o,s,{get:t[s],enumerable:!0})},f=(o,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of g(t))!C.call(o,r)&&r!==s&&l(o,r,{get:()=>t[r],enumerable:!(i=D(t,r))||i.enumerable});return o};var w=o=>f(l({},"__esModule",{value:!0}),o);var c={};T(c,{DataTableColumnHeader:()=>d});module.exports=w(c);var m=require("@stackshift-ui/button"),n=require("@stackshift-ui/dropdown-menu"),p=require("@stackshift-ui/system"),a=require("lucide-react"),e=require("react/jsx-runtime"),u="DataTableColumnHeader";function d({column:o,title:t,className:s,...i}){let{[u]:r=p.DefaultComponent}=(0,p.useStackShiftUIComponents)();return o.getCanSort()?(0,e.jsx)(r,{className:(0,p.cn)("flex items-center gap-2",s),...i,children:(0,e.jsxs)(n.DropdownMenu,{children:[(0,e.jsx)(n.DropdownMenuTrigger,{asChild:!0,children:(0,e.jsxs)(m.Button,{variant:"ghost",size:"sm",className:"data-[state=open]:bg-accent -ml-3 h-8",children:[(0,e.jsx)("span",{children:t}),o.getIsSorted()==="desc"?(0,e.jsx)(a.ArrowDown,{}):o.getIsSorted()==="asc"?(0,e.jsx)(a.ArrowUp,{}):(0,e.jsx)(a.ChevronsUpDown,{})]})}),(0,e.jsxs)(n.DropdownMenuContent,{align:"start",children:[(0,e.jsxs)(n.DropdownMenuItem,{onClick:()=>o.toggleSorting(!1),children:[(0,e.jsx)(a.ArrowUp,{}),"Asc"]}),(0,e.jsxs)(n.DropdownMenuItem,{onClick:()=>o.toggleSorting(!0),children:[(0,e.jsx)(a.ArrowDown,{}),"Desc"]}),(0,e.jsx)(n.DropdownMenuSeparator,{}),(0,e.jsxs)(n.DropdownMenuItem,{onClick:()=>o.toggleVisibility(!1),children:[(0,e.jsx)(a.EyeOff,{}),"Hide"]})]})]})}):(0,e.jsx)(r,{className:(0,p.cn)(s),...i,children:t})}d.displayName=u;0&&(module.exports={DataTableColumnHeader});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-4II4GOHT.mjs";import"./chunk-3EYN2AKU.mjs";export{a as DataTableColumnHeader};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Table } from "@tanstack/react-table";
|
|
2
|
+
interface DataTablePaginationProps<TData> {
|
|
3
|
+
table: Table<TData>;
|
|
4
|
+
}
|
|
5
|
+
export declare function DataTablePagination<TData>({ table, ...props }: DataTablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare namespace DataTablePagination {
|
|
7
|
+
var displayName: string;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var x=(t,a)=>{for(var i in a)g(t,i,{get:a[i],enumerable:!0})},v=(t,a,i,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of u(a))!f.call(t,l)&&l!==i&&g(t,l,{get:()=>a[l],enumerable:!(s=d(a,l))||s.enumerable});return t};var C=t=>v(g({},"__esModule",{value:!0}),t);var N={};x(N,{DataTablePagination:()=>p});module.exports=C(N);var c=require("@stackshift-ui/system"),o=require("lucide-react"),r=require("@stackshift-ui/button"),n=require("@stackshift-ui/select"),e=require("react/jsx-runtime"),m="DataTablePagination";function p({table:t,...a}){let{[m]:i=c.DefaultComponent}=(0,c.useStackShiftUIComponents)();return(0,e.jsxs)(i,{className:"flex items-center justify-between px-2",...a,children:[(0,e.jsxs)("div",{className:"text-muted-foreground flex-1 text-sm",children:[t.getFilteredSelectedRowModel().rows.length," of"," ",t.getFilteredRowModel().rows.length," row(s) selected."]}),(0,e.jsxs)("div",{className:"flex items-center space-x-6 lg:space-x-8",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Rows per page"}),(0,e.jsxs)(n.Select,{value:`${t.getState().pagination.pageSize}`,onValueChange:s=>{t.setPageSize(Number(s))},children:[(0,e.jsx)(n.SelectTrigger,{className:"h-8 w-[70px]",children:(0,e.jsx)(n.SelectValue,{placeholder:t.getState().pagination.pageSize})}),(0,e.jsx)(n.SelectContent,{side:"top",children:[10,20,25,30,40,50].map(s=>(0,e.jsx)(n.SelectItem,{value:`${s}`,children:s},s))})]})]}),(0,e.jsxs)("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",t.getState().pagination.pageIndex+1," of ",t.getPageCount()]}),(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsxs)(r.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>t.setPageIndex(0),disabled:!t.getCanPreviousPage(),children:[(0,e.jsx)("span",{className:"sr-only",children:"Go to first page"}),(0,e.jsx)(o.ChevronsLeft,{})]}),(0,e.jsxs)(r.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>t.previousPage(),disabled:!t.getCanPreviousPage(),children:[(0,e.jsx)("span",{className:"sr-only",children:"Go to previous page"}),(0,e.jsx)(o.ChevronLeft,{})]}),(0,e.jsxs)(r.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>t.nextPage(),disabled:!t.getCanNextPage(),children:[(0,e.jsx)("span",{className:"sr-only",children:"Go to next page"}),(0,e.jsx)(o.ChevronRight,{})]}),(0,e.jsxs)(r.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>t.setPageIndex(t.getPageCount()-1),disabled:!t.getCanNextPage(),children:[(0,e.jsx)("span",{className:"sr-only",children:"Go to last page"}),(0,e.jsx)(o.ChevronsRight,{})]})]})]})]})}p.displayName=m;0&&(module.exports={DataTablePagination});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-2YVCA56U.mjs";import"./chunk-3EYN2AKU.mjs";export{a as DataTablePagination};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Table } from "@tanstack/react-table";
|
|
2
|
+
export declare function DataTableViewOptions<TData>({ table, ...props }: {
|
|
3
|
+
table: Table<TData>;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare namespace DataTableViewOptions {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var C=(a,e)=>{for(var r in e)l(a,r,{get:e[r],enumerable:!0})},c=(a,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of w(e))!f.call(a,i)&&i!==r&&l(a,i,{get:()=>e[i],enumerable:!(n=g(e,i))||n.enumerable});return a};var b=a=>c(l({},"__esModule",{value:!0}),a);var M={};C(M,{DataTableViewOptions:()=>D});module.exports=b(M);var s=require("@stackshift-ui/dropdown-menu"),d=require("lucide-react"),m=require("@stackshift-ui/button"),p=require("@stackshift-ui/system"),o=require("react/jsx-runtime"),u="DataTableViewOptions";function D({table:a,...e}){let{[u]:r=p.DefaultComponent}=(0,p.useStackShiftUIComponents)();return(0,o.jsx)(r,{...e,children:(0,o.jsxs)(s.DropdownMenu,{children:[(0,o.jsx)(s.DropdownMenuTrigger,{asChild:!0,children:(0,o.jsxs)(m.Button,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[(0,o.jsx)(d.Settings2,{}),"View"]})}),(0,o.jsxs)(s.DropdownMenuContent,{align:"end",className:"w-[150px]",children:[(0,o.jsx)(s.DropdownMenuLabel,{children:"Toggle columns"}),(0,o.jsx)(s.DropdownMenuSeparator,{}),a.getAllColumns().filter(n=>typeof n.accessorFn!="undefined"&&n.getCanHide()).map(n=>(0,o.jsx)(s.DropdownMenuCheckboxItem,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:i=>n.toggleVisibility(!!i),children:n.id},n.id))]})]})})}D.displayName=u;0&&(module.exports={DataTableViewOptions});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
interface DataTableProps<TData, TValue> {
|
|
3
|
+
columns: ColumnDef<TData, TValue>[];
|
|
4
|
+
data: TData[];
|
|
5
|
+
}
|
|
6
|
+
export declare function DataTable<TData, TValue>({ columns, data, ...props }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace DataTable {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export { type ColumnDef } from "@tanstack/react-table";
|
|
11
|
+
export { DataTableColumnHeader } from "./data-table-column-header";
|
|
12
|
+
export { DataTablePagination } from "./data-table-pagination";
|
|
13
|
+
export { DataTableViewOptions } from "./data-table-view-options";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var v=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(e,n)=>{for(var s in n)v(e,s,{get:n[s],enumerable:!0})},W=(e,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of J(n))!K.call(e,m)&&m!==s&&v(e,m,{get:()=>n[m],enumerable:!(o=q(n,m))||o.enumerable});return e};var X=e=>W(v({},"__esModule",{value:!0}),e);var Y={};Q(Y,{DataTable:()=>U,DataTableColumnHeader:()=>P,DataTablePagination:()=>S,DataTableViewOptions:()=>y});module.exports=X(Y);var M=require("@stackshift-ui/system"),i=require("@stackshift-ui/table"),r=require("@tanstack/react-table"),h=require("react");var C=require("lucide-react"),w=require("@stackshift-ui/button"),g=require("@stackshift-ui/select"),t=require("react/jsx-runtime"),k="DataTablePagination";function S({table:e,...n}){let{[k]:s=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return(0,t.jsxs)(s,{className:"flex items-center justify-between px-2",...n,children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex-1 text-sm",children:[e.getFilteredSelectedRowModel().rows.length," of"," ",e.getFilteredRowModel().rows.length," row(s) selected."]}),(0,t.jsxs)("div",{className:"flex items-center space-M-6 lg:space-M-8",children:[(0,t.jsxs)("div",{className:"flex items-center space-M-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Rows per page"}),(0,t.jsxs)(g.Select,{value:`${e.getState().pagination.pageSize}`,onValueChange:o=>{e.setPageSize(Number(o))},children:[(0,t.jsx)(g.SelectTrigger,{className:"h-8 w-[70px]",children:(0,t.jsx)(g.SelectValue,{placeholder:e.getState().pagination.pageSize})}),(0,t.jsx)(g.SelectContent,{side:"top",children:[10,20,25,30,40,50].map(o=>(0,t.jsx)(g.SelectItem,{value:`${o}`,children:o},o))})]})]}),(0,t.jsxs)("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",e.getState().pagination.pageIndex+1," of ",e.getPageCount()]}),(0,t.jsxs)("div",{className:"flex items-center space-M-2",children:[(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to first page"}),(0,t.jsx)(C.ChevronsLeft,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to previous page"}),(0,t.jsx)(C.ChevronLeft,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to next page"}),(0,t.jsx)(C.ChevronRight,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to last page"}),(0,t.jsx)(C.ChevronsRight,{})]})]})]})]})}S.displayName=k;var p=require("@stackshift-ui/dropdown-menu"),V="DataTableColumnHeader";function P({column:e,title:n,className:s,...o}){let{[V]:m=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return e.getCanSort()?(0,t.jsx)(m,{className:(0,M.cn)("flex items-center gap-2",s),...o,children:(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(w.Button,{variant:"ghost",size:"sm",className:"data-[state=open]:bg-accent -ml-3 h-8",children:[(0,t.jsx)("span",{children:n}),e.getIsSorted()==="desc"?(0,t.jsx)(C.ArrowDown,{}):e.getIsSorted()==="asc"?(0,t.jsx)(C.ArrowUp,{}):(0,t.jsx)(C.ChevronsUpDown,{})]})}),(0,t.jsxs)(p.DropdownMenuContent,{align:"start",children:[(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleSorting(!1),children:[(0,t.jsx)(C.ArrowUp,{}),"Asc"]}),(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleSorting(!0),children:[(0,t.jsx)(C.ArrowDown,{}),"Desc"]}),(0,t.jsx)(p.DropdownMenuSeparator,{}),(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleVisibility(!1),children:[(0,t.jsx)(C.EyeOff,{}),"Hide"]})]})]})}):(0,t.jsx)(m,{className:(0,M.cn)(s),...o,children:n})}P.displayName=V;var F="DataTableViewOptions";function y({table:e,...n}){let{[F]:s=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return(0,t.jsx)(s,{...n,children:(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(w.Button,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[(0,t.jsx)(C.Settings2,{}),"View"]})}),(0,t.jsxs)(p.DropdownMenuContent,{align:"end",className:"w-[150px]",children:[(0,t.jsx)(p.DropdownMenuLabel,{children:"Toggle columns"}),(0,t.jsx)(p.DropdownMenuSeparator,{}),e.getAllColumns().filter(o=>typeof o.accessorFn!="undefined"&&o.getCanHide()).map(o=>(0,t.jsx)(p.DropdownMenuCheckboxItem,{className:"capitalize",checked:o.getIsVisible(),onCheckedChange:m=>o.toggleVisibility(!!m),children:o.id},o.id))]})]})})}y.displayName=F;var L="DataTable";function U({columns:e,data:n,...s}){var R;let{[L]:o=M.DefaultComponent}=(0,M.useStackShiftUIComponents)(),[m,A]=(0,h.useState)([]),[G,O]=(0,h.useState)({}),[E,$]=(0,h.useState)([]),b=(0,r.useReactTable)({data:n,columns:e,getCoreRowModel:(0,r.getCoreRowModel)(),getPaginationRowModel:(0,r.getPaginationRowModel)(),onSortingChange:A,getSortedRowModel:(0,r.getSortedRowModel)(),onRowSelectionChange:O,onColumnFiltersChange:$,getFilteredRowModel:(0,r.getFilteredRowModel)(),state:{sorting:m,rowSelection:G,columnFilters:E}});return(0,t.jsxs)(o,{className:"relative w-full h-full flex flex-col gap-2",...s,children:[(0,t.jsx)("div",{className:"rounded-md border",children:(0,t.jsxs)(i.Table,{children:[(0,t.jsx)(i.TableHeader,{children:b.getHeaderGroups().map(D=>(0,t.jsx)(i.TableRow,{children:D.headers.map(f=>(0,t.jsx)(i.TableHead,{children:f.isPlaceholder?null:(0,r.flexRender)(f.column.columnDef.header,f.getContext())},f.id))},D.id))}),(0,t.jsx)(i.TableBody,{children:(R=b.getRowModel().rows)!=null&&R.length?b.getRowModel().rows.map(D=>(0,t.jsx)(i.TableRow,{"data-state":D.getIsSelected()&&"selected",children:D.getVisibleCells().map(f=>(0,t.jsx)(i.TableCell,{children:(0,r.flexRender)(f.column.columnDef.cell,f.getContext())},f.id))},D.id)):(0,t.jsx)(i.TableRow,{children:(0,t.jsx)(i.TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]})}),(0,t.jsx)("div",{className:"w-full h-fit py-10",children:(0,t.jsx)(S,{table:b})})]})}U.displayName=L;0&&(module.exports={DataTable,DataTableColumnHeader,DataTablePagination,DataTableViewOptions});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";import{a as d}from"./chunk-VTWRQFOH.mjs";import{a}from"./chunk-4II4GOHT.mjs";import{a as b}from"./chunk-2YVCA56U.mjs";import{a as c}from"./chunk-URJGIMUX.mjs";import"./chunk-3EYN2AKU.mjs";export{d as DataTable,a as DataTableColumnHeader,b as DataTablePagination,c as DataTableViewOptions};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./data-table";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var v=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(e,n)=>{for(var s in n)v(e,s,{get:n[s],enumerable:!0})},W=(e,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of J(n))!K.call(e,m)&&m!==s&&v(e,m,{get:()=>n[m],enumerable:!(o=q(n,m))||o.enumerable});return e};var X=e=>W(v({},"__esModule",{value:!0}),e);var Y={};Q(Y,{DataTable:()=>U,DataTableColumnHeader:()=>P,DataTablePagination:()=>S,DataTableViewOptions:()=>y});module.exports=X(Y);var M=require("@stackshift-ui/system"),i=require("@stackshift-ui/table"),r=require("@tanstack/react-table"),h=require("react");var C=require("lucide-react"),w=require("@stackshift-ui/button"),g=require("@stackshift-ui/select"),t=require("react/jsx-runtime"),k="DataTablePagination";function S({table:e,...n}){let{[k]:s=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return(0,t.jsxs)(s,{className:"flex items-center justify-between px-2",...n,children:[(0,t.jsxs)("div",{className:"text-muted-foreground flex-1 text-sm",children:[e.getFilteredSelectedRowModel().rows.length," of"," ",e.getFilteredRowModel().rows.length," row(s) selected."]}),(0,t.jsxs)("div",{className:"flex items-center space-M-6 lg:space-M-8",children:[(0,t.jsxs)("div",{className:"flex items-center space-M-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Rows per page"}),(0,t.jsxs)(g.Select,{value:`${e.getState().pagination.pageSize}`,onValueChange:o=>{e.setPageSize(Number(o))},children:[(0,t.jsx)(g.SelectTrigger,{className:"h-8 w-[70px]",children:(0,t.jsx)(g.SelectValue,{placeholder:e.getState().pagination.pageSize})}),(0,t.jsx)(g.SelectContent,{side:"top",children:[10,20,25,30,40,50].map(o=>(0,t.jsx)(g.SelectItem,{value:`${o}`,children:o},o))})]})]}),(0,t.jsxs)("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",e.getState().pagination.pageIndex+1," of ",e.getPageCount()]}),(0,t.jsxs)("div",{className:"flex items-center space-M-2",children:[(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to first page"}),(0,t.jsx)(C.ChevronsLeft,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to previous page"}),(0,t.jsx)(C.ChevronLeft,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to next page"}),(0,t.jsx)(C.ChevronRight,{})]}),(0,t.jsxs)(w.Button,{variant:"outline",size:"icon",className:"hidden size-8 lg:flex",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[(0,t.jsx)("span",{className:"sr-only",children:"Go to last page"}),(0,t.jsx)(C.ChevronsRight,{})]})]})]})]})}S.displayName=k;var p=require("@stackshift-ui/dropdown-menu"),V="DataTableColumnHeader";function P({column:e,title:n,className:s,...o}){let{[V]:m=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return e.getCanSort()?(0,t.jsx)(m,{className:(0,M.cn)("flex items-center gap-2",s),...o,children:(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(w.Button,{variant:"ghost",size:"sm",className:"data-[state=open]:bg-accent -ml-3 h-8",children:[(0,t.jsx)("span",{children:n}),e.getIsSorted()==="desc"?(0,t.jsx)(C.ArrowDown,{}):e.getIsSorted()==="asc"?(0,t.jsx)(C.ArrowUp,{}):(0,t.jsx)(C.ChevronsUpDown,{})]})}),(0,t.jsxs)(p.DropdownMenuContent,{align:"start",children:[(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleSorting(!1),children:[(0,t.jsx)(C.ArrowUp,{}),"Asc"]}),(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleSorting(!0),children:[(0,t.jsx)(C.ArrowDown,{}),"Desc"]}),(0,t.jsx)(p.DropdownMenuSeparator,{}),(0,t.jsxs)(p.DropdownMenuItem,{onClick:()=>e.toggleVisibility(!1),children:[(0,t.jsx)(C.EyeOff,{}),"Hide"]})]})]})}):(0,t.jsx)(m,{className:(0,M.cn)(s),...o,children:n})}P.displayName=V;var F="DataTableViewOptions";function y({table:e,...n}){let{[F]:s=M.DefaultComponent}=(0,M.useStackShiftUIComponents)();return(0,t.jsx)(s,{...n,children:(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(w.Button,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[(0,t.jsx)(C.Settings2,{}),"View"]})}),(0,t.jsxs)(p.DropdownMenuContent,{align:"end",className:"w-[150px]",children:[(0,t.jsx)(p.DropdownMenuLabel,{children:"Toggle columns"}),(0,t.jsx)(p.DropdownMenuSeparator,{}),e.getAllColumns().filter(o=>typeof o.accessorFn!="undefined"&&o.getCanHide()).map(o=>(0,t.jsx)(p.DropdownMenuCheckboxItem,{className:"capitalize",checked:o.getIsVisible(),onCheckedChange:m=>o.toggleVisibility(!!m),children:o.id},o.id))]})]})})}y.displayName=F;var L="DataTable";function U({columns:e,data:n,...s}){var R;let{[L]:o=M.DefaultComponent}=(0,M.useStackShiftUIComponents)(),[m,A]=(0,h.useState)([]),[G,O]=(0,h.useState)({}),[E,$]=(0,h.useState)([]),b=(0,r.useReactTable)({data:n,columns:e,getCoreRowModel:(0,r.getCoreRowModel)(),getPaginationRowModel:(0,r.getPaginationRowModel)(),onSortingChange:A,getSortedRowModel:(0,r.getSortedRowModel)(),onRowSelectionChange:O,onColumnFiltersChange:$,getFilteredRowModel:(0,r.getFilteredRowModel)(),state:{sorting:m,rowSelection:G,columnFilters:E}});return(0,t.jsxs)(o,{className:"relative w-full h-full flex flex-col gap-2",...s,children:[(0,t.jsx)("div",{className:"rounded-md border",children:(0,t.jsxs)(i.Table,{children:[(0,t.jsx)(i.TableHeader,{children:b.getHeaderGroups().map(D=>(0,t.jsx)(i.TableRow,{children:D.headers.map(f=>(0,t.jsx)(i.TableHead,{children:f.isPlaceholder?null:(0,r.flexRender)(f.column.columnDef.header,f.getContext())},f.id))},D.id))}),(0,t.jsx)(i.TableBody,{children:(R=b.getRowModel().rows)!=null&&R.length?b.getRowModel().rows.map(D=>(0,t.jsx)(i.TableRow,{"data-state":D.getIsSelected()&&"selected",children:D.getVisibleCells().map(f=>(0,t.jsx)(i.TableCell,{children:(0,r.flexRender)(f.column.columnDef.cell,f.getContext())},f.id))},D.id)):(0,t.jsx)(i.TableRow,{children:(0,t.jsx)(i.TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]})}),(0,t.jsx)("div",{className:"w-full h-fit py-10",children:(0,t.jsx)(S,{table:b})})]})}U.displayName=L;0&&(module.exports={DataTable,DataTableColumnHeader,DataTablePagination,DataTableViewOptions});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";import{a as t}from"./chunk-VTWRQFOH.mjs";import{a as e}from"./chunk-4II4GOHT.mjs";import{a as o}from"./chunk-2YVCA56U.mjs";import{a as r}from"./chunk-URJGIMUX.mjs";import"./chunk-3EYN2AKU.mjs";export{t as DataTable,e as DataTableColumnHeader,o as DataTablePagination,r as DataTableViewOptions};
|