@linzjs/step-ag-grid 1.5.4 → 2.0.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 (61) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js +241 -200
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/GridCell.d.ts +18 -27
  5. package/dist/src/components/GridPopoverHook.d.ts +4 -2
  6. package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -3
  7. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -4
  8. package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
  9. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +2 -3
  10. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -3
  11. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
  12. package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -3
  13. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
  14. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
  15. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
  16. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  17. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
  18. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
  19. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
  20. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -3
  21. package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
  22. package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
  23. package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
  24. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
  25. package/dist/src/stories/components/FormTest.d.ts +1 -2
  26. package/dist/step-ag-grid.esm.js +238 -198
  27. package/dist/step-ag-grid.esm.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/components/Grid.tsx +2 -2
  30. package/src/components/GridCell.tsx +57 -79
  31. package/src/components/GridLoadableCell.tsx +4 -1
  32. package/src/components/GridPopoverHook.tsx +10 -14
  33. package/src/components/gridForm/GridFormDropDown.tsx +41 -30
  34. package/src/components/gridForm/GridFormEditBearing.tsx +13 -13
  35. package/src/components/gridForm/GridFormMessage.tsx +8 -13
  36. package/src/components/gridForm/GridFormMultiSelect.tsx +19 -19
  37. package/src/components/gridForm/GridFormPopoutMenu.tsx +7 -8
  38. package/src/components/gridForm/GridFormTextArea.tsx +16 -17
  39. package/src/components/gridForm/GridFormTextInput.tsx +17 -17
  40. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +17 -16
  41. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
  42. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +17 -16
  43. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +20 -21
  44. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
  45. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
  46. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
  47. package/src/components/gridRender/GridRenderGenericCell.tsx +3 -5
  48. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
  49. package/src/contexts/GridContextProvider.tsx +3 -5
  50. package/src/contexts/GridPopoverContext.tsx +32 -0
  51. package/src/contexts/GridPopoverContextProvider.tsx +53 -0
  52. package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
  53. package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
  54. package/src/stories/components/FormTest.tsx +4 -3
  55. package/src/stories/components/GridPopoutBearing.stories.tsx +28 -25
  56. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +91 -50
  57. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -13
  58. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +76 -61
  59. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +58 -51
  60. package/src/stories/components/GridReadOnly.stories.tsx +73 -57
  61. package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
@@ -6,9 +6,9 @@ import { GridBaseRow } from "../Grid";
6
6
  import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
7
7
  import { delay, fromPairs } from "lodash-es";
8
8
  import { LuiCheckboxInput } from "@linzjs/lui";
9
- import { GenericCellEditorParams, GridFormProps } from "../GridCell";
10
9
  import { useGridPopoverHook } from "../GridPopoverHook";
11
10
  import { MenuSeparatorString } from "@components/gridForm/GridFormDropDown";
11
+ import { CellParams } from "@components/GridCell";
12
12
 
13
13
  interface MultiFinalSelectOption<ValueType> {
14
14
  value: ValueType;
@@ -23,8 +23,7 @@ export interface MultiSelectResult<RowType> {
23
23
  values: Record<string, any>;
24
24
  }
25
25
 
26
- export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType>
27
- extends GenericCellEditorParams<RowType> {
26
+ export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> {
28
27
  filtered?: boolean;
29
28
  filterPlaceholder?: string;
30
29
  onSave?: (props: MultiSelectResult<RowType>) => Promise<boolean>;
@@ -34,16 +33,17 @@ export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType
34
33
  initialSelectedValues?: (selectedRows: RowType[]) => any[];
35
34
  }
36
35
 
37
- export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(props: GridFormProps<RowType>) => {
38
- const formProps = props.formProps as GridFormMultiSelectProps<RowType, ValueType>;
39
-
36
+ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
37
+ props: GridFormMultiSelectProps<RowType, ValueType>,
38
+ ) => {
39
+ const { selectedRows } = props as unknown as CellParams<RowType>;
40
40
  const [filter, setFilter] = useState("");
41
41
  const [filteredValues, setFilteredValues] = useState<any[]>([]);
42
42
  const optionsInitialising = useRef(false);
43
43
  const [options, setOptions] = useState<MultiFinalSelectOption<ValueType>[]>();
44
44
  const subSelectedValues = useRef<Record<string, any>>({});
45
45
  const [selectedValues, setSelectedValues] = useState<any[]>(() =>
46
- formProps.initialSelectedValues ? formProps.initialSelectedValues(props.selectedRows) : [],
46
+ props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [],
47
47
  );
48
48
 
49
49
  const save = useCallback(
@@ -51,24 +51,24 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
51
51
  const values: Record<string, any> = fromPairs(
52
52
  selectedValues.map((value) => [value, subSelectedValues.current[value] ?? true]),
53
53
  );
54
- if (formProps.onSave) {
55
- return await formProps.onSave({ selectedRows, values });
54
+ if (props.onSave) {
55
+ return await props.onSave({ selectedRows, values });
56
56
  }
57
57
  return true;
58
58
  },
59
- [formProps, selectedValues],
59
+ [props, selectedValues],
60
60
  );
61
- const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
61
+ const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
62
62
 
63
63
  // Load up options list if it's async function
64
64
  useEffect(() => {
65
65
  if (options || optionsInitialising.current) return;
66
66
  optionsInitialising.current = true;
67
- let optionsConf = formProps.options ?? [];
67
+ let optionsConf = props.options ?? [];
68
68
 
69
69
  (async () => {
70
70
  if (typeof optionsConf == "function") {
71
- optionsConf = await optionsConf(props.selectedRows);
71
+ optionsConf = await optionsConf(selectedRows);
72
72
  }
73
73
 
74
74
  const optionsList = optionsConf?.map((item) => {
@@ -78,7 +78,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
78
78
  return item;
79
79
  }) as any as MultiFinalSelectOption<ValueType>[];
80
80
 
81
- if (formProps.filtered) {
81
+ if (props.filtered) {
82
82
  // This is needed otherwise when filter input is rendered and sets autofocus
83
83
  // the mouse up of the double click edit triggers the cell to cancel editing
84
84
  delay(() => setOptions(optionsList), 100);
@@ -87,10 +87,10 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
87
87
  }
88
88
  optionsInitialising.current = false;
89
89
  })();
90
- }, [formProps.filtered, formProps.options, options, props.selectedRows]);
90
+ }, [props.filtered, props.options, options, selectedRows]);
91
91
 
92
92
  useEffect(() => {
93
- if (!formProps.filtered || options == null) return;
93
+ if (!props.filtered || options == null) return;
94
94
  setFilteredValues(
95
95
  options
96
96
  .map((option) => {
@@ -103,12 +103,12 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
103
103
  })
104
104
  .filter((r) => r !== undefined),
105
105
  );
106
- }, [formProps.filtered, filter, options]);
106
+ }, [props.filtered, filter, options]);
107
107
 
108
108
  return popoverWrapper(
109
109
  <ComponentLoadingWrapper loading={!options}>
110
110
  <div className={"Grid-popoverContainerList"}>
111
- {options && formProps.filtered && (
111
+ {options && props.filtered && (
112
112
  <>
113
113
  <FocusableItem className={"filter-item"} key={"filter"}>
114
114
  {({ ref }: any) => (
@@ -119,7 +119,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
119
119
  style={{ border: "0px" }}
120
120
  ref={ref}
121
121
  type="text"
122
- placeholder={formProps.filterPlaceholder ?? "Placeholder"}
122
+ placeholder={props.filterPlaceholder ?? "Placeholder"}
123
123
  data-testid={"filteredMenu-free-text-input"}
124
124
  defaultValue={""}
125
125
  onChange={(e) => setFilter(e.target.value.toLowerCase())}
@@ -3,10 +3,10 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react";
3
3
  import { GridContext } from "@contexts/GridContext";
4
4
  import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
5
5
  import { MenuDivider, MenuItem } from "@react-menu3";
6
- import { GenericCellEditorParams, GridFormProps } from "../GridCell";
7
6
  import { useGridPopoverHook } from "../GridPopoverHook";
7
+ import { CellParams } from "@components/GridCell";
8
8
 
9
- export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
9
+ export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> {
10
10
  options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
11
11
  }
12
12
 
@@ -29,9 +29,8 @@ export interface MenuOption<RowType> {
29
29
  * NOTE: If the popout menu doesn't appear on single click when also selecting row it's because
30
30
  * you need a useMemo around your columnDefs
31
31
  */
32
- export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormProps<RowType>) => {
33
- const formProps = props.formProps as GridFormPopoutMenuProps<RowType>;
34
-
32
+ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(_props: GridFormPopoutMenuProps<RowType>) => {
33
+ const props = _props as GridFormPopoutMenuProps<RowType> & CellParams<RowType>;
35
34
  const { updatingCells } = useContext(GridContext);
36
35
  const optionsInitialising = useRef(false);
37
36
  const [options, setOptions] = useState<MenuOption<RowType>[]>();
@@ -40,7 +39,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
40
39
  useEffect(() => {
41
40
  if (options || optionsInitialising.current) return;
42
41
  optionsInitialising.current = true;
43
- const optionsConf = formProps.options ?? [];
42
+ const optionsConf = props.options ?? [];
44
43
 
45
44
  (async () => {
46
45
  if (typeof optionsConf == "function") {
@@ -51,7 +50,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
51
50
 
52
51
  optionsInitialising.current = false;
53
52
  })();
54
- }, [options, formProps.options, props.selectedRows]);
53
+ }, [options, props.options, props.selectedRows]);
55
54
 
56
55
  const actionClick = useCallback(
57
56
  async (menuOption: MenuOption<any>) => {
@@ -69,7 +68,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
69
68
  return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
70
69
  });
71
70
 
72
- const { popoverWrapper } = useGridPopoverHook(props);
71
+ const { popoverWrapper } = useGridPopoverHook();
73
72
  return popoverWrapper(
74
73
  <ComponentLoadingWrapper loading={!filteredOptions}>
75
74
  <div className={"Grid-popoverContainerList"}>
@@ -1,10 +1,10 @@
1
1
  import { useCallback, useState } from "react";
2
- import { GenericCellEditorParams, GridFormProps } from "../GridCell";
3
2
  import { TextAreaInput } from "../../lui/TextAreaInput";
4
3
  import { useGridPopoverHook } from "../GridPopoverHook";
5
4
  import { GridBaseRow } from "../Grid";
5
+ import { CellParams } from "@components/GridCell";
6
6
 
7
- export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
7
+ export interface GridFormTextAreaProps<RowType extends GridBaseRow> {
8
8
  placeholder?: string;
9
9
  required?: boolean;
10
10
  maxlength?: number;
@@ -13,22 +13,22 @@ export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends Gene
13
13
  onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
14
14
  }
15
15
 
16
- export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormProps<RowType>) => {
17
- const formProps = props.formProps as GridFormTextAreaProps<RowType>;
16
+ export const GridFormTextArea = <RowType extends GridBaseRow>(_props: GridFormTextAreaProps<RowType>) => {
17
+ const props = _props as GridFormTextAreaProps<RowType> & CellParams<RowType>;
18
18
  const [value, setValue] = useState(props.value ?? "");
19
19
 
20
20
  const invalid = useCallback(() => {
21
- if (formProps.required && value.length == 0) {
21
+ if (props.required && value.length == 0) {
22
22
  return `Some text is required`;
23
23
  }
24
- if (formProps.maxlength && value.length > formProps.maxlength) {
25
- return `Text must be no longer than ${formProps.maxlength} characters`;
24
+ if (props.maxlength && value.length > props.maxlength) {
25
+ return `Text must be no longer than ${props.maxlength} characters`;
26
26
  }
27
- if (formProps.validate) {
28
- return formProps.validate(value);
27
+ if (props.validate) {
28
+ return props.validate(value);
29
29
  }
30
30
  return null;
31
- }, [formProps, value]);
31
+ }, [props, value]);
32
32
 
33
33
  const save = useCallback(
34
34
  async (selectedRows: any[]): Promise<boolean> => {
@@ -36,8 +36,8 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
36
36
 
37
37
  if (props.value === (value ?? "")) return true;
38
38
 
39
- if (formProps.onSave) {
40
- return await formProps.onSave(selectedRows, value);
39
+ if (props.onSave) {
40
+ return await props.onSave(selectedRows, value);
41
41
  }
42
42
 
43
43
  const field = props.field;
@@ -48,17 +48,16 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormPro
48
48
  selectedRows.forEach((row) => (row[field] = value));
49
49
  return true;
50
50
  },
51
- [formProps, invalid, props.field, props.value, value],
51
+ [props, invalid, value],
52
52
  );
53
- const { popoverWrapper } = useGridPopoverHook(props, save);
54
-
53
+ const { popoverWrapper } = useGridPopoverHook({ save });
55
54
  return popoverWrapper(
56
- <div style={{ display: "flex", flexDirection: "row", width: formProps.width ?? 240 }} className={"FormTest"}>
55
+ <div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
57
56
  <TextAreaInput
58
57
  value={value}
59
58
  onChange={(e) => setValue(e.target.value)}
60
59
  error={invalid()}
61
- inputProps={{ placeholder: formProps.placeholder }}
60
+ inputProps={{ placeholder: props.placeholder }}
62
61
  />
63
62
  </div>,
64
63
  );
@@ -1,10 +1,10 @@
1
1
  import { useCallback, useState } from "react";
2
- import { GenericCellEditorParams, GridFormProps } from "../GridCell";
3
2
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
4
3
  import { useGridPopoverHook } from "../GridPopoverHook";
5
4
  import { GridBaseRow } from "../Grid";
5
+ import { CellParams } from "@components/GridCell";
6
6
 
7
- export interface GridFormTextInputProps<RowType extends GridBaseRow> extends GenericCellEditorParams<RowType> {
7
+ export interface GridFormTextInputProps<RowType extends GridBaseRow> {
8
8
  placeholder?: string;
9
9
  units?: string;
10
10
  required?: boolean;
@@ -15,24 +15,24 @@ export interface GridFormTextInputProps<RowType extends GridBaseRow> extends Gen
15
15
  onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
16
16
  }
17
17
 
18
- export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormProps<RowType>) => {
19
- const formProps = props.formProps as GridFormTextInputProps<RowType>;
18
+ export const GridFormTextInput = <RowType extends GridBaseRow>(_props: GridFormTextInputProps<RowType>) => {
19
+ const props = _props as GridFormTextInputProps<RowType> & CellParams<RowType>;
20
20
  const initValue = props.value == null ? "" : `${props.value}`;
21
21
  const [value, setValue] = useState(initValue);
22
22
 
23
23
  const invalid = useCallback(() => {
24
24
  const trimmedValue = value.trim();
25
- if (formProps.required && trimmedValue.length == 0) {
25
+ if (props.required && trimmedValue.length == 0) {
26
26
  return `Some text is required`;
27
27
  }
28
- if (formProps.maxlength && trimmedValue.length > formProps.maxlength) {
29
- return `Text must be no longer than ${formProps.maxlength} characters`;
28
+ if (props.maxlength && trimmedValue.length > props.maxlength) {
29
+ return `Text must be no longer than ${props.maxlength} characters`;
30
30
  }
31
- if (formProps.validate) {
32
- return formProps.validate(trimmedValue, props.data);
31
+ if (props.validate) {
32
+ return props.validate(trimmedValue, props.data);
33
33
  }
34
34
  return null;
35
- }, [formProps, value]);
35
+ }, [props, value]);
36
36
 
37
37
  const save = useCallback(
38
38
  async (selectedRows: any[]): Promise<boolean> => {
@@ -40,8 +40,8 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
40
40
  const trimmedValue = value.trim();
41
41
  if (initValue === trimmedValue) return true;
42
42
 
43
- if (formProps.onSave) {
44
- return await formProps.onSave(selectedRows, trimmedValue);
43
+ if (props.onSave) {
44
+ return await props.onSave(selectedRows, trimmedValue);
45
45
  }
46
46
 
47
47
  const field = props.field;
@@ -52,20 +52,20 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
52
52
  selectedRows.forEach((row) => (row[field] = trimmedValue));
53
53
  return true;
54
54
  },
55
- [invalid, value, initValue, formProps, props.field],
55
+ [invalid, value, initValue, props],
56
56
  );
57
- const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
57
+ const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
58
58
 
59
59
  return popoverWrapper(
60
- <div style={{ display: "flex", flexDirection: "row", width: formProps.width ?? 240 }} className={"FormTest"}>
60
+ <div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
61
61
  <TextInputFormatted
62
62
  value={value}
63
63
  onChange={(e) => setValue(e.target.value)}
64
64
  error={invalid()}
65
- formatted={formProps.units}
65
+ formatted={props.units}
66
66
  inputProps={{
67
67
  style: { width: "100%" },
68
- placeholder: formProps.placeholder,
68
+ placeholder: props.placeholder,
69
69
  onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
70
70
  }}
71
71
  />
@@ -1,21 +1,22 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
- import { GridCell } from "../GridCell";
2
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
4
3
  import { GridBaseRow } from "../Grid";
5
4
  import { GridFormMultiSelect, GridFormMultiSelectProps } from "../gridForm/GridFormMultiSelect";
5
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
6
6
 
7
7
  export const GridPopoutEditMultiSelect = <RowType extends GridBaseRow, ValueType>(
8
- colDef: GenericCellColDef<RowType, GridFormMultiSelectProps<RowType, ValueType>>,
9
- ) =>
10
- GridCell<RowType, GridFormMultiSelectProps<RowType, ValueType>>({
11
- initialWidth: 65,
12
- maxWidth: 150,
13
- cellClass: colDef.cellEditor?.multiEdit ? GenericMultiEditCellClass : undefined,
14
- ...colDef,
15
- ...(colDef?.cellEditorParams && {
16
- cellEditorParams: {
17
- ...colDef.cellEditorParams,
18
- form: GridFormMultiSelect,
19
- },
20
- }),
21
- });
8
+ colDef: GenericCellColDef<RowType>,
9
+ props: GenericCellEditorProps<GridFormMultiSelectProps<RowType, ValueType>>,
10
+ ): ColDefT<RowType> =>
11
+ GridCell(
12
+ {
13
+ initialWidth: 65,
14
+ maxWidth: 150,
15
+ cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
16
+ ...colDef,
17
+ },
18
+ {
19
+ editor: GridFormMultiSelect,
20
+ ...props,
21
+ },
22
+ );
@@ -1,61 +1,69 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
2
  import { bearingCorrectionValueFormatter, bearingValueFormatter } from "@utils/bearing";
4
- import { GridCell } from "../GridCell";
3
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
5
4
  import { GridFormEditBearing, GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
6
5
  import { GridBaseRow } from "../Grid";
6
+ import { ColDef } from "ag-grid-community";
7
7
 
8
8
  export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
9
- colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
10
- ) =>
11
- GridCell<RowType, GridFormEditBearingProps<RowType>>({
12
- initialWidth: 65,
13
- maxWidth: 150,
14
- valueFormatter: bearingValueFormatter,
15
- cellClass: colDef.cellEditorParams?.multiEdit ? GenericMultiEditCellClass : undefined,
16
- ...colDef,
17
- ...(colDef?.cellEditorParams && {
18
- cellEditorParams: {
19
- ...colDef.cellEditorParams,
20
- form: GridFormEditBearing,
21
- },
22
- }),
23
- });
9
+ colDef: ColDef,
10
+ props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
11
+ ): ColDefT<RowType> => {
12
+ return GridCell(
13
+ {
14
+ initialWidth: 65,
15
+ maxWidth: 150,
16
+ valueFormatter: bearingValueFormatter,
17
+ cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
18
+ ...colDef,
19
+ },
20
+ {
21
+ editor: GridFormEditBearing,
22
+ ...props,
23
+ },
24
+ );
25
+ };
24
26
 
25
27
  export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
26
- colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
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;
28
+ colDef: ColDef,
29
+ props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
30
+ ): ColDefT<RowType> => {
31
+ return GridPopoverEditBearingLike(
32
+ { valueFormatter: bearingValueFormatter, ...colDef },
33
+ {
34
+ multiEdit: !!props.multiEdit,
35
+ editorParams: {
36
+ placeHolder: "Enter bearing correction",
37
+ range: (value: number | null) => {
38
+ if (value === null) return "Bearing correction is required";
39
+ if (value >= 360) return "Bearing correction must be less than 360 degrees";
40
+ if (value < 0) return "Bearing correction must not be negative";
41
+ return null;
42
+ },
43
+ ...props.editorParams,
38
44
  },
39
- ...init.cellEditorParams,
40
45
  },
41
- };
46
+ );
42
47
  };
43
48
 
44
49
  export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
45
- colDef: GenericCellColDef<RowType, GridFormEditBearingProps<RowType>>,
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;
50
+ colDef: ColDef,
51
+ props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
52
+ ): ColDefT<RowType> => {
53
+ return GridPopoverEditBearingLike(
54
+ { valueFormatter: bearingCorrectionValueFormatter, ...colDef },
55
+ {
56
+ multiEdit: !!props.multiEdit,
57
+ editorParams: {
58
+ placeHolder: "Enter bearing correction",
59
+ range: (value: number | null) => {
60
+ if (value === null) return "Bearing is required";
61
+ if (value >= 360) return "Bearing must be less than 360 degrees";
62
+ if (value <= -180) return "Bearing must be greater then -180 degrees";
63
+ return null;
64
+ },
65
+ ...props.editorParams,
57
66
  },
58
- ...init.cellEditorParams,
59
67
  },
60
- };
68
+ );
61
69
  };
@@ -1,21 +1,22 @@
1
1
  import { GenericMultiEditCellClass } from "../GenericCellClass";
2
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
3
- import { GridCell } from "../GridCell";
2
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
4
3
  import { GridBaseRow } from "../Grid";
5
4
  import { GridFormDropDown, GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
5
+ import { ColDef } from "ag-grid-community";
6
6
 
7
7
  export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
8
- colDef: GenericCellColDef<RowType, GridFormPopoutDropDownProps<RowType, ValueType>>,
9
- ) =>
10
- GridCell<RowType, GridFormPopoutDropDownProps<RowType, ValueType>>({
11
- initialWidth: 65,
12
- maxWidth: 150,
13
- cellClass: colDef.cellEditor?.multiEdit ? GenericMultiEditCellClass : undefined,
14
- ...colDef,
15
- ...(colDef?.cellEditorParams && {
16
- cellEditorParams: {
17
- ...colDef.cellEditorParams,
18
- form: GridFormDropDown,
19
- },
20
- }),
21
- });
8
+ colDef: ColDef,
9
+ props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType, ValueType>>,
10
+ ): ColDefT<RowType> =>
11
+ GridCell(
12
+ {
13
+ initialWidth: 65,
14
+ maxWidth: 150,
15
+ cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
16
+ ...colDef,
17
+ },
18
+ {
19
+ editor: GridFormDropDown,
20
+ ...props,
21
+ },
22
+ );
@@ -4,32 +4,31 @@ import "../../react-menu3/styles/index.scss";
4
4
  import { ColDef } from "ag-grid-community";
5
5
  import { GenericMultiEditCellClass } from "../GenericCellClass";
6
6
  import { GridBaseRow } from "../Grid";
7
- import { GridCell } from "../GridCell";
7
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
8
8
  import { GridFormPopoutMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
9
9
  import { GridRenderPopoutMenuCell } from "../gridRender/GridRenderPopoutMenuCell";
10
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
11
10
 
12
11
  /**
13
12
  * Popout burger menu
14
13
  */
15
14
  export const GridPopoverMenu = <RowType extends GridBaseRow>(
16
- colDef: GenericCellColDef<RowType, GridFormPopoutMenuProps<RowType>>,
17
- ): ColDef =>
18
- GridCell<RowType, GridFormPopoutMenuProps<RowType>>({
19
- maxWidth: 64,
20
- editable: colDef.editable != null ? colDef.editable : true,
21
- cellRenderer: GridRenderPopoutMenuCell,
22
- cellClass: colDef?.cellEditorParams?.multiEdit !== false ? GenericMultiEditCellClass : undefined,
23
- ...colDef,
24
- cellRendererParams: {
25
- // Menus open on single click, this parameter is picked up in Grid.tsx
26
- singleClickEdit: true,
27
- },
28
- ...(colDef?.cellEditorParams && {
29
- cellEditorParams: {
30
- multiEdit: true,
31
- ...colDef.cellEditorParams,
32
- form: GridFormPopoutMenu,
15
+ colDef: ColDef,
16
+ props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>,
17
+ ): ColDefT<RowType> =>
18
+ GridCell<RowType, GridFormPopoutMenuProps<RowType>>(
19
+ {
20
+ maxWidth: 64,
21
+ editable: colDef.editable != null ? colDef.editable : true,
22
+ cellRenderer: GridRenderPopoutMenuCell,
23
+ cellClass: colDef?.cellEditorParams?.multiEdit !== false ? GenericMultiEditCellClass : undefined,
24
+ ...colDef,
25
+ cellRendererParams: {
26
+ // Menus open on single click, this parameter is picked up in Grid.tsx
27
+ singleClickEdit: true,
33
28
  },
34
- }),
35
- });
29
+ },
30
+ {
31
+ editor: GridFormPopoutMenu,
32
+ ...props,
33
+ },
34
+ );
@@ -1,22 +1,24 @@
1
- import { GridCell } from "../GridCell";
1
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridFormMessage, GridFormMessageProps } from "../gridForm/GridFormMessage";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
4
+ import { ColDef } from "ag-grid-community";
5
5
 
6
6
  export const GridPopoverMessage = <RowType extends GridBaseRow>(
7
- colDef: GenericCellColDef<RowType, GridFormMessageProps<RowType>>,
8
- ) => {
9
- return GridCell<RowType, GridFormMessageProps<RowType>>({
10
- maxWidth: 140,
11
- ...colDef,
12
- cellRendererParams: colDef.cellRendererParams ?? {
13
- singleClickEdit: true,
14
- },
15
- ...(colDef?.cellEditorParams && {
16
- cellEditorParams: {
17
- ...colDef.cellEditorParams,
18
- form: GridFormMessage,
7
+ colDef: ColDef,
8
+ props: GenericCellEditorProps<GridFormMessageProps<RowType>>,
9
+ ): ColDefT<RowType> => {
10
+ return GridCell(
11
+ {
12
+ maxWidth: 140,
13
+ ...colDef,
14
+ cellRendererParams: {
15
+ singleClickEdit: true,
16
+ ...colDef.cellRendererParams,
19
17
  },
20
- }),
21
- });
18
+ },
19
+ {
20
+ editor: GridFormMessage,
21
+ ...props,
22
+ },
23
+ );
22
24
  };