argous 1.2.242 → 1.2.244

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.
@@ -7,10 +7,15 @@ export interface CamProps {
7
7
  * Component style
8
8
  */
9
9
  style?: object,
10
+ /**
11
+ * constraints for cam audio and video
12
+ */
13
+ constraints?: object,
10
14
  /**
11
15
  * Function called on get stream
12
16
  */
13
17
  onGetStream?: (parameters: object) => void
18
+
14
19
  }
15
20
 
16
21
 
@@ -66,7 +66,7 @@ var react_1 = __importStar(require("react"));
66
66
  var GET_STREAM_INTERVAL_TIMEOUT = 3000;
67
67
  var VIDEO_ID = 'cam-video';
68
68
  var CANVAS_ID = 'cam-canvas';
69
- var VIDEO_CONSTRAINTS = {
69
+ var DEFAULT_VIDEO_CONSTRAINTS = {
70
70
  audio: false,
71
71
  video: {
72
72
  facingMode: 'user'
@@ -111,7 +111,7 @@ var camSnapshot = function (_a) {
111
111
  };
112
112
  exports.camSnapshot = camSnapshot;
113
113
  var Cam = function (_a) {
114
- var _b = _a.id, id = _b === void 0 ? '' : _b, _c = _a.style, style = _c === void 0 ? {} : _c, onGetStream = _a.onGetStream;
114
+ var _b = _a.id, id = _b === void 0 ? '' : _b, _c = _a.style, style = _c === void 0 ? {} : _c, onGetStream = _a.onGetStream, _d = _a.constraints, constraints = _d === void 0 ? DEFAULT_VIDEO_CONSTRAINTS : _d;
115
115
  var videoRef = react_1.useRef(null);
116
116
  var streamRef = react_1.useRef(null);
117
117
  var getStreamIntervalIdRef = react_1.useRef(null);
@@ -125,7 +125,7 @@ var Cam = function (_a) {
125
125
  _a.label = 1;
126
126
  case 1:
127
127
  _a.trys.push([1, 3, , 4]);
128
- return [4 /*yield*/, navigator.mediaDevices.getUserMedia(VIDEO_CONSTRAINTS)];
128
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
129
129
  case 2:
130
130
  stream = _a.sent();
131
131
  stream.getTracks().forEach(function (track) {
@@ -149,7 +149,7 @@ var Cam = function (_a) {
149
149
  return [2 /*return*/];
150
150
  }
151
151
  });
152
- }); }, [onGetStream]);
152
+ }); }, [onGetStream, constraints]);
153
153
  var stopVideo = function (stream) { return (stream) && stream.getTracks().forEach(function (track) {
154
154
  track === null || track === void 0 ? void 0 : track.stop();
155
155
  track.enabled = false;
@@ -163,6 +163,7 @@ var Cam = function (_a) {
163
163
  };
164
164
  }, [getStream]);
165
165
  return react_1.default.createElement("div", { style: style, className: 'cam-div' },
166
+ console.log('videoRef', videoRef),
166
167
  react_1.default.createElement("video", { id: videoElementId, ref: videoRef, autoPlay: true }));
167
168
  };
168
169
  exports.default = Cam;
@@ -1,3 +1,6 @@
1
+ import { TypographyVariant } from '@material-ui/core';
2
+
3
+
1
4
  export interface PercentageDisplayProps {
2
5
  /**
3
6
  * Identificação do elemento
@@ -6,7 +9,7 @@ export interface PercentageDisplayProps {
6
9
  /**
7
10
  * Porcentagem
8
11
  */
9
- percentage?: number|string,
12
+ percentage?: (number|string),
10
13
  /**
11
14
  * Tamanho do componente
12
15
  */
@@ -34,9 +37,15 @@ export interface PercentageDisplayProps {
34
37
  /**
35
38
  * Cor de fundo da barra
36
39
  */
37
- barBackgroundColor?: string
40
+ barBackgroundColor?: string,
41
+ /**
42
+ * Variant do componente Typography MUI
43
+ */
44
+ typographyVariant?: TypographyVariant
38
45
  }
39
46
 
47
+
40
48
  declare function PercentageDisplay(props: PercentageDisplayProps): JSX.Element
41
49
 
50
+
42
51
  export default PercentageDisplay;
@@ -61,7 +61,9 @@ var useStyles = core_1.makeStyles({
61
61
  }
62
62
  },
63
63
  valueContainer: {
64
- position: 'relative',
64
+ position: 'relative'
65
+ },
66
+ typography: {
65
67
  color: function (_a) {
66
68
  var color = _a.color;
67
69
  return color;
@@ -73,7 +75,7 @@ var useStyles = core_1.makeStyles({
73
75
  }
74
76
  });
75
77
  var PercentageDisplay = function (_a) {
76
- var id = _a.id, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.size, size = _c === void 0 ? 50 : _c, _d = _a.barWidth, barWidth = _d === void 0 ? 6 : _d, _e = _a.fontSize, fontSize = _e === void 0 ? '0.9rem' : _e, _f = _a.color, color = _f === void 0 ? '#000' : _f, _g = _a.backgroundColor, backgroundColor = _g === void 0 ? '#fff' : _g, _h = _a.barColor, barColor = _h === void 0 ? '#00995d' : _h, _j = _a.barBackgroundColor, barBackgroundColor = _j === void 0 ? '#00995d26' : _j;
78
+ var id = _a.id, _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.size, size = _c === void 0 ? 50 : _c, _d = _a.barWidth, barWidth = _d === void 0 ? 6 : _d, _e = _a.fontSize, fontSize = _e === void 0 ? '0.9rem' : _e, _f = _a.color, color = _f === void 0 ? '#000' : _f, _g = _a.typographyVariant, typographyVariant = _g === void 0 ? undefined : _g, _h = _a.backgroundColor, backgroundColor = _h === void 0 ? '#fff' : _h, _j = _a.barColor, barColor = _j === void 0 ? '#00995d' : _j, _k = _a.barBackgroundColor, barBackgroundColor = _k === void 0 ? '#00995d26' : _k;
77
79
  var progressBarWidth = size - barWidth;
78
80
  var classes = useStyles({ color: color, backgroundColor: backgroundColor, barColor: barColor, barBackgroundColor: barBackgroundColor, size: size, progressBarWidth: progressBarWidth, fontSize: fontSize });
79
81
  var percentageDisplayProgressId = id + "-percentageDisplayProgress";
@@ -84,9 +86,12 @@ var PercentageDisplay = function (_a) {
84
86
  return;
85
87
  progressBar.style.background = "conic-gradient(" + barColor + " " + porcentagem * 3.6 + "deg, " + barBackgroundColor + " " + porcentagem * 3.6 + "deg)";
86
88
  }, [barBackgroundColor, barColor, percentage, percentageDisplayProgressId]);
87
- react_1.useEffect(function () { return createProgress(); }, [percentage, createProgress]);
89
+ react_1.useEffect(function () {
90
+ createProgress();
91
+ }, [percentage, createProgress]);
88
92
  return react_1.default.createElement("div", { className: classes.container },
89
93
  react_1.default.createElement("div", { id: percentageDisplayProgressId, className: classes.circularProgress },
90
- react_1.default.createElement("div", { className: classes.valueContainer }, percentage + "%")));
94
+ react_1.default.createElement("div", { className: classes.valueContainer },
95
+ react_1.default.createElement(core_1.Typography, { variant: typographyVariant, className: classes.typography }, percentage + "%"))));
91
96
  };
92
97
  exports.default = PercentageDisplay;
@@ -7,10 +7,15 @@ export interface CamProps {
7
7
  * Component style
8
8
  */
9
9
  style?: object,
10
+ /**
11
+ * constraints for cam audio and video
12
+ */
13
+ constraints?: object,
10
14
  /**
11
15
  * Function called on get stream
12
16
  */
13
17
  onGetStream?: (parameters: object) => void
18
+
14
19
  }
15
20
 
16
21
 
@@ -9,7 +9,7 @@ const GET_STREAM_INTERVAL_TIMEOUT = 3000;
9
9
  const VIDEO_ID = 'cam-video';
10
10
  const CANVAS_ID = 'cam-canvas';
11
11
 
12
- const VIDEO_CONSTRAINTS = {
12
+ const DEFAULT_VIDEO_CONSTRAINTS = {
13
13
  audio: false,
14
14
  video: {
15
15
  facingMode: 'user'
@@ -51,7 +51,7 @@ export const camSnapshot = ({ e = undefined, download = false, camComponentId =
51
51
  };
52
52
 
53
53
 
54
- const Cam = ({ id = '', style = {}, onGetStream }) => {
54
+ const Cam = ({ id = '', style = {}, onGetStream, constraints = DEFAULT_VIDEO_CONSTRAINTS }) => {
55
55
 
56
56
  const videoRef = useRef(null);
57
57
  const streamRef = useRef(null);
@@ -62,7 +62,7 @@ const Cam = ({ id = '', style = {}, onGetStream }) => {
62
62
  let stream = null;
63
63
 
64
64
  try {
65
- stream = await navigator.mediaDevices.getUserMedia(VIDEO_CONSTRAINTS);
65
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
66
66
  stream.getTracks().forEach((track) => {
67
67
  if (track.kind === 'video') track.enabled = true;
68
68
  });
@@ -76,7 +76,7 @@ const Cam = ({ id = '', style = {}, onGetStream }) => {
76
76
  streamRef.current = stream;
77
77
  (typeof onGetStream === 'function') && onGetStream({ stream });
78
78
  } else if (stream) stopVideo(stream);
79
- }, [onGetStream]);
79
+ }, [onGetStream, constraints]);
80
80
 
81
81
  const stopVideo = (stream) => (stream) && stream.getTracks().forEach((track) => {
82
82
  track?.stop();
@@ -94,6 +94,7 @@ const Cam = ({ id = '', style = {}, onGetStream }) => {
94
94
 
95
95
 
96
96
  return <div style={style} className='cam-div'>
97
+ {console.log('videoRef', videoRef)}
97
98
  <video id={videoElementId} ref={videoRef} autoPlay />
98
99
  </div>;
99
100
  };
@@ -1,3 +1,6 @@
1
+ import { TypographyVariant } from '@material-ui/core';
2
+
3
+
1
4
  export interface PercentageDisplayProps {
2
5
  /**
3
6
  * Identificação do elemento
@@ -6,7 +9,7 @@ export interface PercentageDisplayProps {
6
9
  /**
7
10
  * Porcentagem
8
11
  */
9
- percentage?: number|string,
12
+ percentage?: (number|string),
10
13
  /**
11
14
  * Tamanho do componente
12
15
  */
@@ -34,9 +37,15 @@ export interface PercentageDisplayProps {
34
37
  /**
35
38
  * Cor de fundo da barra
36
39
  */
37
- barBackgroundColor?: string
40
+ barBackgroundColor?: string,
41
+ /**
42
+ * Variant do componente Typography MUI
43
+ */
44
+ typographyVariant?: TypographyVariant
38
45
  }
39
46
 
47
+
40
48
  declare function PercentageDisplay(props: PercentageDisplayProps): JSX.Element
41
49
 
50
+
42
51
  export default PercentageDisplay;
@@ -1,6 +1,7 @@
1
- import { makeStyles } from '@material-ui/core';
1
+ import { makeStyles, Typography } from '@material-ui/core';
2
2
  import React, { useCallback, useEffect } from 'react';
3
3
 
4
+
4
5
  const useStyles = makeStyles({
5
6
  container: {
6
7
  display: 'grid',
@@ -23,12 +24,15 @@ const useStyles = makeStyles({
23
24
  }
24
25
  },
25
26
  valueContainer: {
26
- position: 'relative',
27
+ position: 'relative'
28
+ },
29
+ typography: {
27
30
  color: ({ color }) => color,
28
31
  fontSize: ({ fontSize }) => fontSize
29
32
  }
30
33
  });
31
34
 
35
+
32
36
  const PercentageDisplay = ({
33
37
  id,
34
38
  percentage = 0,
@@ -36,6 +40,7 @@ const PercentageDisplay = ({
36
40
  barWidth = 6,
37
41
  fontSize = '0.9rem',
38
42
  color = '#000',
43
+ typographyVariant = undefined,
39
44
  backgroundColor = '#fff',
40
45
  barColor = '#00995d',
41
46
  barBackgroundColor = '#00995d26'
@@ -51,15 +56,22 @@ const PercentageDisplay = ({
51
56
  if (!progressBar) return;
52
57
  progressBar.style.background = `conic-gradient(${barColor} ${porcentagem * 3.6}deg, ${barBackgroundColor} ${porcentagem * 3.6}deg)`;
53
58
  }, [barBackgroundColor, barColor, percentage, percentageDisplayProgressId]);
54
- useEffect(() => createProgress(), [percentage, createProgress]);
59
+
60
+ useEffect(() => {
61
+ createProgress();
62
+ }, [percentage, createProgress]);
63
+
55
64
 
56
65
  return <div className={classes.container}>
57
66
  <div id={percentageDisplayProgressId} className={classes.circularProgress}>
58
67
  <div className={classes.valueContainer}>
59
- {`${percentage}%`}
68
+ <Typography variant={typographyVariant} className={classes.typography}>
69
+ {`${percentage}%`}
70
+ </Typography>
60
71
  </div>
61
72
  </div>
62
73
  </div>;
63
74
  };
64
75
 
76
+
65
77
  export default PercentageDisplay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.242",
3
+ "version": "1.2.244",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",