@linzjs/step-ag-grid 1.4.5 → 1.4.6

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.
Files changed (72) hide show
  1. package/dist/index.js +195 -163
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -1
  4. package/dist/src/react-menu3/components/Menu.d.ts +16 -2
  5. package/dist/src/react-menu3/components/MenuButton.d.ts +8 -1
  6. package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -2
  7. package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -2
  8. package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -2
  9. package/dist/src/react-menu3/components/MenuItem.d.ts +59 -1
  10. package/dist/src/react-menu3/components/MenuList.d.ts +57 -30
  11. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +44 -2
  12. package/dist/src/react-menu3/components/SubMenu.d.ts +110 -1
  13. package/dist/src/react-menu3/hooks/useBEM.d.ts +4 -3
  14. package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
  15. package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
  16. package/dist/src/react-menu3/hooks/useItemState.d.ts +4 -3
  17. package/dist/src/react-menu3/hooks/useItems.d.ts +6 -4
  18. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -1
  19. package/dist/src/react-menu3/hooks/useMenuState.d.ts +13 -10
  20. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -10
  21. package/dist/src/react-menu3/index.d.ts +391 -0
  22. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +10 -9
  23. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +7 -6
  24. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +7 -6
  25. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +17 -19
  26. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +18 -20
  27. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +11 -6
  28. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +23 -18
  29. package/dist/src/react-menu3/utils/constants.d.ts +51 -9
  30. package/dist/src/react-menu3/utils/propTypes.d.ts +1 -0
  31. package/dist/src/react-menu3/utils/utils.d.ts +19 -10
  32. package/dist/src/react-menu3/utils/withHovering.d.ts +7 -1
  33. package/dist/src/stories/components/ReactMenu.stories.d.ts +8 -0
  34. package/dist/step-ag-grid.esm.js +197 -165
  35. package/dist/step-ag-grid.esm.js.map +1 -1
  36. package/package.json +11 -11
  37. package/src/components/gridForm/GridFormDropDown.tsx +1 -1
  38. package/src/components/gridForm/GridFormMultiSelect.tsx +10 -4
  39. package/src/react-menu3/components/ControlledMenu.tsx +2 -1
  40. package/src/react-menu3/components/FocusableItem.tsx +58 -53
  41. package/src/react-menu3/components/Menu.tsx +40 -28
  42. package/src/react-menu3/components/MenuButton.tsx +30 -29
  43. package/src/react-menu3/components/MenuDivider.tsx +14 -18
  44. package/src/react-menu3/components/MenuGroup.tsx +25 -16
  45. package/src/react-menu3/components/MenuHeader.tsx +14 -18
  46. package/src/react-menu3/components/MenuItem.tsx +159 -106
  47. package/src/react-menu3/components/MenuList.tsx +104 -36
  48. package/src/react-menu3/components/MenuRadioGroup.tsx +54 -15
  49. package/src/react-menu3/components/SubMenu.tsx +307 -201
  50. package/src/react-menu3/hooks/useBEM.ts +4 -3
  51. package/src/react-menu3/hooks/useCombinedRef.ts +6 -12
  52. package/src/react-menu3/hooks/useItemEffect.ts +6 -5
  53. package/src/react-menu3/hooks/useItemState.ts +16 -12
  54. package/src/react-menu3/hooks/useItems.ts +11 -10
  55. package/src/react-menu3/hooks/useMenuChange.ts +3 -3
  56. package/src/react-menu3/hooks/useMenuState.ts +25 -7
  57. package/src/react-menu3/hooks/useMenuStateAndFocus.ts +6 -4
  58. package/src/react-menu3/index.d.ts +1 -0
  59. package/src/react-menu3/index.ts +431 -0
  60. package/src/react-menu3/positionUtils/getPositionHelpers.ts +18 -11
  61. package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +12 -5
  62. package/src/react-menu3/positionUtils/placeArrowVertical.ts +12 -5
  63. package/src/react-menu3/positionUtils/placeLeftorRight.ts +33 -17
  64. package/src/react-menu3/positionUtils/placeToporBottom.ts +34 -18
  65. package/src/react-menu3/positionUtils/positionContextMenu.ts +15 -3
  66. package/src/react-menu3/positionUtils/positionMenu.ts +21 -14
  67. package/src/react-menu3/style-utils/index.ts +10 -7
  68. package/src/react-menu3/utils/constants.ts +63 -10
  69. package/src/react-menu3/utils/propTypes.ts +3 -1
  70. package/src/react-menu3/utils/utils.ts +40 -23
  71. package/src/react-menu3/utils/withHovering.tsx +11 -6
  72. package/src/stories/components/ReactMenu.stories.tsx +37 -0
package/dist/index.js CHANGED
@@ -991,10 +991,6 @@ var setRef = function (ref, instance) {
991
991
  };
992
992
  var useCombinedRef = function (refA, refB) {
993
993
  return react.useMemo(function () {
994
- if (!refA)
995
- return refB;
996
- if (!refB)
997
- return refA;
998
994
  return function (instance) {
999
995
  setRef(refA, instance);
1000
996
  setRef(refB, instance);
@@ -1012,7 +1008,6 @@ var useIsomorphicLayoutEffect = typeof window !== "undefined" &&
1012
1008
  ? react.useLayoutEffect
1013
1009
  : react.useEffect;
1014
1010
 
1015
- // @ts-nocheck
1016
1011
  var menuContainerClass = "szh-menu-container";
1017
1012
  var menuClass = "szh-menu";
1018
1013
  var menuButtonClass = "szh-menu-button";
@@ -1023,13 +1018,23 @@ var menuHeaderClass = "header";
1023
1018
  var menuGroupClass = "group";
1024
1019
  var subMenuClass = "submenu";
1025
1020
  var radioGroupClass = "radio-group";
1026
- var HoverItemContext = react.createContext();
1027
- var MenuListItemContext = react.createContext({});
1021
+ var HoverItemContext = react.createContext(undefined);
1022
+ var MenuListItemContext = react.createContext({
1023
+ dispatch: function () { },
1024
+ updateItems: function () { },
1025
+ setOpenSubmenuCount: function () { return 0; }
1026
+ });
1028
1027
  var MenuListContext = react.createContext({});
1029
- var EventHandlersContext = react.createContext({});
1028
+ var EventHandlersContext = react.createContext({
1029
+ handleClick: function () { }
1030
+ });
1030
1031
  var RadioGroupContext = react.createContext({});
1032
+ // FIXME hacking a default context in here is probably bad
1031
1033
  var SettingsContext = react.createContext({});
1032
- var ItemSettingsContext = react.createContext({});
1034
+ var ItemSettingsContext = react.createContext({
1035
+ submenuOpenDelay: 0,
1036
+ submenuCloseDelay: 0
1037
+ });
1033
1038
  var Keys = Object.freeze({
1034
1039
  ENTER: "Enter",
1035
1040
  ESC: "Escape",
@@ -1068,7 +1073,6 @@ var MenuStateMap = Object.freeze({
1068
1073
  exited: "closed"
1069
1074
  });
1070
1075
 
1071
- // @ts-nocheck
1072
1076
  var isMenuOpen = function (state) { return !!state && state[0] === "o"; };
1073
1077
  var batchedUpdates = reactDom.unstable_batchedUpdates || (function (callback) { return callback(); });
1074
1078
  var values = Object.values || (function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); });
@@ -1079,10 +1083,11 @@ var floatEqual = function (a, b, diff) {
1079
1083
  var getTransition = function (transition, name) {
1080
1084
  return transition === true || !!(transition && transition[name]);
1081
1085
  };
1082
- var safeCall = function (fn, arg) { return (typeof fn === "function" ? fn(arg) : fn); };
1086
+ function safeCall(fn, arg) {
1087
+ return typeof fn === "function" ? fn(arg) : fn;
1088
+ }
1083
1089
  var internalKey = "_szhsinMenu";
1084
1090
  var getName = function (component) { return component[internalKey]; };
1085
- var defineName = function (name, component) { return Object.defineProperty(component, internalKey, { value: name }); };
1086
1091
  var mergeProps = function (target, source) {
1087
1092
  source &&
1088
1093
  Object.keys(source).forEach(function (key) {
@@ -1105,7 +1110,7 @@ var mergeProps = function (target, source) {
1105
1110
  return target;
1106
1111
  };
1107
1112
  var parsePadding = function (paddingStr) {
1108
- if (typeof paddingStr !== "string")
1113
+ if (paddingStr == null)
1109
1114
  return { top: 0, right: 0, bottom: 0, left: 0 };
1110
1115
  var padding = paddingStr.trim().split(/\s+/, 4).map(parseFloat);
1111
1116
  var top = !isNaN(padding[0]) ? padding[0] : 0;
@@ -1119,15 +1124,19 @@ var parsePadding = function (paddingStr) {
1119
1124
  };
1120
1125
  // Adapted from https://github.com/popperjs/popper-core/tree/v2.9.1/src/dom-utils
1121
1126
  var getScrollAncestor = function (node) {
1122
- var thisWindow = node.ownerDocument.defaultView;
1127
+ var _a, _b, _c;
1128
+ var thisWindow = (_b = ((_a = node === null || node === void 0 ? void 0 : node.ownerDocument) !== null && _a !== void 0 ? _a : document).defaultView) !== null && _b !== void 0 ? _b : window;
1123
1129
  while (node) {
1124
1130
  node = node.parentNode;
1125
- if (!node || node === thisWindow.document.body)
1126
- return;
1127
- var _a = thisWindow.getComputedStyle(node), overflow = _a.overflow, overflowX = _a.overflowX, overflowY = _a.overflowY;
1128
- if (/auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX))
1129
- return node;
1131
+ if (!node || node === ((_c = thisWindow === null || thisWindow === void 0 ? void 0 : thisWindow.document) === null || _c === void 0 ? void 0 : _c.body))
1132
+ return null;
1133
+ if (node instanceof Element) {
1134
+ var _d = thisWindow.getComputedStyle(node), overflow = _d.overflow, overflowX = _d.overflowX, overflowY = _d.overflowY;
1135
+ if (/auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX))
1136
+ return node;
1137
+ }
1130
1138
  }
1139
+ return null;
1131
1140
  };
1132
1141
  function commonProps(isDisabled, isHovering) {
1133
1142
  return {
@@ -1135,13 +1144,7 @@ function commonProps(isDisabled, isHovering) {
1135
1144
  tabIndex: isHovering ? 0 : -1
1136
1145
  };
1137
1146
  }
1138
- function indexOfNode(nodeList, node) {
1139
- for (var i = 0; i < nodeList.length; i++) {
1140
- if (nodeList[i] === node)
1141
- return i;
1142
- }
1143
- return -1;
1144
- }
1147
+ var indexOfNode = function (nodeList, node) { return lodashEs.findIndex(nodeList, node); };
1145
1148
 
1146
1149
  var stylePropTypes = function (name) {
1147
1150
  var _a;
@@ -1149,8 +1152,9 @@ var stylePropTypes = function (name) {
1149
1152
  _a[name ? "".concat(name, "ClassName") : "className"] = propTypes.oneOfType([propTypes.string, propTypes.func]),
1150
1153
  _a);
1151
1154
  };
1155
+ var Direction = propTypes.oneOf(["left", "right", "top", "bottom"]);
1152
1156
  // Menu, SubMenu and ControlledMenu
1153
- var menuPropTypes = __assign(__assign(__assign({ className: propTypes.string }, stylePropTypes("menu")), stylePropTypes("arrow")), { menuStyle: propTypes.object, arrowStyle: propTypes.object, arrow: propTypes.bool, setDownOverflow: propTypes.bool, offsetX: propTypes.number, offsetY: propTypes.number, align: propTypes.oneOf(["start", "center", "end"]), direction: propTypes.oneOf(["left", "right", "top", "bottom"]), position: propTypes.oneOf(["auto", "anchor", "initial"]), overflow: propTypes.oneOf(["auto", "visible", "hidden"]) });
1157
+ var menuPropTypes = __assign(__assign(__assign({ className: propTypes.string }, stylePropTypes("menu")), stylePropTypes("arrow")), { menuStyle: propTypes.object, arrowStyle: propTypes.object, arrow: propTypes.bool, setDownOverflow: propTypes.bool, offsetX: propTypes.number, offsetY: propTypes.number, align: propTypes.oneOf(["start", "center", "end"]), direction: Direction, position: propTypes.oneOf(["auto", "anchor", "initial"]), overflow: propTypes.oneOf(["auto", "visible", "hidden"]) });
1154
1158
  // Menu and ControlledMenu
1155
1159
  var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps: propTypes.object, initialMounted: propTypes.bool, unmountOnClose: propTypes.bool, transition: propTypes.oneOfType([
1156
1160
  propTypes.bool,
@@ -1167,22 +1171,21 @@ var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps:
1167
1171
  }),
1168
1172
  ]), theming: propTypes.string, onItemClick: propTypes.func });
1169
1173
  // Menu and SubMenu
1170
- var uncontrolledMenuPropTypes = {
1174
+ ({
1171
1175
  instanceRef: propTypes.oneOfType([propTypes.object, propTypes.func]),
1172
1176
  onMenuChange: propTypes.func
1173
- };
1177
+ });
1174
1178
 
1175
1179
  var withHovering = function (name, WrappedComponent) {
1176
1180
  var Component = react.memo(WrappedComponent);
1177
1181
  var WithHovering = react.forwardRef(function (props, ref) {
1178
- var itemRef = react.useRef(null);
1179
- return (jsxRuntime.jsx(Component, __assign({}, props, { itemRef: itemRef, externalRef: ref, isHovering: react.useContext(HoverItemContext) === itemRef.current })));
1182
+ var menuItemRef = react.useRef(null);
1183
+ return (jsxRuntime.jsx(Component, __assign({}, props, { menuItemRef: menuItemRef, externalRef: ref, isHovering: react.useContext(HoverItemContext) === menuItemRef.current })));
1180
1184
  });
1181
1185
  WithHovering.displayName = "WithHovering(".concat(name, ")");
1182
1186
  return WithHovering;
1183
1187
  };
1184
1188
 
1185
- // @ts-nocheck
1186
1189
  var useItems = function (menuRef, focusRef) {
1187
1190
  var _a = react.useState(), hoverItem = _a[0], setHoverItem = _a[1];
1188
1191
  var stateRef = react.useRef({
@@ -1192,6 +1195,7 @@ var useItems = function (menuRef, focusRef) {
1192
1195
  });
1193
1196
  var mutableState = stateRef.current;
1194
1197
  var updateItems = react.useCallback(function (item, isMounted) {
1198
+ var _a;
1195
1199
  var items = mutableState.items;
1196
1200
  if (!item) {
1197
1201
  mutableState.items = [];
@@ -1204,8 +1208,8 @@ var useItems = function (menuRef, focusRef) {
1204
1208
  if (index > -1) {
1205
1209
  items.splice(index, 1);
1206
1210
  if (item.contains(document.activeElement)) {
1207
- focusRef.current.focus();
1208
- setHoverItem();
1211
+ (_a = focusRef === null || focusRef === void 0 ? void 0 : focusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1212
+ setHoverItem(undefined);
1209
1213
  }
1210
1214
  }
1211
1215
  }
@@ -1242,6 +1246,8 @@ var useItems = function (menuRef, focusRef) {
1242
1246
  newItem = items[index];
1243
1247
  break;
1244
1248
  case HoverActionTypes.SET_INDEX:
1249
+ if (typeof nextIndex !== "number")
1250
+ break;
1245
1251
  sortItems();
1246
1252
  index = nextIndex;
1247
1253
  newItem = items[index];
@@ -1278,32 +1284,33 @@ var useItems = function (menuRef, focusRef) {
1278
1284
  return { hoverItem: hoverItem, dispatch: dispatch, updateItems: updateItems };
1279
1285
  };
1280
1286
 
1281
- var useItemEffect = function (isDisabled, itemRef, updateItems) {
1287
+ var useItemEffect = function (isDisabled, menuItemRef, updateItems) {
1282
1288
  useIsomorphicLayoutEffect(function () {
1289
+ if (!menuItemRef)
1290
+ return;
1283
1291
  if (process.env.NODE_ENV !== "production" && !updateItems) {
1284
- throw new Error("[React-Menu] This menu item or submenu should be rendered under a menu: ".concat(itemRef.current.outerHTML));
1292
+ throw new Error("[React-Menu] This menu item or submenu should be rendered under a menu: ".concat(menuItemRef.current.outerHTML));
1285
1293
  }
1286
1294
  if (isDisabled)
1287
1295
  return;
1288
- var item = itemRef.current;
1296
+ var item = menuItemRef.current;
1289
1297
  updateItems(item, true);
1290
1298
  return function () {
1291
1299
  updateItems(item);
1292
1300
  };
1293
- }, [isDisabled, itemRef, updateItems]);
1301
+ }, [isDisabled, menuItemRef, updateItems]);
1294
1302
  };
1295
1303
 
1296
- // @ts-nocheck
1297
1304
  // This hook includes some common stateful logic in MenuItem and FocusableItem
1298
- var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
1305
+ var useItemState = function (menuItemRef, focusRef, isHovering, isDisabled) {
1299
1306
  var submenuCloseDelay = react.useContext(ItemSettingsContext).submenuCloseDelay;
1300
1307
  var _a = react.useContext(MenuListItemContext), isParentOpen = _a.isParentOpen, isSubmenuOpen = _a.isSubmenuOpen, dispatch = _a.dispatch, updateItems = _a.updateItems;
1301
- var timeoutId = react.useRef(0);
1308
+ var timeoutId = react.useRef();
1302
1309
  var setHover = function () {
1303
- !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, itemRef.current);
1310
+ !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
1304
1311
  };
1305
1312
  var unsetHover = function () {
1306
- !isDisabled && dispatch(HoverActionTypes.UNSET, itemRef.current);
1313
+ !isDisabled && dispatch(HoverActionTypes.UNSET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
1307
1314
  };
1308
1315
  var onBlur = function (e) {
1309
1316
  // Focus has moved out of the entire item
@@ -1315,7 +1322,7 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
1315
1322
  if (isSubmenuOpen) {
1316
1323
  if (!timeoutId.current)
1317
1324
  timeoutId.current = setTimeout(function () {
1318
- timeoutId.current = 0;
1325
+ timeoutId.current = undefined;
1319
1326
  setHover();
1320
1327
  }, submenuCloseDelay);
1321
1328
  }
@@ -1326,17 +1333,17 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
1326
1333
  var onPointerLeave = function (_, keepHover) {
1327
1334
  if (timeoutId.current) {
1328
1335
  clearTimeout(timeoutId.current);
1329
- timeoutId.current = 0;
1336
+ timeoutId.current = undefined;
1330
1337
  }
1331
1338
  !keepHover && unsetHover();
1332
1339
  };
1333
- useItemEffect(isDisabled, itemRef, updateItems);
1340
+ useItemEffect(isDisabled, menuItemRef, updateItems);
1334
1341
  react.useEffect(function () { return function () { return clearTimeout(timeoutId.current); }; }, []);
1335
1342
  react.useEffect(function () {
1336
1343
  // Don't set focus when parent menu is closed, otherwise focus will be lost
1337
1344
  // and onBlur event will be fired with relatedTarget setting as null.
1338
1345
  if (isHovering && isParentOpen) {
1339
- focusRef.current && focusRef.current.focus();
1346
+ (focusRef === null || focusRef === void 0 ? void 0 : focusRef.current) && focusRef.current.focus();
1340
1347
  }
1341
1348
  }, [focusRef, isHovering, isParentOpen]);
1342
1349
  return {
@@ -1347,16 +1354,18 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
1347
1354
  };
1348
1355
  };
1349
1356
 
1350
- // @ts-nocheck
1351
1357
  var useMenuChange = function (onMenuChange, isOpen) {
1352
1358
  var prevOpen = react.useRef(isOpen);
1353
1359
  react.useEffect(function () {
1354
- if (prevOpen.current !== isOpen)
1355
- safeCall(onMenuChange, { open: isOpen });
1360
+ if (onMenuChange && prevOpen.current !== isOpen)
1361
+ safeCall(onMenuChange, { open: !!isOpen });
1356
1362
  prevOpen.current = isOpen;
1357
1363
  }, [onMenuChange, isOpen]);
1358
1364
  };
1359
1365
 
1366
+ /**
1367
+ * A custom Hook which helps manage the states of `ControlledMenu`.
1368
+ */
1360
1369
  var useMenuState = function (props) {
1361
1370
  var _a = props !== null && props !== void 0 ? props : {
1362
1371
  transition: false
@@ -1381,18 +1390,17 @@ var useMenuStateAndFocus = function (options) {
1381
1390
  return [__assign({ menuItemFocus: menuItemFocus }, menuProps), toggleMenu, openMenu];
1382
1391
  };
1383
1392
 
1384
- var MenuButton = defineName("MenuButton", react.forwardRef(function MenuButton(_a, ref) {
1393
+ react.forwardRef(function MenuButton(_a, ref) {
1385
1394
  var className = _a.className, isOpen = _a.isOpen, disabled = _a.disabled, children = _a.children, restProps = __rest(_a, ["className", "isOpen", "disabled", "children"]);
1386
1395
  var modifiers = react.useMemo(function () { return ({ open: isOpen }); }, [isOpen]);
1387
1396
  return (jsxRuntime.jsx("button", __assign({ "aria-haspopup": true, "aria-expanded": isOpen, "aria-disabled": disabled || undefined, type: "button", disabled: disabled }, restProps, { ref: ref, className: useBEM({ block: menuButtonClass, modifiers: modifiers, className: className }) }, { children: children })));
1388
- }));
1389
- MenuButton.propTypes = __assign(__assign({}, stylePropTypes()), { isOpen: propTypes.bool, disabled: propTypes.bool });
1397
+ });
1390
1398
 
1391
- // @ts-nocheck
1392
1399
  var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBoxPadding) {
1400
+ var _a;
1393
1401
  var menuRect = menuRef.current.getBoundingClientRect();
1394
1402
  var containerRect = containerRef.current.getBoundingClientRect();
1395
- var thisWindow = containerRef.current.ownerDocument.defaultView;
1403
+ var thisWindow = (_a = containerRef.current.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
1396
1404
  var boundingRect = menuScroll === window || menuScroll === thisWindow
1397
1405
  ? {
1398
1406
  left: 0,
@@ -1407,7 +1415,9 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
1407
1415
  var getLeftOverflow = function (x) { return x + containerRect.left - boundingRect.left - padding.left; };
1408
1416
  var getRightOverflow = function (x) { return x + containerRect.left + menuRect.width - boundingRect.right + padding.right; };
1409
1417
  var getTopOverflow = function (y) { return y + containerRect.top - boundingRect.top - padding.top; };
1410
- var getBottomOverflow = function (y) { return y + containerRect.top + menuRect.height - boundingRect.bottom + padding.bottom; };
1418
+ var getBottomOverflow = function (y) {
1419
+ return y + containerRect.top + menuRect.height - boundingRect.bottom + padding.bottom;
1420
+ };
1411
1421
  var confineHorizontally = function (x) {
1412
1422
  // If menu overflows to the left side, adjust x to have the menu contained within the viewport
1413
1423
  // and there is no need to check the right side;
@@ -1421,7 +1431,7 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
1421
1431
  if (rightOverflow > 0) {
1422
1432
  x -= rightOverflow;
1423
1433
  // Check again to make sure menu doesn't overflow to the left
1424
- // because it may go off screen and cannot be scroll into view.
1434
+ // because it may go off-screen and cannot be scrolled into view.
1425
1435
  leftOverflow = getLeftOverflow(x);
1426
1436
  if (leftOverflow < 0)
1427
1437
  x -= leftOverflow;
@@ -1460,7 +1470,6 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
1460
1470
  };
1461
1471
  };
1462
1472
 
1463
- // @ts-nocheck
1464
1473
  var positionContextMenu = function (_a) {
1465
1474
  var positionHelpers = _a.positionHelpers, anchorPoint = _a.anchorPoint;
1466
1475
  var menuRect = positionHelpers.menuRect, containerRect = positionHelpers.containerRect, getLeftOverflow = positionHelpers.getLeftOverflow, getRightOverflow = positionHelpers.getRightOverflow, getTopOverflow = positionHelpers.getTopOverflow, getBottomOverflow = positionHelpers.getBottomOverflow, confineHorizontally = positionHelpers.confineHorizontally, confineVertically = positionHelpers.confineVertically;
@@ -1497,19 +1506,16 @@ var positionContextMenu = function (_a) {
1497
1506
  return { x: x, y: y, computedDirection: computedDirection };
1498
1507
  };
1499
1508
 
1500
- // @ts-nocheck
1501
- var placeArrowVertical = function (_a) {
1502
- var arrowRef = _a.arrowRef, menuY = _a.menuY, anchorRect = _a.anchorRect, containerRect = _a.containerRect, menuRect = _a.menuRect;
1503
- var y = anchorRect.top - containerRect.top - menuY + anchorRect.height / 2;
1504
- var offset = arrowRef.current.offsetHeight * 1.25;
1509
+ var placeArrowVertical = function (p) {
1510
+ var y = p.anchorRect.top - p.containerRect.top - p.menuY + p.anchorRect.height / 2;
1511
+ var offset = p.arrowRef.current ? p.arrowRef.current.offsetHeight * 1.25 : 0;
1505
1512
  y = Math.max(offset, y);
1506
- y = Math.min(y, menuRect.height - offset);
1513
+ y = Math.min(y, p.menuRect.height - offset);
1507
1514
  return y;
1508
1515
  };
1509
1516
 
1510
- // @ts-nocheck
1511
- var placeLeftorRight = function (_a) {
1512
- var anchorRect = _a.anchorRect, containerRect = _a.containerRect, menuRect = _a.menuRect, placeLeftorRightY = _a.placeLeftorRightY, placeLeftX = _a.placeLeftX, placeRightX = _a.placeRightX, getLeftOverflow = _a.getLeftOverflow, getRightOverflow = _a.getRightOverflow, confineHorizontally = _a.confineHorizontally, confineVertically = _a.confineVertically, arrowRef = _a.arrowRef, arrow = _a.arrow, direction = _a.direction, position = _a.position;
1517
+ var placeLeftorRight = function (props) {
1518
+ var anchorRect = props.anchorRect, containerRect = props.containerRect, menuRect = props.menuRect, placeLeftorRightY = props.placeLeftorRightY, placeLeftX = props.placeLeftX, placeRightX = props.placeRightX, getLeftOverflow = props.getLeftOverflow, getRightOverflow = props.getRightOverflow, confineHorizontally = props.confineHorizontally, confineVertically = props.confineVertically, arrowRef = props.arrowRef, arrow = props.arrow, direction = props.direction, position = props.position;
1513
1519
  var computedDirection = direction;
1514
1520
  var y = placeLeftorRightY;
1515
1521
  if (position !== "initial") {
@@ -1566,19 +1572,16 @@ var placeLeftorRight = function (_a) {
1566
1572
  return { arrowY: arrowY, x: x, y: y, computedDirection: computedDirection };
1567
1573
  };
1568
1574
 
1569
- // @ts-nocheck
1570
- var placeArrowHorizontal = function (_a) {
1571
- var arrowRef = _a.arrowRef, menuX = _a.menuX, anchorRect = _a.anchorRect, containerRect = _a.containerRect, menuRect = _a.menuRect;
1572
- var x = anchorRect.left - containerRect.left - menuX + anchorRect.width / 2;
1573
- var offset = arrowRef.current.offsetWidth * 1.25;
1575
+ var placeArrowHorizontal = function (p) {
1576
+ var x = p.anchorRect.left - p.containerRect.left - p.menuX + p.anchorRect.width / 2;
1577
+ var offset = p.arrowRef.current ? p.arrowRef.current.offsetWidth * 1.25 : 0;
1574
1578
  x = Math.max(offset, x);
1575
- x = Math.min(x, menuRect.width - offset);
1579
+ x = Math.min(x, p.menuRect.width - offset);
1576
1580
  return x;
1577
1581
  };
1578
1582
 
1579
- // @ts-nocheck
1580
- var placeToporBottom = function (_a) {
1581
- var anchorRect = _a.anchorRect, containerRect = _a.containerRect, menuRect = _a.menuRect, placeToporBottomX = _a.placeToporBottomX, placeTopY = _a.placeTopY, placeBottomY = _a.placeBottomY, getTopOverflow = _a.getTopOverflow, getBottomOverflow = _a.getBottomOverflow, confineHorizontally = _a.confineHorizontally, confineVertically = _a.confineVertically, arrowRef = _a.arrowRef, arrow = _a.arrow, direction = _a.direction, position = _a.position;
1583
+ var placeToporBottom = function (props) {
1584
+ var anchorRect = props.anchorRect, containerRect = props.containerRect, menuRect = props.menuRect, placeToporBottomX = props.placeToporBottomX, placeTopY = props.placeTopY, placeBottomY = props.placeBottomY, getTopOverflow = props.getTopOverflow, getBottomOverflow = props.getBottomOverflow, confineHorizontally = props.confineHorizontally, confineVertically = props.confineVertically, arrowRef = props.arrowRef, arrow = props.arrow, direction = props.direction, position = props.position;
1582
1585
  // make sure invalid direction is treated as 'bottom'
1583
1586
  var computedDirection = direction === "top" ? "top" : "bottom";
1584
1587
  var x = placeToporBottomX;
@@ -1636,12 +1639,12 @@ var placeToporBottom = function (_a) {
1636
1639
  return { arrowX: arrowX, x: x, y: y, computedDirection: computedDirection };
1637
1640
  };
1638
1641
 
1639
- var positionMenu = function (_a) {
1640
- var arrow = _a.arrow, align = _a.align, direction = _a.direction, offsetX = _a.offsetX, offsetY = _a.offsetY, position = _a.position, anchorRef = _a.anchorRef, arrowRef = _a.arrowRef, positionHelpers = _a.positionHelpers;
1642
+ var positionMenu = function (props) {
1643
+ var arrow = props.arrow, align = props.align, direction = props.direction, offsetX = props.offsetX, offsetY = props.offsetY, position = props.position, anchorRef = props.anchorRef, arrowRef = props.arrowRef, positionHelpers = props.positionHelpers;
1641
1644
  var menuRect = positionHelpers.menuRect, containerRect = positionHelpers.containerRect;
1642
1645
  var horizontalOffset = offsetX;
1643
1646
  var verticalOffset = offsetY;
1644
- if (arrow) {
1647
+ if (arrow && arrowRef.current) {
1645
1648
  if (direction === "left" || direction === "right") {
1646
1649
  horizontalOffset += arrowRef.current.offsetWidth;
1647
1650
  }
@@ -1649,7 +1652,9 @@ var positionMenu = function (_a) {
1649
1652
  verticalOffset += arrowRef.current.offsetHeight;
1650
1653
  }
1651
1654
  }
1652
- var anchorRect = anchorRef.current.getBoundingClientRect();
1655
+ var anchorRect = anchorRef.current
1656
+ ? anchorRef.current.getBoundingClientRect()
1657
+ : { left: 0, right: 0, top: 200, bottom: 200, width: 200, height: 200 };
1653
1658
  var placeLeftX = anchorRect.left - containerRect.left - menuRect.width - horizontalOffset;
1654
1659
  var placeRightX = anchorRect.right - containerRect.left + horizontalOffset;
1655
1660
  var placeTopY = anchorRect.top - containerRect.top - menuRect.height - verticalOffset;
@@ -1684,16 +1689,16 @@ var positionMenu = function (_a) {
1684
1689
  var MenuList = function (_a) {
1685
1690
  var ariaLabel = _a.ariaLabel, menuClassName = _a.menuClassName, menuStyle = _a.menuStyle, arrowClassName = _a.arrowClassName, arrowStyle = _a.arrowStyle, anchorPoint = _a.anchorPoint, anchorRef = _a.anchorRef, containerRef = _a.containerRef, externalRef = _a.externalRef, parentScrollingRef = _a.parentScrollingRef, arrow = _a.arrow, _b = _a.align, align = _b === void 0 ? "start" : _b, _c = _a.direction, direction = _c === void 0 ? "bottom" : _c, _d = _a.position, position = _d === void 0 ? "auto" : _d, _e = _a.overflow, overflow = _e === void 0 ? "visible" : _e, setDownOverflow = _a.setDownOverflow, repositionFlag = _a.repositionFlag, _f = _a.captureFocus, captureFocus = _f === void 0 ? true : _f, state = _a.state, endTransition = _a.endTransition, isDisabled = _a.isDisabled, menuItemFocus = _a.menuItemFocus, _g = _a.offsetX, offsetX = _g === void 0 ? 0 : _g, _h = _a.offsetY, offsetY = _h === void 0 ? 0 : _h, children = _a.children, onClose = _a.onClose, restProps = __rest(_a, ["ariaLabel", "menuClassName", "menuStyle", "arrowClassName", "arrowStyle", "anchorPoint", "anchorRef", "containerRef", "externalRef", "parentScrollingRef", "arrow", "align", "direction", "position", "overflow", "setDownOverflow", "repositionFlag", "captureFocus", "state", "endTransition", "isDisabled", "menuItemFocus", "offsetX", "offsetY", "children", "onClose"]);
1686
1691
  var _j = react.useState({ x: 0, y: 0 }), menuPosition = _j[0], setMenuPosition = _j[1];
1687
- var _k = react.useState({}), arrowPosition = _k[0], setArrowPosition = _k[1];
1692
+ var _k = react.useState({ x: 0, y: 0 }), arrowPosition = _k[0], setArrowPosition = _k[1];
1688
1693
  var _l = react.useState(), overflowData = _l[0], setOverflowData = _l[1];
1689
1694
  var _m = react.useState(direction), expandedDirection = _m[0], setExpandedDirection = _m[1];
1690
1695
  var _o = react.useState(0), openSubmenuCount = _o[0], setOpenSubmenuCount = _o[1];
1691
1696
  var _p = react.useReducer(function (c) { return c + 1; }, 1), reposSubmenu = _p[0], forceReposSubmenu = _p[1];
1692
1697
  var _q = react.useContext(SettingsContext), transition = _q.transition, boundingBoxRef = _q.boundingBoxRef, boundingBoxPadding = _q.boundingBoxPadding, rootMenuRef = _q.rootMenuRef, rootAnchorRef = _q.rootAnchorRef, scrollNodesRef = _q.scrollNodesRef, reposition = _q.reposition, viewScroll = _q.viewScroll;
1693
1698
  var reposFlag = react.useContext(MenuListContext).reposSubmenu || repositionFlag;
1694
- var menuRef = react.useRef(null);
1695
- var focusRef = react.useRef();
1696
- var arrowRef = react.useRef();
1699
+ var menuRef = react.useRef({});
1700
+ var focusRef = react.useRef(null);
1701
+ var arrowRef = react.useRef(null);
1697
1702
  var prevOpen = react.useRef(false);
1698
1703
  var latestMenuSize = react.useRef({ width: 0, height: 0 });
1699
1704
  var latestHandlePosition = react.useRef(function () { });
@@ -1703,30 +1708,33 @@ var MenuList = function (_a) {
1703
1708
  var closeTransition = getTransition(transition, "close");
1704
1709
  var scrollNodes = scrollNodesRef.current;
1705
1710
  var onKeyDown = function (e) {
1706
- var isTextInputTarget = e.target.nodeName === "TEXTAREA" || (e.target.nodeName === "INPUT" && e.target.getAttribute("type") === "text");
1711
+ var elementTarget = e.target instanceof HTMLElement ? e.target : null;
1712
+ var isTextInputTarget = elementTarget &&
1713
+ (elementTarget.nodeName === "TEXTAREA" ||
1714
+ (elementTarget.nodeName === "INPUT" && elementTarget.getAttribute("type") === "text"));
1707
1715
  switch (e.key) {
1708
1716
  case Keys.HOME:
1709
1717
  // Don't eat home/end events on inputs
1710
1718
  if (isTextInputTarget)
1711
1719
  return;
1712
- dispatch(HoverActionTypes.FIRST);
1720
+ dispatch(HoverActionTypes.FIRST, null, 0);
1713
1721
  break;
1714
1722
  case Keys.END:
1715
1723
  // Don't eat home/end events on inputs
1716
1724
  if (isTextInputTarget)
1717
1725
  return;
1718
- dispatch(HoverActionTypes.LAST);
1726
+ dispatch(HoverActionTypes.LAST, null, 0);
1719
1727
  break;
1720
1728
  case Keys.UP:
1721
- dispatch(HoverActionTypes.DECREASE, hoverItem);
1729
+ dispatch(HoverActionTypes.DECREASE, hoverItem, 0);
1722
1730
  break;
1723
1731
  case Keys.DOWN:
1724
- dispatch(HoverActionTypes.INCREASE, hoverItem);
1732
+ dispatch(HoverActionTypes.INCREASE, hoverItem, 0);
1725
1733
  break;
1726
1734
  // prevent browser from scrolling the page when SPACE is pressed
1727
1735
  case Keys.SPACE:
1728
1736
  // Don't preventDefault on children of FocusableItem
1729
- if (e.target && e.target.className.indexOf(menuClass) !== -1) {
1737
+ if (elementTarget && elementTarget.className.includes(menuClass)) {
1730
1738
  e.preventDefault();
1731
1739
  }
1732
1740
  return;
@@ -1738,9 +1746,9 @@ var MenuList = function (_a) {
1738
1746
  };
1739
1747
  var onAnimationEnd = function () {
1740
1748
  if (state === "closing") {
1741
- setOverflowData(); // reset overflowData after closing
1749
+ setOverflowData(undefined); // reset overflowData after closing
1742
1750
  }
1743
- safeCall(endTransition);
1751
+ endTransition && safeCall(endTransition);
1744
1752
  };
1745
1753
  var handlePosition = react.useCallback(function (noOverflowCheck) {
1746
1754
  if (!containerRef.current) {
@@ -1753,11 +1761,15 @@ var MenuList = function (_a) {
1753
1761
  scrollNodes.menu =
1754
1762
  (boundingBoxRef
1755
1763
  ? boundingBoxRef.current // user explicitly sets boundingBoxRef
1756
- : getScrollAncestor(rootMenuRef.current)) || window; // try to discover bounding box automatically
1764
+ : getScrollAncestor(rootMenuRef === null || rootMenuRef === void 0 ? void 0 : rootMenuRef.current)) || window; // try to discover bounding box automatically
1757
1765
  }
1758
1766
  var positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
1759
1767
  var menuRect = positionHelpers.menuRect;
1760
- var results = { computedDirection: "bottom" };
1768
+ var results = {
1769
+ computedDirection: "bottom",
1770
+ x: 0,
1771
+ y: 0
1772
+ };
1761
1773
  if (anchorPoint) {
1762
1774
  results = positionContextMenu({ positionHelpers: positionHelpers, anchorPoint: anchorPoint });
1763
1775
  }
@@ -1774,7 +1786,8 @@ var MenuList = function (_a) {
1774
1786
  positionHelpers: positionHelpers
1775
1787
  });
1776
1788
  }
1777
- var arrowX = results.arrowX, arrowY = results.arrowY, x = results.x, y = results.y, computedDirection = results.computedDirection;
1789
+ var y = results.y;
1790
+ var x = results.x, arrowX = results.arrowX, arrowY = results.arrowY, computedDirection = results.computedDirection;
1778
1791
  var menuHeight = menuRect.height;
1779
1792
  if (!noOverflowCheck && overflow !== "visible") {
1780
1793
  var getTopOverflow = positionHelpers.getTopOverflow, getBottomOverflow = positionHelpers.getBottomOverflow;
@@ -1798,17 +1811,17 @@ var MenuList = function (_a) {
1798
1811
  y -= topOverflow;
1799
1812
  }
1800
1813
  }
1801
- if (height >= 0) {
1814
+ if (height != null && height >= 0) {
1802
1815
  // To avoid triggering reposition in the next ResizeObserver callback
1803
1816
  menuHeight = height;
1804
1817
  setOverflowData({ height: height, overflowAmt: overflowAmt_1 });
1805
1818
  }
1806
1819
  else {
1807
- setOverflowData();
1820
+ setOverflowData(undefined);
1808
1821
  }
1809
1822
  }
1810
1823
  if (arrow)
1811
- setArrowPosition({ x: arrowX, y: arrowY });
1824
+ setArrowPosition({ x: arrowX !== null && arrowX !== void 0 ? arrowX : 0, y: arrowY !== null && arrowY !== void 0 ? arrowY : 0 });
1812
1825
  setMenuPosition({ x: x, y: y });
1813
1826
  setExpandedDirection(computedDirection);
1814
1827
  latestMenuSize.current = { width: menuRect.width, height: menuHeight };
@@ -1873,7 +1886,7 @@ var MenuList = function (_a) {
1873
1886
  scrollObservers.forEach(function (o) { return o.addEventListener("scroll", handleScroll); });
1874
1887
  return function () { return scrollObservers.forEach(function (o) { return o.removeEventListener("scroll", handleScroll); }); };
1875
1888
  }, [rootAnchorRef, scrollNodes, isOpen, onClose, viewScroll, handlePosition]);
1876
- var hasOverflow = !!overflowData && overflowData.overflowAmt > 0;
1889
+ var hasOverflow = !!overflowData && overflowData.overflowAmt != null && overflowData.overflowAmt > 0;
1877
1890
  react.useEffect(function () {
1878
1891
  if (hasOverflow || !isOpen || !parentScrollingRef)
1879
1892
  return;
@@ -1914,20 +1927,20 @@ var MenuList = function (_a) {
1914
1927
  }, [reposition]);
1915
1928
  react.useEffect(function () {
1916
1929
  if (!isOpen) {
1917
- dispatch(HoverActionTypes.RESET);
1930
+ dispatch(HoverActionTypes.RESET, undefined, 0);
1918
1931
  if (!closeTransition)
1919
- setOverflowData();
1920
- return;
1932
+ setOverflowData(undefined);
1933
+ return function () { };
1921
1934
  }
1922
1935
  var _a = menuItemFocus || {}, position = _a.position, alwaysUpdate = _a.alwaysUpdate;
1923
1936
  var setItemFocus = function () {
1924
1937
  if (position === FocusPositions.FIRST) {
1925
- dispatch(HoverActionTypes.FIRST);
1938
+ dispatch(HoverActionTypes.FIRST, undefined, 0);
1926
1939
  }
1927
1940
  else if (position === FocusPositions.LAST) {
1928
- dispatch(HoverActionTypes.LAST);
1941
+ dispatch(HoverActionTypes.LAST, undefined, 0);
1929
1942
  }
1930
- else if (position >= -1) {
1943
+ else if (typeof position === "number" && position >= -1) {
1931
1944
  dispatch(HoverActionTypes.SET_INDEX, undefined, position);
1932
1945
  }
1933
1946
  };
@@ -1937,14 +1950,16 @@ var MenuList = function (_a) {
1937
1950
  else if (captureFocus) {
1938
1951
  // Use a timeout here because if set focus immediately, page might scroll unexpectedly.
1939
1952
  var id_1 = setTimeout(function () {
1953
+ var _a;
1940
1954
  // If focus has already been set to a children element, don't set focus on menu or item
1941
1955
  if (!menuRef.current.contains(document.activeElement)) {
1942
- focusRef.current.focus();
1956
+ (_a = focusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1943
1957
  setItemFocus();
1944
1958
  }
1945
1959
  }, openTransition ? 170 : 100);
1946
1960
  return function () { return clearTimeout(id_1); };
1947
1961
  }
1962
+ return function () { };
1948
1963
  }, [isOpen, openTransition, closeTransition, captureFocus, menuItemFocus, dispatch]);
1949
1964
  var isSubmenuOpen = openSubmenuCount > 0;
1950
1965
  var itemContext = react.useMemo(function () { return ({
@@ -1954,7 +1969,8 @@ var MenuList = function (_a) {
1954
1969
  dispatch: dispatch,
1955
1970
  updateItems: updateItems
1956
1971
  }); }, [isOpen, isSubmenuOpen, dispatch, updateItems]);
1957
- var maxHeight, overflowAmt;
1972
+ var maxHeight;
1973
+ var overflowAmt;
1958
1974
  if (overflowData) {
1959
1975
  setDownOverflow ? (overflowAmt = overflowData.overflowAmt) : (maxHeight = overflowData.height);
1960
1976
  }
@@ -1965,7 +1981,7 @@ var MenuList = function (_a) {
1965
1981
  parentMenuRef: menuRef,
1966
1982
  parentDir: expandedDirection
1967
1983
  }); }, [reposSubmenu, overflow, overflowAmt, expandedDirection]);
1968
- var overflowStyle = maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined;
1984
+ var overflowStyle = maxHeight != null && maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined;
1969
1985
  var modifiers = react.useMemo(function () { return ({
1970
1986
  state: state,
1971
1987
  dir: expandedDirection
@@ -2134,8 +2150,8 @@ ControlledMenu.propTypes /* remove-proptypes */ = __assign(__assign({}, rootMenu
2134
2150
  alwaysUpdate: propTypes.bool
2135
2151
  }), onClose: propTypes.func });
2136
2152
 
2137
- var Menu = react.forwardRef(function Menu(_a, externalRef) {
2138
- var ariaLabel = _a["aria-label"]; _a.captureFocus; var menuButton = _a.menuButton, instanceRef = _a.instanceRef, onMenuChange = _a.onMenuChange, restProps = __rest(_a, ["aria-label", "captureFocus", "menuButton", "instanceRef", "onMenuChange"]);
2153
+ function MenuFr(_a, externalRef) {
2154
+ var ariaLabel = _a["aria-label"], menuButton = _a.menuButton, instanceRef = _a.instanceRef, onMenuChange = _a.onMenuChange, restProps = __rest(_a, ["aria-label", "menuButton", "instanceRef", "onMenuChange"]);
2139
2155
  var _b = useMenuStateAndFocus(restProps), stateProps = _b[0], toggleMenu = _b[1], openMenu = _b[2];
2140
2156
  var isOpen = isMenuOpen(stateProps.state);
2141
2157
  var skipOpen = react.useRef(false);
@@ -2143,7 +2159,7 @@ var Menu = react.forwardRef(function Menu(_a, externalRef) {
2143
2159
  var handleClose = react.useCallback(function (e) {
2144
2160
  toggleMenu(false);
2145
2161
  if (e.key)
2146
- buttonRef.current.focus();
2162
+ buttonRef.current && buttonRef.current.focus();
2147
2163
  }, [toggleMenu]);
2148
2164
  var onClick = function (e) {
2149
2165
  if (skipOpen.current)
@@ -2164,10 +2180,11 @@ var Menu = react.forwardRef(function Menu(_a, externalRef) {
2164
2180
  }
2165
2181
  e.preventDefault();
2166
2182
  };
2183
+ // FIXME erk! button seems to be many types
2167
2184
  var button = safeCall(menuButton, { open: isOpen });
2168
2185
  if (!button || !button.type)
2169
2186
  throw new Error("Menu requires a menuButton prop.");
2170
- var buttonProps = __assign({ ref: useCombinedRef(button.ref, buttonRef) }, mergeProps({ onClick: onClick, onKeyDown: onKeyDown }, button.props));
2187
+ var buttonProps = __assign(__assign({ ref: useCombinedRef(button.ref, buttonRef) }, mergeProps({ onClick: onClick, onKeyDown: onKeyDown }, button.props)), { isOpen: false });
2171
2188
  if (getName(button.type) === "MenuButton") {
2172
2189
  buttonProps.isOpen = isOpen;
2173
2190
  }
@@ -2178,27 +2195,28 @@ var Menu = react.forwardRef(function Menu(_a, externalRef) {
2178
2195
  closeMenu: function () { return toggleMenu(false); }
2179
2196
  }); });
2180
2197
  return (jsxRuntime.jsxs(react.Fragment, { children: [renderButton, jsxRuntime.jsx(ControlledMenu, __assign({}, restProps, stateProps, { "aria-label": ariaLabel || (typeof button.props.children === "string" ? button.props.children : "Menu"), anchorRef: buttonRef, ref: externalRef, onClose: handleClose, skipOpen: skipOpen }))] }));
2181
- });
2182
- Menu.propTypes = __assign(__assign(__assign({}, rootMenuPropTypes), uncontrolledMenuPropTypes), { menuButton: propTypes.oneOfType([propTypes.element, propTypes.func]).isRequired });
2198
+ }
2199
+ react.forwardRef(MenuFr);
2183
2200
 
2184
- var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2185
- var ariaLabel = _a["aria-label"], className = _a.className, disabled = _a.disabled, direction = _a.direction, label = _a.label, openTrigger = _a.openTrigger, onMenuChange = _a.onMenuChange, isHovering = _a.isHovering, instanceRef = _a.instanceRef, itemRef = _a.itemRef; _a.captureFocus; _a.repositionFlag; var _b = _a.itemProps, itemProps = _b === void 0 ? {} : _b, restProps = __rest(_a, ["aria-label", "className", "disabled", "direction", "label", "openTrigger", "onMenuChange", "isHovering", "instanceRef", "itemRef", "captureFocus", "repositionFlag", "itemProps"]);
2201
+ var SubMenuFr = function (_a) {
2202
+ var ariaLabel = _a["aria-label"], className = _a.className, disabled = _a.disabled, direction = _a.direction, label = _a.label, openTrigger = _a.openTrigger, onMenuChange = _a.onMenuChange, isHovering = _a.isHovering, instanceRef = _a.instanceRef, menuItemRef = _a.menuItemRef, _b = _a.itemProps, itemProps = _b === void 0 ? {} : _b, restProps = __rest(_a, ["aria-label", "className", "disabled", "direction", "label", "openTrigger", "onMenuChange", "isHovering", "instanceRef", "menuItemRef", "itemProps"]);
2186
2203
  var settings = react.useContext(SettingsContext);
2187
2204
  var rootMenuRef = settings.rootMenuRef;
2188
2205
  var _c = react.useContext(ItemSettingsContext), submenuOpenDelay = _c.submenuOpenDelay, submenuCloseDelay = _c.submenuCloseDelay;
2189
2206
  var _d = react.useContext(MenuListContext), parentMenuRef = _d.parentMenuRef, parentDir = _d.parentDir, parentOverflow = _d.overflow;
2190
2207
  var _e = react.useContext(MenuListItemContext), isParentOpen = _e.isParentOpen, isSubmenuOpen = _e.isSubmenuOpen, setOpenSubmenuCount = _e.setOpenSubmenuCount, dispatch = _e.dispatch, updateItems = _e.updateItems;
2191
2208
  var isPortal = parentOverflow !== "visible";
2209
+ // FIXME Matt no idea what's going on here
2192
2210
  var _f = useMenuStateAndFocus(settings), stateProps = _f[0], toggleMenu = _f[1], _openMenu = _f[2];
2193
2211
  var state = stateProps.state;
2194
2212
  var isDisabled = !!disabled;
2195
2213
  var isOpen = isMenuOpen(state);
2196
2214
  var containerRef = react.useRef(null);
2197
- var timeoutId = react.useRef(0);
2215
+ var timeoutId = react.useRef();
2198
2216
  var stopTimer = function () {
2199
2217
  if (timeoutId.current) {
2200
2218
  clearTimeout(timeoutId.current);
2201
- timeoutId.current = 0;
2219
+ timeoutId.current = undefined;
2202
2220
  }
2203
2221
  };
2204
2222
  var openMenu = function () {
@@ -2210,7 +2228,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2210
2228
  setHover();
2211
2229
  !isDisabled && _openMenu.apply(void 0, args);
2212
2230
  };
2213
- var setHover = function () { return !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, itemRef.current); };
2231
+ var setHover = function () { return !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0); };
2214
2232
  var delayOpen = function (delay) {
2215
2233
  setHover();
2216
2234
  if (!openTrigger)
@@ -2229,7 +2247,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2229
2247
  var handlePointerLeave = function () {
2230
2248
  stopTimer();
2231
2249
  if (!isOpen)
2232
- dispatch(HoverActionTypes.UNSET, itemRef.current);
2250
+ dispatch(HoverActionTypes.UNSET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
2233
2251
  };
2234
2252
  var handleKeyDown = function (e) {
2235
2253
  var handled = false;
@@ -2237,7 +2255,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2237
2255
  // LEFT key is bubbled up from submenu items
2238
2256
  case Keys.LEFT:
2239
2257
  if (isOpen) {
2240
- itemRef.current.focus();
2258
+ (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
2241
2259
  toggleMenu(false);
2242
2260
  handled = true;
2243
2261
  }
@@ -2264,19 +2282,19 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2264
2282
  break;
2265
2283
  }
2266
2284
  };
2267
- useItemEffect(isDisabled, itemRef, updateItems);
2285
+ useItemEffect(isDisabled, menuItemRef, updateItems);
2268
2286
  useMenuChange(onMenuChange, isOpen);
2269
2287
  react.useEffect(function () { return function () { return clearTimeout(timeoutId.current); }; }, []);
2270
2288
  react.useEffect(function () {
2271
2289
  // Don't set focus when parent menu is closed, otherwise focus will be lost
2272
2290
  // and onBlur event will be fired with relatedTarget setting as null.
2273
2291
  if (isHovering && isParentOpen) {
2274
- itemRef.current.focus();
2292
+ (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
2275
2293
  }
2276
2294
  else {
2277
2295
  toggleMenu(false);
2278
2296
  }
2279
- }, [isHovering, isParentOpen, toggleMenu, itemRef]);
2297
+ }, [isHovering, isParentOpen, toggleMenu, menuItemRef]);
2280
2298
  react.useEffect(function () {
2281
2299
  setOpenSubmenuCount(function (count) { return (isOpen ? count + 1 : Math.max(count - 1, 0)); });
2282
2300
  }, [setOpenSubmenuCount, isOpen]);
@@ -2290,7 +2308,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2290
2308
  },
2291
2309
  closeMenu: function () {
2292
2310
  if (isOpen) {
2293
- itemRef.current.focus();
2311
+ (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
2294
2312
  toggleMenu(false);
2295
2313
  }
2296
2314
  }
@@ -2309,36 +2327,40 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
2309
2327
  onClick: function () { return openTrigger !== "none" && openMenu(); }
2310
2328
  }, restItemProps);
2311
2329
  var getMenuList = function () {
2312
- var menuList = (jsxRuntime.jsx(MenuList, __assign({}, restProps, stateProps, { ariaLabel: ariaLabel || (typeof label === "string" ? label : "Submenu"), anchorRef: itemRef, containerRef: isPortal ? rootMenuRef : containerRef, direction: direction || (parentDir === "right" || parentDir === "left" ? parentDir : "right"), parentScrollingRef: isPortal && parentMenuRef, isDisabled: isDisabled })));
2313
- var container = rootMenuRef.current;
2330
+ var menuList = (jsxRuntime.jsx(MenuList, __assign({}, restProps, stateProps, { ariaLabel: ariaLabel || (typeof label === "string" ? label : "Submenu"), anchorRef: menuItemRef, containerRef: isPortal ? rootMenuRef : containerRef, direction: direction || (parentDir === "right" || parentDir === "left" ? parentDir : "right"), parentScrollingRef: isPortal && parentMenuRef, isDisabled: isDisabled })));
2331
+ var container = rootMenuRef === null || rootMenuRef === void 0 ? void 0 : rootMenuRef.current;
2314
2332
  return isPortal && container ? reactDom.createPortal(menuList, container) : menuList;
2315
2333
  };
2316
- return (jsxRuntime.jsxs("li", __assign({ className: useBEM({ block: menuClass, element: subMenuClass, className: className }), style: { position: "relative" }, role: "presentation", ref: containerRef, onKeyDown: handleKeyDown }, { children: [jsxRuntime.jsx("div", __assign({ role: "menuitem", "aria-haspopup": true, "aria-expanded": isOpen }, mergedItemProps, commonProps(isDisabled, isHovering), { ref: useCombinedRef(externalItemRef, itemRef), className: useBEM({
2334
+ return (jsxRuntime.jsxs("li", __assign({ className: useBEM({ block: menuClass, element: subMenuClass, className: className }), style: { position: "relative" }, role: "presentation", ref: containerRef, onKeyDown: handleKeyDown }, { children: [jsxRuntime.jsx("div", __assign({ role: "menuitem", "aria-haspopup": true, "aria-expanded": isOpen }, mergedItemProps, commonProps(isDisabled, isHovering), { ref: useCombinedRef(externalItemRef, menuItemRef), className: useBEM({
2317
2335
  block: menuClass,
2318
2336
  element: menuItemClass,
2319
2337
  modifiers: modifiers,
2320
2338
  className: itemClassName
2321
2339
  }) }, { children: react.useMemo(function () { return safeCall(label, modifiers); }, [label, modifiers]) })), state && getMenuList()] })));
2322
- });
2323
- SubMenu.propTypes = __assign(__assign(__assign({}, menuPropTypes), uncontrolledMenuPropTypes), { disabled: propTypes.bool, openTrigger: propTypes.oneOf(["none", "clickOnly"]), label: propTypes.oneOfType([propTypes.node, propTypes.func]), itemProps: propTypes.shape(__assign({}, stylePropTypes())) });
2340
+ };
2341
+ withHovering("SubMenu", SubMenuFr);
2324
2342
 
2325
- var MenuItem = withHovering("MenuItem", function MenuItem(_a) {
2326
- var className = _a.className, value = _a.value, href = _a.href, type = _a.type, checked = _a.checked, disabled = _a.disabled, children = _a.children, onClick = _a.onClick, isHovering = _a.isHovering, itemRef = _a.itemRef, externalRef = _a.externalRef, restProps = __rest(_a, ["className", "value", "href", "type", "checked", "disabled", "children", "onClick", "isHovering", "itemRef", "externalRef"]);
2343
+ var MenuItemFr = function (_a) {
2344
+ var className = _a.className, value = _a.value, href = _a.href, type = _a.type, checked = _a.checked, disabled = _a.disabled, children = _a.children, onClick = _a.onClick, isHovering = _a.isHovering, menuItemRef = _a.menuItemRef, externalRef = _a.externalRef, restProps = __rest(_a, ["className", "value", "href", "type", "checked", "disabled", "children", "onClick", "isHovering", "menuItemRef", "externalRef"]);
2327
2345
  var isDisabled = !!disabled;
2328
- var _b = useItemState(itemRef, itemRef, isHovering, isDisabled), setHover = _b.setHover, restStateProps = __rest(_b, ["setHover"]);
2346
+ var _b = useItemState(menuItemRef, menuItemRef, isHovering, isDisabled), setHover = _b.setHover, restStateProps = __rest(_b, ["setHover"]);
2329
2347
  var eventHandlers = react.useContext(EventHandlersContext);
2330
2348
  var radioGroup = react.useContext(RadioGroupContext);
2331
2349
  var isRadio = type === "radio";
2332
2350
  var isCheckBox = type === "checkbox";
2333
2351
  var isAnchor = !!href && !isDisabled && !isRadio && !isCheckBox;
2334
2352
  var isChecked = isRadio ? radioGroup.value === value : isCheckBox ? !!checked : false;
2353
+ // FIXME handle click seems to be a combination of multiple event types
2335
2354
  var handleClick = function (e) {
2336
2355
  if (isDisabled) {
2337
2356
  e.stopPropagation();
2338
2357
  e.preventDefault();
2339
2358
  return;
2340
2359
  }
2341
- var event = { value: value, syntheticEvent: e };
2360
+ var event = {
2361
+ value: value,
2362
+ syntheticEvent: e
2363
+ };
2342
2364
  if (e.key !== undefined)
2343
2365
  event.key = e.key;
2344
2366
  if (isCheckBox)
@@ -2357,7 +2379,7 @@ var MenuItem = withHovering("MenuItem", function MenuItem(_a) {
2357
2379
  case Keys.ENTER:
2358
2380
  case Keys.SPACE:
2359
2381
  if (isAnchor) {
2360
- itemRef.current.click();
2382
+ (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.click();
2361
2383
  }
2362
2384
  else {
2363
2385
  handleClick(e);
@@ -2377,21 +2399,22 @@ var MenuItem = withHovering("MenuItem", function MenuItem(_a) {
2377
2399
  // 1. Preset props adhering to WAI-ARIA Authoring Practices.
2378
2400
  // 2. Merged outer and local props
2379
2401
  // 3. ref, className
2380
- var menuItemProps = __assign(__assign(__assign({ role: isRadio ? "menuitemradio" : isCheckBox ? "menuitemcheckbox" : "menuitem", "aria-checked": isRadio || isCheckBox ? isChecked : undefined }, mergedProps), commonProps(isDisabled, isHovering)), { ref: useCombinedRef(externalRef, itemRef), className: useBEM({ block: menuClass, element: menuItemClass, modifiers: modifiers, className: className }), children: react.useMemo(function () { return safeCall(children, modifiers); }, [children, modifiers]) });
2402
+ var menuItemProps = __assign(__assign(__assign({ role: isRadio ? "menuitemradio" : isCheckBox ? "menuitemcheckbox" : "menuitem", "aria-checked": isRadio || isCheckBox ? isChecked : undefined }, mergedProps), commonProps(isDisabled, isHovering)), { ref: useCombinedRef(externalRef, menuItemRef), className: useBEM({ block: menuClass, element: menuItemClass, modifiers: modifiers, className: className }), children: react.useMemo(function () { return safeCall(children, modifiers); }, [children, modifiers]) });
2381
2403
  if (isAnchor) {
2382
2404
  return (jsxRuntime.jsx("li", __assign({ role: "presentation" }, { children: jsxRuntime.jsx("a", __assign({ href: href }, menuItemProps)) })));
2383
2405
  }
2384
2406
  else {
2385
2407
  return jsxRuntime.jsx("li", __assign({}, menuItemProps));
2386
2408
  }
2387
- });
2388
- MenuItem.propTypes = __assign(__assign({}, stylePropTypes()), { value: propTypes.any, href: propTypes.string, type: propTypes.oneOf(["checkbox", "radio"]), checked: propTypes.bool, disabled: propTypes.bool, children: propTypes.oneOfType([propTypes.node, propTypes.func]), onClick: propTypes.func });
2409
+ };
2410
+ // FIXME matt as any
2411
+ var MenuItem = withHovering("MenuItem", MenuItemFr);
2389
2412
 
2390
- var FocusableItem = withHovering("FocusableItem", function FocusableItem(_a) {
2391
- var className = _a.className, disabled = _a.disabled, children = _a.children, isHovering = _a.isHovering, itemRef = _a.itemRef, externalRef = _a.externalRef, restProps = __rest(_a, ["className", "disabled", "children", "isHovering", "itemRef", "externalRef"]);
2413
+ var FocusableItemFr = function (_a) {
2414
+ var className = _a.className, disabled = _a.disabled, children = _a.children, isHovering = _a.isHovering, menuItemRef = _a.menuItemRef, externalRef = _a.externalRef, restProps = __rest(_a, ["className", "disabled", "children", "isHovering", "menuItemRef", "externalRef"]);
2392
2415
  var isDisabled = !!disabled;
2393
2416
  var ref = react.useRef(null);
2394
- var _b = useItemState(itemRef, ref, isHovering, isDisabled), setHover = _b.setHover, onPointerLeave = _b.onPointerLeave, restStateProps = __rest(_b, ["setHover", "onPointerLeave"]);
2417
+ var _b = useItemState(menuItemRef, ref, isHovering, isDisabled), setHover = _b.setHover, onPointerLeave = _b.onPointerLeave, restStateProps = __rest(_b, ["setHover", "onPointerLeave"]);
2395
2418
  var handleClose = react.useContext(EventHandlersContext).handleClose;
2396
2419
  var modifiers = react.useMemo(function () { return ({
2397
2420
  disabled: isDisabled,
@@ -2402,50 +2425,51 @@ var FocusableItem = withHovering("FocusableItem", function FocusableItem(_a) {
2402
2425
  return safeCall(children, __assign(__assign({}, modifiers), { ref: ref, closeMenu: handleClose }));
2403
2426
  }, [children, modifiers, handleClose]);
2404
2427
  var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerLeave: function (e) { return onPointerLeave(e, true); }, onFocus: setHover }), restProps);
2405
- return (jsxRuntime.jsx("li", __assign({ role: "menuitem" }, mergedProps, commonProps(isDisabled), { ref: useCombinedRef(externalRef, itemRef), className: useBEM({ block: menuClass, element: menuItemClass, modifiers: modifiers, className: className }) }, { children: renderChildren })));
2406
- });
2407
- FocusableItem.propTypes = __assign(__assign({}, stylePropTypes()), { disabled: propTypes.bool, children: propTypes.func });
2428
+ return (jsxRuntime.jsx("li", __assign({ role: "menuitem" }, mergedProps, commonProps(isDisabled), { ref: useCombinedRef(externalRef, menuItemRef), className: useBEM({ block: menuClass, element: menuItemClass, modifiers: modifiers, className: className }) }, { children: renderChildren })));
2429
+ };
2430
+ var FocusableItem = withHovering("FocusableItem", FocusableItemFr);
2408
2431
 
2409
- var MenuDivider = react.memo(react.forwardRef(function MenuDivider(_a, externalRef) {
2432
+ var MenuDividerFr = function (_a, externalRef) {
2410
2433
  var className = _a.className, restProps = __rest(_a, ["className"]);
2411
2434
  return (jsxRuntime.jsx("li", __assign({ role: "separator" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuDividerClass, className: className }) })));
2412
- }));
2413
- MenuDivider.propTypes = __assign({}, stylePropTypes());
2435
+ };
2436
+ var MenuDivider = react.memo(react.forwardRef(MenuDividerFr));
2414
2437
 
2415
- var MenuHeader = react.memo(react.forwardRef(function MenuHeader(_a, externalRef) {
2438
+ var MenuHeaderFr = function (_a, externalRef) {
2416
2439
  var className = _a.className, restProps = __rest(_a, ["className"]);
2417
2440
  return (jsxRuntime.jsx("li", __assign({ role: "presentation" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuHeaderClass, className: className }) })));
2418
- }));
2419
- MenuHeader.propTypes = __assign({}, stylePropTypes());
2441
+ };
2442
+ react.memo(react.forwardRef(MenuHeaderFr));
2420
2443
 
2421
- var MenuGroup = react.forwardRef(function MenuGroup(_a, externalRef) {
2444
+ var MenuGroupFr = function (_a, externalRef) {
2422
2445
  var className = _a.className, style = _a.style, takeOverflow = _a.takeOverflow, restProps = __rest(_a, ["className", "style", "takeOverflow"]);
2423
2446
  var ref = react.useRef(null);
2424
2447
  var _b = react.useState(), overflowStyle = _b[0], setOverflowStyle = _b[1];
2425
2448
  var _c = react.useContext(MenuListContext), overflow = _c.overflow, overflowAmt = _c.overflowAmt;
2426
2449
  useIsomorphicLayoutEffect(function () {
2427
2450
  var maxHeight;
2428
- if (takeOverflow && overflowAmt >= 0) {
2451
+ if (takeOverflow && overflowAmt != null && overflowAmt >= 0 && ref.current) {
2452
+ // FIXME Matt added && ref.current
2429
2453
  maxHeight = ref.current.getBoundingClientRect().height - overflowAmt;
2430
2454
  if (maxHeight < 0)
2431
2455
  maxHeight = 0;
2432
2456
  }
2433
- setOverflowStyle(maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined);
2457
+ setOverflowStyle(maxHeight != null && maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined);
2434
2458
  }, [takeOverflow, overflow, overflowAmt]);
2435
2459
  useIsomorphicLayoutEffect(function () {
2436
- if (overflowStyle)
2460
+ if (overflowStyle && ref.current)
2437
2461
  ref.current.scrollTop = 0;
2438
2462
  }, [overflowStyle]);
2439
2463
  return (jsxRuntime.jsx("div", __assign({}, restProps, { ref: useCombinedRef(externalRef, ref), className: useBEM({ block: menuClass, element: menuGroupClass, className: className }), style: __assign(__assign({}, style), overflowStyle) })));
2440
- });
2441
- MenuGroup.propTypes = __assign(__assign({}, stylePropTypes()), { takeOverflow: propTypes.bool });
2464
+ };
2465
+ react.forwardRef(MenuGroupFr);
2442
2466
 
2443
- var MenuRadioGroup = react.forwardRef(function MenuRadioGroup(_a, externalRef) {
2467
+ var MenuRadioGroupFr = function (_a, externalRef) {
2444
2468
  var ariaLabel = _a["aria-label"], className = _a.className, name = _a.name, value = _a.value, onRadioChange = _a.onRadioChange, restProps = __rest(_a, ["aria-label", "className", "name", "value", "onRadioChange"]);
2445
2469
  var contextValue = react.useMemo(function () { return ({ name: name, value: value, onRadioChange: onRadioChange }); }, [name, value, onRadioChange]);
2446
2470
  return (jsxRuntime.jsx(RadioGroupContext.Provider, __assign({ value: contextValue }, { children: jsxRuntime.jsx("li", __assign({ role: "presentation" }, { children: jsxRuntime.jsx("ul", __assign({ role: "group", "aria-label": ariaLabel || name || "Radio group" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: radioGroupClass, className: className }) })) })) })));
2447
- });
2448
- MenuRadioGroup.propTypes = __assign(__assign({}, stylePropTypes()), { name: propTypes.string, value: propTypes.any, onRadioChange: propTypes.func });
2471
+ };
2472
+ react.forwardRef(MenuRadioGroupFr);
2449
2473
 
2450
2474
  var useGridPopoverHook = function (props, save) {
2451
2475
  var cellEditorParams = props.cellEditorParams, saving = props.saving, updateValue = props.updateValue;
@@ -2533,7 +2557,7 @@ var GridFormMultiSelect = function (props) {
2533
2557
  }
2534
2558
  });
2535
2559
  }); }, [formProps, selectedValues]);
2536
- var popoverWrapper = useGridPopoverHook(props, save).popoverWrapper;
2560
+ var _e = useGridPopoverHook(props, save), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
2537
2561
  // Load up options list if it's async function
2538
2562
  react.useEffect(function () {
2539
2563
  var _a;
@@ -2593,10 +2617,18 @@ var GridFormMultiSelect = function (props) {
2593
2617
  } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2594
2618
  var _a;
2595
2619
  return item.value === MenuSeparatorString$1 ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
2620
+ // FIXME Matt Event type guessed here
2596
2621
  e.keepOpen = true;
2597
- // onSelectMenuOption(itemIndex, e.value);
2622
+ if (selectedValues.includes(e.value)) {
2623
+ setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
2624
+ }
2625
+ else {
2626
+ setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
2627
+ }
2598
2628
  return false;
2599
- } }, { children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: selectedValues.includes(item.value), value: "".concat(item.value), label: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), onChange: function (e) {
2629
+ }, onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2630
+ return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
2631
+ }); }); } }, { children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: selectedValues.includes(item.value), value: "".concat(item.value), label: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), onChange: function (e) {
2600
2632
  if (e.target.checked) {
2601
2633
  setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
2602
2634
  }
@@ -2997,7 +3029,7 @@ var GridFormDropDown = function (props) {
2997
3029
  }
2998
3030
  });
2999
3031
  }); }, [filteredValues, options, selectItemHandler, stopEditing]);
3000
- return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [formProps.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item", index: -1 }, { children: function (_a) {
3032
+ return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [formProps.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3001
3033
  var _b;
3002
3034
  var ref = _a.ref;
3003
3035
  return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = formProps.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));