@linzjs/step-ag-grid 1.4.1 → 1.4.4
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.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +1 -1
- package/dist/step-ag-grid.esm.js +10 -7
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +2 -1
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridForm/GridFormPopoutMenu.tsx +2 -2
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +45 -2
- package/src/stories/components/GridReadOnly.stories.tsx +3 -3
- package/src/utils/bearing.ts +7 -4
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { ControlledMenu } from "@szhsin/react-menu";
|
|
|
5
5
|
import { GridFormProps } from "./GridCell";
|
|
6
6
|
import { hasParentClass } from "@utils/util";
|
|
7
7
|
import { GridBaseRow } from "./Grid";
|
|
8
|
+
import { isEmpty } from "lodash-es";
|
|
8
9
|
|
|
9
10
|
export const useGridPopoverHook = <RowType extends GridBaseRow>(
|
|
10
11
|
props: GridFormProps<RowType>,
|
|
@@ -84,7 +85,7 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(
|
|
|
84
85
|
{anchorRef.current && (
|
|
85
86
|
<ControlledMenu
|
|
86
87
|
state={isOpen ? "open" : "closed"}
|
|
87
|
-
portal={
|
|
88
|
+
portal={isEmpty(document.querySelectorAll(".PopoutWindowContainer"))}
|
|
88
89
|
unmountOnClose={true}
|
|
89
90
|
anchorRef={anchorRef}
|
|
90
91
|
menuClassName={"lui-menu"}
|
|
@@ -182,7 +182,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
|
|
|
182
182
|
<MenuDivider key={`$$divider_${index}`} />
|
|
183
183
|
) : filteredValues.includes(item.value) ? null : (
|
|
184
184
|
<MenuItem
|
|
185
|
-
key={`${
|
|
185
|
+
key={`${props.field}-${index}`}
|
|
186
186
|
disabled={!!item.disabled}
|
|
187
187
|
title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
|
|
188
188
|
value={item.value}
|
|
@@ -21,7 +21,7 @@ export interface MenuOption<RowType> {
|
|
|
21
21
|
label: JSX.Element | string | MenuSeparatorType;
|
|
22
22
|
action?: (selectedRows: RowType[]) => Promise<boolean>;
|
|
23
23
|
disabled?: string | boolean;
|
|
24
|
-
|
|
24
|
+
supportsMultiEdit: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -65,7 +65,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
|
|
|
65
65
|
const selectedRowCount = props.selectedRows.length;
|
|
66
66
|
|
|
67
67
|
const filteredOptions = options?.filter((menuOption) => {
|
|
68
|
-
return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.
|
|
68
|
+
return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
const { popoverWrapper } = useGridPopoverHook(props);
|
|
@@ -8,10 +8,12 @@ import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useCallback, useMemo, useState } from "react";
|
|
10
10
|
import {
|
|
11
|
+
FinalSelectOption,
|
|
11
12
|
GridFormDropDown,
|
|
12
13
|
GridFormPopoutDropDownProps,
|
|
13
14
|
MenuSeparator,
|
|
14
15
|
MenuSeparatorString,
|
|
16
|
+
SelectOption,
|
|
15
17
|
} from "@components/gridForm/GridFormDropDown";
|
|
16
18
|
import { ColDef } from "ag-grid-community";
|
|
17
19
|
import { wait } from "@utils/util";
|
|
@@ -43,6 +45,12 @@ interface ITestRow {
|
|
|
43
45
|
position: string | null;
|
|
44
46
|
position2: string | null;
|
|
45
47
|
position3: string | null;
|
|
48
|
+
position4: ICode | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface ICode {
|
|
52
|
+
code: string;
|
|
53
|
+
desc: string;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
@@ -65,6 +73,14 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
65
73
|
].filter((v) => (filter != null ? v != null && v.toLowerCase().indexOf(filter) === 0 : true));
|
|
66
74
|
}, []);
|
|
67
75
|
|
|
76
|
+
const optionsObjects = useMemo(
|
|
77
|
+
() => [
|
|
78
|
+
{ code: "O1", desc: "Object One" },
|
|
79
|
+
{ code: "O2", desc: "Object Two" },
|
|
80
|
+
],
|
|
81
|
+
[],
|
|
82
|
+
);
|
|
83
|
+
|
|
68
84
|
const columnDefs = useMemo(
|
|
69
85
|
() =>
|
|
70
86
|
[
|
|
@@ -148,6 +164,21 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
148
164
|
options: [null, "Architect", "Developer", "Product Owner", "Scrum Master", "Tester", "(other)"],
|
|
149
165
|
},
|
|
150
166
|
}),
|
|
167
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position4"]>({
|
|
168
|
+
field: "position4",
|
|
169
|
+
initialWidth: 65,
|
|
170
|
+
maxWidth: 150,
|
|
171
|
+
headerName: "Filtered (object)",
|
|
172
|
+
valueGetter: (params) => params.data.position4?.desc,
|
|
173
|
+
cellEditorParams: {
|
|
174
|
+
multiEdit: true,
|
|
175
|
+
filtered: "local",
|
|
176
|
+
filterPlaceholder: "Filter this",
|
|
177
|
+
options: optionsObjects.map((o) => {
|
|
178
|
+
return { value: o, label: o.desc, disabled: false };
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
151
182
|
] as ColDef[],
|
|
152
183
|
[optionsFn],
|
|
153
184
|
);
|
|
@@ -155,8 +186,20 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
155
186
|
const rowData = useMemo(
|
|
156
187
|
() =>
|
|
157
188
|
[
|
|
158
|
-
{
|
|
159
|
-
|
|
189
|
+
{
|
|
190
|
+
id: 1000,
|
|
191
|
+
position: "Tester",
|
|
192
|
+
position2: "1",
|
|
193
|
+
position3: "Tester",
|
|
194
|
+
position4: { code: "O1", desc: "Object One" },
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: 1001,
|
|
198
|
+
position: "Developer",
|
|
199
|
+
position2: "2",
|
|
200
|
+
position3: "Developer",
|
|
201
|
+
position4: { code: "O2", desc: "Object Two" },
|
|
202
|
+
},
|
|
160
203
|
] as ITestRow[],
|
|
161
204
|
[],
|
|
162
205
|
);
|
|
@@ -98,7 +98,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
98
98
|
await wait(1500);
|
|
99
99
|
return true;
|
|
100
100
|
},
|
|
101
|
-
|
|
101
|
+
supportsMultiEdit: false,
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
label: "Multi-edit",
|
|
@@ -107,12 +107,12 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
107
107
|
await wait(1500);
|
|
108
108
|
return true;
|
|
109
109
|
},
|
|
110
|
-
|
|
110
|
+
supportsMultiEdit: true,
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
label: "Disabled item",
|
|
114
114
|
disabled: "Disabled for test",
|
|
115
|
-
|
|
115
|
+
supportsMultiEdit: true,
|
|
116
116
|
},
|
|
117
117
|
];
|
|
118
118
|
},
|
package/src/utils/bearing.ts
CHANGED
|
@@ -13,6 +13,9 @@ export const bearingCorrectionValueFormatter = (params: ValueFormatterParams): s
|
|
|
13
13
|
if (value == null) {
|
|
14
14
|
return "-";
|
|
15
15
|
}
|
|
16
|
+
if (typeof value === "string") {
|
|
17
|
+
return convertDDToDMS(bearingNumberParser(value), true, true);
|
|
18
|
+
}
|
|
16
19
|
return convertDDToDMS(value, true, true);
|
|
17
20
|
};
|
|
18
21
|
|
|
@@ -47,11 +50,11 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
|
|
|
47
50
|
if (dd === 0) addTrailingZeros = false;
|
|
48
51
|
|
|
49
52
|
// toFixed rounds parts up greater than 60, which has to be corrected below
|
|
50
|
-
const [bearingWholeString,
|
|
53
|
+
const [bearingWholeString, bearingDecimalString] = dd.toFixed(5).split(".");
|
|
51
54
|
|
|
52
55
|
let bearingWhole = Math.abs(parseInt(bearingWholeString));
|
|
53
|
-
let minNumeric = parseInt(
|
|
54
|
-
let secNumeric = parseInt(
|
|
56
|
+
let minNumeric = parseInt(bearingDecimalString?.substring(0, 2));
|
|
57
|
+
let secNumeric = parseInt(bearingDecimalString?.substring(2, 4));
|
|
55
58
|
|
|
56
59
|
// If the toFixed caused rounding beyond 60 minutes/seconds then apply the carry
|
|
57
60
|
if (secNumeric >= 60) {
|
|
@@ -68,7 +71,7 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
|
|
|
68
71
|
|
|
69
72
|
const minString = minNumeric.toString().padStart(2, "0");
|
|
70
73
|
const secString = secNumeric.toString().padStart(2, "0");
|
|
71
|
-
const deciSecString =
|
|
74
|
+
const deciSecString = bearingDecimalString?.substring(4, 5);
|
|
72
75
|
|
|
73
76
|
let dmsString = `${showPositiveSymbol && dd > 0 ? "+" : ""}${dd < 0 ? "-" : ""}${bearingWhole}°`;
|
|
74
77
|
if (addTrailingZeros || deciSecString != "0") {
|