@popmenu/common-ui 0.40.3 → 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.
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { ChipProps } from './ChipProps';
3
+ export declare const Chip: {
4
+ (props: ChipProps): JSX.Element;
5
+ displayName: string;
6
+ };
@@ -0,0 +1,4 @@
1
+ import { ChipProps as MuiChipProps } from '@material-ui/core/Chip';
2
+ export interface ChipProps extends MuiChipProps {
3
+ severity?: 'success' | 'info' | 'warning' | 'error';
4
+ }
@@ -0,0 +1,2 @@
1
+ import { ChipProps } from './ChipProps';
2
+ export declare const useChipStyles: (props: ChipProps) => import("@material-ui/styles").ClassNameMap<string>;
@@ -1 +1,2 @@
1
- export { default, ChipProps } from '@material-ui/core/Chip';
1
+ export { Chip as default } from './Chip';
2
+ export { ChipProps } from './ChipProps';
package/build/index.es.js CHANGED
@@ -21,7 +21,7 @@ export { default as CardMedia } from '@material-ui/core/CardMedia';
21
21
  import MuiCheckbox from '@material-ui/core/Checkbox';
22
22
  import FormControlLabel from '@material-ui/core/FormControlLabel';
23
23
  export { default as FormControlLabel } from '@material-ui/core/FormControlLabel';
24
- export { default as Chip } from '@material-ui/core/Chip';
24
+ import MuiChip from '@material-ui/core/Chip';
25
25
  import Collapse from '@material-ui/core/Collapse';
26
26
  export { default as Dialog } from '@material-ui/core/Dialog';
27
27
  export { default as DialogActions } from '@material-ui/core/DialogActions';
@@ -90,60 +90,135 @@ function __rest(s, e) {
90
90
  return t;
91
91
  }
92
92
 
93
- var _path$V;
93
+ var _g;
94
94
 
95
- 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); }
95
+ 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); }
96
+
97
+ function SvgCheckCircle(props) {
98
+ return /*#__PURE__*/React.createElement("svg", _extends$6({
99
+ viewBox: "0 0 16 16",
100
+ fill: "none",
101
+ strokeLinecap: "round",
102
+ strokeLinejoin: "round",
103
+ width: "1em",
104
+ height: "1em"
105
+ }, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
106
+ stroke: "currentColor"
107
+ }, /*#__PURE__*/React.createElement("path", {
108
+ d: "M14.667 7.387V8a6.667 6.667 0 11-3.954-6.093"
109
+ }), /*#__PURE__*/React.createElement("path", {
110
+ d: "M14.667 2.667L8 9.34l-2-2"
111
+ }))));
112
+ }
113
+
114
+ var _path$5;
115
+
116
+ 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); }
117
+
118
+ function SvgInfo(props) {
119
+ return /*#__PURE__*/React.createElement("svg", _extends$5({
120
+ viewBox: "0 0 16 16",
121
+ fill: "none",
122
+ strokeLinecap: "round",
123
+ strokeLinejoin: "round",
124
+ width: "1em",
125
+ height: "1em"
126
+ }, props), _path$5 || (_path$5 = /*#__PURE__*/React.createElement("path", {
127
+ d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zm0-4V8m0-2.667h.007",
128
+ stroke: "currentColor"
129
+ })));
130
+ }
131
+
132
+ var _path$4;
133
+
134
+ 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); }
96
135
 
97
136
  function SvgMinusCircle(props) {
98
- return /*#__PURE__*/React.createElement("svg", _extends$1D({
137
+ return /*#__PURE__*/React.createElement("svg", _extends$4({
99
138
  viewBox: "0 0 16 16",
100
139
  fill: "none",
101
140
  strokeLinecap: "round",
102
141
  strokeLinejoin: "round",
103
142
  width: "1em",
104
143
  height: "1em"
105
- }, props), _path$V || (_path$V = /*#__PURE__*/React.createElement("path", {
144
+ }, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
106
145
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zM5.333 8h5.334",
107
146
  stroke: "currentColor"
108
147
  })));
109
148
  }
110
149
 
111
- var _path$R;
150
+ var _path$3;
112
151
 
113
- 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); }
152
+ 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); }
114
153
 
115
154
  function SvgPlusCircle(props) {
116
- return /*#__PURE__*/React.createElement("svg", _extends$1z({
155
+ return /*#__PURE__*/React.createElement("svg", _extends$3({
117
156
  viewBox: "0 0 16 16",
118
157
  fill: "none",
119
158
  strokeLinecap: "round",
120
159
  strokeLinejoin: "round",
121
160
  width: "1em",
122
161
  height: "1em"
123
- }, props), _path$R || (_path$R = /*#__PURE__*/React.createElement("path", {
162
+ }, props), _path$3 || (_path$3 = /*#__PURE__*/React.createElement("path", {
124
163
  d: "M8 14.667A6.667 6.667 0 108 1.334a6.667 6.667 0 000 13.333zm0-9.334v5.334M5.333 8h5.334",
125
164
  stroke: "currentColor"
126
165
  })));
127
166
  }
128
167
 
129
- var _path$I;
168
+ var _path$2;
130
169
 
131
- 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); }
170
+ 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); }
132
171
 
133
172
  function SvgUser(props) {
134
- return /*#__PURE__*/React.createElement("svg", _extends$1m({
173
+ return /*#__PURE__*/React.createElement("svg", _extends$2({
135
174
  viewBox: "0 0 16 16",
136
175
  fill: "none",
137
176
  strokeLinecap: "round",
138
177
  strokeLinejoin: "round",
139
178
  width: "1em",
140
179
  height: "1em"
141
- }, props), _path$I || (_path$I = /*#__PURE__*/React.createElement("path", {
180
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
142
181
  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",
143
182
  stroke: "currentColor"
144
183
  })));
145
184
  }
146
185
 
186
+ var _path$1;
187
+
188
+ 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); }
189
+
190
+ function SvgError(props) {
191
+ return /*#__PURE__*/React.createElement("svg", _extends$1({
192
+ viewBox: "0 0 16 16",
193
+ fill: "none",
194
+ strokeLinecap: "round",
195
+ strokeLinejoin: "round",
196
+ width: "1em",
197
+ height: "1em"
198
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
199
+ 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",
200
+ stroke: "currentColor"
201
+ })));
202
+ }
203
+
204
+ var _path;
205
+
206
+ 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); }
207
+
208
+ function SvgWarning(props) {
209
+ return /*#__PURE__*/React.createElement("svg", _extends({
210
+ viewBox: "0 0 16 16",
211
+ fill: "none",
212
+ strokeLinecap: "round",
213
+ strokeLinejoin: "round",
214
+ width: "1em",
215
+ height: "1em"
216
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
217
+ 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",
218
+ stroke: "currentColor"
219
+ })));
220
+ }
221
+
147
222
  var useIconStyles = makeStyles(function (_a) {
148
223
  var spacing = _a.spacing, palette = _a.palette;
149
224
  var getFontSize = function (_a) {
@@ -371,6 +446,93 @@ var Checkbox = forwardRef(function (props, ref) {
371
446
  });
372
447
  Checkbox.displayName = 'Checkbox';
373
448
 
449
+ var getBackground = function (theme) { return function (props) {
450
+ var variant = props.variant, severity = props.severity;
451
+ var background;
452
+ var backgrounds = {
453
+ outlined: 'none',
454
+ error: 'error.main',
455
+ warning: 'warning.main',
456
+ info: 'info.light',
457
+ success: 'success.light',
458
+ };
459
+ if (variant === 'outlined') {
460
+ background = backgrounds[variant];
461
+ }
462
+ else if (severity) {
463
+ var _a = backgrounds[severity].split('.'), color = _a[0], colorVariant = _a[1];
464
+ background = theme.palette[color][colorVariant];
465
+ }
466
+ return background;
467
+ }; };
468
+ var getColor = function (theme) { return function (props) {
469
+ var variant = props.variant, severity = props.severity;
470
+ var textColor;
471
+ if (variant === 'outlined' && severity) {
472
+ var textColors = {
473
+ error: theme.palette.error.main,
474
+ info: theme.palette.info.main,
475
+ warning: theme.palette.warning.dark,
476
+ success: theme.palette.success.dark,
477
+ };
478
+ textColor = textColors[severity];
479
+ }
480
+ else if (variant === 'outlined' && !severity) {
481
+ textColor = theme.palette.grey[700];
482
+ }
483
+ else if ((variant === 'default' || variant === undefined) && severity) {
484
+ var textColors = {
485
+ error: theme.palette.common.white,
486
+ info: theme.palette.secondary.main,
487
+ warning: theme.palette.secondary.main,
488
+ success: theme.palette.secondary.main,
489
+ };
490
+ textColor = textColors[severity];
491
+ }
492
+ return textColor;
493
+ }; };
494
+ var getBorder = function (theme) { return function (props) {
495
+ var variant = props.variant, severity = props.severity;
496
+ var borderColor;
497
+ if (variant === 'outlined' && severity) {
498
+ var borderColors = {
499
+ error: theme.palette.error.main,
500
+ info: theme.palette.info.main,
501
+ warning: theme.palette.warning.dark,
502
+ success: theme.palette.success.dark,
503
+ };
504
+ borderColor = borderColors[severity];
505
+ }
506
+ return borderColor;
507
+ }; };
508
+ var useChipStyles = makeStyles$1(function (theme) { return ({
509
+ root: {
510
+ background: getBackground(theme),
511
+ color: getColor(theme),
512
+ borderColor: getBorder(theme),
513
+ borderRadius: theme.spacing(0.5),
514
+ },
515
+ icon: {
516
+ color: 'inherit',
517
+ height: theme.spacing(2),
518
+ width: theme.spacing(2),
519
+ },
520
+ }); });
521
+
522
+ var IconDictionary = {
523
+ error: SvgError,
524
+ info: SvgInfo,
525
+ success: SvgCheckCircle,
526
+ warning: SvgWarning,
527
+ };
528
+ var Chip = function (props) {
529
+ var severity = props.severity, restProps = __rest(props, ["severity"]);
530
+ var classes = useChipStyles(props);
531
+ var icon = severity ? React__default.createElement(IconDictionary[severity]) : undefined;
532
+ return React__default.createElement(MuiChip, __assign({ classes: classes, icon: icon }, restProps));
533
+ };
534
+ Chip.displayName = 'Chip';
535
+
374
536
  var defaultTypographyProps = {
375
537
  variant: 'body1',
376
538
  };
@@ -831,5 +993,5 @@ var useTabs = function (options) {
831
993
  };
832
994
  };
833
995
 
834
- export { Avatar, Button, Checkbox, CollapsibleText, Divider, Icon, IconButton, Link, NumberField, Paper, PaperContent, Radio, SplitInput, Switch, TabPanel, ToggleButton, ToggleButtonGroup, Tooltip, Typography, useCollapsibleText, useTabs };
996
+ export { Avatar, Button, Checkbox, Chip, CollapsibleText, Divider, Icon, IconButton, Link, NumberField, Paper, PaperContent, Radio, SplitInput, Switch, TabPanel, ToggleButton, ToggleButtonGroup, Tooltip, Typography, useCollapsibleText, useTabs };
835
997
  //# sourceMappingURL=index.es.js.map