@ackplus/react-tanstack-data-table 1.0.35 → 1.1.3
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 -11
- 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 +6 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/index.js +32 -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 +136 -0
- package/src/lib/types/export.types.ts +154 -0
- package/src/lib/types/index.ts +24 -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
|
@@ -10,38 +10,60 @@ exports.createEnhancedSlotComponent = createEnhancedSlotComponent;
|
|
|
10
10
|
exports.validateSlotProps = validateSlotProps;
|
|
11
11
|
exports.createSlotProps = createSlotProps;
|
|
12
12
|
exports.withSlotProps = withSlotProps;
|
|
13
|
+
/**
|
|
14
|
+
* Enhanced Slot Helper Utilities
|
|
15
|
+
*
|
|
16
|
+
* Utilities to help with rendering slotted components with enhanced prop merging,
|
|
17
|
+
* type safety, and full customization support.
|
|
18
|
+
*/
|
|
13
19
|
const react_1 = require("react");
|
|
20
|
+
/**
|
|
21
|
+
* Enhanced slot component retrieval with better type safety
|
|
22
|
+
*/
|
|
14
23
|
function getSlotComponent(slots, slotName, fallback) {
|
|
15
24
|
return (slots === null || slots === void 0 ? void 0 : slots[slotName]) || fallback;
|
|
16
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Merge slot props with default props and user overrides
|
|
28
|
+
* Handles special cases for MUI sx prop, style prop, and className
|
|
29
|
+
*/
|
|
17
30
|
function mergeSlotProps(defaultProps = {}, slotProps = {}, userProps = {}) {
|
|
18
|
-
|
|
31
|
+
// Deep merge objects, giving priority to user props
|
|
32
|
+
const merged = { ...defaultProps };
|
|
33
|
+
// Merge slot props
|
|
19
34
|
Object.keys(slotProps).forEach(key => {
|
|
20
35
|
const slotValue = slotProps[key];
|
|
21
36
|
const mergedValue = merged[key];
|
|
22
37
|
if (key === 'sx' && typeof slotValue === 'object' && typeof mergedValue === 'object') {
|
|
23
|
-
|
|
38
|
+
// Special handling for MUI sx prop
|
|
39
|
+
merged[key] = { ...mergedValue, ...slotValue };
|
|
24
40
|
}
|
|
25
41
|
else if (key === 'style' && typeof slotValue === 'object' && typeof mergedValue === 'object') {
|
|
26
|
-
|
|
42
|
+
// Special handling for style prop
|
|
43
|
+
merged[key] = { ...mergedValue, ...slotValue };
|
|
27
44
|
}
|
|
28
45
|
else if (key === 'className' && typeof slotValue === 'string' && typeof mergedValue === 'string') {
|
|
46
|
+
// Special handling for className prop
|
|
29
47
|
merged[key] = `${mergedValue} ${slotValue}`.trim();
|
|
30
48
|
}
|
|
31
49
|
else {
|
|
32
50
|
merged[key] = slotValue;
|
|
33
51
|
}
|
|
34
52
|
});
|
|
53
|
+
// Merge user props (highest priority)
|
|
35
54
|
Object.keys(userProps).forEach(key => {
|
|
36
55
|
const userValue = userProps[key];
|
|
37
56
|
const mergedValue = merged[key];
|
|
38
57
|
if (key === 'sx' && typeof userValue === 'object' && typeof mergedValue === 'object') {
|
|
39
|
-
|
|
58
|
+
// Special handling for MUI sx prop
|
|
59
|
+
merged[key] = { ...mergedValue, ...userValue };
|
|
40
60
|
}
|
|
41
61
|
else if (key === 'style' && typeof userValue === 'object' && typeof mergedValue === 'object') {
|
|
42
|
-
|
|
62
|
+
// Special handling for style prop
|
|
63
|
+
merged[key] = { ...mergedValue, ...userValue };
|
|
43
64
|
}
|
|
44
65
|
else if (key === 'className' && typeof userValue === 'string' && typeof mergedValue === 'string') {
|
|
66
|
+
// Special handling for className prop
|
|
45
67
|
merged[key] = `${mergedValue} ${userValue}`.trim();
|
|
46
68
|
}
|
|
47
69
|
else {
|
|
@@ -50,22 +72,37 @@ function mergeSlotProps(defaultProps = {}, slotProps = {}, userProps = {}) {
|
|
|
50
72
|
});
|
|
51
73
|
return merged;
|
|
52
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Enhanced slot component retrieval with automatic prop merging
|
|
77
|
+
*/
|
|
53
78
|
function getSlotComponentWithProps(slots, slotProps = {}, slotName, fallback, defaultProps = {}) {
|
|
54
79
|
const component = getSlotComponent(slots, slotName, fallback);
|
|
55
80
|
const props = mergeSlotProps(defaultProps, slotProps[slotName] || {}, {});
|
|
56
81
|
return { component, props };
|
|
57
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Utility to check if a slot is overridden by user
|
|
85
|
+
*/
|
|
58
86
|
function isSlotOverridden(slots, slotName) {
|
|
59
87
|
return Boolean(slots === null || slots === void 0 ? void 0 : slots[slotName]);
|
|
60
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Utility to get all overridden slots
|
|
91
|
+
*/
|
|
61
92
|
function getOverriddenSlots(slots) {
|
|
62
93
|
if (!slots)
|
|
63
94
|
return [];
|
|
64
95
|
return Object.keys(slots).filter(key => Boolean(slots[key]));
|
|
65
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Type-safe slot prop extractor
|
|
99
|
+
*/
|
|
66
100
|
function extractSlotProps(slotProps, slotName) {
|
|
67
101
|
return ((slotProps === null || slotProps === void 0 ? void 0 : slotProps[slotName]) || {});
|
|
68
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Enhanced slot component with better prop handling
|
|
105
|
+
*/
|
|
69
106
|
function createEnhancedSlotComponent(slots, slotName, fallback, baseProps = {}) {
|
|
70
107
|
const SlotComponent = getSlotComponent(slots, slotName, fallback);
|
|
71
108
|
return function EnhancedSlot(props) {
|
|
@@ -73,6 +110,9 @@ function createEnhancedSlotComponent(slots, slotName, fallback, baseProps = {})
|
|
|
73
110
|
return (0, react_1.createElement)(SlotComponent, mergedProps);
|
|
74
111
|
};
|
|
75
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Utility to validate slot props at runtime (development only)
|
|
115
|
+
*/
|
|
76
116
|
function validateSlotProps(slotName, props, requiredProps = []) {
|
|
77
117
|
if (process.env.NODE_ENV === 'development') {
|
|
78
118
|
const missingProps = requiredProps.filter(prop => !(prop in props));
|
|
@@ -83,9 +123,18 @@ function validateSlotProps(slotName, props, requiredProps = []) {
|
|
|
83
123
|
}
|
|
84
124
|
return true;
|
|
85
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Helper to create slot props with proper typing
|
|
128
|
+
*/
|
|
86
129
|
function createSlotProps(table, additionalProps = {}) {
|
|
87
|
-
return
|
|
130
|
+
return {
|
|
131
|
+
table,
|
|
132
|
+
...additionalProps,
|
|
133
|
+
};
|
|
88
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Enhanced slot component wrapper that handles all prop merging automatically
|
|
137
|
+
*/
|
|
89
138
|
function withSlotProps(slots, slotProps = {}, slotName, fallback) {
|
|
90
139
|
return function SlotWrapper(props) {
|
|
91
140
|
const SlotComponent = getSlotComponent(slots, slotName, fallback);
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { DataTableColumn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced configuration for selection column
|
|
4
|
+
*/
|
|
2
5
|
export interface SelectionColumnConfig<T> {
|
|
3
6
|
multiSelect?: boolean;
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a default selection column using TanStack Table custom feature methods
|
|
10
|
+
*/
|
|
5
11
|
export declare const createSelectionColumn: <T>(config: Partial<DataTableColumn<T>> & SelectionColumnConfig<T>) => DataTableColumn<T, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a default expanding column
|
|
14
|
+
*/
|
|
6
15
|
export declare const createExpandingColumn: <T>(config: Partial<DataTableColumn<T>>) => DataTableColumn<T>;
|
|
16
|
+
//# sourceMappingURL=special-columns.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-columns.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/special-columns.utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAgE,MAAM,UAAU,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC;CAEzB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,QAAQ,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,KAAG,eAAe,CAAC,CAAC,EAAE,GAAG,CAqD9H,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,QAAQ,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAG,eAAe,CAAC,CAAC,CAkB9F,CAAC"}
|
|
@@ -5,10 +5,25 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Creates a default selection column using TanStack Table custom feature methods
|
|
10
|
+
*/
|
|
11
|
+
const createSelectionColumn = (config) => ({
|
|
12
|
+
id: types_1.DEFAULT_SELECTION_COLUMN_NAME,
|
|
13
|
+
size: 60,
|
|
14
|
+
minSize: 60,
|
|
15
|
+
align: 'center',
|
|
16
|
+
filterable: false,
|
|
17
|
+
enableResizing: false,
|
|
18
|
+
enableSorting: false,
|
|
19
|
+
enableHiding: false,
|
|
20
|
+
enablePinning: false,
|
|
21
|
+
hideInExport: true,
|
|
22
|
+
header: ({ table }) => {
|
|
9
23
|
var _a, _b;
|
|
10
24
|
if (!config.multiSelect)
|
|
11
25
|
return null;
|
|
26
|
+
// Use TanStack Table custom feature methods (same pattern as TanStack documentation)
|
|
12
27
|
const allSelected = ((_a = table.getIsAllRowsSelected) === null || _a === void 0 ? void 0 : _a.call(table)) || false;
|
|
13
28
|
const someSelected = ((_b = table.getIsSomeRowsSelected) === null || _b === void 0 ? void 0 : _b.call(table)) || false;
|
|
14
29
|
return (0, react_1.createElement)(material_1.Checkbox, {
|
|
@@ -22,9 +37,11 @@ const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_S
|
|
|
22
37
|
size: 'small',
|
|
23
38
|
sx: { p: 0 },
|
|
24
39
|
});
|
|
25
|
-
},
|
|
40
|
+
},
|
|
41
|
+
cell: ({ row, table }) => {
|
|
26
42
|
var _a, _b, _c;
|
|
27
43
|
const rowId = row.id;
|
|
44
|
+
// Use TanStack Table custom feature methods (same pattern as TanStack documentation)
|
|
28
45
|
const checked = ((_a = table.getIsRowSelected) === null || _a === void 0 ? void 0 : _a.call(table, rowId)) || false;
|
|
29
46
|
const canSelect = (_c = (_b = table.canSelectRow) === null || _b === void 0 ? void 0 : _b.call(table, rowId)) !== null && _c !== void 0 ? _c : true;
|
|
30
47
|
return (0, react_1.createElement)(material_1.Checkbox, {
|
|
@@ -42,11 +59,30 @@ const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_S
|
|
|
42
59
|
opacity: canSelect ? 1 : 0.5
|
|
43
60
|
},
|
|
44
61
|
});
|
|
45
|
-
}
|
|
62
|
+
},
|
|
63
|
+
...config,
|
|
64
|
+
});
|
|
46
65
|
exports.createSelectionColumn = createSelectionColumn;
|
|
47
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Creates a default expanding column
|
|
68
|
+
*/
|
|
69
|
+
const createExpandingColumn = (config) => ({
|
|
70
|
+
id: types_1.DEFAULT_EXPANDING_COLUMN_NAME,
|
|
71
|
+
size: 60,
|
|
72
|
+
minSize: 60,
|
|
73
|
+
align: 'center',
|
|
74
|
+
filterable: false,
|
|
75
|
+
enableResizing: false,
|
|
76
|
+
enableSorting: false,
|
|
77
|
+
enableHiding: false,
|
|
78
|
+
enablePinning: false,
|
|
79
|
+
hideInExport: true,
|
|
80
|
+
header: '',
|
|
81
|
+
cell: ({ row }) => (0, react_1.createElement)(material_1.IconButton, {
|
|
48
82
|
onClick: row.getToggleExpandedHandler(),
|
|
49
83
|
size: 'small',
|
|
50
84
|
sx: { p: 0 },
|
|
51
|
-
}, row.getIsExpanded() ? (0, react_1.createElement)(icons_material_1.KeyboardArrowUpOutlined) : (0, react_1.createElement)(icons_material_1.KeyboardArrowDownOutlined))
|
|
85
|
+
}, row.getIsExpanded() ? (0, react_1.createElement)(icons_material_1.KeyboardArrowUpOutlined) : (0, react_1.createElement)(icons_material_1.KeyboardArrowDownOutlined)),
|
|
86
|
+
...config,
|
|
87
|
+
});
|
|
52
88
|
exports.createExpandingColumn = createExpandingColumn;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styling utilities for DataTable components
|
|
3
|
+
*/
|
|
1
4
|
import type { DataTableColumn, PinnedColumnStyleOptions } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Generate consistent styling for pinned columns
|
|
7
|
+
*/
|
|
2
8
|
export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions): {
|
|
3
9
|
backgroundColor: (theme: any) => any;
|
|
4
10
|
backgroundImage: (theme: any) => string;
|
|
@@ -10,6 +16,7 @@ export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions):
|
|
|
10
16
|
wordBreak: "break-word";
|
|
11
17
|
overflow: "visible";
|
|
12
18
|
textOverflow?: undefined;
|
|
19
|
+
boxSizing: string;
|
|
13
20
|
maxWidth: string | number;
|
|
14
21
|
minWidth: number;
|
|
15
22
|
width: string | number;
|
|
@@ -23,6 +30,7 @@ export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions):
|
|
|
23
30
|
wordBreak: "break-word";
|
|
24
31
|
overflow: "visible";
|
|
25
32
|
textOverflow?: undefined;
|
|
33
|
+
boxSizing: string;
|
|
26
34
|
maxWidth: string | number;
|
|
27
35
|
minWidth: number;
|
|
28
36
|
width: string | number;
|
|
@@ -37,6 +45,7 @@ export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions):
|
|
|
37
45
|
whiteSpace: "nowrap";
|
|
38
46
|
textOverflow: "ellipsis";
|
|
39
47
|
wordBreak?: undefined;
|
|
48
|
+
boxSizing: string;
|
|
40
49
|
maxWidth: string | number;
|
|
41
50
|
minWidth: number;
|
|
42
51
|
width: string | number;
|
|
@@ -50,10 +59,14 @@ export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions):
|
|
|
50
59
|
whiteSpace: "nowrap";
|
|
51
60
|
textOverflow: "ellipsis";
|
|
52
61
|
wordBreak?: undefined;
|
|
62
|
+
boxSizing: string;
|
|
53
63
|
maxWidth: string | number;
|
|
54
64
|
minWidth: number;
|
|
55
65
|
width: string | number;
|
|
56
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Common table cell styling
|
|
69
|
+
*/
|
|
57
70
|
export declare const tableCellStyles: {
|
|
58
71
|
readonly sticky: {
|
|
59
72
|
readonly position: "sticky";
|
|
@@ -65,6 +78,9 @@ export declare const tableCellStyles: {
|
|
|
65
78
|
readonly borderColor: "divider";
|
|
66
79
|
};
|
|
67
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Common table row styling
|
|
83
|
+
*/
|
|
68
84
|
export declare const tableRowStyles: {
|
|
69
85
|
readonly hover: {
|
|
70
86
|
readonly '&:hover': {
|
|
@@ -77,4 +93,8 @@ export declare const tableRowStyles: {
|
|
|
77
93
|
};
|
|
78
94
|
};
|
|
79
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Get text alignment style from column metadata
|
|
98
|
+
*/
|
|
80
99
|
export declare function getColumnAlignment(column?: DataTableColumn<any>): 'left' | 'center' | 'right';
|
|
100
|
+
//# sourceMappingURL=styling-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styling-helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/styling-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAE1E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ErE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;CAUlB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAG7F"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Styling utilities for DataTable components
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.tableRowStyles = exports.tableCellStyles = void 0;
|
|
7
|
+
exports.getPinnedColumnStyle = getPinnedColumnStyle;
|
|
8
|
+
exports.getColumnAlignment = getColumnAlignment;
|
|
9
|
+
/**
|
|
10
|
+
* Generate consistent styling for pinned columns
|
|
11
|
+
*/
|
|
12
|
+
function getPinnedColumnStyle(options) {
|
|
13
|
+
const { width = 'auto', minWidth, maxWidth, isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, wrapText = false, } = options;
|
|
14
|
+
// Pinned columns should ALWAYS be sticky, regardless of enableStickyHeader setting
|
|
15
|
+
const needsPinnedPositioning = isPinned;
|
|
16
|
+
const shouldBeSticky = isPinned; // Pinned columns are always sticky
|
|
17
|
+
// Position logic
|
|
18
|
+
let positionStyle = {};
|
|
19
|
+
if (shouldBeSticky) {
|
|
20
|
+
// Pinned columns must always be sticky - override any Table-level sticky positioning
|
|
21
|
+
positionStyle = { position: 'sticky' };
|
|
22
|
+
}
|
|
23
|
+
else if (!disableStickyHeader) {
|
|
24
|
+
// Non-pinned columns: set relative when we're managing positioning
|
|
25
|
+
positionStyle = { position: 'relative' };
|
|
26
|
+
}
|
|
27
|
+
// When disableStickyHeader is true and column is not pinned, let Table handle stickiness
|
|
28
|
+
// Text wrapping styles - configurable per column
|
|
29
|
+
const textWrappingStyles = wrapText
|
|
30
|
+
? {
|
|
31
|
+
whiteSpace: 'normal',
|
|
32
|
+
wordBreak: 'break-word',
|
|
33
|
+
overflow: 'visible',
|
|
34
|
+
}
|
|
35
|
+
: {
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
whiteSpace: 'nowrap',
|
|
38
|
+
textOverflow: 'ellipsis',
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
// Width constraints - more strict for narrow columns
|
|
42
|
+
width,
|
|
43
|
+
...(minWidth !== undefined && { minWidth }),
|
|
44
|
+
...(maxWidth !== undefined ? { maxWidth } : { maxWidth: width }),
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
...textWrappingStyles,
|
|
47
|
+
// Position handling
|
|
48
|
+
...positionStyle,
|
|
49
|
+
// Pinned positioning (works with both sticky modes)
|
|
50
|
+
...(needsPinnedPositioning ? {
|
|
51
|
+
left: isPinned === 'left' ? pinnedPosition : undefined,
|
|
52
|
+
right: isPinned === 'right' ? pinnedRightPosition : undefined,
|
|
53
|
+
zIndex,
|
|
54
|
+
} : {}),
|
|
55
|
+
boxShadow: isPinned === 'left' && isLastLeftPinnedColumn
|
|
56
|
+
? 'inset -1px 0 0 var(--palette-TableCell-border), 2px 0 2px -4px rgba(0,0,0,.18)'
|
|
57
|
+
: isPinned === 'right' && isFirstRightPinnedColumn
|
|
58
|
+
? 'inset 1px 0 0 var(--palette-TableCell-border), -1px 0 2px -4px rgba(0,0,0,.18)'
|
|
59
|
+
: undefined,
|
|
60
|
+
// For pinned columns: use solid background + transparent overlay to prevent text bleeding through
|
|
61
|
+
...(isPinned ? {
|
|
62
|
+
// Solid base background (opaque)
|
|
63
|
+
backgroundColor: (theme) => theme.palette.background.paper,
|
|
64
|
+
// Transparent overlay for hover/selected states
|
|
65
|
+
backgroundImage: (theme) => `linear-gradient(var(--row-bg, ${theme.palette.background.paper}), var(--row-bg, ${theme.palette.background.paper}))`,
|
|
66
|
+
} : {
|
|
67
|
+
// Non-pinned columns: use standard transparent background
|
|
68
|
+
backgroundColor: (theme) => `var(--row-bg, ${theme.palette.background.paper})`,
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Common table cell styling
|
|
74
|
+
*/
|
|
75
|
+
exports.tableCellStyles = {
|
|
76
|
+
sticky: {
|
|
77
|
+
position: 'sticky',
|
|
78
|
+
zIndex: 10,
|
|
79
|
+
backgroundColor: 'background.paper',
|
|
80
|
+
},
|
|
81
|
+
pinned: {
|
|
82
|
+
borderRight: '1px solid',
|
|
83
|
+
borderColor: 'divider',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Common table row styling
|
|
88
|
+
*/
|
|
89
|
+
exports.tableRowStyles = {
|
|
90
|
+
hover: {
|
|
91
|
+
'&:hover': {
|
|
92
|
+
backgroundColor: 'action.hover',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
striped: {
|
|
96
|
+
'&:nth-of-type(odd)': {
|
|
97
|
+
backgroundColor: 'action.selected',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Get text alignment style from column metadata
|
|
103
|
+
*/
|
|
104
|
+
function getColumnAlignment(column) {
|
|
105
|
+
if (!column)
|
|
106
|
+
return 'left';
|
|
107
|
+
return column.align || 'left';
|
|
108
|
+
}
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General table utilities for DataTable components
|
|
3
|
+
*/
|
|
1
4
|
import type { TableMetrics } from '../types';
|
|
2
5
|
export type DataTableSize = 'small' | 'medium';
|
|
6
|
+
/**
|
|
7
|
+
* Calculate skeleton rows count based on viewport and row height
|
|
8
|
+
*/
|
|
3
9
|
export declare function calculateSkeletonRows(containerHeight: number, rowHeight: number, maxRows?: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Generate unique row ID for virtualization
|
|
12
|
+
*/
|
|
4
13
|
export declare function generateRowId<T>(row: T, index: number, idKey?: keyof T): string;
|
|
14
|
+
/**
|
|
15
|
+
* Calculate total width of pinned columns
|
|
16
|
+
*/
|
|
5
17
|
export declare function calculatePinnedColumnsWidth(columns: any[], side: 'left' | 'right'): number;
|
|
18
|
+
/**
|
|
19
|
+
* Check if table should use fixed layout
|
|
20
|
+
*/
|
|
6
21
|
export declare function shouldUseFixedLayout(fitToScreen: boolean, enableColumnResizing: boolean, totalColumns: number): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Format cell value based on column type
|
|
24
|
+
*/
|
|
7
25
|
export declare function formatCellValue(value: any, type: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Debounce function for search and filters
|
|
28
|
+
*/
|
|
8
29
|
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Get table performance metrics
|
|
32
|
+
*/
|
|
9
33
|
export declare function calculateTableMetrics(totalRows: number, visibleRows: number, columns: any[], renderStartTime: number): TableMetrics;
|
|
34
|
+
//# sourceMappingURL=table-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/table-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE/C;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,SAAK,GACb,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,CAK/E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACvC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,MAAM,GAAG,OAAO,GACvB,MAAM,CAIR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,OAAO,EACpB,oBAAoB,EAAE,OAAO,EAC7B,YAAY,EAAE,MAAM,GACrB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAehE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACtD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACb,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMlC;AAED;;GAEG;AAEH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,GAAG,EAAE,EACd,eAAe,EAAE,MAAM,GACxB,YAAY,CAOd"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* General table utilities for DataTable components
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.calculateSkeletonRows = calculateSkeletonRows;
|
|
4
7
|
exports.generateRowId = generateRowId;
|
|
@@ -7,24 +10,39 @@ exports.shouldUseFixedLayout = shouldUseFixedLayout;
|
|
|
7
10
|
exports.formatCellValue = formatCellValue;
|
|
8
11
|
exports.debounce = debounce;
|
|
9
12
|
exports.calculateTableMetrics = calculateTableMetrics;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate skeleton rows count based on viewport and row height
|
|
15
|
+
*/
|
|
10
16
|
function calculateSkeletonRows(containerHeight, rowHeight, maxRows = 10) {
|
|
11
17
|
const estimatedRows = Math.ceil(containerHeight / rowHeight);
|
|
12
18
|
return Math.min(estimatedRows, maxRows);
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate unique row ID for virtualization
|
|
22
|
+
*/
|
|
14
23
|
function generateRowId(row, index, idKey) {
|
|
15
24
|
if (idKey && row[idKey]) {
|
|
16
25
|
return String(row[idKey]);
|
|
17
26
|
}
|
|
18
27
|
return `row-${index}`;
|
|
19
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Calculate total width of pinned columns
|
|
31
|
+
*/
|
|
20
32
|
function calculatePinnedColumnsWidth(columns, side) {
|
|
21
33
|
return columns
|
|
22
34
|
.filter(col => col.getIsPinned() === side)
|
|
23
35
|
.reduce((total, col) => total + (col.getSize() || 0), 0);
|
|
24
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if table should use fixed layout
|
|
39
|
+
*/
|
|
25
40
|
function shouldUseFixedLayout(fitToScreen, enableColumnResizing, totalColumns) {
|
|
26
41
|
return fitToScreen || (enableColumnResizing && totalColumns > 5);
|
|
27
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Format cell value based on column type
|
|
45
|
+
*/
|
|
28
46
|
function formatCellValue(value, type) {
|
|
29
47
|
if (value === null || value === undefined) {
|
|
30
48
|
return '-';
|
|
@@ -40,6 +58,9 @@ function formatCellValue(value, type) {
|
|
|
40
58
|
return String(value);
|
|
41
59
|
}
|
|
42
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Debounce function for search and filters
|
|
63
|
+
*/
|
|
43
64
|
function debounce(func, wait) {
|
|
44
65
|
let timeout;
|
|
45
66
|
return (...args) => {
|
|
@@ -47,6 +68,9 @@ function debounce(func, wait) {
|
|
|
47
68
|
timeout = setTimeout(() => func(...args), wait);
|
|
48
69
|
};
|
|
49
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Get table performance metrics
|
|
73
|
+
*/
|
|
50
74
|
function calculateTableMetrics(totalRows, visibleRows, columns, renderStartTime) {
|
|
51
75
|
return {
|
|
52
76
|
totalRows,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ackplus/react-tanstack-data-table",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"description": "A powerful React data table component built with MUI and TanStack Table",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -26,24 +26,49 @@
|
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/ack-solutions/react-tanstack-data-table/issues"
|
|
28
28
|
},
|
|
29
|
-
"main": "./
|
|
30
|
-
"types": "./
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.js",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"src"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.build.json"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"lodash": "^4.17.21",
|
|
49
|
+
"moment": "^2.30.1",
|
|
50
|
+
"rxjs": "^7.8.0",
|
|
51
|
+
"xlsx": "^0.18.5",
|
|
52
|
+
"@tanstack/react-table": "^8.21.3",
|
|
53
|
+
"@tanstack/react-virtual": "^3.13.10"
|
|
54
|
+
},
|
|
31
55
|
"peerDependencies": {
|
|
32
56
|
"@emotion/react": ">=11.0.0",
|
|
33
57
|
"@emotion/styled": ">=11.0.0",
|
|
34
58
|
"@mui/icons-material": ">=5.0.0 || ^6.0.0 || ^7.0.0",
|
|
35
59
|
"@mui/material": ">=5.0.0 || ^6.0.0 || ^7.0.0",
|
|
36
|
-
"@tanstack/react-table": ">=8.10.0",
|
|
37
|
-
"@tanstack/react-virtual": ">=3.0.0",
|
|
38
60
|
"react": ">=18.0.0 || ^19.0.0",
|
|
39
61
|
"react-dom": ">=18.0.0 || ^19.0.0",
|
|
40
|
-
"xlsx": ">=0.18.0",
|
|
41
|
-
"moment": ">=2.29.0",
|
|
42
62
|
"@mui/x-date-pickers": ">=5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
43
63
|
},
|
|
44
64
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
65
|
+
"@emotion/react": "^11.14.0",
|
|
66
|
+
"@emotion/styled": "^11.14.0",
|
|
67
|
+
"@mui/icons-material": "^7.1.1",
|
|
68
|
+
"@mui/material": "^7.1.1",
|
|
69
|
+
"@mui/x-date-pickers": "^8.5.3",
|
|
70
|
+
"react": "19.2.3",
|
|
71
|
+
"react-dom": "19.2.3",
|
|
72
|
+
"typescript": "~5.8.3"
|
|
48
73
|
}
|
|
49
|
-
}
|
|
74
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MUI TanStack DataTable
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive, highly customizable data table component built with:
|
|
5
|
+
* - Material-UI (MUI) for styling
|
|
6
|
+
* - TanStack Table for table logic
|
|
7
|
+
* - TypeScript for type safety
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Column sorting, filtering, resizing, reordering, and pinning
|
|
11
|
+
* - Row selection, expansion, and virtualization
|
|
12
|
+
* - Pagination with customizable page sizes
|
|
13
|
+
* - Global and column-specific search/filtering
|
|
14
|
+
* - Export functionality (CSV, XLSX, JSON)
|
|
15
|
+
* - Responsive design with mobile support
|
|
16
|
+
* - Accessibility features
|
|
17
|
+
* - Customizable toolbar and actions
|
|
18
|
+
* - Loading states and empty data handling
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// Main components - be specific to avoid conflicts
|
|
22
|
+
export { DataTable } from './lib/data-table';
|
|
23
|
+
|
|
24
|
+
// Other component exports
|
|
25
|
+
export * from './lib/components/headers';
|
|
26
|
+
export * from './lib/components/rows';
|
|
27
|
+
export * from './lib/components/filters';
|
|
28
|
+
export * from './lib/components/pagination';
|
|
29
|
+
export * from './lib/components/droupdown/menu-dropdown';
|
|
30
|
+
|
|
31
|
+
// Individual toolbar components for custom toolbars
|
|
32
|
+
export {
|
|
33
|
+
ColumnVisibilityControl,
|
|
34
|
+
ColumnPinningControl,
|
|
35
|
+
ColumnResetControl,
|
|
36
|
+
TableExportControl,
|
|
37
|
+
TableSizeControl,
|
|
38
|
+
BulkActionsToolbar,
|
|
39
|
+
DataTableToolbar,
|
|
40
|
+
} from './lib/components/toolbar';
|
|
41
|
+
|
|
42
|
+
// Export bulk action types
|
|
43
|
+
export type { BulkActionsToolbarProps } from './lib/components/toolbar';
|
|
44
|
+
|
|
45
|
+
// Utilities and helpers
|
|
46
|
+
export * from './lib/utils/styling-helpers';
|
|
47
|
+
export * from './lib/utils/column-helpers';
|
|
48
|
+
export * from './lib/utils/table-helpers';
|
|
49
|
+
export * from './lib/utils/logger';
|
|
50
|
+
|
|
51
|
+
// Custom hooks
|
|
52
|
+
export * from './lib/types';
|
|
53
|
+
|
|
54
|
+
// Re-export commonly used types from TanStack Table
|
|
55
|
+
export type {
|
|
56
|
+
Column,
|
|
57
|
+
ColumnDef,
|
|
58
|
+
Row,
|
|
59
|
+
Table,
|
|
60
|
+
Header,
|
|
61
|
+
Cell,
|
|
62
|
+
SortingState,
|
|
63
|
+
ColumnFiltersState,
|
|
64
|
+
VisibilityState,
|
|
65
|
+
ColumnOrderState,
|
|
66
|
+
ColumnPinningState,
|
|
67
|
+
PaginationState,
|
|
68
|
+
} from '@tanstack/react-table';
|
|
69
|
+
|
|
70
|
+
// Custom features (this includes SelectMode from features)
|
|
71
|
+
export * from './lib/features';
|