@linzjs/step-ag-grid 7.11.8 → 7.11.10

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,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useMemo, useLayoutEffect, useEffect, createContext, memo, forwardRef, useRef, useContext, useState, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
3
3
  import ReactDOM, { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
4
- import { findIndex, debounce, negate, isEmpty, delay, sortBy, defer as defer$1, last, difference, castArray, remove, flatten, xorBy, partition, pick, groupBy, fromPairs, toPairs, omit } from 'lodash-es';
4
+ import { findIndex, debounce, negate, isEmpty, difference, delay, sortBy, defer as defer$1, last, castArray, remove, flatten, xorBy, partition, pick, groupBy, fromPairs, toPairs, omit } from 'lodash-es';
5
5
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
6
6
  import { AgGridReact } from 'ag-grid-react';
7
7
  import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput, LuiButton } from '@linzjs/lui';
@@ -1427,8 +1427,8 @@ var ControlledMenuFr = function (_a, externalRef) {
1427
1427
  if (activeElement !== firstInputEl && activeElement !== lastInputEl)
1428
1428
  return;
1429
1429
  var isTextArea = activeElement.nodeName === "TEXTAREA";
1430
- var suppressEnterAutoSave = activeElement.getAttribute("data-disableenterautosave") || isTextArea;
1431
- var allowTabToSave = activeElement.getAttribute("data-allowtabtosave");
1430
+ var suppressEnterAutoSave = activeElement.getAttribute("data-disableenterautosave") == "true" || isTextArea;
1431
+ var allowTabToSave = activeElement.getAttribute("data-allowtabtosave") == "true";
1432
1432
  var invokeSave = function (reason) {
1433
1433
  var _a, _b;
1434
1434
  if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current))
@@ -2060,68 +2060,68 @@ var GridContextProvider = function (props) {
2060
2060
  var _b = useState(false), gridReady = _b[0], setGridReady = _b[1];
2061
2061
  var idsBeforeUpdate = useRef([]);
2062
2062
  var externallySelectedItemsAreInSync = useRef(false);
2063
- var setGridApi = function (gridApi) {
2063
+ var setGridApi = useCallback(function (gridApi) {
2064
2064
  _setGridApi(gridApi);
2065
2065
  setGridReady(!!gridApi);
2066
- };
2066
+ }, []);
2067
2067
  /**
2068
2068
  * Wraps things that require gridApi in common handling, for when gridApi not present.
2069
2069
  *
2070
2070
  * @param hasApiFn Execute when api is ready.
2071
2071
  * @param noApiFn Execute if api is not ready.
2072
2072
  */
2073
- var gridApiOp = function (hasApiFn, noApiFn) {
2073
+ var gridApiOp = useCallback(function (hasApiFn, noApiFn) {
2074
2074
  if (!noApiFn) {
2075
2075
  noApiFn = (function () { });
2076
2076
  }
2077
2077
  return gridApi ? hasApiFn(gridApi) : noApiFn();
2078
- };
2078
+ }, [gridApi]);
2079
2079
  /**
2080
2080
  * Set the quick filter value to grid.
2081
2081
  */
2082
- var setQuickFilter = function (quickFilter) {
2082
+ var setQuickFilter = useCallback(function (quickFilter) {
2083
2083
  gridApiOp(function (gridApi) { return gridApi.setQuickFilter(quickFilter); });
2084
- };
2084
+ }, [gridApiOp]);
2085
2085
  /**
2086
2086
  * Get all row id's in grid.
2087
2087
  */
2088
- var _getAllRowIds = function () {
2088
+ var _getAllRowIds = useCallback(function () {
2089
2089
  var result = [];
2090
2090
  return gridApiOp(function (gridApi) {
2091
2091
  gridApi.forEachNode(function (node) { return result.push(node.data.id); });
2092
2092
  return result;
2093
2093
  }, function () { return result; });
2094
- };
2094
+ }, [gridApiOp]);
2095
2095
  /**
2096
2096
  * Record all row id's before update so that we can select/flash the new rows after update.
2097
2097
  */
2098
- var beforeUpdate = function () {
2098
+ var beforeUpdate = useCallback(function () {
2099
2099
  idsBeforeUpdate.current = _getAllRowIds();
2100
- };
2100
+ }, [_getAllRowIds]);
2101
2101
  /**
2102
2102
  * Find new row ids
2103
2103
  * Uses beforeUpdate ids to find new nodes.
2104
2104
  */
2105
- var _getNewNodes = function () {
2105
+ var _getNewNodes = useCallback(function () {
2106
2106
  return gridApiOp(function (gridApi) {
2107
2107
  return difference(_getAllRowIds(), idsBeforeUpdate.current)
2108
2108
  .map(function (rowId) { return gridApi.getRowNode("" + rowId); }) //
2109
2109
  .filter(function (r) { return r; });
2110
2110
  }, function () { return []; });
2111
- };
2111
+ }, [_getAllRowIds, gridApiOp]);
2112
2112
  /**
2113
2113
  * Get grid nodes via rowIds. If rowIds has no matching node the result may be smaller than expected.
2114
2114
  * This can happen if the grid has not re-rendered yet.
2115
2115
  *
2116
2116
  * @param rowIds Row ids to get from grid.
2117
2117
  */
2118
- var _rowIdsToNodes = function (rowIds) {
2118
+ var _rowIdsToNodes = useCallback(function (rowIds) {
2119
2119
  return gridApiOp(function (gridApi) {
2120
2120
  return rowIds
2121
2121
  .map(function (rowId) { return gridApi.getRowNode("" + rowId); }) //
2122
2122
  .filter(function (r) { return r; });
2123
2123
  }, function () { return []; });
2124
- };
2124
+ }, [gridApiOp]);
2125
2125
  /**
2126
2126
  * Internal method for selecting and flashing rows.
2127
2127
  *
@@ -2130,7 +2130,7 @@ var GridContextProvider = function (props) {
2130
2130
  * @param flash Whether to flash rows
2131
2131
  * @param retryCount Table updates may not be present when this is called, so retry is needed.
2132
2132
  */
2133
- var _selectRowsWithOptionalFlash = function (rowIds, select, flash, retryCount) {
2133
+ var _selectRowsWithOptionalFlash = useCallback(function (rowIds, select, flash, retryCount) {
2134
2134
  if (retryCount === void 0) { retryCount = 15; }
2135
2135
  return gridApiOp(function (gridApi) {
2136
2136
  var _a;
@@ -2155,7 +2155,8 @@ var GridContextProvider = function (props) {
2155
2155
  var colId_1 = col.colId;
2156
2156
  // We need to make sure we aren't currently editing a cell otherwise tests will fail
2157
2157
  // as they will start to edit the cell before this stuff has a chance to run
2158
- colId_1 != null && defer$1(function () { return isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex_1, colId_1); });
2158
+ colId_1 != null &&
2159
+ defer$1(function () { return isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex_1, colId_1); });
2159
2160
  }
2160
2161
  }
2161
2162
  }
@@ -2180,11 +2181,11 @@ var GridContextProvider = function (props) {
2180
2181
  }, 250);
2181
2182
  }
2182
2183
  });
2183
- };
2184
- var selectRowsById = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, false); };
2185
- var selectRowsByIdWithFlash = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, true); };
2186
- var flashRows = function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, false, true); };
2187
- var selectRowsDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2184
+ }, [_getNewNodes, _rowIdsToNodes, gridApiOp]);
2185
+ var selectRowsById = useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, false); }, [_selectRowsWithOptionalFlash]);
2186
+ var selectRowsByIdWithFlash = useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, true, true); }, [_selectRowsWithOptionalFlash]);
2187
+ var flashRows = useCallback(function (rowIds) { return _selectRowsWithOptionalFlash(rowIds, false, true); }, [_selectRowsWithOptionalFlash]);
2188
+ var selectRowsDiff = useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2188
2189
  return __generator(this, function (_a) {
2189
2190
  switch (_a.label) {
2190
2191
  case 0:
@@ -2196,8 +2197,8 @@ var GridContextProvider = function (props) {
2196
2197
  return [2 /*return*/];
2197
2198
  }
2198
2199
  });
2199
- }); };
2200
- var selectRowsWithFlashDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2200
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2201
+ var selectRowsWithFlashDiff = useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2201
2202
  return __generator(this, function (_a) {
2202
2203
  switch (_a.label) {
2203
2204
  case 0:
@@ -2209,8 +2210,8 @@ var GridContextProvider = function (props) {
2209
2210
  return [2 /*return*/];
2210
2211
  }
2211
2212
  });
2212
- }); };
2213
- var flashRowsDiff = function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2213
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2214
+ var flashRowsDiff = useCallback(function (fn) { return __awaiter(void 0, void 0, void 0, function () {
2214
2215
  return __generator(this, function (_a) {
2215
2216
  switch (_a.label) {
2216
2217
  case 0:
@@ -2222,15 +2223,15 @@ var GridContextProvider = function (props) {
2222
2223
  return [2 /*return*/];
2223
2224
  }
2224
2225
  });
2225
- }); };
2226
- var getSelectedRows = function () {
2226
+ }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2227
+ var getSelectedRows = useCallback(function () {
2227
2228
  return gridApiOp(function (gridApi) { return gridApi.getSelectedRows(); }, function () { return []; });
2228
- };
2229
- var getSelectedRowIds = function () { return getSelectedRows().map(function (row) { return row.id; }); };
2230
- var editingCells = function () {
2229
+ }, [gridApiOp]);
2230
+ var getSelectedRowIds = useCallback(function () { return getSelectedRows().map(function (row) { return row.id; }); }, [getSelectedRows]);
2231
+ var editingCells = useCallback(function () {
2231
2232
  return gridApiOp(function (gridApi) { return isNotEmpty(gridApi.getEditingCells()); }, function () { return false; });
2232
- };
2233
- var ensureRowVisible = function (id) {
2233
+ }, [gridApiOp]);
2234
+ var ensureRowVisible = useCallback(function (id) {
2234
2235
  return gridApiOp(function (gridApi) {
2235
2236
  var node = gridApi.getRowNode("".concat(id));
2236
2237
  if (!node)
@@ -2238,29 +2239,38 @@ var GridContextProvider = function (props) {
2238
2239
  gridApi.ensureNodeVisible(node);
2239
2240
  return true;
2240
2241
  });
2241
- };
2242
+ }, [gridApiOp]);
2242
2243
  /**
2243
2244
  * Scroll last selected row into view on grid sort change
2244
2245
  */
2245
- var ensureSelectedRowIsVisible = function () {
2246
+ var ensureSelectedRowIsVisible = useCallback(function () {
2246
2247
  gridApiOp(function (gridApi) {
2247
2248
  var selectedNodes = gridApi.getSelectedNodes();
2248
2249
  if (isEmpty(selectedNodes))
2249
2250
  return;
2250
2251
  gridApi.ensureNodeVisible(last(selectedNodes));
2251
2252
  });
2252
- };
2253
+ }, [gridApiOp]);
2253
2254
  /**
2254
2255
  * Resize columns to fit container
2255
2256
  */
2256
- var sizeColumnsToFit = function () {
2257
+ var sizeColumnsToFit = useCallback(function () {
2257
2258
  gridApiOp(function (gridApi) {
2258
2259
  // Hide size columns to fit errors in tests
2259
2260
  document.body.clientWidth && gridApi.sizeColumnsToFit();
2260
2261
  });
2261
- };
2262
- var stopEditing = function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); };
2263
- var updatingCells = function (props, fnUpdate, setSaving, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2262
+ }, [gridApiOp]);
2263
+ var stopEditing = useCallback(function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); }, [gridApiOp]);
2264
+ var selectNextCell = useCallback(function (tabDirection) {
2265
+ if (tabDirection === void 0) { tabDirection = 0; }
2266
+ gridApiOp(function (gridApi) {
2267
+ if (tabDirection == 1)
2268
+ gridApi.tabToNextCell();
2269
+ if (tabDirection == -1)
2270
+ gridApi.tabToPreviousCell();
2271
+ });
2272
+ }, [gridApiOp]);
2273
+ var updatingCells = useCallback(function (props, fnUpdate, setSaving, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2264
2274
  return __generator(this, function (_a) {
2265
2275
  switch (_a.label) {
2266
2276
  case 0:
@@ -2321,25 +2331,16 @@ var GridContextProvider = function (props) {
2321
2331
  case 1: return [2 /*return*/, _a.sent()];
2322
2332
  }
2323
2333
  });
2324
- }); };
2325
- var redrawRows = function (rowNodes) {
2334
+ }); }, [gridApiOp, modifyUpdating, selectNextCell]);
2335
+ var redrawRows = useCallback(function (rowNodes) {
2326
2336
  gridApiOp(function (gridApi) {
2327
2337
  gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
2328
2338
  });
2329
- };
2330
- var selectNextCell = function (tabDirection) {
2331
- if (tabDirection === void 0) { tabDirection = 0; }
2332
- gridApiOp(function (gridApi) {
2333
- if (tabDirection == 1)
2334
- gridApi.tabToNextCell();
2335
- if (tabDirection == -1)
2336
- gridApi.tabToPreviousCell();
2337
- });
2338
- };
2339
- var setExternallySelectedItemsAreInSync = function (inSync) {
2339
+ }, [gridApiOp]);
2340
+ var setExternallySelectedItemsAreInSync = useCallback(function (inSync) {
2340
2341
  externallySelectedItemsAreInSync.current = inSync;
2341
- };
2342
- var waitForExternallySelectedItemsToBeInSync = function () { return __awaiter(void 0, void 0, void 0, function () {
2342
+ }, []);
2343
+ var waitForExternallySelectedItemsToBeInSync = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
2343
2344
  var i;
2344
2345
  return __generator(this, function (_a) {
2345
2346
  switch (_a.label) {
@@ -2358,7 +2359,7 @@ var GridContextProvider = function (props) {
2358
2359
  case 4: return [2 /*return*/];
2359
2360
  }
2360
2361
  });
2361
- }); };
2362
+ }); }, []);
2362
2363
  return (jsx(GridContext.Provider, __assign({ value: {
2363
2364
  gridReady: gridReady,
2364
2365
  setGridApi: setGridApi,
@@ -3217,8 +3218,7 @@ var fieldToString = function (field) {
3217
3218
  return typeof field == "symbol" ? field.toString() : "".concat(field);
3218
3219
  };
3219
3220
  var GridFormDropDown = function (props) {
3220
- var stopEditing = useContext(GridContext).stopEditing;
3221
- var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
3221
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, data = _a.data;
3222
3222
  // Save triggers during async action processing which triggers another selectItem(), this ref blocks that
3223
3223
  var _b = useState(""), filter = _b[0], setFilter = _b[1];
3224
3224
  var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
@@ -3227,7 +3227,8 @@ var GridFormDropDown = function (props) {
3227
3227
  var subComponentIsValid = useRef(false);
3228
3228
  var subComponentInitialValue = useRef(null);
3229
3229
  var _e = useState(null), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
3230
- var _f = useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
3230
+ // Note: null is assumed to be the filter
3231
+ var _f = useState(null), selectedItem = _f[0], setSelectedItem = _f[1];
3231
3232
  var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
3232
3233
  var hasChanged;
3233
3234
  return __generator(this, function (_a) {
@@ -3248,45 +3249,6 @@ var GridFormDropDown = function (props) {
3248
3249
  }
3249
3250
  });
3250
3251
  }); }, [field, props, selectedRows]);
3251
- var clickItemHandler = useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
3252
- return __generator(this, function (_a) {
3253
- if (subComponentValue !== undefined && !subComponentIsValid.current)
3254
- return [2 /*return*/, false];
3255
- return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
3256
- return __generator(this, function (_a) {
3257
- switch (_a.label) {
3258
- case 0: return [4 /*yield*/, selectItemHandler(value, subComponentValue)];
3259
- case 1: return [2 /*return*/, _a.sent()];
3260
- }
3261
- });
3262
- }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3263
- });
3264
- }); }, [selectItemHandler, updateValue]);
3265
- var selectFilterHandler = useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
3266
- return __generator(this, function (_a) {
3267
- switch (_a.label) {
3268
- case 0: return [4 /*yield*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3269
- var _a;
3270
- return __generator(this, function (_b) {
3271
- switch (_b.label) {
3272
- case 0:
3273
- _a = props.onSelectFilter;
3274
- if (!_a) return [3 /*break*/, 2];
3275
- return [4 /*yield*/, props.onSelectFilter({ selectedRows: selectedRows, value: value })];
3276
- case 1:
3277
- _a = (_b.sent());
3278
- _b.label = 2;
3279
- case 2:
3280
- return [2 /*return*/, true];
3281
- }
3282
- });
3283
- }); }, 0)];
3284
- case 1:
3285
- _a.sent();
3286
- return [2 /*return*/];
3287
- }
3288
- });
3289
- }); }, [props, updateValue]);
3290
3252
  // Load up options list if it's async function
3291
3253
  useEffect(function () {
3292
3254
  var _a;
@@ -3340,7 +3302,7 @@ var GridFormDropDown = function (props) {
3340
3302
  return undefined;
3341
3303
  }
3342
3304
  var str = option.label || "";
3343
- return str.toLowerCase().indexOf(filter.toLowerCase()) === -1 ? option.value : undefined;
3305
+ return str.toLowerCase().indexOf(filter.toLowerCase()) !== -1 ? option : undefined;
3344
3306
  })
3345
3307
  .filter(function (r) { return r !== undefined; }));
3346
3308
  }
@@ -3361,83 +3323,67 @@ var GridFormDropDown = function (props) {
3361
3323
  * Saves are wrapped in updateValue and triggered by blur events
3362
3324
  */
3363
3325
  var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3326
+ var onSelectFilter;
3364
3327
  return __generator(this, function (_a) {
3365
3328
  switch (_a.label) {
3366
3329
  case 0:
3367
3330
  if (!options)
3368
3331
  return [2 /*return*/, true];
3369
- // Handler for sub-selected value
3370
- if (!selectedSubComponent)
3371
- return [2 /*return*/, true];
3372
- if (selectedSubComponent.subComponent && !subComponentIsValid.current)
3373
- return [2 /*return*/, false];
3374
- return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
3332
+ if (!(selectedItem === null)) return [3 /*break*/, 5];
3333
+ if (!props.onSelectFilter) return [3 /*break*/, 2];
3334
+ onSelectFilter = props.onSelectFilter;
3335
+ return [4 /*yield*/, onSelectFilter({ selectedRows: selectedRows, value: filter })];
3375
3336
  case 1:
3376
3337
  _a.sent();
3377
3338
  return [2 /*return*/, true];
3339
+ case 2:
3340
+ if (!(filteredValues.length === 1)) return [3 /*break*/, 4];
3341
+ if (filteredValues[0].subComponent)
3342
+ return [2 /*return*/, false];
3343
+ return [4 /*yield*/, selectItemHandler(filteredValues[0].value, null)];
3344
+ case 3: return [2 /*return*/, _a.sent()];
3345
+ case 4: return [2 /*return*/, false];
3346
+ case 5:
3347
+ if (selectedItem.subComponent && !subComponentIsValid.current)
3348
+ return [2 /*return*/, false];
3349
+ return [4 /*yield*/, selectItemHandler(selectedItem.value, subSelectedValue)];
3350
+ case 6:
3351
+ _a.sent();
3352
+ return [2 /*return*/, true];
3378
3353
  }
3379
3354
  });
3380
- }); }, [options, selectItemHandler, selectedSubComponent, subSelectedValue]);
3355
+ }); }, [filter, filteredValues, options, props, selectItemHandler, selectedItem, selectedRows, subSelectedValue]);
3381
3356
  var popoverWrapper = useGridPopoverHook({
3382
3357
  className: props.className,
3383
- invalid: function () { return !!(selectedSubComponent && !subComponentIsValid.current); },
3358
+ invalid: function () { return !!(selectedItem && !subComponentIsValid.current); },
3384
3359
  save: save
3385
3360
  }).popoverWrapper;
3386
- var enterKeyPressedRef = useRef(false);
3387
- var handleKeyDown = useCallback(function (e) {
3388
- if (e.key === "Enter") {
3389
- e.stopPropagation();
3390
- e.preventDefault();
3391
- enterKeyPressedRef.current = true;
3392
- }
3393
- }, []);
3394
- var handleKeyUp = useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
3395
- var _a;
3396
- return __generator(this, function (_b) {
3397
- switch (_b.label) {
3398
- case 0:
3399
- if (!options)
3400
- return [2 /*return*/];
3401
- if (!(e.key === "Enter")) return [3 /*break*/, 3];
3402
- e.stopPropagation();
3403
- e.preventDefault();
3404
- if (!enterKeyPressedRef.current)
3405
- return [2 /*return*/];
3406
- _a = props.onSelectFilter;
3407
- if (!_a) return [3 /*break*/, 2];
3408
- return [4 /*yield*/, selectFilterHandler(filter)];
3409
- case 1:
3410
- _a = (_b.sent());
3411
- _b.label = 2;
3412
- case 2:
3413
- stopEditing();
3414
- _b.label = 3;
3415
- case 3: return [2 /*return*/];
3416
- }
3417
- });
3418
- }); }, [filter, options, props.onSelectFilter, selectFilterHandler, stopEditing]);
3419
- return popoverWrapper(jsxs(Fragment$1, { children: [props.filtered && (jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3361
+ return popoverWrapper(jsxs(Fragment$1, { children: [props.filtered && (jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsx(FocusableItem, __assign({ className: "filter-item", onFocus: function () {
3362
+ setSelectedItem(null);
3363
+ setSubSelectedValue(null);
3364
+ subComponentIsValid.current = true;
3365
+ } }, { children: function (_a) {
3420
3366
  var _b;
3421
3367
  var ref = _a.ref;
3422
- return (jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [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) && (jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
3423
- } })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (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) {
3368
+ return (jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [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) && (jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
3369
+ } })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && isEmpty(filteredValues) && (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) {
3424
3370
  var _a;
3425
- return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
3371
+ return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : (filteredValues.includes(item) && (jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
3372
+ setSelectedItem(item);
3426
3373
  if (item.subComponent) {
3427
- // toggle selection
3428
- setSelectedSubComponent(selectedSubComponent === item ? null : item);
3374
+ setSelectedItem(item);
3429
3375
  subComponentIsValid.current = true;
3430
3376
  subComponentInitialValue.current = null;
3431
- e.keepOpen = true;
3432
3377
  }
3433
3378
  else {
3434
- clickItemHandler(item.value, undefined, e.key === "Tab"
3435
- ? e.shiftKey
3436
- ? CloseReason.TAB_BACKWARD
3437
- : CloseReason.TAB_FORWARD
3438
- : CloseReason.CLICK).then();
3379
+ setSubSelectedValue(null);
3380
+ subComponentIsValid.current = true;
3381
+ }
3382
+ }, onClick: function (e) {
3383
+ if (item.subComponent) {
3384
+ e.keepOpen = true;
3439
3385
  }
3440
- } }, { 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 && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
3386
+ } }, { 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 && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
3441
3387
  context: { options: options },
3442
3388
  data: data,
3443
3389
  value: subSelectedValue,
@@ -3457,7 +3403,7 @@ var GridFormDropDown = function (props) {
3457
3403
  return [2 /*return*/];
3458
3404
  });
3459
3405
  }); }
3460
- } }, { children: item.subComponent && (jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index)));
3406
+ } }, { children: item.subComponent && (jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index))));
3461
3407
  })] }) }))] }));
3462
3408
  };
3463
3409