@linzjs/step-ag-grid 8.3.1 → 8.3.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 -0
- package/dist/step-ag-grid.esm.js +20 -21
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +7 -2
- package/src/components/gridForm/GridFormDropDown.tsx +14 -23
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export interface GridPopoverHookProps<RowType> {
|
|
|
16
16
|
| null
|
|
17
17
|
| undefined;
|
|
18
18
|
save?: (selectedRows: RowType[]) => Promise<boolean>;
|
|
19
|
+
dontSaveOnExternalClick?: boolean;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopoverHookProps<RowType>) => {
|
|
@@ -96,7 +97,11 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
96
97
|
ref={saveButtonRef}
|
|
97
98
|
data-reason={""}
|
|
98
99
|
onClick={(e) => {
|
|
99
|
-
|
|
100
|
+
let reason = e.currentTarget.getAttribute("data-reason") ?? undefined;
|
|
101
|
+
if (props.dontSaveOnExternalClick && reason === CloseReason.BLUR) {
|
|
102
|
+
reason = CloseReason.CANCEL;
|
|
103
|
+
}
|
|
104
|
+
triggerSave(reason).then();
|
|
100
105
|
}}
|
|
101
106
|
style={{ display: "none" }}
|
|
102
107
|
/>
|
|
@@ -105,7 +110,7 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
105
110
|
</>
|
|
106
111
|
);
|
|
107
112
|
},
|
|
108
|
-
[anchorRef, isOpen, props.className, saving, triggerSave],
|
|
113
|
+
[anchorRef, isOpen, props.className, props.dontSaveOnExternalClick, saving, triggerSave],
|
|
109
114
|
);
|
|
110
115
|
|
|
111
116
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FocusableItem, MenuDivider, MenuHeader, MenuItem } from "../../react-menu3";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
4
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
5
5
|
import { isEmpty } from "lodash-es";
|
|
@@ -188,27 +188,11 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
188
188
|
return true;
|
|
189
189
|
}, [filter, filteredValues, options, props, selectItemHandler, selectedItem, selectedRows, subSelectedValue]);
|
|
190
190
|
|
|
191
|
-
const onMouseEnterFocus = useCallback((item: FinalSelectOption) => {
|
|
192
|
-
setSelectedItem(item);
|
|
193
|
-
if (item.subComponent) {
|
|
194
|
-
subComponentIsValid.current = true;
|
|
195
|
-
subComponentInitialValue.current = null;
|
|
196
|
-
} else {
|
|
197
|
-
setSubSelectedValue(null);
|
|
198
|
-
subComponentIsValid.current = true;
|
|
199
|
-
}
|
|
200
|
-
}, []);
|
|
201
|
-
|
|
202
|
-
const onMouseLeaveFocus = useCallback(() => {
|
|
203
|
-
setSelectedItem(null);
|
|
204
|
-
setSubSelectedValue(null);
|
|
205
|
-
subComponentIsValid.current = true;
|
|
206
|
-
}, []);
|
|
207
|
-
|
|
208
191
|
const { popoverWrapper } = useGridPopoverHook({
|
|
209
192
|
className: props.className,
|
|
210
193
|
invalid: () => !!(selectedItem && !subComponentIsValid.current),
|
|
211
194
|
save,
|
|
195
|
+
dontSaveOnExternalClick: true,
|
|
212
196
|
});
|
|
213
197
|
|
|
214
198
|
let lastHeader: JSX.Element | null = null;
|
|
@@ -277,7 +261,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
277
261
|
}
|
|
278
262
|
return (
|
|
279
263
|
(!filteredValues || filteredValues.includes(item)) && (
|
|
280
|
-
|
|
264
|
+
<Fragment key={`${index}`}>
|
|
281
265
|
{showHeader}
|
|
282
266
|
<div key={`menu-wrapper-${index}`}>
|
|
283
267
|
<MenuItem
|
|
@@ -285,9 +269,16 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
285
269
|
disabled={!!item.disabled}
|
|
286
270
|
title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
|
|
287
271
|
value={item.value}
|
|
288
|
-
onFocus={() =>
|
|
289
|
-
|
|
290
|
-
|
|
272
|
+
onFocus={() => {
|
|
273
|
+
setSelectedItem(item);
|
|
274
|
+
if (item.subComponent) {
|
|
275
|
+
subComponentIsValid.current = true;
|
|
276
|
+
subComponentInitialValue.current = null;
|
|
277
|
+
} else {
|
|
278
|
+
setSubSelectedValue(null);
|
|
279
|
+
subComponentIsValid.current = true;
|
|
280
|
+
}
|
|
281
|
+
}}
|
|
291
282
|
onClick={(e: ClickEvent) => {
|
|
292
283
|
if (item.subComponent) {
|
|
293
284
|
e.keepOpen = true;
|
|
@@ -331,7 +322,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
331
322
|
</FocusableItem>
|
|
332
323
|
)}
|
|
333
324
|
</div>
|
|
334
|
-
|
|
325
|
+
</Fragment>
|
|
335
326
|
)
|
|
336
327
|
);
|
|
337
328
|
})}
|
|
@@ -100,7 +100,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
100
100
|
headerName: "Custom edit",
|
|
101
101
|
maxWidth: 100,
|
|
102
102
|
editable: true,
|
|
103
|
-
valueFormatter: () => "
|
|
103
|
+
valueFormatter: () => "Press E",
|
|
104
104
|
cellRendererParams: {
|
|
105
105
|
rightHoverElement: (
|
|
106
106
|
<GridIcon icon={"ic_launch_modal"} title={"Title text"} className={"GridCell-editableIcon"} />
|