@fluentui/react-menu 9.4.1 → 9.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CHANGELOG.json +60 -1
  2. package/CHANGELOG.md +17 -2
  3. package/dist/index.d.ts +45 -4
  4. package/lib/components/Menu/Menu.types.js.map +1 -1
  5. package/lib/components/Menu/useMenu.js +13 -7
  6. package/lib/components/Menu/useMenu.js.map +1 -1
  7. package/lib/components/MenuItem/useMenuItem.js +3 -1
  8. package/lib/components/MenuItem/useMenuItem.js.map +1 -1
  9. package/lib/components/MenuPopover/useMenuPopover.js +20 -14
  10. package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
  11. package/lib/components/MenuTrigger/useMenuTrigger.js +42 -28
  12. package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  13. package/lib/index.js.map +1 -1
  14. package/lib-amd/Menu.js +6 -0
  15. package/lib-amd/Menu.js.map +1 -0
  16. package/lib-amd/MenuDivider.js +6 -0
  17. package/lib-amd/MenuDivider.js.map +1 -0
  18. package/lib-amd/MenuGroup.js +6 -0
  19. package/lib-amd/MenuGroup.js.map +1 -0
  20. package/lib-amd/MenuGroupHeader.js +6 -0
  21. package/lib-amd/MenuGroupHeader.js.map +1 -0
  22. package/lib-amd/MenuItem.js +6 -0
  23. package/lib-amd/MenuItem.js.map +1 -0
  24. package/lib-amd/MenuItemCheckbox.js +6 -0
  25. package/lib-amd/MenuItemCheckbox.js.map +1 -0
  26. package/lib-amd/MenuItemRadio.js +6 -0
  27. package/lib-amd/MenuItemRadio.js.map +1 -0
  28. package/lib-amd/MenuList.js +6 -0
  29. package/lib-amd/MenuList.js.map +1 -0
  30. package/lib-amd/MenuPopover.js +6 -0
  31. package/lib-amd/MenuPopover.js.map +1 -0
  32. package/lib-amd/MenuSplitGroup.js +6 -0
  33. package/lib-amd/MenuSplitGroup.js.map +1 -0
  34. package/lib-amd/MenuTrigger.js +6 -0
  35. package/lib-amd/MenuTrigger.js.map +1 -0
  36. package/lib-amd/components/Menu/Menu.js +16 -0
  37. package/lib-amd/components/Menu/Menu.js.map +1 -0
  38. package/lib-amd/components/Menu/Menu.types.js +5 -0
  39. package/lib-amd/components/Menu/Menu.types.js.map +1 -0
  40. package/lib-amd/components/Menu/index.js +10 -0
  41. package/lib-amd/components/Menu/index.js.map +1 -0
  42. package/lib-amd/components/Menu/renderMenu.js +15 -0
  43. package/lib-amd/components/Menu/renderMenu.js.map +1 -0
  44. package/lib-amd/components/Menu/useMenu.js +233 -0
  45. package/lib-amd/components/Menu/useMenu.js.map +1 -0
  46. package/lib-amd/components/Menu/useMenuContextValues.js +29 -0
  47. package/lib-amd/components/Menu/useMenuContextValues.js.map +1 -0
  48. package/lib-amd/components/MenuDivider/MenuDivider.js +15 -0
  49. package/lib-amd/components/MenuDivider/MenuDivider.js.map +1 -0
  50. package/lib-amd/components/MenuDivider/MenuDivider.types.js +5 -0
  51. package/lib-amd/components/MenuDivider/MenuDivider.types.js.map +1 -0
  52. package/lib-amd/components/MenuDivider/index.js +10 -0
  53. package/lib-amd/components/MenuDivider/index.js.map +1 -0
  54. package/lib-amd/components/MenuDivider/renderMenuDivider.js +15 -0
  55. package/lib-amd/components/MenuDivider/renderMenuDivider.js.map +1 -0
  56. package/lib-amd/components/MenuDivider/useMenuDivider.js +18 -0
  57. package/lib-amd/components/MenuDivider/useMenuDivider.js.map +1 -0
  58. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js +18 -0
  59. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js.map +1 -0
  60. package/lib-amd/components/MenuGroup/MenuGroup.js +16 -0
  61. package/lib-amd/components/MenuGroup/MenuGroup.js.map +1 -0
  62. package/lib-amd/components/MenuGroup/MenuGroup.types.js +5 -0
  63. package/lib-amd/components/MenuGroup/MenuGroup.types.js.map +1 -0
  64. package/lib-amd/components/MenuGroup/index.js +11 -0
  65. package/lib-amd/components/MenuGroup/index.js.map +1 -0
  66. package/lib-amd/components/MenuGroup/renderMenuGroup.js +16 -0
  67. package/lib-amd/components/MenuGroup/renderMenuGroup.js.map +1 -0
  68. package/lib-amd/components/MenuGroup/useMenuGroup.js +20 -0
  69. package/lib-amd/components/MenuGroup/useMenuGroup.js.map +1 -0
  70. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js +12 -0
  71. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js.map +1 -0
  72. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js +14 -0
  73. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
  74. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js +15 -0
  75. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -0
  76. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js +5 -0
  77. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -0
  78. package/lib-amd/components/MenuGroupHeader/index.js +10 -0
  79. package/lib-amd/components/MenuGroupHeader/index.js.map +1 -0
  80. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js +15 -0
  81. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -0
  82. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js +19 -0
  83. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -0
  84. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +27 -0
  85. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -0
  86. package/lib-amd/components/MenuItem/MenuItem.js +15 -0
  87. package/lib-amd/components/MenuItem/MenuItem.js.map +1 -0
  88. package/lib-amd/components/MenuItem/MenuItem.types.js +5 -0
  89. package/lib-amd/components/MenuItem/MenuItem.types.js.map +1 -0
  90. package/lib-amd/components/MenuItem/index.js +10 -0
  91. package/lib-amd/components/MenuItem/index.js.map +1 -0
  92. package/lib-amd/components/MenuItem/renderMenuItem.js +19 -0
  93. package/lib-amd/components/MenuItem/renderMenuItem.js.map +1 -0
  94. package/lib-amd/components/MenuItem/useCharacterSearch.js +22 -0
  95. package/lib-amd/components/MenuItem/useCharacterSearch.js.map +1 -0
  96. package/lib-amd/components/MenuItem/useMenuItem.js +80 -0
  97. package/lib-amd/components/MenuItem/useMenuItem.js.map +1 -0
  98. package/lib-amd/components/MenuItem/useMenuItemStyles.js +100 -0
  99. package/lib-amd/components/MenuItem/useMenuItemStyles.js.map +1 -0
  100. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js +15 -0
  101. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -0
  102. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js +5 -0
  103. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -0
  104. package/lib-amd/components/MenuItemCheckbox/index.js +10 -0
  105. package/lib-amd/components/MenuItemCheckbox/index.js.map +1 -0
  106. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js +16 -0
  107. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -0
  108. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js +26 -0
  109. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -0
  110. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +31 -0
  111. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -0
  112. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js +15 -0
  113. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js.map +1 -0
  114. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js +5 -0
  115. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -0
  116. package/lib-amd/components/MenuItemRadio/index.js +10 -0
  117. package/lib-amd/components/MenuItemRadio/index.js.map +1 -0
  118. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js +19 -0
  119. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -0
  120. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js +27 -0
  121. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js.map +1 -0
  122. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js +31 -0
  123. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -0
  124. package/lib-amd/components/MenuList/MenuList.js +16 -0
  125. package/lib-amd/components/MenuList/MenuList.js.map +1 -0
  126. package/lib-amd/components/MenuList/MenuList.types.js +5 -0
  127. package/lib-amd/components/MenuList/MenuList.types.js.map +1 -0
  128. package/lib-amd/components/MenuList/index.js +11 -0
  129. package/lib-amd/components/MenuList/index.js.map +1 -0
  130. package/lib-amd/components/MenuList/renderMenuList.js +15 -0
  131. package/lib-amd/components/MenuList/renderMenuList.js.map +1 -0
  132. package/lib-amd/components/MenuList/useMenuList.js +119 -0
  133. package/lib-amd/components/MenuList/useMenuList.js.map +1 -0
  134. package/lib-amd/components/MenuList/useMenuListContextValues.js +21 -0
  135. package/lib-amd/components/MenuList/useMenuListContextValues.js.map +1 -0
  136. package/lib-amd/components/MenuList/useMenuListStyles.js +21 -0
  137. package/lib-amd/components/MenuList/useMenuListStyles.js.map +1 -0
  138. package/lib-amd/components/MenuPopover/MenuPopover.js +15 -0
  139. package/lib-amd/components/MenuPopover/MenuPopover.js.map +1 -0
  140. package/lib-amd/components/MenuPopover/MenuPopover.types.js +5 -0
  141. package/lib-amd/components/MenuPopover/MenuPopover.types.js.map +1 -0
  142. package/lib-amd/components/MenuPopover/index.js +10 -0
  143. package/lib-amd/components/MenuPopover/index.js.map +1 -0
  144. package/lib-amd/components/MenuPopover/renderMenuPopover.js +18 -0
  145. package/lib-amd/components/MenuPopover/renderMenuPopover.js.map +1 -0
  146. package/lib-amd/components/MenuPopover/useMenuPopover.js +82 -0
  147. package/lib-amd/components/MenuPopover/useMenuPopover.js.map +1 -0
  148. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js +21 -0
  149. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js.map +1 -0
  150. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
  151. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
  152. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js +5 -0
  153. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
  154. package/lib-amd/components/MenuSplitGroup/index.js +10 -0
  155. package/lib-amd/components/MenuSplitGroup/index.js.map +1 -0
  156. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js +14 -0
  157. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
  158. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js +47 -0
  159. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
  160. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js +43 -0
  161. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
  162. package/lib-amd/components/MenuTrigger/MenuTrigger.js +18 -0
  163. package/lib-amd/components/MenuTrigger/MenuTrigger.js.map +1 -0
  164. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js +5 -0
  165. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js.map +1 -0
  166. package/lib-amd/components/MenuTrigger/index.js +9 -0
  167. package/lib-amd/components/MenuTrigger/index.js.map +1 -0
  168. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js +15 -0
  169. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js.map +1 -0
  170. package/lib-amd/components/MenuTrigger/useMenuTrigger.js +112 -0
  171. package/lib-amd/components/MenuTrigger/useMenuTrigger.js.map +1 -0
  172. package/lib-amd/components/index.js +7 -0
  173. package/lib-amd/components/index.js.map +1 -0
  174. package/lib-amd/contexts/menuContext.js +32 -0
  175. package/lib-amd/contexts/menuContext.js.map +1 -0
  176. package/lib-amd/contexts/menuGroupContext.js +13 -0
  177. package/lib-amd/contexts/menuGroupContext.js.map +1 -0
  178. package/lib-amd/contexts/menuListContext.js +24 -0
  179. package/lib-amd/contexts/menuListContext.js.map +1 -0
  180. package/lib-amd/contexts/menuTriggerContext.js +14 -0
  181. package/lib-amd/contexts/menuTriggerContext.js.map +1 -0
  182. package/lib-amd/index.js +69 -0
  183. package/lib-amd/index.js.map +1 -0
  184. package/lib-amd/selectable/index.js +7 -0
  185. package/lib-amd/selectable/index.js.map +1 -0
  186. package/lib-amd/selectable/types.js +5 -0
  187. package/lib-amd/selectable/types.js.map +1 -0
  188. package/lib-amd/selectable/useCheckmarkStyles.js +28 -0
  189. package/lib-amd/selectable/useCheckmarkStyles.js.map +1 -0
  190. package/lib-amd/utils/index.js +6 -0
  191. package/lib-amd/utils/index.js.map +1 -0
  192. package/lib-amd/utils/useIsSubmenu.js +20 -0
  193. package/lib-amd/utils/useIsSubmenu.js.map +1 -0
  194. package/lib-amd/utils/useOnMenuEnter.js +59 -0
  195. package/lib-amd/utils/useOnMenuEnter.js.map +1 -0
  196. package/lib-commonjs/components/Menu/useMenu.js +13 -7
  197. package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
  198. package/lib-commonjs/components/MenuItem/useMenuItem.js +3 -1
  199. package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
  200. package/lib-commonjs/components/MenuPopover/useMenuPopover.js +20 -14
  201. package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
  202. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +42 -28
  203. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  204. package/lib-commonjs/index.js.map +1 -1
  205. package/package.json +7 -7
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../contexts/menuListContext"], function (require, exports, tslib_1, React, react_utilities_1, menuListContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderMenuList_unstable = void 0;
5
+ /**
6
+ * Function that renders the final JSX of the component
7
+ */
8
+ var renderMenuList_unstable = function (state, contextValues) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return (React.createElement(menuListContext_1.MenuListProvider, { value: contextValues.menuList },
11
+ React.createElement(slots.root, tslib_1.__assign({}, slotProps.root))));
12
+ };
13
+ exports.renderMenuList_unstable = renderMenuList_unstable;
14
+ });
15
+ //# sourceMappingURL=renderMenuList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMenuList.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuList/renderMenuList.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,uBAAuB,GAAG,UAAC,KAAoB,EAAE,aAAoC;QAC1F,IAAA,KAAuB,0BAAQ,CAAgB,KAAK,CAAC,EAAnD,KAAK,WAAA,EAAE,SAAS,eAAmC,CAAC;QAE5D,OAAO,CACL,oBAAC,kCAAgB,IAAC,KAAK,EAAE,aAAa,CAAC,QAAQ;YAC7C,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CACjB,CACpB,CAAC;IACJ,CAAC,CAAC;IARW,QAAA,uBAAuB,2BAQlC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { MenuListContextValues, MenuListSlots, MenuListState } from './MenuList.types';\nimport { MenuListProvider } from '../../contexts/menuListContext';\n\n/**\n * Function that renders the final JSX of the component\n */\nexport const renderMenuList_unstable = (state: MenuListState, contextValues: MenuListContextValues) => {\n const { slots, slotProps } = getSlots<MenuListSlots>(state);\n\n return (\n <MenuListProvider value={contextValues.menuList}>\n <slots.root {...slotProps.root} />\n </MenuListProvider>\n );\n};\n"]}
@@ -0,0 +1,119 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-tabster", "@fluentui/react-context-selector", "../../contexts/menuContext", "../../contexts/menuContext"], function (require, exports, tslib_1, React, react_utilities_1, react_tabster_1, react_context_selector_1, menuContext_1, menuContext_2) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuList_unstable = void 0;
5
+ /**
6
+ * Returns the props and state required to render the component
7
+ */
8
+ var useMenuList_unstable = function (props, ref) {
9
+ var focusAttributes = react_tabster_1.useArrowNavigationGroup({ circular: true, ignoreDefaultKeydown: { Tab: true } });
10
+ var findAllFocusable = react_tabster_1.useFocusFinders().findAllFocusable;
11
+ var menuContext = useMenuContextSelectors();
12
+ var hasMenuContext = react_context_selector_1.useHasParentContext(menuContext_2.MenuContext);
13
+ if (usingPropsAndMenuContext(props, menuContext, hasMenuContext)) {
14
+ // TODO throw warnings in development safely
15
+ // eslint-disable-next-line no-console
16
+ console.warn('You are using both MenuList and Menu props, we recommend you to use Menu props when available');
17
+ }
18
+ var innerRef = React.useRef(null);
19
+ var initialState = tslib_1.__assign(tslib_1.__assign({ components: {
20
+ root: 'div',
21
+ }, root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({ ref: react_utilities_1.useMergedRefs(ref, innerRef), role: 'menu', 'aria-labelledby': menuContext.triggerId }, focusAttributes), props)), hasIcons: menuContext.hasIcons || false, hasCheckmarks: menuContext.hasCheckmarks || false }, (hasMenuContext && menuContext)), props);
22
+ var setFocusByFirstCharacter = React.useCallback(function (e, itemEl) {
23
+ // TODO use some kind of children registration to reduce dependency on DOM roles
24
+ var acceptedRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];
25
+ if (!innerRef.current) {
26
+ return;
27
+ }
28
+ var menuItems = findAllFocusable(innerRef.current, function (el) { return el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')) !== -1; });
29
+ var startIndex = menuItems.indexOf(itemEl) + 1;
30
+ if (startIndex === menuItems.length) {
31
+ startIndex = 0;
32
+ }
33
+ var firstChars = menuItems.map(function (menuItem) { var _a; return (_a = menuItem.textContent) === null || _a === void 0 ? void 0 : _a.charAt(0).toLowerCase(); });
34
+ var char = e.key.toLowerCase();
35
+ var getIndexFirstChars = function (start, firstChar) {
36
+ for (var i = start; i < firstChars.length; i++) {
37
+ if (char === firstChars[i]) {
38
+ return i;
39
+ }
40
+ }
41
+ return -1;
42
+ };
43
+ // Check remaining slots in the menu
44
+ var index = getIndexFirstChars(startIndex, char);
45
+ // If not found in remaining slots, check from beginning
46
+ if (index === -1) {
47
+ index = getIndexFirstChars(0, char);
48
+ }
49
+ // If match was found...
50
+ if (index > -1) {
51
+ menuItems[index].focus();
52
+ }
53
+ }, [findAllFocusable]);
54
+ var _a = react_utilities_1.useControllableState({
55
+ state: initialState.checkedValues,
56
+ defaultState: initialState.defaultCheckedValues,
57
+ initialState: {},
58
+ }), checkedValues = _a[0], setCheckedValues = _a[1];
59
+ var onCheckedValueChange = initialState.onCheckedValueChange;
60
+ var toggleCheckbox = react_utilities_1.useEventCallback(function (e, name, value, checked) {
61
+ var checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];
62
+ var newCheckedItems = tslib_1.__spreadArray([], checkedItems);
63
+ if (checked) {
64
+ newCheckedItems.splice(newCheckedItems.indexOf(value), 1);
65
+ }
66
+ else {
67
+ newCheckedItems.push(value);
68
+ }
69
+ onCheckedValueChange === null || onCheckedValueChange === void 0 ? void 0 : onCheckedValueChange(e, { name: name, checkedItems: newCheckedItems });
70
+ setCheckedValues(function (s) {
71
+ var _a;
72
+ return (tslib_1.__assign(tslib_1.__assign({}, s), (_a = {}, _a[name] = newCheckedItems, _a)));
73
+ });
74
+ });
75
+ var selectRadio = react_utilities_1.useEventCallback(function (e, name, value) {
76
+ var newCheckedItems = [value];
77
+ setCheckedValues(function (s) {
78
+ var _a;
79
+ return (tslib_1.__assign(tslib_1.__assign({}, s), (_a = {}, _a[name] = newCheckedItems, _a)));
80
+ });
81
+ onCheckedValueChange === null || onCheckedValueChange === void 0 ? void 0 : onCheckedValueChange(e, { name: name, checkedItems: newCheckedItems });
82
+ });
83
+ var state = tslib_1.__assign(tslib_1.__assign({}, initialState), { setFocusByFirstCharacter: setFocusByFirstCharacter, selectRadio: selectRadio, toggleCheckbox: toggleCheckbox, checkedValues: checkedValues !== null && checkedValues !== void 0 ? checkedValues : {} });
84
+ return state;
85
+ };
86
+ exports.useMenuList_unstable = useMenuList_unstable;
87
+ /**
88
+ * Adds some sugar to fetching multiple context selector values
89
+ */
90
+ var useMenuContextSelectors = function () {
91
+ var checkedValues = menuContext_1.useMenuContext_unstable(function (context) { return context.checkedValues; });
92
+ var onCheckedValueChange = menuContext_1.useMenuContext_unstable(function (context) { return context.onCheckedValueChange; });
93
+ var defaultCheckedValues = menuContext_1.useMenuContext_unstable(function (context) { return context.defaultCheckedValues; });
94
+ var triggerId = menuContext_1.useMenuContext_unstable(function (context) { return context.triggerId; });
95
+ var hasIcons = menuContext_1.useMenuContext_unstable(function (context) { return context.hasIcons; });
96
+ var hasCheckmarks = menuContext_1.useMenuContext_unstable(function (context) { return context.hasCheckmarks; });
97
+ return {
98
+ checkedValues: checkedValues,
99
+ onCheckedValueChange: onCheckedValueChange,
100
+ defaultCheckedValues: defaultCheckedValues,
101
+ triggerId: triggerId,
102
+ hasIcons: hasIcons,
103
+ hasCheckmarks: hasCheckmarks,
104
+ };
105
+ };
106
+ /**
107
+ * Helper function to detect if props and MenuContext values are both used
108
+ */
109
+ var usingPropsAndMenuContext = function (props, contextValue, hasMenuContext) {
110
+ var isUsingPropsAndContext = false;
111
+ for (var val in contextValue) {
112
+ if (props[val]) {
113
+ isUsingPropsAndContext = true;
114
+ }
115
+ }
116
+ return hasMenuContext && isUsingPropsAndContext;
117
+ };
118
+ });
119
+ //# sourceMappingURL=useMenuList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuList.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuList/useMenuList.ts"],"names":[],"mappings":";;;;IAaA;;OAEG;IACI,IAAM,oBAAo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/B,KAAoB,EACpB,YAAwD,EACxD,cAAuB;QAEvB,IAAI,sBAAsB,GAAG,KAAK,CAAC;QACnC,KAAK,IAAM,GAAG,IAAI,YAAY,EAAE;YAC9B,IAAI,KAAK,CAAC,GAA+F,CAAC,EAAE;gBAC1G,sBAAsB,GAAG,IAAI,CAAC;aAC/B;SACF;QAED,OAAO,cAAc,IAAI,sBAAsB,CAAC;IAClD,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport {\n useMergedRefs,\n useEventCallback,\n useControllableState,\n getNativeElementProps,\n} from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MenuContext } from '../../contexts/menuContext';\nimport type { MenuListProps, MenuListState, UninitializedMenuListState } from './MenuList.types';\n\n/**\n * Returns the props and state required to render the component\n */\nexport const useMenuList_unstable = (props: MenuListProps, ref: React.Ref<HTMLElement>): MenuListState => {\n const focusAttributes = useArrowNavigationGroup({ circular: true, ignoreDefaultKeydown: { Tab: true } });\n const { findAllFocusable } = useFocusFinders();\n const menuContext = useMenuContextSelectors();\n const hasMenuContext = useHasParentContext(MenuContext);\n\n if (usingPropsAndMenuContext(props, menuContext, hasMenuContext)) {\n // TODO throw warnings in development safely\n // eslint-disable-next-line no-console\n console.warn('You are using both MenuList and Menu props, we recommend you to use Menu props when available');\n }\n\n const innerRef = React.useRef<HTMLElement>(null);\n const initialState: UninitializedMenuListState = {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'menu',\n 'aria-labelledby': menuContext.triggerId,\n ...focusAttributes,\n ...props,\n }),\n hasIcons: menuContext.hasIcons || false,\n hasCheckmarks: menuContext.hasCheckmarks || false,\n ...(hasMenuContext && menuContext),\n ...props,\n };\n\n const setFocusByFirstCharacter = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>, itemEl: HTMLElement) => {\n // TODO use some kind of children registration to reduce dependency on DOM roles\n const acceptedRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];\n if (!innerRef.current) {\n return;\n }\n\n const menuItems = findAllFocusable(\n innerRef.current,\n (el: HTMLElement) => el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')!) !== -1,\n );\n\n let startIndex = menuItems.indexOf(itemEl) + 1;\n if (startIndex === menuItems.length) {\n startIndex = 0;\n }\n\n const firstChars = menuItems.map(menuItem => menuItem.textContent?.charAt(0).toLowerCase());\n const char = e.key.toLowerCase();\n\n const getIndexFirstChars = (start: number, firstChar: string) => {\n for (let i = start; i < firstChars.length; i++) {\n if (char === firstChars[i]) {\n return i;\n }\n }\n return -1;\n };\n\n // Check remaining slots in the menu\n let index = getIndexFirstChars(startIndex, char);\n\n // If not found in remaining slots, check from beginning\n if (index === -1) {\n index = getIndexFirstChars(0, char);\n }\n\n // If match was found...\n if (index > -1) {\n menuItems[index].focus();\n }\n },\n [findAllFocusable],\n );\n\n const [checkedValues, setCheckedValues] = useControllableState({\n state: initialState.checkedValues,\n defaultState: initialState.defaultCheckedValues,\n initialState: {},\n });\n\n const { onCheckedValueChange } = initialState;\n const toggleCheckbox = useEventCallback(\n (e: React.MouseEvent | React.KeyboardEvent, name: string, value: string, checked: boolean) => {\n const checkedItems = checkedValues?.[name] || [];\n const newCheckedItems = [...checkedItems];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n\n onCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n },\n );\n\n const selectRadio = useEventCallback((e: React.MouseEvent | React.KeyboardEvent, name: string, value: string) => {\n const newCheckedItems = [value];\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n onCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n });\n\n const state = {\n ...initialState,\n setFocusByFirstCharacter,\n selectRadio,\n toggleCheckbox,\n checkedValues: checkedValues ?? {},\n };\n\n return state;\n};\n\n/**\n * Adds some sugar to fetching multiple context selector values\n */\nconst useMenuContextSelectors = () => {\n const checkedValues = useMenuContext_unstable(context => context.checkedValues);\n const onCheckedValueChange = useMenuContext_unstable(context => context.onCheckedValueChange);\n const defaultCheckedValues = useMenuContext_unstable(context => context.defaultCheckedValues);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const hasIcons = useMenuContext_unstable(context => context.hasIcons);\n const hasCheckmarks = useMenuContext_unstable(context => context.hasCheckmarks);\n\n return {\n checkedValues,\n onCheckedValueChange,\n defaultCheckedValues,\n triggerId,\n hasIcons,\n hasCheckmarks,\n };\n};\n\n/**\n * Helper function to detect if props and MenuContext values are both used\n */\nconst usingPropsAndMenuContext = (\n props: MenuListProps,\n contextValue: ReturnType<typeof useMenuContextSelectors>,\n hasMenuContext: boolean,\n) => {\n let isUsingPropsAndContext = false;\n for (const val in contextValue) {\n if (props[val as keyof Omit<typeof contextValue, 'hasMenuContext' | 'onCheckedValueChange' | 'triggerId'>]) {\n isUsingPropsAndContext = true;\n }\n }\n\n return hasMenuContext && isUsingPropsAndContext;\n};\n"]}
@@ -0,0 +1,21 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuListContextValues_unstable = void 0;
5
+ function useMenuListContextValues_unstable(state) {
6
+ var checkedValues = state.checkedValues, hasCheckmarks = state.hasCheckmarks, hasIcons = state.hasIcons, onCheckedValueChange = state.onCheckedValueChange, selectRadio = state.selectRadio, setFocusByFirstCharacter = state.setFocusByFirstCharacter, toggleCheckbox = state.toggleCheckbox;
7
+ // This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
8
+ var menuList = {
9
+ checkedValues: checkedValues,
10
+ hasCheckmarks: hasCheckmarks,
11
+ hasIcons: hasIcons,
12
+ onCheckedValueChange: onCheckedValueChange,
13
+ selectRadio: selectRadio,
14
+ setFocusByFirstCharacter: setFocusByFirstCharacter,
15
+ toggleCheckbox: toggleCheckbox,
16
+ };
17
+ return { menuList: menuList };
18
+ }
19
+ exports.useMenuListContextValues_unstable = useMenuListContextValues_unstable;
20
+ });
21
+ //# sourceMappingURL=useMenuListContextValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuListContextValues.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuList/useMenuListContextValues.ts"],"names":[],"mappings":";;;;IAEA,SAAgB,iCAAiC,CAAC,KAAoB;QAElE,IAAA,aAAa,GAOX,KAAK,cAPM,EACb,aAAa,GAMX,KAAK,cANM,EACb,QAAQ,GAKN,KAAK,SALC,EACR,oBAAoB,GAIlB,KAAK,qBAJa,EACpB,WAAW,GAGT,KAAK,YAHI,EACX,wBAAwB,GAEtB,KAAK,yBAFiB,EACxB,cAAc,GACZ,KAAK,eADO,CACN;QAEV,mGAAmG;QACnG,IAAM,QAAQ,GAAG;YACf,aAAa,eAAA;YACb,aAAa,eAAA;YACb,QAAQ,UAAA;YACR,oBAAoB,sBAAA;YACpB,WAAW,aAAA;YACX,wBAAwB,0BAAA;YACxB,cAAc,gBAAA;SACf,CAAC;QAEF,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;IACtB,CAAC;IAvBD,8EAuBC","sourcesContent":["import type { MenuListContextValues, MenuListState } from './MenuList.types';\n\nexport function useMenuListContextValues_unstable(state: MenuListState): MenuListContextValues {\n const {\n checkedValues,\n hasCheckmarks,\n hasIcons,\n onCheckedValueChange,\n selectRadio,\n setFocusByFirstCharacter,\n toggleCheckbox,\n } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const menuList = {\n checkedValues,\n hasCheckmarks,\n hasIcons,\n onCheckedValueChange,\n selectRadio,\n setFocusByFirstCharacter,\n toggleCheckbox,\n };\n\n return { menuList };\n}\n"]}
@@ -0,0 +1,21 @@
1
+ define(["require", "exports", "tslib", "@griffel/react"], function (require, exports, tslib_1, react_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuListStyles_unstable = exports.menuListClassNames = void 0;
5
+ exports.menuListClassNames = {
6
+ root: 'fui-MenuList',
7
+ };
8
+ var useStyles = react_1.makeStyles({
9
+ root: tslib_1.__assign({ display: 'flex', flexDirection: 'column' }, react_1.shorthands.gap('2px')),
10
+ });
11
+ /**
12
+ * Apply styling to the Menu slots based on the state
13
+ */
14
+ var useMenuListStyles_unstable = function (state) {
15
+ var styles = useStyles();
16
+ state.root.className = react_1.mergeClasses(exports.menuListClassNames.root, styles.root, state.root.className);
17
+ return state;
18
+ };
19
+ exports.useMenuListStyles_unstable = useMenuListStyles_unstable;
20
+ });
21
+ //# sourceMappingURL=useMenuListStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuListStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuList/useMenuListStyles.ts"],"names":[],"mappings":";;;;IAIa,QAAA,kBAAkB,GAAkC;QAC/D,IAAI,EAAE,cAAc;KACrB,CAAC;IAEF,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,qBACF,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,IACpB,kBAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CACzB;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,0BAA0B,GAAG,UAAC,KAAoB;QAC7D,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CAAC,0BAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChG,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAJW,QAAA,0BAA0B,8BAIrC","sourcesContent":["import type { SlotClassNames } from '@fluentui/react-utilities';\nimport { mergeClasses, makeStyles, shorthands } from '@griffel/react';\nimport type { MenuListSlots, MenuListState } from './MenuList.types';\n\nexport const menuListClassNames: SlotClassNames<MenuListSlots> = {\n root: 'fui-MenuList',\n};\n\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n flexDirection: 'column',\n ...shorthands.gap('2px'),\n },\n});\n\n/**\n * Apply styling to the Menu slots based on the state\n */\nexport const useMenuListStyles_unstable = (state: MenuListState): MenuListState => {\n const styles = useStyles();\n state.root.className = mergeClasses(menuListClassNames.root, styles.root, state.root.className);\n return state;\n};\n"]}
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "react", "./useMenuPopover", "./useMenuPopoverStyles", "./renderMenuPopover"], function (require, exports, React, useMenuPopover_1, useMenuPopoverStyles_1, renderMenuPopover_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MenuPopover = void 0;
5
+ /**
6
+ * Popover intended to wrap `MenuList` and adds styling and interaction support specific to menus
7
+ */
8
+ exports.MenuPopover = React.forwardRef(function (props, ref) {
9
+ var state = useMenuPopover_1.useMenuPopover_unstable(props, ref);
10
+ useMenuPopoverStyles_1.useMenuPopoverStyles_unstable(state);
11
+ return renderMenuPopover_1.renderMenuPopover_unstable(state);
12
+ });
13
+ exports.MenuPopover.displayName = 'MenuPopover';
14
+ });
15
+ //# sourceMappingURL=MenuPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuPopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/MenuPopover.tsx"],"names":[],"mappings":";;;;IAOA;;OAEG;IACU,QAAA,WAAW,GAA0C,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAC5F,IAAM,KAAK,GAAG,wCAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAElD,oDAA6B,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,8CAA0B,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,mBAAW,CAAC,WAAW,GAAG,aAAa,CAAC","sourcesContent":["import * as React from 'react';\nimport { useMenuPopover_unstable } from './useMenuPopover';\nimport { useMenuPopoverStyles_unstable } from './useMenuPopoverStyles';\nimport { renderMenuPopover_unstable } from './renderMenuPopover';\nimport type { MenuPopoverProps } from './MenuPopover.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Popover intended to wrap `MenuList` and adds styling and interaction support specific to menus\n */\nexport const MenuPopover: ForwardRefComponent<MenuPopoverProps> = React.forwardRef((props, ref) => {\n const state = useMenuPopover_unstable(props, ref);\n\n useMenuPopoverStyles_unstable(state);\n return renderMenuPopover_unstable(state);\n});\n\nMenuPopover.displayName = 'MenuPopover';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=MenuPopover.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuPopover.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/MenuPopover.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type MenuPopoverSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * MenuPopover Props\n */\nexport type MenuPopoverProps = ComponentProps<MenuPopoverSlots>;\n\n/**\n * State used in rendering MenuPopover\n */\nexport type MenuPopoverState = ComponentState<MenuPopoverSlots> & {\n /**\n * Root menus are rendered out of DOM order on `document.body`, use this to render the menu in DOM order\n * This option is disregarded for submenus\n */\n inline: boolean;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./MenuPopover", "./MenuPopover.types", "./renderMenuPopover", "./useMenuPopover", "./useMenuPopoverStyles"], function (require, exports, tslib_1, MenuPopover_1, MenuPopover_types_1, renderMenuPopover_1, useMenuPopover_1, useMenuPopoverStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(MenuPopover_1, exports);
5
+ tslib_1.__exportStar(MenuPopover_types_1, exports);
6
+ tslib_1.__exportStar(renderMenuPopover_1, exports);
7
+ tslib_1.__exportStar(useMenuPopover_1, exports);
8
+ tslib_1.__exportStar(useMenuPopoverStyles_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/index.ts"],"names":[],"mappings":";;;IAAA,6CAA8B;IAC9B,mDAAoC;IACpC,mDAAoC;IACpC,gDAAiC;IACjC,sDAAuC","sourcesContent":["export * from './MenuPopover';\nexport * from './MenuPopover.types';\nexport * from './renderMenuPopover';\nexport * from './useMenuPopover';\nexport * from './useMenuPopoverStyles';\n"]}
@@ -0,0 +1,18 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-portal"], function (require, exports, tslib_1, React, react_utilities_1, react_portal_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderMenuPopover_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of MenuPopover
7
+ */
8
+ var renderMenuPopover_unstable = function (state) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ if (state.inline) {
11
+ return React.createElement(slots.root, tslib_1.__assign({}, slotProps.root));
12
+ }
13
+ return (React.createElement(react_portal_1.Portal, null,
14
+ React.createElement(slots.root, tslib_1.__assign({}, slotProps.root))));
15
+ };
16
+ exports.renderMenuPopover_unstable = renderMenuPopover_unstable;
17
+ });
18
+ //# sourceMappingURL=renderMenuPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMenuPopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/renderMenuPopover.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,0BAA0B,GAAG,UAAC,KAAuB;QAC1D,IAAA,KAAuB,0BAAQ,CAAmB,KAAK,CAAC,EAAtD,KAAK,WAAA,EAAE,SAAS,eAAsC,CAAC;QAE/D,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,OAAO,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CAAC;SAC3C;QAED,OAAO,CACL,oBAAC,qBAAM;YACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CAC3B,CACV,CAAC;IACJ,CAAC,CAAC;IAZW,QAAA,0BAA0B,8BAYrC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport { Portal } from '@fluentui/react-portal';\n\n/**\n * Render the final JSX of MenuPopover\n */\nexport const renderMenuPopover_unstable = (state: MenuPopoverState) => {\n const { slots, slotProps } = getSlots<MenuPopoverSlots>(state);\n\n if (state.inline) {\n return <slots.root {...slotProps.root} />;\n }\n\n return (\n <Portal>\n <slots.root {...slotProps.root} />\n </Portal>\n );\n};\n"]}
@@ -0,0 +1,82 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/keyboard-keys", "@fluentui/react-utilities", "../../contexts/menuContext", "../../utils/index", "@fluentui/react-shared-contexts", "../../utils/useIsSubmenu"], function (require, exports, tslib_1, React, keyboard_keys_1, react_utilities_1, menuContext_1, index_1, react_shared_contexts_1, useIsSubmenu_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuPopover_unstable = void 0;
5
+ /**
6
+ * Create the state required to render MenuPopover.
7
+ *
8
+ * The returned state can be modified with hooks such as useMenuPopoverStyles_unstable,
9
+ * before being passed to renderMenuPopover_unstable.
10
+ *
11
+ * @param props - props from this instance of MenuPopover
12
+ * @param ref - reference to root HTMLElement of MenuPopover
13
+ */
14
+ var useMenuPopover_unstable = function (props, ref) {
15
+ var _a;
16
+ var popoverRef = menuContext_1.useMenuContext_unstable(function (context) { return context.menuPopoverRef; });
17
+ var setOpen = menuContext_1.useMenuContext_unstable(function (context) { return context.setOpen; });
18
+ var open = menuContext_1.useMenuContext_unstable(function (context) { return context.open; });
19
+ var openOnHover = menuContext_1.useMenuContext_unstable(function (context) { return context.openOnHover; });
20
+ var isSubmenu = useIsSubmenu_1.useIsSubmenu();
21
+ var canDispatchCustomEventRef = React.useRef(true);
22
+ var throttleDispatchTimerRef = React.useRef(0);
23
+ var dir = react_shared_contexts_1.useFluent_unstable().dir;
24
+ var CloseArrowKey = dir === 'ltr' ? keyboard_keys_1.ArrowLeft : keyboard_keys_1.ArrowRight;
25
+ // use DOM listener since react events propagate up the react tree
26
+ // no need to do `contains` logic as menus are all positioned in different portals
27
+ var mouseOverListenerCallbackRef = React.useCallback(function (node) {
28
+ if (node) {
29
+ // Dispatches the custom menu mouse enter event with throttling
30
+ // Needs to trigger on mouseover to support keyboard + mouse together
31
+ // i.e. keyboard opens submenus while cursor is still on the parent
32
+ node.addEventListener('mouseover', function (e) {
33
+ if (canDispatchCustomEventRef.current) {
34
+ canDispatchCustomEventRef.current = false;
35
+ index_1.dispatchMenuEnterEvent(popoverRef.current, e);
36
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
+ // @ts-ignore #16889 Node setTimeout type leaking
38
+ throttleDispatchTimerRef.current = setTimeout(function () { return (canDispatchCustomEventRef.current = true); }, 250);
39
+ }
40
+ });
41
+ }
42
+ }, [popoverRef, throttleDispatchTimerRef]);
43
+ React.useEffect(function () {
44
+ (function () { return clearTimeout(throttleDispatchTimerRef.current); });
45
+ }, []);
46
+ var inline = (_a = menuContext_1.useMenuContext_unstable(function (context) { return context.inline; })) !== null && _a !== void 0 ? _a : false;
47
+ var rootProps = react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({ role: 'presentation' }, props), { ref: react_utilities_1.useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef) }));
48
+ var onMouseEnterOriginal = rootProps.onMouseEnter, onKeyDownOriginal = rootProps.onKeyDown;
49
+ rootProps.onMouseEnter = react_utilities_1.useEventCallback(function (event) {
50
+ if (openOnHover) {
51
+ setOpen(event, { open: true, keyboard: false, type: 'menuPopoverMouseEnter', event: event });
52
+ }
53
+ onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(event);
54
+ });
55
+ rootProps.onKeyDown = react_utilities_1.useEventCallback(function (event) {
56
+ var _a;
57
+ var key = event.key;
58
+ if (key === keyboard_keys_1.Escape || (isSubmenu && key === CloseArrowKey)) {
59
+ if (open && ((_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
60
+ setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event: event });
61
+ // stop propagation to avoid conflicting with other elements that listen for `Escape`
62
+ // e,g: Dialog, Popover and Tooltip
63
+ event.stopPropagation();
64
+ }
65
+ }
66
+ if (key === keyboard_keys_1.Tab) {
67
+ setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event: event });
68
+ event.preventDefault();
69
+ }
70
+ onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(event);
71
+ });
72
+ return {
73
+ inline: inline,
74
+ components: {
75
+ root: 'div',
76
+ },
77
+ root: rootProps,
78
+ };
79
+ };
80
+ exports.useMenuPopover_unstable = useMenuPopover_unstable;
81
+ });
82
+ //# sourceMappingURL=useMenuPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuPopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/useMenuPopover.ts"],"names":[],"mappings":";;;;IASA;;;;;;;;OAQG;IACI,IAAM,uBAAuB,GAAG,UAAC,KAAuB,EAAE,GAA2B;;QAC1F,IAAM,UAAU,GAAG,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AAC,OAAO,0CAAE,QAAQ,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAA,EAAE;oBACrE,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;oBACnF,qFAAqF;oBACrF,mCAAmC;oBACnC,KAAK,CAAC,eAAe,EAAE,CAAC;iBACzB;aACF;YAED,IAAI,GAAG,KAAK,mBAAG,EAAE;gBACf,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;gBACnF,KAAK,CAAC,cAAc,EAAE,CAAC;aACxB;YAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,QAAA;YACN,UAAU,EAAE;gBACV,IAAI,EAAE,KAAK;aACZ;YACD,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC,CAAC;IAlFW,QAAA,uBAAuB,2BAkFlC","sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { getNativeElementProps, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { MenuPopoverProps, MenuPopoverState } from './MenuPopover.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { dispatchMenuEnterEvent } from '../../utils/index';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\n\n/**\n * Create the state required to render MenuPopover.\n *\n * The returned state can be modified with hooks such as useMenuPopoverStyles_unstable,\n * before being passed to renderMenuPopover_unstable.\n *\n * @param props - props from this instance of MenuPopover\n * @param ref - reference to root HTMLElement of MenuPopover\n */\nexport const useMenuPopover_unstable = (props: MenuPopoverProps, ref: React.Ref<HTMLElement>): MenuPopoverState => {\n const popoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const throttleDispatchTimerRef = React.useRef(0);\n\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\n\n // use DOM listener since react events propagate up the react tree\n // no need to do `contains` logic as menus are all positioned in different portals\n const mouseOverListenerCallbackRef = React.useCallback(\n (node: HTMLElement) => {\n if (node) {\n // Dispatches the custom menu mouse enter event with throttling\n // Needs to trigger on mouseover to support keyboard + mouse together\n // i.e. keyboard opens submenus while cursor is still on the parent\n node.addEventListener('mouseover', e => {\n if (canDispatchCustomEventRef.current) {\n canDispatchCustomEventRef.current = false;\n dispatchMenuEnterEvent(popoverRef.current as HTMLElement, e);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore #16889 Node setTimeout type leaking\n throttleDispatchTimerRef.current = setTimeout(() => (canDispatchCustomEventRef.current = true), 250);\n }\n });\n }\n },\n [popoverRef, throttleDispatchTimerRef],\n );\n\n React.useEffect(() => {\n () => clearTimeout(throttleDispatchTimerRef.current);\n }, []);\n\n const inline = useMenuContext_unstable(context => context.inline) ?? false;\n const rootProps = getNativeElementProps('div', {\n role: 'presentation',\n ...props,\n ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef),\n });\n\n const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;\n\n rootProps.onMouseEnter = useEventCallback((event: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(event, { open: true, keyboard: false, type: 'menuPopoverMouseEnter', event });\n }\n\n onMouseEnterOriginal?.(event);\n });\n\n rootProps.onKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n const key = event.key;\n\n if (key === Escape || (isSubmenu && key === CloseArrowKey)) {\n if (open && popoverRef.current?.contains(event.target as HTMLElement)) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover and Tooltip\n event.stopPropagation();\n }\n }\n\n if (key === Tab) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n event.preventDefault();\n }\n\n onKeyDownOriginal?.(event);\n });\n\n return {\n inline,\n components: {\n root: 'div',\n },\n root: rootProps,\n };\n};\n"]}
@@ -0,0 +1,21 @@
1
+ define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-theme"], function (require, exports, tslib_1, react_1, react_theme_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuPopoverStyles_unstable = exports.menuPopoverClassNames = void 0;
5
+ exports.menuPopoverClassNames = {
6
+ root: 'fui-MenuPopover',
7
+ };
8
+ var useStyles = react_1.makeStyles({
9
+ root: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)), { backgroundColor: react_theme_1.tokens.colorNeutralBackground1, minWidth: '128px', maxWidth: '300px', width: 'max-content', boxShadow: "" + react_theme_1.tokens.shadow16 }), react_1.shorthands.padding('4px')), react_1.shorthands.border('1px', 'solid', react_theme_1.tokens.colorTransparentStroke)),
10
+ });
11
+ /**
12
+ * Apply styling to the Menu slots based on the state
13
+ */
14
+ var useMenuPopoverStyles_unstable = function (state) {
15
+ var styles = useStyles();
16
+ state.root.className = react_1.mergeClasses(exports.menuPopoverClassNames.root, styles.root, state.root.className);
17
+ return state;
18
+ };
19
+ exports.useMenuPopoverStyles_unstable = useMenuPopoverStyles_unstable;
20
+ });
21
+ //# sourceMappingURL=useMenuPopoverStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuPopoverStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/useMenuPopoverStyles.ts"],"names":[],"mappings":";;;;IAKa,QAAA,qBAAqB,GAAqC;QACrE,IAAI,EAAE,iBAAiB;KACxB,CAAC;IAEF,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,0EACC,kBAAU,CAAC,YAAY,CAAC,oBAAM,CAAC,kBAAkB,CAAC,KACrD,eAAe,EAAE,oBAAM,CAAC,uBAAuB,EAC/C,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,KAAG,oBAAM,CAAC,QAAU,KAC5B,kBAAU,CAAC,OAAO,CAAC,KAAK,CAAC,GACzB,kBAAU,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,oBAAM,CAAC,sBAAsB,CAAC,CACpE;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,6BAA6B,GAAG,UAAC,KAAuB;QACnE,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CAAC,6BAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnG,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAJW,QAAA,6BAA6B,iCAIxC","sourcesContent":["import { shorthands, mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const menuPopoverClassNames: SlotClassNames<MenuPopoverSlots> = {\n root: 'fui-MenuPopover',\n};\n\nconst useStyles = makeStyles({\n root: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n backgroundColor: tokens.colorNeutralBackground1,\n minWidth: '128px',\n maxWidth: '300px',\n width: 'max-content',\n boxShadow: `${tokens.shadow16}`,\n ...shorthands.padding('4px'),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n },\n});\n\n/**\n * Apply styling to the Menu slots based on the state\n */\nexport const useMenuPopoverStyles_unstable = (state: MenuPopoverState): MenuPopoverState => {\n const styles = useStyles();\n state.root.className = mergeClasses(menuPopoverClassNames.root, styles.root, state.root.className);\n return state;\n};\n"]}
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "react", "./useMenuSplitGroup", "./renderMenuSplitGroup", "./useMenuSplitGroupStyles"], function (require, exports, React, useMenuSplitGroup_1, renderMenuSplitGroup_1, useMenuSplitGroupStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MenuSplitGroup = void 0;
5
+ /**
6
+ * Layout wrapper that provides extra keyboard navigation behavior for two `MenuItem` components.
7
+ */
8
+ exports.MenuSplitGroup = React.forwardRef(function (props, ref) {
9
+ var state = useMenuSplitGroup_1.useMenuSplitGroup_unstable(props, ref);
10
+ useMenuSplitGroupStyles_1.useMenuSplitGroupStyles_unstable(state);
11
+ return renderMenuSplitGroup_1.renderMenuSplitGroup_unstable(state);
12
+ });
13
+ exports.MenuSplitGroup.displayName = 'MenuSplitGroup';
14
+ });
15
+ //# sourceMappingURL=MenuSplitGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/MenuSplitGroup.tsx"],"names":[],"mappings":";;;;IAOA;;OAEG;IACU,QAAA,cAAc,GAA6C,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAClG,IAAM,KAAK,GAAG,8CAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAErD,0DAAgC,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,oDAA6B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\nimport { useMenuSplitGroup_unstable } from './useMenuSplitGroup';\nimport { renderMenuSplitGroup_unstable } from './renderMenuSplitGroup';\nimport { useMenuSplitGroupStyles_unstable } from './useMenuSplitGroupStyles';\nimport type { MenuSplitGroupProps } from './MenuSplitGroup.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Layout wrapper that provides extra keyboard navigation behavior for two `MenuItem` components.\n */\nexport const MenuSplitGroup: ForwardRefComponent<MenuSplitGroupProps> = React.forwardRef((props, ref) => {\n const state = useMenuSplitGroup_unstable(props, ref);\n\n useMenuSplitGroupStyles_unstable(state);\n return renderMenuSplitGroup_unstable(state);\n});\n\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=MenuSplitGroup.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuSplitGroup.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/MenuSplitGroup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type MenuSplitGroupSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * MenuSplitGroup Props\n */\nexport type MenuSplitGroupProps = ComponentProps<MenuSplitGroupSlots>;\n\n/**\n * State used in rendering MenuSplitGroup\n */\nexport type MenuSplitGroupState = ComponentState<MenuSplitGroupSlots>;\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./MenuSplitGroup", "./MenuSplitGroup.types", "./renderMenuSplitGroup", "./useMenuSplitGroup", "./useMenuSplitGroupStyles"], function (require, exports, tslib_1, MenuSplitGroup_1, MenuSplitGroup_types_1, renderMenuSplitGroup_1, useMenuSplitGroup_1, useMenuSplitGroupStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(MenuSplitGroup_1, exports);
5
+ tslib_1.__exportStar(MenuSplitGroup_types_1, exports);
6
+ tslib_1.__exportStar(renderMenuSplitGroup_1, exports);
7
+ tslib_1.__exportStar(useMenuSplitGroup_1, exports);
8
+ tslib_1.__exportStar(useMenuSplitGroupStyles_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/index.ts"],"names":[],"mappings":";;;IAAA,gDAAiC;IACjC,sDAAuC;IACvC,sDAAuC;IACvC,mDAAoC;IACpC,yDAA0C","sourcesContent":["export * from './MenuSplitGroup';\nexport * from './MenuSplitGroup.types';\nexport * from './renderMenuSplitGroup';\nexport * from './useMenuSplitGroup';\nexport * from './useMenuSplitGroupStyles';\n"]}
@@ -0,0 +1,14 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderMenuSplitGroup_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of MenuSplitGroup
7
+ */
8
+ var renderMenuSplitGroup_unstable = function (state) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return React.createElement(slots.root, tslib_1.__assign({}, slotProps.root));
11
+ };
12
+ exports.renderMenuSplitGroup_unstable = renderMenuSplitGroup_unstable;
13
+ });
14
+ //# sourceMappingURL=renderMenuSplitGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/renderMenuSplitGroup.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,6BAA6B,GAAG,UAAC,KAA0B;QAChE,IAAA,KAAuB,0BAAQ,CAAsB,KAAK,CAAC,EAAzD,KAAK,WAAA,EAAE,SAAS,eAAyC,CAAC;QAElE,OAAO,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CAAC;IAC5C,CAAC,CAAC;IAJW,QAAA,6BAA6B,iCAIxC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { MenuSplitGroupState, MenuSplitGroupSlots } from './MenuSplitGroup.types';\n\n/**\n * Render the final JSX of MenuSplitGroup\n */\nexport const renderMenuSplitGroup_unstable = (state: MenuSplitGroupState) => {\n const { slots, slotProps } = getSlots<MenuSplitGroupSlots>(state);\n\n return <slots.root {...slotProps.root} />;\n};\n"]}
@@ -0,0 +1,47 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-tabster", "@fluentui/react-shared-contexts", "@fluentui/keyboard-keys"], function (require, exports, tslib_1, React, react_utilities_1, react_tabster_1, react_shared_contexts_1, keyboard_keys_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMenuSplitGroup_unstable = void 0;
5
+ /**
6
+ * Create the state required to render MenuSplitGroup.
7
+ *
8
+ * The returned state can be modified with hooks such as useMenuSplitGroupStyles_unstable,
9
+ * before being passed to renderMenuSplitGroup_unstable.
10
+ *
11
+ * @param props - props from this instance of MenuSplitGroup
12
+ * @param ref - reference to root HTMLElement of MenuSplitGroup
13
+ */
14
+ var useMenuSplitGroup_unstable = function (props, ref) {
15
+ var innerRef = React.useRef();
16
+ var _a = react_shared_contexts_1.useFluent_unstable(), dir = _a.dir, targetDocument = _a.targetDocument;
17
+ var nextArrowKey = react_utilities_1.getRTLSafeKey(keyboard_keys_1.ArrowRight, dir);
18
+ var prevArrowKey = react_utilities_1.getRTLSafeKey(keyboard_keys_1.ArrowLeft, dir);
19
+ var _b = react_tabster_1.useFocusFinders(), findNextFocusable = _b.findNextFocusable, findPrevFocusable = _b.findPrevFocusable;
20
+ var onKeyDown = React.useCallback(function (e) {
21
+ var _a;
22
+ var activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
23
+ if (!activeElement) {
24
+ return;
25
+ }
26
+ if (!((_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.contains(activeElement))) {
27
+ return;
28
+ }
29
+ if (e.key === nextArrowKey) {
30
+ var next = findNextFocusable(activeElement, { container: innerRef.current });
31
+ next === null || next === void 0 ? void 0 : next.focus();
32
+ }
33
+ if (e.key === prevArrowKey) {
34
+ var prev = findPrevFocusable(activeElement, { container: innerRef.current });
35
+ prev === null || prev === void 0 ? void 0 : prev.focus();
36
+ }
37
+ }, [findNextFocusable, findPrevFocusable, targetDocument, nextArrowKey, prevArrowKey]);
38
+ return {
39
+ components: {
40
+ root: 'div',
41
+ },
42
+ root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign({ role: 'group', ref: react_utilities_1.useMergedRefs(ref, innerRef), onKeyDown: onKeyDown }, props)),
43
+ };
44
+ };
45
+ exports.useMenuSplitGroup_unstable = useMenuSplitGroup_unstable;
46
+ });
47
+ //# sourceMappingURL=useMenuSplitGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/useMenuSplitGroup.ts"],"names":[],"mappings":";;;;IAOA;;;;;;;;OAQG;IACI,IAAM,0BAA0B,GAAG,UACxC,KAA0B,EAC1B,GAA2B;QAE3B,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAe,CAAC;QACvC,IAAA,KAA0B,0CAAS,EAAE,EAAnC,GAAG,SAAA,EAAE,cAAc,oBAAgB,CAAC;QAE5C,IAAM,YAAY,GAAG,+BA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AS,WAAA,IACN,KAAK,EACR;SACH,CAAC;IACJ,CAAC,CAAC;IA/CW,QAAA,0BAA0B,8BA+CrC","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, getRTLSafeKey, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport type { MenuSplitGroupProps, MenuSplitGroupState } from './MenuSplitGroup.types';\nimport { ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render MenuSplitGroup.\n *\n * The returned state can be modified with hooks such as useMenuSplitGroupStyles_unstable,\n * before being passed to renderMenuSplitGroup_unstable.\n *\n * @param props - props from this instance of MenuSplitGroup\n * @param ref - reference to root HTMLElement of MenuSplitGroup\n */\nexport const useMenuSplitGroup_unstable = (\n props: MenuSplitGroupProps,\n ref: React.Ref<HTMLElement>,\n): MenuSplitGroupState => {\n const innerRef = React.useRef<HTMLElement>();\n const { dir, targetDocument } = useFluent();\n\n const nextArrowKey = getRTLSafeKey(ArrowRight, dir);\n const prevArrowKey = getRTLSafeKey(ArrowLeft, dir);\n\n const { findNextFocusable, findPrevFocusable } = useFocusFinders();\n\n const onKeyDown = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n const activeElement = targetDocument?.activeElement;\n if (!activeElement) {\n return;\n }\n\n if (!innerRef.current?.contains(activeElement)) {\n return;\n }\n\n if (e.key === nextArrowKey) {\n const next = findNextFocusable(activeElement as HTMLElement, { container: innerRef.current });\n next?.focus();\n }\n\n if (e.key === prevArrowKey) {\n const prev = findPrevFocusable(activeElement as HTMLElement, { container: innerRef.current });\n prev?.focus();\n }\n },\n [findNextFocusable, findPrevFocusable, targetDocument, nextArrowKey, prevArrowKey],\n );\n\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n role: 'group',\n ref: useMergedRefs(ref, innerRef),\n onKeyDown,\n ...props,\n }),\n };\n};\n"]}
@@ -0,0 +1,43 @@
1
+ define(["require", "exports", "@griffel/react", "@fluentui/react-theme", "../MenuItem/useMenuItemStyles"], function (require, exports, react_1, react_theme_1, useMenuItemStyles_1) {
2
+ "use strict";
3
+ var _a;
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.useMenuSplitGroupStyles_unstable = exports.menuSplitGroupClassNames = void 0;
6
+ exports.menuSplitGroupClassNames = {
7
+ root: 'fui-MenuSplitGroup',
8
+ };
9
+ /**
10
+ * Styles for the root slot
11
+ */
12
+ var useStyles = react_1.makeStyles({
13
+ root: (_a = {
14
+ display: 'flex'
15
+ },
16
+ _a["& > ." + useMenuItemStyles_1.menuItemClassNames.root + ":nth-child(1)"] = {
17
+ width: '100%',
18
+ },
19
+ _a["& > ." + useMenuItemStyles_1.menuItemClassNames.root + ":nth-child(2)"] = {
20
+ borderTopLeftRadius: 0,
21
+ borderBottomLeftRadius: 0,
22
+ paddingLeft: 0,
23
+ marginLeft: 'auto',
24
+ '::before': {
25
+ content: '""',
26
+ width: react_theme_1.tokens.strokeWidthThin,
27
+ height: '24px',
28
+ backgroundColor: react_theme_1.tokens.colorNeutralStroke1,
29
+ },
30
+ },
31
+ _a),
32
+ });
33
+ /**
34
+ * Apply styling to the MenuSplitGroup slots based on the state
35
+ */
36
+ var useMenuSplitGroupStyles_unstable = function (state) {
37
+ var styles = useStyles();
38
+ state.root.className = react_1.mergeClasses(exports.menuSplitGroupClassNames.root, styles.root, state.root.className);
39
+ return state;
40
+ };
41
+ exports.useMenuSplitGroupStyles_unstable = useMenuSplitGroupStyles_unstable;
42
+ });
43
+ //# sourceMappingURL=useMenuSplitGroupStyles.js.map