@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
@@ -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
  };
@@ -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 { ColDef } from "ag-grid-community";
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: ColDef,
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 { ColDef } from "ag-grid-community";
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: ColDef,
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,19 @@
1
1
  import "./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";
11
10
 
12
11
  export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
13
12
  data: RowType;
14
13
  }
15
14
 
16
- export interface GenericCellColDef<RowType extends GridBaseRow, FormProps extends Record<string, any>> extends ColDef {
15
+ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDef {
17
16
  cellRendererParams?: GenericCellRendererParams<RowType>;
18
- cellEditorParams?: GenericCellEditorParams<RowType> & FormProps;
19
17
  }
20
18
 
21
19
  export interface GenericCellRendererParams<RowType extends GridBaseRow> {
@@ -25,7 +23,7 @@ export interface GenericCellRendererParams<RowType extends GridBaseRow> {
25
23
  }
26
24
 
27
25
  export const GridRendererGenericCell = <RowType extends GridBaseRow>(props: ICellRendererParams): JSX.Element => {
28
- const { checkUpdating } = useContext(UpdatingContext);
26
+ const { checkUpdating } = useContext(GridUpdatingContext);
29
27
 
30
28
  const colDef = props.colDef as ColDef;
31
29
  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"
@@ -17,6 +17,7 @@ export interface GridContextType {
17
17
  flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
18
18
  ensureRowVisible: (id: number) => void;
19
19
  ensureSelectedRowIsVisible: () => void;
20
+ sizeColumnsToFit: () => void;
20
21
  stopEditing: () => void;
21
22
  updatingCells: (
22
23
  props: { selectedRows: GridBaseRow[]; field?: string },
@@ -68,6 +69,9 @@ export const GridContext = createContext<GridContextType>({
68
69
  ensureSelectedRowIsVisible: () => {
69
70
  console.error("no context provider for ensureSelectedRowIsVisible");
70
71
  },
72
+ sizeColumnsToFit: () => {
73
+ console.error("no context provider for sizeColumnsToFit");
74
+ },
71
75
  editingCells: () => {
72
76
  console.error("no context provider for editingCells");
73
77
  return false;
@@ -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
  /**
@@ -220,6 +218,15 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
220
218
  });
221
219
  };
222
220
 
221
+ /**
222
+ * Resize columns to fit container
223
+ */
224
+ const sizeColumnsToFit = (): void => {
225
+ gridApiOp((gridApi) => {
226
+ gridApi.sizeColumnsToFit();
227
+ });
228
+ };
229
+
223
230
  const stopEditing = (): void => gridApiOp((gridApi) => gridApi.stopEditing());
224
231
 
225
232
  const updatingCells = async (
@@ -283,6 +290,7 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
283
290
  editingCells,
284
291
  ensureRowVisible,
285
292
  ensureSelectedRowIsVisible,
293
+ sizeColumnsToFit,
286
294
  stopEditing,
287
295
  updatingCells,
288
296
  }}
@@ -0,0 +1,32 @@
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
+ }
10
+
11
+ export type GridPopoverContextType = {
12
+ anchorRef: RefObject<Element>;
13
+ updateValueRef: RefObject<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>;
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
+ updateValueRef: {
23
+ current: async () => {
24
+ console.error("Missing GridPopoverContext updateValueRef");
25
+ return false;
26
+ },
27
+ },
28
+ saving: false,
29
+ setSaving: () => {},
30
+ setProps: () => {},
31
+ propsRef: { current: null },
32
+ });
@@ -0,0 +1,53 @@
1
+ import { ReactNode, RefObject, useContext, useRef, useState } from "react";
2
+ import { GridPopoverContext, PropsType } from "./GridPopoverContext";
3
+ import { ICellEditorParams } from "ag-grid-community";
4
+ import { GridBaseRow } from "@components/Grid";
5
+ import { GridContext } from "@contexts/GridContext";
6
+
7
+ interface GridPopoverContextProps {
8
+ children: ReactNode;
9
+ }
10
+
11
+ export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
12
+ const { getSelectedRows, updatingCells } = useContext(GridContext);
13
+ const anchorRef = useRef<Element>();
14
+ const propsRef = useRef<PropsType>({} as PropsType);
15
+ const updateValueRef = useRef<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>(async () => {
16
+ console.error("updateValueRef.current is not set");
17
+ return false;
18
+ });
19
+
20
+ const [saving, setSaving] = useState(false);
21
+
22
+ const setProps = (props: ICellEditorParams, multiEdit: boolean) => {
23
+ const selectedRows = multiEdit ? getSelectedRows<GridBaseRow>() : [props.data];
24
+ const field = props.colDef?.field ?? "";
25
+
26
+ anchorRef.current = props.eGridCell;
27
+ propsRef.current = {
28
+ value: props.value,
29
+ data: props.data,
30
+ field,
31
+ selectedRows,
32
+ };
33
+
34
+ updateValueRef.current = async (saveFn: (selectedRows: any[]) => Promise<boolean>): Promise<boolean> => {
35
+ return !saving && (await updatingCells({ selectedRows, field }, saveFn, setSaving));
36
+ };
37
+ };
38
+
39
+ return (
40
+ <GridPopoverContext.Provider
41
+ value={{
42
+ anchorRef: anchorRef as any as RefObject<Element>,
43
+ saving,
44
+ setSaving,
45
+ updateValueRef,
46
+ propsRef,
47
+ setProps,
48
+ }}
49
+ >
50
+ {props.children}
51
+ </GridPopoverContext.Provider>
52
+ );
53
+ };
@@ -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
  };
@@ -3,7 +3,7 @@ import "./FormTest.scss";
3
3
  import { useCallback, useState } from "react";
4
4
  import { LuiTextInput } from "@linzjs/lui";
5
5
  import { wait } from "@utils/util";
6
- import { GridFormProps } from "@components/GridCell";
6
+ import { CellParams } from "@components/GridCell";
7
7
  import { useGridPopoverHook } from "@components/GridPopoverHook";
8
8
  import { GridBaseRow } from "@components/Grid";
9
9
 
@@ -16,7 +16,8 @@ export interface IFormTestRow {
16
16
  distance: number | null;
17
17
  }
18
18
 
19
- export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowType>): JSX.Element => {
19
+ export const FormTest = <RowType extends GridBaseRow>(_props: any): JSX.Element => {
20
+ const props = _props as CellParams<RowType>;
20
21
  const [v1, v2, ...v3] = props.value.split(" ");
21
22
 
22
23
  const [nameType, setNameType] = useState(v1);
@@ -34,7 +35,7 @@ export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowTy
34
35
  // Close form
35
36
  return true;
36
37
  }, [nameType, numba, plan, props.selectedRows]);
37
- const { popoverWrapper } = useGridPopoverHook(props, save);
38
+ const { popoverWrapper } = useGridPopoverHook({ save });
38
39
 
39
40
  return popoverWrapper(
40
41
  <div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
@@ -4,10 +4,10 @@ import "../../lui-overrides.scss";
4
4
 
5
5
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
6
6
  import { useMemo, useState } from "react";
7
- import { UpdatingContextProvider } from "@contexts/UpdatingContextProvider";
7
+ import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
8
8
  import { GridContextProvider } from "@contexts/GridContextProvider";
9
9
  import { Grid, GridProps } from "@components/Grid";
10
- import { GridCell } from "@components/GridCell";
10
+ import { ColDefT, GridCell } from "@components/GridCell";
11
11
  import {
12
12
  GridPopoverEditBearing,
13
13
  GridPopoverEditBearingCorrection,
@@ -24,11 +24,11 @@ export default {
24
24
  decorators: [
25
25
  (Story) => (
26
26
  <div style={{ width: 1200, height: 400, display: "flex" }}>
27
- <UpdatingContextProvider>
27
+ <GridUpdatingContextProvider>
28
28
  <GridContextProvider>
29
29
  <Story />
30
30
  </GridContextProvider>
31
- </UpdatingContextProvider>
31
+ </GridUpdatingContextProvider>
32
32
  </div>
33
33
  ),
34
34
  ],
@@ -42,7 +42,7 @@ interface ITestRow {
42
42
 
43
43
  const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
44
44
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
45
- const columnDefs = useMemo(
45
+ const columnDefs: ColDefT<ITestRow>[] = useMemo(
46
46
  () => [
47
47
  GridCell({
48
48
  field: "id",
@@ -50,31 +50,34 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
50
50
  initialWidth: 65,
51
51
  maxWidth: 85,
52
52
  }),
53
- GridPopoverEditBearing<ITestRow>({
54
- field: "bearing1",
55
- headerName: "Bearing GCE",
56
- cellRendererParams: {
57
- warning: (props) => props.data.id == 1002 && "Testers are testing",
58
- info: (props) => props.data.id == 1001 && "Developers are developing",
53
+ GridPopoverEditBearing(
54
+ {
55
+ field: "bearing1",
56
+ headerName: "Bearing GCE",
57
+ cellRendererParams: {
58
+ warning: (props: any) => props.data.id == 1002 && "Testers are testing",
59
+ info: (props: any) => props.data.id == 1001 && "Developers are developing",
60
+ },
59
61
  },
60
- cellEditorParams: {
62
+ {
61
63
  multiEdit: false,
62
- placeHolder: "Enter Bearing",
63
64
  },
64
- }),
65
- GridPopoverEditBearingCorrection<ITestRow>({
66
- field: "bearingCorrection",
67
- headerName: "Bearing Correction",
68
- cellEditorParams: {
69
- multiEdit: true,
70
- placeHolder: "Enter Bearing Correction",
71
- onSave: async (selectedRows: ITestRow[], value: ITestRow["bearingCorrection"]) => {
72
- await wait(1000);
73
- selectedRows.forEach((row) => (row["bearingCorrection"] = value));
74
- return true;
65
+ ),
66
+ GridPopoverEditBearingCorrection(
67
+ {
68
+ field: "bearingCorrection",
69
+ headerName: "Bearing Correction",
70
+ },
71
+ {
72
+ editorParams: {
73
+ onSave: async (selectedRows, value: ITestRow["bearingCorrection"]) => {
74
+ await wait(1000);
75
+ selectedRows.forEach((row) => (row["bearingCorrection"] = value));
76
+ return true;
77
+ },
75
78
  },
76
79
  },
77
- }),
80
+ ),
78
81
  ],
79
82
  [],
80
83
  );