@jamsrui/data-grid 0.0.4 → 0.0.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,7 +1,7 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Row } from '@tanstack/react-table';
3
3
 
4
- declare const DataGridBody: () => react.JSX.Element;
4
+ declare const DataGridBody: () => react_jsx_runtime.JSX.Element;
5
5
  interface DataGridBodyProps<T> {
6
6
  rows: Row<T>[];
7
7
  }
@@ -1 +1 @@
1
- import{TableBody as a,TableCell as l,TableRow as m}from"@jamsrui/table";import{flexRender as i}from"@tanstack/react-table";import{useDataGridContext as p}from"./data-grid-context";import{DataGridEmpty as d}from"./data-grid-empty";const f=()=>{const{table:o,isEmtpy:r}=p();return React.createElement(a,null,!!r&&React.createElement(d,null),o.getRowModel().rows.map(t=>React.createElement(m,{key:t.id},t.getVisibleCells().map(e=>React.createElement(l,{key:e.id},i(e.column.columnDef.cell,e.getContext()))))))};export{f as DataGridBody};
1
+ import{jsx as o,jsxs as b}from"react/jsx-runtime";import{TableBody as l,TableCell as m,TableRow as i}from"@jamsrui/table";import{flexRender as p}from"@tanstack/react-table";import{useDataGridContext as d}from"./data-grid-context";import{DataGridEmpty as n}from"./data-grid-empty";const w=()=>{const{table:r,isEmtpy:a}=d();return b(l,{children:[!!a&&o(n,{}),r.getRowModel().rows.map(t=>o(i,{children:t.getVisibleCells().map(e=>o(m,{children:p(e.column.columnDef.cell,e.getContext())},e.id))},t.id))]})};export{w as DataGridBody};
@@ -1 +1 @@
1
- import{useRenderElement as s}from"@jamsrui/hooks";import{IconButton as m}from"@jamsrui/icon-button";import{InfoIcon as a}from"@jamsrui/icons";import{Menu as p,MenuContent as d,MenuItem as n,MenuTrigger as g}from"@jamsrui/menu";import{useDataGridContext as u}from"./data-grid-context";const h=o=>{const{table:t}=u(),l=React.createElement(React.Fragment,null,React.createElement(p,null,React.createElement(g,null,React.createElement(m,{label:"Column Visibility",size:"sm"},React.createElement(a,null))),React.createElement(d,null,React.createElement(n,{preventCloseOnClick:!0,onClick:t.getToggleAllColumnsVisibilityHandler()},React.createElement("input",{type:"checkbox",checked:t.getIsAllColumnsVisible(),onChange:t.getToggleAllColumnsVisibilityHandler()})," ","Toggle All"),t.getAllLeafColumns().map(e=>{const i=e.columnDef.header,r=typeof i=="function"?i({}):i;return React.createElement(n,{key:e.id,preventCloseOnClick:!0,isDisabled:!e.getCanHide(),onClick:e.getToggleVisibilityHandler()},React.createElement("input",{type:"checkbox",checked:e.getIsVisible(),onChange:e.getToggleVisibilityHandler()})," ",r)}))));return s("div",{props:[o,{children:l}]})};export{h as DataGridColumnVisibility};
1
+ import{Fragment as b,jsx as i,jsxs as n}from"react/jsx-runtime";import{useRenderElement as p}from"@jamsrui/hooks";import{IconButton as a}from"@jamsrui/icon-button";import{InfoIcon as d}from"@jamsrui/icons";import{Menu as g,MenuContent as u,MenuItem as l,MenuTrigger as c}from"@jamsrui/menu";import{useDataGridContext as C}from"./data-grid-context";const M=r=>{const{table:t}=C(),s=i(b,{children:n(g,{children:[i(c,{children:i(a,{label:"Column Visibility",size:"sm",children:i(d,{})})}),n(u,{children:[n(l,{preventCloseOnClick:!0,onClick:t.getToggleAllColumnsVisibilityHandler(),children:[i("input",{type:"checkbox",checked:t.getIsAllColumnsVisible(),onChange:t.getToggleAllColumnsVisibilityHandler()})," ","Toggle All"]}),t.getAllLeafColumns().map(e=>{const o=e.columnDef.header,m=typeof o=="function"?o({}):o;return n(l,{preventCloseOnClick:!0,isDisabled:!e.getCanHide(),onClick:e.getToggleVisibilityHandler(),children:[i("input",{type:"checkbox",checked:e.getIsVisible(),onChange:e.getToggleVisibilityHandler()})," ",m]},e.id)})]})]})});return p("div",{props:[r,{children:s}]})};export{M as DataGridColumnVisibility};
@@ -1,5 +1,5 @@
1
1
  import { DataGrid } from './data-grid.mjs';
2
- import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import './use-data-grid.mjs';
4
4
  import '@tanstack/react-table';
5
5
  import '@jamsrui/table';
@@ -7,7 +7,7 @@ import '@jamsrui/table';
7
7
  declare const useDataGridConfig: () => DataGridConfig.Props;
8
8
  declare const DataGridConfig: (props: DataGridConfig.Props & {
9
9
  merge?: boolean;
10
- }) => react.JSX.Element;
10
+ }) => react_jsx_runtime.JSX.Element;
11
11
  declare namespace DataGridConfig {
12
12
  interface Props extends DataGrid.Props {
13
13
  children: React.ReactNode;
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare const DataGridEmpty: () => react.JSX.Element;
3
+ declare const DataGridEmpty: () => react_jsx_runtime.JSX.Element;
4
4
  declare namespace DataGridEmpty {
5
5
  interface Props {
6
6
  }
@@ -1 +1 @@
1
- import{TableCell as e,TableRow as o}from"@jamsrui/table";import{useDataGridContext as l}from"./data-grid-context";const p=()=>{const{table:t}=l(),a=t.getAllColumns().length;return React.createElement(o,null,React.createElement(e,{colSpan:a},"No data available"))};export{p as DataGridEmpty};
1
+ import{jsx as t}from"react/jsx-runtime";import{TableCell as e,TableRow as l}from"@jamsrui/table";import{useDataGridContext as r}from"./data-grid-context";const m=()=>{const{table:a}=r(),o=a.getAllColumns().length;return t(l,{children:t(e,{colSpan:o,children:"No data available"})})};export{m as DataGridEmpty};
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare const DataGridHeader: () => react.JSX.Element;
3
+ declare const DataGridHeader: () => react_jsx_runtime.JSX.Element;
4
4
  declare namespace DataGridHeader {
5
5
  interface Props {
6
6
  }
@@ -1 +1 @@
1
- import{ChevronDownIcon as a,ChevronUpIcon as s}from"@jamsrui/icons";import{TableColumn as l,TableHeader as i,TableRow as c}from"@jamsrui/table";import{cn as t}from"@jamsrui/utils";import{flexRender as m}from"@tanstack/react-table";import{useDataGridContext as u}from"./data-grid-context";const w=()=>{const{table:r}=u(),n=r.getHeaderGroups();return React.createElement(i,null,n.map(o=>React.createElement(c,{key:o.id},o.headers.map(e=>React.createElement(l,{key:e.id},e.isPlaceholder?null:React.createElement(React.Fragment,null,React.createElement("button",{onClick:e.column.getToggleSortingHandler(),type:"button",className:t("flex w-full cursor-pointer select-none gap-1 overflow-hidden pr-1 text-transform-inherit",{"":e.column.getCanSort()})},React.createElement("span",{className:"flex w-full grow items-center overflow-hidden font-medium"},m(e.column.columnDef.header,e.getContext()),{asc:React.createElement(s,{className:"size-4 shrink-0"}),desc:React.createElement(a,{className:"size-4 shrink-0"})}[e.column.getIsSorted()]??null)),React.createElement("span",{"aria-label":"resize",onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),role:"presentation",className:t("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",{"isResizing cursor-ew-resize":e.column.getIsResizing()})})))))))};export{w as DataGridHeader};
1
+ import{Fragment as d,jsx as o,jsxs as n}from"react/jsx-runtime";import{ChevronDownIcon as l,ChevronUpIcon as i}from"@jamsrui/icons";import{TableColumn as c,TableHeader as m,TableRow as u}from"@jamsrui/table";import{cn as r}from"@jamsrui/utils";import{flexRender as p}from"@tanstack/react-table";import{useDataGridContext as g}from"./data-grid-context";const C=()=>{const{table:a}=g(),s=a.getHeaderGroups();return o(m,{children:s.map(t=>o(u,{children:t.headers.map(e=>o(c,{children:e.isPlaceholder?null:n(d,{children:[o("button",{onClick:e.column.getToggleSortingHandler(),type:"button",className:r("flex w-full cursor-pointer select-none gap-1 overflow-hidden pr-1 text-transform-inherit",{"":e.column.getCanSort()}),children:n("span",{className:"flex w-full grow items-center overflow-hidden font-medium",children:[p(e.column.columnDef.header,e.getContext()),{asc:o(i,{className:"size-4 shrink-0"}),desc:o(l,{className:"size-4 shrink-0"})}[e.column.getIsSorted()]??null]})}),o("span",{"aria-label":"resize",onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),role:"presentation",className:r("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",{"isResizing cursor-ew-resize":e.column.getIsResizing()})})]})},e.id))},t.id))})};export{C as DataGridHeader};
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare const DataGridLoading: (props: DataGridLoading.Props) => react.JSX.Element;
3
+ declare const DataGridLoading: (props: DataGridLoading.Props) => react_jsx_runtime.JSX.Element;
4
4
  declare namespace DataGridLoading {
5
5
  interface Props {
6
6
  }
@@ -1 +1 @@
1
- import{LinearProgress as r}from"@jamsrui/linear-progress";const o=a=>React.createElement(r,{className:"absolute inset-0",...a});export{o as DataGridLoading};
1
+ import{jsx as o}from"react/jsx-runtime";import{LinearProgress as r}from"@jamsrui/linear-progress";const t=a=>o(r,{className:"absolute inset-0",...a});export{t as DataGridLoading};
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare const DataGridPagination: () => react.JSX.Element | null;
3
+ declare const DataGridPagination: () => react_jsx_runtime.JSX.Element | null;
4
4
  declare namespace DataGridPagination {
5
5
  interface Props<T> {
6
6
  }
@@ -1 +1 @@
1
- import{useState as d}from"react";import{IconButton as a}from"@jamsrui/icon-button";import{ChevronDoubleLeftIcon as p,ChevronDoubleRightIcon as f,ChevronLeftIcon as P,ChevronRightIcon as h}from"@jamsrui/icons";import{Select as x,SelectItem as v}from"@jamsrui/select";import{useDataGridContext as C}from"./data-grid-context";const S=()=>{const{table:e,isEmtpy:s}=C(),[o,i]=d(["10"]),l=()=>{e.nextPage()},r=()=>{e.previousPage()},g=()=>{e.setPageIndex(0)},c=()=>{e.setPageIndex(e.getPageCount()-1)},n=e.getPageCount(),m=n?e.getState().pagination.pageIndex+1:0,u=t=>{e.setPageSize(Number(Array.from(t)[0]??[10])),i(t)};return s?null:React.createElement("div",{className:"flex flex-col w-full justify-between gap-4 md:flex-row md:items-center","data-slot":"pagination"},React.createElement(x,{label:"Rows Per Page:",onValueChange:u,returnFocus:!1,size:"sm",value:o,classNames:{root:"items-center flex max-w-[80px] flex-row gap-2",label:"shrink-0"}},[10,20,50,100,500].map(t=>React.createElement(v,{key:t.toString(),value:t.toString()},t.toString()))),React.createElement("div",{className:"flex gap-1 md:gap-4"},React.createElement("div",{className:"flex items-center justify-center text-sm font-medium"},"Page ",m," of ",n),React.createElement("div",{className:"flex items-center"},React.createElement(a,{isDisabled:!e.getCanPreviousPage(),label:"First Page",onClick:g,radius:"full",size:"sm",variant:"light"},React.createElement("span",{className:"sr-only"},"Go to first page"),React.createElement(p,{height:20,width:20})),React.createElement(a,{isDisabled:!e.getCanPreviousPage(),label:"Previous Page",onClick:r,radius:"full",size:"sm",variant:"light"},React.createElement("span",{className:"sr-only"},"Go to previous page"),React.createElement(P,{height:20,width:20})),React.createElement(a,{isDisabled:!e.getCanNextPage(),label:"Next Page",onClick:l,radius:"full",size:"sm",variant:"light"},React.createElement("span",{className:"sr-only"},"Go to next page"),React.createElement(h,{height:20,width:20})),React.createElement(a,{isDisabled:!e.getCanNextPage(),label:"Last Page",onClick:c,radius:"full",size:"sm",variant:"light"},React.createElement("span",{className:"sr-only"},"Go to last page"),React.createElement(f,{height:20,width:20})))))};export{S as DataGridPagination};
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,isEmtpy: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};
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare const DataGridTable: (props: DataGridTable.Props) => react.JSX.Element;
3
+ declare const DataGridTable: (props: DataGridTable.Props) => react_jsx_runtime.JSX.Element;
4
4
  declare namespace DataGridTable {
5
5
  interface Props {
6
6
  children: React.ReactNode;
@@ -1 +1 @@
1
- import{Table as a}from"@jamsrui/table";import{useDataGridContext as o}from"./data-grid-context";const n=e=>{const{children:r}=e,{rootProps:t}=o();return React.createElement(a,{...t},r)};export{n as DataGridTable};
1
+ import{jsx as p}from"react/jsx-runtime";import{Table as o}from"@jamsrui/table";import{useDataGridContext as t}from"./data-grid-context";const n=e=>{const{children:r}=e,{rootProps:a}=t();return p(o,{...a,children:r})};export{n as DataGridTable};
@@ -1,9 +1,9 @@
1
- import * as react from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { useDataGrid } from './use-data-grid.mjs';
3
3
  import '@tanstack/react-table';
4
4
  import '@jamsrui/table';
5
5
 
6
- declare const DataGrid: (props: DataGrid.Props) => react.JSX.Element;
6
+ declare const DataGrid: (props: DataGrid.Props) => react_jsx_runtime.JSX.Element;
7
7
  declare namespace DataGrid {
8
8
  interface Props extends useDataGrid.Props<any> {
9
9
  }
@@ -1 +1 @@
1
- import{useRenderElement as d}from"@jamsrui/hooks";import{mergeConfigProps as m}from"@jamsrui/utils";import{DataGridBody as n}from"./data-grid-body";import{DataGridColumnVisibility as p}from"./data-grid-column-visibility";import{useDataGridConfig as s}from"./data-grid-config";import{DataGridContext as f}from"./data-grid-context";import{DataGridHeader as c}from"./data-grid-header";import{DataGridLoading as l}from"./data-grid-loading";import{DataGridPagination as D}from"./data-grid-pagination";import{DataGridTable as G}from"./data-grid-table";import{useDataGrid as g}from"./use-data-grid";const B=t=>{const r=s(),a=m(r,r,t),o=g(a),i=React.createElement(React.Fragment,null,React.createElement(p,null),!!o.isLoading&&React.createElement(l,null),React.createElement(G,null,React.createElement(c,null),React.createElement(n,null)),React.createElement(D,null)),e=d("div",{props:[{"data-component":"data-grid","data-slot":"root",className:"relative flex flex-col gap-2"},{children:i}]});return React.createElement(f,{value:o},e)};export{B as DataGrid};
1
+ import{Fragment as C,jsx as r,jsxs as a}from"react/jsx-runtime";import{useRenderElement as n}from"@jamsrui/hooks";import{mergeConfigProps as p}from"@jamsrui/utils";import{DataGridBody as s}from"./data-grid-body";import{DataGridColumnVisibility as f}from"./data-grid-column-visibility";import{useDataGridConfig as l}from"./data-grid-config";import{DataGridContext as D}from"./data-grid-context";import{DataGridHeader as G}from"./data-grid-header";import{DataGridLoading as c}from"./data-grid-loading";import{DataGridPagination as g}from"./data-grid-pagination";import{DataGridTable as x}from"./data-grid-table";import{useDataGrid as u}from"./use-data-grid";const R=i=>{const o=l(),e=p(o,o,i),t=u(e),d=a(C,{children:[r(f,{}),!!t.isLoading&&r(c,{}),a(x,{children:[r(G,{}),r(s,{})]}),r(g,{})]}),m=n("div",{props:[{"data-component":"data-grid","data-slot":"root",className:"relative flex flex-col gap-2"},{children:d}]});return r(D,{value:t,children:m})};export{R as DataGrid};
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DataGrid } from './data-grid.mjs';
2
2
  export { DataGridConfig, useDataGridConfig } from './data-grid-config.mjs';
3
- import 'react';
3
+ import 'react/jsx-runtime';
4
4
  import './use-data-grid.mjs';
5
5
  import '@tanstack/react-table';
6
6
  import '@jamsrui/table';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamsrui/data-grid",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "peerDependencies": {
5
5
  "@tanstack/react-table": ">=8",
6
6
  "react": ">=19"
@@ -10,16 +10,16 @@
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/hooks": "^0.0.4",
14
- "@jamsrui/icon-button": "^0.0.4",
15
- "@jamsrui/core": "^0.0.4",
16
- "@jamsrui/icons": "^0.0.4",
17
- "@jamsrui/input": "^0.0.4",
18
- "@jamsrui/table": "^0.0.4",
19
- "@jamsrui/utils": "^0.0.4",
20
- "@jamsrui/select": "^0.0.4",
21
- "@jamsrui/menu": "^0.0.4",
22
- "@jamsrui/linear-progress": "^0.0.4"
13
+ "@jamsrui/icon-button": "^0.0.6",
14
+ "@jamsrui/icons": "^0.0.6",
15
+ "@jamsrui/linear-progress": "^0.0.6",
16
+ "@jamsrui/input": "^0.0.6",
17
+ "@jamsrui/hooks": "^0.0.6",
18
+ "@jamsrui/core": "^0.0.6",
19
+ "@jamsrui/menu": "^0.0.6",
20
+ "@jamsrui/utils": "^0.0.6",
21
+ "@jamsrui/table": "^0.0.6",
22
+ "@jamsrui/select": "^0.0.6"
23
23
  },
24
24
  "exports": {
25
25
  ".": {