@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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +108 -88
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +4 -3
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +8 -5
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -2
- package/dist/src/react-menu3/components/FocusableItem.d.ts +2 -2
- package/dist/src/react-menu3/components/Menu.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuButton.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuGroup.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuHeader.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuItem.d.ts +2 -4
- package/dist/src/react-menu3/components/MenuList.d.ts +2 -56
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +6 -6
- package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItems.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +1 -1
- package/dist/src/react-menu3/index.d.ts +1 -391
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +389 -0
- package/dist/src/react-menu3/utils/constants.d.ts +12 -5
- package/dist/src/react-menu3/utils/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/{propTypes.d.ts → propTypes2.d.ts} +0 -0
- package/dist/src/react-menu3/utils/utils.d.ts +2 -2
- package/dist/step-ag-grid.esm.js +99 -90
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridCell.tsx +6 -3
- package/src/components/GridPopoverHook.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +32 -19
- package/src/components/gridRender/GridRenderGenericCell.tsx +11 -7
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +14 -2
- package/src/contexts/GridContextProvider.tsx +3 -2
- package/src/react-menu3/components/ControlledMenu.tsx +40 -46
- package/src/react-menu3/components/FocusableItem.tsx +2 -2
- package/src/react-menu3/components/Menu.tsx +1 -1
- package/src/react-menu3/components/MenuButton.tsx +1 -1
- package/src/react-menu3/components/MenuDivider.tsx +2 -2
- package/src/react-menu3/components/MenuGroup.tsx +1 -1
- package/src/react-menu3/components/MenuHeader.tsx +1 -1
- package/src/react-menu3/components/MenuItem.tsx +2 -3
- package/src/react-menu3/components/MenuList.tsx +19 -62
- package/src/react-menu3/components/MenuRadioGroup.tsx +2 -2
- package/src/react-menu3/components/SubMenu.tsx +17 -8
- package/src/react-menu3/hooks/useBEM.ts +1 -1
- package/src/react-menu3/hooks/useItems.ts +1 -1
- package/src/react-menu3/hooks/useMenuChange.ts +1 -1
- package/src/react-menu3/hooks/useMenuState.ts +1 -1
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +1 -1
- package/src/react-menu3/index.ts +1 -431
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +3 -3
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +1 -1
- package/src/react-menu3/positionUtils/placeToporBottom.ts +1 -1
- package/src/react-menu3/positionUtils/positionContextMenu.ts +1 -1
- package/src/react-menu3/positionUtils/positionMenu.ts +1 -1
- package/src/react-menu3/{index.d.ts → types.ts} +106 -359
- package/src/react-menu3/utils/constants.ts +24 -5
- package/src/react-menu3/utils/index.ts +1 -1
- package/src/react-menu3/utils/{propTypes.ts → propTypes2.ts} +0 -0
- package/src/react-menu3/utils/utils.ts +2 -2
- package/src/stories/components/GridReadOnly.stories.tsx +3 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,6 @@ var lodashEs = require('lodash-es');
|
|
|
8
8
|
var agGridReact = require('ag-grid-react');
|
|
9
9
|
var lui = require('@linzjs/lui');
|
|
10
10
|
var reactDom = require('react-dom');
|
|
11
|
-
var propTypes = require('prop-types');
|
|
12
11
|
var reactTransitionState = require('react-transition-state');
|
|
13
12
|
var debounce = require('debounce-promise');
|
|
14
13
|
var uuid = require('uuid');
|
|
@@ -476,9 +475,11 @@ var GridContextProvider = function (props) {
|
|
|
476
475
|
}
|
|
477
476
|
// This is needed to trigger postSortRowsHook
|
|
478
477
|
gridApi.refreshClientSideRowModel();
|
|
479
|
-
stopEditing();
|
|
480
478
|
}
|
|
481
|
-
|
|
479
|
+
else {
|
|
480
|
+
// Don't set saving if ok as the form has already closed
|
|
481
|
+
setSaving && setSaving(false);
|
|
482
|
+
}
|
|
482
483
|
return [2 /*return*/, ok];
|
|
483
484
|
}
|
|
484
485
|
});
|
|
@@ -909,7 +910,7 @@ var GridCell = function (props) {
|
|
|
909
910
|
cellEditor: GenericCellEditorComponent
|
|
910
911
|
})), props), { cellRendererParams: __assign({ originalCellRender: props.cellRenderer }, props.cellRendererParams) });
|
|
911
912
|
};
|
|
912
|
-
var
|
|
913
|
+
var GenericCellEditorComponentFr = function (props, _) {
|
|
913
914
|
var _a, _b, _c;
|
|
914
915
|
var _d = react.useContext(GridContext), updatingCells = _d.updatingCells, getSelectedRows = _d.getSelectedRows;
|
|
915
916
|
var colDef = props.colDef, data = props.data;
|
|
@@ -938,7 +939,8 @@ var GenericCellEditorComponent = function (props) {
|
|
|
938
939
|
if (cellEditorParams == null)
|
|
939
940
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
940
941
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { children: colDef.cellRenderer ? jsxRuntime.jsx(colDef.cellRenderer, __assign({}, props, { saving: saving })) : props.value }), (cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.form) && (jsxRuntime.jsx(cellEditorParams.form, { cellEditorParams: props, updateValue: updateValue, saving: saving, formProps: formProps, value: value, field: field, selectedRows: selectedRows }))] }));
|
|
941
|
-
};
|
|
942
|
+
};
|
|
943
|
+
var GenericCellEditorComponent = react.forwardRef(GenericCellEditorComponentFr);
|
|
942
944
|
|
|
943
945
|
/**
|
|
944
946
|
* If loading is true this returns a loading spinner, otherwise it returns its children.
|
|
@@ -1075,7 +1077,6 @@ var MenuStateMap = Object.freeze({
|
|
|
1075
1077
|
|
|
1076
1078
|
var isMenuOpen = function (state) { return !!state && state[0] === "o"; };
|
|
1077
1079
|
var batchedUpdates = reactDom.unstable_batchedUpdates || (function (callback) { return callback(); });
|
|
1078
|
-
var values = Object.values || (function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); });
|
|
1079
1080
|
var floatEqual = function (a, b, diff) {
|
|
1080
1081
|
if (diff === void 0) { diff = 0.0001; }
|
|
1081
1082
|
return Math.abs(a - b) < diff;
|
|
@@ -1146,36 +1147,6 @@ function commonProps(isDisabled, isHovering) {
|
|
|
1146
1147
|
}
|
|
1147
1148
|
var indexOfNode = function (nodeList, node) { return lodashEs.findIndex(nodeList, node); };
|
|
1148
1149
|
|
|
1149
|
-
var stylePropTypes = function (name) {
|
|
1150
|
-
var _a;
|
|
1151
|
-
return (_a = {},
|
|
1152
|
-
_a[name ? "".concat(name, "ClassName") : "className"] = propTypes.oneOfType([propTypes.string, propTypes.func]),
|
|
1153
|
-
_a);
|
|
1154
|
-
};
|
|
1155
|
-
var Direction = propTypes.oneOf(["left", "right", "top", "bottom"]);
|
|
1156
|
-
// Menu, SubMenu and ControlledMenu
|
|
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"]) });
|
|
1158
|
-
// Menu and ControlledMenu
|
|
1159
|
-
var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps: propTypes.object, initialMounted: propTypes.bool, unmountOnClose: propTypes.bool, transition: propTypes.oneOfType([
|
|
1160
|
-
propTypes.bool,
|
|
1161
|
-
propTypes.exact({
|
|
1162
|
-
open: propTypes.bool,
|
|
1163
|
-
close: propTypes.bool,
|
|
1164
|
-
item: propTypes.bool
|
|
1165
|
-
}),
|
|
1166
|
-
]), transitionTimeout: propTypes.number, boundingBoxRef: propTypes.object, boundingBoxPadding: propTypes.string, reposition: propTypes.oneOf(["auto", "initial"]), repositionFlag: propTypes.oneOfType([propTypes.string, propTypes.number]), viewScroll: propTypes.oneOf(["auto", "close", "initial"]), submenuOpenDelay: propTypes.number, submenuCloseDelay: propTypes.number, portal: propTypes.oneOfType([
|
|
1167
|
-
propTypes.bool,
|
|
1168
|
-
propTypes.exact({
|
|
1169
|
-
target: propTypes.object,
|
|
1170
|
-
stablePosition: propTypes.bool
|
|
1171
|
-
}),
|
|
1172
|
-
]), theming: propTypes.string, onItemClick: propTypes.func });
|
|
1173
|
-
// Menu and SubMenu
|
|
1174
|
-
({
|
|
1175
|
-
instanceRef: propTypes.oneOfType([propTypes.object, propTypes.func]),
|
|
1176
|
-
onMenuChange: propTypes.func
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
1150
|
var withHovering = function (name, WrappedComponent) {
|
|
1180
1151
|
var Component = react.memo(WrappedComponent);
|
|
1181
1152
|
var WithHovering = react.forwardRef(function (props, ref) {
|
|
@@ -1390,17 +1361,17 @@ var useMenuStateAndFocus = function (options) {
|
|
|
1390
1361
|
return [__assign({ menuItemFocus: menuItemFocus }, menuProps), toggleMenu, openMenu];
|
|
1391
1362
|
};
|
|
1392
1363
|
|
|
1393
|
-
react.forwardRef(function MenuButton(_a, ref) {
|
|
1364
|
+
var MenuButton = react.forwardRef(function MenuButton(_a, ref) {
|
|
1394
1365
|
var className = _a.className, isOpen = _a.isOpen, disabled = _a.disabled, children = _a.children, restProps = __rest(_a, ["className", "isOpen", "disabled", "children"]);
|
|
1395
1366
|
var modifiers = react.useMemo(function () { return ({ open: isOpen }); }, [isOpen]);
|
|
1396
1367
|
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 })));
|
|
1397
1368
|
});
|
|
1398
1369
|
|
|
1399
1370
|
var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBoxPadding) {
|
|
1400
|
-
var _a;
|
|
1371
|
+
var _a, _b, _c;
|
|
1401
1372
|
var menuRect = menuRef.current.getBoundingClientRect();
|
|
1402
|
-
var
|
|
1403
|
-
var
|
|
1373
|
+
var thisWindow = (_b = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.defaultView) !== null && _b !== void 0 ? _b : window;
|
|
1374
|
+
var containerRect = ((_c = containerRef.current) !== null && _c !== void 0 ? _c : thisWindow.document.body).getBoundingClientRect();
|
|
1404
1375
|
var boundingRect = menuScroll === window || menuScroll === thisWindow
|
|
1405
1376
|
? {
|
|
1406
1377
|
left: 0,
|
|
@@ -1751,7 +1722,7 @@ var MenuList = function (_a) {
|
|
|
1751
1722
|
endTransition && safeCall(endTransition);
|
|
1752
1723
|
};
|
|
1753
1724
|
var handlePosition = react.useCallback(function (noOverflowCheck) {
|
|
1754
|
-
if (!containerRef.current) {
|
|
1725
|
+
if (!(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current)) {
|
|
1755
1726
|
if (process.env.NODE_ENV !== "production") {
|
|
1756
1727
|
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');
|
|
1757
1728
|
}
|
|
@@ -1950,10 +1921,27 @@ var MenuList = function (_a) {
|
|
|
1950
1921
|
else if (captureFocus) {
|
|
1951
1922
|
// Use a timeout here because if set focus immediately, page might scroll unexpectedly.
|
|
1952
1923
|
var id_1 = setTimeout(function () {
|
|
1953
|
-
var _a;
|
|
1924
|
+
var _a, _b, _c;
|
|
1954
1925
|
// If focus has already been set to a children element, don't set focus on menu or item
|
|
1955
1926
|
if (!menuRef.current.contains(document.activeElement)) {
|
|
1956
|
-
|
|
1927
|
+
// Handle popover portal focus
|
|
1928
|
+
var popupElement = (_a = focusRef.current) === null || _a === void 0 ? void 0 : _a.nextSibling;
|
|
1929
|
+
if (popupElement instanceof Element) {
|
|
1930
|
+
var input = popupElement.querySelectorAll("input,textarea")[0];
|
|
1931
|
+
if (input) {
|
|
1932
|
+
input.focus();
|
|
1933
|
+
// Text areas should start at end
|
|
1934
|
+
if (input instanceof HTMLTextAreaElement) {
|
|
1935
|
+
input.selectionStart = input.value.length;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
else {
|
|
1939
|
+
(_b = focusRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
else {
|
|
1943
|
+
(_c = focusRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1944
|
+
}
|
|
1957
1945
|
setItemFocus();
|
|
1958
1946
|
}
|
|
1959
1947
|
}, openTransition ? 170 : 100);
|
|
@@ -1996,9 +1984,9 @@ var MenuList = function (_a) {
|
|
|
1996
1984
|
return (jsxRuntime.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: [jsxRuntime.jsx("div", { ref: focusRef, tabIndex: -1, style: { position: "absolute", left: 0, top: 0 } }), arrow && (jsxRuntime.jsx("div", { className: _arrowClass, style: __assign(__assign({}, arrowStyle), { position: "absolute", left: arrowPosition.x, top: arrowPosition.y }), ref: arrowRef })), jsxRuntime.jsx(MenuListContext.Provider, __assign({ value: listContext }, { children: jsxRuntime.jsx(MenuListItemContext.Provider, __assign({ value: itemContext }, { children: jsxRuntime.jsx(HoverItemContext.Provider, __assign({ value: hoverItem }, { children: children })) })) }))] })));
|
|
1997
1985
|
};
|
|
1998
1986
|
|
|
1999
|
-
var
|
|
1987
|
+
var ControlledMenuFr = function (_a, externalRef) {
|
|
2000
1988
|
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"]);
|
|
2001
|
-
var containerRef = react.useRef(
|
|
1989
|
+
var containerRef = react.useRef();
|
|
2002
1990
|
var scrollNodesRef = react.useRef({});
|
|
2003
1991
|
var anchorRef = restProps.anchorRef, state = restProps.state;
|
|
2004
1992
|
var settings = react.useMemo(function () { return ({
|
|
@@ -2036,7 +2024,7 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2036
2024
|
// the cell doesn't refresh during update if save is invoked from a native event
|
|
2037
2025
|
// This doesn't happen in React18
|
|
2038
2026
|
// To work around it, I invoke the save by clicking on a passed in invisible button ref
|
|
2039
|
-
if (saveButtonRef.current)
|
|
2027
|
+
if (saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current)
|
|
2040
2028
|
saveButtonRef.current.click();
|
|
2041
2029
|
else
|
|
2042
2030
|
safeCall(onClose, { reason: CloseReason.BLUR });
|
|
@@ -2051,7 +2039,7 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2051
2039
|
setTimeout(function () { return (skipOpen.current = false); }, 300);
|
|
2052
2040
|
}
|
|
2053
2041
|
}
|
|
2054
|
-
}, [clickIsWithinMenu, onClose]);
|
|
2042
|
+
}, [clickIsWithinMenu, onClose, saveButtonRef, skipOpen]);
|
|
2055
2043
|
var handleScreenEventForCancel = react.useCallback(function (ev) {
|
|
2056
2044
|
if (!clickIsWithinMenu(ev)) {
|
|
2057
2045
|
ev.preventDefault();
|
|
@@ -2060,7 +2048,7 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2060
2048
|
}, [clickIsWithinMenu]);
|
|
2061
2049
|
react.useEffect(function () {
|
|
2062
2050
|
if (isMenuOpen(state)) {
|
|
2063
|
-
var thisDocument_1 = anchorRef.current ? anchorRef.current.ownerDocument : document;
|
|
2051
|
+
var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
|
|
2064
2052
|
thisDocument_1.addEventListener("mousedown", handleScreenEventForCancel, true);
|
|
2065
2053
|
thisDocument_1.addEventListener("mouseup", handleScreenEventForSave, true);
|
|
2066
2054
|
thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
|
|
@@ -2073,13 +2061,13 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2073
2061
|
};
|
|
2074
2062
|
}
|
|
2075
2063
|
return function () { };
|
|
2076
|
-
}, [handleScreenEventForSave, handleScreenEventForCancel, state]);
|
|
2064
|
+
}, [handleScreenEventForSave, handleScreenEventForCancel, state, anchorRef]);
|
|
2077
2065
|
var itemSettings = react.useMemo(function () { return ({
|
|
2078
2066
|
submenuOpenDelay: submenuOpenDelay,
|
|
2079
2067
|
submenuCloseDelay: submenuCloseDelay
|
|
2080
2068
|
}); }, [submenuOpenDelay, submenuCloseDelay]);
|
|
2081
2069
|
var eventHandlers = react.useMemo(function () { return ({
|
|
2082
|
-
handleClick: function (event,
|
|
2070
|
+
handleClick: function (event, isCheckOrRadio) {
|
|
2083
2071
|
if (!event.stopPropagation)
|
|
2084
2072
|
safeCall(onItemClick, event);
|
|
2085
2073
|
var keepOpen = event.keepOpen;
|
|
@@ -2087,7 +2075,7 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2087
2075
|
// if event.keepOpen is undefined, the following default behaviour is used
|
|
2088
2076
|
// According to WAI-ARIA Authoring Practices 1.1
|
|
2089
2077
|
// Keep menu open when check or radio is invoked by SPACE key
|
|
2090
|
-
keepOpen =
|
|
2078
|
+
keepOpen = isCheckOrRadio && event.key === Keys.SPACE;
|
|
2091
2079
|
}
|
|
2092
2080
|
if (!keepOpen) {
|
|
2093
2081
|
safeCall(onClose, {
|
|
@@ -2115,7 +2103,7 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2115
2103
|
// If a user clicks on the menu button when a menu is open, we need to close the menu.
|
|
2116
2104
|
// However, a blur event will be fired prior to the click event on menu button,
|
|
2117
2105
|
// which makes the menu first close and then open again.
|
|
2118
|
-
// If this
|
|
2106
|
+
// If this happens, e.relatedTarget is incorrectly set to null instead of the button in Safari and Firefox,
|
|
2119
2107
|
// and makes it difficult to determine whether onBlur is fired because of clicking on menu button.
|
|
2120
2108
|
// This is a workaround approach which sets a flag to skip a following click event.
|
|
2121
2109
|
if (skipOpen) {
|
|
@@ -2131,24 +2119,22 @@ var ControlledMenu = react.forwardRef(function ControlledMenu(_a, externalRef) {
|
|
|
2131
2119
|
modifiers: modifiers,
|
|
2132
2120
|
className: className
|
|
2133
2121
|
}), style: __assign(__assign({}, containerProps === null || containerProps === void 0 ? void 0 : containerProps.style), { position: "relative" }), ref: containerRef }, { children: state && (jsxRuntime.jsx(SettingsContext.Provider, __assign({ value: settings }, { children: jsxRuntime.jsx(ItemSettingsContext.Provider, __assign({ value: itemSettings }, { children: jsxRuntime.jsx(EventHandlersContext.Provider, __assign({ value: eventHandlers }, { children: jsxRuntime.jsx(MenuList, __assign({}, restProps, { ariaLabel: ariaLabel || "Menu", externalRef: externalRef, containerRef: containerRef, onClose: onClose })) })) })) }))) })));
|
|
2134
|
-
if (portal === true && anchorRef.current !== undefined) {
|
|
2122
|
+
if (portal === true && (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) !== undefined) {
|
|
2135
2123
|
portal = { target: anchorRef.current.ownerDocument.body };
|
|
2136
2124
|
}
|
|
2137
|
-
if (portal
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2125
|
+
if (portal) {
|
|
2126
|
+
if (typeof portal === "boolean") {
|
|
2127
|
+
if (portal && typeof document !== "undefined") {
|
|
2128
|
+
return reactDom.createPortal(menuList, document.body);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
else {
|
|
2132
|
+
return portal.target ? reactDom.createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
|
|
2133
|
+
}
|
|
2142
2134
|
}
|
|
2143
2135
|
return menuList;
|
|
2144
|
-
}
|
|
2145
|
-
ControlledMenu
|
|
2146
|
-
x: propTypes.number,
|
|
2147
|
-
y: propTypes.number
|
|
2148
|
-
}), anchorRef: propTypes.object, skipOpen: propTypes.object, captureFocus: propTypes.bool, menuItemFocus: propTypes.exact({
|
|
2149
|
-
position: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
|
2150
|
-
alwaysUpdate: propTypes.bool
|
|
2151
|
-
}), onClose: propTypes.func });
|
|
2136
|
+
};
|
|
2137
|
+
var ControlledMenu = react.forwardRef(ControlledMenuFr);
|
|
2152
2138
|
|
|
2153
2139
|
function MenuFr(_a, externalRef) {
|
|
2154
2140
|
var ariaLabel = _a["aria-label"], menuButton = _a.menuButton, instanceRef = _a.instanceRef, onMenuChange = _a.onMenuChange, restProps = __rest(_a, ["aria-label", "menuButton", "instanceRef", "onMenuChange"]);
|
|
@@ -2196,7 +2182,7 @@ function MenuFr(_a, externalRef) {
|
|
|
2196
2182
|
}); });
|
|
2197
2183
|
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 }))] }));
|
|
2198
2184
|
}
|
|
2199
|
-
react.forwardRef(MenuFr);
|
|
2185
|
+
var Menu = react.forwardRef(MenuFr);
|
|
2200
2186
|
|
|
2201
2187
|
var SubMenuFr = function (_a) {
|
|
2202
2188
|
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"]);
|
|
@@ -2338,7 +2324,7 @@ var SubMenuFr = function (_a) {
|
|
|
2338
2324
|
className: itemClassName
|
|
2339
2325
|
}) }, { children: react.useMemo(function () { return safeCall(label, modifiers); }, [label, modifiers]) })), state && getMenuList()] })));
|
|
2340
2326
|
};
|
|
2341
|
-
withHovering("SubMenu", SubMenuFr);
|
|
2327
|
+
var SubMenu = withHovering("SubMenu", SubMenuFr);
|
|
2342
2328
|
|
|
2343
2329
|
var MenuItemFr = function (_a) {
|
|
2344
2330
|
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"]);
|
|
@@ -2407,7 +2393,6 @@ var MenuItemFr = function (_a) {
|
|
|
2407
2393
|
return jsxRuntime.jsx("li", __assign({}, menuItemProps));
|
|
2408
2394
|
}
|
|
2409
2395
|
};
|
|
2410
|
-
// FIXME matt as any
|
|
2411
2396
|
var MenuItem = withHovering("MenuItem", MenuItemFr);
|
|
2412
2397
|
|
|
2413
2398
|
var FocusableItemFr = function (_a) {
|
|
@@ -2439,7 +2424,7 @@ var MenuHeaderFr = function (_a, externalRef) {
|
|
|
2439
2424
|
var className = _a.className, restProps = __rest(_a, ["className"]);
|
|
2440
2425
|
return (jsxRuntime.jsx("li", __assign({ role: "presentation" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuHeaderClass, className: className }) })));
|
|
2441
2426
|
};
|
|
2442
|
-
react.memo(react.forwardRef(MenuHeaderFr));
|
|
2427
|
+
var MenuHeader = react.memo(react.forwardRef(MenuHeaderFr));
|
|
2443
2428
|
|
|
2444
2429
|
var MenuGroupFr = function (_a, externalRef) {
|
|
2445
2430
|
var className = _a.className, style = _a.style, takeOverflow = _a.takeOverflow, restProps = __rest(_a, ["className", "style", "takeOverflow"]);
|
|
@@ -2462,14 +2447,14 @@ var MenuGroupFr = function (_a, externalRef) {
|
|
|
2462
2447
|
}, [overflowStyle]);
|
|
2463
2448
|
return (jsxRuntime.jsx("div", __assign({}, restProps, { ref: useCombinedRef(externalRef, ref), className: useBEM({ block: menuClass, element: menuGroupClass, className: className }), style: __assign(__assign({}, style), overflowStyle) })));
|
|
2464
2449
|
};
|
|
2465
|
-
react.forwardRef(MenuGroupFr);
|
|
2450
|
+
var MenuGroup = react.forwardRef(MenuGroupFr);
|
|
2466
2451
|
|
|
2467
2452
|
var MenuRadioGroupFr = function (_a, externalRef) {
|
|
2468
2453
|
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"]);
|
|
2469
2454
|
var contextValue = react.useMemo(function () { return ({ name: name, value: value, onRadioChange: onRadioChange }); }, [name, value, onRadioChange]);
|
|
2470
2455
|
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 }) })) })) })));
|
|
2471
2456
|
};
|
|
2472
|
-
react.forwardRef(MenuRadioGroupFr);
|
|
2457
|
+
var MenuRadioGroup = react.forwardRef(MenuRadioGroupFr);
|
|
2473
2458
|
|
|
2474
2459
|
var useGridPopoverHook = function (props, save) {
|
|
2475
2460
|
var cellEditorParams = props.cellEditorParams, saving = props.saving, updateValue = props.updateValue;
|
|
@@ -2523,7 +2508,18 @@ var GridRenderPopoutMenuCell = function (props) {
|
|
|
2523
2508
|
var _a, _b, _c;
|
|
2524
2509
|
var checkUpdating = react.useContext(UpdatingContext).checkUpdating;
|
|
2525
2510
|
var isLoading = checkUpdating((_b = (_a = props.colDef) === null || _a === void 0 ? void 0 : _a.field) !== null && _b !== void 0 ? _b : "", props.data.id);
|
|
2526
|
-
var
|
|
2511
|
+
var editable = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.editable;
|
|
2512
|
+
var disabled = !(typeof editable === "function"
|
|
2513
|
+
? editable({
|
|
2514
|
+
node: props.node,
|
|
2515
|
+
data: props.data,
|
|
2516
|
+
column: props.column,
|
|
2517
|
+
colDef: props.colDef,
|
|
2518
|
+
api: props.api,
|
|
2519
|
+
columnApi: props.columnApi,
|
|
2520
|
+
context: props.context
|
|
2521
|
+
})
|
|
2522
|
+
: editable);
|
|
2527
2523
|
return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: isLoading, className: disabled ? "GridPopoutMenu-burgerDisabled" : "GridPopoutMenu-burger" }, { children: jsxRuntime.jsx(lui.LuiIcon, { name: "ic_more_vert", alt: "More actions", size: "md" }) })));
|
|
2528
2524
|
};
|
|
2529
2525
|
|
|
@@ -2606,7 +2602,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
2606
2602
|
return undefined;
|
|
2607
2603
|
}
|
|
2608
2604
|
var str = option.label || "";
|
|
2609
|
-
return str.toLowerCase().indexOf(filter) === -1 ? option.value : undefined;
|
|
2605
|
+
return str.toLowerCase().indexOf(filter.trim()) === -1 ? option.value : undefined;
|
|
2610
2606
|
})
|
|
2611
2607
|
.filter(function (r) { return r !== undefined; }));
|
|
2612
2608
|
}, [formProps.filtered, filter, options]);
|
|
@@ -2614,35 +2610,48 @@ var GridFormMultiSelect = function (props) {
|
|
|
2614
2610
|
var _b;
|
|
2615
2611
|
var ref = _a.ref;
|
|
2616
2612
|
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: "", onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
|
|
2617
|
-
} })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
2613
|
+
} }), "filter"), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
2618
2614
|
var _a;
|
|
2619
|
-
return item.value === MenuSeparatorString$1 ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs(
|
|
2620
|
-
// FIXME Matt Event type guessed here
|
|
2615
|
+
return item.value === MenuSeparatorString$1 ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
|
|
2621
2616
|
e.keepOpen = true;
|
|
2622
|
-
if (selectedValues.includes(
|
|
2617
|
+
if (selectedValues.includes(item.value)) {
|
|
2623
2618
|
setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
|
|
2624
2619
|
}
|
|
2625
2620
|
else {
|
|
2626
2621
|
setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
|
|
2627
2622
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
if (e.
|
|
2633
|
-
|
|
2623
|
+
}, onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2624
|
+
return __generator(this, function (_a) {
|
|
2625
|
+
if (e.key === "Enter")
|
|
2626
|
+
triggerSave().then();
|
|
2627
|
+
else if (e.key === " ") {
|
|
2628
|
+
if (selectedValues.includes(item.value)) {
|
|
2629
|
+
setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
|
|
2630
|
+
}
|
|
2631
|
+
else {
|
|
2632
|
+
setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
|
|
2633
|
+
}
|
|
2634
|
+
e.preventDefault();
|
|
2635
|
+
e.stopPropagation();
|
|
2634
2636
|
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
+
return [2 /*return*/];
|
|
2638
|
+
});
|
|
2639
|
+
}); } }, { 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)), inputProps: {
|
|
2640
|
+
onClick: function (e) {
|
|
2641
|
+
e.preventDefault();
|
|
2642
|
+
e.stopPropagation();
|
|
2643
|
+
return false;
|
|
2637
2644
|
}
|
|
2638
|
-
}
|
|
2645
|
+
}, onChange: function () {
|
|
2646
|
+
/*Do nothing, change handled by menuItem*/
|
|
2647
|
+
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
|
|
2639
2648
|
return item.subComponent &&
|
|
2640
2649
|
item.subComponent({
|
|
2641
2650
|
setValue: function (value) {
|
|
2642
2651
|
subSelectedValues.current[item.value] = value;
|
|
2643
2652
|
}
|
|
2644
2653
|
}, ref);
|
|
2645
|
-
} }), "".concat(item.value, "_subcomponent")))] }));
|
|
2654
|
+
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
2646
2655
|
})] })) })));
|
|
2647
2656
|
};
|
|
2648
2657
|
|
|
@@ -3192,6 +3201,8 @@ var GridPopoverTextInput = function (colDef) {
|
|
|
3192
3201
|
};
|
|
3193
3202
|
|
|
3194
3203
|
exports.ComponentLoadingWrapper = ComponentLoadingWrapper;
|
|
3204
|
+
exports.ControlledMenu = ControlledMenu;
|
|
3205
|
+
exports.FocusableItem = FocusableItem;
|
|
3195
3206
|
exports.GenericMultiEditCellClass = GenericMultiEditCellClass;
|
|
3196
3207
|
exports.Grid = Grid;
|
|
3197
3208
|
exports.GridCell = GridCell;
|
|
@@ -3217,6 +3228,14 @@ exports.GridPopoverTextArea = GridPopoverTextArea;
|
|
|
3217
3228
|
exports.GridPopoverTextInput = GridPopoverTextInput;
|
|
3218
3229
|
exports.GridRenderPopoutMenuCell = GridRenderPopoutMenuCell;
|
|
3219
3230
|
exports.GridRendererGenericCell = GridRendererGenericCell;
|
|
3231
|
+
exports.Menu = Menu;
|
|
3232
|
+
exports.MenuButton = MenuButton;
|
|
3233
|
+
exports.MenuDivider = MenuDivider;
|
|
3234
|
+
exports.MenuGroup = MenuGroup;
|
|
3235
|
+
exports.MenuHeader = MenuHeader;
|
|
3236
|
+
exports.MenuItem = MenuItem;
|
|
3237
|
+
exports.MenuRadioGroup = MenuRadioGroup;
|
|
3238
|
+
exports.SubMenu = SubMenu;
|
|
3220
3239
|
exports.TextAreaInput = TextAreaInput;
|
|
3221
3240
|
exports.TextInputFormatted = TextInputFormatted;
|
|
3222
3241
|
exports.UpdatingContext = UpdatingContext;
|
|
@@ -3230,6 +3249,7 @@ exports.hasParentClass = hasParentClass;
|
|
|
3230
3249
|
exports.isFloat = isFloat;
|
|
3231
3250
|
exports.isNotEmpty = isNotEmpty;
|
|
3232
3251
|
exports.useGridPopoverHook = useGridPopoverHook;
|
|
3252
|
+
exports.useMenuState = useMenuState;
|
|
3233
3253
|
exports.usePostSortRowsHook = usePostSortRowsHook;
|
|
3234
3254
|
exports.wait = wait;
|
|
3235
3255
|
//# sourceMappingURL=index.js.map
|