@linzjs/step-ag-grid 1.4.10 → 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 +86 -35
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormDropDown.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 +86 -35
- 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/GridFormDropDown.tsx +18 -1
- 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/stories/components/GridPopoutEditDropDown.stories.tsx +24 -0
- 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
|
|
@@ -31,6 +31,7 @@ export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow, ValueT
|
|
|
31
31
|
filtered?: "local" | "reload";
|
|
32
32
|
filterPlaceholder?: string;
|
|
33
33
|
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<RowType, ValueType>) => Promise<void>;
|
|
34
|
+
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<RowType, string>) => Promise<void>;
|
|
34
35
|
options:
|
|
35
36
|
| SelectOption<ValueType>[]
|
|
36
37
|
| ((selectedRows: RowType[], filter?: string) => Promise<SelectOption<ValueType>[]> | SelectOption<ValueType>[]);
|
|
@@ -66,6 +67,19 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
|
|
|
66
67
|
[formProps, props.field, props.selectedRows, updatingCells],
|
|
67
68
|
);
|
|
68
69
|
|
|
70
|
+
const selectFilterHandler = useCallback(
|
|
71
|
+
async (value: string): Promise<boolean> => {
|
|
72
|
+
const field = props.field;
|
|
73
|
+
return await updatingCells({ selectedRows: props.selectedRows, field }, async (selectedRows) => {
|
|
74
|
+
if (formProps.onSelectFilter) {
|
|
75
|
+
await formProps.onSelectFilter({ selectedRows, value });
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
[formProps, props.field, props.selectedRows, updatingCells],
|
|
81
|
+
);
|
|
82
|
+
|
|
69
83
|
// Load up options list if it's async function
|
|
70
84
|
useEffect(() => {
|
|
71
85
|
if (options || optionsInitialising.current) return;
|
|
@@ -140,13 +154,16 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
|
|
|
140
154
|
if (activeOptions.length == 1) {
|
|
141
155
|
await selectItemHandler(activeOptions[0].value);
|
|
142
156
|
stopEditing();
|
|
157
|
+
} else if (formProps.onSelectFilter) {
|
|
158
|
+
await selectFilterHandler(filter);
|
|
159
|
+
stopEditing();
|
|
143
160
|
} else {
|
|
144
161
|
e.preventDefault();
|
|
145
162
|
e.stopPropagation();
|
|
146
163
|
}
|
|
147
164
|
}
|
|
148
165
|
},
|
|
149
|
-
[filteredValues, options, selectItemHandler, stopEditing],
|
|
166
|
+
[filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, formProps],
|
|
150
167
|
);
|
|
151
168
|
|
|
152
169
|
return popoverWrapper(
|
|
@@ -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));
|
|
@@ -44,6 +44,7 @@ interface ITestRow {
|
|
|
44
44
|
position2: string | null;
|
|
45
45
|
position3: string | null;
|
|
46
46
|
position4: ICode | null;
|
|
47
|
+
code: string | null;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
interface ICode {
|
|
@@ -177,6 +178,27 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
177
178
|
}),
|
|
178
179
|
},
|
|
179
180
|
}),
|
|
181
|
+
GridPopoverEditDropDown<ITestRow, ICode>({
|
|
182
|
+
field: "code",
|
|
183
|
+
initialWidth: 65,
|
|
184
|
+
maxWidth: 150,
|
|
185
|
+
headerName: "Filter Selectable",
|
|
186
|
+
valueGetter: (params) => params.data.code,
|
|
187
|
+
cellEditorParams: {
|
|
188
|
+
multiEdit: true,
|
|
189
|
+
filtered: "local",
|
|
190
|
+
filterPlaceholder: "Filter this",
|
|
191
|
+
options: optionsObjects.map((o) => {
|
|
192
|
+
return { value: o, label: o.desc, disabled: false };
|
|
193
|
+
}),
|
|
194
|
+
onSelectedItem: async (selected) => {
|
|
195
|
+
selected.selectedRows.forEach((row) => (row.code = selected.value.code));
|
|
196
|
+
},
|
|
197
|
+
onSelectFilter: async (selected) => {
|
|
198
|
+
selected.selectedRows.forEach((row) => (row.code = selected.value));
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
180
202
|
] as ColDef[],
|
|
181
203
|
[optionsFn, optionsObjects],
|
|
182
204
|
);
|
|
@@ -190,6 +212,7 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
190
212
|
position2: "1",
|
|
191
213
|
position3: "Tester",
|
|
192
214
|
position4: { code: "O1", desc: "Object One" },
|
|
215
|
+
code: "O1",
|
|
193
216
|
},
|
|
194
217
|
{
|
|
195
218
|
id: 1001,
|
|
@@ -197,6 +220,7 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
|
|
|
197
220
|
position2: "2",
|
|
198
221
|
position3: "Developer",
|
|
199
222
|
position4: { code: "O2", desc: "Object Two" },
|
|
223
|
+
code: "O2",
|
|
200
224
|
},
|
|
201
225
|
] as ITestRow[],
|
|
202
226
|
[],
|