@popmenu/common-ui 0.28.1 → 0.31.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.js CHANGED
@@ -155,55 +155,55 @@ function __rest(s, e) {
155
155
  return t;
156
156
  }
157
157
 
158
- var _path$2g;
158
+ var _path$Q;
159
159
 
160
- function _extends$3t() { _extends$3t = 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$3t.apply(this, arguments); }
160
+ 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); }
161
161
 
162
162
  function SvgMinusCircle(props) {
163
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$3t({
163
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$1n({
164
164
  viewBox: "0 0 16 16",
165
165
  fill: "none",
166
166
  strokeLinecap: "round",
167
167
  strokeLinejoin: "round",
168
168
  width: "1em",
169
169
  height: "1em"
170
- }, props), _path$2g || (_path$2g = /*#__PURE__*/React__namespace.createElement("path", {
170
+ }, props), _path$Q || (_path$Q = /*#__PURE__*/React__namespace.createElement("path", {
171
171
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zM5.333 8h5.334",
172
172
  stroke: "currentColor"
173
173
  })));
174
174
  }
175
175
 
176
- var _path$28;
176
+ var _path$M;
177
177
 
178
- function _extends$3l() { _extends$3l = 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$3l.apply(this, arguments); }
178
+ function _extends$1j() { _extends$1j = 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$1j.apply(this, arguments); }
179
179
 
180
180
  function SvgPlusCircle(props) {
181
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$3l({
181
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$1j({
182
182
  viewBox: "0 0 16 16",
183
183
  fill: "none",
184
184
  strokeLinecap: "round",
185
185
  strokeLinejoin: "round",
186
186
  width: "1em",
187
187
  height: "1em"
188
- }, props), _path$28 || (_path$28 = /*#__PURE__*/React__namespace.createElement("path", {
188
+ }, props), _path$M || (_path$M = /*#__PURE__*/React__namespace.createElement("path", {
189
189
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zm0-9.334v5.334M5.333 8h5.334",
190
190
  stroke: "currentColor"
191
191
  })));
192
192
  }
193
193
 
194
- var _path$1W;
194
+ var _path$D;
195
195
 
196
- function _extends$31() { _extends$31 = 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$31.apply(this, arguments); }
196
+ function _extends$16() { _extends$16 = 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$16.apply(this, arguments); }
197
197
 
198
198
  function SvgUser(props) {
199
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$31({
199
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$16({
200
200
  viewBox: "0 0 16 16",
201
201
  fill: "none",
202
202
  strokeLinecap: "round",
203
203
  strokeLinejoin: "round",
204
204
  width: "1em",
205
205
  height: "1em"
206
- }, props), _path$1W || (_path$1W = /*#__PURE__*/React__namespace.createElement("path", {
206
+ }, props), _path$D || (_path$D = /*#__PURE__*/React__namespace.createElement("path", {
207
207
  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",
208
208
  stroke: "currentColor"
209
209
  })));
@@ -436,48 +436,35 @@ var Checkbox = React.forwardRef(function (props, ref) {
436
436
  });
437
437
  Checkbox.displayName = 'Checkbox';
438
438
 
439
+ var defaultTypographyProps = {
440
+ variant: 'body1',
441
+ };
442
+
439
443
  var weights = {
440
444
  regular: 400,
445
+ medium: 500,
441
446
  'semi-bold': 600,
442
447
  bold: 700,
443
448
  };
444
- var getColor = function (theme, props) {
445
- var color = props.color;
446
- if (color === undefined) {
447
- return undefined;
448
- }
449
- if (['white', 'black'].includes(color)) {
450
- return theme.palette.common[color];
451
- }
452
- if (color.match(/^grey\.\d{3}/)) {
453
- var scale = color.split('.')[1];
454
- return theme.palette.grey[scale] || theme.palette.grey[900];
455
- }
456
- if ([
457
- 'primary.light',
458
- 'primary.dark',
459
- 'secondary.light',
460
- 'secondary',
461
- 'secondary.dark',
462
- 'info.light',
463
- 'info.dark',
464
- 'success.light',
465
- 'success.dark',
466
- 'error.light',
467
- 'error.dark',
468
- 'warning.light',
469
- 'warning.dark',
470
- ].includes(color)) {
471
- var _a = color.split('.'), paletteKey = _a[0], variant = _a[1];
472
- return theme.palette[paletteKey][variant];
449
+ var getCustomColor = function (theme, color) {
450
+ var isCommonColor = color && ['white', 'black'].includes(color);
451
+ var isGreyColor = color && color.match(/^grey\.\d{3}/);
452
+ var isSemanticColor = color && color.match(/(primary|secondary|info|success|error|warning).?(light|dark)?/);
453
+ var isTextColor = color && ['textPrimary', 'textSecondary'].includes(color);
454
+ switch (true) {
455
+ case isCommonColor:
456
+ return theme.palette.common[color];
457
+ case Boolean(isGreyColor):
458
+ var scale = color.split('.')[1];
459
+ return theme.palette.grey[scale] || theme.palette.grey[900];
460
+ case Boolean(isSemanticColor):
461
+ var _a = color.split('.'), paletteKey = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
462
+ return theme.palette[paletteKey][variant];
463
+ case isTextColor:
464
+ return theme.palette.text[color.slice(4).toLowerCase()];
465
+ default:
466
+ return undefined;
473
467
  }
474
- if (['success', 'info', 'error', 'warning', 'primary', 'secondary'].includes(color)) {
475
- return theme.palette[color].main;
476
- }
477
- if (['textPrimary', 'textSecondary'].includes(color)) {
478
- return theme.palette.text[color.slice(4).toLowerCase()];
479
- }
480
- return undefined;
481
468
  };
482
469
  var useTypographyStyles = styles.makeStyles(function (theme) {
483
470
  var _a;
@@ -492,21 +479,24 @@ var useTypographyStyles = styles.makeStyles(function (theme) {
492
479
  _a.fontFamily = theme.typography.fontFamily,
493
480
  _a.fontWeight = function (_a) {
494
481
  var variant = _a.variant, weight = _a.weight;
495
- return (weight ? weights[weight] : theme.typography[variant || 'body1'].fontWeight);
482
+ return (weight ? weights[weight] : theme.typography[variant].fontWeight);
496
483
  },
497
484
  _a.fontSize = function (_a) {
498
485
  var variant = _a.variant;
499
- return theme.typography[variant || 'body1'].fontSize;
486
+ return theme.typography[variant].fontSize;
500
487
  },
501
488
  _a.lineHeight = function (_a) {
502
489
  var variant = _a.variant;
503
- return theme.typography[variant || 'body1'].lineHeight;
490
+ return theme.typography[variant].lineHeight;
504
491
  },
505
492
  _a.textTransform = function (_a) {
506
493
  var variant = _a.variant;
507
- return theme.typography[variant || 'body1'].textTransform;
494
+ return theme.typography[variant].textTransform;
495
+ },
496
+ _a.color = function (_a) {
497
+ var color = _a.color, variant = _a.variant;
498
+ return (color && getCustomColor(theme, color)) || theme.typography[variant].color;
508
499
  },
509
- _a.color = function (props) { return getColor(theme, props); },
510
500
  _a),
511
501
  caption: {
512
502
  display: 'inline',
@@ -517,30 +507,14 @@ var useTypographyStyles = styles.makeStyles(function (theme) {
517
507
  });
518
508
  });
519
509
 
520
- var variantMap = {
521
- h1: 'h1',
522
- h2: 'h2',
523
- h3: 'h3',
524
- h4: 'h4',
525
- h5: 'h5',
526
- h6: 'h6',
527
- h7: 'h6',
528
- body1: 'p',
529
- body2: 'p',
530
- subtitle1: 'h6',
531
- subtitle2: 'h6',
532
- caption: 'span',
533
- overline: 'span',
534
- };
535
-
536
510
  var Typography = React.forwardRef(function (props, ref) {
537
- props.weight; var _a = props.variant, variant = _a === void 0 ? 'body1' : _a; props.color; var restProps = __rest(props, ["weight", "variant", "color"]);
538
- var validatedVariant = Object.keys(variantMap).includes(variant) ? variant : 'body1';
539
- var classes = useTypographyStyles(__assign(__assign({}, props), { variant: validatedVariant }));
540
- var component = variantMap[validatedVariant];
541
- return React__default['default'].createElement(core.Typography, __assign({ component: component, ref: ref, classes: classes }, restProps, { variant: "inherit" }));
511
+ props.weight; props.color; var restProps = __rest(props, ["weight", "color"]);
512
+ var classes = useTypographyStyles(__assign({}, props));
513
+ var variantMapping = { subtitle1: 'p' };
514
+ return React__default['default'].createElement(core.Typography, __assign({ ref: ref, classes: classes, variantMapping: variantMapping }, restProps));
542
515
  });
543
- Typography.displayName = 'Typography';
516
+ Typography.displayName = 'Typography';
517
+ Typography.defaultProps = defaultTypographyProps;
544
518
 
545
519
  var getFadeStop = function (_a, typographyVariant) {
546
520
  var typography = _a.typography;