@bsol-oss/react-datatable5 1.0.63 → 2.0.0

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.
Files changed (51) hide show
  1. package/dist/index.d.ts +145 -101
  2. package/dist/index.js +257 -271
  3. package/dist/index.mjs +192 -206
  4. package/dist/types/components/Controls/SelectAllRowsToggle.d.ts +4 -4
  5. package/dist/types/components/DataTable/DataTable.d.ts +18 -13
  6. package/dist/types/components/DataTable/DataTableContext.d.ts +4 -3
  7. package/dist/types/components/DataTable/DataTableServer.d.ts +18 -14
  8. package/dist/types/components/DataTable/useDataTable.d.ts +33 -7
  9. package/dist/types/components/DataTable/useDataTableContext.d.ts +8 -0
  10. package/dist/types/index.d.ts +41 -7
  11. package/package.json +1 -1
  12. package/dist/types/components/DataTable.d.ts +0 -33
  13. package/dist/types/components/DataTableContext.d.ts +0 -10
  14. package/dist/types/components/DataTableServer.d.ts +0 -38
  15. package/dist/types/components/DefaultTable.d.ts +0 -5
  16. package/dist/types/components/DensityFeature.d.ts +0 -23
  17. package/dist/types/components/DensityToggle.d.ts +0 -1
  18. package/dist/types/components/DensityToggleButton.d.ts +0 -6
  19. package/dist/types/components/EditFilterButton.d.ts +0 -9
  20. package/dist/types/components/EditOrderButton.d.ts +0 -7
  21. package/dist/types/components/EditSortingButton.d.ts +0 -7
  22. package/dist/types/components/EditViewButton.d.ts +0 -7
  23. package/dist/types/components/FilterOptions.d.ts +0 -4
  24. package/dist/types/components/GlobalFilter.d.ts +0 -3
  25. package/dist/types/components/PageSizeControl.d.ts +0 -4
  26. package/dist/types/components/ResetFilteringButton.d.ts +0 -4
  27. package/dist/types/components/ResetSelectionButton.d.ts +0 -4
  28. package/dist/types/components/ResetSortingButton.d.ts +0 -4
  29. package/dist/types/components/RowCountText.d.ts +0 -1
  30. package/dist/types/components/SelectAllRowsToggle.d.ts +0 -8
  31. package/dist/types/components/Table.d.ts +0 -8
  32. package/dist/types/components/TableBody.d.ts +0 -17
  33. package/dist/types/components/TableCardContainer.d.ts +0 -6
  34. package/dist/types/components/TableCards.d.ts +0 -4
  35. package/dist/types/components/TableComponent.d.ts +0 -6
  36. package/dist/types/components/TableComponentRenderer.d.ts +0 -6
  37. package/dist/types/components/TableControls.d.ts +0 -13
  38. package/dist/types/components/TableFilter.d.ts +0 -8
  39. package/dist/types/components/TableFilterTags.d.ts +0 -1
  40. package/dist/types/components/TableFooter.d.ts +0 -7
  41. package/dist/types/components/TableHeader.d.ts +0 -8
  42. package/dist/types/components/TableLoadingComponent.d.ts +0 -5
  43. package/dist/types/components/TableOrderer.d.ts +0 -1
  44. package/dist/types/components/TablePagination.d.ts +0 -3
  45. package/dist/types/components/TableReloadButton.d.ts +0 -4
  46. package/dist/types/components/TableSelector.d.ts +0 -1
  47. package/dist/types/components/TableSorter.d.ts +0 -1
  48. package/dist/types/components/TableViewer.d.ts +0 -1
  49. package/dist/types/components/TextCell.d.ts +0 -10
  50. package/dist/types/components/useDataFromUrl.d.ts +0 -14
  51. package/dist/types/components/useDataTable.d.ts +0 -7
package/dist/index.d.ts CHANGED
@@ -1,11 +1,69 @@
1
1
  /// <reference types="react" />
2
- import { RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionState, ColumnFiltersState, SortingState, VisibilityState, Row, Table as Table$1, Column } from '@tanstack/react-table';
2
+ import { RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionState, ColumnOrderState, ColumnFiltersState, GlobalFilterTableState, PaginationState, SortingState, VisibilityState, Row, Table as Table$1, Column } from '@tanstack/react-table';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { RankingInfo } from '@tanstack/match-sorter-utils';
5
4
  import React$1, { ReactNode } from 'react';
6
- import * as react_icons_lib from 'react-icons/lib';
5
+ import { RankingInfo } from '@tanstack/match-sorter-utils';
7
6
  import { TableProps as TableProps$1, GridProps, TextProps, TooltipProps } from '@chakra-ui/react';
8
7
  import * as _tanstack_table_core from '@tanstack/table-core';
8
+ import * as react_icons_lib from 'react-icons/lib';
9
+
10
+ interface DensityToggleButtonProps {
11
+ icon?: React$1.ReactElement;
12
+ text?: string;
13
+ }
14
+ declare const DensityToggleButton: ({ text, icon, }: DensityToggleButtonProps) => react_jsx_runtime.JSX.Element;
15
+
16
+ interface EditFilterButtonProps {
17
+ text?: string;
18
+ title?: string;
19
+ closeText?: string;
20
+ resetText?: string;
21
+ icon?: React.ReactElement;
22
+ }
23
+ declare const EditFilterButton: ({ text, title, closeText, resetText, icon, ...props }: EditFilterButtonProps) => react_jsx_runtime.JSX.Element;
24
+
25
+ interface EditOrderButtonProps {
26
+ title?: string;
27
+ icon?: React$1.ReactElement;
28
+ text?: string;
29
+ }
30
+ declare const EditOrderButton: ({ text, icon, title, }: EditOrderButtonProps) => react_jsx_runtime.JSX.Element;
31
+
32
+ interface EditSortingButtonProps {
33
+ title?: string;
34
+ icon?: React.ReactElement;
35
+ text?: string;
36
+ }
37
+ declare const EditSortingButton: ({ text, icon, title, }: EditSortingButtonProps) => react_jsx_runtime.JSX.Element;
38
+
39
+ interface EditViewButtonProps {
40
+ text?: string;
41
+ icon?: React$1.ReactElement;
42
+ title?: string;
43
+ }
44
+ declare const EditViewButton: ({ text, icon, title, }: EditViewButtonProps) => react_jsx_runtime.JSX.Element;
45
+
46
+ interface PageSizeControlProps {
47
+ pageSizes?: number[];
48
+ }
49
+ declare const PageSizeControl: ({ pageSizes, }: PageSizeControlProps) => react_jsx_runtime.JSX.Element;
50
+
51
+ interface ResetFilteringButtonProps {
52
+ text?: string;
53
+ }
54
+ declare const ResetFilteringButton: ({ text, }: ResetFilteringButtonProps) => react_jsx_runtime.JSX.Element;
55
+
56
+ interface ResetSelectionButtonProps {
57
+ text?: string;
58
+ }
59
+ declare const ResetSelectionButton: ({ text, }: ResetSelectionButtonProps) => react_jsx_runtime.JSX.Element;
60
+
61
+ interface ResetSortingButtonProps {
62
+ text?: string;
63
+ }
64
+ declare const ResetSortingButton: ({ text, }: ResetSortingButtonProps) => react_jsx_runtime.JSX.Element;
65
+
66
+ declare const RowCountText: () => react_jsx_runtime.JSX.Element;
9
67
 
10
68
  type DensityState = "sm" | "md" | "lg";
11
69
  interface DensityTableState {
@@ -45,19 +103,24 @@ interface DataTableProps<TData> {
45
103
  enableMultiRowSelection?: boolean;
46
104
  enableSubRowSelection?: boolean;
47
105
  onRowSelect?: (rowSelectionState: RowSelectionState, data: TData[]) => void;
48
- columnOrder?: string[];
49
- columnFilters?: ColumnFiltersState;
50
- globalFilter?: string;
51
- density?: DensityState;
52
- pagination?: {
53
- pageIndex: number;
54
- pageSize: number;
55
- };
56
- sorting?: SortingState;
57
- rowSelection?: RowSelectionState;
58
- columnVisibility?: VisibilityState;
59
- }
60
- declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder: defaultColumnOrder, columnFilters: defaultColumnFilter, density, globalFilter: defaultGlobalFilter, pagination: defaultPagination, sorting: defaultSorting, rowSelection: defaultRowSelection, columnVisibility: defaultColumnVisibility, children, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
106
+ columnOrder: ColumnOrderState;
107
+ columnFilters: ColumnFiltersState;
108
+ globalFilter: GlobalFilterTableState;
109
+ density: DensityState;
110
+ pagination: PaginationState;
111
+ sorting: SortingState;
112
+ rowSelection: RowSelectionState;
113
+ columnVisibility: VisibilityState;
114
+ setPagination: OnChangeFn<PaginationState>;
115
+ setSorting: OnChangeFn<SortingState>;
116
+ setColumnFilters: OnChangeFn<ColumnFiltersState>;
117
+ setRowSelection: OnChangeFn<RowSelectionState>;
118
+ setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
119
+ setColumnOrder: OnChangeFn<ColumnOrderState>;
120
+ setDensity: OnChangeFn<DensityState>;
121
+ setColumnVisibility: OnChangeFn<VisibilityState>;
122
+ }
123
+ declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
61
124
 
62
125
  interface DataTableServerProps<TData> {
63
126
  children: JSX.Element | JSX.Element[];
@@ -67,18 +130,22 @@ interface DataTableServerProps<TData> {
67
130
  enableMultiRowSelection?: boolean;
68
131
  enableSubRowSelection?: boolean;
69
132
  onRowSelect?: (rowSelectionState: RowSelectionState, data: TData[]) => void;
70
- columnOrder?: string[];
71
- columnFilters?: ColumnFiltersState;
72
- globalFilter?: string;
73
- density?: DensityState;
74
- pagination?: {
75
- pageIndex: number;
76
- pageSize: number;
77
- };
78
- sorting?: SortingState;
79
- rowSelection?: RowSelectionState;
80
- loadingComponent?: JSX.Element;
81
- columnVisibility?: VisibilityState;
133
+ columnOrder: ColumnOrderState;
134
+ columnFilters: ColumnFiltersState;
135
+ globalFilter: GlobalFilterTableState;
136
+ density: DensityState;
137
+ pagination: PaginationState;
138
+ sorting: SortingState;
139
+ rowSelection: RowSelectionState;
140
+ columnVisibility: VisibilityState;
141
+ setPagination: OnChangeFn<PaginationState>;
142
+ setSorting: OnChangeFn<SortingState>;
143
+ setColumnFilters: OnChangeFn<ColumnFiltersState>;
144
+ setRowSelection: OnChangeFn<RowSelectionState>;
145
+ setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
146
+ setColumnOrder: OnChangeFn<ColumnOrderState>;
147
+ setDensity: OnChangeFn<DensityState>;
148
+ setColumnVisibility: OnChangeFn<VisibilityState>;
82
149
  }
83
150
  interface Result<T> {
84
151
  results: T[];
@@ -88,7 +155,7 @@ interface DataResponse<T> extends Result<T> {
88
155
  count: number;
89
156
  filterCount: number;
90
157
  }
91
- declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder: defaultColumnOrder, columnFilters: defaultColumnFilter, density, globalFilter: defaultGlobalFilter, pagination: defaultPagination, sorting: defaultSorting, rowSelection: defaultRowSelection, columnVisibility: defaultColumnVisibility, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
158
+ declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
92
159
 
93
160
  interface TableControlsProps {
94
161
  totalText?: string;
@@ -108,73 +175,6 @@ interface DefaultTableProps extends TableControlsProps {
108
175
  }
109
176
  declare const DefaultTable: ({ totalText, showFilter, showFooter, fitTableWidth, fitTableHeight, isMobile, filterOptions, showFilterTags, showFilterName, }: DefaultTableProps) => react_jsx_runtime.JSX.Element;
110
177
 
111
- interface DensityToggleButtonProps {
112
- icon?: React$1.ReactElement;
113
- text?: string;
114
- }
115
- declare const DensityToggleButton: ({ text, icon, }: DensityToggleButtonProps) => react_jsx_runtime.JSX.Element;
116
-
117
- interface EditFilterButtonProps {
118
- text?: string;
119
- title?: string;
120
- closeText?: string;
121
- resetText?: string;
122
- icon?: React.ReactElement;
123
- }
124
- declare const EditFilterButton: ({ text, title, closeText, resetText, icon, ...props }: EditFilterButtonProps) => react_jsx_runtime.JSX.Element;
125
-
126
- interface EditOrderButtonProps {
127
- title?: string;
128
- icon?: React$1.ReactElement;
129
- text?: string;
130
- }
131
- declare const EditOrderButton: ({ text, icon, title, }: EditOrderButtonProps) => react_jsx_runtime.JSX.Element;
132
-
133
- interface EditSortingButtonProps {
134
- title?: string;
135
- icon?: React.ReactElement;
136
- text?: string;
137
- }
138
- declare const EditSortingButton: ({ text, icon, title, }: EditSortingButtonProps) => react_jsx_runtime.JSX.Element;
139
-
140
- interface EditViewButtonProps {
141
- text?: string;
142
- icon?: React$1.ReactElement;
143
- title?: string;
144
- }
145
- declare const EditViewButton: ({ text, icon, title, }: EditViewButtonProps) => react_jsx_runtime.JSX.Element;
146
-
147
- interface FilterOptionsProps {
148
- column: string;
149
- }
150
- declare const FilterOptions: ({ column }: FilterOptionsProps) => react_jsx_runtime.JSX.Element;
151
-
152
- declare const GlobalFilter: ({ icon }: {
153
- icon?: react_icons_lib.IconType | undefined;
154
- }) => react_jsx_runtime.JSX.Element;
155
-
156
- interface PageSizeControlProps {
157
- pageSizes?: number[];
158
- }
159
- declare const PageSizeControl: ({ pageSizes, }: PageSizeControlProps) => react_jsx_runtime.JSX.Element;
160
-
161
- interface ResetFilteringButtonProps {
162
- text?: string;
163
- }
164
- declare const ResetFilteringButton: ({ text, }: ResetFilteringButtonProps) => react_jsx_runtime.JSX.Element;
165
-
166
- interface ResetSelectionButtonProps {
167
- text?: string;
168
- }
169
- declare const ResetSelectionButton: ({ text, }: ResetSelectionButtonProps) => react_jsx_runtime.JSX.Element;
170
-
171
- interface ResetSortingButtonProps {
172
- text?: string;
173
- }
174
- declare const ResetSortingButton: ({ text, }: ResetSortingButtonProps) => react_jsx_runtime.JSX.Element;
175
-
176
- declare const RowCountText: () => react_jsx_runtime.JSX.Element;
177
-
178
178
  interface TableProps extends TableProps$1 {
179
179
  showLoading?: boolean;
180
180
  loadingComponent?: JSX.Element;
@@ -281,30 +281,74 @@ interface useDataFromUrlProps<T> {
281
281
  }
282
282
  declare const useDataFromUrl: <T>({ url, params, disableFirstFetch, onFetchSuccess, defaultData, }: useDataFromUrlProps<T>) => useDataFromUrlReturn<T>;
283
283
 
284
- declare const useDataTable: () => {
284
+ declare const useDataTableContext: () => {
285
285
  table: _tanstack_table_core.Table<any>;
286
286
  refreshData: () => void;
287
- globalFilter: string;
288
- setGlobalFilter: (filter: string) => void;
287
+ globalFilter: _tanstack_table_core.GlobalFilterTableState;
288
+ setGlobalFilter: _tanstack_table_core.OnChangeFn<_tanstack_table_core.GlobalFilterTableState>;
289
289
  loading: boolean;
290
+ hasError: boolean;
290
291
  };
291
292
 
293
+ interface FilterOptionsProps {
294
+ column: string;
295
+ }
296
+ declare const FilterOptions: ({ column }: FilterOptionsProps) => react_jsx_runtime.JSX.Element;
297
+
298
+ declare const GlobalFilter: ({ icon }: {
299
+ icon?: react_icons_lib.IconType | undefined;
300
+ }) => react_jsx_runtime.JSX.Element;
301
+
292
302
  declare module "@tanstack/react-table" {
293
303
  interface ColumnMeta<TData extends RowData, TValue> {
304
+ /**
305
+ * The display name of the column, used for rendering headers.
306
+ */
294
307
  displayName?: string;
295
308
  /**
296
- * @note you should provide a proper `filterfn` to handle the filtering when choosing `boolean`, `dateRange` and `custom`
309
+ * Specifies the type of filter to be used for the column.
310
+ *
311
+ * @remarks You should provide a proper `filterfn` to handle filtering when choosing `boolean`, `dateRange`, and `custom`.
312
+ *
313
+ * @remarks You should decide `renderFilter` to display filter ui when choosing `custom`.
314
+ *
315
+ * Possible values:
316
+ * - "text": A text input filter.
317
+ * - "range": A numerical range filter.
318
+ * - "select": A dropdown select filter.
319
+ * - "tag": A tag-based filter.
320
+ * - "boolean": A true/false filter.
321
+ * - "dateRange": A date range filter.
322
+ * - "custom": A custom filter function.
297
323
  */
298
324
  filterVariant?: "text" | "range" | "select" | "tag" | "boolean" | "dateRange" | "custom";
325
+ /**
326
+ * Options for the select filter variant, if applicable.
327
+ */
299
328
  filterOptions?: string[];
329
+ /**
330
+ * Configuration for the range filter variant, if applicable.
331
+ *
332
+ * Properties:
333
+ * - `min`: Minimum value for the range.
334
+ * - `max`: Maximum value for the range.
335
+ * - `step`: Step increment for the range.
336
+ * - `defaultValue`: Default range values for the filter.
337
+ */
300
338
  filterRangeConfig?: {
301
339
  min: number;
302
340
  max: number;
303
341
  step: number;
304
342
  defaultValue: [number, number];
305
343
  };
344
+ /**
345
+ * A function that renders the filter component for the column.
346
+ *
347
+ * @param column - The column for which the filter is being rendered.
348
+ * @returns A JSX element representing the filter UI.
349
+ */
306
350
  renderFilter?: (column: Column<TData>) => JSX.Element;
307
351
  }
308
352
  }
309
353
 
310
- export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, EditFilterButton, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, EditViewButton, type EditViewButtonProps, FilterOptions, type FilterOptionsProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, TablePagination, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
354
+ export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, EditFilterButton, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, EditViewButton, type EditViewButtonProps, FilterOptions, type FilterOptionsProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, TablePagination, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTableContext };