@bsol-oss/react-datatable5 1.0.32 → 1.0.34

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { RowData, OnChangeFn, Updater, FilterFn, ColumnDef, Row } from '@tanstack/react-table';
3
+ import { RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionState, Row } from '@tanstack/react-table';
4
4
  import { RankingInfo } from '@tanstack/match-sorter-utils';
5
5
  import { ReactNode } from 'react';
6
6
  import { TextProps, TooltipProps } from '@chakra-ui/react';
@@ -36,25 +36,27 @@ declare module "@tanstack/react-table" {
36
36
  itemRank: RankingInfo;
37
37
  }
38
38
  }
39
- interface DataTableProps<T> {
39
+ interface DataTableProps<TData> {
40
40
  children: JSX.Element | JSX.Element[];
41
- data: T[];
42
- columns: ColumnDef<T, any>[];
41
+ data: TData[];
42
+ columns: ColumnDef<TData, any>[];
43
43
  density?: DensityState;
44
44
  enableRowSelection?: boolean;
45
45
  enableMultiRowSelection?: boolean;
46
46
  enableSubRowSelection?: boolean;
47
+ onRowSelect?: (rowSelection: RowSelectionState) => void;
47
48
  }
48
- declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, children, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
49
+ declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, onRowSelect, children, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
49
50
 
50
- interface DataTableServerProps<T> {
51
+ interface DataTableServerProps<TData> {
51
52
  children: JSX.Element | JSX.Element[];
52
53
  url: string;
53
- columns: ColumnDef<T, any>[];
54
+ columns: ColumnDef<TData, any>[];
54
55
  enableRowSelection?: boolean;
55
56
  enableMultiRowSelection?: boolean;
56
57
  enableSubRowSelection?: boolean;
57
58
  density?: DensityState;
59
+ onRowSelect?: (row: RowSelectionState) => void;
58
60
  }
59
61
  interface Result<T> {
60
62
  results: T[];
@@ -69,7 +71,7 @@ declare module "@tanstack/react-table" {
69
71
  displayName: string;
70
72
  }
71
73
  }
72
- declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
74
+ declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, onRowSelect, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
73
75
 
74
76
  declare const DensityToggleButton: () => react_jsx_runtime.JSX.Element;
75
77
 
package/dist/index.js CHANGED
@@ -103,7 +103,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
103
103
  // Return if the item should be filtered in/out
104
104
  return itemRank.passed;
105
105
  };
106
- const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = 'sm', children, }) => {
106
+ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", onRowSelect = () => { }, children, }) => {
107
107
  const [columnOrder, setColumnOrder] = react.useState([]);
108
108
  const [globalFilter, setGlobalFilter] = react.useState("");
109
109
  const [densityState, setDensity] = react.useState(density);
@@ -144,6 +144,9 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
144
144
  react.useEffect(() => {
145
145
  setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
146
146
  }, []);
147
+ react.useEffect(() => {
148
+ onRowSelect(table.getState().rowSelection);
149
+ }, [table.getState().rowSelection]);
147
150
  return (jsxRuntime.jsx(TableContext.Provider, { value: {
148
151
  table: { ...table },
149
152
  refreshData: () => {
@@ -183,7 +186,7 @@ const useDataFromUrl = ({ url, params = {}, defaultData, }) => {
183
186
  return { data, loading, hasError, refreshData };
184
187
  };
185
188
 
186
- const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", children, }) => {
189
+ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", onRowSelect = () => { }, children, }) => {
187
190
  const [sorting, setSorting] = react.useState([]);
188
191
  const [columnFilters, setColumnFilters] = react.useState([]); // can set initial column filter state here
189
192
  const [pagination, setPagination] = react.useState({
@@ -237,7 +240,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
237
240
  rowSelection,
238
241
  columnOrder,
239
242
  globalFilter,
240
- density: densityState
243
+ density: densityState,
241
244
  },
242
245
  defaultColumn: {
243
246
  size: 150, //starting column size
@@ -269,6 +272,9 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
269
272
  react.useEffect(() => {
270
273
  setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
271
274
  }, []);
275
+ react.useEffect(() => {
276
+ onRowSelect(table.getState().rowSelection);
277
+ }, [table.getState().rowSelection]);
272
278
  return (jsxRuntime.jsx(TableContext.Provider, { value: {
273
279
  table: { ...table },
274
280
  refreshData: refreshData,
@@ -405,7 +411,6 @@ const EditSortingButton = () => {
405
411
  const TableViewer = () => {
406
412
  const { table } = useDataTable();
407
413
  return (jsxRuntime.jsx(react$1.Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
408
- console.log(column.columnDef.meta, "gokspo");
409
414
  const displayName = column.columnDef.meta === undefined
410
415
  ? column.id
411
416
  : column.columnDef.meta.displayName;
@@ -647,7 +652,7 @@ const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipP
647
652
  if (label) {
648
653
  return (jsxRuntime.jsx(react$1.Box, { padding: padding, children: jsxRuntime.jsx(react$1.Tooltip, { label: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", ...tooltipProps, children: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }) }));
649
654
  }
650
- return (jsxRuntime.jsx(react$1.Box, { padding: padding, children: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, children: children }) }));
655
+ return (jsxRuntime.jsx(react$1.Box, { padding: padding, children: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }));
651
656
  };
652
657
 
653
658
  exports.DataTable = DataTable;
package/dist/index.mjs CHANGED
@@ -101,7 +101,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
101
101
  // Return if the item should be filtered in/out
102
102
  return itemRank.passed;
103
103
  };
104
- const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = 'sm', children, }) => {
104
+ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", onRowSelect = () => { }, children, }) => {
105
105
  const [columnOrder, setColumnOrder] = useState([]);
106
106
  const [globalFilter, setGlobalFilter] = useState("");
107
107
  const [densityState, setDensity] = useState(density);
@@ -142,6 +142,9 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
142
142
  useEffect(() => {
143
143
  setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
144
144
  }, []);
145
+ useEffect(() => {
146
+ onRowSelect(table.getState().rowSelection);
147
+ }, [table.getState().rowSelection]);
145
148
  return (jsx(TableContext.Provider, { value: {
146
149
  table: { ...table },
147
150
  refreshData: () => {
@@ -181,7 +184,7 @@ const useDataFromUrl = ({ url, params = {}, defaultData, }) => {
181
184
  return { data, loading, hasError, refreshData };
182
185
  };
183
186
 
184
- const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", children, }) => {
187
+ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, density = "sm", onRowSelect = () => { }, children, }) => {
185
188
  const [sorting, setSorting] = useState([]);
186
189
  const [columnFilters, setColumnFilters] = useState([]); // can set initial column filter state here
187
190
  const [pagination, setPagination] = useState({
@@ -235,7 +238,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
235
238
  rowSelection,
236
239
  columnOrder,
237
240
  globalFilter,
238
- density: densityState
241
+ density: densityState,
239
242
  },
240
243
  defaultColumn: {
241
244
  size: 150, //starting column size
@@ -267,6 +270,9 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
267
270
  useEffect(() => {
268
271
  setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
269
272
  }, []);
273
+ useEffect(() => {
274
+ onRowSelect(table.getState().rowSelection);
275
+ }, [table.getState().rowSelection]);
270
276
  return (jsx(TableContext.Provider, { value: {
271
277
  table: { ...table },
272
278
  refreshData: refreshData,
@@ -403,7 +409,6 @@ const EditSortingButton = () => {
403
409
  const TableViewer = () => {
404
410
  const { table } = useDataTable();
405
411
  return (jsx(Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
406
- console.log(column.columnDef.meta, "gokspo");
407
412
  const displayName = column.columnDef.meta === undefined
408
413
  ? column.id
409
414
  : column.columnDef.meta.displayName;
@@ -645,7 +650,7 @@ const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipP
645
650
  if (label) {
646
651
  return (jsx(Box, { padding: padding, children: jsx(Tooltip, { label: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", ...tooltipProps, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }) }));
647
652
  }
648
- return (jsx(Box, { padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, children: children }) }));
653
+ return (jsx(Box, { padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }));
649
654
  };
650
655
 
651
656
  export { DataTable, DataTableServer, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, Table, TableBody, TableCardContainer, TableCards, TableFilter, TableFooter, TableHeader, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTable };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ColumnDef, FilterFn } from "@tanstack/react-table";
2
+ import { ColumnDef, FilterFn, RowSelectionState } from "@tanstack/react-table";
3
3
  import { RankingInfo } from "@tanstack/match-sorter-utils";
4
4
  import { DensityState } from "./DensityFeature";
5
5
  declare module "@tanstack/react-table" {
@@ -10,13 +10,14 @@ declare module "@tanstack/react-table" {
10
10
  itemRank: RankingInfo;
11
11
  }
12
12
  }
13
- export interface DataTableProps<T> {
13
+ export interface DataTableProps<TData> {
14
14
  children: JSX.Element | JSX.Element[];
15
- data: T[];
16
- columns: ColumnDef<T, any>[];
15
+ data: TData[];
16
+ columns: ColumnDef<TData, any>[];
17
17
  density?: DensityState;
18
18
  enableRowSelection?: boolean;
19
19
  enableMultiRowSelection?: boolean;
20
20
  enableSubRowSelection?: boolean;
21
+ onRowSelect?: (rowSelection: RowSelectionState) => void;
21
22
  }
22
- export declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, children, }: DataTableProps<TData>) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, onRowSelect, children, }: DataTableProps<TData>) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Table } from "@tanstack/react-table";
3
- export interface DataTableContext<T> {
4
- table: Table<T>;
3
+ export interface DataTableContext<TData> {
4
+ table: Table<TData>;
5
5
  refreshData: () => void;
6
6
  globalFilter: string;
7
7
  setGlobalFilter: (filter: string) => void;
@@ -1,14 +1,15 @@
1
1
  /// <reference types="react" />
2
- import { ColumnDef, RowData } from "@tanstack/react-table";
2
+ import { ColumnDef, RowData, RowSelectionState } from "@tanstack/react-table";
3
3
  import { DensityState } from "./DensityFeature";
4
- export interface DataTableServerProps<T> {
4
+ export interface DataTableServerProps<TData> {
5
5
  children: JSX.Element | JSX.Element[];
6
6
  url: string;
7
- columns: ColumnDef<T, any>[];
7
+ columns: ColumnDef<TData, any>[];
8
8
  enableRowSelection?: boolean;
9
9
  enableMultiRowSelection?: boolean;
10
10
  enableSubRowSelection?: boolean;
11
11
  density?: DensityState;
12
+ onRowSelect?: (row: RowSelectionState) => void;
12
13
  }
13
14
  export interface Result<T> {
14
15
  results: T[];
@@ -23,4 +24,4 @@ declare module "@tanstack/react-table" {
23
24
  displayName: string;
24
25
  }
25
26
  }
26
- export declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, children, }: DataTableServerProps<TData>) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, density, onRowSelect, children, }: DataTableServerProps<TData>) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",