@popmenu/table 0.19.2 → 0.21.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 +14 -3
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/useManualPagination/index.d.ts +1 -0
- package/build/hooks/useManualPagination/useManualPagination.d.ts +5 -0
- package/build/hooks/useManualPagination/useManualPaginationTypes.d.ts +52 -0
- package/build/index.d.ts +1 -0
- package/build/index.es.js +182 -177
- package/build/index.es.js.map +1 -1
- package/build/index.js +180 -175
- package/build/index.js.map +1 -1
- package/build/util/index.d.ts +1 -0
- package/build/util/tableConstants.d.ts +5 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Cell, Column } from 'react-table';
|
|
2
|
+
import { Cell, Column, TableInstance, UsePaginationOptions } from 'react-table';
|
|
3
3
|
export interface TableProps {
|
|
4
4
|
/** Configurations for each individual column. */
|
|
5
5
|
columns: Array<Column & {
|
|
@@ -13,8 +13,8 @@ export interface TableProps {
|
|
|
13
13
|
label: string;
|
|
14
14
|
action: (cell: Cell) => void;
|
|
15
15
|
}>;
|
|
16
|
-
/** Styles the table to
|
|
17
|
-
|
|
16
|
+
/** Styles the table to maintain the height of a fully populated page (entries in a table, not the window). */
|
|
17
|
+
fullHeight?: boolean;
|
|
18
18
|
/** Styles the table to take up its containers full width. */
|
|
19
19
|
fullWidth?: boolean;
|
|
20
20
|
/** Enables sortability for columns. */
|
|
@@ -25,4 +25,15 @@ export interface TableProps {
|
|
|
25
25
|
emptyMessage?: string;
|
|
26
26
|
/** An image to be displayed with the empty message. */
|
|
27
27
|
EmptyImage?: () => React.ReactNode;
|
|
28
|
+
/** Callback for managing pagination events. */
|
|
29
|
+
onPaginate?: (pageIndex: number, instance: TableInstance) => void;
|
|
30
|
+
/** Callback for managing pagination events. */
|
|
31
|
+
paginationOptions?: UsePaginationOptions<Record<string, unknown>> & Partial<{
|
|
32
|
+
initialState: Partial<{
|
|
33
|
+
pageSize: number;
|
|
34
|
+
pageIndex: number;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
37
|
+
/** Added to the main parameter of the useTable hook. */
|
|
38
|
+
tableOptions?: Record<string, unknown>;
|
|
28
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useManualPagination } from './useManualPagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useManualPagination } from './useManualPagination';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UseManualPaginationConfig, UseManualPaginationResult } from './useManualPaginationTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Makes props for the Table component that will enable manual pagination and also provides page state.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useManualPagination: (config: UseManualPaginationConfig) => UseManualPaginationResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TableInstance } from 'react-table';
|
|
2
|
+
interface PaginationEvent {
|
|
3
|
+
/** Index of the page a user has selected. */
|
|
4
|
+
index: number;
|
|
5
|
+
/** The entire table instance by react-table. */
|
|
6
|
+
instance: TableInstance;
|
|
7
|
+
}
|
|
8
|
+
export interface UseManualPaginationConfig {
|
|
9
|
+
/** The total number of records available. */
|
|
10
|
+
total: number;
|
|
11
|
+
/** Sets the default page to show when the table is first presented. */
|
|
12
|
+
initialPageIndex?: number;
|
|
13
|
+
/** Sets the default page size to show when the table is first presented. */
|
|
14
|
+
initialPageSize?: number;
|
|
15
|
+
/** Callback triggered when a pagination even occurs. setPageIndex, which is the second arg of the callback,
|
|
16
|
+
* is required to be called manually. */
|
|
17
|
+
onPaginate?: (paginationEvent: PaginationEvent, setPageIndex: (index: number) => void) => void;
|
|
18
|
+
}
|
|
19
|
+
interface ManualPaginationProps {
|
|
20
|
+
/** A callback for pagination events. Should map to the Table component's onPaginate prop */
|
|
21
|
+
onPaginate: (index: number, instance: TableInstance) => void;
|
|
22
|
+
/** Additional configuration for the Table component. Should map to the Table component's tableOptions prop */
|
|
23
|
+
tableOptions: {
|
|
24
|
+
useControlledState: (state: Record<string, unknown>) => Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
/** Additional configuration for the Table component. Should map to the Table component's paginationOptions prop */
|
|
27
|
+
paginationOptions: {
|
|
28
|
+
initialState: {
|
|
29
|
+
pageIndex: number;
|
|
30
|
+
pageSize: number;
|
|
31
|
+
};
|
|
32
|
+
manualPagination: boolean;
|
|
33
|
+
pageCount: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
interface PageState {
|
|
37
|
+
/** The number of rows a Table shows per page */
|
|
38
|
+
pageSize: number;
|
|
39
|
+
/** The page index a Table will show */
|
|
40
|
+
pageIndex: number;
|
|
41
|
+
/** Updates pageSize */
|
|
42
|
+
setPageSize: (size: number) => void;
|
|
43
|
+
/** Updates pageIndex */
|
|
44
|
+
setPageIndex: (index: number) => void;
|
|
45
|
+
}
|
|
46
|
+
export interface UseManualPaginationResult {
|
|
47
|
+
/** A collection of props for the Table component that will enable manual pagination. Apply with spread operator. */
|
|
48
|
+
manualPaginationProps: ManualPaginationProps;
|
|
49
|
+
/** Stateful values for controlling pages of a Table */
|
|
50
|
+
pageState: PageState;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
package/build/index.d.ts
CHANGED
package/build/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { forwardRef, createElement, useMemo } from 'react';
|
|
2
|
+
import React__default, { forwardRef, createElement, useMemo, useState } from 'react';
|
|
3
3
|
import { useTable } from 'react-table/src/hooks/useTable.js';
|
|
4
4
|
import { usePagination } from 'react-table/src/plugin-hooks/usePagination.js';
|
|
5
5
|
import { useSortBy } from 'react-table/src/plugin-hooks/useSortBy.js';
|
|
6
6
|
import { Pagination } from '@material-ui/lab';
|
|
7
7
|
import '@material-ui/lab/Alert';
|
|
8
|
-
import { makeStyles, Paper as Paper$1, Box, useTheme as useTheme$1 } from '@material-ui/core';
|
|
8
|
+
import { makeStyles, Paper as Paper$1, Link as Link$1, Box, useTheme as useTheme$1 } from '@material-ui/core';
|
|
9
9
|
import '@material-ui/core/AppBar';
|
|
10
10
|
import MuiIconButton from '@material-ui/core/IconButton';
|
|
11
11
|
import MuiTypography from '@material-ui/core/Typography';
|
|
@@ -34,7 +34,6 @@ import '@material-ui/core/FormControl';
|
|
|
34
34
|
import '@material-ui/core/Grid';
|
|
35
35
|
import '@material-ui/core/InputAdornment';
|
|
36
36
|
import '@material-ui/core/LinearProgress';
|
|
37
|
-
import MuiLink from '@material-ui/core/Link';
|
|
38
37
|
import '@material-ui/core/List';
|
|
39
38
|
import '@material-ui/core/ListItem';
|
|
40
39
|
import '@material-ui/core/ListItemIcon';
|
|
@@ -138,41 +137,23 @@ function __rest(s, e) {
|
|
|
138
137
|
return t;
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
159
|
-
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
160
|
-
value = palette[color][variant];
|
|
161
|
-
}
|
|
162
|
-
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
163
|
-
value = props.color;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return value;
|
|
167
|
-
};
|
|
168
|
-
return {
|
|
169
|
-
root: {
|
|
170
|
-
color: getColor,
|
|
171
|
-
fontSize: getFontSize,
|
|
172
|
-
strokeWidth: '1.3px',
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
});
|
|
140
|
+
var _path$3k;
|
|
141
|
+
|
|
142
|
+
function _extends$3B() { _extends$3B = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3B.apply(this, arguments); }
|
|
143
|
+
|
|
144
|
+
function SvgUser(props) {
|
|
145
|
+
return /*#__PURE__*/React.createElement("svg", _extends$3B({
|
|
146
|
+
viewBox: "0 0 16 16",
|
|
147
|
+
strokeLinecap: "round",
|
|
148
|
+
strokeLinejoin: "round",
|
|
149
|
+
stroke: "currentColor",
|
|
150
|
+
width: "1em",
|
|
151
|
+
height: "1em",
|
|
152
|
+
fill: "none"
|
|
153
|
+
}, props), _path$3k || (_path$3k = /*#__PURE__*/React.createElement("path", {
|
|
154
|
+
d: "M13.333 14v-1.333A2.667 2.667 0 0010.667 10H5.333a2.667 2.667 0 00-2.666 2.667V14M8 7.333A2.667 2.667 0 108 2a2.667 2.667 0 000 5.333z"
|
|
155
|
+
})));
|
|
156
|
+
}
|
|
176
157
|
|
|
177
158
|
var classnames = {exports: {}};
|
|
178
159
|
|
|
@@ -234,6 +215,42 @@ var classnames = {exports: {}};
|
|
|
234
215
|
|
|
235
216
|
var classNames = classnames.exports;
|
|
236
217
|
|
|
218
|
+
var useIconStyles = makeStyles(function (_a) {
|
|
219
|
+
var spacing = _a.spacing, palette = _a.palette;
|
|
220
|
+
var getFontSize = function (_a) {
|
|
221
|
+
var size = _a.size;
|
|
222
|
+
var sizes = {
|
|
223
|
+
inherit: 'inherit',
|
|
224
|
+
small: spacing(1.5),
|
|
225
|
+
medium: spacing(2),
|
|
226
|
+
large: spacing(2.5),
|
|
227
|
+
'extra-large': spacing(3),
|
|
228
|
+
};
|
|
229
|
+
return size ? sizes[size] : 'inherit';
|
|
230
|
+
};
|
|
231
|
+
var getColor = function (props) {
|
|
232
|
+
var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
|
|
233
|
+
var value = 'inherit';
|
|
234
|
+
if (props.color) {
|
|
235
|
+
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
236
|
+
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
237
|
+
value = palette[color][variant];
|
|
238
|
+
}
|
|
239
|
+
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
240
|
+
value = props.color;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return value;
|
|
244
|
+
};
|
|
245
|
+
return {
|
|
246
|
+
root: {
|
|
247
|
+
color: getColor,
|
|
248
|
+
fontSize: getFontSize,
|
|
249
|
+
strokeWidth: '1.3px',
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
|
|
237
254
|
var iconStaticClassName = 'pop-icon';
|
|
238
255
|
var Icon = function (props) {
|
|
239
256
|
var icon = props.icon, className = props.className, restProps = __rest(props, ["icon", "className"]);
|
|
@@ -355,18 +372,9 @@ var LoadingStatus;
|
|
|
355
372
|
LoadingStatus["LOADED"] = "LOADED";
|
|
356
373
|
LoadingStatus["PENDING"] = "PENDING";
|
|
357
374
|
})(LoadingStatus || (LoadingStatus = {}));
|
|
358
|
-
/**
|
|
359
|
-
* Hook returns [imgProps, loaded]
|
|
360
|
-
* ref: Merged default and provided imgProp object. Includes load and error events for img tag. To be passed to MuiAvatar.
|
|
361
|
-
* loaded: Indicates whether the src supplied to an img within Avatar results in loaded or error
|
|
362
|
-
*/
|
|
363
375
|
var useImgProps = function (avatarProps) {
|
|
364
376
|
var _a = React__default.useState(LoadingStatus.PENDING), loaded = _a[0], setLoaded = _a[1];
|
|
365
|
-
var imgProps = __assign(__assign({}, avatarProps.imgProps), {
|
|
366
|
-
var _a, _b;
|
|
367
|
-
setLoaded(LoadingStatus.ERROR);
|
|
368
|
-
(_b = (_a = avatarProps.imgProps) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
369
|
-
}, onLoad: function (event) {
|
|
377
|
+
var imgProps = __assign(__assign({}, avatarProps.imgProps), { onLoad: function (event) {
|
|
370
378
|
var _a, _b;
|
|
371
379
|
setLoaded(LoadingStatus.LOADED);
|
|
372
380
|
(_b = (_a = avatarProps.imgProps) === null || _a === void 0 ? void 0 : _a.onLoad) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
@@ -393,97 +401,49 @@ var getAvatarFontSize = function (props) {
|
|
|
393
401
|
large: '1.25rem',
|
|
394
402
|
'extra-large': '3.5rem',
|
|
395
403
|
};
|
|
396
|
-
return fontSizes[props.size
|
|
397
|
-
};
|
|
398
|
-
var getAvatarBackground = function (props) {
|
|
399
|
-
var src = props.src, loaded = props.loaded;
|
|
400
|
-
var background = props.background;
|
|
401
|
-
if (src && loaded === LoadingStatus.LOADED) {
|
|
402
|
-
background = 'transparent';
|
|
403
|
-
}
|
|
404
|
-
return background;
|
|
404
|
+
return fontSizes[props.size];
|
|
405
405
|
};
|
|
406
406
|
var useAvatarStyles = makeStyles$1(function (theme) { return ({
|
|
407
|
-
root: {
|
|
408
|
-
width:
|
|
409
|
-
height:
|
|
410
|
-
fontSize:
|
|
411
|
-
backgroundColor:
|
|
412
|
-
color:
|
|
413
|
-
objectFit:
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
},
|
|
407
|
+
root: function (props) { return ({
|
|
408
|
+
width: getAvatarDimensions(theme, props),
|
|
409
|
+
height: getAvatarDimensions(theme, props),
|
|
410
|
+
fontSize: getAvatarFontSize(props),
|
|
411
|
+
backgroundColor: props.loaded === LoadingStatus.LOADED ? 'transparent' : props.background,
|
|
412
|
+
color: theme.palette.getContrastText(props.background),
|
|
413
|
+
objectFit: props.fit,
|
|
414
|
+
}); },
|
|
415
|
+
fallback: function (props) { return ({
|
|
416
|
+
fontSize: getAvatarDimensions(theme, props),
|
|
417
|
+
strokeWidth: 1,
|
|
418
|
+
}); },
|
|
420
419
|
}); });
|
|
421
420
|
|
|
422
|
-
var _path$2;
|
|
423
|
-
|
|
424
|
-
function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
425
|
-
|
|
426
|
-
function SvgSilhouetteFemale(props) {
|
|
427
|
-
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
428
|
-
viewBox: "0 0 300 300",
|
|
429
|
-
fill: "none",
|
|
430
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
431
|
-
}, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
|
|
432
|
-
d: "M179.417 182.917a3.362 3.362 0 00-2.951 1.076 3.461 3.461 0 00-.875 3.021c1.916 10.069 8.368 23.889 28.173 32.493 2.347 1.014 5.972 1.805 10.57 2.799 17.208 3.722 45.986 9.958 53.055 36.333a3.488 3.488 0 001.622 2.11 3.491 3.491 0 002.639.345 3.488 3.488 0 002.109-1.622 3.473 3.473 0 00.345-2.639c-8.173-30.465-40.777-37.527-58.298-41.319-4.056-.882-7.563-1.639-9.278-2.389-11.903-5.167-19.59-12.833-22.924-22.819 33.07 2.458 48.042-10.716 48.702-11.313a3.469 3.469 0 001.121-2.951 3.478 3.478 0 00-1.732-2.639c-19.084-10.903-19.084-48.577-19.084-62.764 0-39.674-26.722-71.125-60.979-71.618-.326-.011-.652-.018-.979-.021h-.007c-34.757.194-63.035 31.68-63.035 70.194 0 14.188 0 51.868-19.083 62.764a3.5 3.5 0 00-1.73 2.769 3.494 3.494 0 001.313 2.988c.959.743 22.14 16.952 48.202 12.028-3.486 9.569-11.07 16.931-22.625 21.951-1.674.73-5.007 1.528-8.868 2.445-17.64 4.194-50.48 12.007-58.702 42.687a3.481 3.481 0 00.348 2.638 3.475 3.475 0 006.368-.839c7.145-26.694 36.229-33.604 53.597-37.743 4.354-1.035 7.791-1.854 10.028-2.82 19.805-8.604 26.25-22.423 28.173-32.493a3.45 3.45 0 00-1.104-3.243 3.457 3.457 0 00-3.347-.722c-18.799 5.917-36.167-2.222-43.757-6.736 18.132-15.181 18.132-50.118 18.132-65.674 0-34.7 25.18-63.076 56.389-63.263l.736.041c30.778.438 53.986 28.236 53.986 64.667 0 15.562 0 50.576 18.208 65.757-6.271 3.583-20.569 9.382-44.458 6.521z",
|
|
433
|
-
fill: "#2E3042"
|
|
434
|
-
})));
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
var _path$1;
|
|
438
|
-
|
|
439
|
-
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
440
|
-
|
|
441
|
-
function SvgSilhouetteMale(props) {
|
|
442
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
443
|
-
viewBox: "0 0 300 300",
|
|
444
|
-
fill: "none",
|
|
445
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
446
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
447
|
-
d: "M27.594 261.886a3.513 3.513 0 004.281-2.478c7.204-26.904 36.484-33.877 53.984-38.05 4.386-1.043 7.848-1.869 10.1-2.842 19.935-8.66 26.433-22.592 28.377-32.757a3.493 3.493 0 00-.133-1.81 3.492 3.492 0 00-1.021-1.501c-10.38-8.968-19.137-22.431-24.663-37.917a3.447 3.447 0 00-.72-1.197c-7.31-7.953-11.506-16.361-11.506-23.06 0-3.914 1.475-6.539 4.798-8.52a3.5 3.5 0 001.7-2.857c1.545-35.662 26.922-63.735 58.047-63.917l.749.049c31.279.434 56.495 29.11 57.397 65.275a3.487 3.487 0 001.245 2.584c2.189 1.855 3.211 4.207 3.211 7.4 0 5.607-2.987 12.503-8.401 19.406a3.633 3.633 0 00-.587 1.106c-5.596 17.754-15.64 33.429-27.545 43.02a3.517 3.517 0 00-1.245 3.381c1.945 10.159 8.442 24.083 28.377 32.757 2.357 1.022 6.015 1.821 10.653 2.822 17.325 3.752 46.318 10.046 53.431 36.628a3.503 3.503 0 002.926 2.562 3.494 3.494 0 003.922-3.019 3.52 3.52 0 00-.091-1.363c-8.219-30.713-41.065-37.833-58.705-41.655-4.092-.889-7.625-1.652-9.345-2.408-13.01-5.657-21.026-14.275-23.859-25.658 12.08-10.383 22.187-26.401 27.965-44.365 6.134-7.981 9.505-16.2 9.505-23.221 0-4.684-1.511-8.59-4.504-11.643-1.665-39.232-29.636-70.127-64.35-70.624L150.545 38c-34.085.182-62.175 30.264-64.63 68.818-4.379 3.22-6.603 7.736-6.603 13.47 0 8.282 4.68 18.188 12.87 27.275 5.659 15.563 14.43 29.235 24.873 38.805-2.819 11.426-10.842 20.072-23.88 25.735-1.685.735-5.043 1.541-8.932 2.465-17.773 4.228-50.843 12.104-59.125 43.034a3.501 3.501 0 002.476 4.284z",
|
|
448
|
-
fill: "#2E3042"
|
|
449
|
-
})));
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
var _path;
|
|
453
|
-
|
|
454
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
455
|
-
|
|
456
|
-
function SvgSilhouetteNeutral(props) {
|
|
457
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
458
|
-
viewBox: "0 0 300 300",
|
|
459
|
-
fill: "none",
|
|
460
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
461
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
462
|
-
fillRule: "evenodd",
|
|
463
|
-
clipRule: "evenodd",
|
|
464
|
-
d: "M209 121c0 32.585-26.415 59-59 59s-59-26.415-59-59 26.415-59 59-59 59 26.415 59 59zm8 0c0 37.003-29.997 67-67 67s-67-29.997-67-67 29.997-67 67-67 67 29.997 67 67zm35 137.333V284h8v-25.667c0-13.614-5.821-26.671-16.182-36.298C233.456 212.408 219.403 207 204.75 207H94.25c-14.653 0-28.706 5.408-39.068 15.035C44.821 231.662 39 244.719 39 258.333V284h8v-25.667c0-11.295 4.824-22.257 13.628-30.437C69.45 219.698 81.537 215 94.25 215h110.5c12.714 0 24.799 4.698 33.622 12.896 8.804 8.18 13.628 19.142 13.628 30.437z",
|
|
465
|
-
fill: "#2E3042"
|
|
466
|
-
})));
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
var silhouettes = {
|
|
470
|
-
female: SvgSilhouetteFemale,
|
|
471
|
-
male: SvgSilhouetteMale,
|
|
472
|
-
neutral: SvgSilhouetteNeutral,
|
|
473
|
-
};
|
|
474
421
|
var Avatar = forwardRef(function (props, ref) {
|
|
475
|
-
var children = props.children,
|
|
476
|
-
var
|
|
422
|
+
var children = props.children, src = props.src, alt = props.alt, fallback = props.fallback, muiProps = __rest(props, ["children", "src", "alt", "fallback"]);
|
|
423
|
+
var _a = useImgProps(props), imgProps = _a.imgProps, loaded = _a.loaded;
|
|
477
424
|
var classes = useAvatarStyles(__assign(__assign({}, props), { loaded: loaded }));
|
|
478
|
-
var
|
|
479
|
-
var
|
|
480
|
-
|
|
425
|
+
var displayAltTextFallback = src && alt;
|
|
426
|
+
var displayNoFallback = fallback === 'none';
|
|
427
|
+
var displayCustomFallback = fallback !== 'none' && typeof fallback !== 'undefined';
|
|
428
|
+
var Fallback;
|
|
429
|
+
if (displayAltTextFallback) {
|
|
430
|
+
Fallback = null;
|
|
431
|
+
}
|
|
432
|
+
else if (displayNoFallback) {
|
|
433
|
+
Fallback = ' ';
|
|
434
|
+
}
|
|
435
|
+
else if (displayCustomFallback) {
|
|
436
|
+
Fallback = fallback;
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
Fallback = React__default.createElement(Icon, { icon: SvgUser, className: classes.fallback });
|
|
440
|
+
}
|
|
441
|
+
return (React__default.createElement(MuiAvatar, __assign({ ref: ref, classes: { root: classes.root }, src: src, alt: alt }, muiProps, { imgProps: imgProps }), children || Fallback));
|
|
481
442
|
});
|
|
482
443
|
Avatar.defaultProps = {
|
|
483
444
|
size: 'medium',
|
|
484
445
|
fit: 'cover',
|
|
485
446
|
background: '#E0E0E0',
|
|
486
|
-
silhouette: 'neutral',
|
|
487
447
|
};
|
|
488
448
|
Avatar.displayName = 'Avatar';
|
|
489
449
|
|
|
@@ -582,42 +542,21 @@ makeStyles(function (theme) { return ({
|
|
|
582
542
|
},
|
|
583
543
|
}); });
|
|
584
544
|
|
|
585
|
-
var
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
resolved = palette.text[color.substring(4).toLowerCase()];
|
|
594
|
-
}
|
|
595
|
-
else if (color === 'inherit') {
|
|
596
|
-
resolved = color;
|
|
597
|
-
}
|
|
598
|
-
return resolved;
|
|
599
|
-
};
|
|
600
|
-
var useLinkStyles = makeStyles$1(function (theme) {
|
|
601
|
-
var _a;
|
|
602
|
-
return ({
|
|
603
|
-
root: (_a = {
|
|
604
|
-
display: 'flex',
|
|
605
|
-
color: function (props) { return getLinkColor(theme, props); }
|
|
606
|
-
},
|
|
607
|
-
_a["& ." + iconStaticClassName] = {
|
|
608
|
-
alignSelf: 'center',
|
|
609
|
-
},
|
|
610
|
-
_a),
|
|
611
|
-
});
|
|
612
|
-
});
|
|
545
|
+
var useLinkStyles = makeStyles$1(function (theme) { return ({
|
|
546
|
+
root: function (props) {
|
|
547
|
+
var _a;
|
|
548
|
+
return (__assign(__assign({ display: 'flex' }, (props.color === undefined && { color: theme.palette.info.main })), (_a = {}, _a["& ." + iconStaticClassName] = {
|
|
549
|
+
alignSelf: 'center',
|
|
550
|
+
}, _a)));
|
|
551
|
+
},
|
|
552
|
+
}); });
|
|
613
553
|
|
|
614
554
|
var Link = forwardRef(function (props, ref) {
|
|
615
|
-
var children = props.children
|
|
555
|
+
var children = props.children, muiProps = __rest(props, ["children"]);
|
|
616
556
|
var classes = useLinkStyles(props);
|
|
617
|
-
return (React__default.createElement(
|
|
557
|
+
return (React__default.createElement(Link$1, __assign({ ref: ref, classes: { root: classes.root } }, muiProps), children));
|
|
618
558
|
});
|
|
619
559
|
Link.defaultProps = {
|
|
620
|
-
color: 'info',
|
|
621
560
|
variant: 'body1',
|
|
622
561
|
};
|
|
623
562
|
Link.displayName = 'Link';
|
|
@@ -871,9 +810,15 @@ var TableBody = function (props) {
|
|
|
871
810
|
return React__default.createElement("tbody", __assign$1({}, restProps), children);
|
|
872
811
|
};
|
|
873
812
|
|
|
813
|
+
var tableConstants = {
|
|
814
|
+
tableTypography: 'body1',
|
|
815
|
+
cellPaddingFactor: 2,
|
|
816
|
+
headerBorder: 2,
|
|
817
|
+
};
|
|
818
|
+
|
|
874
819
|
var useTableCellStyles = makeStyles(function (theme) { return ({
|
|
875
820
|
root: function () { return ({
|
|
876
|
-
padding: theme.spacing(
|
|
821
|
+
padding: theme.spacing(tableConstants.cellPaddingFactor),
|
|
877
822
|
}); },
|
|
878
823
|
}); });
|
|
879
824
|
|
|
@@ -895,7 +840,7 @@ var useTableStyles = makeStyles(function (_a) {
|
|
|
895
840
|
},
|
|
896
841
|
table: function (_a) {
|
|
897
842
|
var fullWidth = _a.fullWidth;
|
|
898
|
-
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography.
|
|
843
|
+
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography[tableConstants.tableTypography]));
|
|
899
844
|
},
|
|
900
845
|
tableWrap: function () { return ({
|
|
901
846
|
maxWidth: '100%',
|
|
@@ -905,6 +850,10 @@ var useTableStyles = makeStyles(function (_a) {
|
|
|
905
850
|
});
|
|
906
851
|
});
|
|
907
852
|
|
|
853
|
+
var filterProps = function (props) {
|
|
854
|
+
props.icon; props.action; var filteredProps = __rest$1(props, ["icon", "action"]);
|
|
855
|
+
return filteredProps;
|
|
856
|
+
};
|
|
908
857
|
var TableActionsCell = function (props) {
|
|
909
858
|
var _a = props.actions, primary = _a.primary, secondary = _a.secondary, intermediate = __rest$1(_a, ["primary", "secondary"]);
|
|
910
859
|
var tertiary = intermediate.tertiary, restActions = __rest$1(intermediate, ["tertiary"]);
|
|
@@ -921,11 +870,11 @@ var TableActionsCell = function (props) {
|
|
|
921
870
|
closeMenu();
|
|
922
871
|
};
|
|
923
872
|
return (React__default.createElement(Box, { display: "flex" },
|
|
924
|
-
primary && primary.icon && (React__default.createElement(IconButton, { size: "small", onClick: function () { return primary.action(props.cell); } },
|
|
873
|
+
primary && primary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return primary.action(props.cell); } }, filterProps(primary)),
|
|
925
874
|
React__default.createElement(Icon, { icon: primary.icon }))),
|
|
926
|
-
secondary && secondary.icon && (React__default.createElement(IconButton, { size: "small", onClick: function () { return secondary.action(props.cell); } },
|
|
875
|
+
secondary && secondary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return secondary.action(props.cell); } }, filterProps(secondary)),
|
|
927
876
|
React__default.createElement(Icon, { icon: secondary.icon }))),
|
|
928
|
-
!overflow && tertiary && tertiary.icon && (React__default.createElement(IconButton, { size: "small", onClick: function () { return tertiary.action(props.cell); } },
|
|
877
|
+
!overflow && tertiary && tertiary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return tertiary.action(props.cell); } }, filterProps(tertiary)),
|
|
929
878
|
React__default.createElement(Icon, { icon: tertiary.icon }))),
|
|
930
879
|
overflow && restActions && (React__default.createElement(React__default.Fragment, null,
|
|
931
880
|
React__default.createElement(IconButton, { size: "small", onClick: openMenu },
|
|
@@ -933,8 +882,8 @@ var TableActionsCell = function (props) {
|
|
|
933
882
|
React__default.createElement(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: closeMenu }, Object.values(__assign$1({ tertiary: tertiary }, restActions))
|
|
934
883
|
.filter(function (value) { return value; })
|
|
935
884
|
.map(function (_a, i) {
|
|
936
|
-
var label = _a.label, action = _a.action;
|
|
937
|
-
return (React__default.createElement(MenuItem, { key: i, onClick: function () { return handleItemClick(action); } }, label));
|
|
885
|
+
var label = _a.label, action = _a.action, restProps = __rest$1(_a, ["label", "action"]);
|
|
886
|
+
return (React__default.createElement(MenuItem, __assign$1({ key: i, onClick: function () { return handleItemClick(action); } }, restProps), label));
|
|
938
887
|
}))))));
|
|
939
888
|
};
|
|
940
889
|
|
|
@@ -957,36 +906,92 @@ var makeColumns = function (config) {
|
|
|
957
906
|
/* eslint-disable react/jsx-key */
|
|
958
907
|
var Table = function (props) {
|
|
959
908
|
var actionColumnId = 'table-actions-column';
|
|
960
|
-
var rawColumns = props.columns, data = props.data, actions = props.actions, sortable = props.sortable, emptyMessage = props.emptyMessage, EmptyImage = props.EmptyImage, isLoading = props.loading,
|
|
909
|
+
var rawColumns = props.columns, data = props.data, actions = props.actions, sortable = props.sortable, emptyMessage = props.emptyMessage, EmptyImage = props.EmptyImage, isLoading = props.loading, fullHeight = props.fullHeight, _a = props.paginationOptions, paginationOptions = _a === void 0 ? {} : _a, _b = props.tableOptions, tableOptions = _b === void 0 ? {} : _b, onPaginate = props.onPaginate;
|
|
910
|
+
var theme = useTheme$1();
|
|
961
911
|
var classes = useTableStyles(props);
|
|
962
912
|
var columns = useMemo(function () { return makeColumns({ columns: rawColumns, actions: actions, actionColumnId: actionColumnId }); }, [rawColumns, actions]);
|
|
963
|
-
var
|
|
964
|
-
var
|
|
913
|
+
var initialPaginationState = paginationOptions.initialState, restPaginationOptions = __rest$1(paginationOptions, ["initialState"]);
|
|
914
|
+
var initialState = __assign$1({}, initialPaginationState);
|
|
915
|
+
var instance = useTable(__assign$1(__assign$1({ columns: columns, data: data, disableSortBy: !sortable, initialState: initialState }, restPaginationOptions), tableOptions), useSortBy, usePagination);
|
|
916
|
+
var getTableProps = instance.getTableProps, getTableBodyProps = instance.getTableBodyProps, headerGroups = instance.headerGroups, page = instance.page, prepareRow = instance.prepareRow, pageCount = instance.pageCount, gotoPage = instance.gotoPage, rows = instance.rows;
|
|
965
917
|
var isPaginated = pageCount > 1;
|
|
966
918
|
var isEmpty = rows.length === 0;
|
|
919
|
+
var lineHeightRem = parseFloat(theme.typography[tableConstants.tableTypography].lineHeight);
|
|
920
|
+
var documentFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
921
|
+
var typographyHeight = lineHeightRem * documentFontSize;
|
|
922
|
+
var cellHeight = typographyHeight + theme.spacing(tableConstants.cellPaddingFactor * 2);
|
|
923
|
+
var headerHeight = cellHeight + tableConstants.headerBorder;
|
|
924
|
+
var bodyHeight = instance.state.pageSize * cellHeight;
|
|
925
|
+
var footerHeight = 88;
|
|
926
|
+
var minHeight = headerHeight + bodyHeight + footerHeight;
|
|
967
927
|
var handlePagination = function (_e, pageNumber) {
|
|
968
|
-
|
|
928
|
+
var pageIndex = pageNumber - 1;
|
|
929
|
+
if (onPaginate) {
|
|
930
|
+
onPaginate(pageIndex, instance);
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
gotoPage(pageIndex);
|
|
934
|
+
}
|
|
969
935
|
};
|
|
970
|
-
return (React__default.createElement(Box, { className: classes.root, minHeight:
|
|
971
|
-
React__default.createElement(Box, { className: classes.tableWrap
|
|
936
|
+
return (React__default.createElement(Box, { className: classes.root, minHeight: fullHeight ? minHeight : 'unset' },
|
|
937
|
+
React__default.createElement(Box, { className: classes.tableWrap },
|
|
972
938
|
React__default.createElement("table", __assign$1({ className: classes.table }, getTableProps()),
|
|
973
939
|
React__default.createElement(TableHeader, null, headerGroups.map(function (headerGroup) { return (React__default.createElement(TableHeaderRow, __assign$1({}, headerGroup.getHeaderGroupProps()), headerGroup.headers.map(function (column) { return (React__default.createElement(TableHeaderCell, __assign$1({}, column.getHeaderProps(column.getSortByToggleProps()), { column: __assign$1(__assign$1({}, column), { isActionColumn: column.id === actionColumnId }), tableProps: props }), column.render('Header'))); }))); })),
|
|
974
940
|
!isEmpty && !isLoading && (React__default.createElement(TableBody, __assign$1({}, getTableBodyProps()), page.map(function (row) {
|
|
975
941
|
prepareRow(row);
|
|
976
942
|
return (React__default.createElement(TableRow, __assign$1({}, row.getRowProps()), row.cells.map(function (cell) { return (React__default.createElement(TableCell, __assign$1({}, cell.getCellProps()), cell.render('Cell'))); })));
|
|
977
943
|
}))))),
|
|
978
|
-
isEmpty && (React__default.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
944
|
+
isEmpty && !isLoading && (React__default.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
979
945
|
EmptyImage && EmptyImage(),
|
|
980
946
|
React__default.createElement(Typography, null, emptyMessage))),
|
|
981
947
|
isLoading && (React__default.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
982
948
|
React__default.createElement(CircularProgress, { size: 80, color: "inherit" }))),
|
|
983
|
-
isPaginated &&
|
|
984
|
-
React__default.createElement(Pagination, { count: pageCount, page: state.pageIndex + 1, onChange: handlePagination })))));
|
|
949
|
+
isPaginated && (React__default.createElement(TableFooter, null,
|
|
950
|
+
React__default.createElement(Pagination, { count: pageCount, page: instance.state.pageIndex + 1, onChange: handlePagination })))));
|
|
985
951
|
};
|
|
986
952
|
Table.defaultProps = {
|
|
987
953
|
emptyMessage: 'No results.',
|
|
988
|
-
enableMinHeight: true,
|
|
989
954
|
};
|
|
990
955
|
|
|
991
|
-
|
|
956
|
+
/**
|
|
957
|
+
* Makes props for the Table component that will enable manual pagination and also provides page state.
|
|
958
|
+
*/
|
|
959
|
+
var useManualPagination = function (config) {
|
|
960
|
+
var _a = config.initialPageIndex, initialPageIndex = _a === void 0 ? 0 : _a, _b = config.initialPageSize, initialPageSize = _b === void 0 ? 10 : _b, total = config.total, onPaginate = config.onPaginate;
|
|
961
|
+
var _c = useState(0), pageIndex = _c[0], setPageIndex = _c[1];
|
|
962
|
+
var _d = useState(initialPageSize), pageSize = _d[0], setPageSize = _d[1];
|
|
963
|
+
var handlePagination = function (index, instance) {
|
|
964
|
+
if (onPaginate) {
|
|
965
|
+
onPaginate({ index: index, instance: instance }, setPageIndex);
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
setPageIndex(index);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
var manualPaginationProps = {
|
|
972
|
+
onPaginate: handlePagination,
|
|
973
|
+
tableOptions: {
|
|
974
|
+
useControlledState: function (state) {
|
|
975
|
+
return useMemo(function () { return (__assign$1(__assign$1({}, state), { pageIndex: pageIndex, pageSize: pageSize })); }, [pageIndex, pageSize]);
|
|
976
|
+
},
|
|
977
|
+
},
|
|
978
|
+
paginationOptions: {
|
|
979
|
+
initialState: { pageIndex: initialPageIndex, pageSize: pageSize },
|
|
980
|
+
manualPagination: true,
|
|
981
|
+
pageCount: Math.ceil(total / pageSize),
|
|
982
|
+
},
|
|
983
|
+
};
|
|
984
|
+
var pageState = {
|
|
985
|
+
pageIndex: pageIndex,
|
|
986
|
+
pageSize: pageSize,
|
|
987
|
+
setPageIndex: setPageIndex,
|
|
988
|
+
setPageSize: setPageSize,
|
|
989
|
+
};
|
|
990
|
+
return {
|
|
991
|
+
manualPaginationProps: manualPaginationProps,
|
|
992
|
+
pageState: pageState,
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
export { Table, useManualPagination };
|
|
992
997
|
//# sourceMappingURL=index.es.js.map
|