@ackplus/react-tanstack-data-table 1.0.35 → 1.1.1
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/LICENSE +21 -0
- package/{src → dist}/index.d.ts +21 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/{src → dist}/lib/components/droupdown/menu-dropdown.d.ts +2 -1
- package/dist/lib/components/droupdown/menu-dropdown.d.ts.map +1 -0
- package/{src → dist}/lib/components/droupdown/menu-dropdown.js +38 -7
- package/{src → dist}/lib/components/filters/filter-value-input.d.ts +3 -1
- package/dist/lib/components/filters/filter-value-input.d.ts.map +1 -0
- package/dist/lib/components/filters/filter-value-input.js +83 -0
- package/{src → dist}/lib/components/filters/index.d.ts +1 -0
- package/dist/lib/components/filters/index.d.ts.map +1 -0
- package/dist/lib/components/filters/index.js +142 -0
- package/{src → dist}/lib/components/headers/draggable-header.d.ts +2 -2
- package/dist/lib/components/headers/draggable-header.d.ts.map +1 -0
- package/{src → dist}/lib/components/headers/draggable-header.js +81 -17
- package/dist/lib/components/headers/index.d.ts +6 -0
- package/dist/lib/components/headers/index.d.ts.map +1 -0
- package/dist/lib/components/headers/index.js +21 -0
- package/{src → dist}/lib/components/headers/table-header.d.ts +15 -1
- package/dist/lib/components/headers/table-header.d.ts.map +1 -0
- package/{src → dist}/lib/components/headers/table-header.js +50 -17
- package/{src → dist}/lib/components/index.d.ts +6 -1
- package/dist/lib/components/index.d.ts.map +1 -0
- package/dist/lib/components/index.js +32 -0
- package/{src → dist}/lib/components/pagination/data-table-pagination.d.ts +2 -1
- package/dist/lib/components/pagination/data-table-pagination.d.ts.map +1 -0
- package/{src → dist}/lib/components/pagination/data-table-pagination.js +20 -6
- package/dist/lib/components/pagination/index.d.ts +5 -0
- package/dist/lib/components/pagination/index.d.ts.map +1 -0
- package/dist/lib/components/pagination/index.js +20 -0
- package/{src → dist}/lib/components/rows/data-table-row.d.ts +15 -2
- package/dist/lib/components/rows/data-table-row.d.ts.map +1 -0
- package/{src → dist}/lib/components/rows/data-table-row.js +58 -25
- package/{src → dist}/lib/components/rows/empty-data-row.d.ts +3 -3
- package/dist/lib/components/rows/empty-data-row.d.ts.map +1 -0
- package/{src → dist}/lib/components/rows/empty-data-row.js +12 -4
- package/dist/lib/components/rows/index.d.ts +7 -0
- package/dist/lib/components/rows/index.d.ts.map +1 -0
- package/dist/lib/components/rows/index.js +22 -0
- package/{src → dist}/lib/components/rows/loading-rows.d.ts +3 -1
- package/dist/lib/components/rows/loading-rows.d.ts.map +1 -0
- package/{src → dist}/lib/components/rows/loading-rows.js +27 -19
- package/{src → dist}/lib/components/toolbar/bulk-actions-toolbar.d.ts +4 -3
- package/dist/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +1 -0
- package/dist/lib/components/toolbar/bulk-actions-toolbar.js +49 -0
- package/{src → dist}/lib/components/toolbar/column-filter-control.d.ts +3 -1
- package/dist/lib/components/toolbar/column-filter-control.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/column-filter-control.js +73 -4
- package/{src → dist}/lib/components/toolbar/column-pinning-control.d.ts +2 -1
- package/dist/lib/components/toolbar/column-pinning-control.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/column-pinning-control.js +70 -6
- package/{src → dist}/lib/components/toolbar/column-reset-control.d.ts +3 -1
- package/dist/lib/components/toolbar/column-reset-control.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/column-reset-control.js +9 -2
- package/{src → dist}/lib/components/toolbar/column-visibility-control.d.ts +2 -1
- package/dist/lib/components/toolbar/column-visibility-control.d.ts.map +1 -0
- package/dist/lib/components/toolbar/column-visibility-control.js +77 -0
- package/{src → dist}/lib/components/toolbar/data-table-toolbar.d.ts +3 -2
- package/dist/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/data-table-toolbar.js +17 -4
- package/{src → dist}/lib/components/toolbar/index.d.ts +4 -0
- package/dist/lib/components/toolbar/index.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/index.js +6 -0
- package/dist/lib/components/toolbar/table-export-control.d.ts +12 -0
- package/dist/lib/components/toolbar/table-export-control.d.ts.map +1 -0
- package/dist/lib/components/toolbar/table-export-control.js +67 -0
- package/{src → dist}/lib/components/toolbar/table-search-control.d.ts +3 -1
- package/dist/lib/components/toolbar/table-search-control.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/table-search-control.js +45 -2
- package/{src → dist}/lib/components/toolbar/table-size-control.d.ts +3 -1
- package/dist/lib/components/toolbar/table-size-control.d.ts.map +1 -0
- package/{src → dist}/lib/components/toolbar/table-size-control.js +20 -8
- package/{src → dist}/lib/contexts/data-table-context.d.ts +6 -2
- package/dist/lib/contexts/data-table-context.d.ts.map +1 -0
- package/{src → dist}/lib/contexts/data-table-context.js +34 -1
- package/dist/lib/data-table.d.ts +5 -0
- package/dist/lib/data-table.d.ts.map +1 -0
- package/{src/lib/components/table → dist/lib}/data-table.js +427 -143
- package/dist/lib/features/column-filter.feature.d.ts +55 -0
- package/dist/lib/features/column-filter.feature.d.ts.map +1 -0
- package/{src → dist}/lib/features/column-filter.feature.js +116 -18
- package/dist/lib/features/index.d.ts +9 -0
- package/dist/lib/features/index.d.ts.map +1 -0
- package/{src → dist}/lib/features/index.js +7 -0
- package/{src → dist}/lib/features/selection.feature.d.ts +8 -1
- package/dist/lib/features/selection.feature.d.ts.map +1 -0
- package/{src → dist}/lib/features/selection.feature.js +76 -15
- package/dist/lib/icons/add-icon.d.ts +4 -0
- package/dist/lib/icons/add-icon.d.ts.map +1 -0
- package/dist/lib/icons/add-icon.js +12 -0
- package/dist/lib/icons/csv-icon.d.ts +4 -0
- package/dist/lib/icons/csv-icon.d.ts.map +1 -0
- package/dist/lib/icons/csv-icon.js +12 -0
- package/dist/lib/icons/delete-icon.d.ts +4 -0
- package/dist/lib/icons/delete-icon.d.ts.map +1 -0
- package/dist/lib/icons/delete-icon.js +12 -0
- package/dist/lib/icons/excel-icon.d.ts +4 -0
- package/dist/lib/icons/excel-icon.d.ts.map +1 -0
- package/dist/lib/icons/excel-icon.js +12 -0
- package/dist/lib/icons/index.d.ts +8 -0
- package/dist/lib/icons/index.d.ts.map +1 -0
- package/dist/lib/icons/unpin-icon.d.ts +4 -0
- package/dist/lib/icons/unpin-icon.d.ts.map +1 -0
- package/dist/lib/icons/unpin-icon.js +12 -0
- package/{src → dist}/lib/icons/view-comfortable-icon.d.ts +3 -1
- package/dist/lib/icons/view-comfortable-icon.d.ts.map +1 -0
- package/dist/lib/icons/view-comfortable-icon.js +12 -0
- package/dist/lib/icons/view-compact-icon.d.ts +4 -0
- package/dist/lib/icons/view-compact-icon.d.ts.map +1 -0
- package/dist/lib/icons/view-compact-icon.js +12 -0
- package/{src → dist}/lib/types/column.types.d.ts +10 -1
- package/dist/lib/types/column.types.d.ts.map +1 -0
- package/{src → dist}/lib/types/data-table-api.d.ts +2 -1
- package/dist/lib/types/data-table-api.d.ts.map +1 -0
- package/{src/lib/components/table → dist/lib/types}/data-table.types.d.ts +10 -10
- package/dist/lib/types/data-table.types.d.ts.map +1 -0
- package/{src → dist}/lib/types/export.types.d.ts +38 -0
- package/dist/lib/types/export.types.d.ts.map +1 -0
- package/dist/lib/types/export.types.js +6 -0
- package/{src → dist}/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/index.js +30 -0
- package/{src → dist}/lib/types/slots.types.d.ts +50 -3
- package/dist/lib/types/slots.types.d.ts.map +1 -0
- package/{src → dist}/lib/types/table.types.d.ts +14 -0
- package/dist/lib/types/table.types.d.ts.map +1 -0
- package/{src → dist}/lib/utils/column-helpers.d.ts +10 -0
- package/dist/lib/utils/column-helpers.d.ts.map +1 -0
- package/{src → dist}/lib/utils/column-helpers.js +20 -4
- package/{src → dist}/lib/utils/debounced-fetch.utils.d.ts +3 -5
- package/dist/lib/utils/debounced-fetch.utils.d.ts.map +1 -0
- package/{src → dist}/lib/utils/debounced-fetch.utils.js +12 -6
- package/{src → dist}/lib/utils/export-utils.d.ts +13 -0
- package/dist/lib/utils/export-utils.d.ts.map +1 -0
- package/dist/lib/utils/export-utils.js +252 -0
- package/{src → dist}/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +35 -0
- package/{src → dist}/lib/utils/logger.d.ts +43 -0
- package/dist/lib/utils/logger.d.ts.map +1 -0
- package/{src → dist}/lib/utils/logger.js +22 -2
- package/{src → dist}/lib/utils/slot-helpers.d.ts +39 -1
- package/dist/lib/utils/slot-helpers.d.ts.map +1 -0
- package/{src → dist}/lib/utils/slot-helpers.js +55 -6
- package/{src → dist}/lib/utils/special-columns.utils.d.ts +10 -0
- package/dist/lib/utils/special-columns.utils.d.ts.map +1 -0
- package/{src → dist}/lib/utils/special-columns.utils.js +41 -5
- package/{src → dist}/lib/utils/styling-helpers.d.ts +20 -0
- package/dist/lib/utils/styling-helpers.d.ts.map +1 -0
- package/dist/lib/utils/styling-helpers.js +108 -0
- package/{src → dist}/lib/utils/table-helpers.d.ts +25 -0
- package/dist/lib/utils/table-helpers.d.ts.map +1 -0
- package/{src → dist}/lib/utils/table-helpers.js +24 -0
- package/package.json +36 -11
- package/src/index.ts +71 -0
- package/src/lib/components/droupdown/menu-dropdown.tsx +97 -0
- package/src/lib/components/filters/filter-value-input.tsx +225 -0
- package/src/lib/components/filters/{index.js → index.ts} +3 -6
- package/src/lib/components/headers/draggable-header.tsx +326 -0
- package/src/lib/components/headers/{index.d.ts → index.ts} +4 -0
- package/src/lib/components/headers/table-header.tsx +173 -0
- package/src/lib/components/index.ts +21 -0
- package/src/lib/components/pagination/data-table-pagination.tsx +99 -0
- package/src/lib/components/pagination/index.ts +5 -0
- package/src/lib/components/rows/data-table-row.tsx +208 -0
- package/src/lib/components/rows/empty-data-row.tsx +69 -0
- package/src/lib/components/rows/{index.d.ts → index.ts} +4 -0
- package/src/lib/components/rows/loading-rows.tsx +160 -0
- package/src/lib/components/toolbar/bulk-actions-toolbar.tsx +125 -0
- package/src/lib/components/toolbar/column-filter-control.tsx +374 -0
- package/src/lib/components/toolbar/column-pinning-control.tsx +275 -0
- package/src/lib/components/toolbar/column-reset-control.tsx +74 -0
- package/src/lib/components/toolbar/column-visibility-control.tsx +105 -0
- package/src/lib/components/toolbar/data-table-toolbar.tsx +229 -0
- package/src/lib/components/toolbar/index.ts +17 -0
- package/src/lib/components/toolbar/table-export-control.tsx +179 -0
- package/src/lib/components/toolbar/table-search-control.tsx +155 -0
- package/src/lib/components/toolbar/table-size-control.tsx +102 -0
- package/src/lib/contexts/data-table-context.tsx +112 -0
- package/src/lib/data-table.tsx +1911 -0
- package/src/lib/features/README.md +161 -0
- package/src/lib/features/column-filter.feature.ts +456 -0
- package/src/lib/features/index.ts +23 -0
- package/src/lib/features/selection.feature.ts +318 -0
- package/src/lib/icons/add-icon.tsx +23 -0
- package/src/lib/icons/csv-icon.tsx +15 -0
- package/src/lib/icons/delete-icon.tsx +30 -0
- package/src/lib/icons/excel-icon.tsx +15 -0
- package/src/lib/icons/unpin-icon.tsx +18 -0
- package/src/lib/icons/view-comfortable-icon.tsx +45 -0
- package/src/lib/icons/view-compact-icon.tsx +55 -0
- package/src/lib/types/column.types.ts +44 -0
- package/src/lib/types/data-table-api.ts +169 -0
- package/src/lib/types/data-table.types.ts +139 -0
- package/src/lib/types/export.types.ts +154 -0
- package/src/lib/types/index.ts +22 -0
- package/src/lib/types/slots.types.ts +332 -0
- package/src/lib/types/table.types.ts +90 -0
- package/src/lib/utils/column-helpers.ts +72 -0
- package/src/lib/utils/debounced-fetch.utils.ts +54 -0
- package/src/lib/utils/export-utils.ts +285 -0
- package/src/lib/utils/index.ts +27 -0
- package/src/lib/utils/logger.ts +203 -0
- package/src/lib/utils/slot-helpers.tsx +194 -0
- package/src/lib/utils/special-columns.utils.ts +94 -0
- package/src/lib/utils/styling-helpers.ts +126 -0
- package/src/lib/utils/table-helpers.ts +106 -0
- package/src/index.js +0 -27
- package/src/lib/components/filters/filter-value-input.js +0 -41
- package/src/lib/components/headers/index.js +0 -5
- package/src/lib/components/index.js +0 -10
- package/src/lib/components/pagination/index.d.ts +0 -1
- package/src/lib/components/pagination/index.js +0 -4
- package/src/lib/components/rows/index.js +0 -6
- package/src/lib/components/table/data-table.d.ts +0 -4
- package/src/lib/components/table/index.d.ts +0 -2
- package/src/lib/components/table/index.js +0 -5
- package/src/lib/components/toolbar/bulk-actions-toolbar.js +0 -30
- package/src/lib/components/toolbar/column-visibility-control.js +0 -31
- package/src/lib/components/toolbar/table-export-control.d.ts +0 -31
- package/src/lib/components/toolbar/table-export-control.js +0 -56
- package/src/lib/examples/advanced-features-example.d.ts +0 -1
- package/src/lib/examples/advanced-features-example.js +0 -269
- package/src/lib/examples/bulk-actions-test.d.ts +0 -1
- package/src/lib/examples/bulk-actions-test.js +0 -44
- package/src/lib/examples/custom-column-filter-example.d.ts +0 -1
- package/src/lib/examples/custom-column-filter-example.js +0 -60
- package/src/lib/examples/index.d.ts +0 -8
- package/src/lib/examples/index.js +0 -19
- package/src/lib/examples/selection-test-example.d.ts +0 -1
- package/src/lib/examples/selection-test-example.js +0 -101
- package/src/lib/examples/server-side-fetching-example.d.ts +0 -1
- package/src/lib/examples/server-side-fetching-example.js +0 -245
- package/src/lib/examples/server-side-test.d.ts +0 -1
- package/src/lib/examples/server-side-test.js +0 -9
- package/src/lib/examples/simple-local-example.d.ts +0 -1
- package/src/lib/examples/simple-local-example.js +0 -95
- package/src/lib/examples/simple-slots-example.d.ts +0 -1
- package/src/lib/examples/simple-slots-example.js +0 -115
- package/src/lib/features/column-filter.feature.d.ts +0 -45
- package/src/lib/features/index.d.ts +0 -2
- package/src/lib/hooks/index.d.ts +0 -1
- package/src/lib/hooks/index.js +0 -4
- package/src/lib/hooks/use-data-table-api.d.ts +0 -46
- package/src/lib/hooks/use-data-table-api.js +0 -690
- package/src/lib/icons/add-icon.d.ts +0 -2
- package/src/lib/icons/add-icon.js +0 -8
- package/src/lib/icons/csv-icon.d.ts +0 -2
- package/src/lib/icons/csv-icon.js +0 -8
- package/src/lib/icons/delete-icon.d.ts +0 -2
- package/src/lib/icons/delete-icon.js +0 -8
- package/src/lib/icons/excel-icon.d.ts +0 -2
- package/src/lib/icons/excel-icon.js +0 -8
- package/src/lib/icons/unpin-icon.d.ts +0 -2
- package/src/lib/icons/unpin-icon.js +0 -8
- package/src/lib/icons/view-comfortable-icon.js +0 -8
- package/src/lib/icons/view-compact-icon.d.ts +0 -2
- package/src/lib/icons/view-compact-icon.js +0 -8
- package/src/lib/types/export.types.js +0 -2
- package/src/lib/types/index.js +0 -8
- package/src/lib/utils/export-utils.js +0 -175
- package/src/lib/utils/index.js +0 -11
- package/src/lib/utils/styling-helpers.js +0 -70
- package/tsconfig.tsbuildinfo +0 -1
- /package/{src → dist}/lib/icons/index.js +0 -0
- /package/{src → dist}/lib/types/column.types.js +0 -0
- /package/{src → dist}/lib/types/data-table-api.js +0 -0
- /package/{src/lib/components/table → dist/lib/types}/data-table.types.js +0 -0
- /package/{src → dist}/lib/types/slots.types.js +0 -0
- /package/{src → dist}/lib/types/table.types.js +0 -0
- /package/src/lib/icons/{index.d.ts → index.ts} +0 -0
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column utilities for DataTable components
|
|
3
|
+
*/
|
|
1
4
|
import { Column, ColumnDef } from "@tanstack/react-table";
|
|
2
5
|
export type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'select' | 'actions';
|
|
6
|
+
/**
|
|
7
|
+
* Get the type of a column from its metadata
|
|
8
|
+
*/
|
|
3
9
|
export declare function getColumnType(column: Column<any, unknown>): ColumnType;
|
|
4
10
|
export declare function getCustomFilterComponent(column: Column<any, unknown>): any;
|
|
5
11
|
export declare function getColumnOptions(column: Column<any, unknown>): any[];
|
|
6
12
|
export declare function withIdsDeep<T>(cols: ColumnDef<T, any>[]): ColumnDef<T, any>[];
|
|
13
|
+
/**
|
|
14
|
+
* Determine if a column should be filterable
|
|
15
|
+
*/
|
|
7
16
|
export declare function isColumnFilterable(column: Column<any, unknown>): boolean;
|
|
17
|
+
//# sourceMappingURL=column-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/column-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEvF;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,UAAU,CAMtE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,GAAG,CAG1E;AAGD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,GAAG,EAAE,CAsBpE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAQ7E;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,OAAO,CAQxE"}
|
|
@@ -5,22 +5,29 @@ exports.getCustomFilterComponent = getCustomFilterComponent;
|
|
|
5
5
|
exports.getColumnOptions = getColumnOptions;
|
|
6
6
|
exports.withIdsDeep = withIdsDeep;
|
|
7
7
|
exports.isColumnFilterable = isColumnFilterable;
|
|
8
|
+
/**
|
|
9
|
+
* Get the type of a column from its metadata
|
|
10
|
+
*/
|
|
8
11
|
function getColumnType(column) {
|
|
9
12
|
var _a;
|
|
13
|
+
// Check if column has explicit type in columnDef
|
|
10
14
|
if ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.type) {
|
|
11
15
|
return column.columnDef.type;
|
|
12
16
|
}
|
|
13
|
-
return 'text';
|
|
17
|
+
return 'text'; // Default to text
|
|
14
18
|
}
|
|
15
19
|
function getCustomFilterComponent(column) {
|
|
16
20
|
var _a, _b;
|
|
21
|
+
// Check if column has custom filter component in meta
|
|
17
22
|
return ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.filterComponent) || ((_b = column === null || column === void 0 ? void 0 : column.columnDef) === null || _b === void 0 ? void 0 : _b.editComponent);
|
|
18
23
|
}
|
|
19
24
|
function getColumnOptions(column) {
|
|
20
25
|
var _a;
|
|
26
|
+
// Check if column has explicit options in meta
|
|
21
27
|
if ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.options) {
|
|
22
28
|
return (column === null || column === void 0 ? void 0 : column.columnDef.options) || [];
|
|
23
29
|
}
|
|
30
|
+
// Default options for boolean type
|
|
24
31
|
const columnType = getColumnType(column);
|
|
25
32
|
if (columnType === 'boolean') {
|
|
26
33
|
return [
|
|
@@ -39,15 +46,24 @@ function getColumnOptions(column) {
|
|
|
39
46
|
function withIdsDeep(cols) {
|
|
40
47
|
return cols.map((c, i) => {
|
|
41
48
|
var _a, _b;
|
|
42
|
-
return (
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
return ({
|
|
50
|
+
...c,
|
|
51
|
+
id: (_b = (_a = c.id) !== null && _a !== void 0 ? _a : c.accessorKey) !== null && _b !== void 0 ? _b : `col_${i}`,
|
|
52
|
+
...(Array.isArray(c.columns) && {
|
|
53
|
+
columns: withIdsDeep(c.columns)
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
45
56
|
});
|
|
46
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Determine if a column should be filterable
|
|
60
|
+
*/
|
|
47
61
|
function isColumnFilterable(column) {
|
|
48
62
|
var _a, _b;
|
|
63
|
+
// Check if column is explicitly marked as filterable
|
|
49
64
|
if (((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.filterable) !== undefined) {
|
|
50
65
|
return (_b = column === null || column === void 0 ? void 0 : column.columnDef) === null || _b === void 0 ? void 0 : _b.filterable;
|
|
51
66
|
}
|
|
67
|
+
// Default to filterable for data columns
|
|
52
68
|
return true;
|
|
53
69
|
}
|
|
@@ -3,9 +3,7 @@ export declare function useDebouncedFetch<T extends Record<string, any>>(onFetch
|
|
|
3
3
|
data: T[];
|
|
4
4
|
total: number;
|
|
5
5
|
}>) | undefined, delay?: number): {
|
|
6
|
-
debouncedFetch:
|
|
7
|
-
|
|
8
|
-
total: number;
|
|
9
|
-
}>;
|
|
10
|
-
isLoading: boolean;
|
|
6
|
+
debouncedFetch: any;
|
|
7
|
+
isLoading: any;
|
|
11
8
|
};
|
|
9
|
+
//# sourceMappingURL=debounced-fetch.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounced-fetch.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/debounced-fetch.utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3D,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAAG,SAAS,EACnG,KAAK,SAAM;;;EA8Cd"}
|
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDebouncedFetch = useDebouncedFetch;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const react_1 = require("react");
|
|
6
5
|
function useDebouncedFetch(onFetchData, delay = 300) {
|
|
7
6
|
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
8
7
|
const debounceTimer = (0, react_1.useRef)(null);
|
|
9
|
-
const debouncedFetch = (0, react_1.useCallback)((filters) =>
|
|
8
|
+
const debouncedFetch = (0, react_1.useCallback)(async (filters) => {
|
|
10
9
|
if (!onFetchData)
|
|
11
10
|
return null;
|
|
11
|
+
// Create a unique key for the current fetch parameters
|
|
12
|
+
// const currentParams = JSON.stringify(filters);
|
|
13
|
+
// Clear existing timer
|
|
12
14
|
if (debounceTimer.current) {
|
|
13
15
|
clearTimeout(debounceTimer.current);
|
|
14
16
|
}
|
|
15
17
|
return new Promise((resolve) => {
|
|
16
|
-
debounceTimer.current = setTimeout(() =>
|
|
18
|
+
debounceTimer.current = setTimeout(async () => {
|
|
17
19
|
setIsLoading(true);
|
|
18
20
|
try {
|
|
19
|
-
const result =
|
|
21
|
+
const result = await onFetchData(filters);
|
|
20
22
|
resolve(result);
|
|
21
23
|
}
|
|
22
24
|
catch (error) {
|
|
25
|
+
// Handle fetch error silently or could be passed to onError callback
|
|
26
|
+
console.error('Error fetching data:', error);
|
|
23
27
|
resolve(null);
|
|
24
28
|
}
|
|
25
29
|
finally {
|
|
26
30
|
setIsLoading(false);
|
|
27
31
|
}
|
|
28
|
-
}
|
|
32
|
+
}, delay);
|
|
29
33
|
});
|
|
30
|
-
}
|
|
34
|
+
}, [onFetchData, delay]);
|
|
35
|
+
// Cleanup timer on unmount
|
|
31
36
|
(0, react_1.useEffect)(() => {
|
|
37
|
+
// Fetch data when dependencies change
|
|
32
38
|
return () => {
|
|
33
39
|
if (debounceTimer.current) {
|
|
34
40
|
clearTimeout(debounceTimer.current);
|
|
@@ -26,5 +26,18 @@ export interface ServerExportOptions extends ExportOptions {
|
|
|
26
26
|
currentFilters?: any;
|
|
27
27
|
selection?: SelectionState;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Export data for client-side tables
|
|
31
|
+
* - If rows are selected, export only selected rows
|
|
32
|
+
* - Otherwise export all filtered/visible rows
|
|
33
|
+
* - Only export visible columns
|
|
34
|
+
*/
|
|
29
35
|
export declare function exportClientData<TData>(table: Table<TData>, options: ExportOptions): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Export data for server-side tables
|
|
38
|
+
* - Fetch data using provided fetchData function
|
|
39
|
+
* - Pass selection information to server for filtering
|
|
40
|
+
* - Export all returned data (server handles selection/filtering)
|
|
41
|
+
*/
|
|
30
42
|
export declare function exportServerData<TData>(table: Table<TData>, options: ServerExportOptions): Promise<void>;
|
|
43
|
+
//# sourceMappingURL=export-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/export-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrG,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACzF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAChE;AAGD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACtD,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClG,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EACxC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EACnB,OAAO,EAAE,aAAa,GACvB,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EACxC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EACnB,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAkHf"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.exportClientData = exportClientData;
|
|
37
|
+
exports.exportServerData = exportServerData;
|
|
38
|
+
const XLSX = __importStar(require("xlsx"));
|
|
39
|
+
/**
|
|
40
|
+
* Export data for client-side tables
|
|
41
|
+
* - If rows are selected, export only selected rows
|
|
42
|
+
* - Otherwise export all filtered/visible rows
|
|
43
|
+
* - Only export visible columns
|
|
44
|
+
*/
|
|
45
|
+
async function exportClientData(table, options) {
|
|
46
|
+
const { format, filename, onProgress, onComplete, onError } = options;
|
|
47
|
+
try {
|
|
48
|
+
// Get selected rows if any are selected
|
|
49
|
+
// const selectedRowIds = Object.keys(table.getState().rowSelection).filter(
|
|
50
|
+
// key => table.getState().rowSelection[key]
|
|
51
|
+
// );
|
|
52
|
+
// const hasSelectedRows = selectedRowIds.length > 0;
|
|
53
|
+
// // Get the rows to export
|
|
54
|
+
// const rowsToExport = hasSelectedRows ? table.getSelectedRowModel().rows : table.getFilteredRowModel().rows;
|
|
55
|
+
const selectedRows = table.getSelectedRows ? table.getSelectedRows() : [];
|
|
56
|
+
const hasSelectedRows = selectedRows.length > 0;
|
|
57
|
+
const rowsToExport = hasSelectedRows ? selectedRows : table.getFilteredRowModel().rows;
|
|
58
|
+
// Prepare data for export - get all visible columns and their values, excluding hideInExport columns
|
|
59
|
+
const exportData = rowsToExport.map((row, index) => {
|
|
60
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
61
|
+
processedRows: index + 1,
|
|
62
|
+
totalRows: rowsToExport.length,
|
|
63
|
+
percentage: Math.round(((index + 1) / rowsToExport.length) * 100),
|
|
64
|
+
});
|
|
65
|
+
const rowData = {};
|
|
66
|
+
// Get all visible cells for this row, excluding columns marked as hideInExport
|
|
67
|
+
row.getVisibleCells().forEach(cell => {
|
|
68
|
+
const columnDef = cell.column.columnDef;
|
|
69
|
+
// Skip columns marked as hideInExport
|
|
70
|
+
if (columnDef.hideInExport === true) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const header = typeof columnDef.header === 'string' ? columnDef.header : cell.column.id;
|
|
74
|
+
// Use getValue() - it already handles all formatting
|
|
75
|
+
rowData[header] = cell.getValue() || '';
|
|
76
|
+
});
|
|
77
|
+
return rowData;
|
|
78
|
+
});
|
|
79
|
+
// Export the data
|
|
80
|
+
await exportToFile(exportData, format, filename);
|
|
81
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete({
|
|
82
|
+
success: true,
|
|
83
|
+
filename: `${filename}.${format === 'excel' ? 'xlsx' : 'csv'}`,
|
|
84
|
+
totalRows: exportData.length,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error('Client export failed:', error);
|
|
89
|
+
onError === null || onError === void 0 ? void 0 : onError({
|
|
90
|
+
message: error instanceof Error ? error.message : 'Export failed',
|
|
91
|
+
code: 'CLIENT_EXPORT_ERROR',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Export data for server-side tables
|
|
97
|
+
* - Fetch data using provided fetchData function
|
|
98
|
+
* - Pass selection information to server for filtering
|
|
99
|
+
* - Export all returned data (server handles selection/filtering)
|
|
100
|
+
*/
|
|
101
|
+
async function exportServerData(table, options) {
|
|
102
|
+
const { format, filename, fetchData, currentFilters, selection, onProgress, onComplete, onError } = options;
|
|
103
|
+
try {
|
|
104
|
+
// Initial progress
|
|
105
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({});
|
|
106
|
+
// First, get total count to determine if we need chunking
|
|
107
|
+
const initialResponse = await fetchData({
|
|
108
|
+
...currentFilters,
|
|
109
|
+
pagination: { pageIndex: 0, pageSize: 1 }
|
|
110
|
+
}, selection);
|
|
111
|
+
if (!initialResponse || !initialResponse.data || !Array.isArray(initialResponse.data)) {
|
|
112
|
+
throw new Error('Invalid data received from server');
|
|
113
|
+
}
|
|
114
|
+
const totalRows = initialResponse.total || initialResponse.data.length;
|
|
115
|
+
const CHUNK_SIZE = 1000; // Fetch 1000 rows per request
|
|
116
|
+
const needsChunking = totalRows > CHUNK_SIZE;
|
|
117
|
+
let allData = [];
|
|
118
|
+
if (needsChunking) {
|
|
119
|
+
// Fetch data in chunks (no progress events during fetching)
|
|
120
|
+
const totalPages = Math.ceil(totalRows / CHUNK_SIZE);
|
|
121
|
+
for (let page = 1; page <= totalPages; page++) {
|
|
122
|
+
// Fetch current chunk
|
|
123
|
+
const chunkFilters = {
|
|
124
|
+
...currentFilters,
|
|
125
|
+
pagination: {
|
|
126
|
+
pageIndex: page - 1,
|
|
127
|
+
pageSize: CHUNK_SIZE,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
const chunkResponse = await fetchData(chunkFilters, selection);
|
|
131
|
+
if (!chunkResponse || !chunkResponse.data || !Array.isArray(chunkResponse.data)) {
|
|
132
|
+
throw new Error(`Failed to fetch chunk ${page}`);
|
|
133
|
+
}
|
|
134
|
+
allData = [...allData, ...chunkResponse.data];
|
|
135
|
+
// Small delay to prevent overwhelming the server
|
|
136
|
+
if (page < totalPages) {
|
|
137
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Small dataset, use single request
|
|
143
|
+
allData = initialResponse.data;
|
|
144
|
+
}
|
|
145
|
+
// Get visible columns for proper headers and data processing, excluding hideInExport columns
|
|
146
|
+
const visibleColumns = table.getVisibleLeafColumns().filter(col => {
|
|
147
|
+
const columnDef = col.columnDef;
|
|
148
|
+
return col.getIsVisible() && columnDef.hideInExport !== true;
|
|
149
|
+
});
|
|
150
|
+
// Prepare data for export with proper column processing
|
|
151
|
+
const exportData = [];
|
|
152
|
+
for (let index = 0; index < allData.length; index++) {
|
|
153
|
+
const rowData = allData[index];
|
|
154
|
+
const exportRow = {};
|
|
155
|
+
visibleColumns.forEach(column => {
|
|
156
|
+
var _a;
|
|
157
|
+
const columnId = column.id;
|
|
158
|
+
const columnDef = column.columnDef;
|
|
159
|
+
const header = typeof columnDef.header === 'string'
|
|
160
|
+
? columnDef.header
|
|
161
|
+
: columnId;
|
|
162
|
+
// Get value from raw data
|
|
163
|
+
let value = rowData[columnId];
|
|
164
|
+
// Apply accessorFn if defined
|
|
165
|
+
if (column.accessorFn && typeof column.accessorFn === 'function') {
|
|
166
|
+
value = ((_a = (column.accessorFn(rowData, index) || '')) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
167
|
+
}
|
|
168
|
+
// Convert to string for export
|
|
169
|
+
if (value === null || value === undefined) {
|
|
170
|
+
value = '';
|
|
171
|
+
}
|
|
172
|
+
else if (typeof value === 'object') {
|
|
173
|
+
value = JSON.stringify(value);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
value = String(value);
|
|
177
|
+
}
|
|
178
|
+
exportRow[header] = value;
|
|
179
|
+
});
|
|
180
|
+
exportData.push(exportRow);
|
|
181
|
+
}
|
|
182
|
+
await exportToFile(exportData, format, filename);
|
|
183
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete({
|
|
184
|
+
success: true,
|
|
185
|
+
filename: `${filename}.${format === 'excel' ? 'xlsx' : 'csv'}`,
|
|
186
|
+
totalRows: exportData.length,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error('Server export failed:', error);
|
|
191
|
+
onError === null || onError === void 0 ? void 0 : onError({
|
|
192
|
+
message: error instanceof Error ? error.message : 'Export failed',
|
|
193
|
+
code: 'SERVER_EXPORT_ERROR',
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Export data to file (CSV or Excel)
|
|
199
|
+
*/
|
|
200
|
+
async function exportToFile(data, format, filename) {
|
|
201
|
+
if (data.length === 0) {
|
|
202
|
+
throw new Error('No data to export');
|
|
203
|
+
}
|
|
204
|
+
if (format === 'csv') {
|
|
205
|
+
const csv = convertToCSV(data);
|
|
206
|
+
downloadFile(csv, `${filename}.csv`, 'text/csv');
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const workbook = XLSX.utils.book_new();
|
|
210
|
+
const worksheet = XLSX.utils.json_to_sheet(data);
|
|
211
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, 'Data');
|
|
212
|
+
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
|
|
213
|
+
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
|
214
|
+
downloadFile(blob, `${filename}.xlsx`, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Convert data to CSV format
|
|
219
|
+
*/
|
|
220
|
+
function convertToCSV(data) {
|
|
221
|
+
if (data.length === 0)
|
|
222
|
+
return '';
|
|
223
|
+
const headers = Object.keys(data[0]);
|
|
224
|
+
const csvRows = [headers.join(',')];
|
|
225
|
+
for (const row of data) {
|
|
226
|
+
const values = headers.map(header => {
|
|
227
|
+
const value = row[header] || '';
|
|
228
|
+
// Escape quotes and wrap in quotes if contains comma or quote
|
|
229
|
+
if (typeof value === 'string' && (value.includes(',') || value.includes('"') || value.includes('\n'))) {
|
|
230
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
231
|
+
}
|
|
232
|
+
return value;
|
|
233
|
+
});
|
|
234
|
+
csvRows.push(values.join(','));
|
|
235
|
+
}
|
|
236
|
+
return csvRows.join('\n');
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Download file to user's device
|
|
240
|
+
*/
|
|
241
|
+
function downloadFile(content, filename, mimeType) {
|
|
242
|
+
const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });
|
|
243
|
+
const url = URL.createObjectURL(blob);
|
|
244
|
+
const link = document.createElement('a');
|
|
245
|
+
link.href = url;
|
|
246
|
+
link.download = filename;
|
|
247
|
+
link.style.display = 'none';
|
|
248
|
+
document.body.appendChild(link);
|
|
249
|
+
link.click();
|
|
250
|
+
document.body.removeChild(link);
|
|
251
|
+
URL.revokeObjectURL(url);
|
|
252
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for DataTable components
|
|
3
|
+
*/
|
|
1
4
|
export * from './styling-helpers';
|
|
2
5
|
export * from './table-helpers';
|
|
3
6
|
export * from './column-helpers';
|
|
@@ -6,3 +9,4 @@ export * from './special-columns.utils';
|
|
|
6
9
|
export * from './debounced-fetch.utils';
|
|
7
10
|
export * from './slot-helpers';
|
|
8
11
|
export * from './logger';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,yBAAyB,CAAC;AAGxC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for DataTable components
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
// Styling utilities
|
|
21
|
+
__exportStar(require("./styling-helpers"), exports);
|
|
22
|
+
// Table utilities
|
|
23
|
+
__exportStar(require("./table-helpers"), exports);
|
|
24
|
+
// Column utilities
|
|
25
|
+
__exportStar(require("./column-helpers"), exports);
|
|
26
|
+
// Export utilities
|
|
27
|
+
__exportStar(require("./export-utils"), exports);
|
|
28
|
+
// Special columns utilities
|
|
29
|
+
__exportStar(require("./special-columns.utils"), exports);
|
|
30
|
+
// Debounced fetch utilities
|
|
31
|
+
__exportStar(require("./debounced-fetch.utils"), exports);
|
|
32
|
+
// Slot helper utilities
|
|
33
|
+
__exportStar(require("./slot-helpers"), exports);
|
|
34
|
+
// Logging utilities
|
|
35
|
+
__exportStar(require("./logger"), exports);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utilities for the DataTable package.
|
|
3
|
+
*
|
|
4
|
+
* Provides a lightweight wrapper around `console` that can be configured globally
|
|
5
|
+
* or per-instance to help troubleshoot behaviour in consuming applications.
|
|
6
|
+
*/
|
|
1
7
|
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
2
8
|
interface ConsoleLike {
|
|
3
9
|
debug?: (...args: unknown[]) => void;
|
|
@@ -7,11 +13,29 @@ interface ConsoleLike {
|
|
|
7
13
|
log?: (...args: unknown[]) => void;
|
|
8
14
|
}
|
|
9
15
|
export interface DataTableLoggingOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Whether logging should be enabled.
|
|
18
|
+
*/
|
|
10
19
|
enabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Minimum level that will be emitted. Defaults to `warn`.
|
|
22
|
+
*/
|
|
11
23
|
level?: LogLevel;
|
|
24
|
+
/**
|
|
25
|
+
* Prefix prepended to every log message. Defaults to `DataTable`.
|
|
26
|
+
*/
|
|
12
27
|
prefix?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional scope that will be appended after the prefix when present.
|
|
30
|
+
*/
|
|
13
31
|
scope?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Include an ISO timestamp ahead of each log line.
|
|
34
|
+
*/
|
|
14
35
|
includeTimestamp?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A custom logger implementation. Defaults to `console`.
|
|
38
|
+
*/
|
|
15
39
|
logger?: ConsoleLike;
|
|
16
40
|
}
|
|
17
41
|
type LoggerInput = boolean | DataTableLoggingOptions;
|
|
@@ -24,11 +48,30 @@ export interface LoggerInstance {
|
|
|
24
48
|
info: (...args: unknown[]) => void;
|
|
25
49
|
warn: (...args: unknown[]) => void;
|
|
26
50
|
error: (...args: unknown[]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new logger that inherits configuration and extends the scope.
|
|
53
|
+
*/
|
|
27
54
|
child: (scope: string, overrides?: LoggerInput) => LoggerInstance;
|
|
55
|
+
/**
|
|
56
|
+
* Check whether a level would emit given current configuration.
|
|
57
|
+
*/
|
|
28
58
|
isLevelEnabled: (level: LogMethodLevel) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Access the resolved configuration for inspection.
|
|
61
|
+
*/
|
|
29
62
|
config: ResolvedLoggerConfig;
|
|
30
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a new logger instance. Configuration cascades from the global config unless overridden.
|
|
66
|
+
*/
|
|
31
67
|
export declare const createLogger: (scope?: string, input?: LoggerInput, parentConfig?: ResolvedLoggerConfig) => LoggerInstance;
|
|
68
|
+
/**
|
|
69
|
+
* Configure the global logger defaults for every DataTable instance.
|
|
70
|
+
*/
|
|
32
71
|
export declare const configureDataTableLogging: (options: DataTableLoggingOptions) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Read the current global logging configuration.
|
|
74
|
+
*/
|
|
33
75
|
export declare const getDataTableLoggingConfig: () => ResolvedLoggerConfig;
|
|
34
76
|
export {};
|
|
77
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE,UAAU,WAAW;IACjB,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC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OAEG;IACH,MAAM,EAAE,oBAAoB,CAAC;CAChC;AAsBD;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,QAAQ,WAAW,EAAE,eAAe,oBAAoB,KAAG,cAiBvG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,uBAAuB,SAEzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAO,oBAA6C,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logging utilities for the DataTable package.
|
|
4
|
+
*
|
|
5
|
+
* Provides a lightweight wrapper around `console` that can be configured globally
|
|
6
|
+
* or per-instance to help troubleshoot behaviour in consuming applications.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.getDataTableLoggingConfig = exports.configureDataTableLogging = exports.createLogger = void 0;
|
|
4
10
|
const LOG_LEVEL_ORDER = {
|
|
@@ -86,6 +92,9 @@ const createLoggerMethods = (config) => {
|
|
|
86
92
|
error: logWithLevel('error'),
|
|
87
93
|
};
|
|
88
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Create a new logger instance. Configuration cascades from the global config unless overridden.
|
|
97
|
+
*/
|
|
89
98
|
const createLogger = (scope, input, parentConfig) => {
|
|
90
99
|
const resolvedConfig = resolveConfig(scope, input, parentConfig);
|
|
91
100
|
const methods = createLoggerMethods(resolvedConfig);
|
|
@@ -95,12 +104,23 @@ const createLogger = (scope, input, parentConfig) => {
|
|
|
95
104
|
: resolvedConfig.scope;
|
|
96
105
|
return (0, exports.createLogger)(combinedScope, overrides, resolvedConfig);
|
|
97
106
|
};
|
|
98
|
-
return
|
|
107
|
+
return {
|
|
108
|
+
...methods,
|
|
109
|
+
child,
|
|
110
|
+
isLevelEnabled: (level) => isLevelEnabled(level, resolvedConfig),
|
|
111
|
+
config: resolvedConfig,
|
|
112
|
+
};
|
|
99
113
|
};
|
|
100
114
|
exports.createLogger = createLogger;
|
|
115
|
+
/**
|
|
116
|
+
* Configure the global logger defaults for every DataTable instance.
|
|
117
|
+
*/
|
|
101
118
|
const configureDataTableLogging = (options) => {
|
|
102
119
|
globalConfig = resolveConfig(options.scope, options, globalConfig);
|
|
103
120
|
};
|
|
104
121
|
exports.configureDataTableLogging = configureDataTableLogging;
|
|
105
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Read the current global logging configuration.
|
|
124
|
+
*/
|
|
125
|
+
const getDataTableLoggingConfig = () => ({ ...globalConfig });
|
|
106
126
|
exports.getDataTableLoggingConfig = getDataTableLoggingConfig;
|
|
@@ -1,15 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Slot Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities to help with rendering slotted components with enhanced prop merging,
|
|
5
|
+
* type safety, and full customization support.
|
|
6
|
+
*/
|
|
1
7
|
import { ComponentType } from 'react';
|
|
2
8
|
import { DataTableSlots } from '../types/slots.types';
|
|
9
|
+
/**
|
|
10
|
+
* Enhanced slot component retrieval with better type safety
|
|
11
|
+
*/
|
|
3
12
|
export declare function getSlotComponent<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K, fallback: ComponentType<any>): ComponentType<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Merge slot props with default props and user overrides
|
|
15
|
+
* Handles special cases for MUI sx prop, style prop, and className
|
|
16
|
+
*/
|
|
4
17
|
export declare function mergeSlotProps(defaultProps?: Record<string, any>, slotProps?: Record<string, any>, userProps?: Record<string, any>): Record<string, any>;
|
|
18
|
+
/**
|
|
19
|
+
* Enhanced slot component retrieval with automatic prop merging
|
|
20
|
+
*/
|
|
5
21
|
export declare function getSlotComponentWithProps<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotProps: Record<string, any>, slotName: K, fallback: ComponentType<any>, defaultProps?: Record<string, any>): {
|
|
6
22
|
component: ComponentType<any>;
|
|
7
23
|
props: Record<string, any>;
|
|
8
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Utility to check if a slot is overridden by user
|
|
27
|
+
*/
|
|
9
28
|
export declare function isSlotOverridden<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Utility to get all overridden slots
|
|
31
|
+
*/
|
|
10
32
|
export declare function getOverriddenSlots<T>(slots: Partial<DataTableSlots<T>> | undefined): Array<keyof DataTableSlots<T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Type-safe slot prop extractor
|
|
35
|
+
*/
|
|
11
36
|
export declare function extractSlotProps<T, K extends keyof DataTableSlots<T>>(slotProps: Record<string, any> | undefined, slotName: K): Record<string, any>;
|
|
37
|
+
/**
|
|
38
|
+
* Enhanced slot component with better prop handling
|
|
39
|
+
*/
|
|
12
40
|
export declare function createEnhancedSlotComponent<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K, fallback: ComponentType<any>, baseProps?: Record<string, any>): ComponentType<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Utility to validate slot props at runtime (development only)
|
|
43
|
+
*/
|
|
13
44
|
export declare function validateSlotProps<T, K extends keyof DataTableSlots<T>>(slotName: K, props: any, requiredProps?: string[]): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Helper to create slot props with proper typing
|
|
47
|
+
*/
|
|
14
48
|
export declare function createSlotProps<T>(table: any, additionalProps?: Record<string, any>): Record<string, any>;
|
|
15
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Enhanced slot component wrapper that handles all prop merging automatically
|
|
51
|
+
*/
|
|
52
|
+
export declare function withSlotProps<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotProps: Record<string, any>, slotName: K, fallback: ComponentType<any>): (props: any) => any;
|
|
53
|
+
//# sourceMappingURL=slot-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