@linzjs/step-ag-grid 1.4.6 → 1.4.7

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 (69) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +108 -88
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/GridCell.d.ts +4 -3
  5. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +8 -5
  6. package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -2
  7. package/dist/src/react-menu3/components/FocusableItem.d.ts +2 -2
  8. package/dist/src/react-menu3/components/Menu.d.ts +1 -1
  9. package/dist/src/react-menu3/components/MenuButton.d.ts +1 -1
  10. package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
  11. package/dist/src/react-menu3/components/MenuGroup.d.ts +1 -1
  12. package/dist/src/react-menu3/components/MenuHeader.d.ts +1 -1
  13. package/dist/src/react-menu3/components/MenuItem.d.ts +2 -4
  14. package/dist/src/react-menu3/components/MenuList.d.ts +2 -56
  15. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
  16. package/dist/src/react-menu3/components/SubMenu.d.ts +6 -6
  17. package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
  18. package/dist/src/react-menu3/hooks/useItems.d.ts +1 -1
  19. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -1
  20. package/dist/src/react-menu3/hooks/useMenuState.d.ts +1 -1
  21. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +1 -1
  22. package/dist/src/react-menu3/index.d.ts +1 -391
  23. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
  24. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +1 -1
  25. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +1 -1
  26. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +1 -1
  27. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +1 -1
  28. package/dist/src/react-menu3/types.d.ts +389 -0
  29. package/dist/src/react-menu3/utils/constants.d.ts +12 -5
  30. package/dist/src/react-menu3/utils/index.d.ts +0 -1
  31. package/dist/src/react-menu3/utils/{propTypes.d.ts → propTypes2.d.ts} +0 -0
  32. package/dist/src/react-menu3/utils/utils.d.ts +2 -2
  33. package/dist/step-ag-grid.esm.js +99 -90
  34. package/dist/step-ag-grid.esm.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/GridCell.tsx +6 -3
  37. package/src/components/GridPopoverHook.tsx +1 -1
  38. package/src/components/gridForm/GridFormMultiSelect.tsx +32 -19
  39. package/src/components/gridRender/GridRenderGenericCell.tsx +11 -7
  40. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +14 -2
  41. package/src/contexts/GridContextProvider.tsx +3 -2
  42. package/src/react-menu3/components/ControlledMenu.tsx +40 -46
  43. package/src/react-menu3/components/FocusableItem.tsx +2 -2
  44. package/src/react-menu3/components/Menu.tsx +1 -1
  45. package/src/react-menu3/components/MenuButton.tsx +1 -1
  46. package/src/react-menu3/components/MenuDivider.tsx +2 -2
  47. package/src/react-menu3/components/MenuGroup.tsx +1 -1
  48. package/src/react-menu3/components/MenuHeader.tsx +1 -1
  49. package/src/react-menu3/components/MenuItem.tsx +2 -3
  50. package/src/react-menu3/components/MenuList.tsx +19 -62
  51. package/src/react-menu3/components/MenuRadioGroup.tsx +2 -2
  52. package/src/react-menu3/components/SubMenu.tsx +17 -8
  53. package/src/react-menu3/hooks/useBEM.ts +1 -1
  54. package/src/react-menu3/hooks/useItems.ts +1 -1
  55. package/src/react-menu3/hooks/useMenuChange.ts +1 -1
  56. package/src/react-menu3/hooks/useMenuState.ts +1 -1
  57. package/src/react-menu3/hooks/useMenuStateAndFocus.ts +1 -1
  58. package/src/react-menu3/index.ts +1 -431
  59. package/src/react-menu3/positionUtils/getPositionHelpers.ts +3 -3
  60. package/src/react-menu3/positionUtils/placeLeftorRight.ts +1 -1
  61. package/src/react-menu3/positionUtils/placeToporBottom.ts +1 -1
  62. package/src/react-menu3/positionUtils/positionContextMenu.ts +1 -1
  63. package/src/react-menu3/positionUtils/positionMenu.ts +1 -1
  64. package/src/react-menu3/{index.d.ts → types.ts} +106 -359
  65. package/src/react-menu3/utils/constants.ts +24 -5
  66. package/src/react-menu3/utils/index.ts +1 -1
  67. package/src/react-menu3/utils/{propTypes.ts → propTypes2.ts} +0 -0
  68. package/src/react-menu3/utils/utils.ts +2 -2
  69. package/src/stories/components/GridReadOnly.stories.tsx +3 -4
@@ -1,10 +1,9 @@
1
- import { createContext, useRef, useContext, useCallback, useState, useEffect, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
1
+ import { createContext, useRef, useContext, useCallback, useState, useEffect, useMemo, forwardRef, useLayoutEffect, memo, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { castArray, remove, flatten, isEmpty, delay, sortBy, last, difference, xorBy, findIndex } from 'lodash-es';
4
4
  import { AgGridReact } from 'ag-grid-react';
5
5
  import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput } from '@linzjs/lui';
6
6
  import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
7
- import { oneOf, object, bool, number, string, oneOfType, exact, func } from 'prop-types';
8
7
  import { useTransition } from 'react-transition-state';
9
8
  import debounce from 'debounce-promise';
10
9
  import { v4 } from 'uuid';
@@ -468,9 +467,11 @@ var GridContextProvider = function (props) {
468
467
  }
469
468
  // This is needed to trigger postSortRowsHook
470
469
  gridApi.refreshClientSideRowModel();
471
- stopEditing();
472
470
  }
473
- setSaving && setSaving(false);
471
+ else {
472
+ // Don't set saving if ok as the form has already closed
473
+ setSaving && setSaving(false);
474
+ }
474
475
  return [2 /*return*/, ok];
475
476
  }
476
477
  });
@@ -901,7 +902,7 @@ var GridCell = function (props) {
901
902
  cellEditor: GenericCellEditorComponent
902
903
  })), props), { cellRendererParams: __assign({ originalCellRender: props.cellRenderer }, props.cellRendererParams) });
903
904
  };
904
- var GenericCellEditorComponent = function (props) {
905
+ var GenericCellEditorComponentFr = function (props, _) {
905
906
  var _a, _b, _c;
906
907
  var _d = useContext(GridContext), updatingCells = _d.updatingCells, getSelectedRows = _d.getSelectedRows;
907
908
  var colDef = props.colDef, data = props.data;
@@ -930,7 +931,8 @@ var GenericCellEditorComponent = function (props) {
930
931
  if (cellEditorParams == null)
931
932
  return jsx(Fragment, {});
932
933
  return (jsxs(Fragment, { children: [jsx("div", { children: colDef.cellRenderer ? jsx(colDef.cellRenderer, __assign({}, props, { saving: saving })) : props.value }), (cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.form) && (jsx(cellEditorParams.form, { cellEditorParams: props, updateValue: updateValue, saving: saving, formProps: formProps, value: value, field: field, selectedRows: selectedRows }))] }));
933
- };
934
+ };
935
+ var GenericCellEditorComponent = forwardRef(GenericCellEditorComponentFr);
934
936
 
935
937
  /**
936
938
  * If loading is true this returns a loading spinner, otherwise it returns its children.
@@ -1067,7 +1069,6 @@ var MenuStateMap = Object.freeze({
1067
1069
 
1068
1070
  var isMenuOpen = function (state) { return !!state && state[0] === "o"; };
1069
1071
  var batchedUpdates = unstable_batchedUpdates || (function (callback) { return callback(); });
1070
- var values = Object.values || (function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); });
1071
1072
  var floatEqual = function (a, b, diff) {
1072
1073
  if (diff === void 0) { diff = 0.0001; }
1073
1074
  return Math.abs(a - b) < diff;
@@ -1138,36 +1139,6 @@ function commonProps(isDisabled, isHovering) {
1138
1139
  }
1139
1140
  var indexOfNode = function (nodeList, node) { return findIndex(nodeList, node); };
1140
1141
 
1141
- var stylePropTypes = function (name) {
1142
- var _a;
1143
- return (_a = {},
1144
- _a[name ? "".concat(name, "ClassName") : "className"] = oneOfType([string, func]),
1145
- _a);
1146
- };
1147
- var Direction = oneOf(["left", "right", "top", "bottom"]);
1148
- // Menu, SubMenu and ControlledMenu
1149
- var menuPropTypes = __assign(__assign(__assign({ className: string }, stylePropTypes("menu")), stylePropTypes("arrow")), { menuStyle: object, arrowStyle: object, arrow: bool, setDownOverflow: bool, offsetX: number, offsetY: number, align: oneOf(["start", "center", "end"]), direction: Direction, position: oneOf(["auto", "anchor", "initial"]), overflow: oneOf(["auto", "visible", "hidden"]) });
1150
- // Menu and ControlledMenu
1151
- var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps: object, initialMounted: bool, unmountOnClose: bool, transition: oneOfType([
1152
- bool,
1153
- exact({
1154
- open: bool,
1155
- close: bool,
1156
- item: bool
1157
- }),
1158
- ]), transitionTimeout: number, boundingBoxRef: object, boundingBoxPadding: string, reposition: oneOf(["auto", "initial"]), repositionFlag: oneOfType([string, number]), viewScroll: oneOf(["auto", "close", "initial"]), submenuOpenDelay: number, submenuCloseDelay: number, portal: oneOfType([
1159
- bool,
1160
- exact({
1161
- target: object,
1162
- stablePosition: bool
1163
- }),
1164
- ]), theming: string, onItemClick: func });
1165
- // Menu and SubMenu
1166
- ({
1167
- instanceRef: oneOfType([object, func]),
1168
- onMenuChange: func
1169
- });
1170
-
1171
1142
  var withHovering = function (name, WrappedComponent) {
1172
1143
  var Component = memo(WrappedComponent);
1173
1144
  var WithHovering = forwardRef(function (props, ref) {
@@ -1382,17 +1353,17 @@ var useMenuStateAndFocus = function (options) {
1382
1353
  return [__assign({ menuItemFocus: menuItemFocus }, menuProps), toggleMenu, openMenu];
1383
1354
  };
1384
1355
 
1385
- forwardRef(function MenuButton(_a, ref) {
1356
+ var MenuButton = forwardRef(function MenuButton(_a, ref) {
1386
1357
  var className = _a.className, isOpen = _a.isOpen, disabled = _a.disabled, children = _a.children, restProps = __rest(_a, ["className", "isOpen", "disabled", "children"]);
1387
1358
  var modifiers = useMemo(function () { return ({ open: isOpen }); }, [isOpen]);
1388
1359
  return (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 })));
1389
1360
  });
1390
1361
 
1391
1362
  var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBoxPadding) {
1392
- var _a;
1363
+ var _a, _b, _c;
1393
1364
  var menuRect = menuRef.current.getBoundingClientRect();
1394
- var containerRect = containerRef.current.getBoundingClientRect();
1395
- var thisWindow = (_a = containerRef.current.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
1365
+ var thisWindow = (_b = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.defaultView) !== null && _b !== void 0 ? _b : window;
1366
+ var containerRect = ((_c = containerRef.current) !== null && _c !== void 0 ? _c : thisWindow.document.body).getBoundingClientRect();
1396
1367
  var boundingRect = menuScroll === window || menuScroll === thisWindow
1397
1368
  ? {
1398
1369
  left: 0,
@@ -1743,7 +1714,7 @@ var MenuList = function (_a) {
1743
1714
  endTransition && safeCall(endTransition);
1744
1715
  };
1745
1716
  var handlePosition = useCallback(function (noOverflowCheck) {
1746
- if (!containerRef.current) {
1717
+ if (!(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current)) {
1747
1718
  if (process.env.NODE_ENV !== "production") {
1748
1719
  console.error('[React-Menu] Menu cannot be positioned properly as container ref is null. If you need to initialise `state` prop to "open" for ControlledMenu, please see this solution: https://codesandbox.io/s/initial-open-sp10wn');
1749
1720
  }
@@ -1942,10 +1913,27 @@ var MenuList = function (_a) {
1942
1913
  else if (captureFocus) {
1943
1914
  // Use a timeout here because if set focus immediately, page might scroll unexpectedly.
1944
1915
  var id_1 = setTimeout(function () {
1945
- var _a;
1916
+ var _a, _b, _c;
1946
1917
  // If focus has already been set to a children element, don't set focus on menu or item
1947
1918
  if (!menuRef.current.contains(document.activeElement)) {
1948
- (_a = focusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1919
+ // Handle popover portal focus
1920
+ var popupElement = (_a = focusRef.current) === null || _a === void 0 ? void 0 : _a.nextSibling;
1921
+ if (popupElement instanceof Element) {
1922
+ var input = popupElement.querySelectorAll("input,textarea")[0];
1923
+ if (input) {
1924
+ input.focus();
1925
+ // Text areas should start at end
1926
+ if (input instanceof HTMLTextAreaElement) {
1927
+ input.selectionStart = input.value.length;
1928
+ }
1929
+ }
1930
+ else {
1931
+ (_b = focusRef.current) === null || _b === void 0 ? void 0 : _b.focus();
1932
+ }
1933
+ }
1934
+ else {
1935
+ (_c = focusRef.current) === null || _c === void 0 ? void 0 : _c.focus();
1936
+ }
1949
1937
  setItemFocus();
1950
1938
  }
1951
1939
  }, openTransition ? 170 : 100);
@@ -1988,9 +1976,9 @@ var MenuList = function (_a) {
1988
1976
  return (jsxs("ul", __assign({ role: "menu", "aria-label": ariaLabel }, mergeProps({ onKeyDown: onKeyDown, onAnimationEnd: onAnimationEnd }, restProps), commonProps(isDisabled), { ref: useCombinedRef(externalRef, menuRef), className: useBEM({ block: menuClass, modifiers: modifiers, className: menuClassName }), style: __assign(__assign(__assign({}, menuStyle), overflowStyle), { margin: 0, display: state === "closed" ? "none" : undefined, position: "absolute", left: menuPosition.x, top: menuPosition.y }) }, { children: [jsx("div", { ref: focusRef, tabIndex: -1, style: { position: "absolute", left: 0, top: 0 } }), arrow && (jsx("div", { className: _arrowClass, style: __assign(__assign({}, arrowStyle), { position: "absolute", left: arrowPosition.x, top: arrowPosition.y }), ref: arrowRef })), jsx(MenuListContext.Provider, __assign({ value: listContext }, { children: jsx(MenuListItemContext.Provider, __assign({ value: itemContext }, { children: jsx(HoverItemContext.Provider, __assign({ value: hoverItem }, { children: children })) })) }))] })));
1989
1977
  };
1990
1978
 
1991
- var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
1979
+ var ControlledMenuFr = function (_a, externalRef) {
1992
1980
  var ariaLabel = _a["aria-label"], className = _a.className, containerProps = _a.containerProps, initialMounted = _a.initialMounted, unmountOnClose = _a.unmountOnClose, transition = _a.transition, transitionTimeout = _a.transitionTimeout, boundingBoxRef = _a.boundingBoxRef, boundingBoxPadding = _a.boundingBoxPadding, _b = _a.reposition, reposition = _b === void 0 ? "auto" : _b, _c = _a.submenuOpenDelay, submenuOpenDelay = _c === void 0 ? 300 : _c, _d = _a.submenuCloseDelay, submenuCloseDelay = _d === void 0 ? 150 : _d, skipOpen = _a.skipOpen, _e = _a.viewScroll, viewScroll = _e === void 0 ? "initial" : _e, portal = _a.portal, theming = _a.theming, onItemClick = _a.onItemClick, onClose = _a.onClose, saveButtonRef = _a.saveButtonRef, restProps = __rest(_a, ["aria-label", "className", "containerProps", "initialMounted", "unmountOnClose", "transition", "transitionTimeout", "boundingBoxRef", "boundingBoxPadding", "reposition", "submenuOpenDelay", "submenuCloseDelay", "skipOpen", "viewScroll", "portal", "theming", "onItemClick", "onClose", "saveButtonRef"]);
1993
- var containerRef = useRef(null);
1981
+ var containerRef = useRef();
1994
1982
  var scrollNodesRef = useRef({});
1995
1983
  var anchorRef = restProps.anchorRef, state = restProps.state;
1996
1984
  var settings = useMemo(function () { return ({
@@ -2028,7 +2016,7 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2028
2016
  // the cell doesn't refresh during update if save is invoked from a native event
2029
2017
  // This doesn't happen in React18
2030
2018
  // To work around it, I invoke the save by clicking on a passed in invisible button ref
2031
- if (saveButtonRef.current)
2019
+ if (saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current)
2032
2020
  saveButtonRef.current.click();
2033
2021
  else
2034
2022
  safeCall(onClose, { reason: CloseReason.BLUR });
@@ -2043,7 +2031,7 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2043
2031
  setTimeout(function () { return (skipOpen.current = false); }, 300);
2044
2032
  }
2045
2033
  }
2046
- }, [clickIsWithinMenu, onClose]);
2034
+ }, [clickIsWithinMenu, onClose, saveButtonRef, skipOpen]);
2047
2035
  var handleScreenEventForCancel = useCallback(function (ev) {
2048
2036
  if (!clickIsWithinMenu(ev)) {
2049
2037
  ev.preventDefault();
@@ -2052,7 +2040,7 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2052
2040
  }, [clickIsWithinMenu]);
2053
2041
  useEffect(function () {
2054
2042
  if (isMenuOpen(state)) {
2055
- var thisDocument_1 = anchorRef.current ? anchorRef.current.ownerDocument : document;
2043
+ var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
2056
2044
  thisDocument_1.addEventListener("mousedown", handleScreenEventForCancel, true);
2057
2045
  thisDocument_1.addEventListener("mouseup", handleScreenEventForSave, true);
2058
2046
  thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
@@ -2065,13 +2053,13 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2065
2053
  };
2066
2054
  }
2067
2055
  return function () { };
2068
- }, [handleScreenEventForSave, handleScreenEventForCancel, state]);
2056
+ }, [handleScreenEventForSave, handleScreenEventForCancel, state, anchorRef]);
2069
2057
  var itemSettings = useMemo(function () { return ({
2070
2058
  submenuOpenDelay: submenuOpenDelay,
2071
2059
  submenuCloseDelay: submenuCloseDelay
2072
2060
  }); }, [submenuOpenDelay, submenuCloseDelay]);
2073
2061
  var eventHandlers = useMemo(function () { return ({
2074
- handleClick: function (event, isCheckorRadio) {
2062
+ handleClick: function (event, isCheckOrRadio) {
2075
2063
  if (!event.stopPropagation)
2076
2064
  safeCall(onItemClick, event);
2077
2065
  var keepOpen = event.keepOpen;
@@ -2079,7 +2067,7 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2079
2067
  // if event.keepOpen is undefined, the following default behaviour is used
2080
2068
  // According to WAI-ARIA Authoring Practices 1.1
2081
2069
  // Keep menu open when check or radio is invoked by SPACE key
2082
- keepOpen = isCheckorRadio && event.key === Keys.SPACE;
2070
+ keepOpen = isCheckOrRadio && event.key === Keys.SPACE;
2083
2071
  }
2084
2072
  if (!keepOpen) {
2085
2073
  safeCall(onClose, {
@@ -2107,7 +2095,7 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2107
2095
  // If a user clicks on the menu button when a menu is open, we need to close the menu.
2108
2096
  // However, a blur event will be fired prior to the click event on menu button,
2109
2097
  // which makes the menu first close and then open again.
2110
- // If this happen, e.relatedTarget is incorrectly set to null instead of the button in Safari and Firefox,
2098
+ // If this happens, e.relatedTarget is incorrectly set to null instead of the button in Safari and Firefox,
2111
2099
  // and makes it difficult to determine whether onBlur is fired because of clicking on menu button.
2112
2100
  // This is a workaround approach which sets a flag to skip a following click event.
2113
2101
  if (skipOpen) {
@@ -2123,24 +2111,22 @@ var ControlledMenu = forwardRef(function ControlledMenu(_a, externalRef) {
2123
2111
  modifiers: modifiers,
2124
2112
  className: className
2125
2113
  }), style: __assign(__assign({}, containerProps === null || containerProps === void 0 ? void 0 : containerProps.style), { position: "relative" }), ref: containerRef }, { children: state && (jsx(SettingsContext.Provider, __assign({ value: settings }, { children: jsx(ItemSettingsContext.Provider, __assign({ value: itemSettings }, { children: jsx(EventHandlersContext.Provider, __assign({ value: eventHandlers }, { children: jsx(MenuList, __assign({}, restProps, { ariaLabel: ariaLabel || "Menu", externalRef: externalRef, containerRef: containerRef, onClose: onClose })) })) })) }))) })));
2126
- if (portal === true && anchorRef.current !== undefined) {
2114
+ if (portal === true && (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== undefined) {
2127
2115
  portal = { target: anchorRef.current.ownerDocument.body };
2128
2116
  }
2129
- if (portal === true && typeof document !== "undefined") {
2130
- return createPortal(menuList, document.body);
2131
- }
2132
- else if (portal) {
2133
- return portal.target ? createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
2117
+ if (portal) {
2118
+ if (typeof portal === "boolean") {
2119
+ if (portal && typeof document !== "undefined") {
2120
+ return createPortal(menuList, document.body);
2121
+ }
2122
+ }
2123
+ else {
2124
+ return portal.target ? createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
2125
+ }
2134
2126
  }
2135
2127
  return menuList;
2136
- });
2137
- ControlledMenu.propTypes /* remove-proptypes */ = __assign(__assign({}, rootMenuPropTypes), { state: oneOf(values(MenuStateMap)), anchorPoint: exact({
2138
- x: number,
2139
- y: number
2140
- }), anchorRef: object, skipOpen: object, captureFocus: bool, menuItemFocus: exact({
2141
- position: oneOfType([string, number]),
2142
- alwaysUpdate: bool
2143
- }), onClose: func });
2128
+ };
2129
+ var ControlledMenu = forwardRef(ControlledMenuFr);
2144
2130
 
2145
2131
  function MenuFr(_a, externalRef) {
2146
2132
  var ariaLabel = _a["aria-label"], menuButton = _a.menuButton, instanceRef = _a.instanceRef, onMenuChange = _a.onMenuChange, restProps = __rest(_a, ["aria-label", "menuButton", "instanceRef", "onMenuChange"]);
@@ -2188,7 +2174,7 @@ function MenuFr(_a, externalRef) {
2188
2174
  }); });
2189
2175
  return (jsxs(Fragment$1, { children: [renderButton, 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 }))] }));
2190
2176
  }
2191
- forwardRef(MenuFr);
2177
+ var Menu = forwardRef(MenuFr);
2192
2178
 
2193
2179
  var SubMenuFr = function (_a) {
2194
2180
  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"]);
@@ -2330,7 +2316,7 @@ var SubMenuFr = function (_a) {
2330
2316
  className: itemClassName
2331
2317
  }) }, { children: useMemo(function () { return safeCall(label, modifiers); }, [label, modifiers]) })), state && getMenuList()] })));
2332
2318
  };
2333
- withHovering("SubMenu", SubMenuFr);
2319
+ var SubMenu = withHovering("SubMenu", SubMenuFr);
2334
2320
 
2335
2321
  var MenuItemFr = function (_a) {
2336
2322
  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"]);
@@ -2399,7 +2385,6 @@ var MenuItemFr = function (_a) {
2399
2385
  return jsx("li", __assign({}, menuItemProps));
2400
2386
  }
2401
2387
  };
2402
- // FIXME matt as any
2403
2388
  var MenuItem = withHovering("MenuItem", MenuItemFr);
2404
2389
 
2405
2390
  var FocusableItemFr = function (_a) {
@@ -2431,7 +2416,7 @@ var MenuHeaderFr = function (_a, externalRef) {
2431
2416
  var className = _a.className, restProps = __rest(_a, ["className"]);
2432
2417
  return (jsx("li", __assign({ role: "presentation" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuHeaderClass, className: className }) })));
2433
2418
  };
2434
- memo(forwardRef(MenuHeaderFr));
2419
+ var MenuHeader = memo(forwardRef(MenuHeaderFr));
2435
2420
 
2436
2421
  var MenuGroupFr = function (_a, externalRef) {
2437
2422
  var className = _a.className, style = _a.style, takeOverflow = _a.takeOverflow, restProps = __rest(_a, ["className", "style", "takeOverflow"]);
@@ -2454,14 +2439,14 @@ var MenuGroupFr = function (_a, externalRef) {
2454
2439
  }, [overflowStyle]);
2455
2440
  return (jsx("div", __assign({}, restProps, { ref: useCombinedRef(externalRef, ref), className: useBEM({ block: menuClass, element: menuGroupClass, className: className }), style: __assign(__assign({}, style), overflowStyle) })));
2456
2441
  };
2457
- forwardRef(MenuGroupFr);
2442
+ var MenuGroup = forwardRef(MenuGroupFr);
2458
2443
 
2459
2444
  var MenuRadioGroupFr = function (_a, externalRef) {
2460
2445
  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"]);
2461
2446
  var contextValue = useMemo(function () { return ({ name: name, value: value, onRadioChange: onRadioChange }); }, [name, value, onRadioChange]);
2462
2447
  return (jsx(RadioGroupContext.Provider, __assign({ value: contextValue }, { children: jsx("li", __assign({ role: "presentation" }, { children: jsx("ul", __assign({ role: "group", "aria-label": ariaLabel || name || "Radio group" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: radioGroupClass, className: className }) })) })) })));
2463
2448
  };
2464
- forwardRef(MenuRadioGroupFr);
2449
+ var MenuRadioGroup = forwardRef(MenuRadioGroupFr);
2465
2450
 
2466
2451
  var useGridPopoverHook = function (props, save) {
2467
2452
  var cellEditorParams = props.cellEditorParams, saving = props.saving, updateValue = props.updateValue;
@@ -2515,7 +2500,18 @@ var GridRenderPopoutMenuCell = function (props) {
2515
2500
  var _a, _b, _c;
2516
2501
  var checkUpdating = useContext(UpdatingContext).checkUpdating;
2517
2502
  var isLoading = checkUpdating((_b = (_a = props.colDef) === null || _a === void 0 ? void 0 : _a.field) !== null && _b !== void 0 ? _b : "", props.data.id);
2518
- var disabled = !((_c = props.colDef) === null || _c === void 0 ? void 0 : _c.editable);
2503
+ var editable = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.editable;
2504
+ var disabled = !(typeof editable === "function"
2505
+ ? editable({
2506
+ node: props.node,
2507
+ data: props.data,
2508
+ column: props.column,
2509
+ colDef: props.colDef,
2510
+ api: props.api,
2511
+ columnApi: props.columnApi,
2512
+ context: props.context
2513
+ })
2514
+ : editable);
2519
2515
  return (jsx(GridLoadableCell, __assign({ isLoading: isLoading, className: disabled ? "GridPopoutMenu-burgerDisabled" : "GridPopoutMenu-burger" }, { children: jsx(LuiIcon, { name: "ic_more_vert", alt: "More actions", size: "md" }) })));
2520
2516
  };
2521
2517
 
@@ -2598,7 +2594,7 @@ var GridFormMultiSelect = function (props) {
2598
2594
  return undefined;
2599
2595
  }
2600
2596
  var str = option.label || "";
2601
- return str.toLowerCase().indexOf(filter) === -1 ? option.value : undefined;
2597
+ return str.toLowerCase().indexOf(filter.trim()) === -1 ? option.value : undefined;
2602
2598
  })
2603
2599
  .filter(function (r) { return r !== undefined; }));
2604
2600
  }, [formProps.filtered, filter, options]);
@@ -2606,35 +2602,48 @@ var GridFormMultiSelect = function (props) {
2606
2602
  var _b;
2607
2603
  var ref = _a.ref;
2608
2604
  return (jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: 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: "", onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
2609
- } })), jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2605
+ } }), "filter"), jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2610
2606
  var _a;
2611
- return item.value === MenuSeparatorString$1 ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxs(Fragment, { children: [jsx(MenuItem, __assign({ onClick: function (e) {
2612
- // FIXME Matt Event type guessed here
2607
+ return item.value === MenuSeparatorString$1 ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxs(Fragment$1, { children: [jsx(MenuItem, __assign({ onClick: function (e) {
2613
2608
  e.keepOpen = true;
2614
- if (selectedValues.includes(e.value)) {
2609
+ if (selectedValues.includes(item.value)) {
2615
2610
  setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
2616
2611
  }
2617
2612
  else {
2618
2613
  setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
2619
2614
  }
2620
- return false;
2621
- }, onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2622
- return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
2623
- }); }); } }, { children: jsx(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) {
2624
- if (e.target.checked) {
2625
- setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
2615
+ }, onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () {
2616
+ return __generator(this, function (_a) {
2617
+ if (e.key === "Enter")
2618
+ triggerSave().then();
2619
+ else if (e.key === " ") {
2620
+ if (selectedValues.includes(item.value)) {
2621
+ setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
2622
+ }
2623
+ else {
2624
+ setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
2625
+ }
2626
+ e.preventDefault();
2627
+ e.stopPropagation();
2626
2628
  }
2627
- else {
2628
- setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
2629
+ return [2 /*return*/];
2630
+ });
2631
+ }); } }, { children: jsx(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)), inputProps: {
2632
+ onClick: function (e) {
2633
+ e.preventDefault();
2634
+ e.stopPropagation();
2635
+ return false;
2629
2636
  }
2630
- } }) }), "".concat(item.value)), selectedValues.includes(item.value) && item.subComponent && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
2637
+ }, onChange: function () {
2638
+ /*Do nothing, change handled by menuItem*/
2639
+ } }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
2631
2640
  return item.subComponent &&
2632
2641
  item.subComponent({
2633
2642
  setValue: function (value) {
2634
2643
  subSelectedValues.current[item.value] = value;
2635
2644
  }
2636
2645
  }, ref);
2637
- } }), "".concat(item.value, "_subcomponent")))] }));
2646
+ } }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
2638
2647
  })] })) })));
2639
2648
  };
2640
2649
 
@@ -3183,5 +3192,5 @@ var GridPopoverTextInput = function (colDef) {
3183
3192
  })));
3184
3193
  };
3185
3194
 
3186
- export { ComponentLoadingWrapper, GenericMultiEditCellClass, Grid, GridCell, GridContext, GridContextProvider, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormPopoutMenu, GridFormTextArea, GridFormTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, TextAreaInput, TextInputFormatted, UpdatingContext, UpdatingContextProvider, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, usePostSortRowsHook, wait };
3195
+ export { ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericMultiEditCellClass, Grid, GridCell, GridContext, GridContextProvider, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormPopoutMenu, GridFormTextArea, GridFormTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuItem, MenuRadioGroup, SubMenu, TextAreaInput, TextInputFormatted, UpdatingContext, UpdatingContextProvider, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3187
3196
  //# sourceMappingURL=step-ag-grid.esm.js.map