@popmenu/table 0.68.1 → 0.69.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/build/components/Table/TableProps.d.ts +2 -0
- package/build/components/TableControlsContainer/TableControlsContainer.d.ts +3 -0
- package/build/components/TableControlsContainer/TableControlsContainerProps.d.ts +6 -0
- package/build/components/TableControlsContainer/index.d.ts +1 -0
- package/build/index.es.js +46 -11
- package/build/index.es.js.map +1 -1
- package/build/index.js +46 -11
- package/build/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableControlsContainer } from './TableControlsContainer';
|
package/build/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { createElement, forwardRef, createContext, useContext, useState, useRef, isValidElement } from 'react';
|
|
3
|
+
import { makeStyles, Typography as Typography$2, Link as Link$2, Paper as Paper$2, Box, FormControl, InputLabel, Select, TextField, Popover, ButtonBase, InputAdornment, useTheme as useTheme$1 } from '@material-ui/core';
|
|
3
4
|
import { Pagination } from '@material-ui/lab';
|
|
4
5
|
import { useReactTable, getCoreRowModel, getSortedRowModel, getFilteredRowModel, getPaginationRowModel, flexRender } from '@tanstack/react-table';
|
|
5
|
-
import { makeStyles, Typography as Typography$2, Link as Link$2, Paper as Paper$2, Box, FormControl, InputLabel, Select, TextField, Popover, ButtonBase, InputAdornment, useTheme as useTheme$1 } from '@material-ui/core';
|
|
6
6
|
import CommonAlert from '@material-ui/lab/Alert';
|
|
7
7
|
import '@material-ui/core/AppBar';
|
|
8
8
|
import MuiAvatar from '@material-ui/core/Avatar';
|
|
@@ -2805,17 +2805,17 @@ var useSettingsIndexCardStyles = makeStyles$1(function (theme) { return ({
|
|
|
2805
2805
|
}); });
|
|
2806
2806
|
|
|
2807
2807
|
var SettingsIndexCard = forwardRef(function (props, ref) {
|
|
2808
|
-
var title = props.title, description = props.description, Icon
|
|
2808
|
+
var title = props.title, description = props.description, Icon = props.Icon, onClick = props.onClick, statusLabel = props.statusLabel, restProps = __rest$1(props, ["title", "description", "Icon", "onClick", "statusLabel"]);
|
|
2809
2809
|
var classes = useSettingsIndexCardStyles(props);
|
|
2810
2810
|
var showStatusLabel = (statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.text) && (statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.color);
|
|
2811
2811
|
return (React__default.createElement(ButtonBase, __assign$1({ onClick: onClick, ref: ref }, restProps),
|
|
2812
2812
|
React__default.createElement(Card, { classes: { root: classes.cardRoot } },
|
|
2813
2813
|
React__default.createElement(CardContent, { classes: { root: classes.cardContentRoot } },
|
|
2814
2814
|
React__default.createElement(Box, { fontSize: "32px", display: "flex", justifyContent: 'space-between', alignItems: "center", paddingBottom: 2 },
|
|
2815
|
-
React__default.createElement(Icon, { icon: Icon
|
|
2816
|
-
showStatusLabel && (React__default.createElement(Typography, { weight: "semi-bold", variant: "body2", color: statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.color }, statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.text))),
|
|
2817
|
-
React__default.createElement(Typography, { align: "left", variant: "h6", gutterBottom: true }, title),
|
|
2818
|
-
description && (React__default.createElement(Typography, { align: "left", variant: "body2", color: "grey.700" }, description))))));
|
|
2815
|
+
React__default.createElement(Icon$1, { icon: Icon || SvgHelp, size: "inherit" }),
|
|
2816
|
+
showStatusLabel && (React__default.createElement(Typography$1, { weight: "semi-bold", variant: "body2", color: statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.color }, statusLabel === null || statusLabel === void 0 ? void 0 : statusLabel.text))),
|
|
2817
|
+
React__default.createElement(Typography$1, { align: "left", variant: "h6", gutterBottom: true }, title),
|
|
2818
|
+
description && (React__default.createElement(Typography$1, { align: "left", variant: "body2", color: "grey.700" }, description))))));
|
|
2819
2819
|
});
|
|
2820
2820
|
SettingsIndexCard.displayName = 'SettingsIndexCard';
|
|
2821
2821
|
|
|
@@ -3165,6 +3165,7 @@ createTheme(adminDarkOptions);
|
|
|
3165
3165
|
var useStyles$3 = makeStyles({
|
|
3166
3166
|
root: {
|
|
3167
3167
|
justifySelf: 'end',
|
|
3168
|
+
gridArea: 'columnFilter',
|
|
3168
3169
|
},
|
|
3169
3170
|
});
|
|
3170
3171
|
|
|
@@ -3193,6 +3194,7 @@ var useStyles$2 = makeStyles({
|
|
|
3193
3194
|
maxWidth: 300,
|
|
3194
3195
|
minWidth: 200,
|
|
3195
3196
|
width: '100%',
|
|
3197
|
+
gridArea: 'globalFilter',
|
|
3196
3198
|
},
|
|
3197
3199
|
});
|
|
3198
3200
|
|
|
@@ -3952,6 +3954,35 @@ var ColumnFilterChip = function (props) {
|
|
|
3952
3954
|
React__default.createElement(Typography$1, __assign$3({ className: classes.label, weight: "semi-bold" }, { component: 'span' }), label[1])) }));
|
|
3953
3955
|
};
|
|
3954
3956
|
|
|
3957
|
+
var TableControlsContainer = function (props) {
|
|
3958
|
+
var showTitle = props.showTitle, showGlobalSearch = props.showGlobalSearch, showColumnFilter = props.showColumnFilter;
|
|
3959
|
+
var gridTemplateAreas;
|
|
3960
|
+
switch (true) {
|
|
3961
|
+
case showTitle && showGlobalSearch && showColumnFilter:
|
|
3962
|
+
gridTemplateAreas = "\n \"title .\"\n \"globalFilter columnFilter\"\n ";
|
|
3963
|
+
break;
|
|
3964
|
+
case showTitle && !showGlobalSearch && showColumnFilter:
|
|
3965
|
+
gridTemplateAreas = "\n \"title columnFilter\"\n ";
|
|
3966
|
+
break;
|
|
3967
|
+
case !showTitle && showGlobalSearch && showColumnFilter:
|
|
3968
|
+
gridTemplateAreas = "\n \"globalFilter columnFilter\"\n ";
|
|
3969
|
+
break;
|
|
3970
|
+
case showTitle && !showGlobalSearch && !showColumnFilter:
|
|
3971
|
+
gridTemplateAreas = "\n \"title .\"\n ";
|
|
3972
|
+
break;
|
|
3973
|
+
case !showTitle && !showGlobalSearch && showColumnFilter:
|
|
3974
|
+
gridTemplateAreas = "\n \". columnFilter\"\n ";
|
|
3975
|
+
break;
|
|
3976
|
+
case !showTitle && showGlobalSearch && !showColumnFilter:
|
|
3977
|
+
gridTemplateAreas = "\n \"globalFilter .\"\n ";
|
|
3978
|
+
break;
|
|
3979
|
+
case showTitle && showGlobalSearch && !showColumnFilter:
|
|
3980
|
+
gridTemplateAreas = "\n \"title .\"\n \"globalFilter .\"\n ";
|
|
3981
|
+
break;
|
|
3982
|
+
}
|
|
3983
|
+
return (React__default.createElement(Box, { display: "grid", gridTemplateColumns: "repeat(2, minmax(150px, 1fr))", gridTemplateAreas: gridTemplateAreas, gridGap: 16, marginBottom: 3 }, props.children));
|
|
3984
|
+
};
|
|
3985
|
+
|
|
3955
3986
|
var ColumnFilterResetButton = function (props) {
|
|
3956
3987
|
var _a = props.children, children = _a === void 0 ? 'Clear All' : _a, restProps = __rest$3(props, ["children"]);
|
|
3957
3988
|
return (React__default.createElement(Button, __assign$3({ variant: "text", textTransform: "none" }, restProps), children));
|
|
@@ -3964,7 +3995,7 @@ var defaultTableProps = {
|
|
|
3964
3995
|
searchable: false,
|
|
3965
3996
|
};
|
|
3966
3997
|
var Table = function (props) {
|
|
3967
|
-
var data = props.data, columns = props.columns, enableSortingRemoval = props.enableSortingRemoval, loading = props.loading, searchable = props.searchable, sortable = props.sortable, externalFilterState = props.filterState, externalGlobalFilterState = props.globalFilterState, externalPaginationState = props.paginationState, externalSortingState = props.sortingState, externalVisibilityState = props.visibilityState, pageCount = props.pageCount, GlobalFilterProps = props.GlobalFilterProps, Empty = props.Empty, idBase = props.idBase;
|
|
3998
|
+
var title = props.title, data = props.data, columns = props.columns, enableSortingRemoval = props.enableSortingRemoval, loading = props.loading, searchable = props.searchable, sortable = props.sortable, externalFilterState = props.filterState, externalGlobalFilterState = props.globalFilterState, externalPaginationState = props.paginationState, externalSortingState = props.sortingState, externalVisibilityState = props.visibilityState, pageCount = props.pageCount, GlobalFilterProps = props.GlobalFilterProps, Empty = props.Empty, idBase = props.idBase;
|
|
3968
3999
|
var classes = useStyles$7(props);
|
|
3969
4000
|
var rootRef = useRef(null);
|
|
3970
4001
|
// Prepare Empty State
|
|
@@ -3996,15 +4027,19 @@ var Table = function (props) {
|
|
|
3996
4027
|
var pageIndex = pageNumber - 1;
|
|
3997
4028
|
table.setPageIndex(pageIndex);
|
|
3998
4029
|
};
|
|
3999
|
-
var
|
|
4030
|
+
var showTitle = Boolean(title);
|
|
4031
|
+
var showGlobalSearch = Boolean(searchable || isControlledGlobalFilter);
|
|
4032
|
+
var showColumnFilter = Boolean(hasColumnFilters);
|
|
4033
|
+
var showControls = Boolean(showTitle || showGlobalSearch || showColumnFilter);
|
|
4000
4034
|
return (React__default.createElement(TableContext.Provider, { value: table },
|
|
4001
4035
|
React__default.createElement(Box, __assign$3({ className: classes.root }, { ref: rootRef }, { "data-table-element": "root" }, (table.getPageCount() > 1 && {
|
|
4002
4036
|
minHeight: getTableMinHeight(rootRef, table.getState().pagination.pageSize),
|
|
4003
4037
|
})),
|
|
4004
4038
|
showControls && (React__default.createElement(Box, null,
|
|
4005
|
-
React__default.createElement(
|
|
4006
|
-
|
|
4007
|
-
|
|
4039
|
+
React__default.createElement(TableControlsContainer, { showTitle: showTitle, showGlobalSearch: showGlobalSearch, showColumnFilter: showColumnFilter },
|
|
4040
|
+
showTitle && (React__default.createElement(Typography$2, { variant: "h5", style: { gridArea: 'title', alignSelf: 'center' } }, title)),
|
|
4041
|
+
showGlobalSearch && (React__default.createElement(GlobalFilter, __assign$3({}, GlobalFilterProps, { value: table.getState().globalFilter, setValue: table.setGlobalFilter }))),
|
|
4042
|
+
showColumnFilter && React__default.createElement(FilterPanel, null)),
|
|
4008
4043
|
React__default.createElement(Box, { display: "flex", flexWrap: "wrap", gridGap: 8 },
|
|
4009
4044
|
selectedColumnFilters.map(function (selectedColumnFilter, i) { return (React__default.createElement(ColumnFilterChip, { key: "selected-column-filter-chip-" + i, columnFilter: selectedColumnFilter, label: formatSelectedFilterText(selectedColumnFilter), onClick: deselectColumnFilter })); }),
|
|
4010
4045
|
selectedColumnFilters.length >= 1 && React__default.createElement(ColumnFilterResetButton, { onClick: function () { return resetColumnFilters(); } })))),
|