@natoora-libs/core 0.1.2 → 0.1.4-dev-doug-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.
|
@@ -7332,6 +7332,7 @@ var Switch_default = (0, import_react31.memo)(LabelledSwitch);
|
|
|
7332
7332
|
// src/components/SmartTableHeaderFilterMenu/SmartTableHeaderFilterMenu.tsx
|
|
7333
7333
|
var import_react32 = __toESM(require("react"), 1);
|
|
7334
7334
|
var import_icons_material14 = require("@mui/icons-material");
|
|
7335
|
+
var import_Check = __toESM(require("@mui/icons-material/Check"), 1);
|
|
7335
7336
|
var import_material58 = require("@mui/material");
|
|
7336
7337
|
var import_classnames3 = __toESM(require("classnames"), 1);
|
|
7337
7338
|
var import_mui51 = require("tss-react/mui");
|
|
@@ -7342,14 +7343,18 @@ var useStyles45 = (0, import_mui51.makeStyles)()((theme) => ({
|
|
|
7342
7343
|
flexDirection: "column",
|
|
7343
7344
|
gap: theme.spacing(0.5)
|
|
7344
7345
|
},
|
|
7345
|
-
|
|
7346
|
+
filter: {
|
|
7346
7347
|
display: "flex",
|
|
7347
|
-
|
|
7348
|
+
alignItems: "center",
|
|
7349
|
+
justifyContent: "space-between",
|
|
7348
7350
|
padding: theme.spacing(0, 3)
|
|
7349
7351
|
},
|
|
7350
7352
|
applyFilterButtonsContainer: {
|
|
7351
7353
|
display: "flex",
|
|
7352
7354
|
padding: theme.spacing(0, 1)
|
|
7355
|
+
},
|
|
7356
|
+
saveAsDefaultButton: {
|
|
7357
|
+
color: theme.palette.primary.main
|
|
7353
7358
|
}
|
|
7354
7359
|
}));
|
|
7355
7360
|
var resolveFilterOption = (filterOption) => {
|
|
@@ -7369,18 +7374,21 @@ var findFilterIndex = (filters, filterOption) => filters.findIndex((item) => {
|
|
|
7369
7374
|
});
|
|
7370
7375
|
var SmartTableHeaderFilterMenu = ({
|
|
7371
7376
|
headCell,
|
|
7372
|
-
|
|
7377
|
+
numActiveFilters,
|
|
7373
7378
|
headerFilters,
|
|
7379
|
+
shouldShowCheckOnFilter,
|
|
7374
7380
|
onApplyFilters
|
|
7375
7381
|
}) => {
|
|
7376
7382
|
const { classes } = useStyles45();
|
|
7377
7383
|
const [anchorEl, setAnchorEl] = (0, import_react32.useState)(null);
|
|
7378
|
-
const [shouldSave, setShouldSave] = (0, import_react32.useState)(false);
|
|
7379
7384
|
const [selectedFilters, setSelectedFilters] = (0, import_react32.useState)(
|
|
7380
7385
|
headerFilters[headCell.id] ?? []
|
|
7381
7386
|
);
|
|
7387
|
+
const filterOptions = headCell.filterOptionsQuery?.data ?? [];
|
|
7388
|
+
const numFilterOptions = filterOptions.length ?? 0;
|
|
7389
|
+
const numCurrentSelectedFilters = selectedFilters.length;
|
|
7382
7390
|
const handleFilterMenuOpen = (event) => {
|
|
7383
|
-
if (!
|
|
7391
|
+
if (!numFilterOptions) {
|
|
7384
7392
|
headCell.filterOptionsQuery?.refetch();
|
|
7385
7393
|
}
|
|
7386
7394
|
setAnchorEl(event.currentTarget);
|
|
@@ -7388,7 +7396,6 @@ var SmartTableHeaderFilterMenu = ({
|
|
|
7388
7396
|
const handleFilterMenuClose = () => {
|
|
7389
7397
|
setSelectedFilters(headerFilters[headCell.id]);
|
|
7390
7398
|
setAnchorEl(null);
|
|
7391
|
-
setShouldSave(false);
|
|
7392
7399
|
};
|
|
7393
7400
|
const handleFilterOptionClick = (option) => {
|
|
7394
7401
|
const selectedIndex = findFilterIndex(selectedFilters, option);
|
|
@@ -7406,6 +7413,20 @@ var SmartTableHeaderFilterMenu = ({
|
|
|
7406
7413
|
}
|
|
7407
7414
|
setSelectedFilters(newSelected);
|
|
7408
7415
|
};
|
|
7416
|
+
const handleApplyFilters = (shouldSave) => {
|
|
7417
|
+
const updatedFilters = {
|
|
7418
|
+
...headerFilters,
|
|
7419
|
+
[headCell.id]: [...selectedFilters]
|
|
7420
|
+
};
|
|
7421
|
+
onApplyFilters?.(updatedFilters, shouldSave);
|
|
7422
|
+
setAnchorEl(null);
|
|
7423
|
+
};
|
|
7424
|
+
(0, import_react32.useEffect)(() => {
|
|
7425
|
+
setSelectedFilters(headerFilters[headCell.id] ?? []);
|
|
7426
|
+
}, [headerFilters, headCell.id]);
|
|
7427
|
+
const isOptionChecked = (0, import_react32.useMemo)(() => (resolvedOption) => !!selectedFilters?.some(
|
|
7428
|
+
(value) => resolveFilterOption(value) === resolvedOption
|
|
7429
|
+
), [selectedFilters]);
|
|
7409
7430
|
return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
|
|
7410
7431
|
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7411
7432
|
import_material58.IconButton,
|
|
@@ -7415,13 +7436,13 @@ var SmartTableHeaderFilterMenu = ({
|
|
|
7415
7436
|
"data-testid": "filter-menu-button",
|
|
7416
7437
|
style: { padding: 0 },
|
|
7417
7438
|
className: (0, import_classnames3.default)("filter-menu-trigger", {
|
|
7418
|
-
"has-active-filters":
|
|
7439
|
+
"has-active-filters": numActiveFilters
|
|
7419
7440
|
}),
|
|
7420
|
-
children:
|
|
7441
|
+
children: numActiveFilters ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7421
7442
|
import_material58.Chip,
|
|
7422
7443
|
{
|
|
7423
7444
|
sx: { height: 24 },
|
|
7424
|
-
label:
|
|
7445
|
+
label: numActiveFilters,
|
|
7425
7446
|
icon: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_icons_material14.FilterList, { style: { fontSize: 18 }, color: "primary" })
|
|
7426
7447
|
}
|
|
7427
7448
|
) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_icons_material14.FilterList, { style: { fontSize: 18 } })
|
|
@@ -7437,61 +7458,69 @@ var SmartTableHeaderFilterMenu = ({
|
|
|
7437
7458
|
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
7438
7459
|
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
7439
7460
|
children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_material58.Box, { className: classes.filterMenu, children: [
|
|
7440
|
-
|
|
7461
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_material58.Box, { px: 3, children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7462
|
+
import_material58.FormControlLabel,
|
|
7463
|
+
{
|
|
7464
|
+
label: "Select All",
|
|
7465
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7466
|
+
import_material58.Checkbox,
|
|
7467
|
+
{
|
|
7468
|
+
disableRipple: true,
|
|
7469
|
+
checked: numCurrentSelectedFilters === numFilterOptions,
|
|
7470
|
+
indeterminate: numCurrentSelectedFilters > 0 && numCurrentSelectedFilters < numFilterOptions,
|
|
7471
|
+
onChange: ({ target: { checked } }) => {
|
|
7472
|
+
if (checked) {
|
|
7473
|
+
setSelectedFilters([...filterOptions]);
|
|
7474
|
+
} else {
|
|
7475
|
+
setSelectedFilters([]);
|
|
7476
|
+
}
|
|
7477
|
+
}
|
|
7478
|
+
}
|
|
7479
|
+
)
|
|
7480
|
+
}
|
|
7481
|
+
) }),
|
|
7482
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_material58.Divider, {}),
|
|
7483
|
+
filterOptions.map(
|
|
7441
7484
|
(option) => {
|
|
7442
7485
|
const resolvedOption = resolveFilterOption(option);
|
|
7443
|
-
return /* @__PURE__ */ (0, import_jsx_runtime109.
|
|
7444
|
-
import_material58.
|
|
7486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
|
|
7487
|
+
import_material58.Box,
|
|
7445
7488
|
{
|
|
7446
|
-
className: classes.
|
|
7447
|
-
children:
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7489
|
+
className: classes.filter,
|
|
7490
|
+
children: [
|
|
7491
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7492
|
+
import_material58.FormControlLabel,
|
|
7493
|
+
{
|
|
7494
|
+
label: resolvedOption,
|
|
7495
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7496
|
+
import_material58.Checkbox,
|
|
7497
|
+
{
|
|
7498
|
+
disableRipple: true,
|
|
7499
|
+
onChange: () => handleFilterOptionClick(option),
|
|
7500
|
+
checked: isOptionChecked(resolvedOption)
|
|
7501
|
+
}
|
|
7502
|
+
)
|
|
7503
|
+
},
|
|
7504
|
+
resolvedOption
|
|
7505
|
+
),
|
|
7506
|
+
shouldShowCheckOnFilter?.(headCell.id, option) ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_Check.default, { fontSize: "small", color: "action" }) : null
|
|
7507
|
+
]
|
|
7463
7508
|
},
|
|
7464
7509
|
resolvedOption
|
|
7465
7510
|
);
|
|
7466
7511
|
}
|
|
7467
7512
|
),
|
|
7468
7513
|
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_material58.Divider, {}),
|
|
7469
|
-
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_material58.FormControl, { className: classes.filterCheckboxDropdown, children: [
|
|
7470
|
-
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7471
|
-
import_material58.FormControlLabel,
|
|
7472
|
-
{
|
|
7473
|
-
label: "Save Filters",
|
|
7474
|
-
control: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7475
|
-
import_material58.Checkbox,
|
|
7476
|
-
{
|
|
7477
|
-
disableRipple: true,
|
|
7478
|
-
checked: shouldSave,
|
|
7479
|
-
onChange: (e) => setShouldSave(e.target.checked)
|
|
7480
|
-
}
|
|
7481
|
-
)
|
|
7482
|
-
}
|
|
7483
|
-
),
|
|
7484
|
-
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_material58.FormHelperText, { sx: { margin: 0 }, children: "Filters auto-apply on return." })
|
|
7485
|
-
] }),
|
|
7486
|
-
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_material58.Divider, {}),
|
|
7487
7514
|
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_material58.Box, { className: classes.applyFilterButtonsContainer, children: [
|
|
7488
7515
|
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
7489
7516
|
ExtendedButton_default,
|
|
7490
7517
|
{
|
|
7518
|
+
copy: "Save as Default",
|
|
7491
7519
|
buttonType: "button",
|
|
7492
|
-
copy: "Deselect All",
|
|
7493
7520
|
variant: "text",
|
|
7494
|
-
|
|
7521
|
+
tooltip: "Persists those filters for future visits",
|
|
7522
|
+
className: classes.saveAsDefaultButton,
|
|
7523
|
+
onClick: () => handleApplyFilters(true)
|
|
7495
7524
|
}
|
|
7496
7525
|
),
|
|
7497
7526
|
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
@@ -7500,15 +7529,7 @@ var SmartTableHeaderFilterMenu = ({
|
|
|
7500
7529
|
copy: "Apply",
|
|
7501
7530
|
color: "primary",
|
|
7502
7531
|
buttonType: "submit",
|
|
7503
|
-
onClick: () =>
|
|
7504
|
-
const updatedFilters = {
|
|
7505
|
-
...headerFilters,
|
|
7506
|
-
[headCell.id]: [...selectedFilters]
|
|
7507
|
-
};
|
|
7508
|
-
onApplyFilters?.(updatedFilters, shouldSave);
|
|
7509
|
-
setAnchorEl(null);
|
|
7510
|
-
setShouldSave(false);
|
|
7511
|
-
}
|
|
7532
|
+
onClick: () => handleApplyFilters(false)
|
|
7512
7533
|
}
|
|
7513
7534
|
)
|
|
7514
7535
|
] })
|
|
@@ -7588,7 +7609,8 @@ var SmartTableHeader = ({
|
|
|
7588
7609
|
headerFilters,
|
|
7589
7610
|
onRequestSort,
|
|
7590
7611
|
onSelectAllClick,
|
|
7591
|
-
onApplyFilters
|
|
7612
|
+
onApplyFilters,
|
|
7613
|
+
shouldShowCheckOnFilter
|
|
7592
7614
|
}) => {
|
|
7593
7615
|
const { classes } = useStyles46();
|
|
7594
7616
|
const createSortHandler = (property) => (event) => {
|
|
@@ -7610,6 +7632,7 @@ var SmartTableHeader = ({
|
|
|
7610
7632
|
{
|
|
7611
7633
|
className: classes.tableHeaderContent,
|
|
7612
7634
|
align: "left",
|
|
7635
|
+
sx: { width: headCell.width ?? "auto" },
|
|
7613
7636
|
sortDirection: orderBy === headCell.id ? order : false,
|
|
7614
7637
|
children: [
|
|
7615
7638
|
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
|
|
@@ -7630,8 +7653,9 @@ var SmartTableHeader = ({
|
|
|
7630
7653
|
{
|
|
7631
7654
|
headCell,
|
|
7632
7655
|
headerFilters,
|
|
7633
|
-
|
|
7634
|
-
onApplyFilters
|
|
7656
|
+
numActiveFilters: headerFilters[headCell.id]?.length ?? 0,
|
|
7657
|
+
onApplyFilters,
|
|
7658
|
+
shouldShowCheckOnFilter
|
|
7635
7659
|
}
|
|
7636
7660
|
) : null
|
|
7637
7661
|
]
|
|
@@ -7949,7 +7973,9 @@ var TableDesktop = ({
|
|
|
7949
7973
|
handleClickOnClearFiltersButton,
|
|
7950
7974
|
deleteItem,
|
|
7951
7975
|
keyField = "id",
|
|
7952
|
-
|
|
7976
|
+
tableLayout = "auto",
|
|
7977
|
+
onApplyFilters,
|
|
7978
|
+
shouldShowCheckOnFilter
|
|
7953
7979
|
}) => {
|
|
7954
7980
|
const [order, setOrder] = (0, import_react35.useState)(appliedFilters?.sortDir || "desc");
|
|
7955
7981
|
const [orderBy, setOrderBy] = (0, import_react35.useState)(
|
|
@@ -8060,6 +8086,7 @@ var TableDesktop = ({
|
|
|
8060
8086
|
"aria-labelledby": "tableTitle",
|
|
8061
8087
|
"aria-label": "sticky table",
|
|
8062
8088
|
stickyHeader: true,
|
|
8089
|
+
style: { tableLayout },
|
|
8063
8090
|
children: [
|
|
8064
8091
|
/* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
8065
8092
|
SmartTableHeader_default,
|
|
@@ -8073,7 +8100,8 @@ var TableDesktop = ({
|
|
|
8073
8100
|
headerFilters: headerFilters ?? {},
|
|
8074
8101
|
onRequestSort: handleRequestSort,
|
|
8075
8102
|
onSelectAllClick: handleSelectAllClick,
|
|
8076
|
-
onApplyFilters
|
|
8103
|
+
onApplyFilters,
|
|
8104
|
+
shouldShowCheckOnFilter
|
|
8077
8105
|
}
|
|
8078
8106
|
),
|
|
8079
8107
|
/* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_material63.TableBody, { children: rowsPerPage !== emptyRows ? renderTableRows : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|