@linzjs/step-ag-grid 1.5.3 → 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 (64) hide show
  1. package/dist/index.d.ts +9 -9
  2. package/dist/index.js +410 -358
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/Grid.d.ts +1 -1
  5. package/dist/src/components/GridCell.d.ts +18 -27
  6. package/dist/src/components/GridPopoverHook.d.ts +4 -2
  7. package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -3
  8. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -4
  9. package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
  10. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -10
  11. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -4
  12. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
  13. package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
  14. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
  15. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
  16. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
  17. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  18. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
  19. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
  20. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
  21. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -3
  22. package/dist/src/contexts/GridContext.d.ts +1 -0
  23. package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
  24. package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
  25. package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
  26. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
  27. package/dist/src/stories/components/FormTest.d.ts +1 -2
  28. package/dist/step-ag-grid.esm.js +404 -356
  29. package/dist/step-ag-grid.esm.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/components/Grid.tsx +20 -15
  32. package/src/components/GridCell.tsx +57 -79
  33. package/src/components/GridLoadableCell.tsx +4 -1
  34. package/src/components/GridPopoverHook.tsx +10 -14
  35. package/src/components/gridForm/GridFormDropDown.tsx +41 -30
  36. package/src/components/gridForm/GridFormEditBearing.tsx +13 -13
  37. package/src/components/gridForm/GridFormMessage.tsx +8 -13
  38. package/src/components/gridForm/GridFormMultiSelect.tsx +27 -29
  39. package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
  40. package/src/components/gridForm/GridFormTextArea.tsx +16 -17
  41. package/src/components/gridForm/GridFormTextInput.tsx +19 -18
  42. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +17 -16
  43. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
  44. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +17 -16
  45. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +20 -21
  46. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
  47. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
  48. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
  49. package/src/components/gridRender/GridRenderGenericCell.tsx +3 -5
  50. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
  51. package/src/contexts/GridContext.tsx +4 -0
  52. package/src/contexts/GridContextProvider.tsx +13 -5
  53. package/src/contexts/GridPopoverContext.tsx +32 -0
  54. package/src/contexts/GridPopoverContextProvider.tsx +53 -0
  55. package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
  56. package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
  57. package/src/stories/components/FormTest.tsx +4 -3
  58. package/src/stories/components/GridPopoutBearing.stories.tsx +28 -25
  59. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +91 -50
  60. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -13
  61. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +76 -61
  62. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +58 -51
  63. package/src/stories/components/GridReadOnly.stories.tsx +73 -57
  64. package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
@@ -6,46 +6,44 @@ 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";
10
+ import { MenuSeparatorString } from "@components/gridForm/GridFormDropDown";
11
+ import { CellParams } from "@components/GridCell";
11
12
 
12
- interface FinalSelectOption<ValueType> {
13
+ interface MultiFinalSelectOption<ValueType> {
13
14
  value: ValueType;
14
15
  label?: JSX.Element | string;
15
16
  subComponent?: (props: any, ref: any) => any;
16
17
  }
17
18
 
18
- export const MenuSeparatorString = "_____MENU_SEPARATOR_____";
19
- export const MenuSeparator = Object.freeze({ value: MenuSeparatorString });
20
-
21
- export type SelectOption<ValueType> = ValueType | FinalSelectOption<ValueType>;
19
+ export type MultiSelectOption<ValueType> = ValueType | MultiFinalSelectOption<ValueType>;
22
20
 
23
21
  export interface MultiSelectResult<RowType> {
24
22
  selectedRows: RowType[];
25
23
  values: Record<string, any>;
26
24
  }
27
25
 
28
- export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType>
29
- extends GenericCellEditorParams<RowType> {
26
+ export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> {
30
27
  filtered?: boolean;
31
28
  filterPlaceholder?: string;
32
29
  onSave?: (props: MultiSelectResult<RowType>) => Promise<boolean>;
33
30
  options:
34
- | SelectOption<ValueType>[]
35
- | ((selectedRows: RowType[]) => Promise<SelectOption<ValueType>[]> | SelectOption<ValueType>[]);
31
+ | MultiSelectOption<ValueType>[]
32
+ | ((selectedRows: RowType[]) => Promise<MultiSelectOption<ValueType>[]> | MultiSelectOption<ValueType>[]);
36
33
  initialSelectedValues?: (selectedRows: RowType[]) => any[];
37
34
  }
38
35
 
39
- export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(props: GridFormProps<RowType>) => {
40
- const formProps = props.formProps as GridFormMultiSelectProps<RowType, ValueType>;
41
-
36
+ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
37
+ props: GridFormMultiSelectProps<RowType, ValueType>,
38
+ ) => {
39
+ const { selectedRows } = props as unknown as CellParams<RowType>;
42
40
  const [filter, setFilter] = useState("");
43
41
  const [filteredValues, setFilteredValues] = useState<any[]>([]);
44
42
  const optionsInitialising = useRef(false);
45
- const [options, setOptions] = useState<FinalSelectOption<ValueType>[]>();
43
+ const [options, setOptions] = useState<MultiFinalSelectOption<ValueType>[]>();
46
44
  const subSelectedValues = useRef<Record<string, any>>({});
47
45
  const [selectedValues, setSelectedValues] = useState<any[]>(() =>
48
- formProps.initialSelectedValues ? formProps.initialSelectedValues(props.selectedRows) : [],
46
+ props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [],
49
47
  );
50
48
 
51
49
  const save = useCallback(
@@ -53,34 +51,34 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
53
51
  const values: Record<string, any> = fromPairs(
54
52
  selectedValues.map((value) => [value, subSelectedValues.current[value] ?? true]),
55
53
  );
56
- if (formProps.onSave) {
57
- return await formProps.onSave({ selectedRows, values });
54
+ if (props.onSave) {
55
+ return await props.onSave({ selectedRows, values });
58
56
  }
59
57
  return true;
60
58
  },
61
- [formProps, selectedValues],
59
+ [props, selectedValues],
62
60
  );
63
- const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
61
+ const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
64
62
 
65
63
  // Load up options list if it's async function
66
64
  useEffect(() => {
67
65
  if (options || optionsInitialising.current) return;
68
66
  optionsInitialising.current = true;
69
- let optionsConf = formProps.options ?? [];
67
+ let optionsConf = props.options ?? [];
70
68
 
71
69
  (async () => {
72
70
  if (typeof optionsConf == "function") {
73
- optionsConf = await optionsConf(props.selectedRows);
71
+ optionsConf = await optionsConf(selectedRows);
74
72
  }
75
73
 
76
74
  const optionsList = optionsConf?.map((item) => {
77
75
  if (item == null || typeof item == "string" || typeof item == "number") {
78
- item = { value: item as ValueType, label: item } as FinalSelectOption<ValueType>;
76
+ item = { value: item as ValueType, label: item } as MultiFinalSelectOption<ValueType>;
79
77
  }
80
78
  return item;
81
- }) as any as FinalSelectOption<ValueType>[];
79
+ }) as any as MultiFinalSelectOption<ValueType>[];
82
80
 
83
- if (formProps.filtered) {
81
+ if (props.filtered) {
84
82
  // This is needed otherwise when filter input is rendered and sets autofocus
85
83
  // the mouse up of the double click edit triggers the cell to cancel editing
86
84
  delay(() => setOptions(optionsList), 100);
@@ -89,10 +87,10 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
89
87
  }
90
88
  optionsInitialising.current = false;
91
89
  })();
92
- }, [formProps.filtered, formProps.options, options, props.selectedRows]);
90
+ }, [props.filtered, props.options, options, selectedRows]);
93
91
 
94
92
  useEffect(() => {
95
- if (!formProps.filtered || options == null) return;
93
+ if (!props.filtered || options == null) return;
96
94
  setFilteredValues(
97
95
  options
98
96
  .map((option) => {
@@ -105,12 +103,12 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
105
103
  })
106
104
  .filter((r) => r !== undefined),
107
105
  );
108
- }, [formProps.filtered, filter, options]);
106
+ }, [props.filtered, filter, options]);
109
107
 
110
108
  return popoverWrapper(
111
109
  <ComponentLoadingWrapper loading={!options}>
112
110
  <div className={"Grid-popoverContainerList"}>
113
- {options && formProps.filtered && (
111
+ {options && props.filtered && (
114
112
  <>
115
113
  <FocusableItem className={"filter-item"} key={"filter"}>
116
114
  {({ ref }: any) => (
@@ -121,7 +119,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(prop
121
119
  style={{ border: "0px" }}
122
120
  ref={ref}
123
121
  type="text"
124
- placeholder={formProps.filterPlaceholder ?? "Placeholder"}
122
+ placeholder={props.filterPlaceholder ?? "Placeholder"}
125
123
  data-testid={"filteredMenu-free-text-input"}
126
124
  defaultValue={""}
127
125
  onChange={(e) => setFilter(e.target.value.toLowerCase())}
@@ -3,15 +3,15 @@ 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
 
13
13
  /** Menu configuration types **/
14
- export const MenuSeparator = Object.freeze({ __isMenuSeparator__: true });
14
+ export const PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
15
15
 
16
16
  interface MenuSeparatorType {
17
17
  __isMenuSeparator__: boolean;
@@ -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>) => {
@@ -66,15 +65,15 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
66
65
  const selectedRowCount = props.selectedRows.length;
67
66
 
68
67
  const filteredOptions = options?.filter((menuOption) => {
69
- return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
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"}>
76
75
  {options?.map((item, index) =>
77
- item.label === MenuSeparator ? (
76
+ item.label === PopoutMenuSeparator ? (
78
77
  <MenuDivider key={`$$divider_${index}`} />
79
78
  ) : (
80
79
  !item.hidden && (
@@ -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,37 +1,38 @@
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;
11
11
  maxlength?: number;
12
12
  width?: string | number;
13
- validate?: (value: string) => string | null;
13
+ // Return null for ok, otherwise an error string
14
+ validate?: (value: string, data: RowType) => string | null;
14
15
  onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
15
16
  }
16
17
 
17
- export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormProps<RowType>) => {
18
- 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>;
19
20
  const initValue = props.value == null ? "" : `${props.value}`;
20
21
  const [value, setValue] = useState(initValue);
21
22
 
22
23
  const invalid = useCallback(() => {
23
24
  const trimmedValue = value.trim();
24
- if (formProps.required && trimmedValue.length == 0) {
25
+ if (props.required && trimmedValue.length == 0) {
25
26
  return `Some text is required`;
26
27
  }
27
- if (formProps.maxlength && trimmedValue.length > formProps.maxlength) {
28
- 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`;
29
30
  }
30
- if (formProps.validate) {
31
- return formProps.validate(trimmedValue);
31
+ if (props.validate) {
32
+ return props.validate(trimmedValue, props.data);
32
33
  }
33
34
  return null;
34
- }, [formProps, value]);
35
+ }, [props, value]);
35
36
 
36
37
  const save = useCallback(
37
38
  async (selectedRows: any[]): Promise<boolean> => {
@@ -39,8 +40,8 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
39
40
  const trimmedValue = value.trim();
40
41
  if (initValue === trimmedValue) return true;
41
42
 
42
- if (formProps.onSave) {
43
- return await formProps.onSave(selectedRows, trimmedValue);
43
+ if (props.onSave) {
44
+ return await props.onSave(selectedRows, trimmedValue);
44
45
  }
45
46
 
46
47
  const field = props.field;
@@ -51,20 +52,20 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(props: GridFormPr
51
52
  selectedRows.forEach((row) => (row[field] = trimmedValue));
52
53
  return true;
53
54
  },
54
- [invalid, value, initValue, formProps, props.field],
55
+ [invalid, value, initValue, props],
55
56
  );
56
- const { popoverWrapper, triggerSave } = useGridPopoverHook(props, save);
57
+ const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
57
58
 
58
59
  return popoverWrapper(
59
- <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"}>
60
61
  <TextInputFormatted
61
62
  value={value}
62
63
  onChange={(e) => setValue(e.target.value)}
63
64
  error={invalid()}
64
- formatted={formProps.units}
65
+ formatted={props.units}
65
66
  inputProps={{
66
67
  style: { width: "100%" },
67
- placeholder: formProps.placeholder,
68
+ placeholder: props.placeholder,
68
69
  onKeyDown: async (e) => e.key === "Enter" && triggerSave().then(),
69
70
  }}
70
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
+ );