@redis-ui/table 2.12.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Table/Table.cjs +70 -145
- package/dist/Table/Table.context.cjs +16 -1
- package/dist/Table/Table.context.d.ts +22 -4
- package/dist/Table/Table.context.js +16 -1
- package/dist/Table/Table.d.ts +83 -5
- package/dist/Table/Table.js +70 -145
- package/dist/Table/Table.style.cjs +10 -5
- package/dist/Table/Table.style.d.ts +3 -3
- package/dist/Table/Table.style.js +10 -5
- package/dist/Table/Table.types.d.ts +20 -38
- package/dist/Table/components/Compose/Compose.cjs +42 -0
- package/dist/Table/components/Compose/Compose.d.ts +13 -0
- package/dist/Table/components/Compose/Compose.js +42 -0
- package/dist/Table/components/EmptyState/EmptyState.cjs +31 -0
- package/dist/Table/components/EmptyState/EmptyState.d.ts +6 -0
- package/dist/Table/components/EmptyState/EmptyState.js +31 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.cjs +13 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.d.ts +3 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.js +13 -0
- package/dist/Table/components/PluggableTable/PluggableTable.cjs +19 -0
- package/dist/Table/components/PluggableTable/PluggableTable.d.ts +10 -0
- package/dist/Table/components/PluggableTable/PluggableTable.js +19 -0
- package/dist/Table/components/PluggableTable/compositionComponents.cjs +21 -0
- package/dist/Table/components/PluggableTable/compositionComponents.d.ts +67 -0
- package/dist/Table/components/PluggableTable/compositionComponents.js +21 -0
- package/dist/Table/components/TableBody/TableBody.cjs +33 -0
- package/dist/Table/components/TableBody/TableBody.d.ts +23 -0
- package/dist/Table/components/TableBody/TableBody.js +33 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.cjs +10 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.js +10 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.cjs +22 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.d.ts +12 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.js +22 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.cjs +38 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.d.ts +20 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.js +38 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.cjs +33 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.d.ts +2 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.js +33 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.cjs +17 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.d.ts +4 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.js +17 -0
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.cjs +3 -4
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.d.ts +1 -1
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.js +3 -4
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.cjs +9 -4
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.d.ts +1 -1
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.js +9 -4
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.types.d.ts +3 -5
- package/dist/Table/components/TableHeader/TableHeader.cjs +28 -0
- package/dist/Table/components/TableHeader/TableHeader.d.ts +21 -0
- package/dist/Table/components/TableHeader/TableHeader.js +28 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.cjs +19 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.d.ts +1 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.js +19 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.cjs +19 -33
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.cjs +15 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.d.ts +8 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.js +15 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.d.ts +16 -4
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.js +19 -33
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.test.d.ts +1 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.cjs +0 -22
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.d.ts +0 -1
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.js +1 -23
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.cjs +40 -0
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.d.ts +9 -0
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.js +40 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.cjs +34 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.d.ts +5 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.js +34 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.cjs +16 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.d.ts +8 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.js +16 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.cjs +23 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.d.ts +5 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.js +23 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.cjs +6 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.d.ts +2 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.js +6 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.cjs +27 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.d.ts +12 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.js +27 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TablePagination/TablePagination.cjs +65 -99
- package/dist/Table/components/TablePagination/TablePagination.d.ts +23 -3
- package/dist/Table/components/TablePagination/TablePagination.js +66 -100
- package/dist/Table/components/TablePagination/TablePagination.style.cjs +70 -50
- package/dist/Table/components/TablePagination/TablePagination.style.d.ts +17 -50
- package/dist/Table/components/TablePagination/TablePagination.style.js +72 -52
- package/dist/Table/components/TablePagination/components/Compose/Compose.cjs +41 -0
- package/dist/Table/components/TablePagination/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TablePagination/components/Compose/Compose.js +41 -0
- package/dist/Table/components/TableRoot/TableRoot.cjs +5 -0
- package/dist/Table/components/TableRoot/TableRoot.d.ts +1 -0
- package/dist/Table/components/TableRoot/TableRoot.js +5 -0
- package/dist/Table/index.d.ts +3 -6
- package/dist/Table/plugins/ClickableRowPlugin.cjs +48 -0
- package/dist/Table/plugins/ClickableRowPlugin.d.ts +25 -0
- package/dist/Table/plugins/ClickableRowPlugin.js +48 -0
- package/dist/Table/plugins/ExpandableRowPlugin.cjs +38 -0
- package/dist/Table/plugins/ExpandableRowPlugin.d.ts +22 -0
- package/dist/Table/plugins/ExpandableRowPlugin.js +38 -0
- package/dist/Table/plugins/PaginationPlugin.cjs +45 -0
- package/dist/Table/plugins/PaginationPlugin.d.ts +16 -0
- package/dist/Table/plugins/PaginationPlugin.js +45 -0
- package/dist/Table/plugins/RowSelectionPlugin.cjs +28 -0
- package/dist/Table/plugins/RowSelectionPlugin.d.ts +12 -0
- package/dist/Table/plugins/RowSelectionPlugin.js +28 -0
- package/dist/Table/plugins/SortingPlugin.cjs +44 -0
- package/dist/Table/plugins/SortingPlugin.d.ts +18 -0
- package/dist/Table/plugins/SortingPlugin.js +44 -0
- package/dist/Table/tanStackExtendedTypes.d.ts +11 -0
- package/dist/Table/utils/plugin.utils.cjs +49 -0
- package/dist/Table/utils/plugin.utils.d.ts +17 -0
- package/dist/Table/utils/plugin.utils.js +49 -0
- package/dist/Table/utils/plugin.utils.test.d.ts +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.js +61 -1
- package/dist/node_modules/@tanstack/react-table/build/lib/index.cjs +7 -0
- package/dist/node_modules/@tanstack/react-table/build/lib/index.js +8 -1
- package/dist/node_modules/@tanstack/table-core/build/lib/index.cjs +361 -4
- package/dist/node_modules/@tanstack/table-core/build/lib/index.js +361 -4
- package/package.json +6 -5
- package/dist/Table/components/EmptyStateRow/EmptyStateRow.cjs +0 -16
- package/dist/Table/components/EmptyStateRow/EmptyStateRow.d.ts +0 -8
- package/dist/Table/components/EmptyStateRow/EmptyStateRow.js +0 -16
- package/dist/node_modules/@radix-ui/react-id/dist/index.cjs +0 -32
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -14
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -24
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -6
|
@@ -8,9 +8,26 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
function createColumnHelper() {
|
|
12
|
+
return {
|
|
13
|
+
accessor: (accessor, column) => {
|
|
14
|
+
return typeof accessor === "function" ? {
|
|
15
|
+
...column,
|
|
16
|
+
accessorFn: accessor
|
|
17
|
+
} : {
|
|
18
|
+
...column,
|
|
19
|
+
accessorKey: accessor
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
display: (column) => column,
|
|
23
|
+
group: (column) => column
|
|
24
|
+
};
|
|
25
|
+
}
|
|
11
26
|
function functionalUpdate(updater, input) {
|
|
12
27
|
return typeof updater === "function" ? updater(input) : updater;
|
|
13
28
|
}
|
|
29
|
+
function noop() {
|
|
30
|
+
}
|
|
14
31
|
function makeStateUpdater(key, instance) {
|
|
15
32
|
return (updater) => {
|
|
16
33
|
instance.setState((old) => {
|
|
@@ -425,7 +442,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
425
442
|
var _row$getValue;
|
|
426
443
|
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
427
444
|
},
|
|
428
|
-
subRows: [],
|
|
445
|
+
subRows: subRows != null ? subRows : [],
|
|
429
446
|
getLeafRows: () => flattenBy(row.subRows, (d) => d.subRows),
|
|
430
447
|
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : void 0,
|
|
431
448
|
getParentRows: () => {
|
|
@@ -1292,10 +1309,10 @@ function passiveEventSupported() {
|
|
|
1292
1309
|
return false;
|
|
1293
1310
|
}
|
|
1294
1311
|
};
|
|
1295
|
-
const
|
|
1312
|
+
const noop2 = () => {
|
|
1296
1313
|
};
|
|
1297
|
-
window.addEventListener("test",
|
|
1298
|
-
window.removeEventListener("test",
|
|
1314
|
+
window.addEventListener("test", noop2, options);
|
|
1315
|
+
window.removeEventListener("test", noop2);
|
|
1299
1316
|
} catch (err) {
|
|
1300
1317
|
supported = false;
|
|
1301
1318
|
}
|
|
@@ -2651,6 +2668,339 @@ function expandRows(rowModel) {
|
|
|
2651
2668
|
rowsById: rowModel.rowsById
|
|
2652
2669
|
};
|
|
2653
2670
|
}
|
|
2671
|
+
function getFacetedMinMaxValues() {
|
|
2672
|
+
return (table, columnId) => memo(() => {
|
|
2673
|
+
var _table$getColumn;
|
|
2674
|
+
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
2675
|
+
}, (facetedRowModel) => {
|
|
2676
|
+
var _facetedRowModel$flat;
|
|
2677
|
+
if (!facetedRowModel) return void 0;
|
|
2678
|
+
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
|
|
2679
|
+
if (typeof firstValue === "undefined") {
|
|
2680
|
+
return void 0;
|
|
2681
|
+
}
|
|
2682
|
+
let facetedMinMaxValues = [firstValue, firstValue];
|
|
2683
|
+
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
2684
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
2685
|
+
for (let j = 0; j < values.length; j++) {
|
|
2686
|
+
const value = values[j];
|
|
2687
|
+
if (value < facetedMinMaxValues[0]) {
|
|
2688
|
+
facetedMinMaxValues[0] = value;
|
|
2689
|
+
} else if (value > facetedMinMaxValues[1]) {
|
|
2690
|
+
facetedMinMaxValues[1] = value;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
return facetedMinMaxValues;
|
|
2695
|
+
}, getMemoOptions(table.options, "debugTable", "getFacetedMinMaxValues"));
|
|
2696
|
+
}
|
|
2697
|
+
function filterRows(rows, filterRowImpl, table) {
|
|
2698
|
+
if (table.options.filterFromLeafRows) {
|
|
2699
|
+
return filterRowModelFromLeafs(rows, filterRowImpl, table);
|
|
2700
|
+
}
|
|
2701
|
+
return filterRowModelFromRoot(rows, filterRowImpl, table);
|
|
2702
|
+
}
|
|
2703
|
+
function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
2704
|
+
var _table$options$maxLea;
|
|
2705
|
+
const newFilteredFlatRows = [];
|
|
2706
|
+
const newFilteredRowsById = {};
|
|
2707
|
+
const maxDepth = (_table$options$maxLea = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea : 100;
|
|
2708
|
+
const recurseFilterRows = function(rowsToFilter2, depth) {
|
|
2709
|
+
if (depth === void 0) {
|
|
2710
|
+
depth = 0;
|
|
2711
|
+
}
|
|
2712
|
+
const rows = [];
|
|
2713
|
+
for (let i = 0; i < rowsToFilter2.length; i++) {
|
|
2714
|
+
var _row$subRows;
|
|
2715
|
+
let row = rowsToFilter2[i];
|
|
2716
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, void 0, row.parentId);
|
|
2717
|
+
newRow.columnFilters = row.columnFilters;
|
|
2718
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
|
|
2719
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
2720
|
+
row = newRow;
|
|
2721
|
+
if (filterRow(row) && !newRow.subRows.length) {
|
|
2722
|
+
rows.push(row);
|
|
2723
|
+
newFilteredRowsById[row.id] = row;
|
|
2724
|
+
newFilteredFlatRows.push(row);
|
|
2725
|
+
continue;
|
|
2726
|
+
}
|
|
2727
|
+
if (filterRow(row) || newRow.subRows.length) {
|
|
2728
|
+
rows.push(row);
|
|
2729
|
+
newFilteredRowsById[row.id] = row;
|
|
2730
|
+
newFilteredFlatRows.push(row);
|
|
2731
|
+
continue;
|
|
2732
|
+
}
|
|
2733
|
+
} else {
|
|
2734
|
+
row = newRow;
|
|
2735
|
+
if (filterRow(row)) {
|
|
2736
|
+
rows.push(row);
|
|
2737
|
+
newFilteredRowsById[row.id] = row;
|
|
2738
|
+
newFilteredFlatRows.push(row);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
return rows;
|
|
2743
|
+
};
|
|
2744
|
+
return {
|
|
2745
|
+
rows: recurseFilterRows(rowsToFilter),
|
|
2746
|
+
flatRows: newFilteredFlatRows,
|
|
2747
|
+
rowsById: newFilteredRowsById
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2750
|
+
function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
2751
|
+
var _table$options$maxLea2;
|
|
2752
|
+
const newFilteredFlatRows = [];
|
|
2753
|
+
const newFilteredRowsById = {};
|
|
2754
|
+
const maxDepth = (_table$options$maxLea2 = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea2 : 100;
|
|
2755
|
+
const recurseFilterRows = function(rowsToFilter2, depth) {
|
|
2756
|
+
if (depth === void 0) {
|
|
2757
|
+
depth = 0;
|
|
2758
|
+
}
|
|
2759
|
+
const rows = [];
|
|
2760
|
+
for (let i = 0; i < rowsToFilter2.length; i++) {
|
|
2761
|
+
let row = rowsToFilter2[i];
|
|
2762
|
+
const pass = filterRow(row);
|
|
2763
|
+
if (pass) {
|
|
2764
|
+
var _row$subRows2;
|
|
2765
|
+
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
|
|
2766
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, void 0, row.parentId);
|
|
2767
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
2768
|
+
row = newRow;
|
|
2769
|
+
}
|
|
2770
|
+
rows.push(row);
|
|
2771
|
+
newFilteredFlatRows.push(row);
|
|
2772
|
+
newFilteredRowsById[row.id] = row;
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
return rows;
|
|
2776
|
+
};
|
|
2777
|
+
return {
|
|
2778
|
+
rows: recurseFilterRows(rowsToFilter),
|
|
2779
|
+
flatRows: newFilteredFlatRows,
|
|
2780
|
+
rowsById: newFilteredRowsById
|
|
2781
|
+
};
|
|
2782
|
+
}
|
|
2783
|
+
function getFacetedRowModel() {
|
|
2784
|
+
return (table, columnId) => memo(() => [table.getPreFilteredRowModel(), table.getState().columnFilters, table.getState().globalFilter, table.getFilteredRowModel()], (preRowModel, columnFilters, globalFilter) => {
|
|
2785
|
+
if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
2786
|
+
return preRowModel;
|
|
2787
|
+
}
|
|
2788
|
+
const filterableIds = [...columnFilters.map((d) => d.id).filter((d) => d !== columnId), globalFilter ? "__global__" : void 0].filter(Boolean);
|
|
2789
|
+
const filterRowsImpl = (row) => {
|
|
2790
|
+
for (let i = 0; i < filterableIds.length; i++) {
|
|
2791
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
return true;
|
|
2796
|
+
};
|
|
2797
|
+
return filterRows(preRowModel.rows, filterRowsImpl, table);
|
|
2798
|
+
}, getMemoOptions(table.options, "debugTable", "getFacetedRowModel"));
|
|
2799
|
+
}
|
|
2800
|
+
function getFacetedUniqueValues() {
|
|
2801
|
+
return (table, columnId) => memo(() => {
|
|
2802
|
+
var _table$getColumn;
|
|
2803
|
+
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
2804
|
+
}, (facetedRowModel) => {
|
|
2805
|
+
if (!facetedRowModel) return /* @__PURE__ */ new Map();
|
|
2806
|
+
let facetedUniqueValues = /* @__PURE__ */ new Map();
|
|
2807
|
+
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
2808
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
2809
|
+
for (let j = 0; j < values.length; j++) {
|
|
2810
|
+
const value = values[j];
|
|
2811
|
+
if (facetedUniqueValues.has(value)) {
|
|
2812
|
+
var _facetedUniqueValues$;
|
|
2813
|
+
facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
|
|
2814
|
+
} else {
|
|
2815
|
+
facetedUniqueValues.set(value, 1);
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
return facetedUniqueValues;
|
|
2820
|
+
}, getMemoOptions(table.options, "debugTable", `getFacetedUniqueValues_${columnId}`));
|
|
2821
|
+
}
|
|
2822
|
+
function getFilteredRowModel() {
|
|
2823
|
+
return (table) => memo(() => [table.getPreFilteredRowModel(), table.getState().columnFilters, table.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
|
|
2824
|
+
if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
2825
|
+
for (let i = 0; i < rowModel.flatRows.length; i++) {
|
|
2826
|
+
rowModel.flatRows[i].columnFilters = {};
|
|
2827
|
+
rowModel.flatRows[i].columnFiltersMeta = {};
|
|
2828
|
+
}
|
|
2829
|
+
return rowModel;
|
|
2830
|
+
}
|
|
2831
|
+
const resolvedColumnFilters = [];
|
|
2832
|
+
const resolvedGlobalFilters = [];
|
|
2833
|
+
(columnFilters != null ? columnFilters : []).forEach((d) => {
|
|
2834
|
+
var _filterFn$resolveFilt;
|
|
2835
|
+
const column = table.getColumn(d.id);
|
|
2836
|
+
if (!column) {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
const filterFn = column.getFilterFn();
|
|
2840
|
+
if (!filterFn) {
|
|
2841
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2842
|
+
console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`);
|
|
2843
|
+
}
|
|
2844
|
+
return;
|
|
2845
|
+
}
|
|
2846
|
+
resolvedColumnFilters.push({
|
|
2847
|
+
id: d.id,
|
|
2848
|
+
filterFn,
|
|
2849
|
+
resolvedValue: (_filterFn$resolveFilt = filterFn.resolveFilterValue == null ? void 0 : filterFn.resolveFilterValue(d.value)) != null ? _filterFn$resolveFilt : d.value
|
|
2850
|
+
});
|
|
2851
|
+
});
|
|
2852
|
+
const filterableIds = (columnFilters != null ? columnFilters : []).map((d) => d.id);
|
|
2853
|
+
const globalFilterFn = table.getGlobalFilterFn();
|
|
2854
|
+
const globallyFilterableColumns = table.getAllLeafColumns().filter((column) => column.getCanGlobalFilter());
|
|
2855
|
+
if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {
|
|
2856
|
+
filterableIds.push("__global__");
|
|
2857
|
+
globallyFilterableColumns.forEach((column) => {
|
|
2858
|
+
var _globalFilterFn$resol;
|
|
2859
|
+
resolvedGlobalFilters.push({
|
|
2860
|
+
id: column.id,
|
|
2861
|
+
filterFn: globalFilterFn,
|
|
2862
|
+
resolvedValue: (_globalFilterFn$resol = globalFilterFn.resolveFilterValue == null ? void 0 : globalFilterFn.resolveFilterValue(globalFilter)) != null ? _globalFilterFn$resol : globalFilter
|
|
2863
|
+
});
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2866
|
+
let currentColumnFilter;
|
|
2867
|
+
let currentGlobalFilter;
|
|
2868
|
+
for (let j = 0; j < rowModel.flatRows.length; j++) {
|
|
2869
|
+
const row = rowModel.flatRows[j];
|
|
2870
|
+
row.columnFilters = {};
|
|
2871
|
+
if (resolvedColumnFilters.length) {
|
|
2872
|
+
for (let i = 0; i < resolvedColumnFilters.length; i++) {
|
|
2873
|
+
currentColumnFilter = resolvedColumnFilters[i];
|
|
2874
|
+
const id = currentColumnFilter.id;
|
|
2875
|
+
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, (filterMeta) => {
|
|
2876
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
if (resolvedGlobalFilters.length) {
|
|
2881
|
+
for (let i = 0; i < resolvedGlobalFilters.length; i++) {
|
|
2882
|
+
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
2883
|
+
const id = currentGlobalFilter.id;
|
|
2884
|
+
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, (filterMeta) => {
|
|
2885
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
2886
|
+
})) {
|
|
2887
|
+
row.columnFilters.__global__ = true;
|
|
2888
|
+
break;
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
if (row.columnFilters.__global__ !== true) {
|
|
2892
|
+
row.columnFilters.__global__ = false;
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
const filterRowsImpl = (row) => {
|
|
2897
|
+
for (let i = 0; i < filterableIds.length; i++) {
|
|
2898
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
2899
|
+
return false;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
return true;
|
|
2903
|
+
};
|
|
2904
|
+
return filterRows(rowModel.rows, filterRowsImpl, table);
|
|
2905
|
+
}, getMemoOptions(table.options, "debugTable", "getFilteredRowModel", () => table._autoResetPageIndex()));
|
|
2906
|
+
}
|
|
2907
|
+
function getGroupedRowModel() {
|
|
2908
|
+
return (table) => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
|
|
2909
|
+
if (!rowModel.rows.length || !grouping.length) {
|
|
2910
|
+
return rowModel;
|
|
2911
|
+
}
|
|
2912
|
+
const existingGrouping = grouping.filter((columnId) => table.getColumn(columnId));
|
|
2913
|
+
const groupedFlatRows = [];
|
|
2914
|
+
const groupedRowsById = {};
|
|
2915
|
+
const groupUpRecursively = function(rows, depth, parentId) {
|
|
2916
|
+
if (depth === void 0) {
|
|
2917
|
+
depth = 0;
|
|
2918
|
+
}
|
|
2919
|
+
if (depth >= existingGrouping.length) {
|
|
2920
|
+
return rows.map((row) => {
|
|
2921
|
+
row.depth = depth;
|
|
2922
|
+
groupedFlatRows.push(row);
|
|
2923
|
+
groupedRowsById[row.id] = row;
|
|
2924
|
+
if (row.subRows) {
|
|
2925
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
2926
|
+
}
|
|
2927
|
+
return row;
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
const columnId = existingGrouping[depth];
|
|
2931
|
+
const rowGroupsMap = groupBy(rows, columnId);
|
|
2932
|
+
const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
|
|
2933
|
+
let [groupingValue, groupedRows2] = _ref;
|
|
2934
|
+
let id = `${columnId}:${groupingValue}`;
|
|
2935
|
+
id = parentId ? `${parentId}>${id}` : id;
|
|
2936
|
+
const subRows = groupUpRecursively(groupedRows2, depth + 1, id);
|
|
2937
|
+
const leafRows = depth ? flattenBy(groupedRows2, (row2) => row2.subRows) : groupedRows2;
|
|
2938
|
+
const row = createRow(table, id, leafRows[0].original, index, depth, void 0, parentId);
|
|
2939
|
+
Object.assign(row, {
|
|
2940
|
+
groupingColumnId: columnId,
|
|
2941
|
+
groupingValue,
|
|
2942
|
+
subRows,
|
|
2943
|
+
leafRows,
|
|
2944
|
+
getValue: (columnId2) => {
|
|
2945
|
+
if (existingGrouping.includes(columnId2)) {
|
|
2946
|
+
if (row._valuesCache.hasOwnProperty(columnId2)) {
|
|
2947
|
+
return row._valuesCache[columnId2];
|
|
2948
|
+
}
|
|
2949
|
+
if (groupedRows2[0]) {
|
|
2950
|
+
var _groupedRows$0$getVal;
|
|
2951
|
+
row._valuesCache[columnId2] = (_groupedRows$0$getVal = groupedRows2[0].getValue(columnId2)) != null ? _groupedRows$0$getVal : void 0;
|
|
2952
|
+
}
|
|
2953
|
+
return row._valuesCache[columnId2];
|
|
2954
|
+
}
|
|
2955
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId2)) {
|
|
2956
|
+
return row._groupingValuesCache[columnId2];
|
|
2957
|
+
}
|
|
2958
|
+
const column = table.getColumn(columnId2);
|
|
2959
|
+
const aggregateFn = column == null ? void 0 : column.getAggregationFn();
|
|
2960
|
+
if (aggregateFn) {
|
|
2961
|
+
row._groupingValuesCache[columnId2] = aggregateFn(columnId2, leafRows, groupedRows2);
|
|
2962
|
+
return row._groupingValuesCache[columnId2];
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
});
|
|
2966
|
+
subRows.forEach((subRow) => {
|
|
2967
|
+
groupedFlatRows.push(subRow);
|
|
2968
|
+
groupedRowsById[subRow.id] = subRow;
|
|
2969
|
+
});
|
|
2970
|
+
return row;
|
|
2971
|
+
});
|
|
2972
|
+
return aggregatedGroupedRows;
|
|
2973
|
+
};
|
|
2974
|
+
const groupedRows = groupUpRecursively(rowModel.rows, 0);
|
|
2975
|
+
groupedRows.forEach((subRow) => {
|
|
2976
|
+
groupedFlatRows.push(subRow);
|
|
2977
|
+
groupedRowsById[subRow.id] = subRow;
|
|
2978
|
+
});
|
|
2979
|
+
return {
|
|
2980
|
+
rows: groupedRows,
|
|
2981
|
+
flatRows: groupedFlatRows,
|
|
2982
|
+
rowsById: groupedRowsById
|
|
2983
|
+
};
|
|
2984
|
+
}, getMemoOptions(table.options, "debugTable", "getGroupedRowModel", () => {
|
|
2985
|
+
table._queue(() => {
|
|
2986
|
+
table._autoResetExpanded();
|
|
2987
|
+
table._autoResetPageIndex();
|
|
2988
|
+
});
|
|
2989
|
+
}));
|
|
2990
|
+
}
|
|
2991
|
+
function groupBy(rows, columnId) {
|
|
2992
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
2993
|
+
return rows.reduce((map, row) => {
|
|
2994
|
+
const resKey = `${row.getGroupingValue(columnId)}`;
|
|
2995
|
+
const previous = map.get(resKey);
|
|
2996
|
+
if (!previous) {
|
|
2997
|
+
map.set(resKey, [row]);
|
|
2998
|
+
} else {
|
|
2999
|
+
previous.push(row);
|
|
3000
|
+
}
|
|
3001
|
+
return map;
|
|
3002
|
+
}, groupMap);
|
|
3003
|
+
}
|
|
2654
3004
|
function getPaginationRowModel(opts) {
|
|
2655
3005
|
return (table) => memo(() => [table.getState().pagination, table.getPrePaginationRowModel(), table.options.paginateExpandedRows ? void 0 : table.getState().expanded], (pagination, rowModel) => {
|
|
2656
3006
|
if (!rowModel.rows.length) {
|
|
@@ -2789,6 +3139,7 @@ export {
|
|
|
2789
3139
|
buildHeaderGroups,
|
|
2790
3140
|
createCell,
|
|
2791
3141
|
createColumn,
|
|
3142
|
+
createColumnHelper,
|
|
2792
3143
|
createRow,
|
|
2793
3144
|
createTable,
|
|
2794
3145
|
defaultColumnSizing,
|
|
@@ -2798,6 +3149,11 @@ export {
|
|
|
2798
3149
|
functionalUpdate,
|
|
2799
3150
|
getCoreRowModel,
|
|
2800
3151
|
getExpandedRowModel,
|
|
3152
|
+
getFacetedMinMaxValues,
|
|
3153
|
+
getFacetedRowModel,
|
|
3154
|
+
getFacetedUniqueValues,
|
|
3155
|
+
getFilteredRowModel,
|
|
3156
|
+
getGroupedRowModel,
|
|
2801
3157
|
getMemoOptions,
|
|
2802
3158
|
getPaginationRowModel,
|
|
2803
3159
|
getSortedRowModel,
|
|
@@ -2807,6 +3163,7 @@ export {
|
|
|
2807
3163
|
isSubRowSelected,
|
|
2808
3164
|
makeStateUpdater,
|
|
2809
3165
|
memo,
|
|
3166
|
+
noop,
|
|
2810
3167
|
orderColumns,
|
|
2811
3168
|
passiveEventSupported,
|
|
2812
3169
|
reSplitAlphaNumeric,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis-ui/table",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.18.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://npm.pkg.github.com/"
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
"styled-components": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@redis-ui/components": "^39.
|
|
35
|
-
"@redis-ui/icons": "^6.1.
|
|
36
|
-
"@redis-ui/styles": "^12.
|
|
37
|
-
"@tanstack/react-table": "^8.9.8"
|
|
34
|
+
"@redis-ui/components": "^39.18.0",
|
|
35
|
+
"@redis-ui/icons": "^6.1.1",
|
|
36
|
+
"@redis-ui/styles": "^12.8.0",
|
|
37
|
+
"@tanstack/react-table": "^8.9.8",
|
|
38
|
+
"type-fest": "^3.13.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@redislabsdev/eslint-config-redis-ui": "^2.0.0",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
|
|
4
|
-
const TableHeaderCell_utils = require("../TableHeaderCell/TableHeaderCell.utils.cjs");
|
|
5
|
-
const Table_style = require("../../Table.style.cjs");
|
|
6
|
-
const EmptyStateRow = ({
|
|
7
|
-
table,
|
|
8
|
-
emptyState
|
|
9
|
-
}) => jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableBodyRow, {
|
|
10
|
-
"$stripedRows": false,
|
|
11
|
-
children: jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableBodyCell, {
|
|
12
|
-
colSpan: TableHeaderCell_utils.normalizeCellSpan(table.getVisibleLeafColumns().length),
|
|
13
|
-
children: (emptyState == null ? void 0 : emptyState()) ?? "No data to display"
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
|
-
exports.EmptyStateRow = EmptyStateRow;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Table } from '@tanstack/react-table';
|
|
3
|
-
type EmptyStateRowProps<T extends object> = {
|
|
4
|
-
table: Table<T>;
|
|
5
|
-
emptyState?: () => ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare const EmptyStateRow: <T extends object>({ table, emptyState }: EmptyStateRowProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { normalizeCellSpan } from "../TableHeaderCell/TableHeaderCell.utils.js";
|
|
3
|
-
import { TableBodyRow, TableBodyCell } from "../../Table.style.js";
|
|
4
|
-
const EmptyStateRow = ({
|
|
5
|
-
table,
|
|
6
|
-
emptyState
|
|
7
|
-
}) => jsxRuntimeExports.jsx(TableBodyRow, {
|
|
8
|
-
"$stripedRows": false,
|
|
9
|
-
children: jsxRuntimeExports.jsx(TableBodyCell, {
|
|
10
|
-
colSpan: normalizeCellSpan(table.getVisibleLeafColumns().length),
|
|
11
|
-
children: (emptyState == null ? void 0 : emptyState()) ?? "No data to display"
|
|
12
|
-
})
|
|
13
|
-
});
|
|
14
|
-
export {
|
|
15
|
-
EmptyStateRow
|
|
16
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const index = require("../../react-use-layout-effect/dist/index.cjs");
|
|
5
|
-
function _interopNamespace(e) {
|
|
6
|
-
if (e && e.__esModule) return e;
|
|
7
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
-
if (e) {
|
|
9
|
-
for (const k in e) {
|
|
10
|
-
if (k !== "default") {
|
|
11
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: () => e[k]
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
23
|
-
var useReactId = React__namespace["useId".toString()] || (() => void 0);
|
|
24
|
-
var count = 0;
|
|
25
|
-
function useId(deterministicId) {
|
|
26
|
-
const [id, setId] = React__namespace.useState(useReactId());
|
|
27
|
-
index.useLayoutEffect(() => {
|
|
28
|
-
setId((reactId) => reactId ?? String(count++));
|
|
29
|
-
}, [deterministicId]);
|
|
30
|
-
return id ? `radix-${id}` : "";
|
|
31
|
-
}
|
|
32
|
-
exports.useId = useId;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useLayoutEffect as useLayoutEffect2 } from "../../react-use-layout-effect/dist/index.js";
|
|
3
|
-
var useReactId = React["useId".toString()] || (() => void 0);
|
|
4
|
-
var count = 0;
|
|
5
|
-
function useId(deterministicId) {
|
|
6
|
-
const [id, setId] = React.useState(useReactId());
|
|
7
|
-
useLayoutEffect2(() => {
|
|
8
|
-
setId((reactId) => reactId ?? String(count++));
|
|
9
|
-
}, [deterministicId]);
|
|
10
|
-
return id ? `radix-${id}` : "";
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
useId
|
|
14
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
function _interopNamespace(e) {
|
|
5
|
-
if (e && e.__esModule) return e;
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
22
|
-
var useLayoutEffect2 = Boolean(globalThis == null ? void 0 : globalThis.document) ? React__namespace.useLayoutEffect : () => {
|
|
23
|
-
};
|
|
24
|
-
exports.useLayoutEffect = useLayoutEffect2;
|