@linzjs/step-ag-grid 1.5.0 → 1.5.1
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.d.ts +4 -4
- package/dist/index.js +51 -30
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +1 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +2 -4
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +1 -1
- package/dist/src/react-menu3/components/Menu.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuList.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +4 -0
- package/dist/step-ag-grid.esm.js +51 -30
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridCell.tsx +1 -0
- package/src/components/GridPopoverHook.tsx +3 -0
- package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +32 -20
- package/src/react-menu3/components/MenuList.tsx +19 -0
- package/src/react-menu3/types.ts +4 -0
- package/src/stories/components/GridPopoutBearing.stories.tsx +1 -1
- package/src/utils/bearing.ts +0 -1
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ export interface GridFormProps<RowType extends GridBaseRow> {
|
|
|
13
13
|
cellEditorParams: ICellEditorParams;
|
|
14
14
|
updateValue: (saveFn: (selectedRows: RowType[]) => Promise<boolean>) => Promise<boolean>;
|
|
15
15
|
saving: boolean;
|
|
16
|
+
data: RowType;
|
|
16
17
|
value: any;
|
|
17
18
|
field: string | undefined;
|
|
18
19
|
selectedRows: RowType[];
|
|
@@ -44,6 +44,9 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(
|
|
|
44
44
|
saveButtonRef={saveButtonRef}
|
|
45
45
|
menuClassName={"lui-menu"}
|
|
46
46
|
onClose={(event: { reason: string }) => triggerSave(event.reason).then()}
|
|
47
|
+
reposition={"initial"}
|
|
48
|
+
viewScroll={"auto"}
|
|
49
|
+
dontShrinkIfDirectionIsTop={true}
|
|
47
50
|
>
|
|
48
51
|
{saving && (
|
|
49
52
|
<div
|
|
@@ -55,7 +55,7 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
|
|
|
55
55
|
maxLength: 16,
|
|
56
56
|
onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
|
|
57
57
|
}}
|
|
58
|
-
formatted={bearingStringValidator(value) ? "?" : convertDDToDMS(bearingNumberParser(value))}
|
|
58
|
+
formatted={bearingStringValidator(value, formProps.range) ? "?" : convertDDToDMS(bearingNumberParser(value))}
|
|
59
59
|
error={bearingStringValidator(value, formProps.range)}
|
|
60
60
|
/>
|
|
61
61
|
</div>,
|
|
@@ -24,26 +24,38 @@ export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
|
|
|
24
24
|
|
|
25
25
|
export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
|
|
26
26
|
colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
|
|
27
|
-
) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
) => {
|
|
28
|
+
const init = GridPopoverEditBearingLike(colDef);
|
|
29
|
+
return {
|
|
30
|
+
...init,
|
|
31
|
+
valueFormatter: bearingValueFormatter,
|
|
32
|
+
cellEditorParams: {
|
|
33
|
+
range: (value: number | null) => {
|
|
34
|
+
if (value === null) return "Bearing is required";
|
|
35
|
+
if (value >= 360) return "Bearing must be less than 360 degrees";
|
|
36
|
+
if (value < 0) return "Bearing must not be negative";
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
...init.cellEditorParams,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
|
|
39
45
|
colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
|
|
40
|
-
) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
) => {
|
|
47
|
+
const init = GridPopoverEditBearingLike(colDef);
|
|
48
|
+
return {
|
|
49
|
+
...init,
|
|
50
|
+
valueFormatter: bearingCorrectionValueFormatter,
|
|
51
|
+
cellEditorParams: {
|
|
52
|
+
range: (value: number | null) => {
|
|
53
|
+
if (value === null) return "Bearing is required";
|
|
54
|
+
if (value >= 360) return "Bearing must be less than 360 degrees";
|
|
55
|
+
if (value <= -180) return "Bearing must be greater then -180 degrees";
|
|
56
|
+
return null;
|
|
57
|
+
},
|
|
58
|
+
...init.cellEditorParams,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -47,6 +47,7 @@ export const MenuList = ({
|
|
|
47
47
|
endTransition,
|
|
48
48
|
isDisabled,
|
|
49
49
|
menuItemFocus,
|
|
50
|
+
dontShrinkIfDirectionIsTop,
|
|
50
51
|
offsetX = 0,
|
|
51
52
|
offsetY = 0,
|
|
52
53
|
children,
|
|
@@ -417,6 +418,23 @@ export const MenuList = ({
|
|
|
417
418
|
className: arrowClassName,
|
|
418
419
|
});
|
|
419
420
|
|
|
421
|
+
const minHeight = useRef(0);
|
|
422
|
+
if (dontShrinkIfDirectionIsTop && menuRef.current?.getBoundingClientRect) {
|
|
423
|
+
const h = menuRef.current?.getBoundingClientRect().height;
|
|
424
|
+
if (minHeight.current < h) minHeight.current = h;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const dontShrinkOps = useMemo(
|
|
428
|
+
() =>
|
|
429
|
+
expandedDirection === "top" && dontShrinkIfDirectionIsTop
|
|
430
|
+
? {
|
|
431
|
+
overflowY: isSubmenuOpen ? "" : "auto",
|
|
432
|
+
minHeight: (isSubmenuOpen ? 0 : minHeight.current) + "px",
|
|
433
|
+
}
|
|
434
|
+
: undefined,
|
|
435
|
+
[dontShrinkIfDirectionIsTop, expandedDirection, isSubmenuOpen],
|
|
436
|
+
);
|
|
437
|
+
|
|
420
438
|
return (
|
|
421
439
|
<ul
|
|
422
440
|
role="menu"
|
|
@@ -428,6 +446,7 @@ export const MenuList = ({
|
|
|
428
446
|
style={{
|
|
429
447
|
...menuStyle,
|
|
430
448
|
...overflowStyle,
|
|
449
|
+
...dontShrinkOps,
|
|
431
450
|
margin: 0,
|
|
432
451
|
display: state === "closed" ? "none" : undefined,
|
|
433
452
|
position: "absolute",
|
package/src/react-menu3/types.ts
CHANGED
|
@@ -377,6 +377,10 @@ export interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
|
377
377
|
* Event fired when descendent menu items are clicked.
|
|
378
378
|
*/
|
|
379
379
|
onItemClick?: EventHandler<ClickEvent>;
|
|
380
|
+
/**
|
|
381
|
+
* NEW Don't shrink container if menu direction is "top"
|
|
382
|
+
*/
|
|
383
|
+
dontShrinkIfDirectionIsTop?: boolean;
|
|
380
384
|
}
|
|
381
385
|
|
|
382
386
|
export interface ExtraMenuProps {
|
|
@@ -67,7 +67,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
67
67
|
headerName: "Bearing Correction",
|
|
68
68
|
cellEditorParams: {
|
|
69
69
|
multiEdit: true,
|
|
70
|
-
placeHolder: "Enter Bearing",
|
|
70
|
+
placeHolder: "Enter Bearing Correction",
|
|
71
71
|
onSave: async (selectedRows: ITestRow[], value: ITestRow["bearingCorrection"]) => {
|
|
72
72
|
await wait(1000);
|
|
73
73
|
selectedRows.forEach((row) => (row["bearingCorrection"] = value));
|