@linzjs/step-ag-grid 1.5.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +117 -2
  2. package/{src/components → dist}/GridTheme.scss +37 -23
  3. package/dist/index.css +351 -0
  4. package/dist/index.js +625 -332
  5. package/dist/index.js.map +1 -1
  6. package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
  7. package/dist/src/components/Grid.d.ts +0 -2
  8. package/dist/src/components/GridCell.d.ts +21 -27
  9. package/dist/src/components/GridPopoverHook.d.ts +5 -2
  10. package/dist/src/components/gridForm/GridFormDropDown.d.ts +10 -4
  11. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +5 -5
  12. package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
  13. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -4
  14. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -3
  15. package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -3
  16. package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
  17. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
  18. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
  19. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
  20. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +3 -4
  21. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
  22. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
  23. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
  24. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +4 -5
  25. package/dist/src/contexts/GridContext.d.ts +1 -1
  26. package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
  27. package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
  28. package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
  29. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
  30. package/dist/src/index.d.ts +31 -0
  31. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -21
  32. package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -0
  33. package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -0
  34. package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -0
  35. package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -0
  36. package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -0
  37. package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -0
  38. package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -0
  39. package/dist/src/react-menu3/index.d.ts +0 -1
  40. package/dist/src/react-menu3/utils/constants.d.ts +1 -50
  41. package/dist/step-ag-grid.esm.js +622 -312
  42. package/dist/step-ag-grid.esm.js.map +1 -1
  43. package/package.json +39 -26
  44. package/src/components/ComponentLoadingWrapper.tsx +2 -1
  45. package/src/components/Grid.tsx +3 -8
  46. package/src/components/GridCell.tsx +62 -79
  47. package/src/components/GridLoadableCell.tsx +0 -1
  48. package/src/components/GridPopoverHook.tsx +18 -16
  49. package/src/components/gridForm/GridFormDropDown.tsx +47 -32
  50. package/src/components/gridForm/GridFormEditBearing.tsx +14 -14
  51. package/src/components/gridForm/GridFormMessage.tsx +11 -17
  52. package/src/components/gridForm/GridFormMultiSelect.tsx +89 -79
  53. package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
  54. package/src/components/gridForm/GridFormTextArea.tsx +16 -17
  55. package/src/components/gridForm/GridFormTextInput.tsx +17 -17
  56. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +20 -15
  57. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
  58. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +21 -15
  59. package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
  60. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +21 -23
  61. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
  62. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
  63. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
  64. package/src/components/gridRender/GridRenderGenericCell.tsx +5 -6
  65. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
  66. package/src/contexts/GridContext.tsx +1 -1
  67. package/src/contexts/GridContextProvider.tsx +3 -5
  68. package/src/contexts/GridPopoverContext.tsx +26 -0
  69. package/src/contexts/GridPopoverContextProvider.tsx +54 -0
  70. package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
  71. package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
  72. package/src/index.ts +38 -0
  73. package/src/lui/TextInputFormatted.scss +1 -1
  74. package/src/react-menu3/README.md +66 -0
  75. package/src/react-menu3/components/ControlledMenu.tsx +9 -17
  76. package/src/react-menu3/components/FocusableItem.tsx +2 -9
  77. package/src/react-menu3/components/MenuGroup.tsx +2 -1
  78. package/src/react-menu3/components/MenuItem.tsx +3 -12
  79. package/src/react-menu3/components/MenuList.tsx +4 -4
  80. package/src/react-menu3/components/MenuRadioGroup.tsx +3 -22
  81. package/src/react-menu3/components/SubMenu.tsx +4 -4
  82. package/src/react-menu3/contexts/EventHandlersContext.ts +11 -0
  83. package/src/react-menu3/contexts/HoverItemContext.ts +3 -0
  84. package/src/react-menu3/contexts/ItemSettingsContext.ts +6 -0
  85. package/src/react-menu3/contexts/MenuListContext.ts +10 -0
  86. package/src/react-menu3/contexts/MenuListItemContext.ts +16 -0
  87. package/src/react-menu3/contexts/RadioGroupContext.ts +8 -0
  88. package/src/react-menu3/contexts/SettingsContext.ts +20 -0
  89. package/src/react-menu3/hooks/useItemState.ts +3 -1
  90. package/src/react-menu3/index.ts +0 -1
  91. package/src/react-menu3/styles/_var.scss +4 -4
  92. package/src/react-menu3/styles/core.scss +6 -6
  93. package/src/react-menu3/styles/index.scss +10 -7
  94. package/src/react-menu3/styles/theme-dark.scss +4 -2
  95. package/src/react-menu3/styles/transitions/slide.scss +8 -8
  96. package/src/react-menu3/utils/constants.ts +1 -74
  97. package/src/react-menu3/utils/withHovering.tsx +1 -1
  98. package/src/stories/components/FormTest.scss +1 -2
  99. package/src/stories/components/FormTest.tsx +4 -3
  100. package/src/stories/components/GridPopoutBearing.stories.tsx +30 -26
  101. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +94 -51
  102. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -14
  103. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +78 -62
  104. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +60 -52
  105. package/src/stories/components/GridReadOnly.stories.tsx +77 -64
  106. package/src/stories/components/ReactMenu.stories.tsx +0 -4
  107. package/src/{components → styles}/Grid.scss +9 -6
  108. package/src/styles/GridFormDropDown.scss +18 -0
  109. package/src/{components/gridForm → styles}/GridFormEditBearing.scss +0 -0
  110. package/src/styles/GridFormMultiSelect.scss +18 -0
  111. package/src/styles/GridRenderGenericCell.scss +15 -0
  112. package/src/styles/GridTheme.scss +108 -0
  113. package/src/styles/index.scss +2 -0
  114. package/src/styles/lui-overrides.scss +49 -0
  115. package/src/styles/react-menu-customisations.scss +135 -0
  116. package/dist/index.d.ts +0 -38
  117. package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
  118. package/dist/src/stories/components/FormTest.d.ts +0 -13
  119. package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +0 -9
  120. package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +0 -9
  121. package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +0 -9
  122. package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +0 -9
  123. package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +0 -9
  124. package/dist/src/stories/components/GridReadOnly.stories.d.ts +0 -9
  125. package/dist/src/stories/components/ReactMenu.stories.d.ts +0 -8
  126. package/src/components/gridRender/GridRenderGenericCell.scss +0 -15
  127. package/src/lui-overrides.scss +0 -163
  128. package/src/react-menu3/style-utils.d.ts +0 -110
@@ -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 { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
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: GenericCellColDef<RowType>,
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: GenericCellColDef<RowType>,
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: GenericCellColDef<RowType>,
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,27 @@
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 { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
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,
8
+ colDef: GenericCellColDef<RowType>,
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
+ editorParams: {
22
+ // Defaults to medium size container
23
+ className: "GridPopoverEditDropDown-containerMedium",
24
+ ...(props.editorParams as GridFormPopoutDropDownProps<RowType, ValueType>),
19
25
  },
20
- }),
21
- });
26
+ },
27
+ );
@@ -1,13 +1,13 @@
1
- @use 'node_modules/@linzjs/lui/dist/scss/Core' as lui;
1
+ @use "../../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
2
2
 
3
3
  .GridPopoutMenu-burger {
4
4
  cursor: pointer;
5
5
 
6
- & svg {
7
- fill: lui.$sea;
6
+ svg {
7
+ fill: colors.$sea;
8
8
  }
9
9
  }
10
10
 
11
11
  .GridPopoutMenu-burgerDisabled svg {
12
- fill: lui.$disabled-color;
12
+ fill: colors.$disabled-color;
13
13
  }
@@ -1,35 +1,33 @@
1
1
  import "./GridPopoverMenu.scss";
2
- import "../../react-menu3/styles/index.scss";
3
2
 
4
- import { ColDef } from "ag-grid-community";
5
3
  import { GenericMultiEditCellClass } from "../GenericCellClass";
6
4
  import { GridBaseRow } from "../Grid";
7
- import { GridCell } from "../GridCell";
5
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
8
6
  import { GridFormPopoutMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
9
7
  import { GridRenderPopoutMenuCell } from "../gridRender/GridRenderPopoutMenuCell";
10
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
8
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
11
9
 
12
10
  /**
13
11
  * Popout burger menu
14
12
  */
15
13
  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,
14
+ colDef: GenericCellColDef<RowType>,
15
+ props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>,
16
+ ): ColDefT<RowType> =>
17
+ GridCell<RowType, GridFormPopoutMenuProps<RowType>>(
18
+ {
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,
33
27
  },
34
- }),
35
- });
28
+ },
29
+ {
30
+ editor: GridFormPopoutMenu,
31
+ ...props,
32
+ },
33
+ );
@@ -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 { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
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: GenericCellColDef<RowType>,
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
  };
@@ -1,20 +1,16 @@
1
- import { GridCell } from "../GridCell";
1
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
4
3
  import { GridFormTextArea, GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
4
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
5
 
6
6
  export const GridPopoverTextArea = <RowType extends GridBaseRow>(
7
- colDef: GenericCellColDef<RowType, GridFormTextAreaProps<RowType>>,
8
- ) => {
9
- return GridCell<RowType, GridFormTextAreaProps<RowType>>({
10
- maxWidth: 260,
11
- ...colDef,
12
- ...(colDef?.cellEditorParams && {
13
- cellEditorParams: {
14
- width: 260,
15
- ...colDef.cellEditorParams,
16
- form: GridFormTextArea,
17
- },
18
- }),
19
- });
20
- };
7
+ colDef: GenericCellColDef<RowType>,
8
+ params: GenericCellEditorProps<GridFormTextAreaProps<RowType>>,
9
+ ): ColDefT<RowType> =>
10
+ GridCell(
11
+ {
12
+ maxWidth: 260,
13
+ ...colDef,
14
+ },
15
+ { editor: GridFormTextArea, ...params },
16
+ );
@@ -1,20 +1,20 @@
1
- import { GridCell } from "../GridCell";
1
+ import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
- import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
4
3
  import { GridFormTextInput, GridFormTextInputProps } from "../gridForm/GridFormTextInput";
4
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
5
 
6
6
  export const GridPopoverTextInput = <RowType extends GridBaseRow>(
7
- colDef: GenericCellColDef<RowType, GridFormTextInputProps<RowType>>,
8
- ) => {
9
- return GridCell<RowType, GridFormTextInputProps<RowType>>({
10
- maxWidth: 140,
11
- ...colDef,
12
- ...(colDef?.cellEditorParams && {
13
- cellEditorParams: {
14
- width: 240,
15
- ...colDef.cellEditorParams,
16
- form: GridFormTextInput,
17
- },
18
- }),
19
- });
7
+ colDef: GenericCellColDef<RowType>,
8
+ params: GenericCellEditorProps<GridFormTextInputProps<RowType>>,
9
+ ): ColDefT<RowType> => {
10
+ return GridCell(
11
+ {
12
+ maxWidth: 140,
13
+ ...colDef,
14
+ },
15
+ {
16
+ editor: GridFormTextInput,
17
+ ...params,
18
+ },
19
+ );
20
20
  };
@@ -1,21 +1,20 @@
1
- import "./GridRenderGenericCell.scss";
1
+ import "../../styles/GridRenderGenericCell.scss";
2
2
 
3
3
  import { useContext } from "react";
4
- import { UpdatingContext } from "@contexts/UpdatingContext";
4
+ import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
5
5
  import { GridLoadableCell } from "../GridLoadableCell";
6
6
  import { GridIcon } from "../GridIcon";
7
7
  import { ColDef, ICellRendererParams } from "ag-grid-community";
8
8
  import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
9
- import { GenericCellEditorParams } from "../GridCell";
10
9
  import { GridBaseRow } from "../Grid";
10
+ import { ColDefT } from "@components/GridCell";
11
11
 
12
12
  export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
13
13
  data: RowType;
14
14
  }
15
15
 
16
- export interface GenericCellColDef<RowType extends GridBaseRow, FormProps extends Record<string, any>> extends ColDef {
16
+ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
17
17
  cellRendererParams?: GenericCellRendererParams<RowType>;
18
- cellEditorParams?: GenericCellEditorParams<RowType> & FormProps;
19
18
  }
20
19
 
21
20
  export interface GenericCellRendererParams<RowType extends GridBaseRow> {
@@ -25,7 +24,7 @@ export interface GenericCellRendererParams<RowType extends GridBaseRow> {
25
24
  }
26
25
 
27
26
  export const GridRendererGenericCell = <RowType extends GridBaseRow>(props: ICellRendererParams): JSX.Element => {
28
- const { checkUpdating } = useContext(UpdatingContext);
27
+ const { checkUpdating } = useContext(GridUpdatingContext);
29
28
 
30
29
  const colDef = props.colDef as ColDef;
31
30
  const cellRendererParams = colDef.cellRendererParams as GenericCellRendererParams<RowType> | undefined;
@@ -1,12 +1,12 @@
1
1
  import { useContext } from "react";
2
2
  import { ColDef, ICellRendererParams } from "ag-grid-community";
3
- import { UpdatingContext } from "@contexts/UpdatingContext";
3
+ import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
4
4
  import { GridLoadableCell } from "../GridLoadableCell";
5
5
  import { LuiIcon } from "@linzjs/lui";
6
6
  import { Column } from "ag-grid-community/dist/lib/entities/column";
7
7
 
8
8
  export const GridRenderPopoutMenuCell = (props: ICellRendererParams) => {
9
- const { checkUpdating } = useContext(UpdatingContext);
9
+ const { checkUpdating } = useContext(GridUpdatingContext);
10
10
  const isLoading = checkUpdating(props.colDef?.field ?? "", props.data.id);
11
11
  const editable = props.colDef?.editable;
12
12
  const disabled = !(typeof editable === "function"
@@ -7,7 +7,7 @@ export interface GridContextType {
7
7
  setGridApi: (gridApi: GridApi | undefined) => void;
8
8
  setQuickFilter: (quickFilter: string) => void;
9
9
  editingCells: () => boolean;
10
- getSelectedRows: <T extends unknown>() => T[];
10
+ getSelectedRows: <T extends GridBaseRow>() => T[];
11
11
  getSelectedRowIds: () => number[];
12
12
  selectRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
13
13
  selectRowsWithFlashDiff: (updateFn: () => Promise<any>) => Promise<void>;
@@ -3,7 +3,7 @@ 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
5
  import { isNotEmpty } from "@utils/util";
6
- import { UpdatingContext } from "./UpdatingContext";
6
+ import { GridUpdatingContext } from "./GridUpdatingContext";
7
7
  import { GridBaseRow } from "@components/Grid";
8
8
 
9
9
  interface GridContextProps {
@@ -16,7 +16,7 @@ interface GridContextProps {
16
16
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
17
17
  */
18
18
  export const GridContextProvider = (props: GridContextProps): ReactElement => {
19
- const { modifyUpdating } = useContext(UpdatingContext);
19
+ const { modifyUpdating } = useContext(GridUpdatingContext);
20
20
  const gridApiRef = useRef<GridApi>();
21
21
  const idsBeforeUpdate = useRef<number[]>([]);
22
22
 
@@ -48,9 +48,7 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
48
48
  noApiFn = (() => {}) as () => R;
49
49
  }
50
50
  const gridApi = gridApiRef.current;
51
- if (gridApi) return hasApiFn(gridApi);
52
- console.error("GridApi not ready");
53
- return noApiFn();
51
+ return gridApi ? hasApiFn(gridApi) : noApiFn();
54
52
  };
55
53
 
56
54
  /**
@@ -0,0 +1,26 @@
1
+ import { createContext, RefObject } from "react";
2
+ import { ICellEditorParams } from "ag-grid-community";
3
+
4
+ export interface PropsType {
5
+ value: any;
6
+ data: any;
7
+ field: string;
8
+ selectedRows: any[];
9
+ updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
10
+ }
11
+
12
+ export type GridPopoverContextType = {
13
+ anchorRef: RefObject<Element>;
14
+ saving: boolean;
15
+ setSaving: (saving: boolean) => void;
16
+ setProps: (props: ICellEditorParams, multiEdit: boolean) => void;
17
+ propsRef: RefObject<PropsType>;
18
+ };
19
+
20
+ export const GridPopoverContext = createContext<GridPopoverContextType>({
21
+ anchorRef: { current: null },
22
+ saving: false,
23
+ setSaving: () => {},
24
+ setProps: () => {},
25
+ propsRef: { current: null },
26
+ });
@@ -0,0 +1,54 @@
1
+ import { ReactNode, RefObject, useCallback, useContext, useRef, useState } from "react";
2
+ import { GridPopoverContext, PropsType } from "./GridPopoverContext";
3
+ import { ICellEditorParams } from "ag-grid-community";
4
+ import { GridContext } from "@contexts/GridContext";
5
+ import { sortBy } from "lodash-es";
6
+ import { GridBaseRow } from "@components/Grid";
7
+
8
+ interface GridPopoverContextProps {
9
+ children: ReactNode;
10
+ }
11
+
12
+ export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
13
+ const { getSelectedRows, updatingCells } = useContext(GridContext);
14
+ const anchorRef = useRef<Element>();
15
+ const propsRef = useRef<PropsType>({} as PropsType);
16
+
17
+ const [saving, setSaving] = useState(false);
18
+
19
+ const setProps = useCallback(
20
+ (props: ICellEditorParams, multiEdit: boolean) => {
21
+ // Then item that is clicked on will always be first in the list
22
+ const selectedRows = multiEdit
23
+ ? sortBy(getSelectedRows(), (row) => row.id !== props.data.id)
24
+ : [props.data as GridBaseRow];
25
+ const field = props.colDef?.field ?? "";
26
+
27
+ anchorRef.current = props.eGridCell;
28
+ propsRef.current = {
29
+ value: props.value,
30
+ data: props.data,
31
+ field,
32
+ selectedRows,
33
+ updateValue: async (saveFn: (selectedRows: any[]) => Promise<boolean>): Promise<boolean> => {
34
+ return !saving && (await updatingCells({ selectedRows, field }, saveFn, setSaving));
35
+ },
36
+ };
37
+ },
38
+ [getSelectedRows, saving, updatingCells],
39
+ );
40
+
41
+ return (
42
+ <GridPopoverContext.Provider
43
+ value={{
44
+ anchorRef: anchorRef as any as RefObject<Element>,
45
+ saving,
46
+ setSaving,
47
+ propsRef,
48
+ setProps,
49
+ }}
50
+ >
51
+ {props.children}
52
+ </GridPopoverContext.Provider>
53
+ );
54
+ };
@@ -1,11 +1,11 @@
1
1
  import { createContext } from "react";
2
2
 
3
- export type UpdatingContextType = {
3
+ export type GridUpdatingContextType = {
4
4
  checkUpdating: (fields: string | string[], id: number | string) => boolean;
5
5
  modifyUpdating: (field: string, ids: (number | string)[], fn: () => void | Promise<void>) => Promise<void>;
6
6
  };
7
7
 
8
- export const UpdatingContext = createContext<UpdatingContextType>({
8
+ export const GridUpdatingContext = createContext<GridUpdatingContextType>({
9
9
  checkUpdating: () => {
10
10
  console.error("Missing UpdatingContext");
11
11
  return false;
@@ -1,23 +1,23 @@
1
1
  import { ReactNode, useRef } from "react";
2
2
  import { castArray, flatten, remove } from "lodash-es";
3
- import { UpdatingContext } from "./UpdatingContext";
3
+ import { GridUpdatingContext } from "./GridUpdatingContext";
4
4
 
5
5
  interface UpdatingContextProviderProps {
6
6
  children: ReactNode;
7
7
  }
8
8
 
9
- export type UpdatingContextStatus = Record<string, (number | string)[] | undefined>;
9
+ export type GridUpdatingContextStatus = Record<string, (number | string)[] | undefined>;
10
10
 
11
11
  type FieldName = string;
12
12
  type IdList = (number | string)[];
13
13
  type UpdatingBlock = Record<FieldName, IdList[]>;
14
14
 
15
- export const UpdatingContextProvider = (props: UpdatingContextProviderProps) => {
15
+ export const GridUpdatingContextProvider = (props: UpdatingContextProviderProps) => {
16
16
  const updatingBlocks = useRef<UpdatingBlock>({});
17
- const updating = useRef<UpdatingContextStatus>({});
17
+ const updating = useRef<GridUpdatingContextStatus>({});
18
18
 
19
19
  const resetUpdating = () => {
20
- const mergedUpdatingBlocks: UpdatingContextStatus = {};
20
+ const mergedUpdatingBlocks: GridUpdatingContextStatus = {};
21
21
  for (const key in updatingBlocks.current) {
22
22
  mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
23
23
  }
@@ -38,6 +38,8 @@ export const UpdatingContextProvider = (props: UpdatingContextProviderProps) =>
38
38
  castArray(fields).some((f) => updating.current[f]?.includes(id));
39
39
 
40
40
  return (
41
- <UpdatingContext.Provider value={{ modifyUpdating, checkUpdating }}>{props.children}</UpdatingContext.Provider>
41
+ <GridUpdatingContext.Provider value={{ modifyUpdating, checkUpdating }}>
42
+ {props.children}
43
+ </GridUpdatingContext.Provider>
42
44
  );
43
45
  };
package/src/index.ts ADDED
@@ -0,0 +1,38 @@
1
+ export * from "@react-menu3";
2
+ export * from "./react-menu3/types";
3
+
4
+ export * from "@contexts/GridUpdatingContext";
5
+ export * from "@contexts/GridUpdatingContextProvider";
6
+ export * from "@contexts/GridContext";
7
+ export * from "@contexts/GridContextProvider";
8
+
9
+ export type { GridBaseRow } from "@components/Grid";
10
+ export { Grid } from "@components/Grid";
11
+ export * from "@components/GridCell";
12
+ export { GridIcon } from "@components/GridIcon";
13
+ export { ComponentLoadingWrapper } from "@components/ComponentLoadingWrapper";
14
+ export { GenericMultiEditCellClass } from "@components/GenericCellClass";
15
+ export { GridLoadableCell } from "@components/GridLoadableCell";
16
+ export { useGridPopoverHook } from "@components/GridPopoverHook";
17
+ export { usePostSortRowsHook } from "@components/PostSortRowsHook";
18
+
19
+ export { GridRendererGenericCell } from "@components/gridRender/GridRenderGenericCell";
20
+ export { GridRenderPopoutMenuCell } from "@components/gridRender/GridRenderPopoutMenuCell";
21
+
22
+ export { GridPopoutEditMultiSelect } from "@components/gridPopoverEdit/GridPopoutEditMultiSelect";
23
+ export { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
24
+ export { GridPopoverEditBearing } from "@components/gridPopoverEdit/GridPopoverEditBearing";
25
+ export { GridPopoverEditBearingCorrection } from "@components/gridPopoverEdit/GridPopoverEditBearing";
26
+ export { GridPopoverEditDropDown } from "@components/gridPopoverEdit/GridPopoverEditDropDown";
27
+ export { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
28
+ export { GridPopoverTextArea } from "@components/gridPopoverEdit/GridPopoverTextArea";
29
+ export { GridPopoverTextInput } from "@components/gridPopoverEdit/GridPopoverTextInput";
30
+
31
+ export { GridHeaderSelect } from "@components/gridHeader/GridHeaderSelect";
32
+
33
+ export { TextAreaInput } from "./lui/TextAreaInput";
34
+ export { TextInputFormatted } from "./lui/TextInputFormatted";
35
+ export { GridSubComponentTextArea } from "@components/GridSubComponentTextArea";
36
+
37
+ export * from "@utils/bearing";
38
+ export * from "@utils/util";
@@ -8,4 +8,4 @@
8
8
  top: 0;
9
9
  line-height: 48px;
10
10
  color: #beb9b4;
11
- }
11
+ }