@popmenu/table 0.70.0 → 0.71.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/FilterPanel/FilterPanelContext/FilterPanelContext.d.ts +7 -0
- package/build/components/FilterPanel/FilterPanelContext/index.d.ts +1 -0
- package/build/components/Table/Table.d.ts +2 -0
- package/build/components/Table/TableProps.d.ts +2 -0
- package/build/index.es.js +17 -5
- package/build/index.es.js.map +1 -1
- package/build/index.js +17 -5
- package/build/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type FilterPanelContextValue = {
|
|
3
|
+
anchorState: [Element | null, React.Dispatch<React.SetStateAction<Element | null>>];
|
|
4
|
+
};
|
|
5
|
+
export declare const FilterPanelContext: React.Context<FilterPanelContextValue | null>;
|
|
6
|
+
export declare const useFilterPanelContext: () => FilterPanelContextValue;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilterPanelContext, useFilterPanelContext } from './FilterPanelContext';
|
|
@@ -3,6 +3,7 @@ import { TableProps } from './TableProps';
|
|
|
3
3
|
declare const defaultTableProps: {
|
|
4
4
|
enableSortingRemoval: boolean;
|
|
5
5
|
fullWidth: boolean;
|
|
6
|
+
paginated: boolean;
|
|
6
7
|
sortable: boolean;
|
|
7
8
|
searchable: boolean;
|
|
8
9
|
};
|
|
@@ -12,6 +13,7 @@ export declare const Table: {
|
|
|
12
13
|
defaultProps: {
|
|
13
14
|
enableSortingRemoval: boolean;
|
|
14
15
|
fullWidth: boolean;
|
|
16
|
+
paginated: boolean;
|
|
15
17
|
sortable: boolean;
|
|
16
18
|
searchable: boolean;
|
|
17
19
|
};
|
|
@@ -22,6 +22,8 @@ export interface TableProps<T = unknown> {
|
|
|
22
22
|
searchable?: boolean;
|
|
23
23
|
/** Makes columns sortable. For uncontrolled sorting only. */
|
|
24
24
|
sortable?: boolean;
|
|
25
|
+
/** Enables and disables pagination all together for the table. */
|
|
26
|
+
paginated?: boolean;
|
|
25
27
|
/** Sorting state. Expects the result of a React useState hook. Used only for manual sorting. */
|
|
26
28
|
sortingState?: [SortingState, Dispatch<SetStateAction<SortingState>>];
|
|
27
29
|
/** Pagination state. Expects the result of a React useState hook. Used only for manual pagination. */
|
package/build/index.es.js
CHANGED
|
@@ -1215,12 +1215,22 @@ var useStyles$4 = makeStyles(function (theme) { return ({
|
|
|
1215
1215
|
|
|
1216
1216
|
var TableContext = createContext({});
|
|
1217
1217
|
|
|
1218
|
+
var FilterPanelContext = createContext(null);
|
|
1219
|
+
var useFilterPanelContext = function () {
|
|
1220
|
+
var context = useContext(FilterPanelContext);
|
|
1221
|
+
if (!context) {
|
|
1222
|
+
throw new Error('useFilterPanelContext has to be used within <FilterPanelContext.Provider>');
|
|
1223
|
+
}
|
|
1224
|
+
return context;
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1218
1227
|
var SelectFilter = function (props) {
|
|
1219
1228
|
var _a, _b, _c;
|
|
1220
1229
|
var options = props.options, columnId = props.columnId, multiple = props.multiple;
|
|
1221
1230
|
var classes = useStyles$4();
|
|
1222
1231
|
var table = useContext(TableContext);
|
|
1223
|
-
var _d =
|
|
1232
|
+
var _d = useFilterPanelContext().anchorState, setAnchorEl = _d[1];
|
|
1233
|
+
var _e = useState(false), open = _e[0], setOpen = _e[1];
|
|
1224
1234
|
var column = table.getColumn(columnId);
|
|
1225
1235
|
var meta = column.columnDef.meta;
|
|
1226
1236
|
var filterName = (_a = meta === null || meta === void 0 ? void 0 : meta.filter) === null || _a === void 0 ? void 0 : _a.name;
|
|
@@ -1255,6 +1265,7 @@ var SelectFilter = function (props) {
|
|
|
1255
1265
|
var handleChange = function (event) {
|
|
1256
1266
|
event.stopPropagation();
|
|
1257
1267
|
column.setFilterValue(event.target.value);
|
|
1268
|
+
setAnchorEl(null);
|
|
1258
1269
|
};
|
|
1259
1270
|
var handleItemClick = function () {
|
|
1260
1271
|
if (multiple) {
|
|
@@ -3183,7 +3194,7 @@ var FilterPanel = function () {
|
|
|
3183
3194
|
var handleClose = function () {
|
|
3184
3195
|
setAnchorEl(null);
|
|
3185
3196
|
};
|
|
3186
|
-
return (React__default.createElement(
|
|
3197
|
+
return (React__default.createElement(FilterPanelContext.Provider, { value: { anchorState: [anchorEl, setAnchorEl] } },
|
|
3187
3198
|
React__default.createElement(Trigger, { onClick: handleClick }),
|
|
3188
3199
|
React__default.createElement(Panel, { onClose: handleClose, anchorEl: anchorEl })));
|
|
3189
3200
|
};
|
|
@@ -3991,11 +4002,12 @@ var ColumnFilterResetButton = function (props) {
|
|
|
3991
4002
|
var defaultTableProps = {
|
|
3992
4003
|
enableSortingRemoval: true,
|
|
3993
4004
|
fullWidth: true,
|
|
4005
|
+
paginated: true,
|
|
3994
4006
|
sortable: false,
|
|
3995
4007
|
searchable: false,
|
|
3996
4008
|
};
|
|
3997
4009
|
var Table = function (props) {
|
|
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;
|
|
4010
|
+
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, paginated = props.paginated, pageCount = props.pageCount, GlobalFilterProps = props.GlobalFilterProps, Empty = props.Empty, idBase = props.idBase;
|
|
3999
4011
|
var classes = useStyles$7(props);
|
|
4000
4012
|
var rootRef = useRef(null);
|
|
4001
4013
|
// Prepare Empty State
|
|
@@ -4021,7 +4033,7 @@ var Table = function (props) {
|
|
|
4021
4033
|
var columnVisibility = (externalVisibilityState || [])[0];
|
|
4022
4034
|
var isControlledColumnVisibility = Boolean(externalVisibilityState);
|
|
4023
4035
|
// Init table instance
|
|
4024
|
-
var table = useReactTable(__assign$3(__assign$3(__assign$3(__assign$3(__assign$3({ data: data, columns: columns, state: __assign$3(__assign$3(__assign$3(__assign$3(__assign$3({}, (isControlledPagination && { pagination: pagination })), (isControlledGlobalFilter && { globalFilter: globalFilter })), (isControlledColumnFilters && { columnFilters: columnFilters })), (isControlledColumnVisibility && { columnVisibility: columnVisibility })), (isControlledColumnSort && { sorting: sorting })), enableSorting: sortable, enableSortingRemoval: enableSortingRemoval, globalFilterFn: coercedValueIncludesString, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), getPaginationRowModel: getPaginationRowModel() }, (isControlledPagination && controlledPaginationOptions)), (isControlledGlobalFilter && controlledGlobalFilterOptions)), (isControlledColumnFilters && controlledColumnFiltersOptions)), (isControlledColumnSort && controlledColumnSortOptions)), { meta: { idBase: idBase } }));
|
|
4036
|
+
var table = useReactTable(__assign$3(__assign$3(__assign$3(__assign$3(__assign$3(__assign$3({ data: data, columns: columns, state: __assign$3(__assign$3(__assign$3(__assign$3(__assign$3({}, (isControlledPagination && { pagination: pagination })), (isControlledGlobalFilter && { globalFilter: globalFilter })), (isControlledColumnFilters && { columnFilters: columnFilters })), (isControlledColumnVisibility && { columnVisibility: columnVisibility })), (isControlledColumnSort && { sorting: sorting })), enableSorting: sortable, enableSortingRemoval: enableSortingRemoval, globalFilterFn: coercedValueIncludesString, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel() }, (paginated && { getPaginationRowModel: getPaginationRowModel() })), (isControlledPagination && controlledPaginationOptions)), (isControlledGlobalFilter && controlledGlobalFilterOptions)), (isControlledColumnFilters && controlledColumnFiltersOptions)), (isControlledColumnSort && controlledColumnSortOptions)), { meta: { idBase: idBase } }));
|
|
4025
4037
|
var _f = useColumnFilters(table), selectedColumnFilters = _f.selectedColumnFilters, hasColumnFilters = _f.hasColumnFilters, deselectColumnFilter = _f.deselectColumnFilter, formatSelectedFilterText = _f.formatSelectedFilterText, resetColumnFilters = _f.resetColumnFilters;
|
|
4026
4038
|
var handlePagination = function (_e, pageNumber) {
|
|
4027
4039
|
var pageIndex = pageNumber - 1;
|
|
@@ -4050,7 +4062,7 @@ var Table = function (props) {
|
|
|
4050
4062
|
isEmpty && isEmptyComponentValid && Empty && !loading && (React__default.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 }, createElement(Empty))),
|
|
4051
4063
|
loading && (React__default.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
4052
4064
|
React__default.createElement(CircularProgress, { size: 80, color: "inherit" }))),
|
|
4053
|
-
table.getPageCount() > 1 && (React__default.createElement(TableFooter, null,
|
|
4065
|
+
paginated && table.getPageCount() > 1 && (React__default.createElement(TableFooter, null,
|
|
4054
4066
|
React__default.createElement(Pagination, { page: table.getState().pagination.pageIndex + 1, count: table.getPageCount(), onChange: handlePagination, disabled: loading }))))));
|
|
4055
4067
|
};
|
|
4056
4068
|
Table.defaultProps = defaultTableProps;
|