@popmenu/table 0.19.2 → 0.19.5

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/index.es.js CHANGED
@@ -5,7 +5,7 @@ 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 useIconStyles = makeStyles(function (_a) {
142
- var spacing = _a.spacing, palette = _a.palette;
143
- var getFontSize = function (_a) {
144
- var size = _a.size;
145
- var sizes = {
146
- inherit: 'inherit',
147
- small: spacing(1.5),
148
- medium: spacing(2),
149
- large: spacing(2.5),
150
- 'extra-large': spacing(3),
151
- };
152
- return size ? sizes[size] : 'inherit';
153
- };
154
- var getColor = function (props) {
155
- var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
156
- var value = 'inherit';
157
- if (props.color) {
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), { onError: function (event) {
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 || 'medium'];
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: function (props) { return getAvatarDimensions(theme, props); },
409
- height: function (props) { return getAvatarDimensions(theme, props); },
410
- fontSize: function (props) { return getAvatarFontSize(props); },
411
- backgroundColor: function (props) { return getAvatarBackground(props); },
412
- color: function (props) { return theme.palette.getContrastText(props.background || '#E0E0E0'); },
413
- objectFit: function (props) { return props.fit; },
414
- },
415
- silhouette: {
416
- '& path': {
417
- fill: function (props) { return theme.palette.getContrastText(props.background || '#E0E0E0'); },
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, _a = props.silhouette, silhouette = _a === void 0 ? 'neutral' : _a, muiProps = __rest(props, ["children", "silhouette"]);
476
- var _b = useImgProps(props), imgProps = _b.imgProps, loaded = _b.loaded;
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 Silhouette = silhouettes[silhouette];
479
- var fallback = muiProps.src || silhouette === 'none' ? '' : React__default.createElement(Silhouette, { className: classes.silhouette });
480
- return (React__default.createElement(MuiAvatar, __assign({ ref: ref, classes: { root: classes.root } }, muiProps, imgProps), children || fallback));
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 getLinkColor = function (_a, _b) {
586
- var palette = _a.palette;
587
- var _c = _b.color, color = _c === void 0 ? 'info' : _c;
588
- var resolved;
589
- if (['primary', 'secondary', 'info', 'error'].includes(color)) {
590
- resolved = palette[color].main;
591
- }
592
- else if (['textPrimary', 'textSecondary'].includes(color)) {
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; props.color; var muiProps = __rest(props, ["children", "color"]);
555
+ var children = props.children, muiProps = __rest(props, ["children"]);
616
556
  var classes = useLinkStyles(props);
617
- return (React__default.createElement(MuiLink, __assign({ ref: ref, classes: { root: classes.root } }, muiProps), children));
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';
@@ -905,6 +844,10 @@ var useTableStyles = makeStyles(function (_a) {
905
844
  });
906
845
  });
907
846
 
847
+ var filterProps = function (props) {
848
+ props.icon; props.action; var filteredProps = __rest$1(props, ["icon", "action"]);
849
+ return filteredProps;
850
+ };
908
851
  var TableActionsCell = function (props) {
909
852
  var _a = props.actions, primary = _a.primary, secondary = _a.secondary, intermediate = __rest$1(_a, ["primary", "secondary"]);
910
853
  var tertiary = intermediate.tertiary, restActions = __rest$1(intermediate, ["tertiary"]);
@@ -921,11 +864,11 @@ var TableActionsCell = function (props) {
921
864
  closeMenu();
922
865
  };
923
866
  return (React__default.createElement(Box, { display: "flex" },
924
- primary && primary.icon && (React__default.createElement(IconButton, { size: "small", onClick: function () { return primary.action(props.cell); } },
867
+ primary && primary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return primary.action(props.cell); } }, filterProps(primary)),
925
868
  React__default.createElement(Icon, { icon: primary.icon }))),
926
- secondary && secondary.icon && (React__default.createElement(IconButton, { size: "small", onClick: function () { return secondary.action(props.cell); } },
869
+ secondary && secondary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return secondary.action(props.cell); } }, filterProps(secondary)),
927
870
  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); } },
871
+ !overflow && tertiary && tertiary.icon && (React__default.createElement(IconButton, __assign$1({ size: "small", onClick: function () { return tertiary.action(props.cell); } }, filterProps(tertiary)),
929
872
  React__default.createElement(Icon, { icon: tertiary.icon }))),
930
873
  overflow && restActions && (React__default.createElement(React__default.Fragment, null,
931
874
  React__default.createElement(IconButton, { size: "small", onClick: openMenu },
@@ -933,8 +876,8 @@ var TableActionsCell = function (props) {
933
876
  React__default.createElement(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: closeMenu }, Object.values(__assign$1({ tertiary: tertiary }, restActions))
934
877
  .filter(function (value) { return value; })
935
878
  .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));
879
+ var label = _a.label, action = _a.action, restProps = __rest$1(_a, ["label", "action"]);
880
+ return (React__default.createElement(MenuItem, __assign$1({ key: i, onClick: function () { return handleItemClick(action); } }, restProps), label));
938
881
  }))))));
939
882
  };
940
883