@fluentui/react-menu 9.0.4 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +141 -5
- package/CHANGELOG.md +41 -6
- package/dist/index.d.ts +26 -28
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/useMenu.js +46 -22
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +2 -4
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +58 -72
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +50 -30
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +25 -27
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +24 -30
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +6 -2
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +18 -23
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/contexts/menuContext.js +8 -6
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +9 -5
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js +5 -5
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +7 -3
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/selectable/types.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +47 -22
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +2 -4
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +59 -71
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +50 -30
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +26 -28
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +25 -31
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +6 -2
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +17 -22
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/contexts/menuContext.js +8 -6
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +9 -5
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +5 -5
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +7 -3
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/package.json +15 -14
- package/dist/tsdoc-metadata.json +0 -11
@@ -2,15 +2,13 @@ import { useMenuListContext_unstable } from '../../contexts/menuListContext';
|
|
2
2
|
export const useCharacterSearch = (state, ref) => {
|
3
3
|
const setFocusByFirstCharacter = useMenuListContext_unstable(context => context.setFocusByFirstCharacter);
|
4
4
|
const {
|
5
|
-
onKeyDown:
|
5
|
+
onKeyDown: originalOnKeyDown
|
6
6
|
} = state.root;
|
7
7
|
|
8
8
|
state.root.onKeyDown = e => {
|
9
9
|
var _a;
|
10
10
|
|
11
|
-
|
12
|
-
onKeyDownBase(e);
|
13
|
-
}
|
11
|
+
originalOnKeyDown === null || originalOnKeyDown === void 0 ? void 0 : originalOnKeyDown(e);
|
14
12
|
|
15
13
|
if (((_a = e.key) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
16
14
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItem/useCharacterSearch.ts"],"names":[],"mappings":"AACA,SAAS,2BAAT,QAA4C,gCAA5C;
|
1
|
+
{"version":3,"sources":["components/MenuItem/useCharacterSearch.ts"],"names":[],"mappings":"AACA,SAAS,2BAAT,QAA4C,gCAA5C;AAIA,OAAO,MAAM,kBAAkB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAA4D;EAC5F,MAAM,wBAAwB,GAAG,2BAA2B,CAAC,OAAO,IAAI,OAAO,CAAC,wBAApB,CAA5D;EAEA,MAAM;IAAE,SAAS,EAAE;EAAb,IAAmC,KAAK,CAAC,IAA/C;;EAEA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAwB,CAAD,IAA0D;;;IAC/E,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,CAAH,CAAjB;;IAEA,IAAI,CAAA,CAAA,EAAA,GAAA,CAAC,CAAC,GAAF,MAAK,IAAL,IAAK,EAAA,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAK,EAAA,CAAE,MAAP,IAAgB,CAApB,EAAuB;MACrB;IACD;;IAED,IAAI,GAAG,CAAC,OAAR,EAAiB;MACf,wBAAwB,KAAA,IAAxB,IAAA,wBAAwB,KAAA,KAAA,CAAxB,GAAwB,KAAA,CAAxB,GAAA,wBAAwB,CAAG,CAAH,EAAM,GAAG,CAAC,OAAV,CAAxB;IACD;EACF,CAVD;;EAYA,OAAO,KAAP;AACD,CAlBM","sourcesContent":["import * as React from 'react';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport type { MenuItemState } from '../../components/index';\nimport type { ARIAButtonElementIntersection } from '@fluentui/react-aria';\n\nexport const useCharacterSearch = (state: MenuItemState, ref: React.RefObject<HTMLElement>) => {\n const setFocusByFirstCharacter = useMenuListContext_unstable(context => context.setFocusByFirstCharacter);\n\n const { onKeyDown: originalOnKeyDown } = state.root;\n\n state.root.onKeyDown = (e: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n originalOnKeyDown?.(e);\n\n if (e.key?.length > 1) {\n return;\n }\n\n if (ref.current) {\n setFocusByFirstCharacter?.(e, ref.current);\n }\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { useEventCallback,
|
2
|
+
import { useEventCallback, resolveShorthand, useMergedRefs, getNativeElementProps } from '@fluentui/react-utilities';
|
3
3
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
4
4
|
import { useCharacterSearch } from './useCharacterSearch';
|
5
5
|
import { useMenuTriggerContext_unstable } from '../../contexts/menuTriggerContext';
|
6
6
|
import { ChevronRightFilled, ChevronRightRegular, ChevronLeftFilled, ChevronLeftRegular, bundleIcon } from '@fluentui/react-icons';
|
7
7
|
import { useMenuListContext_unstable } from '../../contexts/menuListContext';
|
8
8
|
import { useMenuContext_unstable } from '../../contexts/menuContext';
|
9
|
+
import { useARIAButtonShorthand } from '@fluentui/react-aria';
|
10
|
+
import { Enter, Space } from '@fluentui/keyboard-keys';
|
9
11
|
const ChevronRightIcon = /*#__PURE__*/bundleIcon(ChevronRightFilled, ChevronRightRegular);
|
10
12
|
const ChevronLeftIcon = /*#__PURE__*/bundleIcon(ChevronLeftFilled, ChevronLeftRegular);
|
11
13
|
/**
|
@@ -13,22 +15,28 @@ const ChevronLeftIcon = /*#__PURE__*/bundleIcon(ChevronLeftFilled, ChevronLeftRe
|
|
13
15
|
*/
|
14
16
|
|
15
17
|
export const useMenuItem_unstable = (props, ref) => {
|
16
|
-
|
17
|
-
|
18
|
+
const isSubmenuTrigger = useMenuTriggerContext_unstable();
|
19
|
+
const persistOnClickContext = useMenuContext_unstable(context => context.persistOnItemClick);
|
20
|
+
const {
|
21
|
+
as = 'div',
|
22
|
+
disabled,
|
23
|
+
disabledFocusable,
|
24
|
+
hasSubmenu = isSubmenuTrigger,
|
25
|
+
persistOnClick = persistOnClickContext
|
26
|
+
} = props;
|
18
27
|
const hasIcons = useMenuListContext_unstable(context => context.hasIcons);
|
19
28
|
const hasCheckmarks = useMenuListContext_unstable(context => context.hasCheckmarks);
|
20
29
|
const setOpen = useMenuContext_unstable(context => context.setOpen);
|
21
|
-
const persistOnClickContext = useMenuContext_unstable(context => context.persistOnItemClick);
|
22
|
-
const dismissedWithKeyboardRef = React.useRef(false);
|
23
|
-
const isSubmenuTrigger = useMenuTriggerContext_unstable();
|
24
|
-
const hasSubmenu = (_a = props.hasSubmenu) !== null && _a !== void 0 ? _a : isSubmenuTrigger;
|
25
30
|
const {
|
26
31
|
dir
|
27
32
|
} = useFluent();
|
28
33
|
const innerRef = React.useRef(null);
|
34
|
+
const dismissedWithKeyboardRef = React.useRef(false);
|
35
|
+
const isDisabled = Boolean(disabled || disabledFocusable);
|
29
36
|
const state = {
|
30
37
|
hasSubmenu,
|
31
|
-
|
38
|
+
disabled: isDisabled,
|
39
|
+
persistOnClick,
|
32
40
|
components: {
|
33
41
|
root: 'div',
|
34
42
|
icon: 'span',
|
@@ -37,13 +45,48 @@ export const useMenuItem_unstable = (props, ref) => {
|
|
37
45
|
content: 'span',
|
38
46
|
secondaryContent: 'span'
|
39
47
|
},
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
isNativeButton: as === 'button',
|
49
|
+
root: getNativeElementProps(as, useARIAButtonShorthand({
|
50
|
+
disabled: false,
|
51
|
+
disabledFocusable: isDisabled,
|
52
|
+
as
|
53
|
+
}, {
|
54
|
+
required: true,
|
55
|
+
defaultProps: {
|
56
|
+
role: 'menuitem',
|
57
|
+
...props,
|
58
|
+
ref: useMergedRefs(ref, innerRef),
|
59
|
+
onKeyDown: useEventCallback(event => {
|
60
|
+
var _a;
|
61
|
+
|
62
|
+
(_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
63
|
+
|
64
|
+
if (!event.isDefaultPrevented() && (event.key === Space || event.key === Enter)) {
|
65
|
+
dismissedWithKeyboardRef.current = true;
|
66
|
+
}
|
67
|
+
}),
|
68
|
+
onMouseEnter: useEventCallback(event => {
|
69
|
+
var _a, _b;
|
70
|
+
|
71
|
+
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
72
|
+
(_b = props.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(props, event);
|
73
|
+
}),
|
74
|
+
onClick: useEventCallback(event => {
|
75
|
+
var _a;
|
76
|
+
|
77
|
+
if (!hasSubmenu && !persistOnClick) {
|
78
|
+
setOpen(event, {
|
79
|
+
open: false,
|
80
|
+
keyboard: dismissedWithKeyboardRef.current,
|
81
|
+
bubble: true
|
82
|
+
});
|
83
|
+
dismissedWithKeyboardRef.current = false;
|
84
|
+
}
|
85
|
+
|
86
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
87
|
+
})
|
88
|
+
}
|
89
|
+
})),
|
47
90
|
icon: resolveShorthand(props.icon, {
|
48
91
|
required: hasIcons
|
49
92
|
}),
|
@@ -64,63 +107,6 @@ export const useMenuItem_unstable = (props, ref) => {
|
|
64
107
|
}),
|
65
108
|
secondaryContent: resolveShorthand(props.secondaryContent)
|
66
109
|
};
|
67
|
-
const {
|
68
|
-
onClick: onClickOriginal,
|
69
|
-
onKeyDown: onKeyDownOriginal
|
70
|
-
} = state.root;
|
71
|
-
|
72
|
-
state.root.onKeyDown = e => {
|
73
|
-
var _a;
|
74
|
-
|
75
|
-
if (shouldPreventDefaultOnKeyDown(e)) {
|
76
|
-
if (state.disabled) {
|
77
|
-
e.preventDefault();
|
78
|
-
e.stopPropagation();
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
|
82
|
-
dismissedWithKeyboardRef.current = true;
|
83
|
-
e.preventDefault();
|
84
|
-
(_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
|
85
|
-
}
|
86
|
-
|
87
|
-
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
|
88
|
-
};
|
89
|
-
|
90
|
-
state.root.onClick = e => {
|
91
|
-
if (state.disabled) {
|
92
|
-
e.preventDefault();
|
93
|
-
e.stopPropagation();
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
|
97
|
-
let shouldPersist = persistOnClickContext; // prop wins over context;
|
98
|
-
|
99
|
-
if (state.persistOnClick !== undefined && persistOnClickContext !== state.persistOnClick) {
|
100
|
-
shouldPersist = state.persistOnClick;
|
101
|
-
}
|
102
|
-
|
103
|
-
if (!hasSubmenu && !shouldPersist) {
|
104
|
-
setOpen(e, {
|
105
|
-
open: false,
|
106
|
-
keyboard: dismissedWithKeyboardRef.current,
|
107
|
-
bubble: true
|
108
|
-
});
|
109
|
-
dismissedWithKeyboardRef.current = false;
|
110
|
-
}
|
111
|
-
|
112
|
-
onClickOriginal === null || onClickOriginal === void 0 ? void 0 : onClickOriginal(e);
|
113
|
-
};
|
114
|
-
|
115
|
-
const {
|
116
|
-
onMouseEnter: onMouseEnterOriginal
|
117
|
-
} = state.root;
|
118
|
-
state.root.onMouseEnter = useEventCallback(e => {
|
119
|
-
var _a;
|
120
|
-
|
121
|
-
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
122
|
-
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
|
123
|
-
});
|
124
110
|
useCharacterSearch(state, innerRef);
|
125
111
|
return state;
|
126
112
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItem/useMenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,
|
1
|
+
{"version":3,"sources":["components/MenuItem/useMenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,EAA2B,gBAA3B,EAA6C,aAA7C,EAA4D,qBAA5D,QAAyF,2BAAzF;AACA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,8BAAT,QAA+C,mCAA/C;AACA,SACE,kBADF,EAEE,mBAFF,EAGE,iBAHF,EAIE,kBAJF,EAKE,UALF,QAMO,uBANP;AAOA,SAAS,2BAAT,QAA4C,gCAA5C;AACA,SAAS,uBAAT,QAAwC,4BAAxC;AAGA,SAAS,sBAAT,QAAuC,sBAAvC;AACA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AAEA,MAAM,gBAAgB,gBAAG,UAAU,CAAC,kBAAD,EAAqB,mBAArB,CAAnC;AACA,MAAM,eAAe,gBAAG,UAAU,CAAC,iBAAD,EAAoB,kBAApB,CAAlC;AAEA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAAkF;EACpH,MAAM,gBAAgB,GAAG,8BAA8B,EAAvD;EACA,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,kBAApB,CAArD;EACA,MAAM;IACJ,EAAE,GAAG,KADD;IAEJ,QAFI;IAGJ,iBAHI;IAIJ,UAAU,GAAG,gBAJT;IAKJ,cAAc,GAAG;EALb,IAMF,KANJ;EAOA,MAAM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AZ,CAAlB,CA/CA;IAgD3B,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC,gBAAP,EAAyB;MACzD,QAAQ,EAAE,UAD+C;MAEzD,YAAY,EAAE;QACZ,QAAQ,EAAE,GAAG,KAAK,KAAR,gBAAgB,KAAA,CAAA,aAAA,CAAC,gBAAD,EAAiB,IAAjB,CAAhB,gBAAuC,KAAA,CAAA,aAAA,CAAC,eAAD,EAAgB,IAAhB;MADrC;IAF2C,CAAzB,CAhDP;IAsD3B,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAP,EAAgB;MACvC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,QADqB;MAEvC,YAAY,EAAE;QAAE,QAAQ,EAAE,KAAK,CAAC;MAAlB;IAFyB,CAAhB,CAtDE;IA0D3B,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC,gBAAP;EA1DP,CAA7B;EA4DA,kBAAkB,CAAC,KAAD,EAAQ,QAAR,CAAlB;EACA,OAAO,KAAP;AACD,CAlFM","sourcesContent":["import * as React from 'react';\nimport { useEventCallback, resolveShorthand, useMergedRefs, getNativeElementProps } 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 {\n ChevronRightFilled,\n ChevronRightRegular,\n ChevronLeftFilled,\n ChevronLeftRegular,\n bundleIcon,\n} from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport type { MenuItemProps, MenuItemState } from './MenuItem.types';\nimport type { ARIAButtonElement, ARIAButtonElementIntersection, ARIAButtonSlotProps } from '@fluentui/react-aria';\nimport { useARIAButtonShorthand } from '@fluentui/react-aria';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\n\nconst ChevronRightIcon = bundleIcon(ChevronRightFilled, ChevronRightRegular);\nconst ChevronLeftIcon = bundleIcon(ChevronLeftFilled, ChevronLeftRegular);\n\n/**\n * Returns the props and state required to render the component\n */\nexport const useMenuItem_unstable = (props: MenuItemProps, ref: React.Ref<ARIAButtonElement<'div'>>): MenuItemState => {\n const isSubmenuTrigger = useMenuTriggerContext_unstable();\n const persistOnClickContext = useMenuContext_unstable(context => context.persistOnItemClick);\n const {\n as = 'div',\n disabled,\n disabledFocusable,\n hasSubmenu = isSubmenuTrigger,\n persistOnClick = persistOnClickContext,\n } = 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\n const { dir } = useFluent();\n const innerRef = React.useRef<ARIAButtonElementIntersection<'div'>>(null);\n const dismissedWithKeyboardRef = React.useRef(false);\n\n const isDisabled = Boolean(disabled || disabledFocusable);\n\n const state: MenuItemState = {\n hasSubmenu,\n disabled: isDisabled,\n persistOnClick,\n components: {\n root: 'div',\n icon: 'span',\n checkmark: 'span',\n submenuIndicator: 'span',\n content: 'span',\n secondaryContent: 'span',\n },\n isNativeButton: as === 'button',\n root: getNativeElementProps(\n as,\n useARIAButtonShorthand<ARIAButtonSlotProps<'div'>>(\n { disabled: false, disabledFocusable: isDisabled, as },\n {\n required: true,\n defaultProps: {\n role: 'menuitem',\n ...props,\n ref: useMergedRefs(ref, innerRef) as React.Ref<ARIAButtonElementIntersection<'div'>>,\n onKeyDown: useEventCallback(event => {\n props.onKeyDown?.(event);\n if (!event.isDefaultPrevented() && (event.key === Space || event.key === Enter)) {\n dismissedWithKeyboardRef.current = true;\n }\n }),\n onMouseEnter: useEventCallback(event => {\n innerRef.current?.focus();\n\n props.onMouseEnter?.(event);\n }),\n onClick: useEventCallback(event => {\n if (!hasSubmenu && !persistOnClick) {\n setOpen(event, { open: false, keyboard: dismissedWithKeyboardRef.current, bubble: true });\n dismissedWithKeyboardRef.current = false;\n }\n\n props.onClick?.(event);\n }),\n },\n },\n ),\n ),\n icon: resolveShorthand(props.icon, { required: hasIcons }),\n checkmark: resolveShorthand(props.checkmark, { required: hasCheckmarks }),\n submenuIndicator: resolveShorthand(props.submenuIndicator, {\n required: hasSubmenu,\n defaultProps: {\n children: dir === 'ltr' ? <ChevronRightIcon /> : <ChevronLeftIcon />,\n },\n }),\n content: resolveShorthand(props.content, {\n required: !!props.children,\n defaultProps: { children: props.children },\n }),\n secondaryContent: resolveShorthand(props.secondaryContent),\n };\n useCharacterSearch(state, innerRef);\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -16,34 +16,54 @@ const useStyles = /*#__PURE__*/__styles({
|
|
16
16
|
"focusIndicator": {
|
17
17
|
"Brovlpu": "ftqa4ok",
|
18
18
|
"B486eqv": "f2hkw1w",
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
19
|
+
"r6j8yp": "f9sgzds",
|
20
|
+
"w235jp": ["fut1j4r", "fkf1fqv"],
|
21
|
+
"Bjm0d8m": "f1t0sa4d",
|
22
|
+
"jwfw70": ["fkf1fqv", "fut1j4r"],
|
23
|
+
"Boz55fv": "f1m3tk81",
|
24
|
+
"pmqz9c": "f1pr2mxm",
|
25
|
+
"Bl9sb7i": "f29vp72",
|
26
|
+
"h4jxiv": "f1b5h9zn",
|
27
|
+
"E4x6tl": "f1ltau7e",
|
28
|
+
"B9c4r0f": ["f18ihh6m", "fzaptb5"],
|
29
|
+
"Bstwoin": "f1or3dzb",
|
30
|
+
"Bflkndj": ["fzaptb5", "f18ihh6m"],
|
31
|
+
"h1egvf": "fciubpk",
|
32
|
+
"vw8w2h": ["fzvtil0", "f1e7tdtt"],
|
33
|
+
"Bbpctgi": "f14oz5ke",
|
34
|
+
"Dyu7ee": ["f1e7tdtt", "fzvtil0"],
|
35
|
+
"gnkc5c": ["f1clxaxy", "f1pefego"],
|
36
|
+
"Bw9c0us": ["f1pefego", "f1clxaxy"],
|
37
|
+
"B9ptage": ["f1e14n0d", "f19um3kx"],
|
38
|
+
"c7u8z9": ["f19um3kx", "f1e14n0d"],
|
39
|
+
"Bgf7pbm": "f1a5bpr6",
|
40
|
+
"Btw8xqj": ["fjsutlp", "f1fz4ffz"],
|
41
|
+
"B6j1cfa": "f11bfvwp",
|
42
|
+
"B3wlxu": ["f1fz4ffz", "fjsutlp"],
|
43
|
+
"Beastro": "f1hebwof",
|
44
|
+
"Bhizb9d": "f19pyrw2",
|
45
|
+
"B2fkz8r": ["fjebp7m", "f1m6puf8"],
|
46
|
+
"B0gbj9w": ["f1m6puf8", "fjebp7m"]
|
47
|
+
},
|
48
|
+
"resetButton": {
|
49
|
+
"B7ck84d": "f1e4lqlz",
|
50
|
+
"De3pzq": "f1u2r49w",
|
51
|
+
"sj55zd": "f1ym3bx4",
|
52
|
+
"Bahqtrf": "f1mo0ibp",
|
53
|
+
"Be2twd7": "fjoy568",
|
54
|
+
"Bg96gwp": "fytdu2e",
|
55
|
+
"g2u3we": "f1p3nwhy",
|
56
|
+
"h3c5rm": ["f11589ue", "f1pdflbu"],
|
57
|
+
"B9xav0g": "f1q5o8ev",
|
58
|
+
"zhjwy3": ["f1pdflbu", "f11589ue"],
|
59
|
+
"B68tc82": "f1mtd64y",
|
60
|
+
"Bmxbyg5": "f1y7q3j9",
|
61
|
+
"z8tnut": "f1g0x7ka",
|
62
|
+
"z189sj": ["fhxju0i", "f1cnd47f"],
|
63
|
+
"Byoj8tv": "f1qch9an",
|
64
|
+
"uwmqm3": ["f1cnd47f", "fhxju0i"],
|
65
|
+
"Bv0vk6g": "f37px4s",
|
66
|
+
"fsow6f": "fgusgyc"
|
47
67
|
},
|
48
68
|
"root": {
|
49
69
|
"Bbmb7ep": ["f1aa9q02", "f16jpd5f"],
|
@@ -108,7 +128,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
108
128
|
}, {
|
109
129
|
"f": [".ftqa4ok:focus{outline-style:none;}", ".fc1cou1:focus{color:var(--colorNeutralForeground3Hover);}", ".ft33916:focus{color:var(--colorNeutralForegroundDisabled);}"],
|
110
130
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"],
|
111
|
-
"d": [".
|
131
|
+
"d": [".f9sgzds.fui-focus-visible{border-top-color:transparent;}", ".fut1j4r.fui-focus-visible{border-right-color:transparent;}", ".fkf1fqv.fui-focus-visible{border-left-color:transparent;}", ".f1t0sa4d.fui-focus-visible{border-bottom-color:transparent;}", ".f1m3tk81.fui-focus-visible::after{content:\"\";}", ".f1pr2mxm.fui-focus-visible::after{position:absolute;}", ".f29vp72.fui-focus-visible::after{pointer-events:none;}", ".f1b5h9zn.fui-focus-visible::after{z-index:1;}", ".f1ltau7e.fui-focus-visible::after{border-top-style:solid;}", ".f18ihh6m.fui-focus-visible::after{border-right-style:solid;}", ".fzaptb5.fui-focus-visible::after{border-left-style:solid;}", ".f1or3dzb.fui-focus-visible::after{border-bottom-style:solid;}", ".fciubpk.fui-focus-visible::after{border-top-width:2px;}", ".fzvtil0.fui-focus-visible::after{border-right-width:2px;}", ".f1e7tdtt.fui-focus-visible::after{border-left-width:2px;}", ".f14oz5ke.fui-focus-visible::after{border-bottom-width:2px;}", ".f1clxaxy.fui-focus-visible::after{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f1pefego.fui-focus-visible::after{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1e14n0d.fui-focus-visible::after{border-top-right-radius:var(--borderRadiusMedium);}", ".f19um3kx.fui-focus-visible::after{border-top-left-radius:var(--borderRadiusMedium);}", ".f1a5bpr6.fui-focus-visible::after{border-top-color:var(--colorStrokeFocus2);}", ".fjsutlp.fui-focus-visible::after{border-right-color:var(--colorStrokeFocus2);}", ".f1fz4ffz.fui-focus-visible::after{border-left-color:var(--colorStrokeFocus2);}", ".f11bfvwp.fui-focus-visible::after{border-bottom-color:var(--colorStrokeFocus2);}", ".f1hebwof.fui-focus-visible::after{top:-2px;}", ".f19pyrw2.fui-focus-visible::after{bottom:-2px;}", ".fjebp7m.fui-focus-visible::after{left:-2px;}", ".f1m6puf8.fui-focus-visible::after{right:-2px;}", ".f1e4lqlz{box-sizing:content-box;}", ".f1u2r49w{background-color:inherit;}", ".f1ym3bx4{color:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".fytdu2e{line-height:normal;}", ".f1p3nwhy{border-top-color:transparent;}", ".f11589ue{border-right-color:transparent;}", ".f1pdflbu{border-left-color:transparent;}", ".f1q5o8ev{border-bottom-color:transparent;}", ".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f37px4s{-webkit-appearance:button;}", ".fgusgyc{text-align:unset;}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f10pi13n{position:relative;}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f81rol6{padding-right:10px;}", ".frdkuqy{padding-left:10px;}", ".f1d2rq10{height:32px;}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".f1k6fduh{cursor:pointer;}", ".f1q8lukm{-webkit-column-gap:4px;column-gap:4px;}", ".f1ma2n7n{row-gap:4px;}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f161knb0{padding-left:2px;}", ".f12huiiw{padding-right:2px;}", ".f3rmtva{background-color:transparent;}", ".fqerorx{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".f11d4kpn{color:var(--colorNeutralForeground3);}", ".f64fuq3{width:20px;}", ".fjamq6b{height:20px;}", ".fe5j1ua{font-size:20px;}", ".fez10in{line-height:0;}", ".ftuwxu6{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".f4d9j23{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}"],
|
112
132
|
"h": [".f1knas48:hover{background-color:var(--colorNeutralBackground1Hover);}", ".fnwyq0v:hover{color:var(--colorNeutralForeground2Hover);}", ".ft1hn21:hover .fui-Icon-filled{display:inline;}", ".fuxngvv:hover .fui-Icon-regular{display:none;}", ".fp258yr:hover .fui-MenuItem__icon{color:var(--colorNeutralForeground2BrandSelected);}", ".f1jp5ecu:hover{color:var(--colorNeutralForeground3Hover);}", ".fvgxktp:hover{color:var(--colorNeutralForegroundDisabled);}"]
|
113
133
|
});
|
114
134
|
/** Applies style classnames to slots */
|
@@ -116,7 +136,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
116
136
|
|
117
137
|
export const useMenuItemStyles_unstable = state => {
|
118
138
|
const styles = useStyles();
|
119
|
-
state.root.className = mergeClasses(menuItemClassNames.root, styles.root, styles.focusIndicator, state.disabled && styles.disabled, state.root.className);
|
139
|
+
state.root.className = mergeClasses(menuItemClassNames.root, state.isNativeButton && styles.resetButton, styles.root, styles.focusIndicator, state.disabled && styles.disabled, state.root.className);
|
120
140
|
|
121
141
|
if (state.content) {
|
122
142
|
state.content.className = mergeClasses(menuItemClassNames.content, styles.content, state.content.className);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItem/useMenuItemStyles.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,YAAmC,UAAnC,QAAqD,gBAArD;AACA,SAAS,mBAAT,EAA8B,oBAA9B,QAA0D,uBAA1D;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AACA,SAAS,MAAT,QAAuB,uBAAvB;AACA,SAAS,2BAAT,QAA4C,wBAA5C;AAKA,OAAO,MAAM,kBAAkB,GAAkC;EAC/D,IAAI,EAAE,cADyD;EAE/D,IAAI,EAAE,oBAFyD;EAG/D,SAAS,EAAE,yBAHoD;EAI/D,gBAAgB,EAAE,gCAJ6C;EAK/D,OAAO,EAAE,uBALsD;EAM/D,gBAAgB,EAAE;AAN6C,CAA1D;;AASP,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;EAAA;EAAA;EAAA;AAAA,EAAlB;
|
1
|
+
{"version":3,"sources":["components/MenuItem/useMenuItemStyles.ts"],"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AK,CAAC,gBAAN,CAAuB,SAHsB,CAA/C;EAKD;;EACD,2BAA2B,CAAC,KAAD,CAA3B;AACD,CAvCM","sourcesContent":["import { mergeClasses, makeStyles, shorthands } from '@griffel/react';\nimport { iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { useCheckmarkStyles_unstable } from '../../selectable/index';\nimport type { MenuItemCheckboxState } from '../MenuItemCheckbox/index';\nimport type { MenuItemSlots, MenuItemState } from './MenuItem.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const menuItemClassNames: SlotClassNames<MenuItemSlots> = {\n root: 'fui-MenuItem',\n icon: 'fui-MenuItem__icon',\n checkmark: 'fui-MenuItem__checkmark',\n submenuIndicator: 'fui-MenuItem__submenuIndicator',\n content: 'fui-MenuItem__content',\n secondaryContent: 'fui-MenuItem__secondaryContent',\n};\n\nconst useStyles = makeStyles({\n focusIndicator: createFocusOutlineStyle(),\n // TODO: this should be extracted to another package\n resetButton: {\n boxSizing: 'content-box',\n backgroundColor: 'inherit',\n color: 'inherit',\n fontFamily: 'inherit',\n fontSize: 'inherit',\n lineHeight: 'normal',\n ...shorthands.borderColor('transparent'),\n ...shorthands.overflow('visible'),\n ...shorthands.padding(0),\n WebkitAppearance: 'button',\n textAlign: 'unset',\n },\n root: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n position: 'relative',\n color: tokens.colorNeutralForeground2,\n backgroundColor: tokens.colorNeutralBackground1,\n paddingRight: '10px',\n paddingLeft: '10px',\n height: '32px',\n display: 'flex',\n alignItems: 'center',\n fontSize: tokens.fontSizeBase300,\n cursor: 'pointer',\n ...shorthands.gap('4px'),\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n color: tokens.colorNeutralForeground2Hover,\n\n [`& .${iconFilledClassName}`]: {\n display: 'inline',\n },\n [`& .${iconRegularClassName}`]: {\n display: 'none',\n },\n [`& .${menuItemClassNames.icon}`]: {\n color: tokens.colorNeutralForeground2BrandSelected,\n },\n },\n\n userSelect: 'none',\n },\n content: {\n paddingLeft: '2px',\n paddingRight: '2px',\n backgroundColor: 'transparent',\n flexGrow: 1,\n },\n secondaryContent: {\n paddingLeft: '2px',\n paddingRight: '2px',\n color: tokens.colorNeutralForeground3,\n ':hover': {\n color: tokens.colorNeutralForeground3Hover,\n },\n ':focus': {\n color: tokens.colorNeutralForeground3Hover,\n },\n },\n icon: {\n width: '20px',\n height: '20px',\n fontSize: '20px',\n lineHeight: 0,\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n },\n submenuIndicator: {\n width: '20px',\n height: '20px',\n fontSize: '20px',\n lineHeight: 0,\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n ':hover': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n ':focus': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\n/** Applies style classnames to slots */\nexport const useMenuItemStyles_unstable = (state: MenuItemState) => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n menuItemClassNames.root,\n state.isNativeButton && styles.resetButton,\n styles.root,\n styles.focusIndicator,\n state.disabled && styles.disabled,\n state.root.className,\n );\n\n if (state.content) {\n state.content.className = mergeClasses(menuItemClassNames.content, styles.content, state.content.className);\n }\n\n if (state.checkmark) {\n state.checkmark.className = mergeClasses(menuItemClassNames.checkmark, state.checkmark.className);\n }\n\n if (state.secondaryContent) {\n state.secondaryContent.className = mergeClasses(\n menuItemClassNames.secondaryContent,\n !state.disabled && styles.secondaryContent,\n state.secondaryContent.className,\n );\n }\n\n if (state.icon) {\n state.icon.className = mergeClasses(menuItemClassNames.icon, styles.icon, state.icon.className);\n }\n\n if (state.submenuIndicator) {\n state.submenuIndicator.className = mergeClasses(\n menuItemClassNames.submenuIndicator,\n styles.submenuIndicator,\n state.submenuIndicator.className,\n );\n }\n useCheckmarkStyles_unstable(state as MenuItemCheckboxState);\n};\n"],"sourceRoot":"../src/"}
|
@@ -6,41 +6,39 @@ import { useMenuItem_unstable } from '../MenuItem/useMenuItem';
|
|
6
6
|
/** Returns the props and state required to render the component */
|
7
7
|
|
8
8
|
export const useMenuItemCheckbox_unstable = (props, ref) => {
|
9
|
-
const state = useMenuItem_unstable({
|
10
|
-
role: 'menuitemcheckbox',
|
11
|
-
persistOnClick: true,
|
12
|
-
...props,
|
13
|
-
checkmark: resolveShorthand(props.checkmark, {
|
14
|
-
defaultProps: {
|
15
|
-
children: /*#__PURE__*/React.createElement(Checkmark16Filled, null)
|
16
|
-
},
|
17
|
-
required: true
|
18
|
-
})
|
19
|
-
}, ref);
|
20
9
|
const toggleCheckbox = useMenuListContext_unstable(context => context.toggleCheckbox);
|
21
10
|
const {
|
22
|
-
|
23
|
-
|
11
|
+
name,
|
12
|
+
value
|
13
|
+
} = props;
|
24
14
|
const checked = useMenuListContext_unstable(context => {
|
25
15
|
var _a;
|
26
16
|
|
27
|
-
const checkedItems = ((_a = context.checkedValues) === null || _a === void 0 ? void 0 : _a[
|
28
|
-
return checkedItems.indexOf(
|
17
|
+
const checkedItems = ((_a = context.checkedValues) === null || _a === void 0 ? void 0 : _a[name]) || [];
|
18
|
+
return checkedItems.indexOf(value) !== -1;
|
29
19
|
});
|
30
|
-
state
|
31
|
-
|
20
|
+
const state = { ...useMenuItem_unstable({
|
21
|
+
role: 'menuitemcheckbox',
|
22
|
+
persistOnClick: true,
|
23
|
+
...props,
|
24
|
+
'aria-checked': checked,
|
25
|
+
checkmark: resolveShorthand(props.checkmark, {
|
26
|
+
defaultProps: {
|
27
|
+
children: /*#__PURE__*/React.createElement(Checkmark16Filled, null)
|
28
|
+
},
|
29
|
+
required: true
|
30
|
+
}),
|
31
|
+
onClick: e => {
|
32
|
+
var _a;
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
toggleCheckbox === null || toggleCheckbox === void 0 ? void 0 : toggleCheckbox(e, state.name, state.value, state.checked);
|
41
|
-
onClickOriginal === null || onClickOriginal === void 0 ? void 0 : onClickOriginal(e);
|
34
|
+
toggleCheckbox === null || toggleCheckbox === void 0 ? void 0 : toggleCheckbox(e, name, value, checked);
|
35
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
36
|
+
}
|
37
|
+
}, ref),
|
38
|
+
name,
|
39
|
+
value,
|
40
|
+
checked
|
42
41
|
};
|
43
|
-
|
44
42
|
return state;
|
45
43
|
};
|
46
44
|
//# sourceMappingURL=useMenuItemCheckbox.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItemCheckbox/useMenuItemCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,iBAAT,QAAkC,uBAAlC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AACA,SAAS,oBAAT,QAAqC,yBAArC;
|
1
|
+
{"version":3,"sources":["components/MenuItemCheckbox/useMenuItemCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,iBAAT,QAAkC,uBAAlC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AACA,SAAS,oBAAT,QAAqC,yBAArC;AAIA;;AACA,OAAO,MAAM,4BAA4B,GAAG,CAC1C,KAD0C,EAE1C,GAF0C,KAGjB;EACzB,MAAM,cAAc,GAAG,2BAA2B,CAAC,OAAO,IAAI,OAAO,CAAC,cAApB,CAAlD;EACA,MAAM;IAAE,IAAF;IAAQ;EAAR,IAAkB,KAAxB;EAEA,MAAM,OAAO,GAAG,2BAA2B,CAAC,OAAO,IAAG;;;IACpD,MAAM,YAAY,GAAG,CAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAR,MAAqB,IAArB,IAAqB,EAAA,KAAA,KAAA,CAArB,GAAqB,KAAA,CAArB,GAAqB,EAAA,CAAG,IAAH,CAArB,KAAiC,EAAtD;IACA,OAAO,YAAY,CAAC,OAAb,CAAqB,KAArB,MAAgC,CAAC,CAAxC;EACD,CAH0C,CAA3C;EAKA,MAAM,KAAK,GAA0B,EACnC,GAAG,oBAAoB,CACrB;MACE,IAAI,EAAE,kBADR;MAEE,cAAc,EAAE,IAFlB;MAGE,GAAG,KAHL;MAIE,gBAAgB,OAJlB;MAKE,SAAS,EAAE,gBAAgB,CAAC,KAAK,CAAC,SAAP,EAAkB;QAC3C,YAAY,EAAE;UAAE,QAAQ,eAAE,KAAA,CAAA,aAAA,CAAC,iBAAD,EAAkB,IAAlB;QAAZ,CAD6B;QAE3C,QAAQ,EAAE;MAFiC,CAAlB,CAL7B;MASE,OAAO,EAAG,CAAD,IAA8D;;;QACrE,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAG,CAAH,EAAM,IAAN,EAAY,KAAZ,EAAmB,OAAnB,CAAd;QACA,CAAA,EAAA,GAAA,KAAK,CAAC,OAAN,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAa,EAAA,CAAA,IAAA,CAAb,KAAa,EAAG,CAAH,CAAb;MACD;IAZH,CADqB,EAerB,GAfqB,CADY;IAkBnC,IAlBmC;IAmBnC,KAnBmC;IAoBnC;EApBmC,CAArC;EAuBA,OAAO,KAAP;AACD,CApCM","sourcesContent":["import * as React from 'react';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\nimport type { MenuItemCheckboxProps, MenuItemCheckboxState } from './MenuItemCheckbox.types';\nimport type { ARIAButtonElement, ARIAButtonElementIntersection } from '@fluentui/react-aria';\n\n/** Returns the props and state required to render the component */\nexport const useMenuItemCheckbox_unstable = (\n props: MenuItemCheckboxProps,\n ref: React.Ref<ARIAButtonElement<'div'>>,\n): MenuItemCheckboxState => {\n const toggleCheckbox = useMenuListContext_unstable(context => context.toggleCheckbox);\n const { name, value } = props;\n\n const checked = useMenuListContext_unstable(context => {\n const checkedItems = context.checkedValues?.[name] || [];\n return checkedItems.indexOf(value) !== -1;\n });\n\n const state: MenuItemCheckboxState = {\n ...useMenuItem_unstable(\n {\n role: 'menuitemcheckbox',\n persistOnClick: true,\n ...props,\n 'aria-checked': checked,\n checkmark: resolveShorthand(props.checkmark, {\n defaultProps: { children: <Checkmark16Filled /> },\n required: true,\n }),\n onClick: (e: React.MouseEvent<ARIAButtonElementIntersection<'div'>>) => {\n toggleCheckbox?.(e, name, value, checked);\n props.onClick?.(e);\n },\n },\n ref,\n ),\n name,\n value,\n checked,\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItemCheckbox/useMenuItemCheckboxStyles.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["components/MenuItemCheckbox/useMenuItemCheckboxStyles.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,2BAAT,QAA4C,wBAA5C;AACA,SAAS,0BAAT,QAA2C,+BAA3C;AAKA,OAAO,MAAM,0BAA0B,GAA4D;EACjG,IAAI,EAAE,sBAD2F;EAEjG,IAAI,EAAE,4BAF2F;EAGjG,SAAS,EAAE,iCAHsF;EAIjG,OAAO,EAAE,+BAJwF;EAKjG,gBAAgB,EAAE;AAL+E,CAA5F;AAQP,OAAO,MAAM,kCAAkC,GAAI,KAAD,IAAiC;EACjF,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CAAC,0BAA0B,CAAC,IAA5B,EAAkC,KAAK,CAAC,IAAN,CAAW,SAA7C,CAAnC;;EAEA,IAAI,KAAK,CAAC,OAAV,EAAmB;IACjB,KAAK,CAAC,OAAN,CAAc,SAAd,GAA0B,YAAY,CAAC,0BAA0B,CAAC,OAA5B,EAAqC,KAAK,CAAC,OAAN,CAAc,SAAnD,CAAtC;EACD;;EAED,IAAI,KAAK,CAAC,gBAAV,EAA4B;IAC1B,KAAK,CAAC,gBAAN,CAAuB,SAAvB,GAAmC,YAAY,CAC7C,0BAA0B,CAAC,gBADkB,EAE7C,KAAK,CAAC,gBAAN,CAAuB,SAFsB,CAA/C;EAID;;EAED,IAAI,KAAK,CAAC,IAAV,EAAgB;IACd,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CAAC,0BAA0B,CAAC,IAA5B,EAAkC,KAAK,CAAC,IAAN,CAAW,SAA7C,CAAnC;EACD;;EAED,IAAI,KAAK,CAAC,SAAV,EAAqB;IACnB,KAAK,CAAC,SAAN,CAAgB,SAAhB,GAA4B,YAAY,CAAC,0BAA0B,CAAC,SAA5B,EAAuC,KAAK,CAAC,SAAN,CAAgB,SAAvD,CAAxC;EACD;;EAED,0BAA0B,CAAC,KAAD,CAA1B;EACA,2BAA2B,CAAC,KAAD,CAA3B;AACD,CAxBM","sourcesContent":["import { mergeClasses } from '@griffel/react';\nimport { useCheckmarkStyles_unstable } from '../../selectable/index';\nimport { useMenuItemStyles_unstable } from '../MenuItem/useMenuItemStyles';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { MenuItemSlots } from '../index';\nimport type { MenuItemCheckboxState } from './MenuItemCheckbox.types';\n\nexport const menuItemCheckboxClassNames: SlotClassNames<Omit<MenuItemSlots, 'submenuIndicator'>> = {\n root: 'fui-MenuItemCheckbox',\n icon: 'fui-MenuItemCheckbox__icon',\n checkmark: 'fui-MenuItemCheckbox__checkmark',\n content: 'fui-MenuItemCheckbox__content',\n secondaryContent: 'fui-MenuItemCheckbox__secondaryContent',\n};\n\nexport const useMenuItemCheckboxStyles_unstable = (state: MenuItemCheckboxState) => {\n state.root.className = mergeClasses(menuItemCheckboxClassNames.root, state.root.className);\n\n if (state.content) {\n state.content.className = mergeClasses(menuItemCheckboxClassNames.content, state.content.className);\n }\n\n if (state.secondaryContent) {\n state.secondaryContent.className = mergeClasses(\n menuItemCheckboxClassNames.secondaryContent,\n state.secondaryContent.className,\n );\n }\n\n if (state.icon) {\n state.icon.className = mergeClasses(menuItemCheckboxClassNames.icon, state.icon.className);\n }\n\n if (state.checkmark) {\n state.checkmark.className = mergeClasses(menuItemCheckboxClassNames.checkmark, state.checkmark.className);\n }\n\n useMenuItemStyles_unstable(state);\n useCheckmarkStyles_unstable(state);\n};\n"],"sourceRoot":"../src/"}
|
@@ -8,42 +8,36 @@ import { useMenuItem_unstable } from '../MenuItem/useMenuItem';
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
export const useMenuItemRadio_unstable = (props, ref) => {
|
11
|
-
const radioProps = {
|
12
|
-
role: 'menuitemradio'
|
13
|
-
};
|
14
|
-
const state = useMenuItem_unstable({ ...radioProps,
|
15
|
-
...props,
|
16
|
-
checkmark: resolveShorthand(props.checkmark, {
|
17
|
-
defaultProps: {
|
18
|
-
children: /*#__PURE__*/React.createElement(Checkmark16Filled, null)
|
19
|
-
},
|
20
|
-
required: true
|
21
|
-
})
|
22
|
-
}, ref);
|
23
|
-
const selectRadio = useMenuListContext_unstable(context => context.selectRadio);
|
24
11
|
const {
|
25
|
-
|
26
|
-
|
12
|
+
name,
|
13
|
+
value
|
14
|
+
} = props;
|
27
15
|
const checked = useMenuListContext_unstable(context => {
|
28
16
|
var _a;
|
29
17
|
|
30
|
-
const checkedItems = ((_a = context.checkedValues) === null || _a === void 0 ? void 0 : _a[
|
31
|
-
return checkedItems.indexOf(
|
18
|
+
const checkedItems = ((_a = context.checkedValues) === null || _a === void 0 ? void 0 : _a[name]) || [];
|
19
|
+
return checkedItems.indexOf(value) !== -1;
|
32
20
|
});
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
21
|
+
const selectRadio = useMenuListContext_unstable(context => context.selectRadio);
|
22
|
+
return { ...useMenuItem_unstable({ ...props,
|
23
|
+
role: 'menuitemradio',
|
24
|
+
'aria-checked': checked,
|
25
|
+
checkmark: resolveShorthand(props.checkmark, {
|
26
|
+
defaultProps: {
|
27
|
+
children: /*#__PURE__*/React.createElement(Checkmark16Filled, null)
|
28
|
+
},
|
29
|
+
required: true
|
30
|
+
}),
|
31
|
+
onClick: e => {
|
32
|
+
var _a;
|
42
33
|
|
43
|
-
|
44
|
-
|
34
|
+
selectRadio === null || selectRadio === void 0 ? void 0 : selectRadio(e, name, value, checked);
|
35
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
36
|
+
}
|
37
|
+
}, ref),
|
38
|
+
checked,
|
39
|
+
name,
|
40
|
+
value
|
45
41
|
};
|
46
|
-
|
47
|
-
return state;
|
48
42
|
};
|
49
43
|
//# sourceMappingURL=useMenuItemRadio.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/MenuItemRadio/useMenuItemRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,iBAAT,QAAkC,uBAAlC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AACA,SAAS,oBAAT,QAAqC,yBAArC;
|
1
|
+
{"version":3,"sources":["components/MenuItemRadio/useMenuItemRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,iBAAT,QAAkC,uBAAlC;AACA,SAAS,2BAAT,QAA4C,gCAA5C;AACA,SAAS,oBAAT,QAAqC,yBAArC;AAIA;;AAEG;;AACH,OAAO,MAAM,yBAAyB,GAAG,CACvC,KADuC,EAEvC,GAFuC,KAGj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kmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\nimport type { MenuItemRadioProps, MenuItemRadioState } from './MenuItemRadio.types';\nimport type { ARIAButtonElement, ARIAButtonElementIntersection } from '@fluentui/react-aria';\n\n/**\n * Given user props, returns state and render function for a MenuItemRadio.\n */\nexport const useMenuItemRadio_unstable = (\n props: MenuItemRadioProps,\n ref: React.Ref<ARIAButtonElement<'div'>>,\n): MenuItemRadioState => {\n const { name, value } = props;\n\n const checked = useMenuListContext_unstable(context => {\n const checkedItems = context.checkedValues?.[name] || [];\n return checkedItems.indexOf(value) !== -1;\n });\n\n const selectRadio = useMenuListContext_unstable(context => context.selectRadio);\n\n return {\n ...useMenuItem_unstable(\n {\n ...props,\n role: 'menuitemradio',\n 'aria-checked': checked,\n checkmark: resolveShorthand(props.checkmark, {\n defaultProps: { children: <Checkmark16Filled /> },\n required: true,\n }),\n onClick: (e: React.MouseEvent<ARIAButtonElementIntersection<'div'>>) => {\n selectRadio?.(e, name, value, checked);\n props.onClick?.(e);\n },\n },\n ref,\n ),\n checked,\n name,\n value,\n };\n};\n"],"sourceRoot":"../src/"}
|