@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
package/build/index.js
CHANGED
|
@@ -37,7 +37,6 @@ require('@material-ui/core/FormControl');
|
|
|
37
37
|
require('@material-ui/core/Grid');
|
|
38
38
|
require('@material-ui/core/InputAdornment');
|
|
39
39
|
require('@material-ui/core/LinearProgress');
|
|
40
|
-
var MuiLink = require('@material-ui/core/Link');
|
|
41
40
|
require('@material-ui/core/List');
|
|
42
41
|
require('@material-ui/core/ListItem');
|
|
43
42
|
require('@material-ui/core/ListItemIcon');
|
|
@@ -86,7 +85,6 @@ var MuiButton__default = /*#__PURE__*/_interopDefaultLegacy(MuiButton);
|
|
|
86
85
|
var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
|
|
87
86
|
var MuiCheckbox__default = /*#__PURE__*/_interopDefaultLegacy(MuiCheckbox);
|
|
88
87
|
var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
|
|
89
|
-
var MuiLink__default = /*#__PURE__*/_interopDefaultLegacy(MuiLink);
|
|
90
88
|
var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
|
|
91
89
|
var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
|
|
92
90
|
var MuiRadio__default = /*#__PURE__*/_interopDefaultLegacy(MuiRadio);
|
|
@@ -181,41 +179,23 @@ function __rest(s, e) {
|
|
|
181
179
|
return t;
|
|
182
180
|
}
|
|
183
181
|
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
202
|
-
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
203
|
-
value = palette[color][variant];
|
|
204
|
-
}
|
|
205
|
-
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
206
|
-
value = props.color;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return value;
|
|
210
|
-
};
|
|
211
|
-
return {
|
|
212
|
-
root: {
|
|
213
|
-
color: getColor,
|
|
214
|
-
fontSize: getFontSize,
|
|
215
|
-
strokeWidth: '1.3px',
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
});
|
|
182
|
+
var _path$3k;
|
|
183
|
+
|
|
184
|
+
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); }
|
|
185
|
+
|
|
186
|
+
function SvgUser(props) {
|
|
187
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3B({
|
|
188
|
+
viewBox: "0 0 16 16",
|
|
189
|
+
strokeLinecap: "round",
|
|
190
|
+
strokeLinejoin: "round",
|
|
191
|
+
stroke: "currentColor",
|
|
192
|
+
width: "1em",
|
|
193
|
+
height: "1em",
|
|
194
|
+
fill: "none"
|
|
195
|
+
}, props), _path$3k || (_path$3k = /*#__PURE__*/React__namespace.createElement("path", {
|
|
196
|
+
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"
|
|
197
|
+
})));
|
|
198
|
+
}
|
|
219
199
|
|
|
220
200
|
var classnames = {exports: {}};
|
|
221
201
|
|
|
@@ -277,6 +257,42 @@ var classnames = {exports: {}};
|
|
|
277
257
|
|
|
278
258
|
var classNames = classnames.exports;
|
|
279
259
|
|
|
260
|
+
var useIconStyles = core.makeStyles(function (_a) {
|
|
261
|
+
var spacing = _a.spacing, palette = _a.palette;
|
|
262
|
+
var getFontSize = function (_a) {
|
|
263
|
+
var size = _a.size;
|
|
264
|
+
var sizes = {
|
|
265
|
+
inherit: 'inherit',
|
|
266
|
+
small: spacing(1.5),
|
|
267
|
+
medium: spacing(2),
|
|
268
|
+
large: spacing(2.5),
|
|
269
|
+
'extra-large': spacing(3),
|
|
270
|
+
};
|
|
271
|
+
return size ? sizes[size] : 'inherit';
|
|
272
|
+
};
|
|
273
|
+
var getColor = function (props) {
|
|
274
|
+
var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
|
|
275
|
+
var value = 'inherit';
|
|
276
|
+
if (props.color) {
|
|
277
|
+
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
278
|
+
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
279
|
+
value = palette[color][variant];
|
|
280
|
+
}
|
|
281
|
+
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
282
|
+
value = props.color;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return value;
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
root: {
|
|
289
|
+
color: getColor,
|
|
290
|
+
fontSize: getFontSize,
|
|
291
|
+
strokeWidth: '1.3px',
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
|
|
280
296
|
var iconStaticClassName = 'pop-icon';
|
|
281
297
|
var Icon = function (props) {
|
|
282
298
|
var icon = props.icon, className = props.className, restProps = __rest(props, ["icon", "className"]);
|
|
@@ -398,18 +414,9 @@ var LoadingStatus;
|
|
|
398
414
|
LoadingStatus["LOADED"] = "LOADED";
|
|
399
415
|
LoadingStatus["PENDING"] = "PENDING";
|
|
400
416
|
})(LoadingStatus || (LoadingStatus = {}));
|
|
401
|
-
/**
|
|
402
|
-
* Hook returns [imgProps, loaded]
|
|
403
|
-
* ref: Merged default and provided imgProp object. Includes load and error events for img tag. To be passed to MuiAvatar.
|
|
404
|
-
* loaded: Indicates whether the src supplied to an img within Avatar results in loaded or error
|
|
405
|
-
*/
|
|
406
417
|
var useImgProps = function (avatarProps) {
|
|
407
418
|
var _a = React__default['default'].useState(LoadingStatus.PENDING), loaded = _a[0], setLoaded = _a[1];
|
|
408
|
-
var imgProps = __assign(__assign({}, avatarProps.imgProps), {
|
|
409
|
-
var _a, _b;
|
|
410
|
-
setLoaded(LoadingStatus.ERROR);
|
|
411
|
-
(_b = (_a = avatarProps.imgProps) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
412
|
-
}, onLoad: function (event) {
|
|
419
|
+
var imgProps = __assign(__assign({}, avatarProps.imgProps), { onLoad: function (event) {
|
|
413
420
|
var _a, _b;
|
|
414
421
|
setLoaded(LoadingStatus.LOADED);
|
|
415
422
|
(_b = (_a = avatarProps.imgProps) === null || _a === void 0 ? void 0 : _a.onLoad) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
@@ -436,97 +443,49 @@ var getAvatarFontSize = function (props) {
|
|
|
436
443
|
large: '1.25rem',
|
|
437
444
|
'extra-large': '3.5rem',
|
|
438
445
|
};
|
|
439
|
-
return fontSizes[props.size
|
|
440
|
-
};
|
|
441
|
-
var getAvatarBackground = function (props) {
|
|
442
|
-
var src = props.src, loaded = props.loaded;
|
|
443
|
-
var background = props.background;
|
|
444
|
-
if (src && loaded === LoadingStatus.LOADED) {
|
|
445
|
-
background = 'transparent';
|
|
446
|
-
}
|
|
447
|
-
return background;
|
|
446
|
+
return fontSizes[props.size];
|
|
448
447
|
};
|
|
449
448
|
var useAvatarStyles = styles.makeStyles(function (theme) { return ({
|
|
450
|
-
root: {
|
|
451
|
-
width:
|
|
452
|
-
height:
|
|
453
|
-
fontSize:
|
|
454
|
-
backgroundColor:
|
|
455
|
-
color:
|
|
456
|
-
objectFit:
|
|
457
|
-
},
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
},
|
|
449
|
+
root: function (props) { return ({
|
|
450
|
+
width: getAvatarDimensions(theme, props),
|
|
451
|
+
height: getAvatarDimensions(theme, props),
|
|
452
|
+
fontSize: getAvatarFontSize(props),
|
|
453
|
+
backgroundColor: props.loaded === LoadingStatus.LOADED ? 'transparent' : props.background,
|
|
454
|
+
color: theme.palette.getContrastText(props.background),
|
|
455
|
+
objectFit: props.fit,
|
|
456
|
+
}); },
|
|
457
|
+
fallback: function (props) { return ({
|
|
458
|
+
fontSize: getAvatarDimensions(theme, props),
|
|
459
|
+
strokeWidth: 1,
|
|
460
|
+
}); },
|
|
463
461
|
}); });
|
|
464
462
|
|
|
465
|
-
var _path$2;
|
|
466
|
-
|
|
467
|
-
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); }
|
|
468
|
-
|
|
469
|
-
function SvgSilhouetteFemale(props) {
|
|
470
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
|
|
471
|
-
viewBox: "0 0 300 300",
|
|
472
|
-
fill: "none",
|
|
473
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
474
|
-
}, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
475
|
-
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",
|
|
476
|
-
fill: "#2E3042"
|
|
477
|
-
})));
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
var _path$1;
|
|
481
|
-
|
|
482
|
-
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); }
|
|
483
|
-
|
|
484
|
-
function SvgSilhouetteMale(props) {
|
|
485
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
486
|
-
viewBox: "0 0 300 300",
|
|
487
|
-
fill: "none",
|
|
488
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
489
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
490
|
-
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",
|
|
491
|
-
fill: "#2E3042"
|
|
492
|
-
})));
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
var _path;
|
|
496
|
-
|
|
497
|
-
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); }
|
|
498
|
-
|
|
499
|
-
function SvgSilhouetteNeutral(props) {
|
|
500
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
501
|
-
viewBox: "0 0 300 300",
|
|
502
|
-
fill: "none",
|
|
503
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
504
|
-
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
505
|
-
fillRule: "evenodd",
|
|
506
|
-
clipRule: "evenodd",
|
|
507
|
-
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",
|
|
508
|
-
fill: "#2E3042"
|
|
509
|
-
})));
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
var silhouettes = {
|
|
513
|
-
female: SvgSilhouetteFemale,
|
|
514
|
-
male: SvgSilhouetteMale,
|
|
515
|
-
neutral: SvgSilhouetteNeutral,
|
|
516
|
-
};
|
|
517
463
|
var Avatar = React.forwardRef(function (props, ref) {
|
|
518
|
-
var children = props.children,
|
|
519
|
-
var
|
|
464
|
+
var children = props.children, src = props.src, alt = props.alt, fallback = props.fallback, muiProps = __rest(props, ["children", "src", "alt", "fallback"]);
|
|
465
|
+
var _a = useImgProps(props), imgProps = _a.imgProps, loaded = _a.loaded;
|
|
520
466
|
var classes = useAvatarStyles(__assign(__assign({}, props), { loaded: loaded }));
|
|
521
|
-
var
|
|
522
|
-
var
|
|
523
|
-
|
|
467
|
+
var displayAltTextFallback = src && alt;
|
|
468
|
+
var displayNoFallback = fallback === 'none';
|
|
469
|
+
var displayCustomFallback = fallback !== 'none' && typeof fallback !== 'undefined';
|
|
470
|
+
var Fallback;
|
|
471
|
+
if (displayAltTextFallback) {
|
|
472
|
+
Fallback = null;
|
|
473
|
+
}
|
|
474
|
+
else if (displayNoFallback) {
|
|
475
|
+
Fallback = ' ';
|
|
476
|
+
}
|
|
477
|
+
else if (displayCustomFallback) {
|
|
478
|
+
Fallback = fallback;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
Fallback = React__default['default'].createElement(Icon, { icon: SvgUser, className: classes.fallback });
|
|
482
|
+
}
|
|
483
|
+
return (React__default['default'].createElement(MuiAvatar__default['default'], __assign({ ref: ref, classes: { root: classes.root }, src: src, alt: alt }, muiProps, { imgProps: imgProps }), children || Fallback));
|
|
524
484
|
});
|
|
525
485
|
Avatar.defaultProps = {
|
|
526
486
|
size: 'medium',
|
|
527
487
|
fit: 'cover',
|
|
528
488
|
background: '#E0E0E0',
|
|
529
|
-
silhouette: 'neutral',
|
|
530
489
|
};
|
|
531
490
|
Avatar.displayName = 'Avatar';
|
|
532
491
|
|
|
@@ -625,42 +584,21 @@ core.makeStyles(function (theme) { return ({
|
|
|
625
584
|
},
|
|
626
585
|
}); });
|
|
627
586
|
|
|
628
|
-
var
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
resolved = palette.text[color.substring(4).toLowerCase()];
|
|
637
|
-
}
|
|
638
|
-
else if (color === 'inherit') {
|
|
639
|
-
resolved = color;
|
|
640
|
-
}
|
|
641
|
-
return resolved;
|
|
642
|
-
};
|
|
643
|
-
var useLinkStyles = styles.makeStyles(function (theme) {
|
|
644
|
-
var _a;
|
|
645
|
-
return ({
|
|
646
|
-
root: (_a = {
|
|
647
|
-
display: 'flex',
|
|
648
|
-
color: function (props) { return getLinkColor(theme, props); }
|
|
649
|
-
},
|
|
650
|
-
_a["& ." + iconStaticClassName] = {
|
|
651
|
-
alignSelf: 'center',
|
|
652
|
-
},
|
|
653
|
-
_a),
|
|
654
|
-
});
|
|
655
|
-
});
|
|
587
|
+
var useLinkStyles = styles.makeStyles(function (theme) { return ({
|
|
588
|
+
root: function (props) {
|
|
589
|
+
var _a;
|
|
590
|
+
return (__assign(__assign({ display: 'flex' }, (props.color === undefined && { color: theme.palette.info.main })), (_a = {}, _a["& ." + iconStaticClassName] = {
|
|
591
|
+
alignSelf: 'center',
|
|
592
|
+
}, _a)));
|
|
593
|
+
},
|
|
594
|
+
}); });
|
|
656
595
|
|
|
657
596
|
var Link = React.forwardRef(function (props, ref) {
|
|
658
|
-
var children = props.children
|
|
597
|
+
var children = props.children, muiProps = __rest(props, ["children"]);
|
|
659
598
|
var classes = useLinkStyles(props);
|
|
660
|
-
return (React__default['default'].createElement(
|
|
599
|
+
return (React__default['default'].createElement(core.Link, __assign({ ref: ref, classes: { root: classes.root } }, muiProps), children));
|
|
661
600
|
});
|
|
662
601
|
Link.defaultProps = {
|
|
663
|
-
color: 'info',
|
|
664
602
|
variant: 'body1',
|
|
665
603
|
};
|
|
666
604
|
Link.displayName = 'Link';
|
|
@@ -914,9 +852,15 @@ var TableBody = function (props) {
|
|
|
914
852
|
return React__default['default'].createElement("tbody", __assign$1({}, restProps), children);
|
|
915
853
|
};
|
|
916
854
|
|
|
855
|
+
var tableConstants = {
|
|
856
|
+
tableTypography: 'body1',
|
|
857
|
+
cellPaddingFactor: 2,
|
|
858
|
+
headerBorder: 2,
|
|
859
|
+
};
|
|
860
|
+
|
|
917
861
|
var useTableCellStyles = core.makeStyles(function (theme) { return ({
|
|
918
862
|
root: function () { return ({
|
|
919
|
-
padding: theme.spacing(
|
|
863
|
+
padding: theme.spacing(tableConstants.cellPaddingFactor),
|
|
920
864
|
}); },
|
|
921
865
|
}); });
|
|
922
866
|
|
|
@@ -938,7 +882,7 @@ var useTableStyles = core.makeStyles(function (_a) {
|
|
|
938
882
|
},
|
|
939
883
|
table: function (_a) {
|
|
940
884
|
var fullWidth = _a.fullWidth;
|
|
941
|
-
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography.
|
|
885
|
+
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography[tableConstants.tableTypography]));
|
|
942
886
|
},
|
|
943
887
|
tableWrap: function () { return ({
|
|
944
888
|
maxWidth: '100%',
|
|
@@ -948,6 +892,10 @@ var useTableStyles = core.makeStyles(function (_a) {
|
|
|
948
892
|
});
|
|
949
893
|
});
|
|
950
894
|
|
|
895
|
+
var filterProps = function (props) {
|
|
896
|
+
props.icon; props.action; var filteredProps = __rest$1(props, ["icon", "action"]);
|
|
897
|
+
return filteredProps;
|
|
898
|
+
};
|
|
951
899
|
var TableActionsCell = function (props) {
|
|
952
900
|
var _a = props.actions, primary = _a.primary, secondary = _a.secondary, intermediate = __rest$1(_a, ["primary", "secondary"]);
|
|
953
901
|
var tertiary = intermediate.tertiary, restActions = __rest$1(intermediate, ["tertiary"]);
|
|
@@ -964,11 +912,11 @@ var TableActionsCell = function (props) {
|
|
|
964
912
|
closeMenu();
|
|
965
913
|
};
|
|
966
914
|
return (React__default['default'].createElement(core.Box, { display: "flex" },
|
|
967
|
-
primary && primary.icon && (React__default['default'].createElement(IconButton, { size: "small", onClick: function () { return primary.action(props.cell); } },
|
|
915
|
+
primary && primary.icon && (React__default['default'].createElement(IconButton, __assign$1({ size: "small", onClick: function () { return primary.action(props.cell); } }, filterProps(primary)),
|
|
968
916
|
React__default['default'].createElement(Icon, { icon: primary.icon }))),
|
|
969
|
-
secondary && secondary.icon && (React__default['default'].createElement(IconButton, { size: "small", onClick: function () { return secondary.action(props.cell); } },
|
|
917
|
+
secondary && secondary.icon && (React__default['default'].createElement(IconButton, __assign$1({ size: "small", onClick: function () { return secondary.action(props.cell); } }, filterProps(secondary)),
|
|
970
918
|
React__default['default'].createElement(Icon, { icon: secondary.icon }))),
|
|
971
|
-
!overflow && tertiary && tertiary.icon && (React__default['default'].createElement(IconButton, { size: "small", onClick: function () { return tertiary.action(props.cell); } },
|
|
919
|
+
!overflow && tertiary && tertiary.icon && (React__default['default'].createElement(IconButton, __assign$1({ size: "small", onClick: function () { return tertiary.action(props.cell); } }, filterProps(tertiary)),
|
|
972
920
|
React__default['default'].createElement(Icon, { icon: tertiary.icon }))),
|
|
973
921
|
overflow && restActions && (React__default['default'].createElement(React__default['default'].Fragment, null,
|
|
974
922
|
React__default['default'].createElement(IconButton, { size: "small", onClick: openMenu },
|
|
@@ -976,8 +924,8 @@ var TableActionsCell = function (props) {
|
|
|
976
924
|
React__default['default'].createElement(Menu__default['default'], { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: closeMenu }, Object.values(__assign$1({ tertiary: tertiary }, restActions))
|
|
977
925
|
.filter(function (value) { return value; })
|
|
978
926
|
.map(function (_a, i) {
|
|
979
|
-
var label = _a.label, action = _a.action;
|
|
980
|
-
return (React__default['default'].createElement(MenuItem__default['default'], { key: i, onClick: function () { return handleItemClick(action); } }, label));
|
|
927
|
+
var label = _a.label, action = _a.action, restProps = __rest$1(_a, ["label", "action"]);
|
|
928
|
+
return (React__default['default'].createElement(MenuItem__default['default'], __assign$1({ key: i, onClick: function () { return handleItemClick(action); } }, restProps), label));
|
|
981
929
|
}))))));
|
|
982
930
|
};
|
|
983
931
|
|
|
@@ -1000,36 +948,93 @@ var makeColumns = function (config) {
|
|
|
1000
948
|
/* eslint-disable react/jsx-key */
|
|
1001
949
|
var Table = function (props) {
|
|
1002
950
|
var actionColumnId = 'table-actions-column';
|
|
1003
|
-
var rawColumns = props.columns, data = props.data, actions = props.actions, sortable = props.sortable, emptyMessage = props.emptyMessage, EmptyImage = props.EmptyImage, isLoading = props.loading,
|
|
951
|
+
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;
|
|
952
|
+
var theme = core.useTheme();
|
|
1004
953
|
var classes = useTableStyles(props);
|
|
1005
954
|
var columns = React.useMemo(function () { return makeColumns({ columns: rawColumns, actions: actions, actionColumnId: actionColumnId }); }, [rawColumns, actions]);
|
|
1006
|
-
var
|
|
1007
|
-
var
|
|
955
|
+
var initialPaginationState = paginationOptions.initialState, restPaginationOptions = __rest$1(paginationOptions, ["initialState"]);
|
|
956
|
+
var initialState = __assign$1({}, initialPaginationState);
|
|
957
|
+
var instance = useTable_js.useTable(__assign$1(__assign$1({ columns: columns, data: data, disableSortBy: !sortable, initialState: initialState }, restPaginationOptions), tableOptions), useSortBy_js.useSortBy, usePagination_js.usePagination);
|
|
958
|
+
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;
|
|
1008
959
|
var isPaginated = pageCount > 1;
|
|
1009
960
|
var isEmpty = rows.length === 0;
|
|
961
|
+
var lineHeightRem = parseFloat(theme.typography[tableConstants.tableTypography].lineHeight);
|
|
962
|
+
var documentFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
963
|
+
var typographyHeight = lineHeightRem * documentFontSize;
|
|
964
|
+
var cellHeight = typographyHeight + theme.spacing(tableConstants.cellPaddingFactor * 2);
|
|
965
|
+
var headerHeight = cellHeight + tableConstants.headerBorder;
|
|
966
|
+
var bodyHeight = instance.state.pageSize * cellHeight;
|
|
967
|
+
var footerHeight = 88;
|
|
968
|
+
var minHeight = headerHeight + bodyHeight + footerHeight;
|
|
1010
969
|
var handlePagination = function (_e, pageNumber) {
|
|
1011
|
-
|
|
970
|
+
var pageIndex = pageNumber - 1;
|
|
971
|
+
if (onPaginate) {
|
|
972
|
+
onPaginate(pageIndex, instance);
|
|
973
|
+
}
|
|
974
|
+
else {
|
|
975
|
+
gotoPage(pageIndex);
|
|
976
|
+
}
|
|
1012
977
|
};
|
|
1013
|
-
return (React__default['default'].createElement(core.Box, { className: classes.root, minHeight:
|
|
1014
|
-
React__default['default'].createElement(core.Box, { className: classes.tableWrap
|
|
978
|
+
return (React__default['default'].createElement(core.Box, { className: classes.root, minHeight: fullHeight ? minHeight : 'unset' },
|
|
979
|
+
React__default['default'].createElement(core.Box, { className: classes.tableWrap },
|
|
1015
980
|
React__default['default'].createElement("table", __assign$1({ className: classes.table }, getTableProps()),
|
|
1016
981
|
React__default['default'].createElement(TableHeader, null, headerGroups.map(function (headerGroup) { return (React__default['default'].createElement(TableHeaderRow, __assign$1({}, headerGroup.getHeaderGroupProps()), headerGroup.headers.map(function (column) { return (React__default['default'].createElement(TableHeaderCell, __assign$1({}, column.getHeaderProps(column.getSortByToggleProps()), { column: __assign$1(__assign$1({}, column), { isActionColumn: column.id === actionColumnId }), tableProps: props }), column.render('Header'))); }))); })),
|
|
1017
982
|
!isEmpty && !isLoading && (React__default['default'].createElement(TableBody, __assign$1({}, getTableBodyProps()), page.map(function (row) {
|
|
1018
983
|
prepareRow(row);
|
|
1019
984
|
return (React__default['default'].createElement(TableRow, __assign$1({}, row.getRowProps()), row.cells.map(function (cell) { return (React__default['default'].createElement(TableCell, __assign$1({}, cell.getCellProps()), cell.render('Cell'))); })));
|
|
1020
985
|
}))))),
|
|
1021
|
-
isEmpty && (React__default['default'].createElement(core.Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
986
|
+
isEmpty && !isLoading && (React__default['default'].createElement(core.Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
1022
987
|
EmptyImage && EmptyImage(),
|
|
1023
988
|
React__default['default'].createElement(Typography, null, emptyMessage))),
|
|
1024
989
|
isLoading && (React__default['default'].createElement(core.Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", p: 2, flexGrow: 1 },
|
|
1025
990
|
React__default['default'].createElement(CircularProgress__default['default'], { size: 80, color: "inherit" }))),
|
|
1026
|
-
isPaginated &&
|
|
1027
|
-
React__default['default'].createElement(lab.Pagination, { count: pageCount, page: state.pageIndex + 1, onChange: handlePagination })))));
|
|
991
|
+
isPaginated && (React__default['default'].createElement(TableFooter, null,
|
|
992
|
+
React__default['default'].createElement(lab.Pagination, { count: pageCount, page: instance.state.pageIndex + 1, onChange: handlePagination })))));
|
|
1028
993
|
};
|
|
1029
994
|
Table.defaultProps = {
|
|
1030
995
|
emptyMessage: 'No results.',
|
|
1031
|
-
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Makes props for the Table component that will enable manual pagination and also provides page state.
|
|
1000
|
+
*/
|
|
1001
|
+
var useManualPagination = function (config) {
|
|
1002
|
+
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;
|
|
1003
|
+
var _c = React.useState(0), pageIndex = _c[0], setPageIndex = _c[1];
|
|
1004
|
+
var _d = React.useState(initialPageSize), pageSize = _d[0], setPageSize = _d[1];
|
|
1005
|
+
var handlePagination = function (index, instance) {
|
|
1006
|
+
if (onPaginate) {
|
|
1007
|
+
onPaginate({ index: index, instance: instance }, setPageIndex);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
setPageIndex(index);
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
var manualPaginationProps = {
|
|
1014
|
+
onPaginate: handlePagination,
|
|
1015
|
+
tableOptions: {
|
|
1016
|
+
useControlledState: function (state) {
|
|
1017
|
+
return React.useMemo(function () { return (__assign$1(__assign$1({}, state), { pageIndex: pageIndex, pageSize: pageSize })); }, [pageIndex, pageSize]);
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
paginationOptions: {
|
|
1021
|
+
initialState: { pageIndex: initialPageIndex, pageSize: pageSize },
|
|
1022
|
+
manualPagination: true,
|
|
1023
|
+
pageCount: Math.ceil(total / pageSize),
|
|
1024
|
+
},
|
|
1025
|
+
};
|
|
1026
|
+
var pageState = {
|
|
1027
|
+
pageIndex: pageIndex,
|
|
1028
|
+
pageSize: pageSize,
|
|
1029
|
+
setPageIndex: setPageIndex,
|
|
1030
|
+
setPageSize: setPageSize,
|
|
1031
|
+
};
|
|
1032
|
+
return {
|
|
1033
|
+
manualPaginationProps: manualPaginationProps,
|
|
1034
|
+
pageState: pageState,
|
|
1035
|
+
};
|
|
1032
1036
|
};
|
|
1033
1037
|
|
|
1034
1038
|
exports.Table = Table;
|
|
1039
|
+
exports.useManualPagination = useManualPagination;
|
|
1035
1040
|
//# sourceMappingURL=index.js.map
|