argous 1.2.239 → 1.2.241

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.
@@ -199,10 +199,12 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
199
199
  return newArray;
200
200
  }, [head, rowsPerPage]);
201
201
  var dadosMostrados = react_1.useMemo(function () {
202
- if (method || externalCtrlPgn)
203
- return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
204
- return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
205
- }, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados, usePagination, fillListToKeepHeight]);
202
+ if (page > -1) {
203
+ if (method || externalCtrlPgn)
204
+ return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
205
+ return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
206
+ }
207
+ }, [page, lista, dadosNaoCortados, usePagination, method, externalCtrlPgn, cortaDados, fillListToKeepHeight]);
206
208
  react_1.useEffect(function () {
207
209
  dispatch({ type: 'mount', value: savedState.current });
208
210
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -230,9 +232,9 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
230
232
  }, [ctrlPgn.recordCount]);
231
233
  var buscaMetodo = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
232
234
  var res;
233
- var _a, _b;
234
- return __generator(this, function (_c) {
235
- switch (_c.label) {
235
+ var _a, _b, _c;
236
+ return __generator(this, function (_d) {
237
+ switch (_d.label) {
236
238
  case 0:
237
239
  if (!method || !allowMethodRequest)
238
240
  return [2 /*return*/];
@@ -244,10 +246,12 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
244
246
  indOrdem: orderBy >= 0 ? orderBy : undefined
245
247
  } }, methodPrms), code, handleMethodError, token)];
246
248
  case 1:
247
- res = _c.sent();
249
+ res = _d.sent();
248
250
  onMethodResponse && onMethodResponse(res);
249
251
  if (res.status) {
250
- 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)) }));
252
+ if ((_a = res === null || res === void 0 ? void 0 : res.ctrlPgn) === null || _a === void 0 ? void 0 : _a.pgAtl)
253
+ dispatch({ type: 'setPage', value: (res.ctrlPgn.pgAtl - 1) });
254
+ setCtrlPgn(__assign(__assign({}, res.ctrlPgn), { recordCount: (((_b = res.ctrlPgn) === null || _b === void 0 ? void 0 : _b.qtPaginas) * ((_c = res.ctrlPgn) === null || _c === void 0 ? void 0 : _c.qtRegs)) }));
251
255
  setLista(res[methodResultList] || []);
252
256
  }
253
257
  dispatch({ type: 'setLoading', value: false });
@@ -320,6 +324,8 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
320
324
  var fullCtrlPgn = getFullCtrlPgn(true);
321
325
  var fullExternalCtrlPgn = getFullCtrlPgn();
322
326
  if (!lodash_1.isEqual(fullExternalCtrlPgn, fullCtrlPgn)) {
327
+ if (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.pgAtl)
328
+ dispatch({ type: 'setPage', value: (externalCtrlPgn.pgAtl - 1) });
323
329
  setCtrlPgn(__assign(__assign({}, fullExternalCtrlPgn), { recordCount: ((externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtPaginas) * (externalCtrlPgn === null || externalCtrlPgn === void 0 ? void 0 : externalCtrlPgn.qtRegs)) }));
324
330
  setBounced(true);
325
331
  }
@@ -133,29 +133,28 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
133
133
  var ghostRow = (lodash_1.isArray(linha)) ? !linha.some(function (value) { return !!value; }) : false;
134
134
  var _a = rowProps({ index: i, linhaOriginal: linha, linhaFormatada: line(linha), itensSelecionados: selected }) || {}, title = _a.title, rowProperties = __rest(_a, ["title"]);
135
135
  return react_1.default.createElement(dist_1.Draggable, { key: customKey ? lista[i][customKey] : i, render: function (draggableRef) {
136
- var _a;
137
- var _b;
136
+ var _a, _b;
137
+ var _c;
138
138
  return (
139
139
  //TODO criar proprio draggable pois esse remove classes do filho
140
140
  react_1.default.createElement(react_1.Fragment, null,
141
- react_1.default.createElement(exports.CustomTooltip, { title: lineTitle || title },
141
+ react_1.default.createElement(exports.CustomTooltip, { title: (ghostRow) ? '' : (lineTitle || title) },
142
142
  react_1.default.createElement(core_1.TableRow, __assign({ component: dist_1.Draggable }, rowProperties, { className: clsx_1.default((_a = {},
143
143
  _a[classes.hover] = isItemSelected,
144
144
  _a[classes.open] = (isItemOpen && !!children),
145
145
  _a[classes.ghost] = ghostRow,
146
- _a), lineClass(line(linha), linha, i), rowProperties.className), hover: true, role: 'checkbox', tabIndex: -1, selected: isItemSelected, style: lineStyle ? lineStyle(linha, line(linha), i) : undefined, onClick: (ghostRow) ? undefined : (onClick) ? function (e) { return onClick(e, linha, line(linha), i); } : (children) ? function () { return handleOpenClose(i); } : undefined, onDoubleClick: (ghostRow) ? undefined : (onDoubleClick) ? function (e) { return onDoubleClick(e, linha, line(linha), i); } : undefined, innerRef: draggableRef }),
146
+ _a), (ghostRow) ? '' : lineClass(line(linha), linha, i), rowProperties.className), hover: true, role: 'checkbox', tabIndex: -1, selected: isItemSelected, style: (lineStyle && !ghostRow) ? lineStyle(linha, line(linha), i) : undefined, onClick: (ghostRow) ? undefined : (onClick) ? function (e) { return onClick(e, linha, line(linha), i); } : (children) ? function () { return handleOpenClose(i); } : undefined, onDoubleClick: (ghostRow) ? undefined : (onDoubleClick) ? function (e) { return onDoubleClick(e, linha, line(linha), i); } : undefined, innerRef: draggableRef }),
147
147
  enableDrag && react_1.default.createElement(core_1.TableCell, { padding: 'checkbox' },
148
148
  react_1.default.createElement(core_1.Tooltip, { title: 'Arrastar' },
149
149
  react_1.default.createElement(core_1.IconButton, { size: 'small', className: classes.dragHandle },
150
150
  react_1.default.createElement(md_1.MdDragHandle, null)))),
151
- enableCheck && react_1.default.createElement(core_1.TableCell, { padding: 'checkbox' },
152
- react_1.default.createElement(core_1.Checkbox, { disabled: disableCheckIf && disableCheckIf(linha, line(linha), i), onClick: function (e) {
153
- e.stopPropagation();
154
- handleClick(linha[indexToSelect]);
155
- }, checked: isItemSelected })),
156
- lodash_1.isArray(line(linha)) && line(linha).map(function (coluna, j) { return ((ghostRow) ? (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined, className: clsx_1.default(classes.tableCell, classes.ghost) }), "\u00A0")) : (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined, className: classes.tableCell }), getCellContent(coluna, dadosMostrados[i], j, i)))); }))),
151
+ (enableCheck) && (react_1.default.createElement(core_1.TableCell, { padding: 'checkbox', className: clsx_1.default((_b = {}, _b[classes.ghost] = ghostRow, _b)) }, (!ghostRow) && (react_1.default.createElement(core_1.Checkbox, { checked: isItemSelected, disabled: (disableCheckIf) && disableCheckIf(linha, line(linha), i), onClick: function (event) {
152
+ event.stopPropagation();
153
+ handleClick(linha[indexToSelect]);
154
+ } })))),
155
+ lodash_1.isArray(line(linha)) && line(linha).map(function (coluna, j) { return ((ghostRow) ? (react_1.default.createElement(core_1.TableCell, { key: j, className: clsx_1.default(classes.tableCell, classes.ghost) }, "\u00A0")) : (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined, className: classes.tableCell }), getCellContent(coluna, dadosMostrados[i], j, i)))); }))),
157
156
  children && (react_1.default.createElement(core_1.TableRow, { className: classes.group },
158
- react_1.default.createElement(core_1.TableCell, { colSpan: (dadosMostrados === null || dadosMostrados === void 0 ? void 0 : dadosMostrados.length) && ((_b = line(dadosMostrados[0])) === null || _b === void 0 ? void 0 : _b.length) + (enableCheck ? 1 : 0) + (enableDrag ? 1 : 0), style: { padding: open === i ? 8 : 0 }, className: 'argous-complex-table-group-cell' },
157
+ react_1.default.createElement(core_1.TableCell, { colSpan: (dadosMostrados === null || dadosMostrados === void 0 ? void 0 : dadosMostrados.length) && ((_c = line(dadosMostrados[0])) === null || _c === void 0 ? void 0 : _c.length) + (enableCheck ? 1 : 0) + (enableDrag ? 1 : 0), style: { padding: open === i ? 8 : 0 }, className: 'argous-complex-table-group-cell' },
159
158
  react_1.default.createElement(core_1.Collapse, { in: open === i, mountOnEnter: true, unmountOnExit: true }, typeof children === 'function' ? children({ linha: line(linha), linhaOriginal: linha, index: i }) : children))))));
160
159
  } });
161
160
  }) : react_1.default.createElement(core_1.TableRow, null,
@@ -216,9 +216,11 @@ const ArgousComplexTable = forwardRef(({
216
216
  }, [head, rowsPerPage]);
217
217
 
218
218
  const dadosMostrados = useMemo(() => {
219
- if (method || externalCtrlPgn) return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
220
- return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
221
- }, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados, usePagination, fillListToKeepHeight]);
219
+ if (page > -1) {
220
+ if (method || externalCtrlPgn) return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
221
+ return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
222
+ }
223
+ }, [page, lista, dadosNaoCortados, usePagination, method, externalCtrlPgn, cortaDados, fillListToKeepHeight]);
222
224
 
223
225
  useEffect(() => {
224
226
  dispatch({ type: 'mount', value: savedState.current });
@@ -256,6 +258,7 @@ const ArgousComplexTable = forwardRef(({
256
258
  }, code, handleMethodError, token);
257
259
  onMethodResponse && onMethodResponse(res);
258
260
  if (res.status) {
261
+ if (res?.ctrlPgn?.pgAtl) dispatch({ type: 'setPage', value: (res.ctrlPgn.pgAtl - 1) });
259
262
  setCtrlPgn({ ...res.ctrlPgn, recordCount: (res.ctrlPgn?.qtPaginas * res.ctrlPgn?.qtRegs) });
260
263
  setLista(res[methodResultList] || []);
261
264
  }
@@ -339,6 +342,7 @@ const ArgousComplexTable = forwardRef(({
339
342
  const fullCtrlPgn = getFullCtrlPgn(true);
340
343
  const fullExternalCtrlPgn = getFullCtrlPgn();
341
344
  if (!isEqual(fullExternalCtrlPgn, fullCtrlPgn)) {
345
+ if (externalCtrlPgn?.pgAtl) dispatch({ type: 'setPage', value: (externalCtrlPgn.pgAtl - 1) });
342
346
  setCtrlPgn({ ...fullExternalCtrlPgn, recordCount: (externalCtrlPgn?.qtPaginas * externalCtrlPgn?.qtRegs) });
343
347
  setBounced(true);
344
348
  }
@@ -118,7 +118,7 @@ const ArgousComplexTableBody = memo(({
118
118
  return <Draggable key={customKey ? lista[i][customKey] : i} render={draggableRef => (
119
119
  //TODO criar proprio draggable pois esse remove classes do filho
120
120
  <Fragment>
121
- <CustomTooltip title={lineTitle || title}>
121
+ <CustomTooltip title={(ghostRow) ? '' : (lineTitle || title)}>
122
122
  <TableRow
123
123
  component={Draggable}
124
124
  {...rowProperties}
@@ -129,7 +129,7 @@ const ArgousComplexTableBody = memo(({
129
129
  [classes.open]: (isItemOpen && !!children),
130
130
  [classes.ghost]: ghostRow
131
131
  },
132
- lineClass(line(linha), linha, i),
132
+ (ghostRow) ? '' : lineClass(line(linha), linha, i),
133
133
  rowProperties.className
134
134
  )
135
135
  }
@@ -137,7 +137,7 @@ const ArgousComplexTableBody = memo(({
137
137
  role='checkbox'
138
138
  tabIndex={-1}
139
139
  selected={isItemSelected}
140
- style={lineStyle ? lineStyle(linha, line(linha), i) : undefined}
140
+ style={(lineStyle && !ghostRow) ? lineStyle(linha, line(linha), i) : undefined}
141
141
  onClick={(ghostRow) ? undefined : (onClick) ? e => onClick(e, linha, line(linha), i) : (children) ? () => handleOpenClose(i) : undefined}
142
142
  onDoubleClick={(ghostRow) ? undefined : (onDoubleClick) ? e => onDoubleClick(e, linha, line(linha), i) : undefined}
143
143
  innerRef={draggableRef}
@@ -149,20 +149,23 @@ const ArgousComplexTableBody = memo(({
149
149
  </IconButton>
150
150
  </Tooltip>
151
151
  </TableCell>}
152
- {enableCheck && <TableCell padding='checkbox'>
153
- <Checkbox disabled={disableCheckIf && disableCheckIf(linha, line(linha), i)} onClick={e => {
154
- e.stopPropagation();
155
- handleClick(linha[indexToSelect]);
156
- }} checked={isItemSelected} />
157
- </TableCell>}
152
+ {(enableCheck) && (
153
+ <TableCell padding='checkbox' className={clsx({ [classes.ghost]: ghostRow })}>
154
+ {(!ghostRow) && (
155
+ <Checkbox
156
+ checked={isItemSelected}
157
+ disabled={(disableCheckIf) && disableCheckIf(linha, line(linha), i)}
158
+ onClick={(event) => {
159
+ event.stopPropagation();
160
+ handleClick(linha[indexToSelect]);
161
+ }}
162
+ />
163
+ )}
164
+ </TableCell>
165
+ )}
158
166
  {isArray(line(linha)) && line(linha).map((coluna, j) => (
159
167
  (ghostRow) ? (
160
- <TableCell
161
- key={j}
162
- {...columnProps(j, coluna, linha, line(linha))}
163
- style={columnStyles ? columnStyles[j] : undefined}
164
- className={clsx(classes.tableCell, classes.ghost)}
165
- >
168
+ <TableCell key={j} className={clsx(classes.tableCell, classes.ghost)}>
166
169
  &nbsp;
167
170
  </TableCell>
168
171
  ) : (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.239",
3
+ "version": "1.2.241",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",