argous 1.2.219 → 1.2.221

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.
@@ -201,9 +201,9 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
201
201
  }, [ctrlPgn.recordCount]);
202
202
  var buscaMetodo = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
203
203
  var res;
204
- var _a, _b, _c, _d, _e, _f;
205
- return __generator(this, function (_g) {
206
- switch (_g.label) {
204
+ var _a, _b;
205
+ return __generator(this, function (_c) {
206
+ switch (_c.label) {
207
207
  case 0:
208
208
  if (!method || !allowMethodRequest)
209
209
  return [2 /*return*/];
@@ -215,10 +215,10 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
215
215
  indOrdem: orderBy >= 0 ? orderBy : undefined
216
216
  } }, methodPrms), handleMethodError)];
217
217
  case 1:
218
- res = _g.sent();
218
+ res = _c.sent();
219
219
  onMethodResponse && onMethodResponse(res);
220
220
  if (res.status) {
221
- setCtrlPgn(__assign(__assign({}, res.ctrlPgn), { recordCount: ((((_a = res.ctrlPgn) === null || _a === void 0 ? void 0 : _a.recordCount) || ((_b = res[methodResultList]) === null || _b === void 0 ? void 0 : _b.length)) < ((_c = res.ctrlPgn) === null || _c === void 0 ? void 0 : _c.qtRegs)) ? (_d = res[methodResultList]) === null || _d === void 0 ? void 0 : _d.length : ((_e = res.ctrlPgn) === null || _e === void 0 ? void 0 : _e.qtPaginas) * ((_f = res.ctrlPgn) === null || _f === void 0 ? void 0 : _f.qtRegs) }));
221
+ setCtrlPgn(__assign(__assign({}, res.ctrlPgn), { recordCount: (((_a = res.ctrlPgn) === null || _a === void 0 ? void 0 : _a.qtPaginas) * ((_b = res.ctrlPgn) === null || _b === void 0 ? void 0 : _b.qtRegs)) }));
222
222
  setLista(res[methodResultList] || []);
223
223
  }
224
224
  dispatch({ type: 'setLoading', value: false });
@@ -279,7 +279,6 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
279
279
  setSelected: function (s) { return dispatch({ type: 'setSelected', value: lodash_1.isFunction(s) ? s(selected, dadosMostrados) : s }); },
280
280
  setLoading: function (value) { return dispatch({ type: 'setLoading', value: value }); }
281
281
  }); });
282
- //________________EXTERNAL_CTRL_PGN____________________________________________________________________________
283
282
  var _2 = react_1.useState(true), bounced = _2[0], setBounced = _2[1];
284
283
  var getFullCtrlPgn = function (internal) {
285
284
  var ctrl = internal ? ctrlPgn : externalCtrlPgn;
@@ -302,17 +301,16 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
302
301
  var fullCtrlPgn = getFullCtrlPgn(true);
303
302
  var fullExternalCtrlPgn = getFullCtrlPgn();
304
303
  if (!lodash_1.isEqual(fullExternalCtrlPgn, fullCtrlPgn)) {
305
- setCtrlPgn(__assign(__assign({}, fullExternalCtrlPgn), { recordCount: (((externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.recordCount) || (dados === null || dados === void 0 ? void 0 : dados.length)) < (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtRegs)) ? dados === null || dados === void 0 ? void 0 : dados.length : (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtPaginas) * (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtRegs) }));
304
+ setCtrlPgn(__assign(__assign({}, fullExternalCtrlPgn), { recordCount: ((externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtPaginas) * (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtRegs)) }));
306
305
  setBounced(true);
307
306
  }
308
307
  }
309
308
  // eslint-disable-next-line react-hooks/exhaustive-deps
310
309
  }, [externalCtrlPgn]);
311
- //_____________________________________________________________________________________________________________
312
- return (react_1.default.createElement(exports.TableContext.Provider, { value: __assign(__assign({}, memoState), { dadosMostrados: dadosMostrados, lista: lista, indexToSelect: indexToSelect, method: method }) },
310
+ return (react_1.default.createElement(exports.TableContext.Provider, { value: __assign(__assign({}, memoState), { dadosMostrados: dadosMostrados, lista: lista, indexToSelect: indexToSelect, method: method, externalCtrlPgn: externalCtrlPgn }) },
313
311
  react_1.default.createElement(core_1.ClickAwayListener, { onClickAway: onClickAway },
314
312
  react_1.default.createElement(core_1.TableContainer, __assign({ component: core_1.Paper, variant: 'outlined', style: style }, containerProps, { className: clsx_1.default(classes.root, className) }),
315
- react_1.default.createElement(ToolbarComponent, __assign({ numSelected: selected.length, disableFilter: disableFilter || !!method }, __assign({ actions: actions, title: title, selected: selected, filter: filter, filterLabel: filterLabel, lista: lista, indexToSelect: indexToSelect, fixedToolbar: fixedToolbar }, toolbarProps))),
313
+ react_1.default.createElement(ToolbarComponent, __assign({ numSelected: selected.length, disableFilter: disableFilter || !!method || !!externalCtrlPgn }, __assign({ actions: actions, title: title, selected: selected, filter: filter, filterLabel: filterLabel, lista: lista, indexToSelect: indexToSelect, fixedToolbar: fixedToolbar }, toolbarProps))),
316
314
  react_1.default.createElement(core_1.Table, __assign({}, __assign(__assign({}, tableProps), { size: size })),
317
315
  react_1.default.createElement(HeadComponent, __assign({ size: (method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length, numSelected: selected.length, rowCount: (rowsPerPage > ((method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length)) ? ((method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length) : (rowsPerPage || dadosNaoCortados.length) }, { head: head, order: order, orderBy: orderBy, enableCheck: enableCheck, headerColumnStyles: headerColumnStyles, disableSorting: disableSorting, ordCols: ordCols, method: method, cortaDados: cortaDados, disableCheckIf: disableCheckIf, line: line, enableDrag: enableDrag })),
318
316
  react_1.default.createElement(BodyComponent, __assign({}, {
@@ -51,16 +51,16 @@ var ArgousComplexTableHead = react_1.memo(function (_a) {
51
51
  var _b;
52
52
  var numSelected = _a.numSelected, rowCount = _a.rowCount, head = _a.head, enableCheck = _a.enableCheck, disableCheckIf = _a.disableCheckIf, line = _a.line, size = _a.size, headerColumnStyles = _a.headerColumnStyles, disableSorting = _a.disableSorting, ordCols = _a.ordCols, cortaDados = _a.cortaDados, enableDrag = _a.enableDrag;
53
53
  var classes = useStyles();
54
- var _c = react_1.useContext(ArgousComplexTable_1.TableContext), selected = _c.selected, order = _c.order, orderBy = _c.orderBy, dispatch = _c.dispatch, lista = _c.lista, indexToSelect = _c.indexToSelect, method = _c.method;
54
+ var _c = react_1.useContext(ArgousComplexTable_1.TableContext), selected = _c.selected, order = _c.order, orderBy = _c.orderBy, dispatch = _c.dispatch, lista = _c.lista, indexToSelect = _c.indexToSelect, method = _c.method, externalCtrlPgn = _c.externalCtrlPgn;
55
55
  var handleRequestSort = function (property) {
56
56
  var isAsc = orderBy === property && order === 'asc';
57
57
  dispatch({ type: 'setOrder', value: isAsc ? 'desc' : 'asc' });
58
58
  dispatch({ type: 'setOrderBy', value: property });
59
59
  };
60
- var length = react_1.useMemo(function () { return disableCheckIf ? lista.reduce(function (acc, linha, i) { return !disableCheckIf(linha, line(linha), i) ? acc + 1 : acc; }, 0) : size; }, [disableCheckIf, lista, size]);
60
+ var length = react_1.useMemo(function () { return disableCheckIf ? lista.reduce(function (acc, linha, i) { return !disableCheckIf(linha, line(linha), i) ? acc + 1 : acc; }, 0) : size; }, [disableCheckIf, lista, size, line]);
61
61
  var handleSelectAllClick = function (event) {
62
62
  if (event.target.checked) {
63
- if (!method && selected.length === 0)
63
+ if (!method && !externalCtrlPgn && (selected.length === 0))
64
64
  dispatch({ type: 'setSelected', value: cortaDados(lista).filter(function (linha, i) { return disableCheckIf ? !disableCheckIf(linha, line(linha), i) : true; }).map(function (n) { return n[indexToSelect]; }) });
65
65
  else if (selected.length < length)
66
66
  dispatch({ type: 'setSelected', value: lista.filter(function (linha, i) { return disableCheckIf ? !disableCheckIf(linha, line(linha), i) : true; }).map(function (n) { return n[indexToSelect]; }) });
@@ -72,12 +72,12 @@ var ArgousComplexTableHead = react_1.memo(function (_a) {
72
72
  };
73
73
  return (react_1.default.createElement(core_1.TableHead, null,
74
74
  react_1.default.createElement(core_1.TableRow, { className: clsx_1.default((_b = {},
75
- _b[classes.highlight] = (numSelected === rowCount || numSelected === length) && (rowCount && length),
76
- _b[classes.lighthighlight] = numSelected > 0 && numSelected < rowCount,
75
+ _b[classes.highlight] = (((numSelected === rowCount) || (numSelected === length) || (numSelected === (lista === null || lista === void 0 ? void 0 : lista.length))) && (rowCount && length)),
76
+ _b[classes.lighthighlight] = ((numSelected > 0) && ((method || externalCtrlPgn) ? (numSelected < (lista === null || lista === void 0 ? void 0 : lista.length)) : (numSelected < rowCount))),
77
77
  _b)) },
78
78
  enableDrag && react_1.default.createElement(core_1.TableCell, { padding: 'checkbox' }),
79
79
  enableCheck && react_1.default.createElement(core_1.TableCell, { padding: 'checkbox' },
80
- react_1.default.createElement(core_1.Checkbox, { disabled: !length, indeterminate: method ? (numSelected > 0 && numSelected < rowCount) : (numSelected > 0 && numSelected < length), checked: method ? (rowCount > 0 && numSelected === rowCount) : (rowCount > 0 && length && numSelected === length), onChange: handleSelectAllClick })),
80
+ react_1.default.createElement(core_1.Checkbox, { disabled: !length, indeterminate: (method || externalCtrlPgn) ? ((numSelected > 0) && (numSelected < (lista === null || lista === void 0 ? void 0 : lista.length))) : ((numSelected > 0) && (numSelected < length)), checked: (method || externalCtrlPgn) ? ((rowCount > 0) && ((numSelected === rowCount) || (numSelected === (lista === null || lista === void 0 ? void 0 : lista.length)))) : ((rowCount > 0) && length && (numSelected === length)), onChange: handleSelectAllClick })),
81
81
  lodash_1.isArray(head) && head.map(function (item, i) { return (react_1.default.createElement(core_1.TableCell, { key: i, style: headerColumnStyles ? headerColumnStyles[i] : undefined }, (disableSorting[i] || (ordCols && !ordCols[i])) ?
82
82
  item
83
83
  :
@@ -0,0 +1,19 @@
1
+ export interface CamProps {
2
+ /**
3
+ * ID
4
+ */
5
+ id: string,
6
+ /**
7
+ * Component style
8
+ */
9
+ style?: object,
10
+ /**
11
+ * Function called on get stream
12
+ */
13
+ onGetStream?: (parameters: object) => void
14
+ }
15
+
16
+
17
+ declare function Cam(props: CamProps): JSX.Element
18
+
19
+ export default Cam;
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __generator = (this && this.__generator) || function (thisArg, body) {
31
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
+ function verb(n) { return function (v) { return step([n, v]); }; }
34
+ function step(op) {
35
+ if (f) throw new TypeError("Generator is already executing.");
36
+ while (_) try {
37
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
38
+ if (y = 0, t) op = [op[0] & 2, t.value];
39
+ switch (op[0]) {
40
+ case 0: case 1: t = op; break;
41
+ case 4: _.label++; return { value: op[1], done: false };
42
+ case 5: _.label++; y = op[1]; op = [0]; continue;
43
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
+ default:
45
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
+ if (t[2]) _.ops.pop();
50
+ _.trys.pop(); continue;
51
+ }
52
+ op = body.call(thisArg, _);
53
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
+ }
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.camSnapshot = void 0;
62
+ var utils_1 = require("../../utils");
63
+ require("./cam.css");
64
+ var moment_1 = __importDefault(require("moment"));
65
+ var react_1 = __importStar(require("react"));
66
+ var GET_STREAM_INTERVAL_TIMEOUT = 3000;
67
+ var VIDEO_ID = 'cam-video';
68
+ var CANVAS_ID = 'cam-canvas';
69
+ var VIDEO_CONSTRAINTS = {
70
+ audio: false,
71
+ video: {
72
+ facingMode: 'user'
73
+ }
74
+ };
75
+ var createVideoElementId = function (id) {
76
+ if (id === void 0) { id = ''; }
77
+ return (id) ? id + "-" + VIDEO_ID : VIDEO_ID;
78
+ };
79
+ var createCanvasElementId = function (id) {
80
+ if (id === void 0) { id = ''; }
81
+ return (id) ? id + "-" + CANVAS_ID : CANVAS_ID;
82
+ };
83
+ var camSnapshot = function (_a) {
84
+ var _b = _a.e, e = _b === void 0 ? undefined : _b, _c = _a.download, download = _c === void 0 ? false : _c, _d = _a.camComponentId, camComponentId = _d === void 0 ? '' : _d;
85
+ var status = false, file = undefined, linkElement = undefined, canvasElement = undefined;
86
+ var videoElementId = createVideoElementId(camComponentId);
87
+ var videoElement = document.getElementById(videoElementId);
88
+ if (videoElement) {
89
+ canvasElement = document.createElement('canvas');
90
+ if (canvasElement) {
91
+ var canvasElementId = createCanvasElementId(camComponentId);
92
+ canvasElement.id = canvasElementId;
93
+ var canvasContext2D = canvasElement.getContext('2d');
94
+ if (canvasContext2D) {
95
+ canvasElement.width = videoElement.offsetWidth;
96
+ canvasElement.height = videoElement.offsetHeight;
97
+ canvasContext2D.drawImage(videoElement, 0, 0, videoElement.offsetWidth, videoElement.offsetHeight);
98
+ linkElement = document.createElement('a');
99
+ linkElement.download = "Capture_" + moment_1.default(new Date()).format('DD-MM-YYYY_HH:mm:ss') + ".png";
100
+ var dataUrl = canvasElement.toDataURL('image/png');
101
+ linkElement.href = dataUrl;
102
+ var blob = utils_1.dataUrlToBlob(dataUrl);
103
+ if (blob)
104
+ file = new File([blob], linkElement.download, { type: blob.type });
105
+ }
106
+ }
107
+ }
108
+ (linkElement && file) && (status = true);
109
+ (linkElement && download) && linkElement.click();
110
+ return { e: e, status: status, file: file, link: linkElement, canvas: canvasElement };
111
+ };
112
+ exports.camSnapshot = camSnapshot;
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;
115
+ var videoRef = react_1.useRef(null);
116
+ var streamRef = react_1.useRef(null);
117
+ var getStreamIntervalIdRef = react_1.useRef(null);
118
+ var videoElementId = createVideoElementId(id);
119
+ var getStream = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
120
+ var stream, error_1;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ stream = null;
125
+ _a.label = 1;
126
+ case 1:
127
+ _a.trys.push([1, 3, , 4]);
128
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia(VIDEO_CONSTRAINTS)];
129
+ case 2:
130
+ stream = _a.sent();
131
+ stream.getTracks().forEach(function (track) {
132
+ if (track.kind === 'video')
133
+ track.enabled = true;
134
+ });
135
+ return [3 /*break*/, 4];
136
+ case 3:
137
+ error_1 = _a.sent();
138
+ console.error(error_1);
139
+ return [3 /*break*/, 4];
140
+ case 4:
141
+ if ((stream && !streamRef.current) || (!stream && streamRef.current)) {
142
+ videoRef.current.srcObject = stream;
143
+ stopVideo(streamRef.current);
144
+ streamRef.current = stream;
145
+ (typeof onGetStream === 'function') && onGetStream({ stream: stream });
146
+ }
147
+ else if (stream)
148
+ stopVideo(stream);
149
+ return [2 /*return*/];
150
+ }
151
+ });
152
+ }); }, [onGetStream]);
153
+ var stopVideo = function (stream) { return (stream) && stream.getTracks().forEach(function (track) {
154
+ track === null || track === void 0 ? void 0 : track.stop();
155
+ track.enabled = false;
156
+ }); };
157
+ react_1.useEffect(function () {
158
+ getStream();
159
+ getStreamIntervalIdRef.current = setInterval(function () { return getStream(); }, GET_STREAM_INTERVAL_TIMEOUT);
160
+ return function () {
161
+ clearInterval(getStreamIntervalIdRef.current);
162
+ stopVideo(streamRef.current);
163
+ };
164
+ }, [getStream]);
165
+ return react_1.default.createElement("div", { style: style, className: 'cam-div' },
166
+ react_1.default.createElement("video", { id: videoElementId, ref: videoRef, autoPlay: true }));
167
+ };
168
+ exports.default = Cam;
@@ -0,0 +1,8 @@
1
+ .cam-div {
2
+ display: grid;
3
+ }
4
+
5
+ video {
6
+ width: 100%;
7
+ background-color: #000;
8
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './Cam';
2
+ export * from './Cam';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var Cam_1 = require("./Cam");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Cam_1).default; } });
@@ -66,6 +66,6 @@ export interface CarouselProps {
66
66
  }
67
67
 
68
68
 
69
- declare function Carousel(props: CarouselProps) : JSX.Element
69
+ declare function Carousel(props: CarouselProps): JSX.Element
70
70
 
71
71
  export default Carousel;
@@ -166,4 +166,7 @@ export { default as Zoom } from './Zoom';
166
166
  export * from './Zoom';
167
167
 
168
168
  export { default as Carousel } from './Carousel';
169
- export * from './Carousel';
169
+ export * from './Carousel';
170
+
171
+ export { default as Cam } from './Cam';
172
+ export * from './Cam';
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.AutoCompleteFavorites = exports.UtilAutoComplete = exports.ThreadLog = exports.TextArea = exports.Tabs = exports.TablePicker = exports.Stepper = exports.SimpleTable = exports.Select = exports.ProgressBar = exports.Programa = exports.Pagination = exports.OutputText = exports.OtpInput = exports.MultipleSelect = exports.MonthPicker = exports.ModalProvider = exports.MenuBar = exports.MaterialButton = exports.ListSelect = exports.InputTags = exports.Input = exports.ImageResizeButton = exports.ImageResize = exports.Highlight = exports.FormVisualizer = exports.FileUploader = exports.FilePreparer = exports.DropArea = exports.Compartilhar = exports.Collapse = exports.CartaoUsuario = exports.Calendar = exports.Cabecalho = exports.Button = exports.BarraFerramentas = exports.BarChart = exports.AutoComplete = exports.ArgousSimpleTable = exports.ArgousProgressBar = exports.ArgousPagination = exports.ArgousInput = exports.ArgousComplexTableToolbar = exports.ArgousComplexTableHead = exports.ArgousComplexTableBody = exports.ArgousComplexTable = exports.ArgousComplexPagination = exports.ArgousAvatar = exports.ArgousAction = exports.Alert = void 0;
17
- exports.Carousel = exports.Zoom = exports.TextToHtml = exports.UserCard = exports.HalfGauge = exports.PercentageDisplay = void 0;
17
+ exports.Cam = exports.Carousel = exports.Zoom = exports.TextToHtml = exports.UserCard = exports.HalfGauge = exports.PercentageDisplay = void 0;
18
18
  var Alert_1 = require("./Alert");
19
19
  Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
20
20
  __exportStar(require("./Alert"), exports);
@@ -182,3 +182,6 @@ __exportStar(require("./Zoom"), exports);
182
182
  var Carousel_1 = require("./Carousel");
183
183
  Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return __importDefault(Carousel_1).default; } });
184
184
  __exportStar(require("./Carousel"), exports);
185
+ var Cam_1 = require("./Cam");
186
+ Object.defineProperty(exports, "Cam", { enumerable: true, get: function () { return __importDefault(Cam_1).default; } });
187
+ __exportStar(require("./Cam"), exports);
@@ -225,7 +225,7 @@ const ArgousComplexTable = forwardRef(({
225
225
  }, handleMethodError);
226
226
  onMethodResponse && onMethodResponse(res);
227
227
  if (res.status) {
228
- setCtrlPgn({ ...res.ctrlPgn, recordCount: ((res.ctrlPgn?.recordCount || res[methodResultList]?.length) < res.ctrlPgn?.qtRegs) ? res[methodResultList]?.length : res.ctrlPgn?.qtPaginas * res.ctrlPgn?.qtRegs });
228
+ setCtrlPgn({ ...res.ctrlPgn, recordCount: (res.ctrlPgn?.qtPaginas * res.ctrlPgn?.qtRegs) });
229
229
  setLista(res[methodResultList] || []);
230
230
  }
231
231
  dispatch({ type: 'setLoading', value: false });
@@ -288,9 +288,6 @@ const ArgousComplexTable = forwardRef(({
288
288
  setLoading: value => dispatch({ type: 'setLoading', value })
289
289
  }));
290
290
 
291
-
292
- //________________EXTERNAL_CTRL_PGN____________________________________________________________________________
293
-
294
291
  const [bounced, setBounced] = useState(true);
295
292
 
296
293
  const getFullCtrlPgn = (internal) => {
@@ -302,7 +299,7 @@ const ArgousComplexTable = forwardRef(({
302
299
  ...ctrl
303
300
  };
304
301
  };
305
-
302
+
306
303
  useEffect(() => {
307
304
  if (!method && setExternalCtrlPgn) {
308
305
  const fullCtrlPgn = {
@@ -323,23 +320,21 @@ const ArgousComplexTable = forwardRef(({
323
320
  const fullCtrlPgn = getFullCtrlPgn(true);
324
321
  const fullExternalCtrlPgn = getFullCtrlPgn();
325
322
  if (!isEqual(fullExternalCtrlPgn, fullCtrlPgn)) {
326
- setCtrlPgn({ ...fullExternalCtrlPgn, recordCount: ((externalCtrlPgn?.recordCount || dados?.length) < externalCtrlPgn?.qtRegs) ? dados?.length : externalCtrlPgn?.qtPaginas * externalCtrlPgn?.qtRegs });
323
+ setCtrlPgn({ ...fullExternalCtrlPgn, recordCount: (externalCtrlPgn?.qtPaginas * externalCtrlPgn?.qtRegs) });
327
324
  setBounced(true);
328
325
  }
329
326
  }
330
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
331
328
  }, [externalCtrlPgn]);
332
-
333
- //_____________________________________________________________________________________________________________
334
-
329
+
335
330
 
336
331
  return (
337
- <TableContext.Provider value={{ ...memoState, dadosMostrados, lista, indexToSelect, method }}>
332
+ <TableContext.Provider value={{ ...memoState, dadosMostrados, lista, indexToSelect, method, externalCtrlPgn }}>
338
333
  <ClickAwayListener onClickAway={onClickAway}>
339
334
  <TableContainer component={Paper} variant='outlined' style={style} {...containerProps} className={clsx(classes.root, className)}>
340
335
  <ToolbarComponent
341
336
  numSelected={selected.length}
342
- disableFilter={disableFilter || !!method}
337
+ disableFilter={disableFilter || !!method || !!externalCtrlPgn}
343
338
  {...{ actions, title, selected, filter, filterLabel, lista, indexToSelect, fixedToolbar, ...toolbarProps }} />
344
339
  <Table {...{ ...tableProps, size }}>
345
340
  <HeadComponent
@@ -40,7 +40,7 @@ const ArgousComplexTableHead = memo(({
40
40
  enableDrag
41
41
  }) => {
42
42
  const classes = useStyles();
43
- const { selected, order, orderBy, dispatch, lista, indexToSelect, method } = useContext(TableContext);
43
+ const { selected, order, orderBy, dispatch, lista, indexToSelect, method, externalCtrlPgn } = useContext(TableContext);
44
44
 
45
45
  const handleRequestSort = property => {
46
46
  const isAsc = orderBy === property && order === 'asc';
@@ -48,11 +48,11 @@ const ArgousComplexTableHead = memo(({
48
48
  dispatch({ type: 'setOrderBy', value: property });
49
49
  };
50
50
 
51
- const length = useMemo(() => disableCheckIf ? lista.reduce((acc, linha, i) => !disableCheckIf(linha, line(linha), i) ? acc + 1 : acc, 0) : size, [disableCheckIf, lista, size]);
51
+ const length = useMemo(() => disableCheckIf ? lista.reduce((acc, linha, i) => !disableCheckIf(linha, line(linha), i) ? acc + 1 : acc, 0) : size, [disableCheckIf, lista, size, line]);
52
52
 
53
53
  const handleSelectAllClick = event => {
54
54
  if (event.target.checked) {
55
- if (!method && selected.length === 0) dispatch({ type: 'setSelected', value: cortaDados(lista).filter((linha, i) => disableCheckIf ? !disableCheckIf(linha, line(linha), i) : true).map((n) => n[indexToSelect]) });
55
+ if (!method && !externalCtrlPgn && (selected.length === 0)) dispatch({ type: 'setSelected', value: cortaDados(lista).filter((linha, i) => disableCheckIf ? !disableCheckIf(linha, line(linha), i) : true).map((n) => n[indexToSelect]) });
56
56
  else if (selected.length < length) dispatch({ type: 'setSelected', value: lista.filter((linha, i) => disableCheckIf ? !disableCheckIf(linha, line(linha), i) : true).map((n) => n[indexToSelect]) });
57
57
  else dispatch({ type: 'setSelected', value: [] });
58
58
  } else dispatch({ type: 'setSelected', value: [] });
@@ -61,15 +61,15 @@ const ArgousComplexTableHead = memo(({
61
61
  return (
62
62
  <TableHead>
63
63
  <TableRow className={clsx({
64
- [classes.highlight]: (numSelected === rowCount || numSelected === length) && (rowCount && length),
65
- [classes.lighthighlight]: numSelected > 0 && numSelected < rowCount
64
+ [classes.highlight]: (((numSelected === rowCount) || (numSelected === length) || (numSelected === lista?.length)) && (rowCount && length)),
65
+ [classes.lighthighlight]: ((numSelected > 0) && ((method || externalCtrlPgn) ? (numSelected < lista?.length) : (numSelected < rowCount)))
66
66
  })}>
67
67
  {enableDrag && <TableCell padding='checkbox'/>}
68
68
  {enableCheck && <TableCell padding='checkbox'>
69
69
  <Checkbox
70
70
  disabled={!length}
71
- indeterminate={method ? (numSelected > 0 && numSelected < rowCount) : (numSelected > 0 && numSelected < length)}
72
- checked={method ? (rowCount > 0 && numSelected === rowCount) : (rowCount > 0 && length && numSelected === length)}
71
+ indeterminate={(method || externalCtrlPgn) ? ((numSelected > 0) && (numSelected < lista?.length)) : ((numSelected > 0) && (numSelected < length))}
72
+ checked={(method || externalCtrlPgn) ? ((rowCount > 0) && ((numSelected === rowCount) || (numSelected === lista?.length))) : ((rowCount > 0) && length && (numSelected === length))}
73
73
  onChange={handleSelectAllClick}
74
74
  />
75
75
  </TableCell>}
@@ -0,0 +1,19 @@
1
+ export interface CamProps {
2
+ /**
3
+ * ID
4
+ */
5
+ id: string,
6
+ /**
7
+ * Component style
8
+ */
9
+ style?: object,
10
+ /**
11
+ * Function called on get stream
12
+ */
13
+ onGetStream?: (parameters: object) => void
14
+ }
15
+
16
+
17
+ declare function Cam(props: CamProps): JSX.Element
18
+
19
+ export default Cam;
@@ -0,0 +1,102 @@
1
+ import { dataUrlToBlob } from '../../utils';
2
+ import './cam.css';
3
+ import moment from 'moment';
4
+ import React, { useCallback, useEffect, useRef } from 'react';
5
+
6
+
7
+ const GET_STREAM_INTERVAL_TIMEOUT = 3000;
8
+
9
+ const VIDEO_ID = 'cam-video';
10
+ const CANVAS_ID = 'cam-canvas';
11
+
12
+ const VIDEO_CONSTRAINTS = {
13
+ audio: false,
14
+ video: {
15
+ facingMode: 'user'
16
+ }
17
+ };
18
+
19
+ const createVideoElementId = (id = '') => (id) ? `${id}-${VIDEO_ID}` : VIDEO_ID;
20
+ const createCanvasElementId = (id = '') => (id) ? `${id}-${CANVAS_ID}` : CANVAS_ID;
21
+
22
+ export const camSnapshot = ({ e = undefined, download = false, camComponentId = '' }) => {
23
+ let status = false, file = undefined, linkElement = undefined, canvasElement = undefined;
24
+ const videoElementId = createVideoElementId(camComponentId);
25
+ const videoElement = document.getElementById(videoElementId);
26
+
27
+ if (videoElement) {
28
+ canvasElement = document.createElement('canvas');
29
+ if (canvasElement) {
30
+ const canvasElementId = createCanvasElementId(camComponentId);
31
+ canvasElement.id = canvasElementId;
32
+ const canvasContext2D = canvasElement.getContext('2d');
33
+ if (canvasContext2D) {
34
+ canvasElement.width = videoElement.offsetWidth;
35
+ canvasElement.height = videoElement.offsetHeight;
36
+ canvasContext2D.drawImage(videoElement, 0, 0, videoElement.offsetWidth, videoElement.offsetHeight);
37
+
38
+ linkElement = document.createElement('a');
39
+ linkElement.download = `Capture_${moment(new Date()).format('DD-MM-YYYY_HH:mm:ss')}.png`;
40
+ const dataUrl = canvasElement.toDataURL('image/png');
41
+ linkElement.href = dataUrl;
42
+
43
+ const blob = dataUrlToBlob(dataUrl);
44
+ if (blob) file = new File([blob], linkElement.download, { type: blob.type });
45
+ }
46
+ }
47
+ }
48
+ (linkElement && file) && (status = true);
49
+ (linkElement && download) && linkElement.click();
50
+ return { e, status, file, link: linkElement, canvas: canvasElement };
51
+ };
52
+
53
+
54
+ const Cam = ({ id = '', style = {}, onGetStream }) => {
55
+
56
+ const videoRef = useRef(null);
57
+ const streamRef = useRef(null);
58
+ const getStreamIntervalIdRef = useRef(null);
59
+ const videoElementId = createVideoElementId(id);
60
+
61
+ const getStream = useCallback(async () => {
62
+ let stream = null;
63
+
64
+ try {
65
+ stream = await navigator.mediaDevices.getUserMedia(VIDEO_CONSTRAINTS);
66
+ stream.getTracks().forEach((track) => {
67
+ if (track.kind === 'video') track.enabled = true;
68
+ });
69
+ } catch (error) {
70
+ console.error(error);
71
+ }
72
+
73
+ if ((stream && !streamRef.current) || (!stream && streamRef.current)) {
74
+ videoRef.current.srcObject = stream;
75
+ stopVideo(streamRef.current);
76
+ streamRef.current = stream;
77
+ (typeof onGetStream === 'function') && onGetStream({ stream });
78
+ } else if (stream) stopVideo(stream);
79
+ }, [onGetStream]);
80
+
81
+ const stopVideo = (stream) => (stream) && stream.getTracks().forEach((track) => {
82
+ track?.stop();
83
+ track.enabled = false;
84
+ });
85
+
86
+ useEffect(() => {
87
+ getStream();
88
+ getStreamIntervalIdRef.current = setInterval(() => getStream(), GET_STREAM_INTERVAL_TIMEOUT);
89
+ return () => {
90
+ clearInterval(getStreamIntervalIdRef.current);
91
+ stopVideo(streamRef.current);
92
+ };
93
+ }, [getStream]);
94
+
95
+
96
+ return <div style={style} className='cam-div'>
97
+ <video id={videoElementId} ref={videoRef} autoPlay />
98
+ </div>;
99
+ };
100
+
101
+
102
+ export default Cam;
@@ -0,0 +1,8 @@
1
+ .cam-div {
2
+ display: grid;
3
+ }
4
+
5
+ video {
6
+ width: 100%;
7
+ background-color: #000;
8
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './Cam';
2
+ export * from './Cam';
@@ -0,0 +1 @@
1
+ export { default } from './Cam';
@@ -66,6 +66,6 @@ export interface CarouselProps {
66
66
  }
67
67
 
68
68
 
69
- declare function Carousel(props: CarouselProps) : JSX.Element
69
+ declare function Carousel(props: CarouselProps): JSX.Element
70
70
 
71
71
  export default Carousel;
@@ -166,4 +166,7 @@ export { default as Zoom } from './Zoom';
166
166
  export * from './Zoom';
167
167
 
168
168
  export { default as Carousel } from './Carousel';
169
- export * from './Carousel';
169
+ export * from './Carousel';
170
+
171
+ export { default as Cam } from './Cam';
172
+ export * from './Cam';
@@ -164,4 +164,7 @@ export { default as Zoom } from './Zoom';
164
164
  export * from './Zoom';
165
165
 
166
166
  export { default as Carousel } from './Carousel';
167
- export * from './Carousel';
167
+ export * from './Carousel';
168
+
169
+ export { default as Cam } from './Cam';
170
+ export * from './Cam';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.219",
3
+ "version": "1.2.221",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",