argous 1.2.232 → 1.2.234

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.
@@ -266,9 +266,13 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
266
266
  react_1.useEffect(function () {
267
267
  if (method || field || externalCtrlPgn)
268
268
  return;
269
- if (lodash_1.isArray(lista) && lista.length > 0 && page === Math.ceil(method ? ctrlPgn.recordCount : lista.length / parseInt(rowsPerPage, 10)))
269
+ if (lodash_1.isArray(lista) && (lista.length > 0) && (page === Math.ceil((method) ? ctrlPgn.recordCount : (lista.length / parseInt(rowsPerPage, 10)))))
270
270
  dispatch({ type: 'decremmentPage' });
271
- }, [page, method, lista.length, rowsPerPage, ctrlPgn.recordCount, lista, field, externalCtrlPgn]);
271
+ if (lodash_1.isArray(lista) && (lista.length > 0) && ((page + 1) > Math.ceil((method) ? ctrlPgn.recordCount : (lista.length / parseInt(rowsPerPage, 10))))) {
272
+ dispatch({ type: 'setPage', value: 0 });
273
+ setCtrlPgn(function (currentState) { return (__assign(__assign({}, currentState), { pgAtl: 1 })); });
274
+ }
275
+ }, [page, lista.length, rowsPerPage, ctrlPgn.recordCount, lista, method, field, externalCtrlPgn, dispatch]);
272
276
  react_1.useEffect(function () { return dispatch({ type: 'setSelected', value: [] }); }, [lista]);
273
277
  react_1.useEffect(function () {
274
278
  if (onSelect)
@@ -130,7 +130,7 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
130
130
  react_1.default.createElement(core_1.CircularProgress, { disableShrink: true })))) : dadosMostrados.length ? dadosMostrados.map(function (linha, i) {
131
131
  var isItemSelected = isSelected(linha[indexToSelect]);
132
132
  var isItemOpen = i === open;
133
- var fullyEmpty = !linha.some(function (value) { return !!value; });
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
136
  var _a;
@@ -142,8 +142,8 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
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
- _a[classes.ghost] = fullyEmpty,
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: (fullyEmpty) ? undefined : (onClick) ? function (e) { return onClick(e, linha, line(linha), i); } : (children) ? function () { return handleOpenClose(i); } : undefined, onDoubleClick: (fullyEmpty) ? undefined : (onDoubleClick) ? function (e) { return onDoubleClick(e, linha, line(linha), i); } : undefined, innerRef: draggableRef }),
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 }),
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 },
@@ -153,7 +153,7 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
153
153
  e.stopPropagation();
154
154
  handleClick(linha[indexToSelect]);
155
155
  }, checked: isItemSelected })),
156
- lodash_1.isArray(line(linha)) && line(linha).map(function (coluna, j) { return ((fullyEmpty) ? (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)))); }))),
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)))); }))),
157
157
  children && (react_1.default.createElement(core_1.TableRow, { className: classes.group },
158
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' },
159
159
  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))))));
@@ -275,8 +275,12 @@ const ArgousComplexTable = forwardRef(({
275
275
 
276
276
  useEffect(() => {
277
277
  if (method || field || externalCtrlPgn) return;
278
- if (isArray(lista) && lista.length > 0 && page === Math.ceil(method ? ctrlPgn.recordCount : lista.length / parseInt(rowsPerPage, 10))) dispatch({ type: 'decremmentPage' });
279
- }, [page, method, lista.length, rowsPerPage, ctrlPgn.recordCount, lista, field, externalCtrlPgn]);
278
+ if (isArray(lista) && (lista.length > 0) && (page === Math.ceil((method) ? ctrlPgn.recordCount : (lista.length / parseInt(rowsPerPage, 10))))) dispatch({ type: 'decremmentPage' });
279
+ if (isArray(lista) && (lista.length > 0) && ((page + 1) > Math.ceil((method) ? ctrlPgn.recordCount : (lista.length / parseInt(rowsPerPage, 10))))) {
280
+ dispatch({ type: 'setPage', value: 0 });
281
+ setCtrlPgn((currentState) => ({ ...currentState, pgAtl: 1 }));
282
+ }
283
+ }, [page, lista.length, rowsPerPage, ctrlPgn.recordCount, lista, method, field, externalCtrlPgn, dispatch]);
280
284
 
281
285
  useEffect(() => dispatch({ type: 'setSelected', value: [] }), [lista]);
282
286
 
@@ -111,7 +111,7 @@ const ArgousComplexTableBody = memo(({
111
111
 
112
112
  const isItemSelected = isSelected(linha[indexToSelect]);
113
113
  const isItemOpen = i === open;
114
- const fullyEmpty = !linha.some((value) => !!value);
114
+ const ghostRow = (isArray(linha)) ? !linha.some((value) => !!value) : false;
115
115
  const { title, ...rowProperties } = rowProps({ index: i, linhaOriginal: linha, linhaFormatada: line(linha), itensSelecionados: selected }) || {};
116
116
 
117
117
 
@@ -127,7 +127,7 @@ const ArgousComplexTableBody = memo(({
127
127
  {
128
128
  [classes.hover]: isItemSelected,
129
129
  [classes.open]: (isItemOpen && !!children),
130
- [classes.ghost]: fullyEmpty
130
+ [classes.ghost]: ghostRow
131
131
  },
132
132
  lineClass(line(linha), linha, i),
133
133
  rowProperties.className
@@ -138,8 +138,8 @@ const ArgousComplexTableBody = memo(({
138
138
  tabIndex={-1}
139
139
  selected={isItemSelected}
140
140
  style={lineStyle ? lineStyle(linha, line(linha), i) : undefined}
141
- onClick={(fullyEmpty) ? undefined : (onClick) ? e => onClick(e, linha, line(linha), i) : (children) ? () => handleOpenClose(i) : undefined}
142
- onDoubleClick={(fullyEmpty) ? undefined : (onDoubleClick) ? e => onDoubleClick(e, linha, line(linha), i) : undefined}
141
+ onClick={(ghostRow) ? undefined : (onClick) ? e => onClick(e, linha, line(linha), i) : (children) ? () => handleOpenClose(i) : undefined}
142
+ onDoubleClick={(ghostRow) ? undefined : (onDoubleClick) ? e => onDoubleClick(e, linha, line(linha), i) : undefined}
143
143
  innerRef={draggableRef}
144
144
  >
145
145
  {enableDrag && <TableCell padding='checkbox'>
@@ -156,7 +156,7 @@ const ArgousComplexTableBody = memo(({
156
156
  }} checked={isItemSelected} />
157
157
  </TableCell>}
158
158
  {isArray(line(linha)) && line(linha).map((coluna, j) => (
159
- (fullyEmpty) ? (
159
+ (ghostRow) ? (
160
160
  <TableCell
161
161
  key={j}
162
162
  {...columnProps(j, coluna, linha, line(linha))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.232",
3
+ "version": "1.2.234",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",