@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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "1.5.0",
5
+ "version": "1.5.1",
6
6
  "main": "dist/index.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "module": "dist/step-ag-grid.esm.js",
@@ -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
- ...GridPopoverEditBearingLike(colDef),
29
- valueFormatter: bearingValueFormatter,
30
- range: (value: number | null) => {
31
- if (value === null) return "Bearing is required";
32
- if (value >= 360) return "Bearing must be less than 360 degrees";
33
- if (value < 0) return "Bearing must not be negative";
34
- return null;
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
- ...GridPopoverEditBearingLike(colDef),
42
- valueFormatter: bearingCorrectionValueFormatter,
43
- range: (value: number | null) => {
44
- if (value === null) return "Bearing is required";
45
- if (value >= 360) return "Bearing must be less than 360 degrees";
46
- if (value <= -180) return "Bearing must be greater then -180 degrees";
47
- return null;
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",
@@ -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));
@@ -39,7 +39,6 @@ export const bearingStringValidator = (
39
39
  }
40
40
 
41
41
  const bearing = parseFloat(value);
42
-
43
42
  return customValidate ? customValidate(bearing) : null;
44
43
  };
45
44