@linzjs/step-ag-grid 29.1.0 → 29.1.2

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.
@@ -6,7 +6,7 @@ export interface GridPopoverHookProps<TData> {
6
6
  save?: (selectedRows: TData[]) => Promise<boolean>;
7
7
  dontSaveOnExternalClick?: boolean;
8
8
  }
9
- export declare const useGridPopoverHook: <TData extends GridBaseRow>(props: GridPopoverHookProps<TData>) => {
9
+ export declare const useGridPopoverHook: <TData extends GridBaseRow>({ className, save, invalid, dontSaveOnExternalClick, }: GridPopoverHookProps<TData>) => {
10
10
  popoverWrapper: (children: ReactElement) => import("react/jsx-runtime").JSX.Element;
11
11
  triggerSave: (reason?: string) => Promise<void>;
12
12
  };
@@ -17,3 +17,4 @@ export * from './utils/deferredPromise';
17
17
  export * from './utils/textMatcher';
18
18
  export * from './utils/textValidator';
19
19
  export * from './utils/util';
20
+ export * from './utils/waitForCondition';
@@ -15,7 +15,7 @@ export const setUpUserEvent = (customisedUserEvent: any) => {
15
15
  };
16
16
 
17
17
  export const countRows = (within?: HTMLElement): number => {
18
- return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
18
+ return getAllQuick({ tagName: `.ag-center-cols-container div[row-id]:not(:empty)` }, within).length;
19
19
  };
20
20
 
21
21
  export const findRowByIndex = async (rowIndex: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
@@ -16,7 +16,7 @@ export const setUpUserEvent = (customisedUserEvent: any) => {
16
16
  };
17
17
 
18
18
  export const countRows = (within?: HTMLElement): number => {
19
- return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
19
+ return getAllQuick({ tagName: `.ag-center-cols-container div[row-id]:not(:empty)` }, within).length;
20
20
  };
21
21
 
22
22
  export const findRowByIndex = async (rowIndex: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
@@ -0,0 +1 @@
1
+ export declare const waitForCondition: (condition: () => boolean, timeoutMs: number) => Promise<boolean>;
@@ -3938,8 +3938,8 @@ const textMatch = (text, filter) => {
3938
3938
  negativeFilters.every((superFilter) => values.every((value) => isMatch(value, superFilter)))));
3939
3939
  };
3940
3940
 
3941
- const useGridPopoverHook = (props) => {
3942
- const { onBulkEditingComplete } = useGridContext();
3941
+ const useGridPopoverHook = ({ className, save, invalid, dontSaveOnExternalClick, }) => {
3942
+ const { onBulkEditingComplete, redrawRows } = useGridContext();
3943
3943
  const { anchorRef, saving, updateValue, stopEditing } = useGridPopoverContext();
3944
3944
  const saveButtonRef = React.useRef(null);
3945
3945
  const [isOpen, setOpen] = React.useState(false);
@@ -3950,22 +3950,25 @@ const useGridPopoverHook = (props) => {
3950
3950
  if (reason == CloseReason.CANCEL) {
3951
3951
  stopEditing();
3952
3952
  onBulkEditingComplete();
3953
+ redrawRows();
3953
3954
  return;
3954
3955
  }
3955
- if (props?.invalid?.()) {
3956
+ if (invalid?.()) {
3956
3957
  // Don't close, don't do anything it's invalid
3957
3958
  return;
3958
3959
  }
3959
- if (!props.save) {
3960
+ if (!save) {
3960
3961
  // No save method so just close
3961
3962
  stopEditing();
3962
3963
  onBulkEditingComplete();
3964
+ redrawRows();
3963
3965
  return;
3964
3966
  }
3965
- if (await updateValue(props.save, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)) {
3967
+ if (await updateValue(save, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)) {
3966
3968
  stopEditing();
3969
+ redrawRows();
3967
3970
  }
3968
- }, [onBulkEditingComplete, props, stopEditing, updateValue]);
3971
+ }, [invalid, onBulkEditingComplete, redrawRows, save, stopEditing, updateValue]);
3969
3972
  const popoverWrapper = React.useCallback((children) => {
3970
3973
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: anchorRef.current && (jsxRuntime.jsxs(ControlledMenu, { state: isOpen ? 'open' : 'closed', portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: 'step-ag-grid-react-menu', onClose: (event) => {
3971
3974
  // Prevent menu from closing when modals are invoked
@@ -3973,15 +3976,15 @@ const useGridPopoverHook = (props) => {
3973
3976
  return;
3974
3977
  }
3975
3978
  void triggerSave(event.reason);
3976
- }, viewScroll: 'auto', dontShrinkIfDirectionIsTop: true, className: props.className, children: [saving && ( // This is the overlay that prevents editing when the editor is saving
3979
+ }, viewScroll: 'auto', dontShrinkIfDirectionIsTop: true, className: className, children: [saving && ( // This is the overlay that prevents editing when the editor is saving
3977
3980
  jsxRuntime.jsx("div", { className: 'ComponentLoadingWrapper-saveOverlay' })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, "data-reason": '', onClick: (e) => {
3978
3981
  let reason = e.currentTarget.getAttribute('data-reason') ?? undefined;
3979
- if (props.dontSaveOnExternalClick && reason === CloseReason.BLUR) {
3982
+ if (dontSaveOnExternalClick && reason === CloseReason.BLUR) {
3980
3983
  reason = CloseReason.CANCEL;
3981
3984
  }
3982
3985
  void triggerSave(reason);
3983
3986
  }, style: { display: 'none' } })] })) }));
3984
- }, [anchorRef, isOpen, props.className, props.dontSaveOnExternalClick, saving, triggerSave]);
3987
+ }, [anchorRef, isOpen, className, dontSaveOnExternalClick, saving, triggerSave]);
3985
3988
  return {
3986
3989
  popoverWrapper,
3987
3990
  triggerSave,
@@ -5061,6 +5064,18 @@ const GridWrapper = ({ children, maxHeight }) => (jsxRuntime.jsx("div", { classN
5061
5064
  const getColId = (colDef) => colDef.colId ?? '';
5062
5065
  const isFlexColumn = (colDef) => !!colDef.flex && !isGridCellFiller(colDef);
5063
5066
 
5067
+ const waitForCondition = async (condition, timeoutMs) => {
5068
+ const endTime = Date.now() + timeoutMs;
5069
+ while (Date.now() < endTime) {
5070
+ if (condition()) {
5071
+ return true;
5072
+ }
5073
+ await wait(100);
5074
+ }
5075
+ console.warn('waitForCondition failed');
5076
+ return false;
5077
+ };
5078
+
5064
5079
  /**
5065
5080
  * Context for AgGrid operations.
5066
5081
  * Make sure you wrap AgGrid in this.
@@ -5733,17 +5748,6 @@ const downloadCsvUseValueFormattersProcessCellCallback = (params) => {
5733
5748
  // We add an extra encodeToString here just in case valueFormatter is returning non string values
5734
5749
  return encodeToString(result);
5735
5750
  };
5736
- const waitForCondition = async (condition, timeoutMs) => {
5737
- const endTime = Date.now() + timeoutMs;
5738
- while (Date.now() < endTime) {
5739
- if (condition()) {
5740
- return true;
5741
- }
5742
- await wait(100);
5743
- }
5744
- console.warn('waitForCondition failed');
5745
- return false;
5746
- };
5747
5751
 
5748
5752
  const GridUpdatingContextProvider = (props) => {
5749
5753
  const updatingBlocks = React.useRef({});
@@ -5973,4 +5977,5 @@ exports.useGridPopoverHook = useGridPopoverHook;
5973
5977
  exports.useMenuState = useMenuState;
5974
5978
  exports.usePostSortRowsHook = usePostSortRowsHook;
5975
5979
  exports.wait = wait;
5980
+ exports.waitForCondition = waitForCondition;
5976
5981
  //# sourceMappingURL=step-ag-grid.cjs.map