@linzjs/step-ag-grid 29.12.0 → 29.14.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/dist/index.css +26 -2
- package/dist/src/components/Grid.d.ts +37 -67
- package/dist/src/components/GridCell.d.ts +2 -19
- package/dist/src/components/GridCellFiller.d.ts +1 -1
- package/dist/src/components/GridCellMultiEditor.d.ts +1 -2
- package/dist/src/components/GridPopoverHook.d.ts +1 -1
- package/dist/src/components/GridRangeSelectContextMenu.d.ts +10 -0
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +1 -1
- package/dist/src/components/gridFilter/useGridFilter.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMessage.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +3 -2
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +13 -8
- package/dist/src/components/gridHook/useGridCopy.d.ts +15 -0
- package/dist/src/components/gridHook/useGridCopySettings.d.ts +11 -0
- package/dist/src/components/gridHook/useGridRangeSelection.d.ts +25 -0
- package/dist/src/components/gridPopoverEdit/GridButton.d.ts +1 -2
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -2
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/types.d.ts +27 -0
- package/dist/src/contexts/GridContext.d.ts +13 -12
- package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
- package/dist/src/lui/timeoutHook.d.ts +0 -6
- package/dist/src/lui/tsUtils.d.ts +5 -0
- package/dist/src/utils/__tests__/random.ts +19 -0
- package/dist/src/utils/textValidator.d.ts +1 -1
- package/dist/src/utils/util.d.ts +1 -0
- package/dist/step-ag-grid.cjs +650 -242
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +651 -245
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +4 -2
- package/src/components/Grid.tsx +312 -221
- package/src/components/GridCell.tsx +1 -25
- package/src/components/GridCellFiller.tsx +1 -1
- package/src/components/GridCellMultiEditor.tsx +2 -2
- package/src/components/GridPopoverHook.tsx +1 -1
- package/src/components/GridRangeSelectContextMenu.tsx +73 -0
- package/src/components/gridFilter/GridFilterButtons.tsx +1 -1
- package/src/components/gridFilter/useGridFilter.ts +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +2 -4
- package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
- package/src/components/gridForm/GridFormMessage.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
- package/src/components/gridForm/GridFormPopoverMenu.tsx +3 -2
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -1
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -1
- package/src/components/gridForm/GridFormTextArea.tsx +1 -1
- package/src/components/gridForm/GridFormTextInput.tsx +1 -1
- package/src/components/gridHook/useGridContextMenu.tsx +23 -10
- package/src/components/gridHook/useGridCopy.ts +279 -0
- package/src/components/gridHook/useGridCopySettings.ts +28 -0
- package/src/components/gridHook/useGridRangeSelection.ts +235 -0
- package/src/components/gridPopoverEdit/GridButton.tsx +2 -2
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +2 -2
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +5 -2
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -2
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
- package/src/components/gridRender/GridRenderGenericCell.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/components/types.ts +34 -0
- package/src/contexts/GridContext.tsx +57 -148
- package/src/contexts/GridContextProvider.tsx +16 -13
- package/src/contexts/GridPopoverContext.tsx +1 -1
- package/src/contexts/GridPopoverContextProvider.tsx +1 -1
- package/src/lui/timeoutHook.tsx +0 -19
- package/src/lui/tsUtils.ts +8 -0
- package/src/react-menu3/components/MenuButton.tsx +2 -2
- package/src/react-menu3/hooks/useItemState.ts +1 -1
- package/src/stories/grid/GridCopy.stories.tsx +175 -0
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +4 -4
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
- package/src/stories/grid/GridReadOnly.stories.tsx +4 -3
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +2 -2
- package/src/styles/ContextMenu.scss +61 -0
- package/src/styles/Grid.scss +26 -2
- package/src/utils/__tests__/random.ts +19 -0
- package/src/utils/bearing.ts +2 -2
- package/src/utils/textValidator.test.ts +1 -1
- package/src/utils/textValidator.ts +1 -1
- package/src/utils/util.ts +2 -0
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { LuiMiniSpinner,
|
|
2
|
+
import { LuiMiniSpinner, LuiIcon, useShowLUIMessage, LuiStatusSpinner, LuiButtonGroup, LuiButton, LuiCheckboxInput } from '@linzjs/lui';
|
|
3
3
|
import { ModuleRegistry, AllCommunityModule } from 'ag-grid-community';
|
|
4
4
|
import { AgGridReact } from 'ag-grid-react';
|
|
5
|
-
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, xorBy, last, difference, delay, omit, sortBy, partition,
|
|
5
|
+
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, compact, xorBy, last, difference, delay, omit, sortBy, partition, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
6
6
|
import React, { useRef, useLayoutEffect, useEffect, createContext, useContext, useState, useMemo, memo, forwardRef, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1, useId } from 'react';
|
|
7
7
|
import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
|
|
8
8
|
import { createRoot } from 'react-dom/client';
|
|
@@ -417,6 +417,9 @@ function useInterval(callback, delay) {
|
|
|
417
417
|
savedCallback.current = callback;
|
|
418
418
|
}, [callback]);
|
|
419
419
|
useEffect(() => {
|
|
420
|
+
if (delay === null) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
420
423
|
const id = setInterval(() => {
|
|
421
424
|
savedCallback.current();
|
|
422
425
|
}, delay);
|
|
@@ -426,147 +429,54 @@ function useInterval(callback, delay) {
|
|
|
426
429
|
}, [delay]);
|
|
427
430
|
}
|
|
428
431
|
|
|
432
|
+
const NoContext = () => {
|
|
433
|
+
console.error('Missing GridContextProvider');
|
|
434
|
+
return null;
|
|
435
|
+
};
|
|
429
436
|
const GridContext = createContext({
|
|
430
437
|
gridReady: false,
|
|
431
438
|
gridRenderState: () => null,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
getColumns: () => {
|
|
437
|
-
console.error('no context provider for getColumns');
|
|
438
|
-
return [];
|
|
439
|
-
},
|
|
440
|
-
getColumnIds: () => {
|
|
441
|
-
console.error('no context provider for getColumnIds');
|
|
442
|
-
return [];
|
|
443
|
-
},
|
|
439
|
+
getCellValue: NoContext,
|
|
440
|
+
getColDef: NoContext,
|
|
441
|
+
getColumns: NoContext,
|
|
442
|
+
getColumnIds: NoContext,
|
|
444
443
|
invisibleColumnIds: undefined,
|
|
445
|
-
setInvisibleColumnIds:
|
|
446
|
-
|
|
447
|
-
},
|
|
448
|
-
prePopupOps: () => {
|
|
449
|
-
console.error('no context provider for prePopupOps');
|
|
450
|
-
},
|
|
444
|
+
setInvisibleColumnIds: NoContext,
|
|
445
|
+
prePopupOps: NoContext,
|
|
451
446
|
externallySelectedItemsAreInSync: false,
|
|
452
|
-
setApis:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
selectRowsWithFlashDiff: async () => {
|
|
486
|
-
console.error('no context provider for selectRowsWithFlashDiff');
|
|
487
|
-
},
|
|
488
|
-
flashRows: () => {
|
|
489
|
-
console.error('no context provider for flashRows');
|
|
490
|
-
},
|
|
491
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
492
|
-
flashRowsDiff: async () => {
|
|
493
|
-
console.error('no context provider for flashRows');
|
|
494
|
-
},
|
|
495
|
-
// eslint-disable-next-line @typescript-eslint/require-await,@typescript-eslint/no-misused-promises
|
|
496
|
-
focusByRowById: async () => {
|
|
497
|
-
console.error('no context provider for focusByRowById');
|
|
498
|
-
},
|
|
499
|
-
ensureRowVisible: () => {
|
|
500
|
-
console.error('no context provider for ensureRowVisible');
|
|
501
|
-
return true;
|
|
502
|
-
},
|
|
503
|
-
ensureSelectedRowIsVisible: () => {
|
|
504
|
-
console.error('no context provider for ensureSelectedRowIsVisible');
|
|
505
|
-
},
|
|
506
|
-
getFirstRowId: () => {
|
|
507
|
-
console.error('no context provider for getFirstRowId');
|
|
508
|
-
return -1;
|
|
509
|
-
},
|
|
510
|
-
autoSizeColumns: async () => {
|
|
511
|
-
console.error('no context provider for autoSizeColumns');
|
|
512
|
-
return Promise.resolve(null);
|
|
513
|
-
},
|
|
514
|
-
sizeColumnsToFit: () => {
|
|
515
|
-
console.error('no context provider for autoSizeAllColumns');
|
|
516
|
-
return null;
|
|
517
|
-
},
|
|
518
|
-
editingCells: () => {
|
|
519
|
-
console.error('no context provider for editingCells');
|
|
520
|
-
return false;
|
|
521
|
-
},
|
|
522
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
523
|
-
startCellEditing: async () => {
|
|
524
|
-
console.error('no context provider for startCellEditing');
|
|
525
|
-
},
|
|
526
|
-
resetFocusedCellAfterCellEditing: () => {
|
|
527
|
-
console.error('no context provider for resetFocusedCellAfterCellEditing');
|
|
528
|
-
},
|
|
529
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
530
|
-
updatingCells: async () => {
|
|
531
|
-
console.error('no context provider for modifyUpdating');
|
|
532
|
-
return false;
|
|
533
|
-
},
|
|
534
|
-
redrawRows: () => {
|
|
535
|
-
console.error('no context provider for redrawRows');
|
|
536
|
-
},
|
|
537
|
-
setExternallySelectedItemsAreInSync: () => {
|
|
538
|
-
console.error('no context provider for setExternallySelectedItemsAreInSync');
|
|
539
|
-
},
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
541
|
-
waitForExternallySelectedItemsToBeInSync: async () => {
|
|
542
|
-
console.error('no context provider for waitForExternallySelectedItemsToBeInSync');
|
|
543
|
-
},
|
|
544
|
-
addExternalFilter: () => {
|
|
545
|
-
console.error('no context provider for addExternalFilter');
|
|
546
|
-
},
|
|
547
|
-
removeExternalFilter: () => {
|
|
548
|
-
console.error('no context provider for removeExternalFilter');
|
|
549
|
-
},
|
|
550
|
-
isExternalFilterPresent: () => {
|
|
551
|
-
console.error('no context provider for isExternalFilterPresent');
|
|
552
|
-
return false;
|
|
553
|
-
},
|
|
554
|
-
doesExternalFilterPass: () => {
|
|
555
|
-
console.error('no context provider for doesExternalFilterPass');
|
|
556
|
-
return true;
|
|
557
|
-
},
|
|
558
|
-
downloadCsv: () => {
|
|
559
|
-
console.error('no context provider for downloadCsv');
|
|
560
|
-
},
|
|
561
|
-
onBulkEditingComplete: () => {
|
|
562
|
-
console.error('no context provider for onBulkEditingComplete');
|
|
563
|
-
},
|
|
564
|
-
setOnBulkEditingComplete: () => {
|
|
565
|
-
console.error('no context provider for setOnBulkEditingComplete');
|
|
566
|
-
},
|
|
567
|
-
showNoRowsOverlay: () => {
|
|
568
|
-
console.error('no context provider for showLoadingOverlay');
|
|
569
|
-
},
|
|
447
|
+
setApis: NoContext,
|
|
448
|
+
setQuickFilter: NoContext,
|
|
449
|
+
selectRowsById: NoContext,
|
|
450
|
+
getSelectedRows: NoContext,
|
|
451
|
+
getFilteredSelectedRows: NoContext,
|
|
452
|
+
getSelectedRowIds: NoContext,
|
|
453
|
+
getFilteredSelectedRowIds: NoContext,
|
|
454
|
+
selectRowsDiff: NoContext,
|
|
455
|
+
selectRowsByIdWithFlash: NoContext,
|
|
456
|
+
selectRowsWithFlashDiff: NoContext,
|
|
457
|
+
flashRows: NoContext,
|
|
458
|
+
flashRowsDiff: NoContext,
|
|
459
|
+
focusByRowById: NoContext,
|
|
460
|
+
ensureRowVisible: NoContext,
|
|
461
|
+
ensureSelectedRowIsVisible: NoContext,
|
|
462
|
+
getFirstRowId: NoContext,
|
|
463
|
+
autoSizeColumns: NoContext,
|
|
464
|
+
sizeColumnsToFit: NoContext,
|
|
465
|
+
editingCells: NoContext,
|
|
466
|
+
startCellEditing: NoContext,
|
|
467
|
+
resetFocusedCellAfterCellEditing: NoContext,
|
|
468
|
+
updatingCells: NoContext,
|
|
469
|
+
redrawRows: NoContext,
|
|
470
|
+
setExternallySelectedItemsAreInSync: NoContext,
|
|
471
|
+
waitForExternallySelectedItemsToBeInSync: NoContext,
|
|
472
|
+
addExternalFilter: NoContext,
|
|
473
|
+
removeExternalFilter: NoContext,
|
|
474
|
+
isExternalFilterPresent: NoContext,
|
|
475
|
+
doesExternalFilterPass: NoContext,
|
|
476
|
+
downloadCsv: NoContext,
|
|
477
|
+
onBulkEditingComplete: NoContext,
|
|
478
|
+
setOnBulkEditingComplete: NoContext,
|
|
479
|
+
showNoRowsOverlay: NoContext,
|
|
570
480
|
});
|
|
571
481
|
const useGridContext = () => useContext(GridContext);
|
|
572
482
|
|
|
@@ -848,6 +758,36 @@ const GridHeaderSelect = ({ api }) => {
|
|
|
848
758
|
} }) }));
|
|
849
759
|
};
|
|
850
760
|
|
|
761
|
+
function styleInject(css, ref) {
|
|
762
|
+
if ( ref === void 0 ) ref = {};
|
|
763
|
+
var insertAt = ref.insertAt;
|
|
764
|
+
|
|
765
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
766
|
+
|
|
767
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
768
|
+
var style = document.createElement('style');
|
|
769
|
+
style.type = 'text/css';
|
|
770
|
+
|
|
771
|
+
if (insertAt === 'top') {
|
|
772
|
+
if (head.firstChild) {
|
|
773
|
+
head.insertBefore(style, head.firstChild);
|
|
774
|
+
} else {
|
|
775
|
+
head.appendChild(style);
|
|
776
|
+
}
|
|
777
|
+
} else {
|
|
778
|
+
head.appendChild(style);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (style.styleSheet) {
|
|
782
|
+
style.styleSheet.cssText = css;
|
|
783
|
+
} else {
|
|
784
|
+
style.appendChild(document.createTextNode(css));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
var css_248z$4 = ".GridContextMenu li.szh-menu__header{color:#6b6966;font-size:14px;font-weight:600;padding-left:16px;padding-right:16px;text-transform:none}.GridContextMenu li.szh-menu__item{padding-left:16px;padding-right:16px}.GridContextMenu li.szh-menu__item .copyMenuMenuItem{align-items:center;display:flex;gap:8px}.GridContextMenu li.szh-menu__item .copyMenuMenuItem__text{color:#2a292c;font-size:16px;font-weight:400;width:80px}.GridContextMenu li.szh-menu__item .copyMenuMenuItem__buttonDefault{background:none;border:2px solid #0000;display:flex;padding:6px}.GridContextMenu li.szh-menu__item .copyMenuMenuItem__buttonDefault.copyMenuMenuItem__buttonDefault--hidden:hover{border:2px solid #2a292c}.GridContextMenu li.szh-menu__item .copyMenuMenuItem__buttonDefault--hidden .LuiIcon{fill:#0000}.GridContextMenu li.szh-menu__item .LuiIcon,.GridContextMenu li.szh-menu__item .copyMenuMenuItem__buttonDefault--hidden:hover .LuiIcon{fill:#6b6966}.GridContextMenu li.szh-menu__item .LuiIcon[data-icon=ic_tick]{padding-left:4px;padding-right:4px}.GridContextMenu li.szh-menu__item--hover{background-color:#e2f3f7}";
|
|
789
|
+
styleInject(css_248z$4);
|
|
790
|
+
|
|
851
791
|
const EventHandlersContext = createContext({
|
|
852
792
|
handleClick: () => { },
|
|
853
793
|
});
|
|
@@ -2682,7 +2622,7 @@ const SubMenuFr = ({ 'aria-label': ariaLabel, className, disabled, direction, la
|
|
|
2682
2622
|
};
|
|
2683
2623
|
const SubMenu = withHovering('SubMenu', SubMenuFr);
|
|
2684
2624
|
|
|
2685
|
-
const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, }) => {
|
|
2625
|
+
const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, context, }) => {
|
|
2686
2626
|
const { redrawRows, prePopupOps, resetFocusedCellAfterCellEditing, getSelectedRows } = useContext(GridContext);
|
|
2687
2627
|
const [isOpen, setOpen] = useState(false);
|
|
2688
2628
|
const [anchorPoint, setAnchorPoint] = useState({ x: 0, y: 0 });
|
|
@@ -2690,6 +2630,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2690
2630
|
const clickedColDefRef = useRef(null);
|
|
2691
2631
|
const selectedRowsRef = useRef([]);
|
|
2692
2632
|
const clickedRowRef = useRef(null);
|
|
2633
|
+
const eventRef = useRef(undefined);
|
|
2693
2634
|
const openMenu = useCallback((e) => {
|
|
2694
2635
|
if (!e)
|
|
2695
2636
|
return;
|
|
@@ -2709,16 +2650,424 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2709
2650
|
clickedColDefRef.current = event.colDef;
|
|
2710
2651
|
selectedRowsRef.current = getSelectedRows();
|
|
2711
2652
|
clickedRowRef.current = event.data;
|
|
2653
|
+
eventRef.current = event;
|
|
2712
2654
|
// This is actually a pointer event
|
|
2713
2655
|
openMenu(event.event);
|
|
2714
2656
|
}, [contextMenuSelectRow, getSelectedRows, openMenu]);
|
|
2715
2657
|
return {
|
|
2716
2658
|
openMenu,
|
|
2717
2659
|
cellContextMenu,
|
|
2718
|
-
|
|
2660
|
+
contextMenuComponent: ContextMenu ? (jsx(Fragment, { children: jsx(ControlledMenu, { className: 'GridContextMenu', anchorPoint: anchorPoint, state: isOpen ? 'open' : 'closed', direction: "right", onClose: closeMenu, children: isOpen && (jsx(ContextMenu, { selectedRows: selectedRowsRef.current, clickedRow: clickedRowRef.current, colDef: clickedColDefRef.current, event: eventRef.current, close: closeMenu, context: context })) }) })) : null,
|
|
2661
|
+
};
|
|
2662
|
+
};
|
|
2663
|
+
|
|
2664
|
+
const typedEntries = (obj) => Object.entries(obj);
|
|
2665
|
+
|
|
2666
|
+
const gridCopyOptions = {
|
|
2667
|
+
html: { text: 'Text\xa0/\xa0HTML', icon: 'ic_product_list' },
|
|
2668
|
+
csv: { text: 'CSV', icon: 'ic_csv_file' },
|
|
2669
|
+
json: { text: 'Json', icon: 'ic_file_attached_outline', developer: true },
|
|
2670
|
+
};
|
|
2671
|
+
const CopyOptionsStorageKey = 'stepAgGrid_defaultCopy';
|
|
2672
|
+
const useGridCopySettings = () => {
|
|
2673
|
+
const [copyType, _setCopyType] = useState(() => {
|
|
2674
|
+
const defaultCopy = window.localStorage.getItem(CopyOptionsStorageKey) ?? '';
|
|
2675
|
+
return Object.keys(gridCopyOptions).includes(defaultCopy) ? defaultCopy : 'html';
|
|
2676
|
+
});
|
|
2677
|
+
const setCopyType = useCallback((key) => {
|
|
2678
|
+
window.localStorage.setItem(CopyOptionsStorageKey, key);
|
|
2679
|
+
_setCopyType(key);
|
|
2680
|
+
}, []);
|
|
2681
|
+
return {
|
|
2682
|
+
copyType,
|
|
2683
|
+
setCopyType,
|
|
2719
2684
|
};
|
|
2720
2685
|
};
|
|
2721
2686
|
|
|
2687
|
+
const GridRangeSelectContextMenu = ({ event, context, }) => {
|
|
2688
|
+
const developerContextMenu = !!event?.event?.ctrlKey && !!event?.event?.shiftKey;
|
|
2689
|
+
const onCopy = useMemo(() => context?.onCopy, [context?.onCopy]);
|
|
2690
|
+
const onClick = useCallback((type) => {
|
|
2691
|
+
onCopy?.(type);
|
|
2692
|
+
}, [onCopy]);
|
|
2693
|
+
return (jsxs(Fragment, { children: [jsx(MenuHeader, { children: "Copy as" }), typedEntries(gridCopyOptions).map(([key, { icon, text, developer }]) => {
|
|
2694
|
+
return ((!developer || developerContextMenu) && (jsx(MenuItem, { onClick: () => void onClick(key), children: jsxs("div", { className: 'copyMenuMenuItem', children: [jsx(LuiIcon, { name: icon, alt: text, size: 'md' }), jsx("div", { className: 'copyMenuMenuItem__text', children: text })] }) }, key)));
|
|
2695
|
+
}), jsx(MenuDivider, {}), jsx(MenuHeader, { children: "Set copy default" }), typedEntries(gridCopyOptions).map(([key, { text, developer }]) => {
|
|
2696
|
+
return (!developer && (jsx(MenuItem, { onClick: (e) => {
|
|
2697
|
+
context?.setCopyType(key);
|
|
2698
|
+
e.keepOpen = true;
|
|
2699
|
+
}, children: jsxs("div", { className: clsx('copyMenuMenuItem', context?.copyType === key ? '' : 'copyMenuMenuItem__buttonDefault--hidden'), children: [jsx(LuiIcon, { name: 'ic_tick', alt: 'CSV', size: 'sm' }), jsx("div", { className: 'copyMenuMenuItem__text', children: text })] }) }, 'default_' + key)));
|
|
2700
|
+
})] }));
|
|
2701
|
+
};
|
|
2702
|
+
|
|
2703
|
+
const agGridSelectRowColId = 'ag-Grid-SelectionColumn';
|
|
2704
|
+
|
|
2705
|
+
const useGridCopy = ({ ranges, rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef, cellContextMenu, }) => {
|
|
2706
|
+
const showToast = useShowLUIMessage();
|
|
2707
|
+
const { getSelectedRowIds } = useGridContext();
|
|
2708
|
+
const { getColDef, getCellValue } = useGridContext();
|
|
2709
|
+
const { copyType, setCopyType } = useGridCopySettings();
|
|
2710
|
+
const onCopy = useCallback((type = copyType) => {
|
|
2711
|
+
const rangeStart = rangeStartRef.current;
|
|
2712
|
+
const rangeEnd = rangeEndRef.current;
|
|
2713
|
+
if (rangeStart === null || rangeEnd === null || !hasSelectedMoreThanOneCellRef.current) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
if (rangeStart.rowId === rangeEnd.rowId && rangeStart.colId === rangeEnd.colId) {
|
|
2717
|
+
type = 'html';
|
|
2718
|
+
}
|
|
2719
|
+
const json = type === 'json';
|
|
2720
|
+
const { selectedColIds, selectedNodes } = ranges();
|
|
2721
|
+
const filteredSelectedColIds = selectedColIds.filter((colId) => colId === agGridSelectRowColId ||
|
|
2722
|
+
(colId !== 'gridCellFiller' && getColDef(colId)?.headerComponentParams?.exportable !== false));
|
|
2723
|
+
const selectedRowIds = getSelectedRowIds();
|
|
2724
|
+
const formatters = compact(filteredSelectedColIds.map((colKey) => {
|
|
2725
|
+
return (rowNode) => {
|
|
2726
|
+
if (colKey === agGridSelectRowColId) {
|
|
2727
|
+
return selectedRowIds.includes(rowNode.data.id);
|
|
2728
|
+
}
|
|
2729
|
+
else {
|
|
2730
|
+
const v = getCellValue({ rowNode, colKey });
|
|
2731
|
+
if (json && v !== undefined) {
|
|
2732
|
+
return v;
|
|
2733
|
+
}
|
|
2734
|
+
const f = getCellValue({ rowNode, colKey, useFormatter: true });
|
|
2735
|
+
// If it's a number, and it matches value return the original type
|
|
2736
|
+
return v == f ? v : f;
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
}));
|
|
2740
|
+
// Get and apply headers
|
|
2741
|
+
const headers = filteredSelectedColIds.map((colId) => {
|
|
2742
|
+
if (colId === agGridSelectRowColId)
|
|
2743
|
+
return type === 'json' ? 'selected' : 'Selected';
|
|
2744
|
+
if (json) {
|
|
2745
|
+
return colId;
|
|
2746
|
+
}
|
|
2747
|
+
return getColDef(colId)?.headerName ?? '?';
|
|
2748
|
+
});
|
|
2749
|
+
const maxCellLength = {};
|
|
2750
|
+
headers.forEach((headerName, i) => {
|
|
2751
|
+
const colId = filteredSelectedColIds[i];
|
|
2752
|
+
maxCellLength[colId] = headerName.length;
|
|
2753
|
+
});
|
|
2754
|
+
const rows = [];
|
|
2755
|
+
if (type === 'csv' || type === 'html') {
|
|
2756
|
+
rows.push(headers);
|
|
2757
|
+
}
|
|
2758
|
+
selectedNodes.forEach((node) => {
|
|
2759
|
+
const row = [];
|
|
2760
|
+
rows.push(row);
|
|
2761
|
+
formatters.forEach((formatter, i) => {
|
|
2762
|
+
const colId = filteredSelectedColIds[i];
|
|
2763
|
+
let value = formatter(node);
|
|
2764
|
+
if (typeof value === 'string') {
|
|
2765
|
+
value = value.replaceAll('\xa0', ' ');
|
|
2766
|
+
}
|
|
2767
|
+
if (!json) {
|
|
2768
|
+
if (value === '-' || value === '–' || value == null) {
|
|
2769
|
+
value = '';
|
|
2770
|
+
}
|
|
2771
|
+
value = String(value);
|
|
2772
|
+
if (value === '-' || value === '–') {
|
|
2773
|
+
value = '';
|
|
2774
|
+
}
|
|
2775
|
+
maxCellLength[colId] = Math.max(maxCellLength[colId], value.length);
|
|
2776
|
+
}
|
|
2777
|
+
switch (type) {
|
|
2778
|
+
case 'json':
|
|
2779
|
+
value =
|
|
2780
|
+
value === 'undefined' || (value !== null && typeof value === 'object') || typeof value === 'string'
|
|
2781
|
+
? JSON.stringify(value)
|
|
2782
|
+
: value;
|
|
2783
|
+
break;
|
|
2784
|
+
case 'markdown':
|
|
2785
|
+
value = encodeMarkdownValue(value);
|
|
2786
|
+
break;
|
|
2787
|
+
case 'csv':
|
|
2788
|
+
value = encodeCSVValue(value);
|
|
2789
|
+
break;
|
|
2790
|
+
}
|
|
2791
|
+
row.push(String(value));
|
|
2792
|
+
});
|
|
2793
|
+
});
|
|
2794
|
+
let result = '';
|
|
2795
|
+
let html = `<table style="
|
|
2796
|
+
font-family: 'Open Sans', system-ui, sans-serif;
|
|
2797
|
+
font-size: 10px;
|
|
2798
|
+
line-height: 10px;
|
|
2799
|
+
border: 1px solid #d1d9e0;
|
|
2800
|
+
border-collapse: collapse;
|
|
2801
|
+
">`;
|
|
2802
|
+
if (json) {
|
|
2803
|
+
result += '[\n';
|
|
2804
|
+
}
|
|
2805
|
+
rows.forEach((row, rowIndex) => {
|
|
2806
|
+
if (json) {
|
|
2807
|
+
result += ' { ';
|
|
2808
|
+
}
|
|
2809
|
+
if (rowIndex == 1) {
|
|
2810
|
+
html += '<tbody style="font-weight: 400;">';
|
|
2811
|
+
}
|
|
2812
|
+
if (rowIndex == 0) {
|
|
2813
|
+
html += '<thead style="font-weight: 600;">';
|
|
2814
|
+
}
|
|
2815
|
+
if (rowIndex === 0 || (rowIndex & 1) === 1) {
|
|
2816
|
+
html += '<tr>';
|
|
2817
|
+
}
|
|
2818
|
+
else {
|
|
2819
|
+
html += '<tr style="background-color: #f6f8fa;">';
|
|
2820
|
+
}
|
|
2821
|
+
if (rowIndex === 1 && type === 'html') {
|
|
2822
|
+
Object.values(maxCellLength).forEach((maxLength) => {
|
|
2823
|
+
result += '|' + '-'.repeat(maxLength + 2);
|
|
2824
|
+
});
|
|
2825
|
+
result += '|\n';
|
|
2826
|
+
}
|
|
2827
|
+
row.forEach((cell, i) => {
|
|
2828
|
+
switch (type) {
|
|
2829
|
+
case 'csv':
|
|
2830
|
+
if (i !== 0) {
|
|
2831
|
+
result += ', ';
|
|
2832
|
+
}
|
|
2833
|
+
result += cell;
|
|
2834
|
+
break;
|
|
2835
|
+
case 'html':
|
|
2836
|
+
if (i === 0) {
|
|
2837
|
+
result += '|';
|
|
2838
|
+
}
|
|
2839
|
+
const colId = filteredSelectedColIds[i];
|
|
2840
|
+
result += ' ' + cell.padEnd(maxCellLength[colId], ' ') + ' ';
|
|
2841
|
+
result += '|';
|
|
2842
|
+
html +=
|
|
2843
|
+
rowIndex === 0
|
|
2844
|
+
? '<th style="border: 1px solid #d1d9e0; padding:6px 13px; text-align: left;">'
|
|
2845
|
+
: '<td style="border: 1px solid #d1d9e0; padding:6px 13px;">';
|
|
2846
|
+
html += cell;
|
|
2847
|
+
html += rowIndex === 0 ? '</th>' : '</td>';
|
|
2848
|
+
break;
|
|
2849
|
+
case 'json':
|
|
2850
|
+
if (i !== 0) {
|
|
2851
|
+
result += ', ';
|
|
2852
|
+
}
|
|
2853
|
+
result += JSON.stringify(headers[i]) + ': ' + cell;
|
|
2854
|
+
break;
|
|
2855
|
+
}
|
|
2856
|
+
});
|
|
2857
|
+
html += '</tr>';
|
|
2858
|
+
if (rowIndex == 0) {
|
|
2859
|
+
html += '</thead>';
|
|
2860
|
+
}
|
|
2861
|
+
if (rowIndex == rows.length - 1) {
|
|
2862
|
+
html += '</tbody>';
|
|
2863
|
+
}
|
|
2864
|
+
if (json) {
|
|
2865
|
+
result += ' }';
|
|
2866
|
+
}
|
|
2867
|
+
result += '\n';
|
|
2868
|
+
});
|
|
2869
|
+
if (json) {
|
|
2870
|
+
result += ']\n';
|
|
2871
|
+
}
|
|
2872
|
+
html += '</table>';
|
|
2873
|
+
showToast({
|
|
2874
|
+
message: `${gridCopyOptions[type].text} copied`,
|
|
2875
|
+
messageType: 'toast',
|
|
2876
|
+
messageLevel: 'info',
|
|
2877
|
+
});
|
|
2878
|
+
if (type === 'html') {
|
|
2879
|
+
const clipboardItem = new ClipboardItem({
|
|
2880
|
+
'text/html': new Blob([html], { type: 'text/html' }),
|
|
2881
|
+
'text/plain': new Blob([result], { type: 'text/plain' }), // fallback
|
|
2882
|
+
});
|
|
2883
|
+
void navigator.clipboard.write([clipboardItem]).catch((err) => console.error('Failed to copy: ', err));
|
|
2884
|
+
}
|
|
2885
|
+
else {
|
|
2886
|
+
void navigator.clipboard.writeText(result).catch((err) => console.error('Failed to copy: ', err));
|
|
2887
|
+
}
|
|
2888
|
+
}, [getCellValue, ranges, copyType]);
|
|
2889
|
+
const onCopyEvent = useCallback((e) => {
|
|
2890
|
+
const rangeStart = rangeStartRef.current;
|
|
2891
|
+
const rangeEnd = rangeEndRef.current;
|
|
2892
|
+
if (rangeStart === null ||
|
|
2893
|
+
rangeEnd === null ||
|
|
2894
|
+
(rangeStart.colId === rangeEnd.colId &&
|
|
2895
|
+
rangeStart.rowId === rangeEnd.rowId &&
|
|
2896
|
+
!hasSelectedMoreThanOneCellRef.current)) {
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
e.preventDefault();
|
|
2900
|
+
onCopy();
|
|
2901
|
+
}, [onCopy]);
|
|
2902
|
+
const { cellContextMenu: rangeSelectContextMenu, contextMenuComponent: rangeSelectContextMenuComponent } = useGridContextMenu({
|
|
2903
|
+
contextMenu: (GridRangeSelectContextMenu),
|
|
2904
|
+
context: { onCopy, copyType, setCopyType },
|
|
2905
|
+
});
|
|
2906
|
+
const rangeSelectInterceptContextMenu = useCallback((event) => rangeStartRef.current == null ? cellContextMenu(event) : rangeSelectContextMenu(event), [cellContextMenu, rangeSelectContextMenu]);
|
|
2907
|
+
return {
|
|
2908
|
+
onCopyEvent,
|
|
2909
|
+
rangeSelectInterceptContextMenu,
|
|
2910
|
+
rangeSelectContextMenuComponent,
|
|
2911
|
+
};
|
|
2912
|
+
};
|
|
2913
|
+
const encodeMarkdownValue = (value) => {
|
|
2914
|
+
return value.replaceAll('|', '\\|');
|
|
2915
|
+
};
|
|
2916
|
+
const encodeCSVValue = (value) => {
|
|
2917
|
+
let str = String(value);
|
|
2918
|
+
// Check if it needs quoting
|
|
2919
|
+
if (/[",\n]/.test(str)) {
|
|
2920
|
+
// Escape double quotes by doubling them
|
|
2921
|
+
str = '"' + str.replace(/"/g, '""') + '"';
|
|
2922
|
+
}
|
|
2923
|
+
return str;
|
|
2924
|
+
};
|
|
2925
|
+
|
|
2926
|
+
const useGridRangeSelection = ({ enableRangeSelection, gridDivRef, rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef, rangeSortedNodesRef, }) => {
|
|
2927
|
+
const [refreshIntervalEnabled, setRefreshIntervalEnabled] = useState(false);
|
|
2928
|
+
const ranges = useCallback(() => {
|
|
2929
|
+
const gridElement = gridDivRef.current;
|
|
2930
|
+
const rangeStart = rangeStartRef.current;
|
|
2931
|
+
const rangeEnd = rangeEndRef.current;
|
|
2932
|
+
const rangeSortedNodes = rangeSortedNodesRef.current;
|
|
2933
|
+
if (!gridElement || !rangeStart || !rangeEnd || !rangeSortedNodes) {
|
|
2934
|
+
return {
|
|
2935
|
+
selectedColIds: [],
|
|
2936
|
+
selectedNodes: [],
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
const elStyleLeftComparator = (el1, el2) => elStyleLeft(el1) - elStyleLeft(el2);
|
|
2940
|
+
const elStyleLeft = (el) => parseFloat(el.style.left) ?? 0;
|
|
2941
|
+
const getSortedColIds = () => {
|
|
2942
|
+
//
|
|
2943
|
+
const leftHeaders = [...gridElement.querySelectorAll('.ag-pinned-left-header .ag-header-cell')].sort(elStyleLeftComparator);
|
|
2944
|
+
const centerHeaders = [...gridElement.querySelectorAll('.ag-header-viewport .ag-header-cell')].sort(elStyleLeftComparator);
|
|
2945
|
+
const rightHeaders = [...gridElement.querySelectorAll('.ag-pinned-right-header .ag-header-cell')].sort(elStyleLeftComparator);
|
|
2946
|
+
return [...leftHeaders, ...centerHeaders, ...rightHeaders].map((el, i) => el.getAttribute('col-id') ?? String(i));
|
|
2947
|
+
};
|
|
2948
|
+
const sortedColIds = getSortedColIds();
|
|
2949
|
+
const startColIndex = sortedColIds.indexOf(rangeStart.colId);
|
|
2950
|
+
const endColIndex = sortedColIds.indexOf(rangeEnd.colId);
|
|
2951
|
+
const selectedColIds = sortedColIds.slice(Math.min(startColIndex, endColIndex), Math.max(startColIndex, endColIndex) + 1);
|
|
2952
|
+
const startRowIndex = rangeSortedNodes.findIndex((node) => node.data.id === rangeStart.rowId);
|
|
2953
|
+
const endRowIndex = rangeSortedNodes.findIndex((node) => node.data.id === rangeEnd.rowId);
|
|
2954
|
+
const selectedNodes = rangeSortedNodes.slice(Math.min(startRowIndex, endRowIndex), Math.max(startRowIndex, endRowIndex) + 1);
|
|
2955
|
+
return { selectedColIds, selectedNodes };
|
|
2956
|
+
}, []);
|
|
2957
|
+
const redrawSelectedRanges = useCallback(() => {
|
|
2958
|
+
const gridElement = gridDivRef.current;
|
|
2959
|
+
const { selectedColIds, selectedNodes } = ranges();
|
|
2960
|
+
selectedColIds.forEach((colId, colIndex) => {
|
|
2961
|
+
selectedNodes.forEach((node, rowIndex) => {
|
|
2962
|
+
const rowId = node.data.id;
|
|
2963
|
+
const cell = gridElement.querySelector(`.ag-row[row-id=${JSON.stringify(String(rowId))}] .ag-cell[col-id=${JSON.stringify(colId)}`);
|
|
2964
|
+
cell?.classList.add('rangeSelect');
|
|
2965
|
+
if (colIndex === 0) {
|
|
2966
|
+
cell?.classList.add('rangeSelectLeft');
|
|
2967
|
+
}
|
|
2968
|
+
if (colIndex === selectedColIds.length - 1) {
|
|
2969
|
+
cell?.classList.add('rangeSelectRight');
|
|
2970
|
+
}
|
|
2971
|
+
if (rowIndex === 0) {
|
|
2972
|
+
cell?.classList.add('rangeSelectTop');
|
|
2973
|
+
}
|
|
2974
|
+
if (rowIndex === selectedNodes.length - 1) {
|
|
2975
|
+
cell?.classList.add('rangeSelectBottom');
|
|
2976
|
+
}
|
|
2977
|
+
});
|
|
2978
|
+
});
|
|
2979
|
+
}, []);
|
|
2980
|
+
const updateRangeSelectionCellClasses = useCallback((justRefresh) => {
|
|
2981
|
+
//
|
|
2982
|
+
// Get all grid cols, sort by pinned, then style: left
|
|
2983
|
+
const gridElement = gridDivRef.current;
|
|
2984
|
+
if (!gridElement) {
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
// Clear all selections
|
|
2988
|
+
if (!justRefresh) {
|
|
2989
|
+
gridElement
|
|
2990
|
+
.querySelectorAll('.rangeSelect,.rangeSelectLeft,.rangeSelectTop,.rangeSelectRight,.rangeSelectBottom')
|
|
2991
|
+
.forEach((el) => {
|
|
2992
|
+
el.classList.remove('rangeSelect', 'rangeSelectLeft', 'rangeSelectTop', 'rangeSelectRight', 'rangeSelectBottom');
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
// if range selection multiple add .Grid-container.rangeSelectingMultiple
|
|
2996
|
+
const rangeStart = rangeStartRef.current;
|
|
2997
|
+
const rangeEnd = rangeEndRef.current;
|
|
2998
|
+
if (rangeStart !== null &&
|
|
2999
|
+
rangeEnd !== null &&
|
|
3000
|
+
(hasSelectedMoreThanOneCellRef.current ||
|
|
3001
|
+
rangeStart.colId !== rangeEnd.colId ||
|
|
3002
|
+
rangeStart.rowId !== rangeEnd.rowId)) {
|
|
3003
|
+
gridElement.classList.add('rangeSelectingMultiple');
|
|
3004
|
+
gridElement.querySelectorAll('.ag-cell-focus').forEach((el) => {
|
|
3005
|
+
el.classList.remove('ag-cell-focus');
|
|
3006
|
+
});
|
|
3007
|
+
}
|
|
3008
|
+
else {
|
|
3009
|
+
gridElement.classList.remove('rangeSelectingMultiple');
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
const rangeSortedNodes = rangeSortedNodesRef.current;
|
|
3013
|
+
if (!rangeSortedNodes) {
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
redrawSelectedRanges();
|
|
3017
|
+
}, [ranges, redrawSelectedRanges]);
|
|
3018
|
+
// Handle updates after scroll / grid refresh
|
|
3019
|
+
useInterval(() => {
|
|
3020
|
+
updateRangeSelectionCellClasses(true);
|
|
3021
|
+
}, refreshIntervalEnabled ? 150 : null);
|
|
3022
|
+
const clearRangeSelection = useCallback(() => {
|
|
3023
|
+
hasSelectedMoreThanOneCellRef.current = false;
|
|
3024
|
+
setRefreshIntervalEnabled(false);
|
|
3025
|
+
hasSelectedMoreThanOneCellRef.current = false;
|
|
3026
|
+
rangeStartRef.current = null;
|
|
3027
|
+
rangeEndRef.current = null;
|
|
3028
|
+
updateRangeSelectionCellClasses();
|
|
3029
|
+
}, [updateRangeSelectionCellClasses]);
|
|
3030
|
+
const onCellMouseOver = useCallback((e, mouseDown) => {
|
|
3031
|
+
if (!enableRangeSelection) {
|
|
3032
|
+
return;
|
|
3033
|
+
}
|
|
3034
|
+
const button = e.event.buttons;
|
|
3035
|
+
if (button !== 1) {
|
|
3036
|
+
// TODO fix this?
|
|
3037
|
+
//rangeSortedNodesRef.current = null;
|
|
3038
|
+
return;
|
|
3039
|
+
}
|
|
3040
|
+
rangeEndRef.current = {
|
|
3041
|
+
rowId: e.node.data.id,
|
|
3042
|
+
colId: e.column.getColId(),
|
|
3043
|
+
timestamp: Date.now(),
|
|
3044
|
+
};
|
|
3045
|
+
if (mouseDown) {
|
|
3046
|
+
const sortedNodes = [];
|
|
3047
|
+
e.api.forEachNodeAfterFilterAndSort((node) => sortedNodes.push(node));
|
|
3048
|
+
rangeSortedNodesRef.current = sortedNodes;
|
|
3049
|
+
setRefreshIntervalEnabled(true);
|
|
3050
|
+
rangeStartRef.current = { ...rangeEndRef.current };
|
|
3051
|
+
}
|
|
3052
|
+
if (rangeStartRef.current &&
|
|
3053
|
+
rangeEndRef.current &&
|
|
3054
|
+
(rangeStartRef.current.rowId !== rangeEndRef.current.rowId ||
|
|
3055
|
+
rangeStartRef.current.colId !== rangeEndRef.current.colId)) {
|
|
3056
|
+
hasSelectedMoreThanOneCellRef.current = true;
|
|
3057
|
+
window.getSelection()?.removeAllRanges();
|
|
3058
|
+
}
|
|
3059
|
+
updateRangeSelectionCellClasses();
|
|
3060
|
+
}, [enableRangeSelection, updateRangeSelectionCellClasses]);
|
|
3061
|
+
const onCellMouseDown = useCallback((e) => {
|
|
3062
|
+
const button = e.event.buttons;
|
|
3063
|
+
if (button === 1) {
|
|
3064
|
+
clearRangeSelection();
|
|
3065
|
+
}
|
|
3066
|
+
onCellMouseOver(e, true);
|
|
3067
|
+
}, [onCellMouseOver]);
|
|
3068
|
+
return { clearRangeSelection, ranges, onCellMouseDown, onCellMouseOver };
|
|
3069
|
+
};
|
|
3070
|
+
|
|
2722
3071
|
const GridLoadingOverlayComponentFr = (props, externalRef) => (jsx("div", { ref: externalRef, style: {
|
|
2723
3072
|
left: 0,
|
|
2724
3073
|
top: 0,
|
|
@@ -2900,8 +3249,26 @@ ModuleRegistry.registerModules([AllCommunityModule]);
|
|
|
2900
3249
|
/**
|
|
2901
3250
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2902
3251
|
*/
|
|
2903
|
-
const Grid = ({
|
|
2904
|
-
|
|
3252
|
+
const Grid = ({ theme = 'ag-theme-step-default', 'data-testid': dataTestId,
|
|
3253
|
+
// ─── Grid State ───────────────────────────────
|
|
3254
|
+
suppressReadOnlyStyle = false,
|
|
3255
|
+
// ─── Data & Columns ───────────────────────────
|
|
3256
|
+
defaultPostSort = true, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, rowSelection = 'multiple', sizeColumns = 'auto',
|
|
3257
|
+
// ─── Selection ────────────────────────────────
|
|
3258
|
+
autoSelectFirstRow, enableRangeSelection = true, externalSelectedIds, externalSelectedItems, selectColumnPinned = 'left', selectable, setExternalSelectedIds, setExternalSelectedItems,
|
|
3259
|
+
// ─── Editing ──────────────────────────────────
|
|
3260
|
+
singleClickEdit = false,
|
|
3261
|
+
// ─── Context Menu ─────────────────────────────
|
|
3262
|
+
contextMenuSelectRow = false, contextMenu,
|
|
3263
|
+
// ─── Callbacks / Events ───────────────────────
|
|
3264
|
+
onCellFocused: paramsOnCellFocused, onColumnMoved,
|
|
3265
|
+
// ─── Row Behavior ─────────────────────────────
|
|
3266
|
+
suppressColumnVirtualization = true,
|
|
3267
|
+
// ─── Miscellaneous ────────────────────────────
|
|
3268
|
+
maxInitialWidth,
|
|
3269
|
+
// ─── Spread Remaining Params ──────────────────
|
|
3270
|
+
...params }) => {
|
|
3271
|
+
const { setApis, setExternallySelectedItemsAreInSync, setOnBulkEditingComplete, gridReady, gridRenderState, externallySelectedItemsAreInSync, showNoRowsOverlay, autoSizeColumns, sizeColumnsToFit, doesExternalFilterPass, ensureRowVisible, ensureSelectedRowIsVisible, focusByRowById, getColDef, getFirstRowId, isExternalFilterPresent, prePopupOps, selectRowsById, startCellEditing: propStartCellEditing, } = useGridContext();
|
|
2905
3272
|
// CellEditingStop event happens too much for one edit
|
|
2906
3273
|
const startedEditRef = useRef(false);
|
|
2907
3274
|
const startCellEditing = useCallback((props) => {
|
|
@@ -2910,7 +3277,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2910
3277
|
}, [propStartCellEditing]);
|
|
2911
3278
|
const { updatedDep, anyUpdating, updatingCols } = useContext(GridUpdatingContext);
|
|
2912
3279
|
const gridDivRef = useRef(null);
|
|
2913
|
-
const lastSelectedIds = useRef(
|
|
3280
|
+
const lastSelectedIds = useRef();
|
|
2914
3281
|
const [staleGrid, setStaleGrid] = useState(false);
|
|
2915
3282
|
const [autoSized, setAutoSized] = useState(false);
|
|
2916
3283
|
const postSortRows = usePostSortRowsHook({ setStaleGrid });
|
|
@@ -3036,12 +3403,13 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3036
3403
|
*/
|
|
3037
3404
|
const hasSelectedFirstItem = useRef(false);
|
|
3038
3405
|
useEffect(() => {
|
|
3039
|
-
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync)
|
|
3406
|
+
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync) {
|
|
3040
3407
|
return;
|
|
3408
|
+
}
|
|
3041
3409
|
hasSelectedFirstItem.current = true;
|
|
3042
|
-
if (isNotEmpty(rowData) && isEmpty(
|
|
3410
|
+
if (isNotEmpty(rowData) && isEmpty(externalSelectedItems) && isEmpty(externalSelectedIds)) {
|
|
3043
3411
|
const firstRowId = getFirstRowId();
|
|
3044
|
-
if (
|
|
3412
|
+
if (autoSelectFirstRow && selectable) {
|
|
3045
3413
|
selectRowsById([firstRowId]);
|
|
3046
3414
|
}
|
|
3047
3415
|
else {
|
|
@@ -3052,31 +3420,52 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3052
3420
|
externallySelectedItemsAreInSync,
|
|
3053
3421
|
focusByRowById,
|
|
3054
3422
|
gridReady,
|
|
3055
|
-
|
|
3056
|
-
|
|
3423
|
+
externalSelectedItems,
|
|
3424
|
+
autoSelectFirstRow,
|
|
3057
3425
|
rowData,
|
|
3058
3426
|
selectRowsById,
|
|
3059
3427
|
getFirstRowId,
|
|
3428
|
+
selectable,
|
|
3429
|
+
externalSelectedIds,
|
|
3060
3430
|
]);
|
|
3061
3431
|
/**
|
|
3062
3432
|
* Ensure external selected items list is in sync with panel.
|
|
3063
3433
|
*/
|
|
3064
3434
|
const synchroniseExternalStateToGridSelection = useCallback(({ api }) => {
|
|
3065
|
-
if (
|
|
3066
|
-
|
|
3067
|
-
|
|
3435
|
+
if (externalSelectedIds && setExternalSelectedIds) {
|
|
3436
|
+
const selectedRowsIds = api.getSelectedRows().map((row) => row.id);
|
|
3437
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
3438
|
+
if (externalSelectedIds.length !== selectedRowsIds.length ||
|
|
3439
|
+
isNotEmpty(xorBy(selectedRowsIds, externalSelectedIds))) {
|
|
3440
|
+
setExternallySelectedItemsAreInSync(false);
|
|
3441
|
+
setExternalSelectedIds([...selectedRowsIds]);
|
|
3442
|
+
}
|
|
3443
|
+
else {
|
|
3444
|
+
setExternallySelectedItemsAreInSync(true);
|
|
3445
|
+
}
|
|
3068
3446
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3447
|
+
else if (externalSelectedItems && setExternalSelectedItems) {
|
|
3448
|
+
const selectedRows = api.getSelectedRows();
|
|
3449
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
3450
|
+
if (externalSelectedItems.length !== selectedRows.length ||
|
|
3451
|
+
isNotEmpty(xorBy(selectedRows, externalSelectedItems, (row) => row.id))) {
|
|
3452
|
+
setExternallySelectedItemsAreInSync(false);
|
|
3453
|
+
setExternalSelectedItems([...selectedRows]);
|
|
3454
|
+
}
|
|
3455
|
+
else {
|
|
3456
|
+
setExternallySelectedItemsAreInSync(true);
|
|
3457
|
+
}
|
|
3075
3458
|
}
|
|
3076
3459
|
else {
|
|
3077
3460
|
setExternallySelectedItemsAreInSync(true);
|
|
3078
3461
|
}
|
|
3079
|
-
}, [
|
|
3462
|
+
}, [
|
|
3463
|
+
externalSelectedIds,
|
|
3464
|
+
externalSelectedItems,
|
|
3465
|
+
setExternalSelectedIds,
|
|
3466
|
+
setExternalSelectedItems,
|
|
3467
|
+
setExternallySelectedItemsAreInSync,
|
|
3468
|
+
]);
|
|
3080
3469
|
/**
|
|
3081
3470
|
* Synchronise externally selected items to grid.
|
|
3082
3471
|
* If new ids are selected scroll them into view.
|
|
@@ -3084,19 +3473,26 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3084
3473
|
const synchroniseExternallySelectedItemsToGrid = useCallback(() => {
|
|
3085
3474
|
if (!gridReady)
|
|
3086
3475
|
return;
|
|
3087
|
-
if (!
|
|
3476
|
+
if (!externalSelectedItems && !externalSelectedIds) {
|
|
3088
3477
|
setExternallySelectedItemsAreInSync(true);
|
|
3089
3478
|
return;
|
|
3090
3479
|
}
|
|
3091
|
-
const selectedIds =
|
|
3092
|
-
const lastNewId = last(difference(selectedIds, lastSelectedIds.current));
|
|
3480
|
+
const selectedIds = externalSelectedIds ?? externalSelectedItems?.map((row) => row.id);
|
|
3481
|
+
const lastNewId = last(difference(selectedIds, lastSelectedIds.current ?? []));
|
|
3093
3482
|
if (lastNewId != null) {
|
|
3094
3483
|
ensureRowVisible(lastNewId);
|
|
3095
3484
|
}
|
|
3096
3485
|
lastSelectedIds.current = selectedIds;
|
|
3097
3486
|
selectRowsById(selectedIds);
|
|
3098
3487
|
setExternallySelectedItemsAreInSync(true);
|
|
3099
|
-
}, [
|
|
3488
|
+
}, [
|
|
3489
|
+
gridReady,
|
|
3490
|
+
externalSelectedItems,
|
|
3491
|
+
externalSelectedIds,
|
|
3492
|
+
selectRowsById,
|
|
3493
|
+
setExternallySelectedItemsAreInSync,
|
|
3494
|
+
ensureRowVisible,
|
|
3495
|
+
]);
|
|
3100
3496
|
/**
|
|
3101
3497
|
* Combine grid and cell editable into one function
|
|
3102
3498
|
*/
|
|
@@ -3138,7 +3534,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3138
3534
|
const columnDefs = useMemo(() => {
|
|
3139
3535
|
return params.columnDefs.map(mapColDef);
|
|
3140
3536
|
}, [params.columnDefs, mapColDef]);
|
|
3141
|
-
const hasExternallySelectedItems = !!
|
|
3537
|
+
const hasExternallySelectedItems = !!setExternalSelectedItems || !!setExternalSelectedIds;
|
|
3142
3538
|
/**
|
|
3143
3539
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
3144
3540
|
*/
|
|
@@ -3194,15 +3590,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3194
3590
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3195
3591
|
}
|
|
3196
3592
|
}, [startCellEditing]);
|
|
3197
|
-
/**
|
|
3198
|
-
* Handle single click edits
|
|
3199
|
-
*/
|
|
3200
|
-
const onCellClicked = useCallback((event) => {
|
|
3201
|
-
const editable = fnOrVar(event.colDef?.editable, event);
|
|
3202
|
-
if ((editable && event.colDef.singleClickEdit) ?? singleClickEdit) {
|
|
3203
|
-
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3204
|
-
}
|
|
3205
|
-
}, [singleClickEdit, startCellEditing]);
|
|
3206
3593
|
const onCellEditingStopped = useCallback((event) => {
|
|
3207
3594
|
if (!startedEditRef.current) {
|
|
3208
3595
|
return;
|
|
@@ -3251,6 +3638,78 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3251
3638
|
prePopupOps();
|
|
3252
3639
|
}
|
|
3253
3640
|
}, [prePopupOps, startCellEditing]);
|
|
3641
|
+
const { cellContextMenu, contextMenuComponent } = useGridContextMenu({
|
|
3642
|
+
contextMenu,
|
|
3643
|
+
contextMenuSelectRow,
|
|
3644
|
+
});
|
|
3645
|
+
const hasSelectedMoreThanOneCellRef = useRef(false);
|
|
3646
|
+
const rangeStartRef = useRef(null);
|
|
3647
|
+
const rangeEndRef = useRef(null);
|
|
3648
|
+
const rangeSortedNodesRef = useRef(null);
|
|
3649
|
+
const { clearRangeSelection, ranges, onCellMouseDown, onCellMouseOver } = useGridRangeSelection({
|
|
3650
|
+
enableRangeSelection,
|
|
3651
|
+
gridDivRef,
|
|
3652
|
+
rangeStartRef,
|
|
3653
|
+
rangeEndRef,
|
|
3654
|
+
hasSelectedMoreThanOneCellRef,
|
|
3655
|
+
rangeSortedNodesRef,
|
|
3656
|
+
});
|
|
3657
|
+
const { onCopyEvent, rangeSelectInterceptContextMenu, rangeSelectContextMenuComponent } = useGridCopy({
|
|
3658
|
+
ranges,
|
|
3659
|
+
rangeStartRef,
|
|
3660
|
+
rangeEndRef,
|
|
3661
|
+
hasSelectedMoreThanOneCellRef,
|
|
3662
|
+
cellContextMenu,
|
|
3663
|
+
});
|
|
3664
|
+
const onSortChanged = useCallback(() => {
|
|
3665
|
+
clearRangeSelection();
|
|
3666
|
+
ensureSelectedRowIsVisible();
|
|
3667
|
+
}, [clearRangeSelection, ensureSelectedRowIsVisible]);
|
|
3668
|
+
/**
|
|
3669
|
+
* Handle single click edits
|
|
3670
|
+
*/
|
|
3671
|
+
const onCellClicked = useCallback((event) => {
|
|
3672
|
+
if (rangeStartRef.current && rangeEndRef.current) {
|
|
3673
|
+
// This is to detect difference between a single click and a click drag return to cell.
|
|
3674
|
+
if (rangeEndRef.current.timestamp - rangeStartRef.current.timestamp < 100) {
|
|
3675
|
+
clearRangeSelection();
|
|
3676
|
+
}
|
|
3677
|
+
return;
|
|
3678
|
+
}
|
|
3679
|
+
const editable = fnOrVar(event.colDef?.editable, event);
|
|
3680
|
+
if ((editable && event.colDef.singleClickEdit) ?? singleClickEdit) {
|
|
3681
|
+
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3682
|
+
}
|
|
3683
|
+
}, [clearRangeSelection, singleClickEdit, startCellEditing]);
|
|
3684
|
+
/**
|
|
3685
|
+
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
3686
|
+
*/
|
|
3687
|
+
const userSizedColIds = useRef(new Map());
|
|
3688
|
+
/**
|
|
3689
|
+
* Lock/unlock column width on user edit/reset.
|
|
3690
|
+
*/
|
|
3691
|
+
const onColumnResized = useCallback((e) => {
|
|
3692
|
+
const colId = e.column?.getColId();
|
|
3693
|
+
if (colId == null) {
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
const width = e.column?.getActualWidth();
|
|
3697
|
+
if (width == null) {
|
|
3698
|
+
return;
|
|
3699
|
+
}
|
|
3700
|
+
switch (e.source) {
|
|
3701
|
+
case 'uiColumnResized':
|
|
3702
|
+
userSizedColIds.current.set(colId, width);
|
|
3703
|
+
break;
|
|
3704
|
+
case 'autosizeColumns':
|
|
3705
|
+
userSizedColIds.current.delete(colId);
|
|
3706
|
+
break;
|
|
3707
|
+
}
|
|
3708
|
+
}, []);
|
|
3709
|
+
const columnMoved = useCallback((e) => {
|
|
3710
|
+
clearRangeSelection();
|
|
3711
|
+
onColumnMoved?.(e);
|
|
3712
|
+
}, [clearRangeSelection, onColumnMoved]);
|
|
3254
3713
|
/**
|
|
3255
3714
|
* Once the grid has auto-sized we want to run fit to fit the grid in its container,
|
|
3256
3715
|
* but we don't want the non-flex auto-sized columns to "fit" size, so suppressSizeToFit is set to true.
|
|
@@ -3268,7 +3727,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3268
3727
|
let comparator = colDef.comparator;
|
|
3269
3728
|
if (sortable && !comparator) {
|
|
3270
3729
|
comparator = (value1, value2, node1, node2) => {
|
|
3271
|
-
let r
|
|
3730
|
+
let r;
|
|
3272
3731
|
if (typeof valueFormatter === 'function') {
|
|
3273
3732
|
r = compareNaturalInsensitive(valueFormatter({
|
|
3274
3733
|
data: node1.data,
|
|
@@ -3358,37 +3817,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3358
3817
|
}
|
|
3359
3818
|
prevLoading.current = newLoading;
|
|
3360
3819
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
3361
|
-
/**
|
|
3362
|
-
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
3363
|
-
*/
|
|
3364
|
-
const userSizedColIds = useRef(new Map());
|
|
3365
|
-
/**
|
|
3366
|
-
* Lock/unlock column width on user edit/reset.
|
|
3367
|
-
*/
|
|
3368
|
-
const onColumnResized = useCallback((e) => {
|
|
3369
|
-
const colId = e.column?.getColId();
|
|
3370
|
-
if (colId == null) {
|
|
3371
|
-
return;
|
|
3372
|
-
}
|
|
3373
|
-
const width = e.column?.getActualWidth();
|
|
3374
|
-
if (width == null) {
|
|
3375
|
-
return;
|
|
3376
|
-
}
|
|
3377
|
-
switch (e.source) {
|
|
3378
|
-
case 'uiColumnResized':
|
|
3379
|
-
userSizedColIds.current.set(colId, width);
|
|
3380
|
-
/*const colDef = e.column?.getColDef();
|
|
3381
|
-
if (!colDef?.flex) {
|
|
3382
|
-
onGridResize(e);
|
|
3383
|
-
}*/
|
|
3384
|
-
break;
|
|
3385
|
-
case 'autosizeColumns':
|
|
3386
|
-
userSizedColIds.current.delete(colId);
|
|
3387
|
-
//onGridResize(e);
|
|
3388
|
-
break;
|
|
3389
|
-
}
|
|
3390
|
-
}, []);
|
|
3391
|
-
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
3392
3820
|
const startDragYRef = useRef(null);
|
|
3393
3821
|
const clearHighlightRowClasses = useCallback(() => {
|
|
3394
3822
|
document.querySelectorAll(`.ag-row-highlight-above`)?.forEach((el) => {
|
|
@@ -3465,11 +3893,14 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3465
3893
|
}
|
|
3466
3894
|
}, [params, clearHighlightRowClasses]);
|
|
3467
3895
|
useEffect(() => {
|
|
3468
|
-
if (
|
|
3469
|
-
console.warn('<Grid/> has setExternalSelectedItems parameter, but is missing selectable parameter,' +
|
|
3896
|
+
if ((setExternalSelectedItems || setExternalSelectedIds) && selectable == null) {
|
|
3897
|
+
console.warn('<Grid/> has setExternalSelectedItems/setExternalSelectedIds parameter, but is missing selectable parameter,' +
|
|
3470
3898
|
'this will cause weird delays in editing.\nIf you need to hide selection column use hideSelectColumn=true');
|
|
3471
3899
|
}
|
|
3472
|
-
},
|
|
3900
|
+
},
|
|
3901
|
+
// Only needs to run on startup
|
|
3902
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3903
|
+
[selectable]);
|
|
3473
3904
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
3474
3905
|
setOnBulkEditingComplete(params.onBulkEditingComplete);
|
|
3475
3906
|
const getRowId = useCallback((params) => `${params.data.id}`, []);
|
|
@@ -3513,25 +3944,24 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3513
3944
|
}
|
|
3514
3945
|
return false;
|
|
3515
3946
|
},
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3947
|
+
// enableClickSelection = true means ag-grid auto selects row if you click outside the checkbox
|
|
3948
|
+
// if it's false we have to do it.
|
|
3949
|
+
onCellClicked: params.enableClickSelection ? undefined : clickInputWhenContainingCellClicked,
|
|
3519
3950
|
};
|
|
3520
3951
|
}, [
|
|
3521
|
-
params.enableClickSelection,
|
|
3522
|
-
params.enableSelectionWithoutKeys,
|
|
3523
3952
|
params.hideSelectColumn,
|
|
3524
3953
|
params.onRowDragEnd,
|
|
3525
3954
|
rowSelection,
|
|
3526
3955
|
selectColumnPinned,
|
|
3527
3956
|
selectable,
|
|
3957
|
+
params.enableClickSelection,
|
|
3528
3958
|
]);
|
|
3529
3959
|
const onGridSizeChanged = useCallback((event) => {
|
|
3530
3960
|
if (sizeColumns === 'fit' || (['auto', 'auto-skip-headers'].includes(sizeColumns) && hasSetContentSize.current)) {
|
|
3531
3961
|
event.api.sizeColumnsToFit();
|
|
3532
3962
|
}
|
|
3533
3963
|
}, [sizeColumns]);
|
|
3534
|
-
return (jsxs("div", { "data-testid": dataTestId, className: clsx('Grid-container', theme, 'theme-specific', staleGrid && 'Grid-sortIsStale', gridReady && rowData && autoSized && 'Grid-ready'), children: [
|
|
3964
|
+
return (jsxs("div", { "data-testid": dataTestId, className: clsx('Grid-container', theme, 'theme-specific', staleGrid && 'Grid-sortIsStale', gridReady && rowData && autoSized && 'Grid-ready'), children: [contextMenuComponent, rangeSelectContextMenuComponent, jsx("div", { style: { flex: 1 }, ref: gridDivRef, onCopy: onCopyEvent, children: jsx(AgGridReact, { theme: 'legacy', domLayout: params.domLayout, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, getRowId: getRowId, rowData: rowData, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, animateRows: params.animateRows ?? false, doesExternalFilterPass: doesExternalFilterPass, isExternalFilterPresent: isExternalFilterPresent, maintainColumnOrder: true, noRowsOverlayComponent: noRowsOverlayComponent, onCellClicked: onCellClicked, onCellContextMenu: rangeSelectInterceptContextMenu, onCellDoubleClicked: onCellDoubleClick, onCellEditingStopped: onCellEditingStopped, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellMouseDown: onCellMouseDown, onCellMouseOver: onCellMouseOver, onColumnMoved: columnMoved, onColumnResized: onColumnResized, onColumnVisible: () => void setInitialContentSize(), onGridReady: onGridReady, onGridSizeChanged: onGridSizeChanged, onModelUpdated: onModelUpdated, onRowClicked: params.onRowClicked, onRowDataUpdated: onRowDataUpdated, onRowDoubleClicked: params.onRowDoubleClicked, onRowDragCancel: clearHighlightRowClasses, onRowDragEnd: onRowDragEnd, onRowDragMove: onRowDragMove, onSelectionChanged: synchroniseExternalStateToGridSelection, onSortChanged: onSortChanged, pinnedBottomRowData: params.pinnedBottomRowData, pinnedTopRowData: params.pinnedTopRowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, preventDefaultOnContextMenu: true, quickFilterParser: quickFilterParser, rowClassRules: params.rowClassRules, rowDragText: params.rowDragText, rowHeight: rowHeight, rowSelection: selectable
|
|
3535
3965
|
? {
|
|
3536
3966
|
enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
|
|
3537
3967
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
@@ -3541,7 +3971,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3541
3971
|
headerCheckbox: false,
|
|
3542
3972
|
}),
|
|
3543
3973
|
}
|
|
3544
|
-
: undefined, selectionColumnDef: selectionColumnDef,
|
|
3974
|
+
: undefined, selectionColumnDef: selectionColumnDef, suppressCellFocus: params.suppressCellFocus, suppressClickEdit: true, suppressColumnVirtualisation: suppressColumnVirtualization, suppressStartEditOnTab: true }) })] }));
|
|
3545
3975
|
};
|
|
3546
3976
|
const quickFilterParser = (filterStr) => {
|
|
3547
3977
|
// filter is exact matches exactly groups separated by commas
|
|
@@ -3782,33 +4212,6 @@ const GridFilterButtons = ({ className, luiButtonProps, options, }) => {
|
|
|
3782
4212
|
return (jsx("div", { className: clsx(className, 'flex-col-center'), children: jsx(LuiButtonGroup, { children: options.map((option, index) => (jsx(LuiButton, { ...luiButtonProps, className: clsx(`lui-button lui-button-secondary`, selectedOption?.label === option.label && `lui-button-active`, luiButtonProps?.className), onClick: () => setSelectedOption(option), children: option.label }, `${index}`))) }) }));
|
|
3783
4213
|
};
|
|
3784
4214
|
|
|
3785
|
-
function styleInject(css, ref) {
|
|
3786
|
-
if ( ref === void 0 ) ref = {};
|
|
3787
|
-
var insertAt = ref.insertAt;
|
|
3788
|
-
|
|
3789
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
3790
|
-
|
|
3791
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3792
|
-
var style = document.createElement('style');
|
|
3793
|
-
style.type = 'text/css';
|
|
3794
|
-
|
|
3795
|
-
if (insertAt === 'top') {
|
|
3796
|
-
if (head.firstChild) {
|
|
3797
|
-
head.insertBefore(style, head.firstChild);
|
|
3798
|
-
} else {
|
|
3799
|
-
head.appendChild(style);
|
|
3800
|
-
}
|
|
3801
|
-
} else {
|
|
3802
|
-
head.appendChild(style);
|
|
3803
|
-
}
|
|
3804
|
-
|
|
3805
|
-
if (style.styleSheet) {
|
|
3806
|
-
style.styleSheet.cssText = css;
|
|
3807
|
-
} else {
|
|
3808
|
-
style.appendChild(document.createTextNode(css));
|
|
3809
|
-
}
|
|
3810
|
-
}
|
|
3811
|
-
|
|
3812
4215
|
var css_248z$3 = ".GridFilterColsMultiSelect{background:#fff;font-family:Open Sans,system-ui,sans-serif;font-style:normal;font-weight:600;padding:8px}.GridFilterColsMultiSelect .LuiSelect-label-text{color:#6b6966;display:inline-block}.GridFilterColsMultiSelect .LuiCheckboxInput-item,.GridFilterColsMultiSelect .LuiCheckboxInput-selectAll{color:#2a292c;font-size:16px;font-weight:600;letter-spacing:0;line-height:20px;line-height:24px;margin-bottom:0}";
|
|
3813
4216
|
styleInject(css_248z$3);
|
|
3814
4217
|
|
|
@@ -4616,14 +5019,14 @@ const TextInputFormatted = (props) => {
|
|
|
4616
5019
|
|
|
4617
5020
|
const bearingValueFormatter = (value) => {
|
|
4618
5021
|
const safeValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
4619
|
-
if (safeValue == null) {
|
|
5022
|
+
if (safeValue == null || Number.isNaN(safeValue)) {
|
|
4620
5023
|
return '–';
|
|
4621
5024
|
}
|
|
4622
5025
|
return convertDDToDMS(safeValue, false);
|
|
4623
5026
|
};
|
|
4624
5027
|
const bearingCorrectionValueFormatter = (value) => {
|
|
4625
5028
|
const safeValue = value;
|
|
4626
|
-
if (safeValue == null) {
|
|
5029
|
+
if (safeValue == null || Number.isNaN(safeValue)) {
|
|
4627
5030
|
return '–';
|
|
4628
5031
|
}
|
|
4629
5032
|
if (typeof safeValue === 'string') {
|
|
@@ -5419,6 +5822,7 @@ const GridPopoutEditMultiSelectGrid = (colDef, props) => GridCell(colDef, {
|
|
|
5419
5822
|
},
|
|
5420
5823
|
});
|
|
5421
5824
|
|
|
5825
|
+
const GridCellBearingValueFormatter = (params) => bearingValueFormatter(params.value) ?? '';
|
|
5422
5826
|
const GridPopoverEditBearingLike = (colDef, props) => GridCell({
|
|
5423
5827
|
valueFormatter: (params) => props.editorParams?.formatValue(params.value) ?? '',
|
|
5424
5828
|
...colDef,
|
|
@@ -5571,6 +5975,7 @@ const GridContextProvider = (props) => {
|
|
|
5571
5975
|
}
|
|
5572
5976
|
return gridApi && !gridApi.isDestroyed() ? hasApiFn(gridApi) : noApiFn();
|
|
5573
5977
|
}, [gridApi]);
|
|
5978
|
+
const getCellValue = useCallback((...props) => gridApi?.getCellValue(...props), [gridApi]);
|
|
5574
5979
|
/**
|
|
5575
5980
|
* Scroll row into view by Id.
|
|
5576
5981
|
*
|
|
@@ -5730,7 +6135,7 @@ const GridContextProvider = (props) => {
|
|
|
5730
6135
|
// It may be that the first cell is the selection cell, this doesn't exist as a colDef
|
|
5731
6136
|
// so instead, I just try and select it. If it doesn't exist selection will stay on the
|
|
5732
6137
|
// previously focused cell
|
|
5733
|
-
gridApi.setFocusedCell(rowIndex,
|
|
6138
|
+
gridApi.setFocusedCell(rowIndex, agGridSelectRowColId);
|
|
5734
6139
|
}
|
|
5735
6140
|
}, 100);
|
|
5736
6141
|
}
|
|
@@ -6169,6 +6574,7 @@ const GridContextProvider = (props) => {
|
|
|
6169
6574
|
getSelectedRowIds,
|
|
6170
6575
|
getFilteredSelectedRowIds,
|
|
6171
6576
|
getFirstRowId,
|
|
6577
|
+
getCellValue,
|
|
6172
6578
|
editingCells,
|
|
6173
6579
|
ensureRowVisible,
|
|
6174
6580
|
ensureSelectedRowIsVisible,
|
|
@@ -6348,5 +6754,5 @@ const useDeferredPromise = () => {
|
|
|
6348
6754
|
};
|
|
6349
6755
|
};
|
|
6350
6756
|
|
|
6351
|
-
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, colStateFlexed, colStateId, colStateNotFlexed, compareNaturalInsensitive, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6757
|
+
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellBearingValueFormatter, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, agGridSelectRowColId, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, colStateFlexed, colStateId, colStateNotFlexed, compareNaturalInsensitive, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6352
6758
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|