@linzjs/step-ag-grid 14.1.2 → 14.2.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.
package/README.md CHANGED
@@ -162,6 +162,15 @@ const GridDemo = () => {
162
162
  };
163
163
  ```
164
164
 
165
+ ## Bulk editing
166
+ If you are editing a cell and tab out of the cell, the grid will edit the next editable cell.
167
+
168
+ At this point you can send the change to the back-end immediately and then wait for an update response
169
+ _OR_
170
+ you could cache the required change, update then cell locally, and then wait for the callback
171
+ ```<Grid onCellEditingComplete={fn}/>``` which will get invoked when the grid cannot find any
172
+ more editable cells on the grid row, which will speed up editing.
173
+
165
174
  ## Grid sizing
166
175
  Grid uses ```<Grid sizeColumns="auto"/>``` which sizes by cell content by default.
167
176
  To ignore cell content use "fit", to disable use "none".
@@ -44,6 +44,11 @@ export interface GridProps {
44
44
  * If you want to stretch to container width if width is greater than the container add a flex column.
45
45
  */
46
46
  sizeColumns?: "fit" | "auto" | "auto-skip-headers" | "none";
47
+ /**
48
+ * When pressing tab whilst editing the grid will select and edit the next cell if available.
49
+ * Once the last cell to edit closes this callback is called.
50
+ */
51
+ onCellEditingComplete?: () => void;
47
52
  }
48
53
  /**
49
54
  * Wrapper for AgGrid to add commonly used functionality.
@@ -17,6 +17,7 @@ export declare const suppressCellKeyboardEvents: (e: SuppressKeyboardEventParams
17
17
  export declare const generateFilterGetter: <RowType extends GridBaseRow>(field: string | undefined, filterValueGetter: string | ((params: RowValueGetterParams<RowType>) => string) | undefined, valueFormatter: string | ((params: RowValueFormatterParams<RowType>) => string) | undefined) => string | ((params: RowValueGetterParams<RowType>) => string) | undefined;
18
18
  export declare const GridCell: <RowType extends GridBaseRow, Props extends CellEditorCommon>(props: GenericCellColDef<RowType>, custom?: {
19
19
  multiEdit?: boolean | undefined;
20
+ preventAutoEdit?: boolean | undefined;
20
21
  editor?: ((editorProps: Props) => JSX.Element) | undefined;
21
22
  editorParams?: Props | undefined;
22
23
  } | undefined) => ColDefT<RowType>;
@@ -3,6 +3,14 @@ import { ColumnApi, GridApi, RowNode } from "ag-grid-community";
3
3
  import { CsvExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
4
4
  import { ColDefT, GridBaseRow } from "../components";
5
5
  export type GridFilterExternal<RowType extends GridBaseRow> = (data: RowType, rowNode: RowNode) => boolean;
6
+ export interface AutoSizeColumnsProps {
7
+ skipHeader?: boolean;
8
+ colIds?: Set<string> | string[];
9
+ userSizedColIds?: Set<string>;
10
+ }
11
+ export type AutoSizeColumnsResult = {
12
+ width: number;
13
+ } | null;
6
14
  export interface GridContextType<RowType extends GridBaseRow> {
7
15
  gridReady: boolean;
8
16
  setApis: (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => void;
@@ -23,12 +31,9 @@ export interface GridContextType<RowType extends GridBaseRow> {
23
31
  ensureRowVisible: (id: number | string) => boolean;
24
32
  ensureSelectedRowIsVisible: () => void;
25
33
  getFirstRowId: () => number;
26
- autoSizeAllColumns: (props?: {
27
- skipHeader?: boolean;
28
- }) => {
29
- width: number;
30
- } | null;
34
+ autoSizeColumns: (props?: AutoSizeColumnsProps) => AutoSizeColumnsResult;
31
35
  sizeColumnsToFit: () => void;
36
+ cancelEdit: () => void;
32
37
  stopEditing: () => void;
33
38
  updatingCells: (props: {
34
39
  selectedRows: GridBaseRow[];
@@ -46,6 +51,7 @@ export interface GridContextType<RowType extends GridBaseRow> {
46
51
  invisibleColumnIds: string[];
47
52
  setInvisibleColumnIds: (colIds: string[]) => void;
48
53
  downloadCsv: (csvExportParams?: CsvExportParams) => void;
54
+ setOnCellEditingComplete: (callback: (() => void) | undefined) => void;
49
55
  }
50
56
  export declare const GridContext: import("react").Context<GridContextType<any>>;
51
57
  export declare const useGridContext: <RowType extends GridBaseRow>() => GridContextType<RowType>;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export type GridUpdatingContextType = {
3
3
  checkUpdating: (fields: string | string[], id: number | string) => boolean;
4
+ isUpdating: () => boolean;
4
5
  modifyUpdating: (fields: string | string[], ids: (number | string)[], fn: () => void | Promise<void>) => Promise<void>;
5
6
  updatedDep: number;
6
7
  };