@popmenu/table 0.30.0 → 0.33.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/index.es.js CHANGED
@@ -137,19 +137,19 @@ function __rest(s, e) {
137
137
  return t;
138
138
  }
139
139
 
140
- var _path$24;
140
+ var _path$F;
141
141
 
142
- function _extends$3i() { _extends$3i = 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$3i.apply(this, arguments); }
142
+ function _extends$1c() { _extends$1c = 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$1c.apply(this, arguments); }
143
143
 
144
144
  function SvgUser(props) {
145
- return /*#__PURE__*/React.createElement("svg", _extends$3i({
145
+ return /*#__PURE__*/React.createElement("svg", _extends$1c({
146
146
  viewBox: "0 0 16 16",
147
147
  fill: "none",
148
148
  strokeLinecap: "round",
149
149
  strokeLinejoin: "round",
150
150
  width: "1em",
151
151
  height: "1em"
152
- }, props), _path$24 || (_path$24 = /*#__PURE__*/React.createElement("path", {
152
+ }, props), _path$F || (_path$F = /*#__PURE__*/React.createElement("path", {
153
153
  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",
154
154
  stroke: "currentColor"
155
155
  })));
@@ -382,48 +382,35 @@ var Checkbox = forwardRef(function (props, ref) {
382
382
  });
383
383
  Checkbox.displayName = 'Checkbox';
384
384
 
385
+ var defaultTypographyProps = {
386
+ variant: 'body1',
387
+ };
388
+
385
389
  var weights = {
386
390
  regular: 400,
391
+ medium: 500,
387
392
  'semi-bold': 600,
388
393
  bold: 700,
389
394
  };
390
- var getColor = function (theme, props) {
391
- var color = props.color;
392
- if (color === undefined) {
393
- return undefined;
394
- }
395
- if (['white', 'black'].includes(color)) {
396
- return theme.palette.common[color];
397
- }
398
- if (color.match(/^grey\.\d{3}/)) {
399
- var scale = color.split('.')[1];
400
- return theme.palette.grey[scale] || theme.palette.grey[900];
401
- }
402
- if ([
403
- 'primary.light',
404
- 'primary.dark',
405
- 'secondary.light',
406
- 'secondary',
407
- 'secondary.dark',
408
- 'info.light',
409
- 'info.dark',
410
- 'success.light',
411
- 'success.dark',
412
- 'error.light',
413
- 'error.dark',
414
- 'warning.light',
415
- 'warning.dark',
416
- ].includes(color)) {
417
- var _a = color.split('.'), paletteKey = _a[0], variant = _a[1];
418
- return theme.palette[paletteKey][variant];
395
+ var getCustomColor = function (theme, color) {
396
+ var isCommonColor = color && ['white', 'black'].includes(color);
397
+ var isGreyColor = color && color.match(/^grey\.\d{3}/);
398
+ var isSemanticColor = color && color.match(/(primary|secondary|info|success|error|warning).?(light|dark)?/);
399
+ var isTextColor = color && ['textPrimary', 'textSecondary'].includes(color);
400
+ switch (true) {
401
+ case isCommonColor:
402
+ return theme.palette.common[color];
403
+ case Boolean(isGreyColor):
404
+ var scale = color.split('.')[1];
405
+ return theme.palette.grey[scale] || theme.palette.grey[900];
406
+ case Boolean(isSemanticColor):
407
+ var _a = color.split('.'), paletteKey = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
408
+ return theme.palette[paletteKey][variant];
409
+ case isTextColor:
410
+ return theme.palette.text[color.slice(4).toLowerCase()];
411
+ default:
412
+ return undefined;
419
413
  }
420
- if (['success', 'info', 'error', 'warning', 'primary', 'secondary'].includes(color)) {
421
- return theme.palette[color].main;
422
- }
423
- if (['textPrimary', 'textSecondary'].includes(color)) {
424
- return theme.palette.text[color.slice(4).toLowerCase()];
425
- }
426
- return undefined;
427
414
  };
428
415
  var useTypographyStyles = makeStyles$1(function (theme) {
429
416
  var _a;
@@ -438,21 +425,24 @@ var useTypographyStyles = makeStyles$1(function (theme) {
438
425
  _a.fontFamily = theme.typography.fontFamily,
439
426
  _a.fontWeight = function (_a) {
440
427
  var variant = _a.variant, weight = _a.weight;
441
- return (weight ? weights[weight] : theme.typography[variant || 'body1'].fontWeight);
428
+ return (weight ? weights[weight] : theme.typography[variant].fontWeight);
442
429
  },
443
430
  _a.fontSize = function (_a) {
444
431
  var variant = _a.variant;
445
- return theme.typography[variant || 'body1'].fontSize;
432
+ return theme.typography[variant].fontSize;
446
433
  },
447
434
  _a.lineHeight = function (_a) {
448
435
  var variant = _a.variant;
449
- return theme.typography[variant || 'body1'].lineHeight;
436
+ return theme.typography[variant].lineHeight;
450
437
  },
451
438
  _a.textTransform = function (_a) {
452
439
  var variant = _a.variant;
453
- return theme.typography[variant || 'body1'].textTransform;
440
+ return theme.typography[variant].textTransform;
441
+ },
442
+ _a.color = function (_a) {
443
+ var color = _a.color, variant = _a.variant;
444
+ return (color && getCustomColor(theme, color)) || theme.typography[variant].color;
454
445
  },
455
- _a.color = function (props) { return getColor(theme, props); },
456
446
  _a),
457
447
  caption: {
458
448
  display: 'inline',
@@ -463,30 +453,14 @@ var useTypographyStyles = makeStyles$1(function (theme) {
463
453
  });
464
454
  });
465
455
 
466
- var variantMap = {
467
- h1: 'h1',
468
- h2: 'h2',
469
- h3: 'h3',
470
- h4: 'h4',
471
- h5: 'h5',
472
- h6: 'h6',
473
- h7: 'h6',
474
- body1: 'p',
475
- body2: 'p',
476
- subtitle1: 'h6',
477
- subtitle2: 'h6',
478
- caption: 'span',
479
- overline: 'span',
480
- };
481
-
482
456
  var Typography = forwardRef(function (props, ref) {
483
- props.weight; var _a = props.variant, variant = _a === void 0 ? 'body1' : _a; props.color; var restProps = __rest(props, ["weight", "variant", "color"]);
484
- var validatedVariant = Object.keys(variantMap).includes(variant) ? variant : 'body1';
485
- var classes = useTypographyStyles(__assign(__assign({}, props), { variant: validatedVariant }));
486
- var component = variantMap[validatedVariant];
487
- return React__default.createElement(Typography$1, __assign({ component: component, ref: ref, classes: classes }, restProps, { variant: "inherit" }));
457
+ props.weight; props.color; var restProps = __rest(props, ["weight", "color"]);
458
+ var classes = useTypographyStyles(__assign({}, props));
459
+ var variantMapping = { subtitle1: 'p' };
460
+ return React__default.createElement(Typography$1, __assign({ ref: ref, classes: classes, variantMapping: variantMapping }, restProps));
488
461
  });
489
- Typography.displayName = 'Typography';
462
+ Typography.displayName = 'Typography';
463
+ Typography.defaultProps = defaultTypographyProps;
490
464
 
491
465
  var getFadeStop = function (_a, typographyVariant) {
492
466
  var typography = _a.typography;
@@ -754,73 +728,73 @@ var TableHeader = function (props) {
754
728
  return React__default.createElement("thead", __assign$1({}, restProps), children);
755
729
  };
756
730
 
757
- var _path$39;
731
+ var _path$1j;
758
732
 
759
- function _extends$50() { _extends$50 = 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$50.apply(this, arguments); }
733
+ function _extends$2a() { _extends$2a = 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$2a.apply(this, arguments); }
760
734
 
761
735
  function SvgChevronDown(props) {
762
- return /*#__PURE__*/React.createElement("svg", _extends$50({
736
+ return /*#__PURE__*/React.createElement("svg", _extends$2a({
763
737
  viewBox: "0 0 16 16",
764
738
  fill: "none",
765
739
  strokeLinecap: "round",
766
740
  strokeLinejoin: "round",
767
741
  width: "1em",
768
742
  height: "1em"
769
- }, props), _path$39 || (_path$39 = /*#__PURE__*/React.createElement("path", {
743
+ }, props), _path$1j || (_path$1j = /*#__PURE__*/React.createElement("path", {
770
744
  d: "M4 6l4 4 4-4",
771
745
  stroke: "currentColor"
772
746
  })));
773
747
  }
774
748
 
775
- var _path$38;
749
+ var _path$1i;
776
750
 
777
- function _extends$4$() { _extends$4$ = 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$4$.apply(this, arguments); }
751
+ function _extends$29() { _extends$29 = 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$29.apply(this, arguments); }
778
752
 
779
753
  function SvgChevronUp(props) {
780
- return /*#__PURE__*/React.createElement("svg", _extends$4$({
754
+ return /*#__PURE__*/React.createElement("svg", _extends$29({
781
755
  viewBox: "0 0 16 16",
782
756
  fill: "none",
783
757
  strokeLinecap: "round",
784
758
  strokeLinejoin: "round",
785
759
  width: "1em",
786
760
  height: "1em"
787
- }, props), _path$38 || (_path$38 = /*#__PURE__*/React.createElement("path", {
761
+ }, props), _path$1i || (_path$1i = /*#__PURE__*/React.createElement("path", {
788
762
  d: "M12 10L8 6l-4 4",
789
763
  stroke: "currentColor"
790
764
  })));
791
765
  }
792
766
 
793
- var _path$2o;
767
+ var _path$R;
794
768
 
795
- function _extends$3I() { _extends$3I = 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$3I.apply(this, arguments); }
769
+ function _extends$1s() { _extends$1s = 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$1s.apply(this, arguments); }
796
770
 
797
771
  function SvgMore(props) {
798
- return /*#__PURE__*/React.createElement("svg", _extends$3I({
772
+ return /*#__PURE__*/React.createElement("svg", _extends$1s({
799
773
  viewBox: "0 0 16 16",
800
774
  fill: "none",
801
775
  strokeLinecap: "round",
802
776
  strokeLinejoin: "round",
803
777
  width: "1em",
804
778
  height: "1em"
805
- }, props), _path$2o || (_path$2o = /*#__PURE__*/React.createElement("path", {
779
+ }, props), _path$R || (_path$R = /*#__PURE__*/React.createElement("path", {
806
780
  d: "M8 8.667a.667.667 0 100-1.334.667.667 0 000 1.334zM8 4a.667.667 0 100-1.334A.667.667 0 008 4zm0 9.333A.667.667 0 108 12a.667.667 0 000 1.333z",
807
781
  stroke: "currentColor"
808
782
  })));
809
783
  }
810
784
 
811
- var _path$2f;
785
+ var _path$N;
812
786
 
813
- function _extends$3y() { _extends$3y = 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$3y.apply(this, arguments); }
787
+ function _extends$1n() { _extends$1n = 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$1n.apply(this, arguments); }
814
788
 
815
789
  function SvgSearch(props) {
816
- return /*#__PURE__*/React.createElement("svg", _extends$3y({
790
+ return /*#__PURE__*/React.createElement("svg", _extends$1n({
817
791
  viewBox: "0 0 16 16",
818
792
  fill: "none",
819
793
  strokeLinecap: "round",
820
794
  strokeLinejoin: "round",
821
795
  width: "1em",
822
796
  height: "1em"
823
- }, props), _path$2f || (_path$2f = /*#__PURE__*/React.createElement("path", {
797
+ }, props), _path$N || (_path$N = /*#__PURE__*/React.createElement("path", {
824
798
  d: "M7.333 12.667A5.333 5.333 0 107.333 2a5.333 5.333 0 000 10.667zM14 14l-2.9-2.9",
825
799
  stroke: "currentColor"
826
800
  })));