@linzjs/step-ag-grid 29.1.1 → 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.
- package/dist/src/components/GridPopoverHook.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/waitForCondition.d.ts +1 -0
- package/dist/step-ag-grid.cjs +25 -20
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +25 -21
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +17 -12
- package/src/contexts/GridContextProvider.tsx +10 -14
- package/src/index.ts +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +3 -11
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +3 -10
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +3 -10
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +8 -10
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +3 -10
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +3 -10
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +3 -10
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +3 -10
- package/src/utils/waitForCondition.tsx +13 -0
|
@@ -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>(
|
|
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
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const waitForCondition: (condition: () => boolean, timeoutMs: number) => Promise<boolean>;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -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 = (
|
|
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 (
|
|
3956
|
+
if (invalid?.()) {
|
|
3956
3957
|
// Don't close, don't do anything it's invalid
|
|
3957
3958
|
return;
|
|
3958
3959
|
}
|
|
3959
|
-
if (!
|
|
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(
|
|
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,
|
|
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:
|
|
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 (
|
|
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,
|
|
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
|