@linzjs/step-ag-grid 26.0.0 → 26.1.0
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/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -50,6 +50,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
50
50
|
readOnly?: boolean; // set all editables to false when read only, make all styles black, otherwise style is gray for not editable
|
|
51
51
|
defaultPostSort?: boolean; // Retain sort order after edit, Defaults to true.
|
|
52
52
|
selectable?: boolean;
|
|
53
|
+
hideSelectColumn?: boolean;
|
|
53
54
|
theme?: string; // should have prefix ag-theme-
|
|
54
55
|
['data-testid']?: string;
|
|
55
56
|
domLayout?: GridOptions['domLayout'];
|
|
@@ -591,6 +592,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
591
592
|
});
|
|
592
593
|
}, []);
|
|
593
594
|
|
|
595
|
+
const gridElementRef = useRef<Element>();
|
|
594
596
|
const onRowDragMove = useCallback(
|
|
595
597
|
(event: RowDragMoveEvent) => {
|
|
596
598
|
if (startDragYRef.current === null) {
|
|
@@ -601,7 +603,16 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
601
603
|
const data = event.overNode?.data;
|
|
602
604
|
if (data) {
|
|
603
605
|
clearHighlightRowClasses();
|
|
604
|
-
|
|
606
|
+
// Find the grid element, this can only be found on start drag.
|
|
607
|
+
// Once dragging is no progress the event target is the drag element not the start drag column.
|
|
608
|
+
const targetEl = event.event.target as Element | undefined;
|
|
609
|
+
if (targetEl) {
|
|
610
|
+
const gridElement = targetEl.closest('.ag-body');
|
|
611
|
+
if (gridElement) {
|
|
612
|
+
gridElementRef.current = gridElement;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
gridElementRef.current?.querySelectorAll(`[row-id='${data.id}']`)?.forEach((el) => {
|
|
605
616
|
el.classList.add(yDiff < 0 ? 'ag-row-highlight-above' : 'ag-row-highlight-below');
|
|
606
617
|
});
|
|
607
618
|
}
|
|
@@ -612,6 +623,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
612
623
|
const onRowDragEnd = useCallback(
|
|
613
624
|
(event: RowDragEndEvent<TData>) => {
|
|
614
625
|
clearHighlightRowClasses();
|
|
626
|
+
gridElementRef.current = undefined;
|
|
615
627
|
if (!params.onRowDragEnd || startDragYRef.current === null) {
|
|
616
628
|
return;
|
|
617
629
|
}
|
|
@@ -632,6 +644,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
632
644
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
633
645
|
setOnCellEditingComplete(params.onCellEditingComplete);
|
|
634
646
|
|
|
647
|
+
const selectWidth = params.hideSelectColumn ? 0 : selectable && params.onRowDragEnd ? 76 : 48;
|
|
635
648
|
const headerRowCount = columnDefs.some((c) => (c as any).children) ? 2 : 1;
|
|
636
649
|
return (
|
|
637
650
|
<div
|
|
@@ -708,9 +721,10 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
708
721
|
pinnedTopRowData={params.pinnedTopRowData}
|
|
709
722
|
pinnedBottomRowData={params.pinnedBottomRowData}
|
|
710
723
|
selectionColumnDef={{
|
|
724
|
+
suppressNavigable: params.hideSelectColumn,
|
|
711
725
|
rowDrag: !!params.onRowDragEnd,
|
|
712
|
-
minWidth:
|
|
713
|
-
maxWidth:
|
|
726
|
+
minWidth: selectWidth,
|
|
727
|
+
maxWidth: selectWidth,
|
|
714
728
|
pinned: selectColumnPinned,
|
|
715
729
|
headerComponentParams: {
|
|
716
730
|
exportable: false,
|