@linzjs/step-ag-grid 1.3.0 → 1.4.0

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.
Files changed (51) hide show
  1. package/dist/index.d.ts +4 -2
  2. package/dist/index.js +3496 -88220
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/GridCell.d.ts +2 -1
  5. package/dist/src/components/GridPopoverHook.d.ts +7 -0
  6. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -0
  7. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -0
  8. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -1
  9. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +271 -1
  10. package/dist/src/components/gridPopoverEdit/{GridPopoutMenu.d.ts → GridPopoverMenu.d.ts} +2 -2
  11. package/dist/src/contexts/GridContext.d.ts +1 -1
  12. package/dist/src/stories/components/FormTest.d.ts +2 -2
  13. package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +1 -1
  14. package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +1 -1
  15. package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +1 -1
  16. package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +1 -1
  17. package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +1 -1
  18. package/dist/src/stories/components/GridReadOnly.stories.d.ts +1 -1
  19. package/dist/src/utils/bearing.d.ts +2 -1
  20. package/dist/src/utils/bearing.test.d.ts +1 -0
  21. package/dist/step-ag-grid.esm.js +3490 -88217
  22. package/dist/step-ag-grid.esm.js.map +1 -1
  23. package/package.json +38 -39
  24. package/src/components/Grid.tsx +3 -3
  25. package/src/components/GridCell.tsx +27 -3
  26. package/src/components/{GridPopoutHook.tsx → GridPopoverHook.tsx} +7 -5
  27. package/src/components/gridForm/GridFormDropDown.tsx +13 -6
  28. package/src/components/gridForm/GridFormEditBearing.tsx +6 -5
  29. package/src/components/gridForm/GridFormMessage.tsx +3 -3
  30. package/src/components/gridForm/GridFormMultiSelect.tsx +3 -3
  31. package/src/components/gridForm/GridFormPopoutMenu.tsx +9 -7
  32. package/src/components/gridForm/GridFormTextArea.tsx +4 -4
  33. package/src/components/gridForm/GridFormTextInput.tsx +4 -4
  34. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +1 -2
  35. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +29 -4
  36. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +1 -2
  37. package/src/components/gridPopoverEdit/{GridPopoutMenu.scss → GridPopoverMenu.scss} +0 -0
  38. package/src/components/gridPopoverEdit/{GridPopoutMenu.tsx → GridPopoverMenu.tsx} +2 -2
  39. package/src/contexts/GridContext.tsx +1 -1
  40. package/src/contexts/GridContextProvider.tsx +2 -2
  41. package/src/lui/TextInputFormatted.scss +1 -1
  42. package/src/stories/components/FormTest.tsx +6 -6
  43. package/src/stories/components/GridPopoutBearing.stories.tsx +18 -15
  44. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +11 -10
  45. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +4 -4
  46. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +7 -9
  47. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +9 -9
  48. package/src/stories/components/GridReadOnly.stories.tsx +15 -10
  49. package/src/utils/bearing.test.ts +30 -0
  50. package/src/utils/bearing.ts +19 -8
  51. package/dist/src/components/GridPopoutHook.d.ts +0 -7
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.3.0",
5
+ "version": "1.4.0",
6
6
  "main": "dist/index.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "module": "dist/step-ag-grid.esm.js",
@@ -16,30 +16,20 @@
16
16
  "engines": {
17
17
  "node": ">=10"
18
18
  },
19
- "resolutions": {
20
- "webpack": "5"
21
- },
22
19
  "dependencies": {
23
20
  "@linzjs/lui": "^17.18.2",
24
- "@testing-library/jest-dom": "^5.14.1",
25
- "@testing-library/react": "^12.1.3",
26
- "@testing-library/user-event": "^13.5.0",
27
21
  "ag-grid-community": "^27.3.0",
28
22
  "ag-grid-react": "^27.3.0",
29
23
  "debounce-promise": "^3.1.2",
30
24
  "lodash-es": "^4.17.21",
31
25
  "react": "^17.0.2",
32
26
  "react-dom": "^17.0.2",
33
- "react-scripts": "^5.0.1",
34
- "uuid": "^9.0.0",
35
- "autoprefixer": "^10.0.2",
36
- "postcss": "^8.1.7",
37
- "postcss-loader": "^4.0.4"
27
+ "uuid": "^9.0.0"
38
28
  },
39
29
  "scripts": {
40
30
  "build": "rollup -c && npm run",
41
- "test": "react-app-rewired test --passWithNoTests",
42
- "eject": "react-app-rewired eject",
31
+ "test": "react-scripts test --passWithNoTests",
32
+ "eject": "react-scripts eject",
43
33
  "lint": "eslint ./src --ext .js,.ts,.tsx --fix --cache",
44
34
  "storybook": "start-storybook -p 6006 -s public",
45
35
  "build-storybook": "build-storybook -s public",
@@ -71,47 +61,56 @@
71
61
  "@rollup/plugin-node-resolve": "^11.2.1",
72
62
  "@semantic-release/changelog": "^6.0.1",
73
63
  "@semantic-release/git": "^10.0.1",
74
- "@storybook/builder-webpack5": "^6.5.13",
75
- "@storybook/cli": "^6.5.12",
76
- "@storybook/manager-webpack5": "^6.5.13",
77
- "@storybook/preset-scss": "^1.0.3",
78
- "@storybook/react": "^6.5.12",
79
- "@types/debounce-promise": "^3.1.4",
80
- "@types/jest": "^27.5.2",
64
+ "@storybook/addon-actions": "^6.5.13",
65
+ "@storybook/addon-essentials": "^6.5.13",
66
+ "@storybook/addon-interactions": "^6.5.13",
67
+ "@storybook/addon-links": "^6.5.13",
68
+ "storybook-addon-mock": "^2.4.1",
69
+ "@storybook/jest": "^0.0.10",
70
+ "@storybook/react": "6.5.13",
71
+ "@storybook/test-runner": "^0.9.0",
72
+ "@storybook/testing-library": "^0.0.13",
73
+ "@testing-library/jest-dom": "^5.16.5",
74
+ "@testing-library/react": "^12.1.5",
75
+ "@testing-library/user-event": "^14.4.3",
76
+ "@types/debounce-promise": "^3.1.5",
77
+ "@types/jest": "^29.2.0",
81
78
  "@types/lodash-es": "^4.17.6",
82
- "@types/node": "^16.18.0",
83
- "@types/react": "^17.0.50",
84
- "@types/react-dom": "^17.0.17",
79
+ "@types/node": "^18.11.7",
80
+ "@types/react": "^18.0.23",
81
+ "@types/react-dom": "^18.0.7",
85
82
  "@types/uuid": "^8.3.4",
86
- "@typescript-eslint/parser": "^5.39.0",
83
+ "@typescript-eslint/parser": "^5.41.0",
84
+ "babel-jest": "^26.6.3",
87
85
  "babel-preset-react-app": "10.0.0",
88
- "chromatic": "^6.10.1",
89
- "css-loader": "^5.2.7",
86
+ "chromatic": "^6.11.2",
87
+ "css-loader": "3.6.0",
90
88
  "eslint": "8.22.0",
91
89
  "eslint-config-prettier": "^8.5.0",
92
90
  "eslint-config-react-app": "^7.0.1",
93
91
  "eslint-plugin-deprecation": "^1.3.2",
94
92
  "eslint-plugin-import": "^2.26.0",
95
- "eslint-plugin-jest": "^26.1.5",
96
- "eslint-plugin-jsx-a11y": "^6.5.1",
97
- "eslint-plugin-prettier": "^4.0.0",
98
- "eslint-plugin-react": "^7.29.4",
93
+ "eslint-plugin-jest": "^27.1.3",
94
+ "eslint-plugin-jsx-a11y": "^6.6.1",
95
+ "eslint-plugin-prettier": "^4.2.1",
96
+ "eslint-plugin-react": "^7.31.10",
99
97
  "eslint-plugin-react-hooks": "^4.6.0",
100
- "eslint-plugin-testing-library": "^5.3.1",
101
- "prettier": "^2.2.1",
102
- "react-app-rewired": "^2.2.1",
98
+ "eslint-plugin-testing-library": "^5.9.1",
99
+ "postcss": "^8.1.7",
100
+ "postcss-loader": "^4.0.4",
101
+ "prettier": "^2.7.1",
102
+ "react-scripts": "^5.0.1",
103
103
  "rollup": "^2.56.3",
104
104
  "rollup-plugin-copy": "^3.4.0",
105
105
  "rollup-plugin-peer-deps-external": "^2.2.4",
106
106
  "rollup-plugin-postcss": "^4.0.2",
107
107
  "rollup-plugin-typescript2": "^0.31.2",
108
- "sass": "^1.49.9",
109
- "sass-loader": "^10.3.1",
108
+ "sass": "^1.55.0",
109
+ "sass-loader": "10.1.1",
110
110
  "semantic-release": "^19.0.5",
111
111
  "style-loader": "^2.0.0",
112
- "tsconfig-paths-webpack-plugin": "^4.0.0",
113
- "typescript": "^4.8.4",
114
- "webpack": "^5.74.0"
112
+ "tsconfig-paths-webpack-plugin": "^3.5.2",
113
+ "typescript": "^4.8.4"
115
114
  },
116
115
  "babel": {
117
116
  "presets": [
@@ -8,11 +8,11 @@ import { AgGridEvent, CellClickedEvent, ColDef } from "ag-grid-community";
8
8
  import { CellEvent, GridReadyEvent, SelectionChangedEvent } from "ag-grid-community/dist/lib/events";
9
9
  import { GridOptions } from "ag-grid-community/dist/lib/entities/gridOptions";
10
10
  import { difference, last, xorBy } from "lodash-es";
11
- import { GridContext } from "../contexts/GridContext";
11
+ import { GridContext } from "@contexts/GridContext";
12
12
  import { usePostSortRowsHook } from "./PostSortRowsHook";
13
- import { isNotEmpty } from "../utils/util";
13
+ import { isNotEmpty } from "@utils/util";
14
14
  import { GridHeaderSelect } from "./gridHeader/GridHeaderSelect";
15
- import { UpdatingContext } from "../contexts/UpdatingContext";
15
+ import { UpdatingContext } from "@contexts/UpdatingContext";
16
16
 
17
17
  export interface GridBaseRow {
18
18
  id: string | number;
@@ -1,9 +1,11 @@
1
1
  import { useCallback, useContext, useMemo, useState } from "react";
2
2
  import { GridBaseRow } from "./Grid";
3
- import { GridContext } from "../contexts/GridContext";
3
+ import { UpdatingContext } from "@contexts/UpdatingContext";
4
+ import { GridContext } from "@contexts/GridContext";
4
5
  import { GenericMultiEditCellClass } from "./GenericCellClass";
5
6
  import { GenericCellRendererParams, GridRendererGenericCell } from "./gridRender/GridRenderGenericCell";
6
- import { ColDef, ICellEditorParams } from "ag-grid-community";
7
+ import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
8
+ import { GridLoadableCell } from "./GridLoadableCell";
7
9
 
8
10
  export interface GridFormProps<RowType extends GridBaseRow> {
9
11
  cellEditorParams: ICellEditorParams;
@@ -28,6 +30,24 @@ export interface GenericCellEditorColDef<
28
30
  cellRendererParams?: GenericCellRendererParams;
29
31
  }
30
32
 
33
+ export const GridCellRenderer = (cellRendererParams: ICellRendererParams) => {
34
+ const { checkUpdating } = useContext(UpdatingContext);
35
+ const colDef = cellRendererParams.colDef;
36
+
37
+ return colDef?.cellRendererParams?.oldCellRenderer ? (
38
+ <GridLoadableCell
39
+ isLoading={checkUpdating(
40
+ cellRendererParams.colDef?.field ?? cellRendererParams.colDef?.colId ?? "",
41
+ cellRendererParams.data.id,
42
+ )}
43
+ >
44
+ <colDef.cellRendererParams.oldCellRenderer {...cellRendererParams} />
45
+ </GridLoadableCell>
46
+ ) : (
47
+ <GridRendererGenericCell {...cellRendererParams} />
48
+ );
49
+ };
50
+
31
51
  /**
32
52
  * For editing a text area.
33
53
  */
@@ -35,7 +55,7 @@ export const GridCell = <RowType extends GridBaseRow, FormProps extends GenericC
35
55
  props: GenericCellEditorColDef<RowType, FormProps>,
36
56
  ): ColDef => {
37
57
  return {
38
- cellRenderer: props.cellRenderer ?? GridRendererGenericCell,
58
+ cellRenderer: GridCellRenderer,
39
59
  sortable: !!(props?.field || props?.valueGetter),
40
60
  resizable: true,
41
61
  ...(props.cellEditorParams && {
@@ -44,6 +64,10 @@ export const GridCell = <RowType extends GridBaseRow, FormProps extends GenericC
44
64
  cellEditor: GenericCellEditorComponent,
45
65
  }),
46
66
  ...props,
67
+ cellRendererParams: {
68
+ originalCellRender: props.cellRenderer,
69
+ ...props.cellRendererParams,
70
+ },
47
71
  };
48
72
  };
49
73
 
@@ -1,12 +1,12 @@
1
1
  import { ICellEditorParams } from "ag-grid-community";
2
2
  import { useCallback, useContext, useEffect, useRef, useState } from "react";
3
- import { GridContext } from "../contexts/GridContext";
3
+ import { GridContext } from "@contexts/GridContext";
4
4
  import { ControlledMenu } from "@szhsin/react-menu";
5
5
  import { GridFormProps } from "./GridCell";
6
- import { hasParentClass } from "../utils/util";
6
+ import { hasParentClass } from "@utils/util";
7
7
  import { GridBaseRow } from "./Grid";
8
8
 
9
- export const useGridPopoutHook = <RowType extends GridBaseRow>(
9
+ export const useGridPopoverHook = <RowType extends GridBaseRow>(
10
10
  props: GridFormProps<RowType>,
11
11
  save?: (selectedRows: any[]) => Promise<boolean>,
12
12
  ) => {
@@ -66,16 +66,18 @@ export const useGridPopoutHook = <RowType extends GridBaseRow>(
66
66
  document.addEventListener("mousedown", handleScreenMouseDown, true);
67
67
  document.addEventListener("mouseup", handleScreenMouseEvent, true);
68
68
  document.addEventListener("click", handleScreenMouseEvent, true);
69
+ document.addEventListener("dblclick", handleScreenMouseEvent, true);
69
70
  return () => {
70
71
  document.removeEventListener("mousedown", handleScreenMouseDown, true);
71
72
  document.removeEventListener("mouseup", handleScreenMouseEvent, true);
72
73
  document.removeEventListener("click", handleScreenMouseEvent, true);
74
+ document.removeEventListener("dblclick", handleScreenMouseEvent, true);
73
75
  };
74
76
  }
75
77
  return () => {};
76
78
  }, [handleScreenMouseDown, handleScreenMouseEvent, isOpen]);
77
79
 
78
- const popoutWrapper = useCallback(
80
+ const popoverWrapper = useCallback(
79
81
  (children: JSX.Element) => {
80
82
  return (
81
83
  <>
@@ -112,7 +114,7 @@ export const useGridPopoutHook = <RowType extends GridBaseRow>(
112
114
  );
113
115
 
114
116
  return {
115
- popoutWrapper,
117
+ popoverWrapper,
116
118
  triggerSave,
117
119
  };
118
120
  };
@@ -4,11 +4,11 @@ import { MenuItem, MenuDivider, FocusableItem } from "@szhsin/react-menu";
4
4
  import { useCallback, useContext, useEffect, useRef, useState, KeyboardEvent } from "react";
5
5
  import { GridBaseRow } from "../Grid";
6
6
  import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
7
- import { GridContext } from "../../contexts/GridContext";
7
+ import { GridContext } from "@contexts/GridContext";
8
8
  import { delay } from "lodash-es";
9
9
  import debounce from "debounce-promise";
10
10
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
11
- import { useGridPopoutHook } from "../GridPopoutHook";
11
+ import { useGridPopoverHook } from "../GridPopoverHook";
12
12
 
13
13
  export interface GridPopoutEditDropDownSelectedItem<RowType, ValueType> {
14
14
  selectedRows: RowType[];
@@ -18,6 +18,7 @@ export interface GridPopoutEditDropDownSelectedItem<RowType, ValueType> {
18
18
  interface FinalSelectOption<ValueType> {
19
19
  value: ValueType;
20
20
  label?: JSX.Element | string;
21
+ disabled?: boolean | string;
21
22
  }
22
23
 
23
24
  export const MenuSeparatorString = "_____MENU_SEPARATOR_____";
@@ -37,7 +38,7 @@ export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow, ValueT
37
38
  }
38
39
 
39
40
  export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props: GridFormProps<RowType>) => {
40
- const { popoutWrapper } = useGridPopoutHook(props);
41
+ const { popoverWrapper } = useGridPopoverHook(props);
41
42
  const formProps = props.formProps as GridFormPopoutDropDownProps<RowType, ValueType>;
42
43
 
43
44
  const { updatingCells, stopEditing } = useContext(GridContext);
@@ -78,7 +79,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
78
79
 
79
80
  const optionsList = optionsConf?.map((item) => {
80
81
  if (item == null || typeof item == "string" || typeof item == "number") {
81
- item = { value: item as ValueType, label: item } as FinalSelectOption<ValueType>;
82
+ item = { value: item as ValueType, label: item, disabled: false } as FinalSelectOption<ValueType>;
82
83
  }
83
84
  return item;
84
85
  }) as any as FinalSelectOption<ValueType>[];
@@ -148,7 +149,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
148
149
  [filteredValues, options, selectItemHandler, stopEditing],
149
150
  );
150
151
 
151
- return popoutWrapper(
152
+ return popoverWrapper(
152
153
  <>
153
154
  {formProps.filtered && (
154
155
  <>
@@ -180,7 +181,13 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(props:
180
181
  item.value === MenuSeparatorString ? (
181
182
  <MenuDivider key={`$$divider_${index}`} />
182
183
  ) : filteredValues.includes(item.value) ? null : (
183
- <MenuItem key={`${item.value}`} value={item.value} onClick={() => selectItemHandler(item.value)}>
184
+ <MenuItem
185
+ key={`${item.value}`}
186
+ disabled={!!item.disabled}
187
+ title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
188
+ value={item.value}
189
+ onClick={() => selectItemHandler(item.value)}
190
+ >
184
191
  {item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)}
185
192
  </MenuItem>
186
193
  ),
@@ -3,12 +3,13 @@ import "./GridFormEditBearing.scss";
3
3
  import { useCallback, useState } from "react";
4
4
  import { GridBaseRow } from "../Grid";
5
5
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
6
- import { bearingNumberParser, bearingStringValidator, convertDDToDMS } from "../../utils/bearing";
6
+ import { bearingNumberParser, bearingStringValidator, convertDDToDMS } from "@utils/bearing";
7
7
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
8
- import { useGridPopoutHook } from "../GridPopoutHook";
8
+ import { useGridPopoverHook } from "../GridPopoverHook";
9
9
 
10
10
  export interface GridFormEditBearingProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
11
11
  placeHolder: string;
12
+ range?: (value: number | null) => string | null;
12
13
  onSave?: (selectedRows: RowType[], value: number | null) => Promise<boolean>;
13
14
  }
14
15
 
@@ -38,9 +39,9 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
38
39
  },
39
40
  [formProps, props.field, props.value, value],
40
41
  );
41
- const { popoutWrapper, triggerSave } = useGridPopoutHook(props, save);
42
+ const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
42
43
 
43
- return popoutWrapper(
44
+ return popoverWrapper(
44
45
  <div className={"GridFormEditBearing-input Grid-popoverContainer"}>
45
46
  <TextInputFormatted
46
47
  value={value ?? ""}
@@ -55,7 +56,7 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
55
56
  onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
56
57
  }}
57
58
  formatted={bearingStringValidator(value) ? "?" : convertDDToDMS(bearingNumberParser(value))}
58
- error={bearingStringValidator(value)}
59
+ error={bearingStringValidator(value, formProps.range)}
59
60
  />
60
61
  </div>,
61
62
  );
@@ -3,7 +3,7 @@ import { GenericCellEditorParams, GridFormProps } from "../GridCell";
3
3
  import { ICellEditorParams } from "ag-grid-community";
4
4
  import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
5
5
  import { GridBaseRow } from "../Grid";
6
- import { useGridPopoutHook } from "../GridPopoutHook";
6
+ import { useGridPopoverHook } from "../GridPopoverHook";
7
7
 
8
8
  export interface GridFormMessageProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
9
9
  message: (
@@ -16,7 +16,7 @@ export const GridFormMessage = <RowType extends GridBaseRow>(props: GridFormProp
16
16
  const formProps = props.formProps as GridFormMessageProps<RowType>;
17
17
 
18
18
  const [message, setMessage] = useState<string | JSX.Element | null>(null);
19
- const { popoutWrapper } = useGridPopoutHook(props);
19
+ const { popoverWrapper } = useGridPopoverHook(props);
20
20
 
21
21
  useEffect(() => {
22
22
  (async () => {
@@ -24,7 +24,7 @@ export const GridFormMessage = <RowType extends GridBaseRow>(props: GridFormProp
24
24
  })().then();
25
25
  }, [formProps, props.selectedRows, props]);
26
26
 
27
- return popoutWrapper(
27
+ return popoverWrapper(
28
28
  <ComponentLoadingWrapper loading={message === null}>
29
29
  <div style={{ maxWidth: 400 }} className={"Grid-popoverContainer"}>
30
30
  {message}
@@ -7,7 +7,7 @@ import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
7
7
  import { delay } from "lodash-es";
8
8
  import { LuiCheckboxInput } from "@linzjs/lui";
9
9
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
10
- import { useGridPopoutHook } from "../GridPopoutHook";
10
+ import { useGridPopoverHook } from "../GridPopoverHook";
11
11
 
12
12
  interface FinalSelectOption<ValueType> {
13
13
  value: ValueType;
@@ -58,7 +58,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
58
58
  },
59
59
  [formProps, selectedValues],
60
60
  );
61
- const { popoutWrapper } = useGridPopoutHook(props, save);
61
+ const { popoverWrapper } = useGridPopoverHook(props, save);
62
62
 
63
63
  // Load up options list if it's async function
64
64
  useEffect(() => {
@@ -105,7 +105,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
105
105
  );
106
106
  }, [formProps.filtered, filter, options]);
107
107
 
108
- return popoutWrapper(
108
+ return popoverWrapper(
109
109
  <ComponentLoadingWrapper loading={!options}>
110
110
  <div className={"Grid-popoverContainerList"}>
111
111
  {options && formProps.filtered && (
@@ -1,10 +1,10 @@
1
1
  import { GridBaseRow } from "../Grid";
2
2
  import { useCallback, useContext, useEffect, useRef, useState } from "react";
3
- import { GridContext } from "../../contexts/GridContext";
3
+ import { GridContext } from "@contexts/GridContext";
4
4
  import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
5
5
  import { MenuDivider, MenuItem } from "@szhsin/react-menu";
6
6
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
7
- import { useGridPopoutHook } from "../GridPopoutHook";
7
+ import { useGridPopoverHook } from "../GridPopoverHook";
8
8
 
9
9
  export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
10
10
  options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
@@ -19,7 +19,8 @@ interface MenuSeparatorType {
19
19
 
20
20
  export interface MenuOption<RowType> {
21
21
  label: JSX.Element | string | MenuSeparatorType;
22
- action: (selectedRows: RowType[]) => Promise<boolean>;
22
+ action?: (selectedRows: RowType[]) => Promise<boolean>;
23
+ disabled?: string | boolean;
23
24
  multiEdit: boolean;
24
25
  }
25
26
 
@@ -54,7 +55,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
54
55
  const actionClick = useCallback(
55
56
  async (menuOption: MenuOption<any>) => {
56
57
  return await updatingCells({ selectedRows: props.selectedRows, field: props.field }, async (selectedRows) => {
57
- await menuOption.action(selectedRows);
58
+ menuOption.action && (await menuOption.action(selectedRows));
58
59
  return true;
59
60
  });
60
61
  },
@@ -67,8 +68,8 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
67
68
  return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.multiEdit;
68
69
  });
69
70
 
70
- const { popoutWrapper } = useGridPopoutHook(props);
71
- return popoutWrapper(
71
+ const { popoverWrapper } = useGridPopoverHook(props);
72
+ return popoverWrapper(
72
73
  <ComponentLoadingWrapper loading={!filteredOptions}>
73
74
  <div className={"Grid-popoverContainerList"}>
74
75
  {options?.map((item, index) =>
@@ -78,7 +79,8 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
78
79
  <MenuItem
79
80
  key={`${item.label}`}
80
81
  onClick={() => actionClick(item)}
81
- disabled={!filteredOptions?.includes(item)}
82
+ disabled={!!item.disabled || !filteredOptions?.includes(item)}
83
+ title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
82
84
  >
83
85
  {item.label as JSX.Element | string}
84
86
  </MenuItem>
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useState } from "react";
2
2
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
3
3
  import { TextAreaInput } from "../../lui/TextAreaInput";
4
- import { useGridPopoutHook } from "../GridPopoutHook";
4
+ import { useGridPopoverHook } from "../GridPopoverHook";
5
5
  import { GridBaseRow } from "../Grid";
6
6
 
7
7
  export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
@@ -28,7 +28,7 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
28
28
  return formProps.validate(value);
29
29
  }
30
30
  return null;
31
- }, [formProps.maxlength, formProps.required, value.length]);
31
+ }, [formProps, value]);
32
32
 
33
33
  const save = useCallback(
34
34
  async (selectedRows: any[]): Promise<boolean> => {
@@ -50,9 +50,9 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
50
50
  },
51
51
  [formProps, invalid, props.field, props.value, value],
52
52
  );
53
- const { popoutWrapper } = useGridPopoutHook(props, save);
53
+ const { popoverWrapper } = useGridPopoverHook(props, save);
54
54
 
55
- return popoutWrapper(
55
+ return popoverWrapper(
56
56
  <div style={{ display: "flex", flexDirection: "row", width: formProps.width ?? 240 }} className={"FormTest"}>
57
57
  <TextAreaInput
58
58
  value={value}
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useState } from "react";
2
2
  import { GenericCellEditorParams, GridFormProps } from "../GridCell";
3
3
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
4
- import { useGridPopoutHook } from "../GridPopoutHook";
4
+ import { useGridPopoverHook } from "../GridPopoverHook";
5
5
  import { GridBaseRow } from "../Grid";
6
6
 
7
7
  export interface GridFormTextInputProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
@@ -28,7 +28,7 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
28
28
  return formProps.validate(value);
29
29
  }
30
30
  return null;
31
- }, [formProps.maxlength, formProps.required, value.length]);
31
+ }, [formProps, value]);
32
32
 
33
33
  const save = useCallback(
34
34
  async (selectedRows: any[]): Promise<boolean> => {
@@ -50,9 +50,9 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
50
50
  },
51
51
  [invalid, props.value, props.field, value, formProps],
52
52
  );
53
- const { popoutWrapper, triggerSave } = useGridPopoutHook(props, save);
53
+ const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
54
54
 
55
- return popoutWrapper(
55
+ return popoverWrapper(
56
56
  <div style={{ display: "flex", flexDirection: "row", width: formProps.width ?? 240 }} className={"FormTest"}>
57
57
  <TextInputFormatted
58
58
  value={value}
@@ -1,5 +1,5 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef, GridRendererGenericCell } from "../gridRender/GridRenderGenericCell";
2
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
3
  import { GridCell } from "../GridCell";
4
4
  import { GridBaseRow } from "../Grid";
5
5
  import { GridFormMultiSelect, GridFormMultiSelectProps } from "../gridForm/GridFormMultiSelect";
@@ -10,7 +10,6 @@ export const GridPopoutEditMultiSelect = <RowType extends GridBaseRow, ValueType
10
10
  GridCell<RowType, GridFormMultiSelectProps<RowType, ValueType>>({
11
11
  initialWidth: 65,
12
12
  maxWidth: 150,
13
- cellRenderer: GridRendererGenericCell,
14
13
  cellClass: colDef.cellEditor?.multiEdit ? GenericMultiEditCellClass : undefined,
15
14
  ...colDef,
16
15
  ...(colDef?.cellEditorParams && {
@@ -1,18 +1,17 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef, GridRendererGenericCell } from "../gridRender/GridRenderGenericCell";
3
- import { bearingValueFormatter } from "../../utils/bearing";
2
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
+ import { bearingCorrectionValueFormatter, bearingValueFormatter } from "@utils/bearing";
4
4
  import { GridCell } from "../GridCell";
5
5
  import { GridFormEditBearing, GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
6
6
  import { GridBaseRow } from "../Grid";
7
7
 
8
- export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
8
+ export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
9
9
  colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
10
10
  ) =>
11
11
  GridCell<RowType, GridFormEditBearingProps<RowType>>({
12
12
  initialWidth: 65,
13
13
  maxWidth: 150,
14
14
  valueFormatter: bearingValueFormatter,
15
- cellRenderer: GridRendererGenericCell,
16
15
  cellClass: colDef.cellEditorParams?.multiEdit ? GenericMultiEditCellClass : undefined,
17
16
  ...colDef,
18
17
  ...(colDef?.cellEditorParams && {
@@ -22,3 +21,29 @@ export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
22
21
  },
23
22
  }),
24
23
  });
24
+
25
+ export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
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
+ });
37
+
38
+ export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
39
+ 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
+ });
@@ -1,5 +1,5 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef, GridRendererGenericCell } from "../gridRender/GridRenderGenericCell";
2
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
3
  import { GridCell } from "../GridCell";
4
4
  import { GridBaseRow } from "../Grid";
5
5
  import { GridFormDropDown, GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
@@ -10,7 +10,6 @@ export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
10
10
  GridCell<RowType, GridFormPopoutDropDownProps<RowType, ValueType>>({
11
11
  initialWidth: 65,
12
12
  maxWidth: 150,
13
- cellRenderer: GridRendererGenericCell,
14
13
  cellClass: colDef.cellEditor?.multiEdit ? GenericMultiEditCellClass : undefined,
15
14
  ...colDef,
16
15
  ...(colDef?.cellEditorParams && {
@@ -1,4 +1,4 @@
1
- import "./GridPopoutMenu.scss";
1
+ import "./GridPopoverMenu.scss";
2
2
  import "@szhsin/react-menu/dist/index.css";
3
3
 
4
4
  import { ColDef } from "ag-grid-community";
@@ -12,7 +12,7 @@ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
12
12
  /**
13
13
  * Popout burger menu
14
14
  */
15
- export const GridPopoutMenu = <RowType extends GridBaseRow>(
15
+ export const GridPopoverMenu = <RowType extends GridBaseRow>(
16
16
  colDef: GenericCellColDef<RowType, GridFormPopoutMenuProps<RowType>>,
17
17
  ): ColDef =>
18
18
  GridCell<RowType, GridFormPopoutMenuProps<RowType>>({
@@ -1,6 +1,6 @@
1
1
  import { createContext } from "react";
2
2
  import { GridApi } from "ag-grid-community";
3
- import { GridBaseRow } from "../components/Grid";
3
+ import { GridBaseRow } from "@components/Grid";
4
4
 
5
5
  export interface GridContextType {
6
6
  gridReady: () => boolean;
@@ -2,9 +2,9 @@ import { ReactElement, ReactNode, useContext, useRef } from "react";
2
2
  import { GridApi, RowNode } from "ag-grid-community";
3
3
  import { GridContext } from "./GridContext";
4
4
  import { delay, difference, isEmpty, last, sortBy } from "lodash-es";
5
- import { isNotEmpty } from "../utils/util";
5
+ import { isNotEmpty } from "@utils/util";
6
6
  import { UpdatingContext } from "./UpdatingContext";
7
- import { GridBaseRow } from "../components/Grid";
7
+ import { GridBaseRow } from "@components/Grid";
8
8
 
9
9
  interface GridContextProps {
10
10
  children: ReactNode;
@@ -1,5 +1,5 @@
1
1
  .LuiTextInput {
2
- margin-bottom: 0px;
2
+ margin-bottom: 0;
3
3
  }
4
4
 
5
5
  .LuiTextInput-formatted {