@popmenu/common-ui 0.40.0 → 0.42.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
@@ -20,7 +20,7 @@ var CardHeader = require('@material-ui/core/CardHeader');
20
20
  var CardMedia = require('@material-ui/core/CardMedia');
21
21
  var MuiCheckbox = require('@material-ui/core/Checkbox');
22
22
  var FormControlLabel = require('@material-ui/core/FormControlLabel');
23
- var Chip = require('@material-ui/core/Chip');
23
+ var MuiChip = require('@material-ui/core/Chip');
24
24
  var Collapse = require('@material-ui/core/Collapse');
25
25
  var Dialog = require('@material-ui/core/Dialog');
26
26
  var DialogActions = require('@material-ui/core/DialogActions');
@@ -89,7 +89,7 @@ var CardHeader__default = /*#__PURE__*/_interopDefaultLegacy(CardHeader);
89
89
  var CardMedia__default = /*#__PURE__*/_interopDefaultLegacy(CardMedia);
90
90
  var MuiCheckbox__default = /*#__PURE__*/_interopDefaultLegacy(MuiCheckbox);
91
91
  var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
92
- var Chip__default = /*#__PURE__*/_interopDefaultLegacy(Chip);
92
+ var MuiChip__default = /*#__PURE__*/_interopDefaultLegacy(MuiChip);
93
93
  var Collapse__default = /*#__PURE__*/_interopDefaultLegacy(Collapse);
94
94
  var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
95
95
  var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
@@ -157,60 +157,135 @@ function __rest(s, e) {
157
157
  return t;
158
158
  }
159
159
 
160
- var _path$V;
160
+ var _g;
161
161
 
162
- function _extends$1D() { _extends$1D = 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$1D.apply(this, arguments); }
162
+ function _extends$6() { _extends$6 = 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$6.apply(this, arguments); }
163
+
164
+ function SvgCheckCircle(props) {
165
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$6({
166
+ viewBox: "0 0 16 16",
167
+ fill: "none",
168
+ strokeLinecap: "round",
169
+ strokeLinejoin: "round",
170
+ width: "1em",
171
+ height: "1em"
172
+ }, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
173
+ stroke: "currentColor"
174
+ }, /*#__PURE__*/React__namespace.createElement("path", {
175
+ d: "M14.667 7.387V8a6.667 6.667 0 11-3.954-6.093"
176
+ }), /*#__PURE__*/React__namespace.createElement("path", {
177
+ d: "M14.667 2.667L8 9.34l-2-2"
178
+ }))));
179
+ }
180
+
181
+ var _path$5;
182
+
183
+ function _extends$5() { _extends$5 = 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$5.apply(this, arguments); }
184
+
185
+ function SvgInfo(props) {
186
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$5({
187
+ viewBox: "0 0 16 16",
188
+ fill: "none",
189
+ strokeLinecap: "round",
190
+ strokeLinejoin: "round",
191
+ width: "1em",
192
+ height: "1em"
193
+ }, props), _path$5 || (_path$5 = /*#__PURE__*/React__namespace.createElement("path", {
194
+ d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zm0-4V8m0-2.667h.007",
195
+ stroke: "currentColor"
196
+ })));
197
+ }
198
+
199
+ var _path$4;
200
+
201
+ 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); }
163
202
 
164
203
  function SvgMinusCircle(props) {
165
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$1D({
204
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
166
205
  viewBox: "0 0 16 16",
167
206
  fill: "none",
168
207
  strokeLinecap: "round",
169
208
  strokeLinejoin: "round",
170
209
  width: "1em",
171
210
  height: "1em"
172
- }, props), _path$V || (_path$V = /*#__PURE__*/React__namespace.createElement("path", {
211
+ }, props), _path$4 || (_path$4 = /*#__PURE__*/React__namespace.createElement("path", {
173
212
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zM5.333 8h5.334",
174
213
  stroke: "currentColor"
175
214
  })));
176
215
  }
177
216
 
178
- var _path$R;
217
+ var _path$3;
179
218
 
180
- function _extends$1z() { _extends$1z = 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$1z.apply(this, arguments); }
219
+ function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
181
220
 
182
221
  function SvgPlusCircle(props) {
183
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$1z({
222
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$3({
184
223
  viewBox: "0 0 16 16",
185
224
  fill: "none",
186
225
  strokeLinecap: "round",
187
226
  strokeLinejoin: "round",
188
227
  width: "1em",
189
228
  height: "1em"
190
- }, props), _path$R || (_path$R = /*#__PURE__*/React__namespace.createElement("path", {
229
+ }, props), _path$3 || (_path$3 = /*#__PURE__*/React__namespace.createElement("path", {
191
230
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zm0-9.334v5.334M5.333 8h5.334",
192
231
  stroke: "currentColor"
193
232
  })));
194
233
  }
195
234
 
196
- var _path$I;
235
+ var _path$2;
197
236
 
198
- function _extends$1m() { _extends$1m = 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$1m.apply(this, arguments); }
237
+ 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); }
199
238
 
200
239
  function SvgUser(props) {
201
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$1m({
240
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
202
241
  viewBox: "0 0 16 16",
203
242
  fill: "none",
204
243
  strokeLinecap: "round",
205
244
  strokeLinejoin: "round",
206
245
  width: "1em",
207
246
  height: "1em"
208
- }, props), _path$I || (_path$I = /*#__PURE__*/React__namespace.createElement("path", {
247
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
209
248
  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",
210
249
  stroke: "currentColor"
211
250
  })));
212
251
  }
213
252
 
253
+ var _path$1;
254
+
255
+ 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); }
256
+
257
+ function SvgError(props) {
258
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
259
+ viewBox: "0 0 16 16",
260
+ fill: "none",
261
+ strokeLinecap: "round",
262
+ strokeLinejoin: "round",
263
+ width: "1em",
264
+ height: "1em"
265
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
266
+ d: "M5.24 1.333h5.52l3.907 3.907v5.52l-3.907 3.907H5.24L1.333 10.76V5.24L5.24 1.333zm2.76 4V8m0 2.666h.008",
267
+ stroke: "currentColor"
268
+ })));
269
+ }
270
+
271
+ var _path;
272
+
273
+ 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); }
274
+
275
+ function SvgWarning(props) {
276
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends({
277
+ viewBox: "0 0 16 16",
278
+ fill: "none",
279
+ strokeLinecap: "round",
280
+ strokeLinejoin: "round",
281
+ width: "1em",
282
+ height: "1em"
283
+ }, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
284
+ d: "M6.86 2.573L1.213 12a1.334 1.334 0 001.14 2h11.294a1.332 1.332 0 001.14-2L9.14 2.573a1.333 1.333 0 00-2.28 0v0zM8 6v2.667m0 2.667h.007",
285
+ stroke: "currentColor"
286
+ })));
287
+ }
288
+
214
289
  var useIconStyles = core.makeStyles(function (_a) {
215
290
  var spacing = _a.spacing, palette = _a.palette;
216
291
  var getFontSize = function (_a) {
@@ -438,6 +513,93 @@ var Checkbox = React.forwardRef(function (props, ref) {
438
513
  });
439
514
  Checkbox.displayName = 'Checkbox';
440
515
 
516
+ var getBackground = function (theme) { return function (props) {
517
+ var variant = props.variant, severity = props.severity;
518
+ var background;
519
+ var backgrounds = {
520
+ outlined: 'none',
521
+ error: 'error.main',
522
+ warning: 'warning.main',
523
+ info: 'info.light',
524
+ success: 'success.light',
525
+ };
526
+ if (variant === 'outlined') {
527
+ background = backgrounds[variant];
528
+ }
529
+ else if (severity) {
530
+ var _a = backgrounds[severity].split('.'), color = _a[0], colorVariant = _a[1];
531
+ background = theme.palette[color][colorVariant];
532
+ }
533
+ return background;
534
+ }; };
535
+ var getColor = function (theme) { return function (props) {
536
+ var variant = props.variant, severity = props.severity;
537
+ var textColor;
538
+ if (variant === 'outlined' && severity) {
539
+ var textColors = {
540
+ error: theme.palette.error.main,
541
+ info: theme.palette.info.main,
542
+ warning: theme.palette.warning.dark,
543
+ success: theme.palette.success.dark,
544
+ };
545
+ textColor = textColors[severity];
546
+ }
547
+ else if (variant === 'outlined' && !severity) {
548
+ textColor = theme.palette.grey[700];
549
+ }
550
+ else if ((variant === 'default' || variant === undefined) && severity) {
551
+ var textColors = {
552
+ error: theme.palette.common.white,
553
+ info: theme.palette.secondary.main,
554
+ warning: theme.palette.secondary.main,
555
+ success: theme.palette.secondary.main,
556
+ };
557
+ textColor = textColors[severity];
558
+ }
559
+ return textColor;
560
+ }; };
561
+ var getBorder = function (theme) { return function (props) {
562
+ var variant = props.variant, severity = props.severity;
563
+ var borderColor;
564
+ if (variant === 'outlined' && severity) {
565
+ var borderColors = {
566
+ error: theme.palette.error.main,
567
+ info: theme.palette.info.main,
568
+ warning: theme.palette.warning.dark,
569
+ success: theme.palette.success.dark,
570
+ };
571
+ borderColor = borderColors[severity];
572
+ }
573
+ return borderColor;
574
+ }; };
575
+ var useChipStyles = styles.makeStyles(function (theme) { return ({
576
+ root: {
577
+ background: getBackground(theme),
578
+ color: getColor(theme),
579
+ borderColor: getBorder(theme),
580
+ borderRadius: theme.spacing(0.5),
581
+ },
582
+ icon: {
583
+ color: 'inherit',
584
+ height: theme.spacing(2),
585
+ width: theme.spacing(2),
586
+ },
587
+ }); });
588
+
589
+ var IconDictionary = {
590
+ error: SvgError,
591
+ info: SvgInfo,
592
+ success: SvgCheckCircle,
593
+ warning: SvgWarning,
594
+ };
595
+ var Chip = function (props) {
596
+ var severity = props.severity, restProps = __rest(props, ["severity"]);
597
+ var classes = useChipStyles(props);
598
+ var icon = severity ? React__default['default'].createElement(IconDictionary[severity]) : undefined;
599
+ return React__default['default'].createElement(MuiChip__default['default'], __assign({ classes: classes, icon: icon }, restProps));
600
+ };
601
+ Chip.displayName = 'Chip';
602
+
441
603
  var defaultTypographyProps = {
442
604
  variant: 'body1',
443
605
  };
@@ -1174,12 +1336,6 @@ Object.defineProperty(exports, 'FormControlLabel', {
1174
1336
  return FormControlLabel__default['default'];
1175
1337
  }
1176
1338
  });
1177
- Object.defineProperty(exports, 'Chip', {
1178
- enumerable: true,
1179
- get: function () {
1180
- return Chip__default['default'];
1181
- }
1182
- });
1183
1339
  Object.defineProperty(exports, 'Dialog', {
1184
1340
  enumerable: true,
1185
1341
  get: function () {
@@ -1309,6 +1465,7 @@ Object.defineProperty(exports, 'Tabs', {
1309
1465
  exports.Avatar = Avatar;
1310
1466
  exports.Button = Button;
1311
1467
  exports.Checkbox = Checkbox;
1468
+ exports.Chip = Chip;
1312
1469
  exports.CollapsibleText = CollapsibleText;
1313
1470
  exports.Divider = Divider;
1314
1471
  exports.Icon = Icon;