@linzjs/step-ag-grid 17.4.2 → 17.4.4

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.
@@ -1,5 +1,6 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
2
  import { LuiMiniSpinner, LuiIcon, LuiButton, LuiCheckboxInput, LuiButtonGroup } from '@linzjs/lui';
3
+ import { RowHighlightPosition } from 'ag-grid-community';
3
4
  import { AgGridReact } from 'ag-grid-react';
4
5
  import { negate, isEmpty, findIndex, defer as defer$1, debounce as debounce$1, xorBy, last, difference, omit, sortBy, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, compact, filter, sumBy, pull, remove, castArray, flatten } from 'lodash-es';
5
6
  import React, { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
@@ -2523,7 +2524,6 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2523
2524
  },
2524
2525
  checkboxSelection: params.selectable,
2525
2526
  headerComponent: rowSelection === "multiple" ? GridHeaderSelect : null,
2526
- //headerCheckboxSelection:true,
2527
2527
  suppressHeaderKeyboardEvent: (e) => {
2528
2528
  if (!params.selectable)
2529
2529
  return false;
@@ -2739,13 +2739,34 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2739
2739
  }
2740
2740
  }, []);
2741
2741
  const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
2742
- const onRowDragEnd = useCallback((event) => {
2743
- const moved = event.node.data;
2744
- const target = event.overNode?.data;
2745
- moved.id != target.id &&
2746
- event.node.rowIndex != null &&
2747
- params.onRowDragEnd &&
2748
- params.onRowDragEnd(moved, target, event.node.rowIndex);
2742
+ const onRowDragLeave = useCallback((event) => {
2743
+ const clientSideRowModel = event.api.getModel();
2744
+ clientSideRowModel.highlightRowAtPixel(null);
2745
+ }, []);
2746
+ const onRowDragMove = useCallback((event) => {
2747
+ const clientSideRowModel = event.api.getModel();
2748
+ clientSideRowModel.highlightRowAtPixel(event.node, event.y);
2749
+ }, []);
2750
+ const onRowDragEnd = useCallback(async (event) => {
2751
+ const clientSideRowModel = event.api.getModel();
2752
+ if (event.node.rowIndex) {
2753
+ const lastHighlightedRowNode = clientSideRowModel.getLastHighlightedRowNode();
2754
+ const isBelow = lastHighlightedRowNode && lastHighlightedRowNode.highlighted === RowHighlightPosition.Below;
2755
+ let targetIndex = event.overIndex;
2756
+ if (event.node.rowIndex > event.overIndex) {
2757
+ targetIndex += isBelow ? 1 : 0;
2758
+ }
2759
+ else {
2760
+ targetIndex += isBelow ? 0 : -1;
2761
+ }
2762
+ const moved = event.node.data;
2763
+ const target = event.overNode?.data;
2764
+ moved.id != target.id && //moved over a different row
2765
+ moved.rowIndex != targetIndex && //moved to a different index
2766
+ params.onRowDragEnd &&
2767
+ (await params.onRowDragEnd(moved, target, targetIndex));
2768
+ }
2769
+ clientSideRowModel.highlightRowAtPixel(null);
2749
2770
  }, [params]);
2750
2771
  // This is setting a ref in the GridContext so won't be triggering an update loop
2751
2772
  setOnCellEditingComplete(params.onCellEditingComplete);
@@ -2755,7 +2776,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2755
2776
  let rowCount = 0;
2756
2777
  event.api.forEachNode(() => rowCount++);
2757
2778
  return (jsx(GridNoRowsOverlay, { rowCount: rowCount, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText }));
2758
- }, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, rowDragManaged: !!params.onRowDragEnd, suppressMoveWhenRowDragging: true, onRowDragEnd: onRowDragEnd }) })] }));
2779
+ }, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, onRowDragLeave: onRowDragLeave }) })] }));
2759
2780
  };
2760
2781
 
2761
2782
  const GridPopoverContext = createContext({
@@ -3548,7 +3569,7 @@ const GridFormDropDown = (props) => {
3548
3569
  }, [filter, filteredValues, options, props, selectItemHandler, selectedItem, selectedRows, subSelectedValue]);
3549
3570
  const { popoverWrapper } = useGridPopoverHook({
3550
3571
  className: props.className,
3551
- invalid: () => !!(selectedItem && !subComponentIsValid.current),
3572
+ invalid: () => !options || !!(selectedItem && !subComponentIsValid.current),
3552
3573
  save,
3553
3574
  dontSaveOnExternalClick: true,
3554
3575
  });