@linzjs/step-ag-grid 16.0.0 → 17.0.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.
Files changed (102) hide show
  1. package/dist/GridTheme.scss +138 -106
  2. package/dist/index.css +1 -8
  3. package/dist/node_modules/@linzjs/lui/dist/assets/svg-content.d.ts +7 -0
  4. package/dist/src/components/ComponentLoadingWrapper.d.ts +3 -4
  5. package/dist/src/components/Grid.d.ts +2 -2
  6. package/dist/src/components/GridCell.d.ts +5 -5
  7. package/dist/src/components/GridCellMultiEditor.d.ts +2 -2
  8. package/dist/src/components/GridNoRowsOverlay.d.ts +3 -2
  9. package/dist/src/components/GridPopoverHook.d.ts +3 -3
  10. package/dist/src/components/GridWrapper.d.ts +2 -3
  11. package/dist/src/components/PostSortRowsHook.d.ts +1 -1
  12. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +2 -2
  13. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +2 -2
  14. package/dist/src/components/gridFilter/GridFilters.d.ts +2 -5
  15. package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -2
  16. package/dist/src/components/gridForm/GridFormMessage.d.ts +2 -2
  17. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +2 -2
  18. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +3 -3
  19. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +2 -2
  20. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +2 -2
  21. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -2
  22. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +2 -2
  23. package/dist/src/contexts/GridContext.d.ts +4 -4
  24. package/dist/src/contexts/GridContextProvider.d.ts +2 -6
  25. package/dist/src/contexts/GridPopoverContextProvider.d.ts +2 -3
  26. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +2 -6
  27. package/dist/src/lui/ActionButton.d.ts +2 -2
  28. package/dist/src/lui/FormError.d.ts +2 -2
  29. package/dist/src/lui/TextAreaInput.d.ts +3 -3
  30. package/dist/src/lui/TextInputFormatted.d.ts +3 -3
  31. package/dist/src/react-menu3/components/FocusableItem.d.ts +2 -2
  32. package/dist/src/react-menu3/utils/withHovering.d.ts +2 -2
  33. package/dist/src/utils/textValidator.d.ts +3 -3
  34. package/dist/step-ag-grid.cjs.js +31 -15
  35. package/dist/step-ag-grid.cjs.js.map +1 -1
  36. package/dist/step-ag-grid.esm.js +31 -15
  37. package/dist/step-ag-grid.esm.js.map +1 -1
  38. package/package.json +45 -45
  39. package/src/components/ComponentLoadingWrapper.tsx +9 -6
  40. package/src/components/Grid.tsx +19 -10
  41. package/src/components/GridCell.tsx +5 -5
  42. package/src/components/GridCellMultiEditor.tsx +2 -2
  43. package/src/components/GridNoRowsOverlay.tsx +4 -2
  44. package/src/components/GridPopoverHook.tsx +4 -4
  45. package/src/components/GridWrapper.tsx +2 -3
  46. package/src/components/PostSortRowsHook.ts +4 -4
  47. package/src/components/gridFilter/GridFilterButtons.tsx +2 -2
  48. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -2
  49. package/src/components/gridFilter/GridFilters.tsx +4 -6
  50. package/src/components/gridForm/GridFormDropDown.tsx +4 -4
  51. package/src/components/gridForm/GridFormMessage.tsx +3 -3
  52. package/src/components/gridForm/GridFormMultiSelect.tsx +2 -1
  53. package/src/components/gridForm/GridFormPopoverMenu.tsx +4 -4
  54. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +2 -2
  55. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +2 -2
  56. package/src/components/gridForm/GridFormTextArea.tsx +2 -2
  57. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -1
  58. package/src/components/gridRender/GridRenderGenericCell.tsx +2 -1
  59. package/src/contexts/GridContext.tsx +4 -4
  60. package/src/contexts/GridContextProvider.tsx +26 -20
  61. package/src/contexts/GridPopoverContextProvider.tsx +2 -3
  62. package/src/contexts/GridUpdatingContextProvider.tsx +2 -6
  63. package/src/lui/ActionButton.tsx +2 -2
  64. package/src/lui/FormError.tsx +3 -1
  65. package/src/lui/TextAreaInput.tsx +3 -3
  66. package/src/lui/TextInputFormatted.tsx +3 -3
  67. package/src/lui/reactUtils.test.tsx +3 -3
  68. package/src/react-menu3/components/FocusableItem.tsx +2 -2
  69. package/src/react-menu3/utils/utils.ts +1 -1
  70. package/src/react-menu3/utils/withHovering.tsx +2 -2
  71. package/src/stories/grid/FormTest.tsx +2 -2
  72. package/src/stories/grid/GridFilterButtons.stories.tsx +8 -1
  73. package/src/stories/grid/GridNoRowsOverlay.stories.tsx +8 -8
  74. package/src/stories/grid/GridNonEditableRow.stories.tsx +9 -2
  75. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +8 -1
  76. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +8 -1
  77. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +8 -1
  78. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +7 -0
  79. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +7 -0
  80. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +7 -0
  81. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +8 -0
  82. package/src/stories/grid/GridReadOnly.stories.tsx +10 -2
  83. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +2 -2
  84. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +7 -2
  85. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +7 -2
  86. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -1
  87. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +2 -2
  88. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +4 -3
  89. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +3 -3
  90. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +3 -3
  91. package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +1 -1
  92. package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +1 -1
  93. package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +1 -1
  94. package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +2 -2
  95. package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +1 -1
  96. package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +1 -1
  97. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +4 -0
  98. package/src/styles/ComponentLoadingWrapper.scss +1 -4
  99. package/src/styles/Grid.scss +0 -4
  100. package/src/styles/GridTheme.scss +138 -106
  101. package/src/utils/testUtil.ts +3 -0
  102. package/src/utils/textValidator.ts +3 -1
@@ -872,6 +872,10 @@ const getEndStatus = (status, unmountOnExit) => {
872
872
  }
873
873
  };
874
874
  const getTimeout = timeout => typeof timeout === 'object' ? [timeout.enter, timeout.exit] : [timeout, timeout];
875
+ const nextTick = (transitState, status) => setTimeout(() => {
876
+ // Reading document.body.offsetTop can force browser to repaint before transition to the next state
877
+ isNaN(document.body.offsetTop) || transitState(status + 1);
878
+ }, 0);
875
879
 
876
880
  const updateState = (status, setState, latestState, timeoutId, onChange) => {
877
881
  clearTimeout(timeoutId.current);
@@ -913,7 +917,7 @@ const useTransition = ({
913
917
  break;
914
918
  case PRE_ENTER:
915
919
  case PRE_EXIT:
916
- timeoutId.current = setTimeout(() => transitState(status + 1), 0);
920
+ timeoutId.current = nextTick(transitState, status);
917
921
  break;
918
922
  }
919
923
  };
@@ -2316,13 +2320,14 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
2316
2320
  /**
2317
2321
  * Wrapper for AgGrid to add commonly used functionality.
2318
2322
  */
2319
- const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-alpine", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, ...params }) => {
2323
+ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, ...params }) => {
2320
2324
  const { gridReady, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, } = useContext(GridContext);
2321
2325
  const { checkUpdating, updatedDep, updatingCols } = useContext(GridUpdatingContext);
2322
2326
  const { prePopupOps } = useContext(GridContext);
2323
2327
  const gridDivRef = useRef(null);
2324
2328
  const lastSelectedIds = useRef([]);
2325
2329
  const [staleGrid, setStaleGrid] = useState(false);
2330
+ const [autoSized, setAutoSized] = useState(false);
2326
2331
  const postSortRows = usePostSortRowsHook({ setStaleGrid });
2327
2332
  /**
2328
2333
  * onContentSize should only be called at maximum twice.
@@ -2364,6 +2369,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2364
2369
  if (sizeColumns !== "none") {
2365
2370
  sizeColumnsToFit();
2366
2371
  }
2372
+ setAutoSized(true);
2367
2373
  needsAutoSize.current = false;
2368
2374
  }, [autoSizeColumns, params, sizeColumns, sizeColumnsToFit]);
2369
2375
  const lastOwnerDocumentRef = useRef();
@@ -2706,7 +2712,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2706
2712
  }
2707
2713
  }, [sizeColumns, sizeColumnsToFit]);
2708
2714
  /**
2709
- * Set of column Id's that are prevented from auto-sizing as they are user set
2715
+ * Set of column I'd's that are prevented from auto-sizing as they are user set
2710
2716
  */
2711
2717
  const userSizedColIds = useRef(new Set());
2712
2718
  /**
@@ -2728,9 +2734,9 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2728
2734
  const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
2729
2735
  // This is setting a ref in the GridContext so won't be triggering an update loop
2730
2736
  setOnCellEditingComplete(params.onCellEditingComplete);
2731
- return (jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready"), children: [gridContextMenu.component, jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsx(AgGridReact, { rowHeight: params.rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2737
+ return (jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsx(AgGridReact, { rowHeight: params.rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2732
2738
  setInitialContentSize();
2733
- }, onRowDataChanged: onRowDataChanged, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: { minWidth: 48, ...omit(params.defaultColDef, ["editable"]) }, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: (event) => {
2739
+ }, onRowDataUpdated: onRowDataChanged, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: { minWidth: 48, ...omit(params.defaultColDef, ["editable"]) }, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: (event) => {
2734
2740
  let rowCount = 0;
2735
2741
  event.api.forEachNode(() => rowCount++);
2736
2742
  return (jsx(GridNoRowsOverlay, { rowCount: rowCount, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText }));
@@ -3044,7 +3050,7 @@ const GridFilterQuick = ({ quickFilterPlaceholder, defaultValue }) => {
3044
3050
  } }) }));
3045
3051
  };
3046
3052
 
3047
- const GridFilters = ({ children }) => jsx("div", { className: "Grid-container-filters", children: children });
3053
+ const GridFilters = ({ children }) => (jsx("div", { className: "Grid-container-filters", children: children }));
3048
3054
 
3049
3055
  /**
3050
3056
  * Defers state change up to a minimum time since last state change.
@@ -4420,7 +4426,7 @@ const GridPopoverEditDropDown = (colDef, props) => GridCell(colDef, {
4420
4426
  });
4421
4427
 
4422
4428
  const GridPopoverMessage = (colDef, props) => GridCell({
4423
- resizable: false,
4429
+ resizable: true,
4424
4430
  ...colDef,
4425
4431
  cellRendererParams: {
4426
4432
  singleClickEdit: true,
@@ -4605,7 +4611,13 @@ const GridContextProvider = (props) => {
4605
4611
  const gridHasNotUpdated = gridRowIdsNotUpdatedYet || gridRowIdsNotChangedYet;
4606
4612
  // After retry count expires we give-up and deselect all rows, then select any subset of rows that have updated
4607
4613
  if (gridHasNotUpdated && retryCount > 0) {
4608
- delay(() => _selectRowsWithOptionalFlash({ rowIds, select, flash, ifNoCellFocused, retryCount: retryCount - 1 }), 250);
4614
+ delay(() => _selectRowsWithOptionalFlash({
4615
+ rowIds,
4616
+ select,
4617
+ flash,
4618
+ ifNoCellFocused,
4619
+ retryCount: retryCount - 1,
4620
+ }), 250);
4609
4621
  return;
4610
4622
  }
4611
4623
  const rowsThatNeedSelecting = sortBy(rowNodes.filter((node) => !node.isSelected()), (node) => node.data.id);
@@ -4706,13 +4718,14 @@ const GridContextProvider = (props) => {
4706
4718
  const autoSizeColumns = useCallback(({ skipHeader, colIds, userSizedColIds } = {}) => {
4707
4719
  if (!columnApi)
4708
4720
  return null;
4709
- const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds ?? []);
4710
- columnApi.getColumnState().forEach((col) => {
4711
- const colId = col.colId;
4712
- if ((isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId)) {
4713
- columnApi.autoSizeColumn(colId, skipHeader);
4714
- }
4721
+ const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
4722
+ const colsToResize = columnApi.getColumnState().filter((colState) => {
4723
+ const colId = colState.colId;
4724
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId) && !colState.flex;
4715
4725
  });
4726
+ if (!isEmpty(colsToResize)) {
4727
+ columnApi.autoSizeColumns(colsToResize.map((colState) => colState.colId), skipHeader);
4728
+ }
4716
4729
  return {
4717
4730
  width: sumBy(columnApi.getColumnState().filter((col) => !col.hide), "width"),
4718
4731
  };
@@ -4721,7 +4734,7 @@ const GridContextProvider = (props) => {
4721
4734
  * Resize columns to fit container
4722
4735
  */
4723
4736
  const sizeColumnsToFit = useCallback(() => {
4724
- gridApi && gridApi.sizeColumnsToFit();
4737
+ gridApi?.sizeColumnsToFit();
4725
4738
  }, [gridApi]);
4726
4739
  const stopEditing = useCallback(() => {
4727
4740
  if (!gridApi)
@@ -25490,6 +25503,9 @@ const countRows = async (within) => {
25490
25503
  return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
25491
25504
  };
25492
25505
  const findRow = async (rowId, within) => {
25506
+ await waitForWrapper(async () => {
25507
+ expect(getAllQuick({ classes: ".ag-row" }).length > 0).toBe(true);
25508
+ });
25493
25509
  return await findQuick({ tagName: `div[row-id='${rowId}']:not(:empty)` }, within);
25494
25510
  };
25495
25511
  const queryRow = async (rowId, within) => {