@fluentui/react-menu 9.12.16 → 9.12.20
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/CHANGELOG.json +247 -1
- package/CHANGELOG.md +69 -2
- package/lib/components/Menu/useMenu.js +6 -8
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +3 -4
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +6 -6
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +3 -3
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +3 -3
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +3 -5
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +2 -4
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +4 -6
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +11 -13
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +4 -2
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +4 -2
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +6 -8
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +3 -4
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +6 -6
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +3 -3
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +3 -3
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +3 -5
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +2 -4
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js +4 -6
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +11 -13
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +4 -2
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +4 -2
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/package.json +12 -12
@@ -50,19 +50,19 @@ const useMenuItem_unstable = (props, ref)=>{
|
|
50
50
|
disabledFocusable: disabled,
|
51
51
|
ref: (0, _reactutilities.useMergedRefs)(ref, innerRef),
|
52
52
|
onKeyDown: (0, _reactutilities.useEventCallback)((event)=>{
|
53
|
-
var _props_onKeyDown
|
54
|
-
(_props_onKeyDown =
|
53
|
+
var _props_onKeyDown;
|
54
|
+
(_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, event);
|
55
55
|
if (!event.isDefaultPrevented() && (event.key === _keyboardkeys.Space || event.key === _keyboardkeys.Enter)) {
|
56
56
|
dismissedWithKeyboardRef.current = true;
|
57
57
|
}
|
58
58
|
}),
|
59
59
|
onMouseEnter: (0, _reactutilities.useEventCallback)((event)=>{
|
60
|
-
var _innerRef_current, _props_onMouseEnter
|
60
|
+
var _innerRef_current, _props_onMouseEnter;
|
61
61
|
(_innerRef_current = innerRef.current) === null || _innerRef_current === void 0 ? void 0 : _innerRef_current.focus();
|
62
|
-
(_props_onMouseEnter =
|
62
|
+
(_props_onMouseEnter = props.onMouseEnter) === null || _props_onMouseEnter === void 0 ? void 0 : _props_onMouseEnter.call(props, event);
|
63
63
|
}),
|
64
64
|
onClick: (0, _reactutilities.useEventCallback)((event)=>{
|
65
|
-
var _props_onClick
|
65
|
+
var _props_onClick;
|
66
66
|
if (!hasSubmenu && !persistOnClick) {
|
67
67
|
setOpen(event, {
|
68
68
|
open: false,
|
@@ -73,7 +73,7 @@ const useMenuItem_unstable = (props, ref)=>{
|
|
73
73
|
});
|
74
74
|
dismissedWithKeyboardRef.current = false;
|
75
75
|
}
|
76
|
-
(_props_onClick =
|
76
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);
|
77
77
|
})
|
78
78
|
})), {
|
79
79
|
elementType: 'div'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuItem.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback, useMergedRefs, getNativeElementProps, slot } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useCharacterSearch } from './useCharacterSearch';\nimport { useMenuTriggerContext_unstable } from '../../contexts/menuTriggerContext';\nimport { ChevronRightFilled, ChevronRightRegular, ChevronLeftFilled, ChevronLeftRegular, bundleIcon } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nconst ChevronRightIcon = bundleIcon(ChevronRightFilled, ChevronRightRegular);\nconst ChevronLeftIcon = bundleIcon(ChevronLeftFilled, ChevronLeftRegular);\n/**\n * Returns the props and state required to render the component\n */ export const useMenuItem_unstable = (props, ref)=>{\n const isSubmenuTrigger = useMenuTriggerContext_unstable();\n const persistOnClickContext = useMenuContext_unstable((context)=>context.persistOnItemClick);\n const { as = 'div', disabled = false, hasSubmenu = isSubmenuTrigger, persistOnClick = persistOnClickContext } = props;\n const hasIcons = useMenuListContext_unstable((context)=>context.hasIcons);\n const hasCheckmarks = useMenuListContext_unstable((context)=>context.hasCheckmarks);\n const setOpen = useMenuContext_unstable((context)=>context.setOpen);\n const { dir } = useFluent();\n const innerRef = React.useRef(null);\n const dismissedWithKeyboardRef = React.useRef(false);\n const state = {\n hasSubmenu,\n disabled,\n persistOnClick,\n components: {\n root: 'div',\n icon: 'span',\n checkmark: 'span',\n submenuIndicator: 'span',\n content: 'span',\n secondaryContent: 'span'\n },\n root: slot.always(getNativeElementProps(as, useARIAButtonProps(as, {\n role: 'menuitem',\n ...props,\n disabled: false,\n disabledFocusable: disabled,\n ref: useMergedRefs(ref, innerRef),\n onKeyDown: useEventCallback((event)=>{\n var _props_onKeyDown
|
1
|
+
{"version":3,"sources":["useMenuItem.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback, useMergedRefs, getNativeElementProps, slot } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useCharacterSearch } from './useCharacterSearch';\nimport { useMenuTriggerContext_unstable } from '../../contexts/menuTriggerContext';\nimport { ChevronRightFilled, ChevronRightRegular, ChevronLeftFilled, ChevronLeftRegular, bundleIcon } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nconst ChevronRightIcon = bundleIcon(ChevronRightFilled, ChevronRightRegular);\nconst ChevronLeftIcon = bundleIcon(ChevronLeftFilled, ChevronLeftRegular);\n/**\n * Returns the props and state required to render the component\n */ export const useMenuItem_unstable = (props, ref)=>{\n const isSubmenuTrigger = useMenuTriggerContext_unstable();\n const persistOnClickContext = useMenuContext_unstable((context)=>context.persistOnItemClick);\n const { as = 'div', disabled = false, hasSubmenu = isSubmenuTrigger, persistOnClick = persistOnClickContext } = props;\n const hasIcons = useMenuListContext_unstable((context)=>context.hasIcons);\n const hasCheckmarks = useMenuListContext_unstable((context)=>context.hasCheckmarks);\n const setOpen = useMenuContext_unstable((context)=>context.setOpen);\n const { dir } = useFluent();\n const innerRef = React.useRef(null);\n const dismissedWithKeyboardRef = React.useRef(false);\n const state = {\n hasSubmenu,\n disabled,\n persistOnClick,\n components: {\n root: 'div',\n icon: 'span',\n checkmark: 'span',\n submenuIndicator: 'span',\n content: 'span',\n secondaryContent: 'span'\n },\n root: slot.always(getNativeElementProps(as, useARIAButtonProps(as, {\n role: 'menuitem',\n ...props,\n disabled: false,\n disabledFocusable: disabled,\n ref: useMergedRefs(ref, innerRef),\n onKeyDown: useEventCallback((event)=>{\n var _props_onKeyDown;\n (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, event);\n if (!event.isDefaultPrevented() && (event.key === Space || event.key === Enter)) {\n dismissedWithKeyboardRef.current = true;\n }\n }),\n onMouseEnter: useEventCallback((event)=>{\n var _innerRef_current, _props_onMouseEnter;\n (_innerRef_current = innerRef.current) === null || _innerRef_current === void 0 ? void 0 : _innerRef_current.focus();\n (_props_onMouseEnter = props.onMouseEnter) === null || _props_onMouseEnter === void 0 ? void 0 : _props_onMouseEnter.call(props, event);\n }),\n onClick: useEventCallback((event)=>{\n var _props_onClick;\n if (!hasSubmenu && !persistOnClick) {\n setOpen(event, {\n open: false,\n keyboard: dismissedWithKeyboardRef.current,\n bubble: true,\n type: 'menuItemClick',\n event\n });\n dismissedWithKeyboardRef.current = false;\n }\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);\n })\n })), {\n elementType: 'div'\n }),\n icon: slot.optional(props.icon, {\n renderByDefault: hasIcons,\n elementType: 'span'\n }),\n checkmark: slot.optional(props.checkmark, {\n renderByDefault: hasCheckmarks,\n elementType: 'span'\n }),\n submenuIndicator: slot.optional(props.submenuIndicator, {\n renderByDefault: hasSubmenu,\n defaultProps: {\n children: dir === 'ltr' ? /*#__PURE__*/ React.createElement(ChevronRightIcon, null) : /*#__PURE__*/ React.createElement(ChevronLeftIcon, null)\n },\n elementType: 'span'\n }),\n content: slot.optional(props.content, {\n renderByDefault: !!props.children,\n defaultProps: {\n children: props.children\n },\n elementType: 'span'\n }),\n secondaryContent: slot.optional(props.secondaryContent, {\n elementType: 'span'\n })\n };\n useCharacterSearch(state, innerRef);\n return state;\n};\n"],"names":["useMenuItem_unstable","ChevronRightIcon","bundleIcon","ChevronRightFilled","ChevronRightRegular","ChevronLeftIcon","ChevronLeftFilled","ChevronLeftRegular","props","ref","isSubmenuTrigger","useMenuTriggerContext_unstable","persistOnClickContext","useMenuContext_unstable","context","persistOnItemClick","as","disabled","hasSubmenu","persistOnClick","hasIcons","useMenuListContext_unstable","hasCheckmarks","setOpen","dir","useFluent","innerRef","React","useRef","dismissedWithKeyboardRef","state","components","root","icon","checkmark","submenuIndicator","content","secondaryContent","slot","always","getNativeElementProps","useARIAButtonProps","role","disabledFocusable","useMergedRefs","onKeyDown","useEventCallback","event","_props_onKeyDown","call","isDefaultPrevented","key","Space","Enter","current","onMouseEnter","_innerRef_current","_props_onMouseEnter","focus","onClick","_props_onClick","open","keyboard","bubble","type","elementType","optional","renderByDefault","defaultProps","children","createElement","useCharacterSearch"],"mappings":";;;;+BAciBA;;;eAAAA;;;;iEAdM;gCACsD;qCAC7B;oCACb;oCACY;4BAC4D;iCAC/D;6BACJ;2BACL;8BACN;AAC7B,MAAMC,mBAAmBC,IAAAA,sBAAU,EAACC,8BAAkB,EAAEC,+BAAmB;AAC3E,MAAMC,kBAAkBH,IAAAA,sBAAU,EAACI,6BAAiB,EAAEC,8BAAkB;AAG7D,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4D,aAAa;QACjB;QACA7B,SAASE,oBAAI,CAAC4B,QAAQ,CAAC1D,MAAM4B,OAAO,EAAE;YAClC+B,iBAAiB,CAAC,CAAC3D,MAAM6D,QAAQ;YACjCD,cAAc;gBACVC,UAAU7D,MAAM6D,QAAQ;YAC5B;YACAJ,aAAa;QACjB;QACA5B,kBAAkBC,oBAAI,CAAC4B,QAAQ,CAAC1D,MAAM6B,gBAAgB,EAAE;YACpD4B,aAAa;QACjB;IACJ;IACAM,IAAAA,sCAAkB,EAACzC,OAAOJ;IAC1B,OAAOI;AACX"}
|
@@ -36,9 +36,9 @@ const useMenuItemCheckbox_unstable = (props, ref)=>{
|
|
36
36
|
elementType: 'span'
|
37
37
|
}),
|
38
38
|
onClick: (e)=>{
|
39
|
-
var
|
40
|
-
|
41
|
-
(_props_onClick =
|
39
|
+
var _props_onClick;
|
40
|
+
toggleCheckbox === null || toggleCheckbox === void 0 ? void 0 : toggleCheckbox(e, name, value, checked);
|
41
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);
|
42
42
|
}
|
43
43
|
}, ref),
|
44
44
|
name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuItemCheckbox.js"],"sourcesContent":["import * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\n/** Returns the props and state required to render the component */ export const useMenuItemCheckbox_unstable = (props, ref)=>{\n const toggleCheckbox = useMenuListContext_unstable((context)=>context.toggleCheckbox);\n const { name, value } = props;\n const checked = useMenuListContext_unstable((context)=>{\n var _context_checkedValues;\n const checkedItems = ((_context_checkedValues = context.checkedValues) === null || _context_checkedValues === void 0 ? void 0 : _context_checkedValues[name]) || [];\n return checkedItems.indexOf(value) !== -1;\n });\n const state = {\n ...useMenuItem_unstable({\n role: 'menuitemcheckbox',\n persistOnClick: true,\n ...props,\n 'aria-checked': checked,\n checkmark: slot.optional(props.checkmark, {\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(Checkmark16Filled, null)\n },\n renderByDefault: true,\n elementType: 'span'\n }),\n onClick: (e)=>{\n var
|
1
|
+
{"version":3,"sources":["useMenuItemCheckbox.js"],"sourcesContent":["import * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\n/** Returns the props and state required to render the component */ export const useMenuItemCheckbox_unstable = (props, ref)=>{\n const toggleCheckbox = useMenuListContext_unstable((context)=>context.toggleCheckbox);\n const { name, value } = props;\n const checked = useMenuListContext_unstable((context)=>{\n var _context_checkedValues;\n const checkedItems = ((_context_checkedValues = context.checkedValues) === null || _context_checkedValues === void 0 ? void 0 : _context_checkedValues[name]) || [];\n return checkedItems.indexOf(value) !== -1;\n });\n const state = {\n ...useMenuItem_unstable({\n role: 'menuitemcheckbox',\n persistOnClick: true,\n ...props,\n 'aria-checked': checked,\n checkmark: slot.optional(props.checkmark, {\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(Checkmark16Filled, null)\n },\n renderByDefault: true,\n elementType: 'span'\n }),\n onClick: (e)=>{\n var _props_onClick;\n toggleCheckbox === null || toggleCheckbox === void 0 ? void 0 : toggleCheckbox(e, name, value, checked);\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);\n }\n }, ref),\n name,\n value,\n checked\n };\n return state;\n};\n"],"names":["useMenuItemCheckbox_unstable","props","ref","toggleCheckbox","useMenuListContext_unstable","context","name","value","checked","_context_checkedValues","checkedItems","checkedValues","indexOf","state","useMenuItem_unstable","role","persistOnClick","checkmark","slot","optional","defaultProps","children","React","createElement","Checkmark16Filled","renderByDefault","elementType","onClick","e","_props_onClick","call"],"mappings":";;;;+BAKi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-
(_props_onClick =
|
38
|
+
var _props_onClick;
|
39
|
+
selectRadio === null || selectRadio === void 0 ? void 0 : selectRadio(e, name, value, checked);
|
40
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);
|
41
41
|
}
|
42
42
|
}, ref),
|
43
43
|
checked,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuItemRadio.js"],"sourcesContent":["import * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\n/**\n * Given user props, returns state and render function for a MenuItemRadio.\n */ export const useMenuItemRadio_unstable = (props, ref)=>{\n const { name, value } = props;\n const checked = useMenuListContext_unstable((context)=>{\n var _context_checkedValues;\n const checkedItems = ((_context_checkedValues = context.checkedValues) === null || _context_checkedValues === void 0 ? void 0 : _context_checkedValues[name]) || [];\n return checkedItems.indexOf(value) !== -1;\n });\n const selectRadio = useMenuListContext_unstable((context)=>context.selectRadio);\n return {\n ...useMenuItem_unstable({\n ...props,\n role: 'menuitemradio',\n 'aria-checked': checked,\n checkmark: slot.optional(props.checkmark, {\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(Checkmark16Filled, null)\n },\n renderByDefault: true,\n elementType: 'span'\n }),\n onClick: (e)=>{\n var
|
1
|
+
{"version":3,"sources":["useMenuItemRadio.js"],"sourcesContent":["import * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\n/**\n * Given user props, returns state and render function for a MenuItemRadio.\n */ export const useMenuItemRadio_unstable = (props, ref)=>{\n const { name, value } = props;\n const checked = useMenuListContext_unstable((context)=>{\n var _context_checkedValues;\n const checkedItems = ((_context_checkedValues = context.checkedValues) === null || _context_checkedValues === void 0 ? void 0 : _context_checkedValues[name]) || [];\n return checkedItems.indexOf(value) !== -1;\n });\n const selectRadio = useMenuListContext_unstable((context)=>context.selectRadio);\n return {\n ...useMenuItem_unstable({\n ...props,\n role: 'menuitemradio',\n 'aria-checked': checked,\n checkmark: slot.optional(props.checkmark, {\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(Checkmark16Filled, null)\n },\n renderByDefault: true,\n elementType: 'span'\n }),\n onClick: (e)=>{\n var _props_onClick;\n selectRadio === null || selectRadio === void 0 ? void 0 : selectRadio(e, name, value, checked);\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, e);\n }\n }, ref),\n checked,\n name,\n value\n };\n};\n"],"names":["useMenuItemRadio_unstable","props","ref","name","value","checked","useMenuListContext_unstable","context","_context_checkedValues","checkedItems","checkedValues","indexOf","selectRadio","useMenuItem_unstable","role","checkmark","slot","optional","defaultProps","children","React","createElement","Checkmark16Filled","renderByDefault","elementType","onClick","e","_props_onClick","call"],"mappings":";;;;+BAOiBA;;;eAAAA;;;;iEAPM;gCACF;4BACa;iCACU;6BACP;AAG1B,MAAMA,4BAA4B,CAACC,OAAOC;IACjD,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH;IACxB,MAAMI,UAAUC,IAAAA,4CAA2B,EAAC,CAACC;QACzC,IAAIC;QACJ,MAAMC,eAAe,AAAC,CAAA,AAACD,CAAAA,yBAAyBD,QAAQG,aAAa,AAAD,MAAO,QAAQF,2BAA2B,KAAK,IAAI,KAAK,IAAIA,sBAAsB,CAACL,KAAK,AAAD,KAAM,EAAE;QACnK,OAAOM,aAAaE,OAAO,CAACP,WAAW,CAAC;IAC5C;IACA,MAAMQ,cAAcN,IAAAA,4CAA2B,EAAC,CAACC,UAAUA,QAAQK,WAAW;IAC9E,OAAO;QACH,GAAGC,IAAAA,iCAAoB,EAAC;YACpB,GAAGZ,KAAK;YACRa,MAAM;YACN,gBAAgBT;YAChBU,WAAWC,oBAAI,CAACC,QAAQ,CAAChB,MAAMc,SAAS,EAAE;gBACtCG,cAAc;oBACVC,UAAU,WAAW,GAAGC,OAAMC,aAAa,CAACC,6BAAiB,EAAE;gBACnE;gBACAC,iBAAiB;gBACjBC,aAAa;YACjB;YACAC,SAAS,CAACC;gBACN,IAAIC;gBACJf,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYc,GAAGvB,MAAMC,OAAOC;gBACrFsB,CAAAA,iBAAiB1B,MAAMwB,OAAO,AAAD,MAAO,QAAQE,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeC,IAAI,CAAC3B,OAAOyB;YACjH;QACJ,GAAGxB,IAAI;QACPG;QACAF;QACAC;IACJ;AACJ"}
|
@@ -80,8 +80,7 @@ const useMenuList_unstable = (props, ref)=>{
|
|
80
80
|
var _props_onCheckedValueChange;
|
81
81
|
const handleCheckedValueChange = (_props_onCheckedValueChange = props.onCheckedValueChange) !== null && _props_onCheckedValueChange !== void 0 ? _props_onCheckedValueChange : hasMenuContext ? menuContext.onCheckedValueChange : undefined;
|
82
82
|
const toggleCheckbox = (0, _reactutilities.useEventCallback)((e, name, value, checked)=>{
|
83
|
-
|
84
|
-
const checkedItems = ((_checkedValues = checkedValues) === null || _checkedValues === void 0 ? void 0 : _checkedValues[name]) || [];
|
83
|
+
const checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];
|
85
84
|
const newCheckedItems = [
|
86
85
|
...checkedItems
|
87
86
|
];
|
@@ -90,7 +89,7 @@ const useMenuList_unstable = (props, ref)=>{
|
|
90
89
|
} else {
|
91
90
|
newCheckedItems.push(value);
|
92
91
|
}
|
93
|
-
|
92
|
+
handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {
|
94
93
|
name,
|
95
94
|
checkedItems: newCheckedItems
|
96
95
|
});
|
@@ -100,7 +99,6 @@ const useMenuList_unstable = (props, ref)=>{
|
|
100
99
|
}));
|
101
100
|
});
|
102
101
|
const selectRadio = (0, _reactutilities.useEventCallback)((e, name, value)=>{
|
103
|
-
var _handleCheckedValueChange;
|
104
102
|
const newCheckedItems = [
|
105
103
|
value
|
106
104
|
];
|
@@ -108,7 +106,7 @@ const useMenuList_unstable = (props, ref)=>{
|
|
108
106
|
...s,
|
109
107
|
[name]: newCheckedItems
|
110
108
|
}));
|
111
|
-
|
109
|
+
handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {
|
112
110
|
name,
|
113
111
|
checkedItems: newCheckedItems
|
114
112
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuList.js"],"sourcesContent":["import * as React from 'react';\nimport { useMergedRefs, useEventCallback, useControllableState, getNativeElementProps, slot } 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';\n/**\n * Returns the props and state required to render the component\n */ export const useMenuList_unstable = (props, ref)=>{\n const { findAllFocusable } = useFocusFinders();\n const menuContext = useMenuContextSelectors();\n const hasMenuContext = useHasParentContext(MenuContext);\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n ignoreDefaultKeydown: {\n Tab: hasMenuContext\n }\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 const innerRef = React.useRef(null);\n const setFocusByFirstCharacter = React.useCallback((e, itemEl)=>{\n // TODO use some kind of children registration to reduce dependency on DOM roles\n const acceptedRoles = [\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio'\n ];\n if (!innerRef.current) {\n return;\n }\n const menuItems = findAllFocusable(innerRef.current, (el)=>el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')) !== -1);\n let startIndex = menuItems.indexOf(itemEl) + 1;\n if (startIndex === menuItems.length) {\n startIndex = 0;\n }\n const firstChars = menuItems.map((menuItem)=>{\n var _menuItem_textContent;\n return (_menuItem_textContent = menuItem.textContent) === null || _menuItem_textContent === void 0 ? void 0 : _menuItem_textContent.charAt(0).toLowerCase();\n });\n const char = e.key.toLowerCase();\n const getIndexFirstChars = (start, firstChar)=>{\n for(let i = start; i < firstChars.length; i++){\n if (char === firstChars[i]) {\n return i;\n }\n }\n return -1;\n };\n // Check remaining slots in the menu\n let index = getIndexFirstChars(startIndex, char);\n // If not found in remaining slots, check from beginning\n if (index === -1) {\n index = getIndexFirstChars(0, char);\n }\n // If match was found...\n if (index > -1) {\n menuItems[index].focus();\n }\n }, [\n findAllFocusable\n ]);\n var _props_checkedValues;\n const [checkedValues, setCheckedValues] = useControllableState({\n state: (_props_checkedValues = props.checkedValues) !== null && _props_checkedValues !== void 0 ? _props_checkedValues : hasMenuContext ? menuContext.checkedValues : undefined,\n defaultState: props.defaultCheckedValues,\n initialState: {}\n });\n var _props_onCheckedValueChange;\n const handleCheckedValueChange = (_props_onCheckedValueChange = props.onCheckedValueChange) !== null && _props_onCheckedValueChange !== void 0 ? _props_onCheckedValueChange : hasMenuContext ? menuContext.onCheckedValueChange : undefined;\n const toggleCheckbox = useEventCallback((e, name, value, checked)=>{\n var _checkedValues, _handleCheckedValueChange;\n const checkedItems = ((_checkedValues = checkedValues) === null || _checkedValues === void 0 ? void 0 : _checkedValues[name]) || [];\n const newCheckedItems = [\n ...checkedItems\n ];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n (_handleCheckedValueChange = handleCheckedValueChange) === null || _handleCheckedValueChange === void 0 ? void 0 : _handleCheckedValueChange(e, {\n name,\n checkedItems: newCheckedItems\n });\n setCheckedValues((s)=>({\n ...s,\n [name]: newCheckedItems\n }));\n });\n const selectRadio = useEventCallback((e, name, value)=>{\n var _handleCheckedValueChange;\n const newCheckedItems = [\n value\n ];\n setCheckedValues((s)=>({\n ...s,\n [name]: newCheckedItems\n }));\n (_handleCheckedValueChange = handleCheckedValueChange) === null || _handleCheckedValueChange === void 0 ? void 0 : _handleCheckedValueChange(e, {\n name,\n checkedItems: newCheckedItems\n });\n });\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'menu',\n 'aria-labelledby': menuContext.triggerId,\n ...focusAttributes,\n ...props\n }), {\n elementType: 'div'\n }),\n hasIcons: menuContext.hasIcons || false,\n hasCheckmarks: menuContext.hasCheckmarks || false,\n checkedValues,\n hasMenuContext,\n setFocusByFirstCharacter,\n selectRadio,\n toggleCheckbox\n };\n};\n/**\n * Adds some sugar to fetching multiple context selector values\n */ const useMenuContextSelectors = ()=>{\n const checkedValues = useMenuContext_unstable((context)=>context.checkedValues);\n const onCheckedValueChange = useMenuContext_unstable((context)=>context.onCheckedValueChange);\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 return {\n checkedValues,\n onCheckedValueChange,\n triggerId,\n hasIcons,\n hasCheckmarks\n };\n};\n/**\n * Helper function to detect if props and MenuContext values are both used\n */ const usingPropsAndMenuContext = (props, contextValue, hasMenuContext)=>{\n let isUsingPropsAndContext = false;\n for(const val in contextValue){\n if (props[val]) {\n isUsingPropsAndContext = true;\n }\n }\n return hasMenuContext && isUsingPropsAndContext;\n};\n"],"names":["useMenuList_unstable","props","ref","findAllFocusable","useFocusFinders","menuContext","useMenuContextSelectors","hasMenuContext","useHasParentContext","MenuContext","focusAttributes","useArrowNavigationGroup","circular","ignoreDefaultKeydown","Tab","usingPropsAndMenuContext","console","warn","innerRef","React","useRef","setFocusByFirstCharacter","useCallback","e","itemEl","acceptedRoles","current","menuItems","el","hasAttribute","indexOf","getAttribute","startIndex","length","firstChars","map","menuItem","_menuItem_textContent","textContent","charAt","toLowerCase","char","key","getIndexFirstChars","start","firstChar","i","index","focus","_props_checkedValues","checkedValues","setCheckedValues","useControllableState","state","undefined","defaultState","defaultCheckedValues","initialState","_props_onCheckedValueChange","handleCheckedValueChange","onCheckedValueChange","toggleCheckbox","useEventCallback","name","value","checked","_checkedValues","_handleCheckedValueChange","checkedItems","newCheckedItems","splice","push","s","selectRadio","components","root","slot","always","getNativeElementProps","useMergedRefs","role","triggerId","elementType","hasIcons","hasCheckmarks","useMenuContext_unstable","context","contextValue","isUsingPropsAndContext","val"],"mappings":";;;;+BAQiBA;;;eAAAA;;;;iEARM;gCAC4E;8BAC1C;sCACrB;6BACI;AAI7B,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,IAAAA,6BAAe;IAC5C,MAAMC,cAAcC;IACpB,MAAMC,iBAAiBC,IAAAA,yCAAmB,EAACC,wBAAW;IACtD,MAAMC,kBAAkBC,IAAAA,qCAAuB,EAAC;QAC5CC,UAAU;QACVC,sBAAsB;YAClBC,KAAKP;QACT;IACJ;IACA,IAAIQ,yBAAyBd,OAAOI,aAAaE,iBAAiB;QAC9D,4CAA4C;QAC5C,sCAAsC;QACtCS,QAAQC,IAAI,CAAC;IACjB;IACA,MAAMC,WAAWC,OAAMC,MAAM,CAAC;IAC9B,MAAMC,2BAA2BF,OAAMG,WAAW,CAAC,CAACC,GAAGC;QACnD,gFAAgF;QAChF,MAAMC,gBAAgB;YAClB;YACA;YACA;SACH;QACD,IAAI,CAACP,SAASQ,OAAO,EAAE;YACnB;QACJ;QACA,MAAMC,YAAYxB,iBAAiBe,SAASQ,OAAO,EAAE,CAACE,KAAKA,GAAGC,YAAY,CAAC,WAAWJ,cAAcK,OAAO,CAACF,GAAGG,YAAY,CAAC,aAAa,CAAC;QAC1I,IAAIC,aAAaL,UAAUG,OAAO,CAACN,UAAU;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/E,YAAY+E,aAAa,IAAI;QAC5ClC;QACA3C;QACAc;QACAoD;QACAZ;IACJ;AACJ;AACA;;CAEC,GAAG,MAAMvD,0BAA0B;IAChC,MAAM4C,gBAAgBmC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQpC,aAAa;IAC9E,MAAMU,uBAAuByB,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQ1B,oBAAoB;IAC5F,MAAMqB,YAAYI,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQL,SAAS;IACtE,MAAME,WAAWE,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQH,QAAQ;IACpE,MAAMC,gBAAgBC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQF,aAAa;IAC9E,OAAO;QACHlC;QACAU;QACAqB;QACAE;QACAC;IACJ;AACJ;AACA;;CAEC,GAAG,MAAMrE,2BAA2B,CAACd,OAAOsF,cAAchF;IACvD,IAAIiF,yBAAyB;IAC7B,IAAI,MAAMC,OAAOF,aAAa;QAC1B,IAAItF,KAAK,CAACwF,IAAI,EAAE;YACZD,yBAAyB;QAC7B;IACJ;IACA,OAAOjF,kBAAkBiF;AAC7B"}
|
1
|
+
{"version":3,"sources":["useMenuList.js"],"sourcesContent":["import * as React from 'react';\nimport { useMergedRefs, useEventCallback, useControllableState, getNativeElementProps, slot } 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';\n/**\n * Returns the props and state required to render the component\n */ export const useMenuList_unstable = (props, ref)=>{\n const { findAllFocusable } = useFocusFinders();\n const menuContext = useMenuContextSelectors();\n const hasMenuContext = useHasParentContext(MenuContext);\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n ignoreDefaultKeydown: {\n Tab: hasMenuContext\n }\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 const innerRef = React.useRef(null);\n const setFocusByFirstCharacter = React.useCallback((e, itemEl)=>{\n // TODO use some kind of children registration to reduce dependency on DOM roles\n const acceptedRoles = [\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio'\n ];\n if (!innerRef.current) {\n return;\n }\n const menuItems = findAllFocusable(innerRef.current, (el)=>el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')) !== -1);\n let startIndex = menuItems.indexOf(itemEl) + 1;\n if (startIndex === menuItems.length) {\n startIndex = 0;\n }\n const firstChars = menuItems.map((menuItem)=>{\n var _menuItem_textContent;\n return (_menuItem_textContent = menuItem.textContent) === null || _menuItem_textContent === void 0 ? void 0 : _menuItem_textContent.charAt(0).toLowerCase();\n });\n const char = e.key.toLowerCase();\n const getIndexFirstChars = (start, firstChar)=>{\n for(let i = start; i < firstChars.length; i++){\n if (char === firstChars[i]) {\n return i;\n }\n }\n return -1;\n };\n // Check remaining slots in the menu\n let index = getIndexFirstChars(startIndex, char);\n // If not found in remaining slots, check from beginning\n if (index === -1) {\n index = getIndexFirstChars(0, char);\n }\n // If match was found...\n if (index > -1) {\n menuItems[index].focus();\n }\n }, [\n findAllFocusable\n ]);\n var _props_checkedValues;\n const [checkedValues, setCheckedValues] = useControllableState({\n state: (_props_checkedValues = props.checkedValues) !== null && _props_checkedValues !== void 0 ? _props_checkedValues : hasMenuContext ? menuContext.checkedValues : undefined,\n defaultState: props.defaultCheckedValues,\n initialState: {}\n });\n var _props_onCheckedValueChange;\n const handleCheckedValueChange = (_props_onCheckedValueChange = props.onCheckedValueChange) !== null && _props_onCheckedValueChange !== void 0 ? _props_onCheckedValueChange : hasMenuContext ? menuContext.onCheckedValueChange : undefined;\n const toggleCheckbox = useEventCallback((e, name, value, checked)=>{\n const checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];\n const newCheckedItems = [\n ...checkedItems\n ];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {\n name,\n checkedItems: newCheckedItems\n });\n setCheckedValues((s)=>({\n ...s,\n [name]: newCheckedItems\n }));\n });\n const selectRadio = useEventCallback((e, name, value)=>{\n const newCheckedItems = [\n value\n ];\n setCheckedValues((s)=>({\n ...s,\n [name]: newCheckedItems\n }));\n handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {\n name,\n checkedItems: newCheckedItems\n });\n });\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'menu',\n 'aria-labelledby': menuContext.triggerId,\n ...focusAttributes,\n ...props\n }), {\n elementType: 'div'\n }),\n hasIcons: menuContext.hasIcons || false,\n hasCheckmarks: menuContext.hasCheckmarks || false,\n checkedValues,\n hasMenuContext,\n setFocusByFirstCharacter,\n selectRadio,\n toggleCheckbox\n };\n};\n/**\n * Adds some sugar to fetching multiple context selector values\n */ const useMenuContextSelectors = ()=>{\n const checkedValues = useMenuContext_unstable((context)=>context.checkedValues);\n const onCheckedValueChange = useMenuContext_unstable((context)=>context.onCheckedValueChange);\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 return {\n checkedValues,\n onCheckedValueChange,\n triggerId,\n hasIcons,\n hasCheckmarks\n };\n};\n/**\n * Helper function to detect if props and MenuContext values are both used\n */ const usingPropsAndMenuContext = (props, contextValue, hasMenuContext)=>{\n let isUsingPropsAndContext = false;\n for(const val in contextValue){\n if (props[val]) {\n isUsingPropsAndContext = true;\n }\n }\n return hasMenuContext && isUsingPropsAndContext;\n};\n"],"names":["useMenuList_unstable","props","ref","findAllFocusable","useFocusFinders","menuContext","useMenuContextSelectors","hasMenuContext","useHasParentContext","MenuContext","focusAttributes","useArrowNavigationGroup","circular","ignoreDefaultKeydown","Tab","usingPropsAndMenuContext","console","warn","innerRef","React","useRef","setFocusByFirstCharacter","useCallback","e","itemEl","acceptedRoles","current","menuItems","el","hasAttribute","indexOf","getAttribute","startIndex","length","firstChars","map","menuItem","_menuItem_textContent","textContent","charAt","toLowerCase","char","key","getIndexFirstChars","start","firstChar","i","index","focus","_props_checkedValues","checkedValues","setCheckedValues","useControllableState","state","undefined","defaultState","defaultCheckedValues","initialState","_props_onCheckedValueChange","handleCheckedValueChange","onCheckedValueChange","toggleCheckbox","useEventCallback","name","value","checked","checkedItems","newCheckedItems","splice","push","s","selectRadio","components","root","slot","always","getNativeElementProps","useMergedRefs","role","triggerId","elementType","hasIcons","hasCheckmarks","useMenuContext_unstable","context","contextValue","isUsingPropsAndContext","val"],"mappings":";;;;+BAQiBA;;;eAAAA;;;;iEARM;gCAC4E;8BAC1C;sCACrB;6BACI;AAI7B,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,IAAAA,6BAAe;IAC5C,MAAMC,cAAcC;IACpB,MAAMC,iBAAiBC,IAAAA,yCAAmB,EAACC,wBAAW;IACtD,MAAMC,kBAAkBC,IAAAA,qCAAuB,EAAC;QAC5CC,UAAU;QACVC,sBAAsB;YAClBC,KAAKP;QACT;IACJ;IACA,IAAIQ,yBAAyBd,OAAOI,aAAaE,iBAAiB;QAC9D,4CAA4C;QAC5C,sCAAsC;QACtCS,QAAQC,IAAI,CAAC;IACjB;IACA,MAAMC,WAAWC,OAAMC,MAAM,CAAC;IAC9B,MAAMC,2BAA2BF,OAAMG,WAAW,CAAC,CAACC,GAAGC;QACnD,gFAAgF;QAChF,MAAMC,gBAAgB;YAClB;YACA;YACA;SACH;QACD,IAAI,CAACP,SAASQ,O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e;YAClB,GAAGT,KAAK;QACZ,IAAI;YACA+E,aAAa;QACjB;QACAC,UAAU5E,YAAY4E,QAAQ,IAAI;QAClCC,eAAe7E,YAAY6E,aAAa,IAAI;QAC5ChC;QACA3C;QACAc;QACAkD;QACAV;IACJ;AACJ;AACA;;CAEC,GAAG,MAAMvD,0BAA0B;IAChC,MAAM4C,gBAAgBiC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQlC,aAAa;IAC9E,MAAMU,uBAAuBuB,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQxB,oBAAoB;IAC5F,MAAMmB,YAAYI,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQL,SAAS;IACtE,MAAME,WAAWE,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQH,QAAQ;IACpE,MAAMC,gBAAgBC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQF,aAAa;IAC9E,OAAO;QACHhC;QACAU;QACAmB;QACAE;QACAC;IACJ;AACJ;AACA;;CAEC,GAAG,MAAMnE,2BAA2B,CAACd,OAAOoF,cAAc9E;IACvD,IAAI+E,yBAAyB;IAC7B,IAAI,MAAMC,OAAOF,aAAa;QAC1B,IAAIpF,KAAK,CAACsF,IAAI,EAAE;YACZD,yBAAyB;QAC7B;IACJ;IACA,OAAO/E,kBAAkB+E;AAC7B"}
|
@@ -66,7 +66,6 @@ const useMenuPopover_unstable = (props, ref)=>{
|
|
66
66
|
});
|
67
67
|
const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;
|
68
68
|
rootProps.onMouseEnter = (0, _reactutilities.useEventCallback)((event)=>{
|
69
|
-
var _onMouseEnterOriginal;
|
70
69
|
if (openOnHover) {
|
71
70
|
setOpen(event, {
|
72
71
|
open: true,
|
@@ -75,10 +74,9 @@ const useMenuPopover_unstable = (props, ref)=>{
|
|
75
74
|
event
|
76
75
|
});
|
77
76
|
}
|
78
|
-
|
77
|
+
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(event);
|
79
78
|
});
|
80
79
|
rootProps.onKeyDown = (0, _reactutilities.useEventCallback)((event)=>{
|
81
|
-
var _onKeyDownOriginal;
|
82
80
|
const key = event.key;
|
83
81
|
if (key === _keyboardkeys.Escape || isSubmenu && key === CloseArrowKey) {
|
84
82
|
var _popoverRef_current;
|
@@ -106,7 +104,7 @@ const useMenuPopover_unstable = (props, ref)=>{
|
|
106
104
|
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
107
105
|
}
|
108
106
|
}
|
109
|
-
|
107
|
+
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(event);
|
110
108
|
});
|
111
109
|
return {
|
112
110
|
inline,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuPopover.js"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { getNativeElementProps, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\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';\nimport { useRestoreFocusSource } from '@fluentui/react-tabster';\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 */ export const useMenuPopover_unstable = (props, ref)=>{\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 triggerRef = useMenuContext_unstable((context)=>context.triggerRef);\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const throttleDispatchTimerRef = React.useRef(0);\n const restoreFocusSourceAttributes = useRestoreFocusSource();\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\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((node)=>{\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, 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,\n throttleDispatchTimerRef\n ]);\n React.useEffect(()=>{\n ()=>clearTimeout(throttleDispatchTimerRef.current);\n }, []);\n var _useMenuContext_unstable;\n const inline = (_useMenuContext_unstable = useMenuContext_unstable((context)=>context.inline)) !== null && _useMenuContext_unstable !== void 0 ? _useMenuContext_unstable : false;\n const mountNode = useMenuContext_unstable((context)=>context.mountNode);\n const rootProps = slot.always(getNativeElementProps('div', {\n role: 'presentation',\n ...restoreFocusSourceAttributes,\n ...props,\n ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef)\n }), {\n elementType: 'div'\n });\n const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;\n rootProps.onMouseEnter = useEventCallback((event)=>{\n
|
1
|
+
{"version":3,"sources":["useMenuPopover.js"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { getNativeElementProps, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\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';\nimport { useRestoreFocusSource } from '@fluentui/react-tabster';\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 */ export const useMenuPopover_unstable = (props, ref)=>{\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 triggerRef = useMenuContext_unstable((context)=>context.triggerRef);\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const throttleDispatchTimerRef = React.useRef(0);\n const restoreFocusSourceAttributes = useRestoreFocusSource();\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\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((node)=>{\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, 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,\n throttleDispatchTimerRef\n ]);\n React.useEffect(()=>{\n ()=>clearTimeout(throttleDispatchTimerRef.current);\n }, []);\n var _useMenuContext_unstable;\n const inline = (_useMenuContext_unstable = useMenuContext_unstable((context)=>context.inline)) !== null && _useMenuContext_unstable !== void 0 ? _useMenuContext_unstable : false;\n const mountNode = useMenuContext_unstable((context)=>context.mountNode);\n const rootProps = slot.always(getNativeElementProps('div', {\n role: 'presentation',\n ...restoreFocusSourceAttributes,\n ...props,\n ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef)\n }), {\n elementType: 'div'\n });\n const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;\n rootProps.onMouseEnter = useEventCallback((event)=>{\n if (openOnHover) {\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuPopoverMouseEnter',\n event\n });\n }\n onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(event);\n });\n rootProps.onKeyDown = useEventCallback((event)=>{\n const key = event.key;\n if (key === Escape || isSubmenu && key === CloseArrowKey) {\n var _popoverRef_current;\n if (open && ((_popoverRef_current = popoverRef.current) === null || _popoverRef_current === void 0 ? void 0 : _popoverRef_current.contains(event.target))) {\n setOpen(event, {\n open: false,\n keyboard: true,\n type: 'menuPopoverKeyDown',\n event\n });\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 if (key === Tab) {\n setOpen(event, {\n open: false,\n keyboard: true,\n type: 'menuPopoverKeyDown',\n event\n });\n if (!isSubmenu) {\n var _triggerRef_current;\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n }\n }\n onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(event);\n });\n return {\n inline,\n mountNode,\n components: {\n root: 'div'\n },\n root: rootProps\n };\n};\n"],"names":["useMenuPopover_unstable","props","ref","popoverRef","useMenuContext_unstable","context","menuPopoverRef","setOpen","open","openOnHover","triggerRef","isSubmenu","useIsSubmenu","canDispatchCustomEventRef","React","useRef","throttleDispatchTimerRef","restoreFocusSourceAttributes","useRestoreFocusSource","dir","useFluent","CloseArrowKey","ArrowLeft","ArrowRight","mouseOverListenerCallbackRef","useCallback","node","addEventListener","e","current","dispatchMenuEnterEvent","setTimeout","useEffect","clearTimeout","_useMenuContext_unstable","inline","mountNode","rootProps","slot","always","getNativeElementProps","role","useMergedRefs","elementType","onMouseEnter","onMouseEnterOriginal","onKeyDown","onKeyDownOriginal","useEventCallback","event","keyboard","type","key","Escape","_popoverRef_current","contains","target","stopPropagation","Tab","_triggerRef_current","focus","components","root"],"mappings":";;;;+BAgBiBA;;;eAAAA;;;;iEAhBM;8BAC4B;gCAC0B;6BACrC;uBACD;qCACS;8BACnB;8BACS;AAS3B,MAAMA,0BAA0B,CAACC,OAAOC;IAC/C,MAAMC,aAAaC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQC,cAAc;IAC5E,MAAMC,UAAUH,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQE,OAAO;IAClE,MAAMC,OAAOJ,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQG,IAAI;IAC5D,MAAMC,cAAcL,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQI,WAAW;IAC1E,MAAMC,aAAaN,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQK,UAAU;IACxE,MAAMC,YAAYC,IAAAA,0BAAY;IAC9B,MAAMC,4BAA4BC,OAAMC,MAAM,CAAC;IAC/C,MAAMC,2BAA2BF,OAAMC,MAAM,CAAC;IAC9C,MAAME,+BAA+BC,IAAAA,mCAAqB;IAC1D,MAAM,EAAEC,GAAG,EAAE,GAAGC,IAAAA,uCAAS;IACzB,MAAMC,gBAAgBF,QAAQ,QAAQG,uBAAS,GAAGC,wBAAU;IAC5D,kEAAkE;IAClE,kFAAkF;IAClF,MAAMC,+BAA+BV,OAAMW,WAAW,CAAC,CAACC;Q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,IAAAA,gCAAgB,EAAC,CAACC;QACpC,MAAMG,MAAMH,MAAMG,GAAG;QACrB,IAAIA,QAAQC,oBAAM,IAAI1C,aAAayC,QAAQ/B,eAAe;YACtD,IAAIiC;YACJ,IAAI9C,QAAS,CAAA,AAAC8C,CAAAA,sBAAsBnD,WAAW0B,OAAO,AAAD,MAAO,QAAQyB,wBAAwB,KAAK,IAAI,KAAK,IAAIA,oBAAoBC,QAAQ,CAACN,MAAMO,MAAM,CAAA,GAAI;gBACvJjD,QAAQ0C,OAAO;oBACXzC,MAAM;oBACN0C,UAAU;oBACVC,MAAM;oBACNF;gBACJ;gBACA,qFAAqF;gBACrF,mCAAmC;gBACnCA,MAAMQ,eAAe;YACzB;QACJ;QACA,IAAIL,QAAQM,iBAAG,EAAE;YACbnD,QAAQ0C,OAAO;gBACXzC,MAAM;gBACN0C,UAAU;gBACVC,MAAM;gBACNF;YACJ;YACA,IAAI,CAACtC,WAAW;gBACZ,IAAIgD;gBACHA,CAAAA,sBAAsBjD,WAAWmB,OAAO,AAAD,MAAO,QAAQ8B,wBAAwB,KAAK,IAAI,KAAK,IAAIA,oBAAoBC,KAAK;YAC9H;QACJ;QACAb,sBAAsB,QAAQA,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBE;IAC5F;IACA,OAAO;QACHd;QACAC;QACAyB,YAAY;YACRC,MAAM;QACV;QACAA,MAAMzB;IACV;AACJ"}
|
@@ -21,8 +21,8 @@ const useMenuSplitGroup_unstable = (props, ref)=>{
|
|
21
21
|
const prevArrowKey = (0, _reactutilities.getRTLSafeKey)(_keyboardkeys.ArrowLeft, dir);
|
22
22
|
const { findNextFocusable, findPrevFocusable } = (0, _reacttabster.useFocusFinders)();
|
23
23
|
const onKeyDown = _react.useCallback((e)=>{
|
24
|
-
var
|
25
|
-
const activeElement =
|
24
|
+
var _innerRef_current;
|
25
|
+
const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
26
26
|
if (!activeElement) {
|
27
27
|
return;
|
28
28
|
}
|
@@ -30,18 +30,16 @@ const useMenuSplitGroup_unstable = (props, ref)=>{
|
|
30
30
|
return;
|
31
31
|
}
|
32
32
|
if (e.key === nextArrowKey) {
|
33
|
-
var _next;
|
34
33
|
const next = findNextFocusable(activeElement, {
|
35
34
|
container: innerRef.current
|
36
35
|
});
|
37
|
-
|
36
|
+
next === null || next === void 0 ? void 0 : next.focus();
|
38
37
|
}
|
39
38
|
if (e.key === prevArrowKey) {
|
40
|
-
var _prev;
|
41
39
|
const prev = findPrevFocusable(activeElement, {
|
42
40
|
container: innerRef.current
|
43
41
|
});
|
44
|
-
|
42
|
+
prev === null || prev === void 0 ? void 0 : prev.focus();
|
45
43
|
}
|
46
44
|
}, [
|
47
45
|
findNextFocusable,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuSplitGroup.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, getRTLSafeKey, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';\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 */ export const useMenuSplitGroup_unstable = (props, ref)=>{\n const innerRef = React.useRef();\n const { dir, targetDocument } = useFluent();\n const nextArrowKey = getRTLSafeKey(ArrowRight, dir);\n const prevArrowKey = getRTLSafeKey(ArrowLeft, dir);\n const { findNextFocusable, findPrevFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback((e)=>{\n var
|
1
|
+
{"version":3,"sources":["useMenuSplitGroup.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, getRTLSafeKey, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';\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 */ export const useMenuSplitGroup_unstable = (props, ref)=>{\n const innerRef = React.useRef();\n const { dir, targetDocument } = useFluent();\n const nextArrowKey = getRTLSafeKey(ArrowRight, dir);\n const prevArrowKey = getRTLSafeKey(ArrowLeft, dir);\n const { findNextFocusable, findPrevFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback((e)=>{\n var _innerRef_current;\n const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;\n if (!activeElement) {\n return;\n }\n if (!((_innerRef_current = innerRef.current) === null || _innerRef_current === void 0 ? void 0 : _innerRef_current.contains(activeElement))) {\n return;\n }\n if (e.key === nextArrowKey) {\n const next = findNextFocusable(activeElement, {\n container: innerRef.current\n });\n next === null || next === void 0 ? void 0 : next.focus();\n }\n if (e.key === prevArrowKey) {\n const prev = findPrevFocusable(activeElement, {\n container: innerRef.current\n });\n prev === null || prev === void 0 ? void 0 : prev.focus();\n }\n }, [\n findNextFocusable,\n findPrevFocusable,\n targetDocument,\n nextArrowKey,\n prevArrowKey\n ]);\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n role: 'group',\n ref: useMergedRefs(ref, innerRef),\n onKeyDown,\n ...props\n }), {\n elementType: 'div'\n })\n };\n};\n"],"names":["useMenuSplitGroup_unstable","props","ref","innerRef","React","useRef","dir","targetDocument","useFluent","nextArrowKey","getRTLSafeKey","ArrowRight","prevArrowKey","ArrowLeft","findNextFocusable","findPrevFocusable","useFocusFinders","onKeyDown","useCallback","e","_innerRef_current","activeElement","current","contains","key","next","container","focus","prev","components","root","slot","always","getNativeElementProps","role","useMergedRefs","elementType"],"mappings":";;;;+BAaiBA;;;eAAAA;;;;iEAbM;gCACmD;8BAC1C;qCACgB;8BACV;AAS3B,MAAMA,6BAA6B,CAACC,OAAOC;IAClD,MAAMC,WAAWC,OAAMC,MAAM;IAC7B,MAAM,EAAEC,GAAG,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACzC,MAAMC,eAAeC,IAAAA,6BAAa,EAACC,wBAAU,EAAEL;IAC/C,MAAMM,eAAeF,IAAAA,6BAAa,EAACG,uBAAS,EAAEP;IAC9C,MAAM,EAAEQ,iBAAiB,EAAEC,iBAAiB,EAAE,GAAGC,IAAAA,6BAAe;IAChE,MAAMC,YAAYb,OAAMc,WAAW,CAAC,CAACC;QACjC,IAAIC;QACJ,MAAMC,gBAAgBd,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAec,aAAa;QAClH,IAAI,CAACA,eAAe;YAChB;QACJ;QACA,IAAI,CAAE,CAAA,AAACD,CAAAA,oBAAoBjB,SAASmB,OAAO,AAAD,MAAO,QAAQF,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBG,QAAQ,CAACF,cAAa,GAAI;YACzI;QACJ;QACA,IAAIF,EAAEK,GAAG,KAAKf,cAAc;YACxB,MAAMgB,OAAOX,kBAAkBO,eAAe;gBAC1CK,WAAWvB,SAASmB,OAAO;YAC/B;YACAG,SAAS,QAAQA,SAAS,KAAK,IAAI,KAAK,IAAIA,KAAKE,KAAK;QAC1D;QACA,IAAIR,EAAEK,GAAG,KAAKZ,cAAc;YACxB,MAAMgB,OAAOb,kBAAkBM,eAAe;gBAC1CK,WAAWvB,SAASmB,OAAO;YAC/B;YACAM,SAAS,QAAQA,SAAS,KAAK,IAAI,KAAK,IAAIA,KAAKD,KAAK;QAC1D;IACJ,GAAG;QACCb;QACAC;QACAR;QACAE;QACAG;KACH;IACD,OAAO;QACHiB,YAAY;YACRC,MAAM;QACV;QACAA,MAAMC,oBAAI,CAACC,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3CC,MAAM;YACNhC,KAAKiC,IAAAA,6BAAa,EAACjC,KAAKC;YACxBc;YACA,GAAGhB,KAAK;QACZ,IAAI;YACAmC,aAAa;QACjB;IACJ;AACJ"}
|
@@ -18,7 +18,6 @@ const _keyboardkeys = require("@fluentui/keyboard-keys");
|
|
18
18
|
const _reactutilities = require("@fluentui/react-utilities");
|
19
19
|
const _reactaria = require("@fluentui/react-aria");
|
20
20
|
const useMenuTrigger_unstable = (props)=>{
|
21
|
-
var _child, _child1, _child2, _child3, _child4, _child5, _child6, _child7, _child8, _child9;
|
22
21
|
const { children, disableButtonEnhancement = false } = props;
|
23
22
|
const triggerRef = (0, _menuContext.useMenuContext_unstable)((context)=>context.triggerRef);
|
24
23
|
const menuPopoverRef = (0, _menuContext.useMenuContext_unstable)((context)=>context.menuPopoverRef);
|
@@ -31,9 +30,8 @@ const useMenuTrigger_unstable = (props)=>{
|
|
31
30
|
const isSubmenu = (0, _useIsSubmenu.useIsSubmenu)();
|
32
31
|
const { findFirstFocusable } = (0, _reacttabster.useFocusFinders)();
|
33
32
|
const focusFirst = _react.useCallback(()=>{
|
34
|
-
var _firstFocusable;
|
35
33
|
const firstFocusable = findFirstFocusable(menuPopoverRef.current);
|
36
|
-
|
34
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
37
35
|
}, [
|
38
36
|
findFirstFocusable,
|
39
37
|
menuPopoverRef
|
@@ -142,22 +140,22 @@ const useMenuTrigger_unstable = (props)=>{
|
|
142
140
|
};
|
143
141
|
const contextMenuProps = {
|
144
142
|
id: triggerId,
|
145
|
-
...
|
146
|
-
ref: (0, _reactutilities.useMergedRefs)(triggerRef,
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
143
|
+
...child === null || child === void 0 ? void 0 : child.props,
|
144
|
+
ref: (0, _reactutilities.useMergedRefs)(triggerRef, child === null || child === void 0 ? void 0 : child.ref),
|
145
|
+
...restoreFocusTargetAttribute,
|
146
|
+
onMouseEnter: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onMouseEnter, onMouseEnter)),
|
147
|
+
onMouseLeave: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onMouseLeave, onMouseLeave)),
|
148
|
+
onContextMenu: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)),
|
149
|
+
onMouseMove: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onMouseMove, onMouseMove))
|
151
150
|
};
|
152
151
|
const triggerChildProps = {
|
153
152
|
'aria-haspopup': 'menu',
|
154
153
|
'aria-expanded': !open && !isSubmenu ? undefined : open,
|
155
|
-
...restoreFocusTargetAttribute,
|
156
154
|
...contextMenuProps,
|
157
|
-
onClick: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(
|
158
|
-
onKeyDown: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(
|
155
|
+
onClick: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)),
|
156
|
+
onKeyDown: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown))
|
159
157
|
};
|
160
|
-
const ariaButtonTriggerChildProps = (0, _reactaria.useARIAButtonProps)((
|
158
|
+
const ariaButtonTriggerChildProps = (0, _reactaria.useARIAButtonProps)((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', triggerChildProps);
|
161
159
|
return {
|
162
160
|
isSubmenu,
|
163
161
|
children: (0, _reactutilities.applyTriggerPropsToChildren)(children, openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMenuTrigger.js"],"sourcesContent":["import * as React from 'react';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders, useRestoreFocusTarget } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport { applyTriggerPropsToChildren, getTriggerChild, isHTMLElement, mergeCallbacks, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */ export const useMenuTrigger_unstable = (props)=>{\n var _child, _child1, _child2, _child3, _child4, _child5, _child6, _child7, _child8, _child9;\n const { children, disableButtonEnhancement = false } = props;\n const triggerRef = useMenuContext_unstable((context)=>context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable((context)=>context.menuPopoverRef);\n const setOpen = useMenuContext_unstable((context)=>context.setOpen);\n const open = useMenuContext_unstable((context)=>context.open);\n const triggerId = useMenuContext_unstable((context)=>context.triggerId);\n const openOnHover = useMenuContext_unstable((context)=>context.openOnHover);\n const openOnContext = useMenuContext_unstable((context)=>context.openOnContext);\n const restoreFocusTargetAttribute = useRestoreFocusTarget();\n const isSubmenu = useIsSubmenu();\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(()=>{\n var _firstFocusable;\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n (_firstFocusable = firstFocusable) === null || _firstFocusable === void 0 ? void 0 : _firstFocusable.focus();\n }, [\n findFirstFocusable,\n menuPopoverRef\n ]);\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n const child = getTriggerChild(children);\n const onContextMenu = (event)=>{\n if (isTargetDisabled(event) || event.isDefaultPrevented()) {\n return;\n }\n if (openOnContext) {\n event.preventDefault();\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerContextMenu',\n event\n });\n }\n };\n const onClick = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (!openOnContext) {\n setOpen(event, {\n open: !open,\n keyboard: openedWithKeyboardRef.current,\n type: 'menuTriggerClick',\n event\n });\n openedWithKeyboardRef.current = false;\n }\n };\n const onKeyDown = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n const key = event.key;\n if (!openOnContext && (isSubmenu && key === OpenArrowKey || !isSubmenu && key === ArrowDown)) {\n setOpen(event, {\n open: true,\n keyboard: true,\n type: 'menuTriggerKeyDown',\n event\n });\n }\n if (key === Escape && !isSubmenu) {\n setOpen(event, {\n open: false,\n keyboard: true,\n type: 'menuTriggerKeyDown',\n event\n });\n }\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n const onMouseEnter = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerMouseEnter',\n event\n });\n }\n };\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerMouseMove',\n event\n });\n hasMouseMoved.current = true;\n }\n };\n const onMouseLeave = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover) {\n setOpen(event, {\n open: false,\n keyboard: false,\n type: 'menuTriggerMouseLeave',\n event\n });\n }\n };\n const contextMenuProps = {\n id: triggerId,\n ...(_child = child) === null || _child === void 0 ? void 0 : _child.props,\n ref: useMergedRefs(triggerRef, (_child1 = child) === null || _child1 === void 0 ? void 0 : _child1.ref),\n onMouseEnter: useEventCallback(mergeCallbacks((_child2 = child) === null || _child2 === void 0 ? void 0 : _child2.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks((_child3 = child) === null || _child3 === void 0 ? void 0 : _child3.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks((_child4 = child) === null || _child4 === void 0 ? void 0 : _child4.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks((_child5 = child) === null || _child5 === void 0 ? void 0 : _child5.props.onMouseMove, onMouseMove))\n };\n const triggerChildProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n ...restoreFocusTargetAttribute,\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks((_child6 = child) === null || _child6 === void 0 ? void 0 : _child6.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks((_child7 = child) === null || _child7 === void 0 ? void 0 : _child7.props.onKeyDown, onKeyDown))\n };\n const ariaButtonTriggerChildProps = useARIAButtonProps(((_child8 = child) === null || _child8 === void 0 ? void 0 : _child8.type) === 'button' || ((_child9 = child) === null || _child9 === void 0 ? void 0 : _child9.type) === 'a' ? child.type : 'div', triggerChildProps);\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(children, openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps)\n };\n};\nconst isTargetDisabled = (event)=>{\n const isDisabled = (el)=>el.hasAttribute('disabled') || el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true';\n if (isHTMLElement(event.target) && isDisabled(event.target)) {\n return true;\n }\n return isHTMLElement(event.currentTarget) && isDisabled(event.currentTarget);\n};\n"],"names":["useMenuTrigger_unstable","props","_child","_child1","_child2","_child3","_child4","_child5","_child6","_child7","_child8","_child9","children","disableButtonEnhancement","triggerRef","useMenuContext_unstable","context","menuPopoverRef","setOpen","open","triggerId","openOnHover","openOnContext","restoreFocusTargetAttribute","useRestoreFocusTarget","isSubmenu","useIsSubmenu","findFirstFocusable","useFocusFinders","focusFirst","React","useCallback","_firstFocusable","firstFocusable","current","focus","openedWithKeyboardRef","useRef","hasMouseMoved","dir","useFluent","OpenArrowKey","ArrowRight","ArrowLeft","child","getTriggerChild","onContextMenu","event","isTargetDisabled","isDefaultPrevented","preventDefault","keyboard","type","onClick","onKeyDown","key","ArrowDown","Escape","onMouseEnter","onMouseMove","onMouseLeave","contextMenuProps","id","ref","useMergedRefs","useEventCallback","mergeCallbacks","triggerChildProps","undefined","ariaButtonTriggerChildProps","useARIAButtonProps","applyTriggerPropsToChildren","isDisabled","el","hasAttribute","getAttribute","isHTMLElement","target","currentTarget"],"mappings":";;;;+BAaiBA;;;eAAAA;;;;iEAbM;6BACiB;8BACX;8BAC0B;qCACP;8BACS;gCACoE;2BAC1F;AAMxB,MAAMA,0BAA0B,CAACC;IACxC,IAAIC,QAAQC,SAASC,SAASC,SAASC,SAASC,SAASC,SAASC,SAASC,SAASC;IACpF,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGZ;IACvD,MAAMa,aAAaC,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQF,UAAU;IACxE,MAAMG,iBAAiBF,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQC,cAAc;IAChF,MAAMC,UAAUH,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQE,OAAO;IAClE,MAAMC,OAAOJ,IAAAA,oCAAuB,EAAC,CAACC,UAAUA,QAAQG,IAAI;IAC5D,MAAMC,YAAY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C,AAACzD,CAAAA,UAAUmC,KAAI,MAAO,QAAQnC,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQR,KAAK,CAACqD,SAAS,EAAEA;IACpI;IACA,MAAMe,8BAA8BC,IAAAA,6BAAkB,EAAC,AAAC,CAAA,AAAC5D,CAAAA,UAAUkC,KAAI,MAAO,QAAQlC,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQ0C,IAAI,AAAD,MAAO,YAAY,AAAC,CAAA,AAACzC,CAAAA,UAAUiC,KAAI,MAAO,QAAQjC,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQyC,IAAI,AAAD,MAAO,MAAMR,MAAMQ,IAAI,GAAG,OAAOe;IAC3P,OAAO;QACH1C;QACAb,UAAU2D,IAAAA,2CAA2B,EAAC3D,UAAUU,gBAAgBuC,mBAAmBhD,2BAA2BsD,oBAAoBE;IACtI;AACJ;AACA,MAAMrB,mBAAmB,CAACD;IACtB,MAAMyB,aAAa,CAACC,KAAKA,GAAGC,YAAY,CAAC,eAAeD,GAAGC,YAAY,CAAC,oBAAoBD,GAAGE,YAAY,CAAC,qBAAqB;IACjI,IAAIC,IAAAA,6BAAa,EAAC7B,MAAM8B,MAAM,KAAKL,WAAWzB,MAAM8B,MAAM,GAAG;QACzD,OAAO;IACX;IACA,OAAOD,IAAAA,6BAAa,EAAC7B,MAAM+B,aAAa,KAAKN,WAAWzB,MAAM+B,aAAa;AAC/E"}
|
1
|
+
{"version":3,"sources":["useMenuTrigger.js"],"sourcesContent":["import * as React from 'react';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders, useRestoreFocusTarget } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport { applyTriggerPropsToChildren, getTriggerChild, isHTMLElement, mergeCallbacks, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */ export const useMenuTrigger_unstable = (props)=>{\n const { children, disableButtonEnhancement = false } = props;\n const triggerRef = useMenuContext_unstable((context)=>context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable((context)=>context.menuPopoverRef);\n const setOpen = useMenuContext_unstable((context)=>context.setOpen);\n const open = useMenuContext_unstable((context)=>context.open);\n const triggerId = useMenuContext_unstable((context)=>context.triggerId);\n const openOnHover = useMenuContext_unstable((context)=>context.openOnHover);\n const openOnContext = useMenuContext_unstable((context)=>context.openOnContext);\n const restoreFocusTargetAttribute = useRestoreFocusTarget();\n const isSubmenu = useIsSubmenu();\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(()=>{\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();\n }, [\n findFirstFocusable,\n menuPopoverRef\n ]);\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n const child = getTriggerChild(children);\n const onContextMenu = (event)=>{\n if (isTargetDisabled(event) || event.isDefaultPrevented()) {\n return;\n }\n if (openOnContext) {\n event.preventDefault();\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerContextMenu',\n event\n });\n }\n };\n const onClick = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (!openOnContext) {\n setOpen(event, {\n open: !open,\n keyboard: openedWithKeyboardRef.current,\n type: 'menuTriggerClick',\n event\n });\n openedWithKeyboardRef.current = false;\n }\n };\n const onKeyDown = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n const key = event.key;\n if (!openOnContext && (isSubmenu && key === OpenArrowKey || !isSubmenu && key === ArrowDown)) {\n setOpen(event, {\n open: true,\n keyboard: true,\n type: 'menuTriggerKeyDown',\n event\n });\n }\n if (key === Escape && !isSubmenu) {\n setOpen(event, {\n open: false,\n keyboard: true,\n type: 'menuTriggerKeyDown',\n event\n });\n }\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n const onMouseEnter = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerMouseEnter',\n event\n });\n }\n };\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(event, {\n open: true,\n keyboard: false,\n type: 'menuTriggerMouseMove',\n event\n });\n hasMouseMoved.current = true;\n }\n };\n const onMouseLeave = (event)=>{\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover) {\n setOpen(event, {\n open: false,\n keyboard: false,\n type: 'menuTriggerMouseLeave',\n event\n });\n }\n };\n const contextMenuProps = {\n id: triggerId,\n ...child === null || child === void 0 ? void 0 : child.props,\n ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref),\n ...restoreFocusTargetAttribute,\n onMouseEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseMove, onMouseMove))\n };\n const triggerChildProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown))\n };\n const ariaButtonTriggerChildProps = useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', triggerChildProps);\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(children, openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps)\n };\n};\nconst isTargetDisabled = (event)=>{\n const isDisabled = (el)=>el.hasAttribute('disabled') || el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true';\n if (isHTMLElement(event.target) && isDisabled(event.target)) {\n return true;\n }\n return isHTMLElement(event.currentTarget) && isDisabled(event.currentTarget);\n};\n"],"names":["useMenuTrigger_unstable","props","children","disableButtonEnhancement","triggerRef","useMenuContext_unstable","context","menuPopoverRef","setOpen","open","triggerId","openOnHover","openOnContext","restoreFocusTargetAttribute","useRestoreFocusTarget","isSubmenu","useIsSubmenu","findFirstFocusable","useFocusFinders","focusFirst","React","useCallback","firstFocusable","current","focus","openedWithKeyboardRef","useRef","hasMouseMoved","dir","useFluent","OpenArrowKey","ArrowRight","ArrowLeft","child","getTriggerChild","onContextMenu","event","isTargetDisabled","isDefaultPrevented","preventDefault","keyboard","type","onClick","onKeyDown","key","ArrowDown","Escape","onMouseEnter","onMouseMove","onMouseLeave","contextMenuProps","id","ref","useMergedRefs","useEventCallback","mergeCallbacks","triggerChildProps","undefined","ariaButtonTriggerChildProps","useARIAButtonProps","applyTriggerPropsToChildren","isDisabled","el","hasAttribute","getAttribute","isHTMLElement","target","currentTarget"],"mappings":";;;;+BAaiBA;;;eAAAA;;;;iEAbM;6BACiB;8BACX;8BAC0B;qC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A,gCAAgB,EAACC,IAAAA,8BAAc,EAACtB,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMhC,KAAK,CAACyC,OAAO,EAAEA;QAC5GC,WAAWW,IAAAA,gCAAgB,EAACC,IAAAA,8BAAc,EAACtB,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMhC,KAAK,CAAC0C,SAAS,EAAEA;IACpH;IACA,MAAMe,8BAA8BC,IAAAA,6BAAkB,EAAC,AAAC1B,CAAAA,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMQ,IAAI,AAAD,MAAO,YAAY,AAACR,CAAAA,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMQ,IAAI,AAAD,MAAO,MAAMR,MAAMQ,IAAI,GAAG,OAAOe;IAC3N,OAAO;QACHzC;QACAb,UAAU0D,IAAAA,2CAA2B,EAAC1D,UAAUU,gBAAgBsC,mBAAmB/C,2BAA2BqD,oBAAoBE;IACtI;AACJ;AACA,MAAMrB,mBAAmB,CAACD;IACtB,MAAMyB,aAAa,CAACC,KAAKA,GAAGC,YAAY,CAAC,eAAeD,GAAGC,YAAY,CAAC,oBAAoBD,GAAGE,YAAY,CAAC,qBAAqB;IACjI,IAAIC,IAAAA,6BAAa,EAAC7B,MAAM8B,MAAM,KAAKL,WAAWzB,MAAM8B,MAAM,GAAG;QACzD,OAAO;IACX;IACA,OAAOD,IAAAA,6BAAa,EAAC7B,MAAM+B,aAAa,KAAKN,WAAWzB,MAAM+B,aAAa;AAC/E"}
|
@@ -23,5 +23,7 @@ const menuGroupContextDefaultValue = {
|
|
23
23
|
headerId: ''
|
24
24
|
};
|
25
25
|
const MenuGroupContextProvider = MenuGroupContext.Provider;
|
26
|
-
|
27
|
-
|
26
|
+
const useMenuGroupContext_unstable = ()=>{
|
27
|
+
var _React_useContext;
|
28
|
+
return (_React_useContext = _react.useContext(MenuGroupContext)) !== null && _React_useContext !== void 0 ? _React_useContext : menuGroupContextDefaultValue;
|
29
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["menuGroupContext.js"],"sourcesContent":["import * as React from 'react';\nconst MenuGroupContext = React.createContext(undefined);\nconst menuGroupContextDefaultValue = {\n headerId: ''\n};\nexport const MenuGroupContextProvider = MenuGroupContext.Provider;\
|
1
|
+
{"version":3,"sources":["menuGroupContext.js"],"sourcesContent":["import * as React from 'react';\nconst MenuGroupContext = React.createContext(undefined);\nconst menuGroupContextDefaultValue = {\n headerId: ''\n};\nexport const MenuGroupContextProvider = MenuGroupContext.Provider;\nexport const useMenuGroupContext_unstable = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(MenuGroupContext)) !== null && _React_useContext !== void 0 ? _React_useContext : menuGroupContextDefaultValue;\n};\n"],"names":["MenuGroupContextProvider","useMenuGroupContext_unstable","MenuGroupContext","React","createContext","undefined","menuGroupContextDefaultValue","headerId","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAKaA,wBAAwB;eAAxBA;;IACAC,4BAA4B;eAA5BA;;;;iEANU;AACvB,MAAMC,iCAAmBC,OAAMC,aAAa,CAACC;AAC7C,MAAMC,+BAA+B;IACjCC,UAAU;AACd;AACO,MAAMP,2BAA2BE,iBAAiBM,QAAQ;AAC1D,MAAMP,+BAA+B;IACxC,IAAIQ;IACJ,OAAO,AAACA,CAAAA,oBAAoBN,OAAMO,UAAU,CAACR,iBAAgB,MAAO,QAAQO,sBAAsB,KAAK,IAAIA,oBAAoBH;AACnI"}
|
@@ -23,5 +23,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
23
23
|
*/ const MenuTriggerContext = /*#__PURE__*/ _react.createContext(undefined);
|
24
24
|
const menuTriggerContextDefaultValue = false;
|
25
25
|
const MenuTriggerContextProvider = MenuTriggerContext.Provider;
|
26
|
-
|
27
|
-
|
26
|
+
const useMenuTriggerContext_unstable = ()=>{
|
27
|
+
var _React_useContext;
|
28
|
+
return (_React_useContext = _react.useContext(MenuTriggerContext)) !== null && _React_useContext !== void 0 ? _React_useContext : menuTriggerContextDefaultValue;
|
29
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["menuTriggerContext.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Context used communicate with a child menu item that it is a trigger for a submenu\n */ const MenuTriggerContext = React.createContext(undefined);\nconst menuTriggerContextDefaultValue = false;\nexport const MenuTriggerContextProvider = MenuTriggerContext.Provider;\
|
1
|
+
{"version":3,"sources":["menuTriggerContext.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Context used communicate with a child menu item that it is a trigger for a submenu\n */ const MenuTriggerContext = React.createContext(undefined);\nconst menuTriggerContextDefaultValue = false;\nexport const MenuTriggerContextProvider = MenuTriggerContext.Provider;\nexport const useMenuTriggerContext_unstable = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(MenuTriggerContext)) !== null && _React_useContext !== void 0 ? _React_useContext : menuTriggerContextDefaultValue;\n};\n"],"names":["MenuTriggerContextProvider","useMenuTriggerContext_unstable","MenuTriggerContext","React","createContext","undefined","menuTriggerContextDefaultValue","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAKaA,0BAA0B;eAA1BA;;IACAC,8BAA8B;eAA9BA;;;;iEANU;AACvB;;CAEC,GAAG,MAAMC,mCAAqBC,OAAMC,aAAa,CAACC;AACnD,MAAMC,iCAAiC;AAChC,MAAMN,6BAA6BE,mBAAmBK,QAAQ;AAC9D,MAAMN,iCAAiC;IAC1C,IAAIO;IACJ,OAAO,AAACA,CAAAA,oBAAoBL,OAAMM,UAAU,CAACP,mBAAkB,MAAO,QAAQM,sBAAsB,KAAK,IAAIA,oBAAoBF;AACrI"}
|