@linzjs/step-ag-grid 7.11.7 → 7.11.9

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/dist/index.js CHANGED
@@ -1448,8 +1448,8 @@ var ControlledMenuFr = function (_a, externalRef) {
1448
1448
  if (activeElement !== firstInputEl && activeElement !== lastInputEl)
1449
1449
  return;
1450
1450
  var isTextArea = activeElement.nodeName === "TEXTAREA";
1451
- var suppressEnterAutoSave = activeElement.getAttribute("data-disableenterautosave") || isTextArea;
1452
- var allowTabToSave = activeElement.getAttribute("data-allowtabtosave");
1451
+ var suppressEnterAutoSave = activeElement.getAttribute("data-disableenterautosave") != "false" || isTextArea;
1452
+ var allowTabToSave = activeElement.getAttribute("data-allowtabtosave") != "false";
1453
1453
  var invokeSave = function (reason) {
1454
1454
  var _a, _b;
1455
1455
  if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current))
@@ -2081,68 +2081,68 @@ var GridContextProvider = function (props) {
2081
2081
  var _b = React.useState(false), gridReady = _b[0], setGridReady = _b[1];
2082
2082
  var idsBeforeUpdate = React.useRef([]);
2083
2083
  var externallySelectedItemsAreInSync = React.useRef(false);
2084
- var setGridApi = function (gridApi) {
2084
+ var setGridApi = React.useCallback(function (gridApi) {
2085
2085
  _setGridApi(gridApi);
2086
2086
  setGridReady(!!gridApi);
2087
- };
2087
+ }, []);
2088
2088
  /**
2089
2089
  * Wraps things that require gridApi in common handling, for when gridApi not present.
2090
2090
  *
2091
2091
  * @param hasApiFn Execute when api is ready.
2092
2092
  * @param noApiFn Execute if api is not ready.
2093
2093
  */
2094
- var gridApiOp = function (hasApiFn, noApiFn) {
2094
+ var gridApiOp = React.useCallback(function (hasApiFn, noApiFn) {
2095
2095
  if (!noApiFn) {
2096
2096
  noApiFn = (function () { });
2097
2097
  }
2098
2098
  return gridApi ? hasApiFn(gridApi) : noApiFn();
2099
- };
2099
+ }, [gridApi]);
2100
2100
  /**
2101
2101
  * Set the quick filter value to grid.
2102
2102
  */
2103
- var setQuickFilter = function (quickFilter) {
2103
+ var setQuickFilter = React.useCallback(function (quickFilter) {
2104
2104
  gridApiOp(function (gridApi) { return gridApi.setQuickFilter(quickFilter); });
2105
- };
2105
+ }, [gridApiOp]);
2106
2106
  /**
2107
2107
  * Get all row id's in grid.
2108
2108
  */
2109
- var _getAllRowIds = function () {
2109
+ var _getAllRowIds = React.useCallback(function () {
2110
2110
  var result = [];
2111
2111
  return gridApiOp(function (gridApi) {
2112
2112
  gridApi.forEachNode(function (node) { return result.push(node.data.id); });
2113
2113
  return result;
2114
2114
  }, function () { return result; });
2115
- };
2115
+ }, [gridApiOp]);
2116
2116
  /**
2117
2117
  * Record all row id's before update so that we can select/flash the new rows after update.
2118
2118
  */
2119
- var beforeUpdate = function () {
2119
+ var beforeUpdate = React.useCallback(function () {
2120
2120
  idsBeforeUpdate.current = _getAllRowIds();
2121
- };
2121
+ }, [_getAllRowIds]);
2122
2122
  /**
2123
2123
  * Find new row ids
2124
2124
  * Uses beforeUpdate ids to find new nodes.
2125
2125
  */
2126
- var _getNewNodes = function () {
2126
+ var _getNewNodes = React.useCallback(function () {
2127
2127
  return gridApiOp(function (gridApi) {
2128
2128
  return lodashEs.difference(_getAllRowIds(), idsBeforeUpdate.current)
2129
2129
  .map(function (rowId) { return gridApi.getRowNode("" + rowId); }) //
2130
2130
  .filter(function (r) { return r; });
2131
2131
  }, function () { return []; });
2132
- };
2132
+ }, [_getAllRowIds, gridApiOp]);
2133
2133
  /**
2134
2134
  * Get grid nodes via rowIds. If rowIds has no matching node the result may be smaller than expected.
2135
2135
  * This can happen if the grid has not re-rendered yet.
2136
2136
  *
2137
2137
  * @param rowIds Row ids to get from grid.
2138
2138
  */
2139
- var _rowIdsToNodes = function (rowIds) {
2139
+ var _rowIdsToNodes = React.useCallback(function (rowIds) {
2140
2140
  return gridApiOp(function (gridApi) {
2141
2141
  return rowIds
2142
2142
  .map(function (rowId) { return gridApi.getRowNode("" + rowId); }) //
2143
2143
  .filter(function (r) { return r; });
2144
2144
  }, function () { return []; });
2145
- };
2145
+ }, [gridApiOp]);
2146
2146
  /**
2147
2147
  * Internal method for selecting and flashing rows.
2148
2148
  *
@@ -2151,7 +2151,7 @@ var GridContextProvider = function (props) {
2151
2151
  * @param flash Whether to flash rows
2152
2152
  * @param retryCount Table updates may not be present when this is called, so retry is needed.
2153
2153
  */
2154
- var _selectRowsWithOptionalFlash = function (rowIds, select, flash, retryCount) {
2154
+ var _selectRowsWithOptionalFlash = React.useCallback(function (rowIds, select, flash, retryCount) {
2155
2155
  if (retryCount === void 0) { retryCount = 15; }
2156
2156
  return gridApiOp(function (gridApi) {
2157
2157
  var _a;
@@ -2174,7 +2174,10 @@ var GridContextProvider = function (props) {
2174
2174
  var rowIndex_1 = firstNode.rowIndex;
2175
2175
  if (rowIndex_1 != null && col != null) {
2176
2176
  var colId_1 = col.colId;
2177
- colId_1 != null && setTimeout(function () { return gridApi.setFocusedCell(rowIndex_1, colId_1); }, 100);
2177
+ // We need to make sure we aren't currently editing a cell otherwise tests will fail
2178
+ // as they will start to edit the cell before this stuff has a chance to run
2179
+ colId_1 != null &&
2180
+ lodashEs.defer(function () { return lodashEs.isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex_1, colId_1); });
2178
2181
  }
2179
2182
  }
2180
2183
  }
@@ -2199,11 +2202,11 @@ var GridContextProvider = function (props) {
2199
2202
  }, 250);
2200
2203
  }
2201
2204
  });
2202
- };
2203
- var selectRowsById = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, false); };
2204
- var selectRowsByIdWithFlash = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, true); };
2205
- var flashRows = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, false, true); };
2206
- var selectRowsDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2205
+ }, [_getNewNodes, _rowIdsToNodes, gridApiOp]);
2206
+ var selectRowsById = React.useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, false); }, [_selectRowsWithOptionalFlash]);
2207
+ var selectRowsByIdWithFlash = React.useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, true); }, [_selectRowsWithOptionalFlash]);
2208
+ var flashRows = React.useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, false, true); }, [_selectRowsWithOptionalFlash]);
2209
+ var selectRowsDiff = React.useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2207
2210
  return __generator(this, function (_a) {
2208
2211
  switch (_a.label) {
2209
2212
  case 0:
@@ -2215,8 +2218,8 @@ var GridContextProvider = function (props) {
2215
2218
  return [2 /*return*/];
2216
2219
  }
2217
2220
  });
2218
- }); };
2219
- var selectRowsWithFlashDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2221
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2222
+ var selectRowsWithFlashDiff = React.useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2220
2223
  return __generator(this, function (_a) {
2221
2224
  switch (_a.label) {
2222
2225
  case 0:
@@ -2228,8 +2231,8 @@ var GridContextProvider = function (props) {
2228
2231
  return [2 /*return*/];
2229
2232
  }
2230
2233
  });
2231
- }); };
2232
- var flashRowsDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2234
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2235
+ var flashRowsDiff = React.useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2233
2236
  return __generator(this, function (_a) {
2234
2237
  switch (_a.label) {
2235
2238
  case 0:
@@ -2241,15 +2244,15 @@ var GridContextProvider = function (props) {
2241
2244
  return [2 /*return*/];
2242
2245
  }
2243
2246
  });
2244
- }); };
2245
- var getSelectedRows = function () {
2247
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2248
+ var getSelectedRows = React.useCallback(function () {
2246
2249
  return gridApiOp(function (gridApi) { return gridApi.getSelectedRows(); }, function () { return []; });
2247
- };
2248
- var getSelectedRowIds = function () { return getSelectedRows().map(function (row) { return row.id; }); };
2249
- var editingCells = function () {
2250
+ }, [gridApiOp]);
2251
+ var getSelectedRowIds = React.useCallback(function () { return getSelectedRows().map(function (row) { return row.id; }); }, [getSelectedRows]);
2252
+ var editingCells = React.useCallback(function () {
2250
2253
  return gridApiOp(function (gridApi) { return isNotEmpty(gridApi.getEditingCells()); }, function () { return false; });
2251
- };
2252
- var ensureRowVisible = function (id) {
2254
+ }, [gridApiOp]);
2255
+ var ensureRowVisible = React.useCallback(function (id) {
2253
2256
  return gridApiOp(function (gridApi) {
2254
2257
  var node = gridApi.getRowNode("".concat(id));
2255
2258
  if (!node)
@@ -2257,29 +2260,38 @@ var GridContextProvider = function (props) {
2257
2260
  gridApi.ensureNodeVisible(node);
2258
2261
  return true;
2259
2262
  });
2260
- };
2263
+ }, [gridApiOp]);
2261
2264
  /**
2262
2265
  * Scroll last selected row into view on grid sort change
2263
2266
  */
2264
- var ensureSelectedRowIsVisible = function () {
2267
+ var ensureSelectedRowIsVisible = React.useCallback(function () {
2265
2268
  gridApiOp(function (gridApi) {
2266
2269
  var selectedNodes = gridApi.getSelectedNodes();
2267
2270
  if (lodashEs.isEmpty(selectedNodes))
2268
2271
  return;
2269
2272
  gridApi.ensureNodeVisible(lodashEs.last(selectedNodes));
2270
2273
  });
2271
- };
2274
+ }, [gridApiOp]);
2272
2275
  /**
2273
2276
  * Resize columns to fit container
2274
2277
  */
2275
- var sizeColumnsToFit = function () {
2278
+ var sizeColumnsToFit = React.useCallback(function () {
2276
2279
  gridApiOp(function (gridApi) {
2277
2280
  // Hide size columns to fit errors in tests
2278
2281
  document.body.clientWidth && gridApi.sizeColumnsToFit();
2279
2282
  });
2280
- };
2281
- var stopEditing = function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); };
2282
- var updatingCells = function (props, fnUpdate, setSaving, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2283
+ }, [gridApiOp]);
2284
+ var stopEditing = React.useCallback(function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); }, [gridApiOp]);
2285
+ var selectNextCell = React.useCallback(function (tabDirection) {
2286
+ if (tabDirection === void 0) { tabDirection = 0; }
2287
+ gridApiOp(function (gridApi) {
2288
+ if (tabDirection == 1)
2289
+ gridApi.tabToNextCell();
2290
+ if (tabDirection == -1)
2291
+ gridApi.tabToPreviousCell();
2292
+ });
2293
+ }, [gridApiOp]);
2294
+ var updatingCells = React.useCallback(function (props, fnUpdate, setSaving, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2283
2295
  return __generator(this, function (_a) {
2284
2296
  switch (_a.label) {
2285
2297
  case 0:
@@ -2340,25 +2352,16 @@ var GridContextProvider = function (props) {
2340
2352
  case 1: return [2 /*return*/, _a.sent()];
2341
2353
  }
2342
2354
  });
2343
- }); };
2344
- var redrawRows = function (rowNodes) {
2355
+ }); }, [gridApiOp, modifyUpdating, selectNextCell]);
2356
+ var redrawRows = React.useCallback(function (rowNodes) {
2345
2357
  gridApiOp(function (gridApi) {
2346
2358
  gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
2347
2359
  });
2348
- };
2349
- var selectNextCell = function (tabDirection) {
2350
- if (tabDirection === void 0) { tabDirection = 0; }
2351
- gridApiOp(function (gridApi) {
2352
- if (tabDirection == 1)
2353
- gridApi.tabToNextCell();
2354
- if (tabDirection == -1)
2355
- gridApi.tabToPreviousCell();
2356
- });
2357
- };
2358
- var setExternallySelectedItemsAreInSync = function (inSync) {
2360
+ }, [gridApiOp]);
2361
+ var setExternallySelectedItemsAreInSync = React.useCallback(function (inSync) {
2359
2362
  externallySelectedItemsAreInSync.current = inSync;
2360
- };
2361
- var waitForExternallySelectedItemsToBeInSync = function () { return __awaiter(void 0, void 0, void 0, function () {
2363
+ }, []);
2364
+ var waitForExternallySelectedItemsToBeInSync = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
2362
2365
  var i;
2363
2366
  return __generator(this, function (_a) {
2364
2367
  switch (_a.label) {
@@ -2377,7 +2380,7 @@ var GridContextProvider = function (props) {
2377
2380
  case 4: return [2 /*return*/];
2378
2381
  }
2379
2382
  });
2380
- }); };
2383
+ }); }, []);
2381
2384
  return (jsxRuntime.jsx(GridContext.Provider, __assign({ value: {
2382
2385
  gridReady: gridReady,
2383
2386
  setGridApi: setGridApi,
@@ -2700,9 +2703,9 @@ var GridHeaderSelect = function (_a) {
2700
2703
  // This is used to force an update on selection change
2701
2704
  var _b = React.useState(0), updateCounter = _b[0], setUpdateCounter = _b[1];
2702
2705
  var selectedNodeCount = api.getSelectedRows().length;
2703
- var clickHandler = function () {
2706
+ var clickHandler = React.useCallback(function () {
2704
2707
  setUpdateCounter(updateCounter + 1);
2705
- };
2708
+ }, [updateCounter]);
2706
2709
  React.useEffect(function () {
2707
2710
  api.addEventListener("selectionChanged", clickHandler);
2708
2711
  return function () { return api.removeEventListener("selectionChanged", clickHandler); };
@@ -2853,9 +2856,9 @@ var Grid = function (params) {
2853
2856
  else {
2854
2857
  e.api.deselectAll();
2855
2858
  }
2856
- return false;
2859
+ return true;
2857
2860
  }
2858
- return true;
2861
+ return false;
2859
2862
  },
2860
2863
  onCellClicked: clickSelectorCheckboxWhenContainingCellClicked
2861
2864
  }
@@ -3236,8 +3239,7 @@ var fieldToString = function (field) {
3236
3239
  return typeof field == "symbol" ? field.toString() : "".concat(field);
3237
3240
  };
3238
3241
  var GridFormDropDown = function (props) {
3239
- var stopEditing = React.useContext(GridContext).stopEditing;
3240
- var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
3242
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, data = _a.data;
3241
3243
  // Save triggers during async action processing which triggers another selectItem(), this ref blocks that
3242
3244
  var _b = React.useState(""), filter = _b[0], setFilter = _b[1];
3243
3245
  var _c = React.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
@@ -3246,7 +3248,8 @@ var GridFormDropDown = function (props) {
3246
3248
  var subComponentIsValid = React.useRef(false);
3247
3249
  var subComponentInitialValue = React.useRef(null);
3248
3250
  var _e = React.useState(null), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
3249
- var _f = React.useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
3251
+ // Note: null is assumed to be the filter
3252
+ var _f = React.useState(null), selectedItem = _f[0], setSelectedItem = _f[1];
3250
3253
  var selectItemHandler = React.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
3251
3254
  var hasChanged;
3252
3255
  return __generator(this, function (_a) {
@@ -3267,45 +3270,6 @@ var GridFormDropDown = function (props) {
3267
3270
  }
3268
3271
  });
3269
3272
  }); }, [field, props, selectedRows]);
3270
- var clickItemHandler = React.useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
3271
- return __generator(this, function (_a) {
3272
- if (subComponentValue !== undefined && !subComponentIsValid.current)
3273
- return [2 /*return*/, false];
3274
- return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
3275
- return __generator(this, function (_a) {
3276
- switch (_a.label) {
3277
- case 0: return [4 /*yield*/, selectItemHandler(value, subComponentValue)];
3278
- case 1: return [2 /*return*/, _a.sent()];
3279
- }
3280
- });
3281
- }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3282
- });
3283
- }); }, [selectItemHandler, updateValue]);
3284
- var selectFilterHandler = React.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
3285
- return __generator(this, function (_a) {
3286
- switch (_a.label) {
3287
- case 0: return [4 /*yield*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3288
- var _a;
3289
- return __generator(this, function (_b) {
3290
- switch (_b.label) {
3291
- case 0:
3292
- _a = props.onSelectFilter;
3293
- if (!_a) return [3 /*break*/, 2];
3294
- return [4 /*yield*/, props.onSelectFilter({ selectedRows: selectedRows, value: value })];
3295
- case 1:
3296
- _a = (_b.sent());
3297
- _b.label = 2;
3298
- case 2:
3299
- return [2 /*return*/, true];
3300
- }
3301
- });
3302
- }); }, 0)];
3303
- case 1:
3304
- _a.sent();
3305
- return [2 /*return*/];
3306
- }
3307
- });
3308
- }); }, [props, updateValue]);
3309
3273
  // Load up options list if it's async function
3310
3274
  React.useEffect(function () {
3311
3275
  var _a;
@@ -3359,7 +3323,7 @@ var GridFormDropDown = function (props) {
3359
3323
  return undefined;
3360
3324
  }
3361
3325
  var str = option.label || "";
3362
- return str.toLowerCase().indexOf(filter.toLowerCase()) === -1 ? option.value : undefined;
3326
+ return str.toLowerCase().indexOf(filter.toLowerCase()) !== -1 ? option : undefined;
3363
3327
  })
3364
3328
  .filter(function (r) { return r !== undefined; }));
3365
3329
  }
@@ -3380,83 +3344,67 @@ var GridFormDropDown = function (props) {
3380
3344
  * Saves are wrapped in updateValue and triggered by blur events
3381
3345
  */
3382
3346
  var save = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3347
+ var onSelectFilter;
3383
3348
  return __generator(this, function (_a) {
3384
3349
  switch (_a.label) {
3385
3350
  case 0:
3386
3351
  if (!options)
3387
3352
  return [2 /*return*/, true];
3388
- // Handler for sub-selected value
3389
- if (!selectedSubComponent)
3390
- return [2 /*return*/, true];
3391
- if (selectedSubComponent.subComponent && !subComponentIsValid.current)
3392
- return [2 /*return*/, false];
3393
- return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
3353
+ if (!(selectedItem === null)) return [3 /*break*/, 5];
3354
+ if (!props.onSelectFilter) return [3 /*break*/, 2];
3355
+ onSelectFilter = props.onSelectFilter;
3356
+ return [4 /*yield*/, onSelectFilter({ selectedRows: selectedRows, value: filter })];
3394
3357
  case 1:
3395
3358
  _a.sent();
3396
3359
  return [2 /*return*/, true];
3360
+ case 2:
3361
+ if (!(filteredValues.length === 1)) return [3 /*break*/, 4];
3362
+ if (filteredValues[0].subComponent)
3363
+ return [2 /*return*/, false];
3364
+ return [4 /*yield*/, selectItemHandler(filteredValues[0].value, null)];
3365
+ case 3: return [2 /*return*/, _a.sent()];
3366
+ case 4: return [2 /*return*/, false];
3367
+ case 5:
3368
+ if (selectedItem.subComponent && !subComponentIsValid.current)
3369
+ return [2 /*return*/, false];
3370
+ return [4 /*yield*/, selectItemHandler(selectedItem.value, subSelectedValue)];
3371
+ case 6:
3372
+ _a.sent();
3373
+ return [2 /*return*/, true];
3397
3374
  }
3398
3375
  });
3399
- }); }, [options, selectItemHandler, selectedSubComponent, subSelectedValue]);
3376
+ }); }, [filter, filteredValues, options, props, selectItemHandler, selectedItem, selectedRows, subSelectedValue]);
3400
3377
  var popoverWrapper = useGridPopoverHook({
3401
3378
  className: props.className,
3402
- invalid: function () { return !!(selectedSubComponent && !subComponentIsValid.current); },
3379
+ invalid: function () { return !!(selectedItem && !subComponentIsValid.current); },
3403
3380
  save: save
3404
3381
  }).popoverWrapper;
3405
- var enterKeyPressedRef = React.useRef(false);
3406
- var handleKeyDown = React.useCallback(function (e) {
3407
- if (e.key === "Enter") {
3408
- e.stopPropagation();
3409
- e.preventDefault();
3410
- enterKeyPressedRef.current = true;
3411
- }
3412
- }, []);
3413
- var handleKeyUp = React.useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
3414
- var _a;
3415
- return __generator(this, function (_b) {
3416
- switch (_b.label) {
3417
- case 0:
3418
- if (!options)
3419
- return [2 /*return*/];
3420
- if (!(e.key === "Enter")) return [3 /*break*/, 3];
3421
- e.stopPropagation();
3422
- e.preventDefault();
3423
- if (!enterKeyPressedRef.current)
3424
- return [2 /*return*/];
3425
- _a = props.onSelectFilter;
3426
- if (!_a) return [3 /*break*/, 2];
3427
- return [4 /*yield*/, selectFilterHandler(filter)];
3428
- case 1:
3429
- _a = (_b.sent());
3430
- _b.label = 2;
3431
- case 2:
3432
- stopEditing();
3433
- _b.label = 3;
3434
- case 3: return [2 /*return*/];
3435
- }
3436
- });
3437
- }); }, [filter, options, props.onSelectFilter, selectFilterHandler, stopEditing]);
3438
- return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3382
+ return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item", onFocus: function () {
3383
+ setSelectedItem(null);
3384
+ setSubSelectedValue(null);
3385
+ subComponentIsValid.current = true;
3386
+ } }, { children: function (_a) {
3439
3387
  var _b;
3440
3388
  var ref = _a.ref;
3441
- return (jsxRuntime.jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [jsxRuntime.jsx("input", { autoFocus: true, className: "LuiTextInput-input", ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, "data-disableenterautosave": true, "data-allowtabtosave": true, onChange: function (e) { return setFilter(e.target.value); }, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }), props.filterHelpText && isNotEmpty(filter) && (jsxRuntime.jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
3442
- } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (jsxRuntime.jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: "No Options" }), "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3389
+ return (jsxRuntime.jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [jsxRuntime.jsx("input", { className: "LuiTextInput-input", ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, "data-allowtabtosave": true, "data-disableenterautosave": !props.onSelectFilter && !(filteredValues.length === 1 && !filteredValues[0].subComponent), onChange: function (e) { return setFilter(e.target.value); } }), props.filterHelpText && isNotEmpty(filter) && (jsxRuntime.jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
3390
+ } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && lodashEs.isEmpty(filteredValues) && (jsxRuntime.jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: "No Options" }), "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3443
3391
  var _a;
3444
- return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
3392
+ return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : (filteredValues.includes(item) && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
3393
+ setSelectedItem(item);
3445
3394
  if (item.subComponent) {
3446
- // toggle selection
3447
- setSelectedSubComponent(selectedSubComponent === item ? null : item);
3395
+ setSelectedItem(item);
3448
3396
  subComponentIsValid.current = true;
3449
3397
  subComponentInitialValue.current = null;
3450
- e.keepOpen = true;
3451
3398
  }
3452
3399
  else {
3453
- clickItemHandler(item.value, undefined, e.key === "Tab"
3454
- ? e.shiftKey
3455
- ? CloseReason.TAB_BACKWARD
3456
- : CloseReason.TAB_FORWARD
3457
- : CloseReason.CLICK).then();
3400
+ setSubSelectedValue(null);
3401
+ subComponentIsValid.current = true;
3402
+ }
3403
+ }, onClick: function (e) {
3404
+ if (item.subComponent) {
3405
+ e.keepOpen = true;
3458
3406
  }
3459
- } }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedSubComponent === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3407
+ } }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedItem === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3460
3408
  context: { options: options },
3461
3409
  data: data,
3462
3410
  value: subSelectedValue,
@@ -3476,7 +3424,7 @@ var GridFormDropDown = function (props) {
3476
3424
  return [2 /*return*/];
3477
3425
  });
3478
3426
  }); }
3479
- } }, { children: item.subComponent && (jsxRuntime.jsx("div", __assign({ className: "subComponent" }, { children: jsxRuntime.jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index)));
3427
+ } }, { children: item.subComponent && (jsxRuntime.jsx("div", __assign({ className: "subComponent" }, { children: jsxRuntime.jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index))));
3480
3428
  })] }) }))] }));
3481
3429
  };
3482
3430