@economic/taco 1.21.7 → 1.21.8

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.
@@ -11541,6 +11541,7 @@ const Cell = function Cell(props) {
11541
11541
  onSave: meta.editMode.onSave,
11542
11542
  rowIndex: rowIndex,
11543
11543
  table: table,
11544
+ tableRef: tableRef,
11544
11545
  ref: controlRef,
11545
11546
  rowValues: rows[rowIndex].original,
11546
11547
  rowsLength: rows.length
@@ -11561,7 +11562,7 @@ const Cell = function Cell(props) {
11561
11562
  }, reactTable$1.flexRender(cell.column.columnDef.cell, cell.getContext())));
11562
11563
  };
11563
11564
  const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__default.forwardRef((props, ref) => {
11564
- var _cell$column$columnDe4, _cell$column$columnDe5, _cellRef$current, _cellRef$current$pare, _rowMoveReason$cellId;
11565
+ var _cell$column$columnDe4, _cell$column$columnDe5, _cellRef$current2, _cellRef$current2$par, _rowMoveReason$cellId;
11565
11566
  const {
11566
11567
  cell,
11567
11568
  cellRef,
@@ -11571,7 +11572,8 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11571
11572
  onSave: handleSave,
11572
11573
  rowIndex,
11573
11574
  rowValues,
11574
- table
11575
+ table,
11576
+ tableRef
11575
11577
  } = props;
11576
11578
  const {
11577
11579
  editMode: {
@@ -11653,14 +11655,32 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11653
11655
  (_controlRef$current = controlRef.current) === null || _controlRef$current === void 0 ? void 0 : (_controlRef$current$f = _controlRef$current.focus) === null || _controlRef$current$f === void 0 ? void 0 : _controlRef$current$f.call(_controlRef$current);
11654
11656
  }
11655
11657
  }, [isEditingThisCell, controlRef.current]);
11656
- // make sure the cell becomes active if the field is focused
11658
+ const pinnedColumnsWidth = React__default.useMemo(() => {
11659
+ const pinnedColumns = table.getState().columnPinning.left;
11660
+ if (Array.isArray(pinnedColumns) && pinnedColumns.length > 0) {
11661
+ const lastPinnedColumn = pinnedColumns[pinnedColumns.length - 1];
11662
+ const lastPinnedColumnOffset = meta.columnOffsets[lastPinnedColumn];
11663
+ if (lastPinnedColumnOffset !== undefined) {
11664
+ var _table$getState$colum;
11665
+ return lastPinnedColumnOffset + ((_table$getState$colum = table.getState().columnSizing[lastPinnedColumn]) !== null && _table$getState$colum !== void 0 ? _table$getState$colum : 0);
11666
+ }
11667
+ }
11668
+ return 0;
11669
+ }, [meta.columnOffsets, table.getState().columnSizing]);
11657
11670
  const handleFocus = event => {
11658
- var _event$target;
11671
+ var _event$target, _cellRef$current;
11659
11672
  meta.editMode.setColumn(columnIndex);
11660
11673
  if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
11661
11674
  var _event$target2;
11662
11675
  (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.select();
11663
11676
  }
11677
+ // ensure the field is always visible (e.g. not hidden behind the pinned columns)
11678
+ const rect = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.getBoundingClientRect();
11679
+ const leftOffset = meta.columnOffsets[cellId];
11680
+ if (rect && leftOffset && rect.left < pinnedColumnsWidth) {
11681
+ var _tableRef$current4;
11682
+ (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : _tableRef$current4.scrollTo(leftOffset - pinnedColumnsWidth, tableRef.current.scrollTop);
11683
+ }
11664
11684
  };
11665
11685
  React__default.useEffect(() => {
11666
11686
  if (hasChanged(initialValue.current, state)) {
@@ -11716,7 +11736,7 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11716
11736
  'data-inline-editing-component': 'true'
11717
11737
  };
11718
11738
  const className = cn(getCellAlignmentClasses((_cell$column$columnDe5 = cell.column.columnDef.meta) === null || _cell$column$columnDe5 === void 0 ? void 0 : _cell$column$columnDe5.align));
11719
- const indicatorMountNode = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : (_cellRef$current$pare = _cellRef$current.parentElement) === null || _cellRef$current$pare === void 0 ? void 0 : _cellRef$current$pare.querySelector(':first-child');
11739
+ const indicatorMountNode = (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.querySelector(':first-child');
11720
11740
  let controlComponent;
11721
11741
  if (cellControl) {
11722
11742
  if (typeof cellControl === 'function') {
@@ -12056,44 +12076,24 @@ const getSortingFn = dataType => {
12056
12076
  return 'auto';
12057
12077
  };
12058
12078
 
12059
- const isResizingPinnedColumn = (columnId, table) => {
12060
- var _table$getState$colum, _table$getState$colum2;
12061
- return !!columnId && ((_table$getState$colum = table.getState().columnPinning.left) === null || _table$getState$colum === void 0 ? void 0 : _table$getState$colum.includes((_table$getState$colum2 = table.getState().columnSizingInfo) === null || _table$getState$colum2 === void 0 ? void 0 : _table$getState$colum2.isResizingColumn));
12062
- };
12063
- const getOffsetsFromSize = (pinning, visibility, sizing) => {
12064
- const pinned = pinning.left.filter(c => visibility[c] !== false);
12065
- const offsets = {};
12066
- let leftOffset = 0;
12067
- for (const k of pinned) {
12068
- if (!Number.isInteger(sizing[k])) {
12069
- break;
12070
- }
12071
- offsets[k] = leftOffset;
12072
- leftOffset += sizing[k];
12073
- }
12074
- return offsets;
12075
- };
12076
12079
  // pinned columns have position sticky, and because we support more than one of them
12077
12080
  // we must set a 'left' css value. this hook listens to changes on state that will
12078
12081
  // affect the left offset (resize, visibility, pinning) and updates offsets based on width
12079
12082
  const useColumnOffsetStateListener = (table, setColumnOffsets) => {
12080
12083
  const {
12081
- columnPinning,
12082
- columnSizing,
12084
+ columnOrder,
12083
12085
  columnSizingInfo,
12084
12086
  columnVisibility
12085
12087
  } = table.getState();
12086
12088
  React__default.useEffect(() => {
12087
- if (isResizingPinnedColumn(columnSizingInfo.isResizingColumn, table)) {
12088
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12089
- }
12090
- }, [columnSizingInfo]);
12091
- React__default.useEffect(() => {
12092
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12093
- }, [columnVisibility]);
12094
- React__default.useEffect(() => {
12095
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12096
- }, [columnPinning.left]);
12089
+ const offsets = {};
12090
+ // store left offsets for each visible column
12091
+ table.getVisibleLeafColumns().reduce((offset, column) => {
12092
+ offsets[column.id] = offset;
12093
+ return offset + column.getSize();
12094
+ }, 0);
12095
+ setColumnOffsets(offsets);
12096
+ }, [columnOrder, columnSizingInfo, columnVisibility]);
12097
12097
  };
12098
12098
 
12099
12099
  const useRowSelectionListener = (table, onRowSelect) => {
@@ -12257,7 +12257,7 @@ function useTable$1(children, props, ref) {
12257
12257
  const activeRow = useActiveRow(defaultActiveRowIndex);
12258
12258
  const [shouldPauseHoverState, setShouldPauseHoverState] = useShouldPauseHoverState();
12259
12259
  const editMode = useEditMode(onSave);
12260
- const [columnOffsets, setColumnOffsets] = React__default.useState(getOffsetsFromSize(initialState.columnPinning, initialState.columnVisibility, initialState.columnSizing));
12260
+ const [columnOffsets, setColumnOffsets] = React__default.useState({});
12261
12261
  const [rowDensity, setRowDensity] = React__default.useState((_settings$rowDensity = settings === null || settings === void 0 ? void 0 : settings.rowDensity) !== null && _settings$rowDensity !== void 0 ? _settings$rowDensity : 'normal');
12262
12262
  const [dragging, setDragging] = React__default.useState({});
12263
12263
  const [shouldPauseSortingAndFiltering, setShouldPauseSortingAndFiltering] = React__default.useState(false);
@@ -13390,7 +13390,7 @@ const Search$2 = props => {
13390
13390
  (_props$onSearch3 = props.onSearch) === null || _props$onSearch3 === void 0 ? void 0 : _props$onSearch3.call(props, value);
13391
13391
  };
13392
13392
  useGlobalKeyboardShortcut(event => {
13393
- if (event.key === 'f' && (event.ctrlKey || event.metaKey)) {
13393
+ if (event.key === 'f' && (event.ctrlKey || event.metaKey) && !event.shiftKey) {
13394
13394
  if (document.activeElement !== ref.current) {
13395
13395
  var _ref$current;
13396
13396
  event.preventDefault();