frontend-plus-react 0.1.10 → 0.1.11

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.
package/dist/index.js CHANGED
@@ -1535,11 +1535,11 @@ function InputRenderer({
1535
1535
  localCellChanges,
1536
1536
  initialRowId
1537
1537
  ]);
1538
- const handleKeyDown = useCallback3((event) => {
1539
- if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"].includes(event.key)) {
1540
- handleCommit(editingValue, true, true);
1538
+ const handleKeyDown = useCallback3(async (event) => {
1539
+ if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", "F4"].includes(event.key)) {
1540
+ await handleCommit(editingValue, true, true);
1541
1541
  if (onKeyPress) {
1542
- onKeyPress(rowIdx, column.key, event);
1542
+ onKeyPress(rowIdx, column.key, event, handleCommit);
1543
1543
  }
1544
1544
  }
1545
1545
  }, [handleCommit, editingValue, column.key, rowIdx, onKeyPress]);
@@ -1608,7 +1608,7 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
1608
1608
  tableDefinition,
1609
1609
  setCellFeedback,
1610
1610
  cellFeedback,
1611
- onKeyPress: (rowIndex, columnKey, event) => handleKeyPressInEditor(rowIndex, columnKey, event, allColumns),
1611
+ onKeyPress: (rowIndex, columnKey, event, handleCommit) => handleKeyPressInEditor(rowIndex, columnKey, event, allColumns, handleCommit),
1612
1612
  setTableData,
1613
1613
  setLocalCellChanges,
1614
1614
  localCellChanges,
@@ -1719,11 +1719,7 @@ var GenericDataGrid = ({
1719
1719
  }
1720
1720
  };
1721
1721
  fetchDataAndDefinition();
1722
- }, [
1723
- tableName,
1724
- /*fixedFields,*/
1725
- showError
1726
- ]);
1722
+ }, [tableName, fixedFields, showError]);
1727
1723
  useEffect(() => {
1728
1724
  if (cellFeedback) {
1729
1725
  if (feedbackTimerRef.current) {
@@ -1881,19 +1877,20 @@ var GenericDataGrid = ({
1881
1877
  }
1882
1878
  return rows;
1883
1879
  }, [tableData, filters, isFilterRowVisible]);
1884
- const handleKeyPressInEditor = useCallback4((rowIndex, columnKey, event, currentColumns) => {
1880
+ const handleKeyPressInEditor = useCallback4((rowIndex, columnKey, event, currentColumns, handleCommit) => {
1885
1881
  if (dataGridRef.current && tableDefinition) {
1886
1882
  const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
1887
1883
  const editableColumns = currentColumns.filter((col) => {
1888
1884
  const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
1889
1885
  return col.key !== "actionsColumn" && col.customType != "detail" && (fieldDefinition?.editable !== false && !fieldDefinition?.clientSide);
1890
1886
  });
1891
- const { key, currentTarget } = event;
1892
- const input = currentTarget;
1887
+ const { key, target } = event;
1888
+ const input = target;
1893
1889
  if (currentColumnIndex !== -1 && editableColumns.length > 0) {
1894
1890
  const editableColumnKeys = editableColumns.map((col) => col.key);
1895
1891
  let currentEditableColumnIndex = editableColumnKeys.indexOf(columnKey);
1896
- const calcularColumnaSiguienteYHacerFoco = () => {
1892
+ const hacerFoco = ({ rowIdx, idx }) => setTimeout(() => dataGridRef.current?.selectCell({ rowIdx, idx }, { enableEditor: true, shouldFocusCell: true }), 10);
1893
+ const calcularColumnaSiguiente = () => {
1897
1894
  let nextEditableColumnIndex = currentEditableColumnIndex + 1;
1898
1895
  let nextRowIndex = rowIndex;
1899
1896
  if (nextEditableColumnIndex >= editableColumns.length) {
@@ -1908,9 +1905,9 @@ var GenericDataGrid = ({
1908
1905
  }
1909
1906
  const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
1910
1907
  const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
1911
- dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
1908
+ return { rowIdx: nextRowIndex, idx: nextColumnIndex };
1912
1909
  };
1913
- const calcularColumnaAnteriorYHacerFoco = () => {
1910
+ const calcularColumnaAnterior = () => {
1914
1911
  let nextEditableColumnIndex = currentEditableColumnIndex - 1;
1915
1912
  let nextRowIndex = rowIndex;
1916
1913
  if (nextEditableColumnIndex <= 0) {
@@ -1918,57 +1915,65 @@ var GenericDataGrid = ({
1918
1915
  }
1919
1916
  const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
1920
1917
  const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
1921
- dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
1918
+ return { rowIdx: nextRowIndex, idx: nextColumnIndex };
1922
1919
  };
1923
- const calcularFilaSiguienteYHacerFoco = () => {
1920
+ const calcularFilaSiguiente = () => {
1924
1921
  let nextRowIndex = rowIndex;
1925
1922
  nextRowIndex++;
1926
1923
  while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
1927
1924
  nextRowIndex++;
1928
1925
  }
1929
1926
  if (nextRowIndex >= filteredRows.length) {
1930
- return;
1927
+ return { rowIdx: rowIndex, idx: currentColumnIndex };
1931
1928
  }
1932
- dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: currentColumnIndex }, { enableEditor: true, shouldFocusCell: true });
1929
+ return { rowIdx: nextRowIndex, idx: currentColumnIndex };
1933
1930
  };
1934
- const calcularFilaAnteriorYHacerFoco = () => {
1931
+ const calcularFilaAnterior = () => {
1935
1932
  let nextRowIndex = rowIndex;
1936
1933
  nextRowIndex--;
1937
1934
  while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
1938
1935
  nextRowIndex--;
1939
1936
  }
1940
1937
  if (nextRowIndex < 0) {
1941
- return;
1938
+ return { rowIdx: rowIndex, idx: currentColumnIndex };
1942
1939
  }
1943
- dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: currentColumnIndex }, { enableEditor: true, shouldFocusCell: true });
1940
+ return { rowIdx: nextRowIndex, idx: currentColumnIndex };
1944
1941
  };
1945
1942
  if (currentEditableColumnIndex !== -1) {
1946
1943
  switch (true) {
1947
1944
  case ["Enter", "Tab"].includes(key): {
1948
- calcularColumnaSiguienteYHacerFoco();
1945
+ hacerFoco(calcularColumnaSiguiente());
1949
1946
  break;
1950
1947
  }
1951
1948
  case key == "ArrowRight": {
1952
1949
  const cursorPosition = input.selectionStart;
1953
1950
  const inputValueLength = input.value.length;
1954
1951
  if (cursorPosition === inputValueLength) {
1955
- calcularColumnaSiguienteYHacerFoco();
1952
+ hacerFoco(calcularColumnaSiguiente());
1956
1953
  }
1957
1954
  break;
1958
1955
  }
1959
1956
  case key == "ArrowLeft": {
1960
1957
  const cursorPosition = input.selectionStart;
1961
1958
  if (cursorPosition === 0) {
1962
- calcularColumnaAnteriorYHacerFoco();
1959
+ hacerFoco(calcularColumnaAnterior());
1963
1960
  }
1964
1961
  break;
1965
1962
  }
1966
1963
  case key == "ArrowUp": {
1967
- calcularFilaAnteriorYHacerFoco();
1964
+ hacerFoco(calcularFilaAnterior());
1968
1965
  break;
1969
1966
  }
1970
1967
  case key == "ArrowDown": {
1971
- calcularFilaSiguienteYHacerFoco();
1968
+ hacerFoco(calcularFilaSiguiente());
1969
+ break;
1970
+ }
1971
+ case key == "F4": {
1972
+ const { rowIdx, idx } = calcularFilaSiguiente();
1973
+ const previousRow = tableData[rowIndex - 1];
1974
+ if (previousRow && !previousRow[DETAIL_ROW_INDICATOR]) {
1975
+ handleCommit(previousRow[columnKey], true, true).then(() => hacerFoco({ rowIdx, idx }));
1976
+ }
1972
1977
  break;
1973
1978
  }
1974
1979
  default: