@jamsrui/data-grid 0.0.7 → 0.0.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/data-grid-body.mjs +1 -1
- package/dist/data-grid-column-visibility.mjs +1 -1
- package/dist/data-grid-config.d.mts +3 -2
- package/dist/data-grid-header.mjs +1 -1
- package/dist/data-grid-pagination.mjs +1 -1
- package/dist/data-grid-row-select.d.mts +9 -0
- package/dist/data-grid-row-select.mjs +1 -0
- package/dist/data-grid-table.mjs +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/use-data-grid.d.mts +2 -2
- package/dist/use-data-grid.mjs +1 -1
- package/dist/utils.d.mts +5 -0
- package/dist/utils.mjs +1 -0
- package/package.json +14 -11
package/dist/data-grid-body.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as y}from"react/jsx-runtime";import{TableBody as i,TableCell as n,TableRow as m}from"@jamsrui/table";import{flexRender as d}from"@tanstack/react-table";import{useDataGridContext as l}from"./data-grid-context";import{DataGridEmpty as p}from"./data-grid-empty";import{getPinningStyles as s}from"./utils";const w=()=>{const{table:r,isEmpty:a}=l();return y(i,{children:[!!a&&e(p,{}),r.getRowModel().rows.map(o=>e(m,{children:o.getVisibleCells().map(t=>e(n,{"data-pinned":t.column.getIsPinned()||void 0,style:{width:t.column.getSize(),...s(t.column)},children:d(t.column.columnDef.cell,t.getContext())},t.id))},o.id))]})};export{w as DataGridBody};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as y,jsx as e,jsxs as g}from"react/jsx-runtime";import{Button as a}from"@jamsrui/button";import{useRenderElement as m}from"@jamsrui/hooks";import{Settings2Icon as l}from"@jamsrui/icons";import{AnimatedTickIcon as p}from"@jamsrui/icons/animated";import{Menu as d,MenuContent as u,MenuItem as C,MenuTrigger as c}from"@jamsrui/menu";import{useDataGridContext as f}from"./data-grid-context";const k=n=>{const{table:r}=f(),o=e(y,{children:g(d,{children:[e(c,{children:e(a,{size:"sm",startContent:e(l,{}),variant:"flat",children:"Column Visibility"})}),e(u,{children:r.getAllLeafColumns().map(t=>{const i=t.columnDef.header,s=typeof i=="function"?i({}):i;return e(C,{preventCloseOnClick:!0,isDisabled:!t.getCanHide(),onClick:t.getToggleVisibilityHandler(),startContent:e(p,{className:"text-primary",isSelected:t.getIsVisible()}),children:s},t.id)})})]})});return m("div",{props:[n,{children:o}]})};export{k as DataGridColumnVisibility};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { DataGrid } from './data-grid.mjs';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DataGrid } from './data-grid.mjs';
|
|
3
3
|
import './use-data-grid.mjs';
|
|
4
4
|
import '@tanstack/react-table';
|
|
5
5
|
import '@jamsrui/table';
|
|
6
6
|
|
|
7
7
|
declare const useDataGridConfig: () => DataGridConfig.Props;
|
|
8
|
-
declare const DataGridConfig: (props: DataGridConfig.Props & {
|
|
8
|
+
declare const DataGridConfig: (props: Omit<Partial<DataGridConfig.Props>, "children"> & {
|
|
9
9
|
merge?: boolean;
|
|
10
|
+
children: React.ReactNode;
|
|
10
11
|
}) => react_jsx_runtime.JSX.Element;
|
|
11
12
|
declare namespace DataGridConfig {
|
|
12
13
|
interface Props extends DataGrid.Props {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{IconButton as g}from"@jamsrui/icon-button";import{ArrowDownIcon as a,ArrowLeftToLineIcon as m,ArrowRightToLineIcon as f,ArrowUpIcon as s,ChevronsUpDownIcon as C,EllipsisVerticalIcon as I,EyeClosedIcon as b}from"@jamsrui/icons";import{Menu as M,MenuContent as k,MenuGroup as l,MenuItem as v,MenuRadioGroup as c,MenuRadioItem as i,MenuSeparator as u,MenuTrigger as w}from"@jamsrui/menu";import{TableColumn as S,TableHeader as R,TableRow as y}from"@jamsrui/table";import{cn as p}from"@jamsrui/utils";import{flexRender as T}from"@tanstack/react-table";import{useDataGridContext as z}from"./data-grid-context";import{getPinningStyles as D}from"./utils";const P=({column:t})=>o(M,{classNames:{content:"border border-divider"},children:[e(w,{children:e(g,{label:"More",size:"xs",variant:"light",children:e(I,{className:"size-4"})})}),o(k,{children:[e(l,{children:o(c,{value:t.getIsSorted()||"",children:[e(i,{isDisabled:!t.getCanSort(),preventCloseOnClick:!1,startContent:e(s,{}),tickPlacement:"end",value:"asc",onClick:()=>{t.getIsSorted()==="asc"?t.clearSorting():t.toggleSorting(!1)},children:"Asc"}),e(i,{isDisabled:!t.getCanSort(),preventCloseOnClick:!1,startContent:e(a,{}),tickPlacement:"end",value:"desc",onClick:()=>{t.getIsSorted()==="desc"?t.clearSorting():t.toggleSorting(!0)},children:"Desc"})]})}),e(u,{}),e(v,{isDisabled:!t.getCanHide(),onClick:t.getToggleVisibilityHandler(),startContent:e(b,{}),children:"Hide Column"}),e(u,{}),e(l,{children:o(c,{value:t.getIsPinned()||"",children:[e(i,{preventCloseOnClick:!1,startContent:e(m,{}),tickPlacement:"end",value:"left",onClick:()=>{t.pin(t.getIsPinned()==="left"?!1:"left")},children:"Pin To Left"}),e(i,{preventCloseOnClick:!1,startContent:e(f,{}),tickPlacement:"end",value:"right",onClick:()=>t.pin(t.getIsPinned()==="right"?!1:"right"),children:"Pin To Right"})]})})]})]}),B=()=>{const{table:t}=z(),d=t.getHeaderGroups();return e(R,{children:d.map(r=>e(y,{children:r.headers.map(n=>e(S,{className:"relative",colSpan:n.colSpan,"data-pinned":n.column.getIsPinned()||void 0,style:{width:n.getSize(),...D(n.column)},children:n.isPlaceholder?null:o("div",{className:"flex",children:[e("button",{onClick:n.column.getToggleSortingHandler(),type:"button",className:p("flex w-full cursor-pointer select-none gap-1 overflow-hidden pr-1 text-transform-inherit",{"":n.column.getCanSort()}),children:o("span",{className:"flex w-full grow items-center overflow-hidden font-medium",children:[T(n.column.columnDef.header,n.getContext()),{asc:e(s,{className:"size-3 shrink-0"}),desc:e(a,{className:"size-3 shrink-0"}),empty:e(C,{className:"size-3 shrink-0"})}[n.column.getIsSorted()||"empty"]]})}),e(P,{column:n.column}),e("span",{"aria-label":"resize",onDoubleClick:()=>n.column.resetSize(),onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler(),role:"presentation",className:p("absolute right-0 top-1/2 h-3/5 w-[2px] -translate-y-1/2 cursor-ew-resize bg-slate-300/30 opacity-0 transition-all duration-500 group-hover/table:opacity-100 select-none touch-none",{"isResizing cursor-ew-resize":n.column.getIsResizing()})})]})},n.id))},r.id))})};export{B as DataGridHeader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as a}from"react/jsx-runtime";import{useState as f}from"react";import{IconButton as o}from"@jamsrui/icon-button";import{ChevronDoubleLeftIcon as P,ChevronDoubleRightIcon as h,ChevronLeftIcon as v,ChevronRightIcon as x}from"@jamsrui/icons";import{Select as C,SelectItem as b}from"@jamsrui/select";import{useDataGridContext as I}from"./data-grid-context";const G=()=>{const{table:e,
|
|
1
|
+
import{jsx as t,jsxs as a}from"react/jsx-runtime";import{useState as f}from"react";import{IconButton as o}from"@jamsrui/icon-button";import{ChevronDoubleLeftIcon as P,ChevronDoubleRightIcon as h,ChevronLeftIcon as v,ChevronRightIcon as x}from"@jamsrui/icons";import{Select as C,SelectItem as b}from"@jamsrui/select";import{useDataGridContext as I}from"./data-grid-context";const G=()=>{const{table:e,isEmpty:i}=I(),[l,r]=f(["10"]),g=()=>{e.nextPage()},c=()=>{e.previousPage()},m=()=>{e.setPageIndex(0)},u=()=>{e.setPageIndex(e.getPageCount()-1)},s=e.getPageCount(),d=s?e.getState().pagination.pageIndex+1:0,p=n=>{e.setPageSize(Number(Array.from(n)[0]??[10])),r(n)};return i?null:a("div",{className:"flex flex-col w-full justify-between gap-4 md:flex-row md:items-center","data-slot":"pagination",children:[t(C,{label:"Rows Per Page:",onValueChange:p,returnFocus:!1,size:"sm",value:l,classNames:{root:"items-center flex max-w-[80px] flex-row gap-2",label:"shrink-0"},children:[10,20,50,100,500].map(n=>t(b,{value:n.toString(),children:n.toString()},n.toString()))}),a("div",{className:"flex gap-1 md:gap-4",children:[a("div",{className:"flex items-center justify-center text-sm font-medium",children:["Page ",d," of ",s]}),a("div",{className:"flex items-center",children:[a(o,{isDisabled:!e.getCanPreviousPage(),label:"First Page",onClick:m,radius:"full",size:"sm",variant:"light",children:[t("span",{className:"sr-only",children:"Go to first page"}),t(P,{height:20,width:20})]}),a(o,{isDisabled:!e.getCanPreviousPage(),label:"Previous Page",onClick:c,radius:"full",size:"sm",variant:"light",children:[t("span",{className:"sr-only",children:"Go to previous page"}),t(v,{height:20,width:20})]}),a(o,{isDisabled:!e.getCanNextPage(),label:"Next Page",onClick:g,radius:"full",size:"sm",variant:"light",children:[t("span",{className:"sr-only",children:"Go to next page"}),t(x,{height:20,width:20})]}),a(o,{isDisabled:!e.getCanNextPage(),label:"Last Page",onClick:u,radius:"full",size:"sm",variant:"light",children:[t("span",{className:"sr-only",children:"Go to last page"}),t(h,{height:20,width:20})]})]})]})]})};export{G as DataGridPagination};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Row } from '@tanstack/react-table';
|
|
3
|
+
|
|
4
|
+
declare const DataGridRowSelect: ({ row }: {
|
|
5
|
+
row: Row<any>;
|
|
6
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare const DataGridRowSelectAll: () => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { DataGridRowSelect, DataGridRowSelectAll };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import{Checkbox as o}from"@jamsrui/checkbox";import{useDataGridContext as a}from"./data-grid-context";const s=({row:e})=>l(o,{"aria-label":"Select Row",isChecked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(t)}),d=()=>{const{table:e}=a();return l(o,{"aria-label":"Select All Rows",isChecked:e.getIsAllPageRowsSelected(),isIntermediate:e.getIsSomePageRowsSelected(),onCheckedChange:t=>e.toggleAllPageRowsSelected(t)})};export{s as DataGridRowSelect,d as DataGridRowSelectAll};
|
package/dist/data-grid-table.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import{Table as t}from"@jamsrui/table";import{useDataGridContext as o}from"./data-grid-context";const p=e=>{const{children:a}=e,{rootProps:r}=o();return l(t,{className:"w-full table-fixed",...r,children:a})};export{p as DataGridTable};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DataGrid } from './data-grid.mjs';
|
|
2
2
|
export { DataGridConfig, useDataGridConfig } from './data-grid-config.mjs';
|
|
3
|
+
export { DataGridRowSelect, DataGridRowSelectAll } from './data-grid-row-select.mjs';
|
|
3
4
|
import 'react/jsx-runtime';
|
|
4
5
|
import './use-data-grid.mjs';
|
|
5
6
|
import '@tanstack/react-table';
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{DataGrid as
|
|
1
|
+
"use client";import{DataGrid as a}from"./data-grid";import{DataGridConfig as o,useDataGridConfig as i}from"./data-grid-config";import{DataGridRowSelect as f,DataGridRowSelectAll as l}from"./data-grid-row-select";export{a as DataGrid,o as DataGridConfig,f as DataGridRowSelect,l as DataGridRowSelectAll,i as useDataGridConfig};
|
package/dist/use-data-grid.d.mts
CHANGED
|
@@ -5,10 +5,10 @@ import { Table } from '@jamsrui/table';
|
|
|
5
5
|
declare const useDataGrid: <TData>(props: useDataGrid.Props<TData>) => {
|
|
6
6
|
table: _tanstack_react_table.Table<TData>;
|
|
7
7
|
isLoading: boolean | undefined;
|
|
8
|
-
|
|
8
|
+
isEmpty: boolean;
|
|
9
9
|
rootProps: {
|
|
10
10
|
isHeaderSticky: boolean | undefined;
|
|
11
|
-
variant: "
|
|
11
|
+
variant: "bordered" | "solid" | undefined;
|
|
12
12
|
radius: "md" | "sm" | "lg" | "xl" | "2xl" | "3xl" | "full" | "none" | undefined;
|
|
13
13
|
density: "compact" | "standard" | "comfortable" | undefined;
|
|
14
14
|
allowHover: boolean | undefined;
|
package/dist/use-data-grid.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as m,useState as t}from"react";import{getCoreRowModel as k,getExpandedRowModel as V,getFilteredRowModel as v,getPaginationRowModel as H,getSortedRowModel as
|
|
1
|
+
import{useMemo as m,useState as t}from"react";import{getCoreRowModel as k,getExpandedRowModel as V,getFilteredRowModel as v,getPaginationRowModel as H,getSortedRowModel as z,useReactTable as E}from"@tanstack/react-table";const I=S=>{const{columns:u,data:e,state:p,isLoading:o,isHeaderSticky:n,variant:a,radius:i,density:s,allowHover:r,separateRows:l,...w}=S,[R,C]=t([]),[P,b]=t({pageSize:10,pageIndex:0}),[y,M]=t({}),[T,h]=t([]),[D,O]=t({}),[G,x]=t({bottom:[],top:[]}),[F,f]=t([]),d=e.length===0,g=E({columnResizeMode:"onChange",columnResizeDirection:"ltr",getCoreRowModel:k(),getPaginationRowModel:H(),getSortedRowModel:z(),getFilteredRowModel:v(),onSortingChange:C,onColumnFiltersChange:h,onColumnVisibilityChange:M,onRowSelectionChange:O,onPaginationChange:b,getExpandedRowModel:V(),onColumnOrderChange:f,onRowPinningChange:x,...w,state:{sorting:R,columnFilters:T,columnVisibility:y,rowSelection:D,pagination:P,columnOrder:F,...p},data:e,columns:u}),c=m(()=>({isHeaderSticky:n,variant:a,radius:i,density:s,allowHover:r,separateRows:l}),[r,s,n,i,l,a]);return m(()=>({table:g,isLoading:o,isEmpty:d,rootProps:c}),[d,o,c,g])};export{I as useDataGrid};
|
package/dist/utils.d.mts
ADDED
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(t){const e=t.getIsPinned();return{left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,position:e?"sticky":"relative",width:t.getSize(),zIndex:e?1:0}}export{i as getPinningStyles};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jamsrui/data-grid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@tanstack/react-table": ">=8",
|
|
6
6
|
"react": ">=19"
|
|
@@ -10,16 +10,19 @@
|
|
|
10
10
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
11
11
|
"@dnd-kit/sortable": "^10.0.0",
|
|
12
12
|
"@dnd-kit/utilities": "^3.2.2",
|
|
13
|
-
"@jamsrui/
|
|
14
|
-
"@jamsrui/core": "^0.0.
|
|
15
|
-
"@jamsrui/
|
|
16
|
-
"@jamsrui/
|
|
17
|
-
"@jamsrui/
|
|
18
|
-
"@jamsrui/
|
|
19
|
-
"@jamsrui/
|
|
20
|
-
"@jamsrui/
|
|
21
|
-
"@jamsrui/linear-progress": "^0.0.
|
|
22
|
-
"@jamsrui/
|
|
13
|
+
"@jamsrui/button": "^0.0.9",
|
|
14
|
+
"@jamsrui/core": "^0.0.8",
|
|
15
|
+
"@jamsrui/hooks": "^0.0.9",
|
|
16
|
+
"@jamsrui/checkbox": "^0.0.9",
|
|
17
|
+
"@jamsrui/icon-button": "^0.0.9",
|
|
18
|
+
"@jamsrui/icons": "^0.0.8",
|
|
19
|
+
"@jamsrui/input": "^0.0.9",
|
|
20
|
+
"@jamsrui/divider": "^0.0.9",
|
|
21
|
+
"@jamsrui/linear-progress": "^0.0.9",
|
|
22
|
+
"@jamsrui/menu": "^0.0.9",
|
|
23
|
+
"@jamsrui/table": "^0.0.9",
|
|
24
|
+
"@jamsrui/select": "^0.0.9",
|
|
25
|
+
"@jamsrui/utils": "^0.0.9"
|
|
23
26
|
},
|
|
24
27
|
"exports": {
|
|
25
28
|
".": {
|