@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.
- package/dist/index.js +195 -163
- package/dist/index.js.map +1 -1
- package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -1
- package/dist/src/react-menu3/components/Menu.d.ts +16 -2
- package/dist/src/react-menu3/components/MenuButton.d.ts +8 -1
- package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -2
- package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -2
- package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -2
- package/dist/src/react-menu3/components/MenuItem.d.ts +59 -1
- package/dist/src/react-menu3/components/MenuList.d.ts +57 -30
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +44 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +110 -1
- package/dist/src/react-menu3/hooks/useBEM.d.ts +4 -3
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemState.d.ts +4 -3
- package/dist/src/react-menu3/hooks/useItems.d.ts +6 -4
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -1
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +13 -10
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -10
- package/dist/src/react-menu3/index.d.ts +391 -0
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +10 -9
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +7 -6
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +7 -6
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +17 -19
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +18 -20
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +11 -6
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +23 -18
- package/dist/src/react-menu3/utils/constants.d.ts +51 -9
- package/dist/src/react-menu3/utils/propTypes.d.ts +1 -0
- package/dist/src/react-menu3/utils/utils.d.ts +19 -10
- package/dist/src/react-menu3/utils/withHovering.d.ts +7 -1
- package/dist/src/stories/components/ReactMenu.stories.d.ts +8 -0
- package/dist/step-ag-grid.esm.js +197 -165
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +11 -11
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +10 -4
- package/src/react-menu3/components/ControlledMenu.tsx +2 -1
- package/src/react-menu3/components/FocusableItem.tsx +58 -53
- package/src/react-menu3/components/Menu.tsx +40 -28
- package/src/react-menu3/components/MenuButton.tsx +30 -29
- package/src/react-menu3/components/MenuDivider.tsx +14 -18
- package/src/react-menu3/components/MenuGroup.tsx +25 -16
- package/src/react-menu3/components/MenuHeader.tsx +14 -18
- package/src/react-menu3/components/MenuItem.tsx +159 -106
- package/src/react-menu3/components/MenuList.tsx +104 -36
- package/src/react-menu3/components/MenuRadioGroup.tsx +54 -15
- package/src/react-menu3/components/SubMenu.tsx +307 -201
- package/src/react-menu3/hooks/useBEM.ts +4 -3
- package/src/react-menu3/hooks/useCombinedRef.ts +6 -12
- package/src/react-menu3/hooks/useItemEffect.ts +6 -5
- package/src/react-menu3/hooks/useItemState.ts +16 -12
- package/src/react-menu3/hooks/useItems.ts +11 -10
- package/src/react-menu3/hooks/useMenuChange.ts +3 -3
- package/src/react-menu3/hooks/useMenuState.ts +25 -7
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +6 -4
- package/src/react-menu3/index.d.ts +1 -0
- package/src/react-menu3/index.ts +431 -0
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +18 -11
- package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +12 -5
- package/src/react-menu3/positionUtils/placeArrowVertical.ts +12 -5
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +33 -17
- package/src/react-menu3/positionUtils/placeToporBottom.ts +34 -18
- package/src/react-menu3/positionUtils/positionContextMenu.ts +15 -3
- package/src/react-menu3/positionUtils/positionMenu.ts +21 -14
- package/src/react-menu3/style-utils/index.ts +10 -7
- package/src/react-menu3/utils/constants.ts +63 -10
- package/src/react-menu3/utils/propTypes.ts +3 -1
- package/src/react-menu3/utils/utils.ts +40 -23
- package/src/react-menu3/utils/withHovering.tsx +11 -6
- package/src/stories/components/ReactMenu.stories.tsx +37 -0
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createContext, useRef, useContext, useCallback, useState, useEffect, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { castArray, remove, flatten, isEmpty, delay, sortBy, last, difference, xorBy } from 'lodash-es';
|
|
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 { object, bool, number,
|
|
7
|
+
import { oneOf, object, bool, number, string, oneOfType, exact, func } from 'prop-types';
|
|
8
8
|
import { useTransition } from 'react-transition-state';
|
|
9
9
|
import debounce from 'debounce-promise';
|
|
10
10
|
import { v4 } from 'uuid';
|
|
@@ -983,10 +983,6 @@ var setRef = function (ref, instance) {
|
|
|
983
983
|
};
|
|
984
984
|
var useCombinedRef = function (refA, refB) {
|
|
985
985
|
return useMemo(function () {
|
|
986
|
-
if (!refA)
|
|
987
|
-
return refB;
|
|
988
|
-
if (!refB)
|
|
989
|
-
return refA;
|
|
990
986
|
return function (instance) {
|
|
991
987
|
setRef(refA, instance);
|
|
992
988
|
setRef(refB, instance);
|
|
@@ -1004,7 +1000,6 @@ var useIsomorphicLayoutEffect = typeof window !== "undefined" &&
|
|
|
1004
1000
|
? useLayoutEffect
|
|
1005
1001
|
: useEffect;
|
|
1006
1002
|
|
|
1007
|
-
// @ts-nocheck
|
|
1008
1003
|
var menuContainerClass = "szh-menu-container";
|
|
1009
1004
|
var menuClass = "szh-menu";
|
|
1010
1005
|
var menuButtonClass = "szh-menu-button";
|
|
@@ -1015,13 +1010,23 @@ var menuHeaderClass = "header";
|
|
|
1015
1010
|
var menuGroupClass = "group";
|
|
1016
1011
|
var subMenuClass = "submenu";
|
|
1017
1012
|
var radioGroupClass = "radio-group";
|
|
1018
|
-
var HoverItemContext = createContext();
|
|
1019
|
-
var MenuListItemContext = createContext({
|
|
1013
|
+
var HoverItemContext = createContext(undefined);
|
|
1014
|
+
var MenuListItemContext = createContext({
|
|
1015
|
+
dispatch: function () { },
|
|
1016
|
+
updateItems: function () { },
|
|
1017
|
+
setOpenSubmenuCount: function () { return 0; }
|
|
1018
|
+
});
|
|
1020
1019
|
var MenuListContext = createContext({});
|
|
1021
|
-
var EventHandlersContext = createContext({
|
|
1020
|
+
var EventHandlersContext = createContext({
|
|
1021
|
+
handleClick: function () { }
|
|
1022
|
+
});
|
|
1022
1023
|
var RadioGroupContext = createContext({});
|
|
1024
|
+
// FIXME hacking a default context in here is probably bad
|
|
1023
1025
|
var SettingsContext = createContext({});
|
|
1024
|
-
var ItemSettingsContext = createContext({
|
|
1026
|
+
var ItemSettingsContext = createContext({
|
|
1027
|
+
submenuOpenDelay: 0,
|
|
1028
|
+
submenuCloseDelay: 0
|
|
1029
|
+
});
|
|
1025
1030
|
var Keys = Object.freeze({
|
|
1026
1031
|
ENTER: "Enter",
|
|
1027
1032
|
ESC: "Escape",
|
|
@@ -1060,7 +1065,6 @@ var MenuStateMap = Object.freeze({
|
|
|
1060
1065
|
exited: "closed"
|
|
1061
1066
|
});
|
|
1062
1067
|
|
|
1063
|
-
// @ts-nocheck
|
|
1064
1068
|
var isMenuOpen = function (state) { return !!state && state[0] === "o"; };
|
|
1065
1069
|
var batchedUpdates = unstable_batchedUpdates || (function (callback) { return callback(); });
|
|
1066
1070
|
var values = Object.values || (function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); });
|
|
@@ -1071,10 +1075,11 @@ var floatEqual = function (a, b, diff) {
|
|
|
1071
1075
|
var getTransition = function (transition, name) {
|
|
1072
1076
|
return transition === true || !!(transition && transition[name]);
|
|
1073
1077
|
};
|
|
1074
|
-
|
|
1078
|
+
function safeCall(fn, arg) {
|
|
1079
|
+
return typeof fn === "function" ? fn(arg) : fn;
|
|
1080
|
+
}
|
|
1075
1081
|
var internalKey = "_szhsinMenu";
|
|
1076
1082
|
var getName = function (component) { return component[internalKey]; };
|
|
1077
|
-
var defineName = function (name, component) { return Object.defineProperty(component, internalKey, { value: name }); };
|
|
1078
1083
|
var mergeProps = function (target, source) {
|
|
1079
1084
|
source &&
|
|
1080
1085
|
Object.keys(source).forEach(function (key) {
|
|
@@ -1097,7 +1102,7 @@ var mergeProps = function (target, source) {
|
|
|
1097
1102
|
return target;
|
|
1098
1103
|
};
|
|
1099
1104
|
var parsePadding = function (paddingStr) {
|
|
1100
|
-
if (
|
|
1105
|
+
if (paddingStr == null)
|
|
1101
1106
|
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
1102
1107
|
var padding = paddingStr.trim().split(/\s+/, 4).map(parseFloat);
|
|
1103
1108
|
var top = !isNaN(padding[0]) ? padding[0] : 0;
|
|
@@ -1111,15 +1116,19 @@ var parsePadding = function (paddingStr) {
|
|
|
1111
1116
|
};
|
|
1112
1117
|
// Adapted from https://github.com/popperjs/popper-core/tree/v2.9.1/src/dom-utils
|
|
1113
1118
|
var getScrollAncestor = function (node) {
|
|
1114
|
-
var
|
|
1119
|
+
var _a, _b, _c;
|
|
1120
|
+
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;
|
|
1115
1121
|
while (node) {
|
|
1116
1122
|
node = node.parentNode;
|
|
1117
|
-
if (!node || node === thisWindow.document.body)
|
|
1118
|
-
return;
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1123
|
+
if (!node || node === ((_c = thisWindow === null || thisWindow === void 0 ? void 0 : thisWindow.document) === null || _c === void 0 ? void 0 : _c.body))
|
|
1124
|
+
return null;
|
|
1125
|
+
if (node instanceof Element) {
|
|
1126
|
+
var _d = thisWindow.getComputedStyle(node), overflow = _d.overflow, overflowX = _d.overflowX, overflowY = _d.overflowY;
|
|
1127
|
+
if (/auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX))
|
|
1128
|
+
return node;
|
|
1129
|
+
}
|
|
1122
1130
|
}
|
|
1131
|
+
return null;
|
|
1123
1132
|
};
|
|
1124
1133
|
function commonProps(isDisabled, isHovering) {
|
|
1125
1134
|
return {
|
|
@@ -1127,13 +1136,7 @@ function commonProps(isDisabled, isHovering) {
|
|
|
1127
1136
|
tabIndex: isHovering ? 0 : -1
|
|
1128
1137
|
};
|
|
1129
1138
|
}
|
|
1130
|
-
function
|
|
1131
|
-
for (var i = 0; i < nodeList.length; i++) {
|
|
1132
|
-
if (nodeList[i] === node)
|
|
1133
|
-
return i;
|
|
1134
|
-
}
|
|
1135
|
-
return -1;
|
|
1136
|
-
}
|
|
1139
|
+
var indexOfNode = function (nodeList, node) { return findIndex(nodeList, node); };
|
|
1137
1140
|
|
|
1138
1141
|
var stylePropTypes = function (name) {
|
|
1139
1142
|
var _a;
|
|
@@ -1141,8 +1144,9 @@ var stylePropTypes = function (name) {
|
|
|
1141
1144
|
_a[name ? "".concat(name, "ClassName") : "className"] = oneOfType([string, func]),
|
|
1142
1145
|
_a);
|
|
1143
1146
|
};
|
|
1147
|
+
var Direction = oneOf(["left", "right", "top", "bottom"]);
|
|
1144
1148
|
// Menu, SubMenu and ControlledMenu
|
|
1145
|
-
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:
|
|
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"]) });
|
|
1146
1150
|
// Menu and ControlledMenu
|
|
1147
1151
|
var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps: object, initialMounted: bool, unmountOnClose: bool, transition: oneOfType([
|
|
1148
1152
|
bool,
|
|
@@ -1159,22 +1163,21 @@ var rootMenuPropTypes = __assign(__assign({}, menuPropTypes), { containerProps:
|
|
|
1159
1163
|
}),
|
|
1160
1164
|
]), theming: string, onItemClick: func });
|
|
1161
1165
|
// Menu and SubMenu
|
|
1162
|
-
|
|
1166
|
+
({
|
|
1163
1167
|
instanceRef: oneOfType([object, func]),
|
|
1164
1168
|
onMenuChange: func
|
|
1165
|
-
};
|
|
1169
|
+
});
|
|
1166
1170
|
|
|
1167
1171
|
var withHovering = function (name, WrappedComponent) {
|
|
1168
1172
|
var Component = memo(WrappedComponent);
|
|
1169
1173
|
var WithHovering = forwardRef(function (props, ref) {
|
|
1170
|
-
var
|
|
1171
|
-
return (jsx(Component, __assign({}, props, {
|
|
1174
|
+
var menuItemRef = useRef(null);
|
|
1175
|
+
return (jsx(Component, __assign({}, props, { menuItemRef: menuItemRef, externalRef: ref, isHovering: useContext(HoverItemContext) === menuItemRef.current })));
|
|
1172
1176
|
});
|
|
1173
1177
|
WithHovering.displayName = "WithHovering(".concat(name, ")");
|
|
1174
1178
|
return WithHovering;
|
|
1175
1179
|
};
|
|
1176
1180
|
|
|
1177
|
-
// @ts-nocheck
|
|
1178
1181
|
var useItems = function (menuRef, focusRef) {
|
|
1179
1182
|
var _a = useState(), hoverItem = _a[0], setHoverItem = _a[1];
|
|
1180
1183
|
var stateRef = useRef({
|
|
@@ -1184,6 +1187,7 @@ var useItems = function (menuRef, focusRef) {
|
|
|
1184
1187
|
});
|
|
1185
1188
|
var mutableState = stateRef.current;
|
|
1186
1189
|
var updateItems = useCallback(function (item, isMounted) {
|
|
1190
|
+
var _a;
|
|
1187
1191
|
var items = mutableState.items;
|
|
1188
1192
|
if (!item) {
|
|
1189
1193
|
mutableState.items = [];
|
|
@@ -1196,8 +1200,8 @@ var useItems = function (menuRef, focusRef) {
|
|
|
1196
1200
|
if (index > -1) {
|
|
1197
1201
|
items.splice(index, 1);
|
|
1198
1202
|
if (item.contains(document.activeElement)) {
|
|
1199
|
-
focusRef.current.focus();
|
|
1200
|
-
setHoverItem();
|
|
1203
|
+
(_a = focusRef === null || focusRef === void 0 ? void 0 : focusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1204
|
+
setHoverItem(undefined);
|
|
1201
1205
|
}
|
|
1202
1206
|
}
|
|
1203
1207
|
}
|
|
@@ -1234,6 +1238,8 @@ var useItems = function (menuRef, focusRef) {
|
|
|
1234
1238
|
newItem = items[index];
|
|
1235
1239
|
break;
|
|
1236
1240
|
case HoverActionTypes.SET_INDEX:
|
|
1241
|
+
if (typeof nextIndex !== "number")
|
|
1242
|
+
break;
|
|
1237
1243
|
sortItems();
|
|
1238
1244
|
index = nextIndex;
|
|
1239
1245
|
newItem = items[index];
|
|
@@ -1270,32 +1276,33 @@ var useItems = function (menuRef, focusRef) {
|
|
|
1270
1276
|
return { hoverItem: hoverItem, dispatch: dispatch, updateItems: updateItems };
|
|
1271
1277
|
};
|
|
1272
1278
|
|
|
1273
|
-
var useItemEffect = function (isDisabled,
|
|
1279
|
+
var useItemEffect = function (isDisabled, menuItemRef, updateItems) {
|
|
1274
1280
|
useIsomorphicLayoutEffect(function () {
|
|
1281
|
+
if (!menuItemRef)
|
|
1282
|
+
return;
|
|
1275
1283
|
if (process.env.NODE_ENV !== "production" && !updateItems) {
|
|
1276
|
-
throw new Error("[React-Menu] This menu item or submenu should be rendered under a menu: ".concat(
|
|
1284
|
+
throw new Error("[React-Menu] This menu item or submenu should be rendered under a menu: ".concat(menuItemRef.current.outerHTML));
|
|
1277
1285
|
}
|
|
1278
1286
|
if (isDisabled)
|
|
1279
1287
|
return;
|
|
1280
|
-
var item =
|
|
1288
|
+
var item = menuItemRef.current;
|
|
1281
1289
|
updateItems(item, true);
|
|
1282
1290
|
return function () {
|
|
1283
1291
|
updateItems(item);
|
|
1284
1292
|
};
|
|
1285
|
-
}, [isDisabled,
|
|
1293
|
+
}, [isDisabled, menuItemRef, updateItems]);
|
|
1286
1294
|
};
|
|
1287
1295
|
|
|
1288
|
-
// @ts-nocheck
|
|
1289
1296
|
// This hook includes some common stateful logic in MenuItem and FocusableItem
|
|
1290
|
-
var useItemState = function (
|
|
1297
|
+
var useItemState = function (menuItemRef, focusRef, isHovering, isDisabled) {
|
|
1291
1298
|
var submenuCloseDelay = useContext(ItemSettingsContext).submenuCloseDelay;
|
|
1292
1299
|
var _a = useContext(MenuListItemContext), isParentOpen = _a.isParentOpen, isSubmenuOpen = _a.isSubmenuOpen, dispatch = _a.dispatch, updateItems = _a.updateItems;
|
|
1293
|
-
var timeoutId = useRef(
|
|
1300
|
+
var timeoutId = useRef();
|
|
1294
1301
|
var setHover = function () {
|
|
1295
|
-
!isHovering && !isDisabled && dispatch(HoverActionTypes.SET,
|
|
1302
|
+
!isHovering && !isDisabled && dispatch(HoverActionTypes.SET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
|
|
1296
1303
|
};
|
|
1297
1304
|
var unsetHover = function () {
|
|
1298
|
-
!isDisabled && dispatch(HoverActionTypes.UNSET,
|
|
1305
|
+
!isDisabled && dispatch(HoverActionTypes.UNSET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
|
|
1299
1306
|
};
|
|
1300
1307
|
var onBlur = function (e) {
|
|
1301
1308
|
// Focus has moved out of the entire item
|
|
@@ -1307,7 +1314,7 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
|
|
|
1307
1314
|
if (isSubmenuOpen) {
|
|
1308
1315
|
if (!timeoutId.current)
|
|
1309
1316
|
timeoutId.current = setTimeout(function () {
|
|
1310
|
-
timeoutId.current =
|
|
1317
|
+
timeoutId.current = undefined;
|
|
1311
1318
|
setHover();
|
|
1312
1319
|
}, submenuCloseDelay);
|
|
1313
1320
|
}
|
|
@@ -1318,17 +1325,17 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
|
|
|
1318
1325
|
var onPointerLeave = function (_, keepHover) {
|
|
1319
1326
|
if (timeoutId.current) {
|
|
1320
1327
|
clearTimeout(timeoutId.current);
|
|
1321
|
-
timeoutId.current =
|
|
1328
|
+
timeoutId.current = undefined;
|
|
1322
1329
|
}
|
|
1323
1330
|
!keepHover && unsetHover();
|
|
1324
1331
|
};
|
|
1325
|
-
useItemEffect(isDisabled,
|
|
1332
|
+
useItemEffect(isDisabled, menuItemRef, updateItems);
|
|
1326
1333
|
useEffect(function () { return function () { return clearTimeout(timeoutId.current); }; }, []);
|
|
1327
1334
|
useEffect(function () {
|
|
1328
1335
|
// Don't set focus when parent menu is closed, otherwise focus will be lost
|
|
1329
1336
|
// and onBlur event will be fired with relatedTarget setting as null.
|
|
1330
1337
|
if (isHovering && isParentOpen) {
|
|
1331
|
-
focusRef.current && focusRef.current.focus();
|
|
1338
|
+
(focusRef === null || focusRef === void 0 ? void 0 : focusRef.current) && focusRef.current.focus();
|
|
1332
1339
|
}
|
|
1333
1340
|
}, [focusRef, isHovering, isParentOpen]);
|
|
1334
1341
|
return {
|
|
@@ -1339,16 +1346,18 @@ var useItemState = function (itemRef, focusRef, isHovering, isDisabled) {
|
|
|
1339
1346
|
};
|
|
1340
1347
|
};
|
|
1341
1348
|
|
|
1342
|
-
// @ts-nocheck
|
|
1343
1349
|
var useMenuChange = function (onMenuChange, isOpen) {
|
|
1344
1350
|
var prevOpen = useRef(isOpen);
|
|
1345
1351
|
useEffect(function () {
|
|
1346
|
-
if (prevOpen.current !== isOpen)
|
|
1347
|
-
safeCall(onMenuChange, { open: isOpen });
|
|
1352
|
+
if (onMenuChange && prevOpen.current !== isOpen)
|
|
1353
|
+
safeCall(onMenuChange, { open: !!isOpen });
|
|
1348
1354
|
prevOpen.current = isOpen;
|
|
1349
1355
|
}, [onMenuChange, isOpen]);
|
|
1350
1356
|
};
|
|
1351
1357
|
|
|
1358
|
+
/**
|
|
1359
|
+
* A custom Hook which helps manage the states of `ControlledMenu`.
|
|
1360
|
+
*/
|
|
1352
1361
|
var useMenuState = function (props) {
|
|
1353
1362
|
var _a = props !== null && props !== void 0 ? props : {
|
|
1354
1363
|
transition: false
|
|
@@ -1373,18 +1382,17 @@ var useMenuStateAndFocus = function (options) {
|
|
|
1373
1382
|
return [__assign({ menuItemFocus: menuItemFocus }, menuProps), toggleMenu, openMenu];
|
|
1374
1383
|
};
|
|
1375
1384
|
|
|
1376
|
-
|
|
1385
|
+
forwardRef(function MenuButton(_a, ref) {
|
|
1377
1386
|
var className = _a.className, isOpen = _a.isOpen, disabled = _a.disabled, children = _a.children, restProps = __rest(_a, ["className", "isOpen", "disabled", "children"]);
|
|
1378
1387
|
var modifiers = useMemo(function () { return ({ open: isOpen }); }, [isOpen]);
|
|
1379
1388
|
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 })));
|
|
1380
|
-
})
|
|
1381
|
-
MenuButton.propTypes = __assign(__assign({}, stylePropTypes()), { isOpen: bool, disabled: bool });
|
|
1389
|
+
});
|
|
1382
1390
|
|
|
1383
|
-
// @ts-nocheck
|
|
1384
1391
|
var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBoxPadding) {
|
|
1392
|
+
var _a;
|
|
1385
1393
|
var menuRect = menuRef.current.getBoundingClientRect();
|
|
1386
1394
|
var containerRect = containerRef.current.getBoundingClientRect();
|
|
1387
|
-
var thisWindow = containerRef.current.ownerDocument.defaultView;
|
|
1395
|
+
var thisWindow = (_a = containerRef.current.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
|
|
1388
1396
|
var boundingRect = menuScroll === window || menuScroll === thisWindow
|
|
1389
1397
|
? {
|
|
1390
1398
|
left: 0,
|
|
@@ -1399,7 +1407,9 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
|
|
|
1399
1407
|
var getLeftOverflow = function (x) { return x + containerRect.left - boundingRect.left - padding.left; };
|
|
1400
1408
|
var getRightOverflow = function (x) { return x + containerRect.left + menuRect.width - boundingRect.right + padding.right; };
|
|
1401
1409
|
var getTopOverflow = function (y) { return y + containerRect.top - boundingRect.top - padding.top; };
|
|
1402
|
-
var getBottomOverflow = function (y) {
|
|
1410
|
+
var getBottomOverflow = function (y) {
|
|
1411
|
+
return y + containerRect.top + menuRect.height - boundingRect.bottom + padding.bottom;
|
|
1412
|
+
};
|
|
1403
1413
|
var confineHorizontally = function (x) {
|
|
1404
1414
|
// If menu overflows to the left side, adjust x to have the menu contained within the viewport
|
|
1405
1415
|
// and there is no need to check the right side;
|
|
@@ -1413,7 +1423,7 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
|
|
|
1413
1423
|
if (rightOverflow > 0) {
|
|
1414
1424
|
x -= rightOverflow;
|
|
1415
1425
|
// Check again to make sure menu doesn't overflow to the left
|
|
1416
|
-
// because it may go off
|
|
1426
|
+
// because it may go off-screen and cannot be scrolled into view.
|
|
1417
1427
|
leftOverflow = getLeftOverflow(x);
|
|
1418
1428
|
if (leftOverflow < 0)
|
|
1419
1429
|
x -= leftOverflow;
|
|
@@ -1452,7 +1462,6 @@ var getPositionHelpers = function (containerRef, menuRef, menuScroll, boundingBo
|
|
|
1452
1462
|
};
|
|
1453
1463
|
};
|
|
1454
1464
|
|
|
1455
|
-
// @ts-nocheck
|
|
1456
1465
|
var positionContextMenu = function (_a) {
|
|
1457
1466
|
var positionHelpers = _a.positionHelpers, anchorPoint = _a.anchorPoint;
|
|
1458
1467
|
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;
|
|
@@ -1489,19 +1498,16 @@ var positionContextMenu = function (_a) {
|
|
|
1489
1498
|
return { x: x, y: y, computedDirection: computedDirection };
|
|
1490
1499
|
};
|
|
1491
1500
|
|
|
1492
|
-
|
|
1493
|
-
var
|
|
1494
|
-
var
|
|
1495
|
-
var y = anchorRect.top - containerRect.top - menuY + anchorRect.height / 2;
|
|
1496
|
-
var offset = arrowRef.current.offsetHeight * 1.25;
|
|
1501
|
+
var placeArrowVertical = function (p) {
|
|
1502
|
+
var y = p.anchorRect.top - p.containerRect.top - p.menuY + p.anchorRect.height / 2;
|
|
1503
|
+
var offset = p.arrowRef.current ? p.arrowRef.current.offsetHeight * 1.25 : 0;
|
|
1497
1504
|
y = Math.max(offset, y);
|
|
1498
|
-
y = Math.min(y, menuRect.height - offset);
|
|
1505
|
+
y = Math.min(y, p.menuRect.height - offset);
|
|
1499
1506
|
return y;
|
|
1500
1507
|
};
|
|
1501
1508
|
|
|
1502
|
-
|
|
1503
|
-
var
|
|
1504
|
-
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;
|
|
1509
|
+
var placeLeftorRight = function (props) {
|
|
1510
|
+
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;
|
|
1505
1511
|
var computedDirection = direction;
|
|
1506
1512
|
var y = placeLeftorRightY;
|
|
1507
1513
|
if (position !== "initial") {
|
|
@@ -1558,19 +1564,16 @@ var placeLeftorRight = function (_a) {
|
|
|
1558
1564
|
return { arrowY: arrowY, x: x, y: y, computedDirection: computedDirection };
|
|
1559
1565
|
};
|
|
1560
1566
|
|
|
1561
|
-
|
|
1562
|
-
var
|
|
1563
|
-
var
|
|
1564
|
-
var x = anchorRect.left - containerRect.left - menuX + anchorRect.width / 2;
|
|
1565
|
-
var offset = arrowRef.current.offsetWidth * 1.25;
|
|
1567
|
+
var placeArrowHorizontal = function (p) {
|
|
1568
|
+
var x = p.anchorRect.left - p.containerRect.left - p.menuX + p.anchorRect.width / 2;
|
|
1569
|
+
var offset = p.arrowRef.current ? p.arrowRef.current.offsetWidth * 1.25 : 0;
|
|
1566
1570
|
x = Math.max(offset, x);
|
|
1567
|
-
x = Math.min(x, menuRect.width - offset);
|
|
1571
|
+
x = Math.min(x, p.menuRect.width - offset);
|
|
1568
1572
|
return x;
|
|
1569
1573
|
};
|
|
1570
1574
|
|
|
1571
|
-
|
|
1572
|
-
var
|
|
1573
|
-
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;
|
|
1575
|
+
var placeToporBottom = function (props) {
|
|
1576
|
+
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;
|
|
1574
1577
|
// make sure invalid direction is treated as 'bottom'
|
|
1575
1578
|
var computedDirection = direction === "top" ? "top" : "bottom";
|
|
1576
1579
|
var x = placeToporBottomX;
|
|
@@ -1628,12 +1631,12 @@ var placeToporBottom = function (_a) {
|
|
|
1628
1631
|
return { arrowX: arrowX, x: x, y: y, computedDirection: computedDirection };
|
|
1629
1632
|
};
|
|
1630
1633
|
|
|
1631
|
-
var positionMenu = function (
|
|
1632
|
-
var arrow =
|
|
1634
|
+
var positionMenu = function (props) {
|
|
1635
|
+
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;
|
|
1633
1636
|
var menuRect = positionHelpers.menuRect, containerRect = positionHelpers.containerRect;
|
|
1634
1637
|
var horizontalOffset = offsetX;
|
|
1635
1638
|
var verticalOffset = offsetY;
|
|
1636
|
-
if (arrow) {
|
|
1639
|
+
if (arrow && arrowRef.current) {
|
|
1637
1640
|
if (direction === "left" || direction === "right") {
|
|
1638
1641
|
horizontalOffset += arrowRef.current.offsetWidth;
|
|
1639
1642
|
}
|
|
@@ -1641,7 +1644,9 @@ var positionMenu = function (_a) {
|
|
|
1641
1644
|
verticalOffset += arrowRef.current.offsetHeight;
|
|
1642
1645
|
}
|
|
1643
1646
|
}
|
|
1644
|
-
var anchorRect = anchorRef.current
|
|
1647
|
+
var anchorRect = anchorRef.current
|
|
1648
|
+
? anchorRef.current.getBoundingClientRect()
|
|
1649
|
+
: { left: 0, right: 0, top: 200, bottom: 200, width: 200, height: 200 };
|
|
1645
1650
|
var placeLeftX = anchorRect.left - containerRect.left - menuRect.width - horizontalOffset;
|
|
1646
1651
|
var placeRightX = anchorRect.right - containerRect.left + horizontalOffset;
|
|
1647
1652
|
var placeTopY = anchorRect.top - containerRect.top - menuRect.height - verticalOffset;
|
|
@@ -1676,16 +1681,16 @@ var positionMenu = function (_a) {
|
|
|
1676
1681
|
var MenuList = function (_a) {
|
|
1677
1682
|
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"]);
|
|
1678
1683
|
var _j = useState({ x: 0, y: 0 }), menuPosition = _j[0], setMenuPosition = _j[1];
|
|
1679
|
-
var _k = useState({}), arrowPosition = _k[0], setArrowPosition = _k[1];
|
|
1684
|
+
var _k = useState({ x: 0, y: 0 }), arrowPosition = _k[0], setArrowPosition = _k[1];
|
|
1680
1685
|
var _l = useState(), overflowData = _l[0], setOverflowData = _l[1];
|
|
1681
1686
|
var _m = useState(direction), expandedDirection = _m[0], setExpandedDirection = _m[1];
|
|
1682
1687
|
var _o = useState(0), openSubmenuCount = _o[0], setOpenSubmenuCount = _o[1];
|
|
1683
1688
|
var _p = useReducer(function (c) { return c + 1; }, 1), reposSubmenu = _p[0], forceReposSubmenu = _p[1];
|
|
1684
1689
|
var _q = 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;
|
|
1685
1690
|
var reposFlag = useContext(MenuListContext).reposSubmenu || repositionFlag;
|
|
1686
|
-
var menuRef = useRef(
|
|
1687
|
-
var focusRef = useRef();
|
|
1688
|
-
var arrowRef = useRef();
|
|
1691
|
+
var menuRef = useRef({});
|
|
1692
|
+
var focusRef = useRef(null);
|
|
1693
|
+
var arrowRef = useRef(null);
|
|
1689
1694
|
var prevOpen = useRef(false);
|
|
1690
1695
|
var latestMenuSize = useRef({ width: 0, height: 0 });
|
|
1691
1696
|
var latestHandlePosition = useRef(function () { });
|
|
@@ -1695,30 +1700,33 @@ var MenuList = function (_a) {
|
|
|
1695
1700
|
var closeTransition = getTransition(transition, "close");
|
|
1696
1701
|
var scrollNodes = scrollNodesRef.current;
|
|
1697
1702
|
var onKeyDown = function (e) {
|
|
1698
|
-
var
|
|
1703
|
+
var elementTarget = e.target instanceof HTMLElement ? e.target : null;
|
|
1704
|
+
var isTextInputTarget = elementTarget &&
|
|
1705
|
+
(elementTarget.nodeName === "TEXTAREA" ||
|
|
1706
|
+
(elementTarget.nodeName === "INPUT" && elementTarget.getAttribute("type") === "text"));
|
|
1699
1707
|
switch (e.key) {
|
|
1700
1708
|
case Keys.HOME:
|
|
1701
1709
|
// Don't eat home/end events on inputs
|
|
1702
1710
|
if (isTextInputTarget)
|
|
1703
1711
|
return;
|
|
1704
|
-
dispatch(HoverActionTypes.FIRST);
|
|
1712
|
+
dispatch(HoverActionTypes.FIRST, null, 0);
|
|
1705
1713
|
break;
|
|
1706
1714
|
case Keys.END:
|
|
1707
1715
|
// Don't eat home/end events on inputs
|
|
1708
1716
|
if (isTextInputTarget)
|
|
1709
1717
|
return;
|
|
1710
|
-
dispatch(HoverActionTypes.LAST);
|
|
1718
|
+
dispatch(HoverActionTypes.LAST, null, 0);
|
|
1711
1719
|
break;
|
|
1712
1720
|
case Keys.UP:
|
|
1713
|
-
dispatch(HoverActionTypes.DECREASE, hoverItem);
|
|
1721
|
+
dispatch(HoverActionTypes.DECREASE, hoverItem, 0);
|
|
1714
1722
|
break;
|
|
1715
1723
|
case Keys.DOWN:
|
|
1716
|
-
dispatch(HoverActionTypes.INCREASE, hoverItem);
|
|
1724
|
+
dispatch(HoverActionTypes.INCREASE, hoverItem, 0);
|
|
1717
1725
|
break;
|
|
1718
1726
|
// prevent browser from scrolling the page when SPACE is pressed
|
|
1719
1727
|
case Keys.SPACE:
|
|
1720
1728
|
// Don't preventDefault on children of FocusableItem
|
|
1721
|
-
if (
|
|
1729
|
+
if (elementTarget && elementTarget.className.includes(menuClass)) {
|
|
1722
1730
|
e.preventDefault();
|
|
1723
1731
|
}
|
|
1724
1732
|
return;
|
|
@@ -1730,9 +1738,9 @@ var MenuList = function (_a) {
|
|
|
1730
1738
|
};
|
|
1731
1739
|
var onAnimationEnd = function () {
|
|
1732
1740
|
if (state === "closing") {
|
|
1733
|
-
setOverflowData(); // reset overflowData after closing
|
|
1741
|
+
setOverflowData(undefined); // reset overflowData after closing
|
|
1734
1742
|
}
|
|
1735
|
-
safeCall(endTransition);
|
|
1743
|
+
endTransition && safeCall(endTransition);
|
|
1736
1744
|
};
|
|
1737
1745
|
var handlePosition = useCallback(function (noOverflowCheck) {
|
|
1738
1746
|
if (!containerRef.current) {
|
|
@@ -1745,11 +1753,15 @@ var MenuList = function (_a) {
|
|
|
1745
1753
|
scrollNodes.menu =
|
|
1746
1754
|
(boundingBoxRef
|
|
1747
1755
|
? boundingBoxRef.current // user explicitly sets boundingBoxRef
|
|
1748
|
-
: getScrollAncestor(rootMenuRef.current)) || window; // try to discover bounding box automatically
|
|
1756
|
+
: getScrollAncestor(rootMenuRef === null || rootMenuRef === void 0 ? void 0 : rootMenuRef.current)) || window; // try to discover bounding box automatically
|
|
1749
1757
|
}
|
|
1750
1758
|
var positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
|
|
1751
1759
|
var menuRect = positionHelpers.menuRect;
|
|
1752
|
-
var results = {
|
|
1760
|
+
var results = {
|
|
1761
|
+
computedDirection: "bottom",
|
|
1762
|
+
x: 0,
|
|
1763
|
+
y: 0
|
|
1764
|
+
};
|
|
1753
1765
|
if (anchorPoint) {
|
|
1754
1766
|
results = positionContextMenu({ positionHelpers: positionHelpers, anchorPoint: anchorPoint });
|
|
1755
1767
|
}
|
|
@@ -1766,7 +1778,8 @@ var MenuList = function (_a) {
|
|
|
1766
1778
|
positionHelpers: positionHelpers
|
|
1767
1779
|
});
|
|
1768
1780
|
}
|
|
1769
|
-
var
|
|
1781
|
+
var y = results.y;
|
|
1782
|
+
var x = results.x, arrowX = results.arrowX, arrowY = results.arrowY, computedDirection = results.computedDirection;
|
|
1770
1783
|
var menuHeight = menuRect.height;
|
|
1771
1784
|
if (!noOverflowCheck && overflow !== "visible") {
|
|
1772
1785
|
var getTopOverflow = positionHelpers.getTopOverflow, getBottomOverflow = positionHelpers.getBottomOverflow;
|
|
@@ -1790,17 +1803,17 @@ var MenuList = function (_a) {
|
|
|
1790
1803
|
y -= topOverflow;
|
|
1791
1804
|
}
|
|
1792
1805
|
}
|
|
1793
|
-
if (height >= 0) {
|
|
1806
|
+
if (height != null && height >= 0) {
|
|
1794
1807
|
// To avoid triggering reposition in the next ResizeObserver callback
|
|
1795
1808
|
menuHeight = height;
|
|
1796
1809
|
setOverflowData({ height: height, overflowAmt: overflowAmt_1 });
|
|
1797
1810
|
}
|
|
1798
1811
|
else {
|
|
1799
|
-
setOverflowData();
|
|
1812
|
+
setOverflowData(undefined);
|
|
1800
1813
|
}
|
|
1801
1814
|
}
|
|
1802
1815
|
if (arrow)
|
|
1803
|
-
setArrowPosition({ x: arrowX, y: arrowY });
|
|
1816
|
+
setArrowPosition({ x: arrowX !== null && arrowX !== void 0 ? arrowX : 0, y: arrowY !== null && arrowY !== void 0 ? arrowY : 0 });
|
|
1804
1817
|
setMenuPosition({ x: x, y: y });
|
|
1805
1818
|
setExpandedDirection(computedDirection);
|
|
1806
1819
|
latestMenuSize.current = { width: menuRect.width, height: menuHeight };
|
|
@@ -1865,7 +1878,7 @@ var MenuList = function (_a) {
|
|
|
1865
1878
|
scrollObservers.forEach(function (o) { return o.addEventListener("scroll", handleScroll); });
|
|
1866
1879
|
return function () { return scrollObservers.forEach(function (o) { return o.removeEventListener("scroll", handleScroll); }); };
|
|
1867
1880
|
}, [rootAnchorRef, scrollNodes, isOpen, onClose, viewScroll, handlePosition]);
|
|
1868
|
-
var hasOverflow = !!overflowData && overflowData.overflowAmt > 0;
|
|
1881
|
+
var hasOverflow = !!overflowData && overflowData.overflowAmt != null && overflowData.overflowAmt > 0;
|
|
1869
1882
|
useEffect(function () {
|
|
1870
1883
|
if (hasOverflow || !isOpen || !parentScrollingRef)
|
|
1871
1884
|
return;
|
|
@@ -1906,20 +1919,20 @@ var MenuList = function (_a) {
|
|
|
1906
1919
|
}, [reposition]);
|
|
1907
1920
|
useEffect(function () {
|
|
1908
1921
|
if (!isOpen) {
|
|
1909
|
-
dispatch(HoverActionTypes.RESET);
|
|
1922
|
+
dispatch(HoverActionTypes.RESET, undefined, 0);
|
|
1910
1923
|
if (!closeTransition)
|
|
1911
|
-
setOverflowData();
|
|
1912
|
-
return;
|
|
1924
|
+
setOverflowData(undefined);
|
|
1925
|
+
return function () { };
|
|
1913
1926
|
}
|
|
1914
1927
|
var _a = menuItemFocus || {}, position = _a.position, alwaysUpdate = _a.alwaysUpdate;
|
|
1915
1928
|
var setItemFocus = function () {
|
|
1916
1929
|
if (position === FocusPositions.FIRST) {
|
|
1917
|
-
dispatch(HoverActionTypes.FIRST);
|
|
1930
|
+
dispatch(HoverActionTypes.FIRST, undefined, 0);
|
|
1918
1931
|
}
|
|
1919
1932
|
else if (position === FocusPositions.LAST) {
|
|
1920
|
-
dispatch(HoverActionTypes.LAST);
|
|
1933
|
+
dispatch(HoverActionTypes.LAST, undefined, 0);
|
|
1921
1934
|
}
|
|
1922
|
-
else if (position >= -1) {
|
|
1935
|
+
else if (typeof position === "number" && position >= -1) {
|
|
1923
1936
|
dispatch(HoverActionTypes.SET_INDEX, undefined, position);
|
|
1924
1937
|
}
|
|
1925
1938
|
};
|
|
@@ -1929,14 +1942,16 @@ var MenuList = function (_a) {
|
|
|
1929
1942
|
else if (captureFocus) {
|
|
1930
1943
|
// Use a timeout here because if set focus immediately, page might scroll unexpectedly.
|
|
1931
1944
|
var id_1 = setTimeout(function () {
|
|
1945
|
+
var _a;
|
|
1932
1946
|
// If focus has already been set to a children element, don't set focus on menu or item
|
|
1933
1947
|
if (!menuRef.current.contains(document.activeElement)) {
|
|
1934
|
-
focusRef.current.focus();
|
|
1948
|
+
(_a = focusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1935
1949
|
setItemFocus();
|
|
1936
1950
|
}
|
|
1937
1951
|
}, openTransition ? 170 : 100);
|
|
1938
1952
|
return function () { return clearTimeout(id_1); };
|
|
1939
1953
|
}
|
|
1954
|
+
return function () { };
|
|
1940
1955
|
}, [isOpen, openTransition, closeTransition, captureFocus, menuItemFocus, dispatch]);
|
|
1941
1956
|
var isSubmenuOpen = openSubmenuCount > 0;
|
|
1942
1957
|
var itemContext = useMemo(function () { return ({
|
|
@@ -1946,7 +1961,8 @@ var MenuList = function (_a) {
|
|
|
1946
1961
|
dispatch: dispatch,
|
|
1947
1962
|
updateItems: updateItems
|
|
1948
1963
|
}); }, [isOpen, isSubmenuOpen, dispatch, updateItems]);
|
|
1949
|
-
var maxHeight
|
|
1964
|
+
var maxHeight;
|
|
1965
|
+
var overflowAmt;
|
|
1950
1966
|
if (overflowData) {
|
|
1951
1967
|
setDownOverflow ? (overflowAmt = overflowData.overflowAmt) : (maxHeight = overflowData.height);
|
|
1952
1968
|
}
|
|
@@ -1957,7 +1973,7 @@ var MenuList = function (_a) {
|
|
|
1957
1973
|
parentMenuRef: menuRef,
|
|
1958
1974
|
parentDir: expandedDirection
|
|
1959
1975
|
}); }, [reposSubmenu, overflow, overflowAmt, expandedDirection]);
|
|
1960
|
-
var overflowStyle = maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined;
|
|
1976
|
+
var overflowStyle = maxHeight != null && maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined;
|
|
1961
1977
|
var modifiers = useMemo(function () { return ({
|
|
1962
1978
|
state: state,
|
|
1963
1979
|
dir: expandedDirection
|
|
@@ -2126,8 +2142,8 @@ ControlledMenu.propTypes /* remove-proptypes */ = __assign(__assign({}, rootMenu
|
|
|
2126
2142
|
alwaysUpdate: bool
|
|
2127
2143
|
}), onClose: func });
|
|
2128
2144
|
|
|
2129
|
-
|
|
2130
|
-
var ariaLabel = _a["aria-label"]
|
|
2145
|
+
function MenuFr(_a, externalRef) {
|
|
2146
|
+
var ariaLabel = _a["aria-label"], menuButton = _a.menuButton, instanceRef = _a.instanceRef, onMenuChange = _a.onMenuChange, restProps = __rest(_a, ["aria-label", "menuButton", "instanceRef", "onMenuChange"]);
|
|
2131
2147
|
var _b = useMenuStateAndFocus(restProps), stateProps = _b[0], toggleMenu = _b[1], openMenu = _b[2];
|
|
2132
2148
|
var isOpen = isMenuOpen(stateProps.state);
|
|
2133
2149
|
var skipOpen = useRef(false);
|
|
@@ -2135,7 +2151,7 @@ var Menu = forwardRef(function Menu(_a, externalRef) {
|
|
|
2135
2151
|
var handleClose = useCallback(function (e) {
|
|
2136
2152
|
toggleMenu(false);
|
|
2137
2153
|
if (e.key)
|
|
2138
|
-
buttonRef.current.focus();
|
|
2154
|
+
buttonRef.current && buttonRef.current.focus();
|
|
2139
2155
|
}, [toggleMenu]);
|
|
2140
2156
|
var onClick = function (e) {
|
|
2141
2157
|
if (skipOpen.current)
|
|
@@ -2156,10 +2172,11 @@ var Menu = forwardRef(function Menu(_a, externalRef) {
|
|
|
2156
2172
|
}
|
|
2157
2173
|
e.preventDefault();
|
|
2158
2174
|
};
|
|
2175
|
+
// FIXME erk! button seems to be many types
|
|
2159
2176
|
var button = safeCall(menuButton, { open: isOpen });
|
|
2160
2177
|
if (!button || !button.type)
|
|
2161
2178
|
throw new Error("Menu requires a menuButton prop.");
|
|
2162
|
-
var buttonProps = __assign({ ref: useCombinedRef(button.ref, buttonRef) }, mergeProps({ onClick: onClick, onKeyDown: onKeyDown }, button.props));
|
|
2179
|
+
var buttonProps = __assign(__assign({ ref: useCombinedRef(button.ref, buttonRef) }, mergeProps({ onClick: onClick, onKeyDown: onKeyDown }, button.props)), { isOpen: false });
|
|
2163
2180
|
if (getName(button.type) === "MenuButton") {
|
|
2164
2181
|
buttonProps.isOpen = isOpen;
|
|
2165
2182
|
}
|
|
@@ -2170,27 +2187,28 @@ var Menu = forwardRef(function Menu(_a, externalRef) {
|
|
|
2170
2187
|
closeMenu: function () { return toggleMenu(false); }
|
|
2171
2188
|
}); });
|
|
2172
2189
|
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 }))] }));
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2190
|
+
}
|
|
2191
|
+
forwardRef(MenuFr);
|
|
2175
2192
|
|
|
2176
|
-
var
|
|
2177
|
-
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,
|
|
2193
|
+
var SubMenuFr = function (_a) {
|
|
2194
|
+
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"]);
|
|
2178
2195
|
var settings = useContext(SettingsContext);
|
|
2179
2196
|
var rootMenuRef = settings.rootMenuRef;
|
|
2180
2197
|
var _c = useContext(ItemSettingsContext), submenuOpenDelay = _c.submenuOpenDelay, submenuCloseDelay = _c.submenuCloseDelay;
|
|
2181
2198
|
var _d = useContext(MenuListContext), parentMenuRef = _d.parentMenuRef, parentDir = _d.parentDir, parentOverflow = _d.overflow;
|
|
2182
2199
|
var _e = useContext(MenuListItemContext), isParentOpen = _e.isParentOpen, isSubmenuOpen = _e.isSubmenuOpen, setOpenSubmenuCount = _e.setOpenSubmenuCount, dispatch = _e.dispatch, updateItems = _e.updateItems;
|
|
2183
2200
|
var isPortal = parentOverflow !== "visible";
|
|
2201
|
+
// FIXME Matt no idea what's going on here
|
|
2184
2202
|
var _f = useMenuStateAndFocus(settings), stateProps = _f[0], toggleMenu = _f[1], _openMenu = _f[2];
|
|
2185
2203
|
var state = stateProps.state;
|
|
2186
2204
|
var isDisabled = !!disabled;
|
|
2187
2205
|
var isOpen = isMenuOpen(state);
|
|
2188
2206
|
var containerRef = useRef(null);
|
|
2189
|
-
var timeoutId = useRef(
|
|
2207
|
+
var timeoutId = useRef();
|
|
2190
2208
|
var stopTimer = function () {
|
|
2191
2209
|
if (timeoutId.current) {
|
|
2192
2210
|
clearTimeout(timeoutId.current);
|
|
2193
|
-
timeoutId.current =
|
|
2211
|
+
timeoutId.current = undefined;
|
|
2194
2212
|
}
|
|
2195
2213
|
};
|
|
2196
2214
|
var openMenu = function () {
|
|
@@ -2202,7 +2220,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2202
2220
|
setHover();
|
|
2203
2221
|
!isDisabled && _openMenu.apply(void 0, args);
|
|
2204
2222
|
};
|
|
2205
|
-
var setHover = function () { return !isHovering && !isDisabled && dispatch(HoverActionTypes.SET,
|
|
2223
|
+
var setHover = function () { return !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0); };
|
|
2206
2224
|
var delayOpen = function (delay) {
|
|
2207
2225
|
setHover();
|
|
2208
2226
|
if (!openTrigger)
|
|
@@ -2221,7 +2239,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2221
2239
|
var handlePointerLeave = function () {
|
|
2222
2240
|
stopTimer();
|
|
2223
2241
|
if (!isOpen)
|
|
2224
|
-
dispatch(HoverActionTypes.UNSET,
|
|
2242
|
+
dispatch(HoverActionTypes.UNSET, menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current, 0);
|
|
2225
2243
|
};
|
|
2226
2244
|
var handleKeyDown = function (e) {
|
|
2227
2245
|
var handled = false;
|
|
@@ -2229,7 +2247,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2229
2247
|
// LEFT key is bubbled up from submenu items
|
|
2230
2248
|
case Keys.LEFT:
|
|
2231
2249
|
if (isOpen) {
|
|
2232
|
-
|
|
2250
|
+
(menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
|
|
2233
2251
|
toggleMenu(false);
|
|
2234
2252
|
handled = true;
|
|
2235
2253
|
}
|
|
@@ -2256,19 +2274,19 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2256
2274
|
break;
|
|
2257
2275
|
}
|
|
2258
2276
|
};
|
|
2259
|
-
useItemEffect(isDisabled,
|
|
2277
|
+
useItemEffect(isDisabled, menuItemRef, updateItems);
|
|
2260
2278
|
useMenuChange(onMenuChange, isOpen);
|
|
2261
2279
|
useEffect(function () { return function () { return clearTimeout(timeoutId.current); }; }, []);
|
|
2262
2280
|
useEffect(function () {
|
|
2263
2281
|
// Don't set focus when parent menu is closed, otherwise focus will be lost
|
|
2264
2282
|
// and onBlur event will be fired with relatedTarget setting as null.
|
|
2265
2283
|
if (isHovering && isParentOpen) {
|
|
2266
|
-
|
|
2284
|
+
(menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
|
|
2267
2285
|
}
|
|
2268
2286
|
else {
|
|
2269
2287
|
toggleMenu(false);
|
|
2270
2288
|
}
|
|
2271
|
-
}, [isHovering, isParentOpen, toggleMenu,
|
|
2289
|
+
}, [isHovering, isParentOpen, toggleMenu, menuItemRef]);
|
|
2272
2290
|
useEffect(function () {
|
|
2273
2291
|
setOpenSubmenuCount(function (count) { return (isOpen ? count + 1 : Math.max(count - 1, 0)); });
|
|
2274
2292
|
}, [setOpenSubmenuCount, isOpen]);
|
|
@@ -2282,7 +2300,7 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2282
2300
|
},
|
|
2283
2301
|
closeMenu: function () {
|
|
2284
2302
|
if (isOpen) {
|
|
2285
|
-
|
|
2303
|
+
(menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.focus();
|
|
2286
2304
|
toggleMenu(false);
|
|
2287
2305
|
}
|
|
2288
2306
|
}
|
|
@@ -2301,36 +2319,40 @@ var SubMenu = withHovering("SubMenu", function SubMenu(_a) {
|
|
|
2301
2319
|
onClick: function () { return openTrigger !== "none" && openMenu(); }
|
|
2302
2320
|
}, restItemProps);
|
|
2303
2321
|
var getMenuList = function () {
|
|
2304
|
-
var menuList = (jsx(MenuList, __assign({}, restProps, stateProps, { ariaLabel: ariaLabel || (typeof label === "string" ? label : "Submenu"), anchorRef:
|
|
2305
|
-
var container = rootMenuRef.current;
|
|
2322
|
+
var menuList = (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 })));
|
|
2323
|
+
var container = rootMenuRef === null || rootMenuRef === void 0 ? void 0 : rootMenuRef.current;
|
|
2306
2324
|
return isPortal && container ? createPortal(menuList, container) : menuList;
|
|
2307
2325
|
};
|
|
2308
|
-
return (jsxs("li", __assign({ className: useBEM({ block: menuClass, element: subMenuClass, className: className }), style: { position: "relative" }, role: "presentation", ref: containerRef, onKeyDown: handleKeyDown }, { children: [jsx("div", __assign({ role: "menuitem", "aria-haspopup": true, "aria-expanded": isOpen }, mergedItemProps, commonProps(isDisabled, isHovering), { ref: useCombinedRef(externalItemRef,
|
|
2326
|
+
return (jsxs("li", __assign({ className: useBEM({ block: menuClass, element: subMenuClass, className: className }), style: { position: "relative" }, role: "presentation", ref: containerRef, onKeyDown: handleKeyDown }, { children: [jsx("div", __assign({ role: "menuitem", "aria-haspopup": true, "aria-expanded": isOpen }, mergedItemProps, commonProps(isDisabled, isHovering), { ref: useCombinedRef(externalItemRef, menuItemRef), className: useBEM({
|
|
2309
2327
|
block: menuClass,
|
|
2310
2328
|
element: menuItemClass,
|
|
2311
2329
|
modifiers: modifiers,
|
|
2312
2330
|
className: itemClassName
|
|
2313
2331
|
}) }, { children: useMemo(function () { return safeCall(label, modifiers); }, [label, modifiers]) })), state && getMenuList()] })));
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2332
|
+
};
|
|
2333
|
+
withHovering("SubMenu", SubMenuFr);
|
|
2316
2334
|
|
|
2317
|
-
var
|
|
2318
|
-
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,
|
|
2335
|
+
var MenuItemFr = function (_a) {
|
|
2336
|
+
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"]);
|
|
2319
2337
|
var isDisabled = !!disabled;
|
|
2320
|
-
var _b = useItemState(
|
|
2338
|
+
var _b = useItemState(menuItemRef, menuItemRef, isHovering, isDisabled), setHover = _b.setHover, restStateProps = __rest(_b, ["setHover"]);
|
|
2321
2339
|
var eventHandlers = useContext(EventHandlersContext);
|
|
2322
2340
|
var radioGroup = useContext(RadioGroupContext);
|
|
2323
2341
|
var isRadio = type === "radio";
|
|
2324
2342
|
var isCheckBox = type === "checkbox";
|
|
2325
2343
|
var isAnchor = !!href && !isDisabled && !isRadio && !isCheckBox;
|
|
2326
2344
|
var isChecked = isRadio ? radioGroup.value === value : isCheckBox ? !!checked : false;
|
|
2345
|
+
// FIXME handle click seems to be a combination of multiple event types
|
|
2327
2346
|
var handleClick = function (e) {
|
|
2328
2347
|
if (isDisabled) {
|
|
2329
2348
|
e.stopPropagation();
|
|
2330
2349
|
e.preventDefault();
|
|
2331
2350
|
return;
|
|
2332
2351
|
}
|
|
2333
|
-
var event = {
|
|
2352
|
+
var event = {
|
|
2353
|
+
value: value,
|
|
2354
|
+
syntheticEvent: e
|
|
2355
|
+
};
|
|
2334
2356
|
if (e.key !== undefined)
|
|
2335
2357
|
event.key = e.key;
|
|
2336
2358
|
if (isCheckBox)
|
|
@@ -2349,7 +2371,7 @@ var MenuItem = withHovering("MenuItem", function MenuItem(_a) {
|
|
|
2349
2371
|
case Keys.ENTER:
|
|
2350
2372
|
case Keys.SPACE:
|
|
2351
2373
|
if (isAnchor) {
|
|
2352
|
-
|
|
2374
|
+
(menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.click();
|
|
2353
2375
|
}
|
|
2354
2376
|
else {
|
|
2355
2377
|
handleClick(e);
|
|
@@ -2369,21 +2391,22 @@ var MenuItem = withHovering("MenuItem", function MenuItem(_a) {
|
|
|
2369
2391
|
// 1. Preset props adhering to WAI-ARIA Authoring Practices.
|
|
2370
2392
|
// 2. Merged outer and local props
|
|
2371
2393
|
// 3. ref, className
|
|
2372
|
-
var menuItemProps = __assign(__assign(__assign({ role: isRadio ? "menuitemradio" : isCheckBox ? "menuitemcheckbox" : "menuitem", "aria-checked": isRadio || isCheckBox ? isChecked : undefined }, mergedProps), commonProps(isDisabled, isHovering)), { ref: useCombinedRef(externalRef,
|
|
2394
|
+
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: useMemo(function () { return safeCall(children, modifiers); }, [children, modifiers]) });
|
|
2373
2395
|
if (isAnchor) {
|
|
2374
2396
|
return (jsx("li", __assign({ role: "presentation" }, { children: jsx("a", __assign({ href: href }, menuItemProps)) })));
|
|
2375
2397
|
}
|
|
2376
2398
|
else {
|
|
2377
2399
|
return jsx("li", __assign({}, menuItemProps));
|
|
2378
2400
|
}
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2401
|
+
};
|
|
2402
|
+
// FIXME matt as any
|
|
2403
|
+
var MenuItem = withHovering("MenuItem", MenuItemFr);
|
|
2381
2404
|
|
|
2382
|
-
var
|
|
2383
|
-
var className = _a.className, disabled = _a.disabled, children = _a.children, isHovering = _a.isHovering,
|
|
2405
|
+
var FocusableItemFr = function (_a) {
|
|
2406
|
+
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"]);
|
|
2384
2407
|
var isDisabled = !!disabled;
|
|
2385
2408
|
var ref = useRef(null);
|
|
2386
|
-
var _b = useItemState(
|
|
2409
|
+
var _b = useItemState(menuItemRef, ref, isHovering, isDisabled), setHover = _b.setHover, onPointerLeave = _b.onPointerLeave, restStateProps = __rest(_b, ["setHover", "onPointerLeave"]);
|
|
2387
2410
|
var handleClose = useContext(EventHandlersContext).handleClose;
|
|
2388
2411
|
var modifiers = useMemo(function () { return ({
|
|
2389
2412
|
disabled: isDisabled,
|
|
@@ -2394,50 +2417,51 @@ var FocusableItem = withHovering("FocusableItem", function FocusableItem(_a) {
|
|
|
2394
2417
|
return safeCall(children, __assign(__assign({}, modifiers), { ref: ref, closeMenu: handleClose }));
|
|
2395
2418
|
}, [children, modifiers, handleClose]);
|
|
2396
2419
|
var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerLeave: function (e) { return onPointerLeave(e, true); }, onFocus: setHover }), restProps);
|
|
2397
|
-
return (jsx("li", __assign({ role: "menuitem" }, mergedProps, commonProps(isDisabled), { ref: useCombinedRef(externalRef,
|
|
2398
|
-
}
|
|
2399
|
-
FocusableItem
|
|
2420
|
+
return (jsx("li", __assign({ role: "menuitem" }, mergedProps, commonProps(isDisabled), { ref: useCombinedRef(externalRef, menuItemRef), className: useBEM({ block: menuClass, element: menuItemClass, modifiers: modifiers, className: className }) }, { children: renderChildren })));
|
|
2421
|
+
};
|
|
2422
|
+
var FocusableItem = withHovering("FocusableItem", FocusableItemFr);
|
|
2400
2423
|
|
|
2401
|
-
var
|
|
2424
|
+
var MenuDividerFr = function (_a, externalRef) {
|
|
2402
2425
|
var className = _a.className, restProps = __rest(_a, ["className"]);
|
|
2403
2426
|
return (jsx("li", __assign({ role: "separator" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuDividerClass, className: className }) })));
|
|
2404
|
-
}
|
|
2405
|
-
MenuDivider
|
|
2427
|
+
};
|
|
2428
|
+
var MenuDivider = memo(forwardRef(MenuDividerFr));
|
|
2406
2429
|
|
|
2407
|
-
var
|
|
2430
|
+
var MenuHeaderFr = function (_a, externalRef) {
|
|
2408
2431
|
var className = _a.className, restProps = __rest(_a, ["className"]);
|
|
2409
2432
|
return (jsx("li", __assign({ role: "presentation" }, restProps, { ref: externalRef, className: useBEM({ block: menuClass, element: menuHeaderClass, className: className }) })));
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2433
|
+
};
|
|
2434
|
+
memo(forwardRef(MenuHeaderFr));
|
|
2412
2435
|
|
|
2413
|
-
var
|
|
2436
|
+
var MenuGroupFr = function (_a, externalRef) {
|
|
2414
2437
|
var className = _a.className, style = _a.style, takeOverflow = _a.takeOverflow, restProps = __rest(_a, ["className", "style", "takeOverflow"]);
|
|
2415
2438
|
var ref = useRef(null);
|
|
2416
2439
|
var _b = useState(), overflowStyle = _b[0], setOverflowStyle = _b[1];
|
|
2417
2440
|
var _c = useContext(MenuListContext), overflow = _c.overflow, overflowAmt = _c.overflowAmt;
|
|
2418
2441
|
useIsomorphicLayoutEffect(function () {
|
|
2419
2442
|
var maxHeight;
|
|
2420
|
-
if (takeOverflow && overflowAmt >= 0) {
|
|
2443
|
+
if (takeOverflow && overflowAmt != null && overflowAmt >= 0 && ref.current) {
|
|
2444
|
+
// FIXME Matt added && ref.current
|
|
2421
2445
|
maxHeight = ref.current.getBoundingClientRect().height - overflowAmt;
|
|
2422
2446
|
if (maxHeight < 0)
|
|
2423
2447
|
maxHeight = 0;
|
|
2424
2448
|
}
|
|
2425
|
-
setOverflowStyle(maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined);
|
|
2449
|
+
setOverflowStyle(maxHeight != null && maxHeight >= 0 ? { maxHeight: maxHeight, overflow: overflow } : undefined);
|
|
2426
2450
|
}, [takeOverflow, overflow, overflowAmt]);
|
|
2427
2451
|
useIsomorphicLayoutEffect(function () {
|
|
2428
|
-
if (overflowStyle)
|
|
2452
|
+
if (overflowStyle && ref.current)
|
|
2429
2453
|
ref.current.scrollTop = 0;
|
|
2430
2454
|
}, [overflowStyle]);
|
|
2431
2455
|
return (jsx("div", __assign({}, restProps, { ref: useCombinedRef(externalRef, ref), className: useBEM({ block: menuClass, element: menuGroupClass, className: className }), style: __assign(__assign({}, style), overflowStyle) })));
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2456
|
+
};
|
|
2457
|
+
forwardRef(MenuGroupFr);
|
|
2434
2458
|
|
|
2435
|
-
var
|
|
2459
|
+
var MenuRadioGroupFr = function (_a, externalRef) {
|
|
2436
2460
|
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"]);
|
|
2437
2461
|
var contextValue = useMemo(function () { return ({ name: name, value: value, onRadioChange: onRadioChange }); }, [name, value, onRadioChange]);
|
|
2438
2462
|
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 }) })) })) })));
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2463
|
+
};
|
|
2464
|
+
forwardRef(MenuRadioGroupFr);
|
|
2441
2465
|
|
|
2442
2466
|
var useGridPopoverHook = function (props, save) {
|
|
2443
2467
|
var cellEditorParams = props.cellEditorParams, saving = props.saving, updateValue = props.updateValue;
|
|
@@ -2525,7 +2549,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
2525
2549
|
}
|
|
2526
2550
|
});
|
|
2527
2551
|
}); }, [formProps, selectedValues]);
|
|
2528
|
-
var
|
|
2552
|
+
var _e = useGridPopoverHook(props, save), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
|
|
2529
2553
|
// Load up options list if it's async function
|
|
2530
2554
|
useEffect(function () {
|
|
2531
2555
|
var _a;
|
|
@@ -2585,10 +2609,18 @@ var GridFormMultiSelect = function (props) {
|
|
|
2585
2609
|
} })), jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
2586
2610
|
var _a;
|
|
2587
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
|
|
2588
2613
|
e.keepOpen = true;
|
|
2589
|
-
|
|
2614
|
+
if (selectedValues.includes(e.value)) {
|
|
2615
|
+
setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
|
|
2616
|
+
}
|
|
2617
|
+
else {
|
|
2618
|
+
setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
|
|
2619
|
+
}
|
|
2590
2620
|
return false;
|
|
2591
|
-
}
|
|
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) {
|
|
2592
2624
|
if (e.target.checked) {
|
|
2593
2625
|
setSelectedValues(__spreadArray(__spreadArray([], selectedValues, true), [item.value], false));
|
|
2594
2626
|
}
|
|
@@ -2989,7 +3021,7 @@ var GridFormDropDown = function (props) {
|
|
|
2989
3021
|
}
|
|
2990
3022
|
});
|
|
2991
3023
|
}); }, [filteredValues, options, selectItemHandler, stopEditing]);
|
|
2992
|
-
return popoverWrapper(jsxs(Fragment, { children: [formProps.filtered && (jsxs(Fragment, { children: [jsx(FocusableItem, __assign({ className: "filter-item"
|
|
3024
|
+
return popoverWrapper(jsxs(Fragment, { children: [formProps.filtered && (jsxs(Fragment, { children: [jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
|
|
2993
3025
|
var _b;
|
|
2994
3026
|
var ref = _a.ref;
|
|
2995
3027
|
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: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
|