@linzjs/step-ag-grid 14.3.3 → 14.4.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.
@@ -36,6 +36,10 @@ export interface GridContextType<RowType extends GridBaseRow> {
36
36
  autoSizeColumns: (props?: AutoSizeColumnsProps) => AutoSizeColumnsResult;
37
37
  sizeColumnsToFit: () => void;
38
38
  cancelEdit: () => void;
39
+ startCellEditing: ({ rowId, colId }: {
40
+ rowId: number;
41
+ colId: string;
42
+ }) => void;
39
43
  stopEditing: () => void;
40
44
  updatingCells: (props: {
41
45
  selectedRows: GridBaseRow[];
@@ -220,6 +220,9 @@ var GridContext = createContext({
220
220
  cancelEdit: function () {
221
221
  console.error("no context provider for cancelEdit");
222
222
  },
223
+ startCellEditing: function () {
224
+ console.error("no context provider for startCellEditing");
225
+ },
223
226
  stopEditing: function () {
224
227
  console.error("no context provider for stopEditing");
225
228
  },
@@ -718,8 +721,9 @@ var GridHeaderSelect = function (_a) {
718
721
  var Grid = function (_a) {
719
722
  var _b, _c, _d;
720
723
  var dataTestId = _a["data-testid"], _e = _a.rowSelection, rowSelection = _e === void 0 ? "multiple" : _e, _f = _a.suppressColumnVirtualization, suppressColumnVirtualization = _f === void 0 ? true : _f, _g = _a.theme, theme = _g === void 0 ? "ag-theme-alpine" : _g, _h = _a.sizeColumns, sizeColumns = _h === void 0 ? "auto" : _h, _j = _a.selectColumnPinned, selectColumnPinned = _j === void 0 ? null : _j, params = __rest(_a, ["data-testid", "rowSelection", "suppressColumnVirtualization", "theme", "sizeColumns", "selectColumnPinned"]);
721
- var _k = useContext(GridContext), gridReady = _k.gridReady, setApis = _k.setApis, prePopupOps = _k.prePopupOps, ensureRowVisible = _k.ensureRowVisible, getFirstRowId = _k.getFirstRowId, selectRowsById = _k.selectRowsById, focusByRowById = _k.focusByRowById, ensureSelectedRowIsVisible = _k.ensureSelectedRowIsVisible, autoSizeColumns = _k.autoSizeColumns, sizeColumnsToFit = _k.sizeColumnsToFit, externallySelectedItemsAreInSync = _k.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _k.setExternallySelectedItemsAreInSync, isExternalFilterPresent = _k.isExternalFilterPresent, doesExternalFilterPass = _k.doesExternalFilterPass, setOnCellEditingComplete = _k.setOnCellEditingComplete, getColDef = _k.getColDef;
722
- var _l = useContext(GridUpdatingContext), checkUpdating = _l.checkUpdating, updatedDep = _l.updatedDep, updatingCols = _l.updatingCols;
724
+ var _k = useContext(GridContext), gridReady = _k.gridReady, setApis = _k.setApis, ensureRowVisible = _k.ensureRowVisible, getFirstRowId = _k.getFirstRowId, selectRowsById = _k.selectRowsById, focusByRowById = _k.focusByRowById, ensureSelectedRowIsVisible = _k.ensureSelectedRowIsVisible, autoSizeColumns = _k.autoSizeColumns, sizeColumnsToFit = _k.sizeColumnsToFit, externallySelectedItemsAreInSync = _k.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _k.setExternallySelectedItemsAreInSync, isExternalFilterPresent = _k.isExternalFilterPresent, doesExternalFilterPass = _k.doesExternalFilterPass, setOnCellEditingComplete = _k.setOnCellEditingComplete, getColDef = _k.getColDef;
725
+ var _l = useContext(GridUpdatingContext), updatedDep = _l.updatedDep, updatingCols = _l.updatingCols;
726
+ var gridContext = useContext(GridContext);
723
727
  var gridDivRef = useRef(null);
724
728
  var lastSelectedIds = useRef([]);
725
729
  var _m = useState(false), staleGrid = _m[0], setStaleGrid = _m[1];
@@ -985,22 +989,12 @@ var Grid = function (_a) {
985
989
  * Make sure node is selected for editing and start edit
986
990
  */
987
991
  var startCellEditing = useCallback(function (event) {
988
- var _a;
989
- prePopupOps();
990
- if (!event.node.isSelected()) {
991
- event.node.setSelected(true, true);
992
- }
993
- // Cell already being edited, so don't re-edit until finished
994
- if (checkUpdating([(_a = event.colDef.field) !== null && _a !== void 0 ? _a : ""], event.data.id)) {
995
- return;
996
- }
997
- if (event.rowIndex !== null) {
998
- event.api.startEditingCell({
999
- rowIndex: event.rowIndex,
1000
- colKey: event.column.getColId()
992
+ event.data.id &&
993
+ gridContext.startCellEditing({
994
+ rowId: event.data.id,
995
+ colId: event.column.getColId()
1001
996
  });
1002
- }
1003
- }, [checkUpdating, prePopupOps]);
997
+ }, [gridContext]);
1004
998
  /**
1005
999
  * Handle double click edit
1006
1000
  */
@@ -4647,16 +4641,16 @@ var GridWrapper = function (_a) {
4647
4641
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
4648
4642
  */
4649
4643
  var GridContextProvider = function (props) {
4650
- var modifyUpdating = useContext(GridUpdatingContext).modifyUpdating;
4651
- var _a = useState(), gridApi = _a[0], setGridApi = _a[1];
4652
- var _b = useState(), columnApi = _b[0], setColumnApi = _b[1];
4653
- var _c = useState(false), gridReady = _c[0], setGridReady = _c[1];
4654
- var _d = useState(""), quickFilter = _d[0], setQuickFilter = _d[1];
4655
- var _e = useState([]), invisibleColumnIds = _e[0], setInvisibleColumnIds = _e[1];
4644
+ var _a = useContext(GridUpdatingContext), modifyUpdating = _a.modifyUpdating, checkUpdating = _a.checkUpdating;
4645
+ var _b = useState(), gridApi = _b[0], setGridApi = _b[1];
4646
+ var _c = useState(), columnApi = _c[0], setColumnApi = _c[1];
4647
+ var _d = useState(false), gridReady = _d[0], setGridReady = _d[1];
4648
+ var _e = useState(""), quickFilter = _e[0], setQuickFilter = _e[1];
4649
+ var _f = useState([]), invisibleColumnIds = _f[0], setInvisibleColumnIds = _f[1];
4656
4650
  var testId = useRef();
4657
4651
  var idsBeforeUpdate = useRef([]);
4658
4652
  var prePopupFocusedCell = useRef();
4659
- var _f = useState(false), externallySelectedItemsAreInSync = _f[0], setExternallySelectedItemsAreInSync = _f[1];
4653
+ var _g = useState(false), externallySelectedItemsAreInSync = _g[0], setExternallySelectedItemsAreInSync = _g[1];
4660
4654
  var externalFilters = useRef([]);
4661
4655
  /**
4662
4656
  * Set quick filter directly on grid, based on previously save quickFilter state.
@@ -4941,6 +4935,43 @@ var GridContextProvider = function (props) {
4941
4935
  }
4942
4936
  gridApi.stopEditing();
4943
4937
  }, [gridApi]);
4938
+ var startCellEditing = useCallback(function (_a) {
4939
+ var rowId = _a.rowId, colId = _a.colId;
4940
+ return __awaiter(void 0, void 0, void 0, function () {
4941
+ var colDef, rowNode, rowIndex, focusAndEdit;
4942
+ var _b;
4943
+ return __generator(this, function (_c) {
4944
+ if (!gridApi)
4945
+ return [2 /*return*/];
4946
+ colDef = gridApi.getColumnDef(colId);
4947
+ if (!colDef)
4948
+ return [2 /*return*/];
4949
+ // Cell already being edited, so don't re-edit until finished
4950
+ if (checkUpdating([(_b = colDef.field) !== null && _b !== void 0 ? _b : ""], rowId)) {
4951
+ return [2 /*return*/];
4952
+ }
4953
+ rowNode = gridApi.getRowNode("".concat(rowId));
4954
+ if (!rowNode) {
4955
+ return [2 /*return*/];
4956
+ }
4957
+ if (!rowNode.isSelected()) {
4958
+ rowNode.setSelected(true, true);
4959
+ }
4960
+ prePopupOps();
4961
+ rowIndex = rowNode.rowIndex;
4962
+ if (rowIndex != null) {
4963
+ focusAndEdit = function () {
4964
+ gridApi.startEditingCell({
4965
+ rowIndex: rowIndex,
4966
+ colKey: colId
4967
+ });
4968
+ };
4969
+ defer$1(focusAndEdit);
4970
+ }
4971
+ return [2 /*return*/];
4972
+ });
4973
+ });
4974
+ }, [checkUpdating, gridApi, prePopupOps]);
4944
4975
  /**
4945
4976
  * This differs from stopEdit in that it will also invoke cellEditingCompleteCallback
4946
4977
  */
@@ -5151,6 +5182,7 @@ var GridContextProvider = function (props) {
5151
5182
  ensureSelectedRowIsVisible: ensureSelectedRowIsVisible,
5152
5183
  sizeColumnsToFit: sizeColumnsToFit,
5153
5184
  autoSizeColumns: autoSizeColumns,
5185
+ startCellEditing: startCellEditing,
5154
5186
  stopEditing: stopEditing,
5155
5187
  cancelEdit: cancelEdit,
5156
5188
  updatingCells: updatingCells,