@linzjs/step-ag-grid 22.2.3 → 22.2.5

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.
@@ -1,9 +1,10 @@
1
1
  import { ReactElement } from "react";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { CellEditorCommon } from "../GridCell";
4
- export interface GridPopoutEditDropDownSelectedItem<TData> {
4
+ export interface GridPopoutEditDropDownSelectedItem<TData extends GridBaseRow, TValue> {
5
5
  selectedRows: TData[];
6
- value: any;
6
+ selectedRowIds: TData["id"][];
7
+ value: TValue;
7
8
  subComponentValue?: any;
8
9
  }
9
10
  interface FinalSelectOption {
@@ -22,16 +23,16 @@ export declare const MenuHeaderItem: (title: string) => {
22
23
  value: string;
23
24
  };
24
25
  export type SelectOption = null | string | FinalSelectOption;
25
- export interface GridFormDropDownProps<TData extends GridBaseRow> extends CellEditorCommon {
26
+ export interface GridFormDropDownProps<TData extends GridBaseRow, TValue> extends CellEditorCommon {
26
27
  className?: "GridPopoverEditDropDown-containerSmall" | "GridPopoverEditDropDown-containerMedium" | "GridPopoverEditDropDown-containerLarge" | "GridPopoverEditDropDown-containerUnlimited" | "GridPopoverEditDropDown-containerAutoWidth" | string | undefined;
27
28
  filtered?: "local" | "reload";
28
29
  filterDefaultValue?: string;
29
30
  filterPlaceholder?: string;
30
31
  filterHelpText?: string;
31
32
  noOptionsMessage?: string;
32
- onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData>) => Promise<void>;
33
- onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData>) => Promise<void>;
33
+ onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData, TValue>) => Promise<void>;
34
+ onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData, TValue>) => Promise<void>;
34
35
  options: SelectOption[] | ((selectedRows: TData[], filter?: string) => Promise<SelectOption[] | undefined> | SelectOption[] | undefined) | undefined;
35
36
  }
36
- export declare const GridFormDropDown: <TData extends GridBaseRow>(props: GridFormDropDownProps<TData>) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const GridFormDropDown: <TData extends GridBaseRow, TValue>(props: GridFormDropDownProps<TData, TValue>) => import("react/jsx-runtime").JSX.Element;
37
38
  export {};
@@ -2,11 +2,11 @@ import { ICellEditorParams } from "ag-grid-community";
2
2
  import { ColDefT } from "../GridCell";
3
3
  import { GenericCellColDef } from "../gridRender";
4
4
  import { GridBaseRow } from "../Grid";
5
- export interface GridButtonProps<TData> {
5
+ export interface GridButtonProps<TData extends GridBaseRow> {
6
6
  visible?: (cellEditorParams: ICellEditorParams) => boolean;
7
7
  onClick?: (props: {
8
8
  selectedRows: TData[];
9
- selectedRowIds: (string | number)[];
9
+ selectedRowIds: TData["id"][];
10
10
  }) => void;
11
11
  }
12
12
  export declare const GridButton: <TData extends GridBaseRow>(colDef: GenericCellColDef<TData, boolean>, editor: GridButtonProps<TData>) => ColDefT<TData>;
@@ -1,10 +1,10 @@
1
1
  import { CellEditorCommon, ColDefT } from "../GridCell";
2
2
  import { GenericCellColDef } from "../gridRender";
3
3
  import { GridBaseRow } from "../Grid";
4
- export interface GridEditBooleanEditorProps<TData> extends CellEditorCommon {
4
+ export interface GridEditBooleanEditorProps<TData extends GridBaseRow> extends CellEditorCommon {
5
5
  onClick: (props: {
6
6
  selectedRows: TData[];
7
- selectedRowIds: (string | number)[];
7
+ selectedRowIds: TData["id"][];
8
8
  checked: boolean;
9
9
  }) => Promise<boolean>;
10
10
  }
@@ -2,4 +2,4 @@ import { GridBaseRow } from "../Grid";
2
2
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
3
3
  import { GridFormDropDownProps } from "../gridForm/GridFormDropDown";
4
4
  import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
- export declare const GridPopoverEditDropDown: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormDropDownProps<TData>>) => ColDefT<TData, TValue>;
5
+ export declare const GridPopoverEditDropDown: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormDropDownProps<TData, TValue>>) => ColDefT<TData, TValue>;
@@ -3587,7 +3587,12 @@ const GridFormDropDown = (props) => {
3587
3587
  (subComponentValue !== undefined && subComponentInitialValue.current !== JSON.stringify(subComponentValue));
3588
3588
  if (hasChanged) {
3589
3589
  if (props.onSelectedItem) {
3590
- await props.onSelectedItem({ selectedRows, value, subComponentValue });
3590
+ await props.onSelectedItem({
3591
+ selectedRows,
3592
+ selectedRowIds: selectedRows.map((row) => row.id),
3593
+ value,
3594
+ subComponentValue,
3595
+ });
3591
3596
  }
3592
3597
  else {
3593
3598
  selectedRows.forEach((row) => (row[field] = value));
@@ -3653,7 +3658,7 @@ const GridFormDropDown = (props) => {
3653
3658
  if (selectedItem === null) {
3654
3659
  if (props.onSelectFilter) {
3655
3660
  const { onSelectFilter } = props;
3656
- await onSelectFilter({ selectedRows, value: filter });
3661
+ await onSelectFilter({ selectedRows, selectedRowIds: selectedRows.map((row) => row.id), value: filter });
3657
3662
  return true;
3658
3663
  }
3659
3664
  else {
@@ -4491,7 +4496,14 @@ const BooleanCellRenderer = (props) => {
4491
4496
  const params = props?.colDef?.cellEditorParams;
4492
4497
  if (!params)
4493
4498
  return;
4494
- const selectedRows = [data];
4499
+ // The data cannot be relied upon if grid changed whilst editing, data will be stale
4500
+ // So I get the data from the node itself which will be up to date.
4501
+ const selectedRows = [];
4502
+ api.forEachNode((n) => {
4503
+ if (n.data.id === data.id) {
4504
+ selectedRows.push(n.data);
4505
+ }
4506
+ });
4495
4507
  const checked = !value;
4496
4508
  onValueChange(checked);
4497
4509
  params.onClick({ selectedRows, selectedRowIds: selectedRows.map((r) => r.id), checked }).then();