@natoora-libs/core 0.1.16-dev-doug-1 → 0.1.16-dev-doug-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.
|
@@ -7064,6 +7064,7 @@ var useStyles47 = (0, import_mui53.makeStyles)()((theme) => ({
|
|
|
7064
7064
|
tableHeaderContent: {
|
|
7065
7065
|
borderBottom: "1px solid",
|
|
7066
7066
|
borderBottomColor: colors.neutral300,
|
|
7067
|
+
backgroundColor: colors.neutral100,
|
|
7067
7068
|
whiteSpace: "nowrap",
|
|
7068
7069
|
"& .filter-menu-trigger": {
|
|
7069
7070
|
visibility: "hidden",
|
|
@@ -7114,7 +7115,7 @@ var SmartTableHeader = ({
|
|
|
7114
7115
|
};
|
|
7115
7116
|
const isSortActive = (headCellId) => orderBy === headCellId;
|
|
7116
7117
|
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_material59.TableHead, { className: classes.root, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_material59.TableRow, { children: [
|
|
7117
|
-
enableCheckboxSelection ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_material59.TableCell, { padding: "checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
7118
|
+
enableCheckboxSelection ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_material59.TableCell, { padding: "checkbox", sx: { backgroundColor: colors.neutral100 }, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
7118
7119
|
import_material59.Checkbox,
|
|
7119
7120
|
{
|
|
7120
7121
|
color: "primary",
|
|
@@ -7569,16 +7570,28 @@ var import_material64 = require("@mui/material");
|
|
|
7569
7570
|
var import_jsx_runtime117 = require("react/jsx-runtime");
|
|
7570
7571
|
var TableDesktopRowSelectionBar = ({
|
|
7571
7572
|
isEveryRowInPageSelected,
|
|
7572
|
-
|
|
7573
|
+
isRowsFromAllPagesSelected,
|
|
7573
7574
|
numSelectedRows,
|
|
7574
7575
|
totalRowCount,
|
|
7575
|
-
|
|
7576
|
+
onSelectRowsFromAllPagesClick,
|
|
7577
|
+
onClearSelectionClick
|
|
7576
7578
|
}) => {
|
|
7577
|
-
|
|
7579
|
+
const isAnyRowSelected = numSelectedRows > 0;
|
|
7580
|
+
const getSelectedRowsText = () => {
|
|
7581
|
+
if (isRowsFromAllPagesSelected) {
|
|
7582
|
+
return `All ${totalRowCount} rows from all pages are selected based on your filters.`;
|
|
7583
|
+
}
|
|
7584
|
+
if (isEveryRowInPageSelected) {
|
|
7585
|
+
return `All ${numSelectedRows} rows on this page are selected.`;
|
|
7586
|
+
}
|
|
7587
|
+
return `${numSelectedRows} row${numSelectedRows > 1 ? "s" : ""} selected.`;
|
|
7588
|
+
};
|
|
7589
|
+
return isAnyRowSelected ? /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
|
|
7578
7590
|
import_material64.Box,
|
|
7579
7591
|
{
|
|
7580
7592
|
sx: {
|
|
7581
7593
|
p: 1,
|
|
7594
|
+
height: 40,
|
|
7582
7595
|
gap: 2,
|
|
7583
7596
|
display: "flex",
|
|
7584
7597
|
justifyContent: "center",
|
|
@@ -7586,8 +7599,13 @@ var TableDesktopRowSelectionBar = ({
|
|
|
7586
7599
|
backgroundColor: colors.neutral150
|
|
7587
7600
|
},
|
|
7588
7601
|
children: [
|
|
7589
|
-
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_material64.Typography, { children:
|
|
7590
|
-
/* @__PURE__ */ (0, import_jsx_runtime117.
|
|
7602
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_material64.Typography, { children: getSelectedRowsText() }),
|
|
7603
|
+
!isRowsFromAllPagesSelected ? /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_material64.Button, { onClick: onSelectRowsFromAllPagesClick, children: [
|
|
7604
|
+
"Select all ",
|
|
7605
|
+
totalRowCount,
|
|
7606
|
+
" rows from all pages based on your filters"
|
|
7607
|
+
] }) : null,
|
|
7608
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_material64.Button, { onClick: onClearSelectionClick, children: "Clear Selection" })
|
|
7591
7609
|
]
|
|
7592
7610
|
}
|
|
7593
7611
|
) : null;
|
|
@@ -7674,7 +7692,7 @@ var TableDesktop = ({
|
|
|
7674
7692
|
appliedFilters?.sortField || "delivery_date"
|
|
7675
7693
|
);
|
|
7676
7694
|
const [selectedRows, setSelectedRows] = (0, import_react35.useState)(/* @__PURE__ */ new Set());
|
|
7677
|
-
const [
|
|
7695
|
+
const [isRowsFromAllPagesSelected, setIsRowsFromAllPagesSelected] = (0, import_react35.useState)(false);
|
|
7678
7696
|
const { toolbar: Toolbar2 } = components ?? {};
|
|
7679
7697
|
const { toolbarProps, footerProps } = componentsProps ?? {};
|
|
7680
7698
|
const numRows = (0, import_react35.useMemo)(
|
|
@@ -7702,15 +7720,18 @@ var TableDesktop = ({
|
|
|
7702
7720
|
updateSort(property, orderDir);
|
|
7703
7721
|
}
|
|
7704
7722
|
};
|
|
7723
|
+
const selectAllRowsInPage = () => {
|
|
7724
|
+
const allRowsIds = new Set(data.map((n) => n[keyField]));
|
|
7725
|
+
;
|
|
7726
|
+
setSelectedRows(allRowsIds);
|
|
7727
|
+
};
|
|
7705
7728
|
const resetSelectedRows = () => {
|
|
7706
7729
|
setSelectedRows(/* @__PURE__ */ new Set());
|
|
7707
|
-
|
|
7730
|
+
setIsRowsFromAllPagesSelected(false);
|
|
7708
7731
|
};
|
|
7709
7732
|
const handleSelectAllClick = (event) => {
|
|
7710
7733
|
if (event.target.checked) {
|
|
7711
|
-
|
|
7712
|
-
;
|
|
7713
|
-
setSelectedRows(allRowsIds);
|
|
7734
|
+
selectAllRowsInPage();
|
|
7714
7735
|
return;
|
|
7715
7736
|
}
|
|
7716
7737
|
resetSelectedRows();
|
|
@@ -7724,15 +7745,22 @@ var TableDesktop = ({
|
|
|
7724
7745
|
} else {
|
|
7725
7746
|
newSelected.add(rowId);
|
|
7726
7747
|
}
|
|
7748
|
+
if (newSelected.size < numRows) {
|
|
7749
|
+
setIsRowsFromAllPagesSelected(false);
|
|
7750
|
+
}
|
|
7727
7751
|
return newSelected;
|
|
7728
7752
|
});
|
|
7729
7753
|
};
|
|
7730
|
-
const
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7754
|
+
const handleSelectRowsFromAllPagesClick = () => {
|
|
7755
|
+
setIsRowsFromAllPagesSelected(true);
|
|
7756
|
+
selectAllRowsInPage();
|
|
7757
|
+
};
|
|
7758
|
+
const handleClearSelectionClick = () => {
|
|
7759
|
+
resetSelectedRows();
|
|
7760
|
+
};
|
|
7761
|
+
const handleApplyFilters = (updatedFilters, shouldSave) => {
|
|
7762
|
+
resetSelectedRows();
|
|
7763
|
+
onApplyFilters?.(updatedFilters, shouldSave);
|
|
7736
7764
|
};
|
|
7737
7765
|
const handlePageChange = (event, page) => {
|
|
7738
7766
|
resetSelectedRows();
|
|
@@ -7744,13 +7772,13 @@ var TableDesktop = ({
|
|
|
7744
7772
|
}
|
|
7745
7773
|
}, [enableCheckboxSelection]);
|
|
7746
7774
|
(0, import_react35.useEffect)(() => {
|
|
7747
|
-
if (isEveryRowInPageSelected ||
|
|
7775
|
+
if (isEveryRowInPageSelected || isRowsFromAllPagesSelected) {
|
|
7748
7776
|
const rowsIdsSet = new Set(data.map((obj) => obj[keyField]));
|
|
7749
7777
|
setSelectedRows(
|
|
7750
7778
|
(prev) => new Set([...prev].filter((value) => rowsIdsSet.has(value)))
|
|
7751
7779
|
);
|
|
7752
7780
|
}
|
|
7753
|
-
}, [data, setSelectedRows, isEveryRowInPageSelected,
|
|
7781
|
+
}, [data, setSelectedRows, isEveryRowInPageSelected, isRowsFromAllPagesSelected]);
|
|
7754
7782
|
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
7755
7783
|
import_material66.Box,
|
|
7756
7784
|
{
|
|
@@ -7774,7 +7802,7 @@ var TableDesktop = ({
|
|
|
7774
7802
|
Toolbar2,
|
|
7775
7803
|
{
|
|
7776
7804
|
selectedRows: [...selectedRows],
|
|
7777
|
-
isRowsInAllPagesSelected,
|
|
7805
|
+
isRowsInAllPagesSelected: isRowsFromAllPagesSelected,
|
|
7778
7806
|
...toolbarProps
|
|
7779
7807
|
}
|
|
7780
7808
|
) : null,
|
|
@@ -7782,10 +7810,11 @@ var TableDesktop = ({
|
|
|
7782
7810
|
TableDesktopRowSelectionBar,
|
|
7783
7811
|
{
|
|
7784
7812
|
isEveryRowInPageSelected,
|
|
7785
|
-
|
|
7813
|
+
isRowsFromAllPagesSelected,
|
|
7786
7814
|
numSelectedRows: selectedRows.size,
|
|
7787
7815
|
totalRowCount: totalDataCount ?? 0,
|
|
7788
|
-
|
|
7816
|
+
onSelectRowsFromAllPagesClick: handleSelectRowsFromAllPagesClick,
|
|
7817
|
+
onClearSelectionClick: handleClearSelectionClick
|
|
7789
7818
|
}
|
|
7790
7819
|
),
|
|
7791
7820
|
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
@@ -7829,7 +7858,7 @@ var TableDesktop = ({
|
|
|
7829
7858
|
headerFilters: headerFilters ?? {},
|
|
7830
7859
|
onRequestSort: handleRequestSort,
|
|
7831
7860
|
onSelectAllClick: handleSelectAllClick,
|
|
7832
|
-
onApplyFilters,
|
|
7861
|
+
onApplyFilters: handleApplyFilters,
|
|
7833
7862
|
shouldShowCheckOnFilter
|
|
7834
7863
|
}
|
|
7835
7864
|
),
|