@react-aria/menu 3.21.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +2 -10
- package/dist/main.js +6 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -10
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/package.json +15 -24
- package/src/index.ts +2 -11
- package/dist/ar-AE.main.js +0 -6
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -8
- package/dist/ar-AE.module.js +0 -8
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -6
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -8
- package/dist/bg-BG.module.js +0 -8
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -6
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -8
- package/dist/cs-CZ.module.js +0 -8
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -6
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -8
- package/dist/da-DK.module.js +0 -8
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -6
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -8
- package/dist/de-DE.module.js +0 -8
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -6
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -8
- package/dist/el-GR.module.js +0 -8
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -6
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -8
- package/dist/en-US.module.js +0 -8
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -6
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -8
- package/dist/es-ES.module.js +0 -8
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -6
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -8
- package/dist/et-EE.module.js +0 -8
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -6
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -8
- package/dist/fi-FI.module.js +0 -8
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -6
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -8
- package/dist/fr-FR.module.js +0 -8
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -6
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -8
- package/dist/he-IL.module.js +0 -8
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -6
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -8
- package/dist/hr-HR.module.js +0 -8
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -6
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -8
- package/dist/hu-HU.module.js +0 -8
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -6
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -8
- package/dist/it-IT.module.js +0 -8
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -6
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -8
- package/dist/ja-JP.module.js +0 -8
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -6
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -8
- package/dist/ko-KR.module.js +0 -8
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -6
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -8
- package/dist/lt-LT.module.js +0 -8
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -6
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -8
- package/dist/lv-LV.module.js +0 -8
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -6
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -8
- package/dist/nb-NO.module.js +0 -8
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -6
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -8
- package/dist/nl-NL.module.js +0 -8
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -6
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -8
- package/dist/pl-PL.module.js +0 -8
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -6
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -8
- package/dist/pt-BR.module.js +0 -8
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -6
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -8
- package/dist/pt-PT.module.js +0 -8
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -6
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -8
- package/dist/ro-RO.module.js +0 -8
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -6
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -8
- package/dist/ru-RU.module.js +0 -8
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -6
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -8
- package/dist/sk-SK.module.js +0 -8
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -6
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -8
- package/dist/sl-SI.module.js +0 -8
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -6
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -8
- package/dist/sr-SP.module.js +0 -8
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -6
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -8
- package/dist/sv-SE.module.js +0 -8
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -6
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -8
- package/dist/tr-TR.module.js +0 -8
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -193
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -6
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -8
- package/dist/uk-UA.module.js +0 -8
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useMenu.main.js +0 -61
- package/dist/useMenu.main.js.map +0 -1
- package/dist/useMenu.mjs +0 -56
- package/dist/useMenu.module.js +0 -56
- package/dist/useMenu.module.js.map +0 -1
- package/dist/useMenuItem.main.js +0 -225
- package/dist/useMenuItem.main.js.map +0 -1
- package/dist/useMenuItem.mjs +0 -220
- package/dist/useMenuItem.module.js +0 -220
- package/dist/useMenuItem.module.js.map +0 -1
- package/dist/useMenuSection.main.js +0 -43
- package/dist/useMenuSection.main.js.map +0 -1
- package/dist/useMenuSection.mjs +0 -38
- package/dist/useMenuSection.module.js +0 -38
- package/dist/useMenuSection.module.js.map +0 -1
- package/dist/useMenuTrigger.main.js +0 -117
- package/dist/useMenuTrigger.main.js.map +0 -1
- package/dist/useMenuTrigger.mjs +0 -112
- package/dist/useMenuTrigger.module.js +0 -112
- package/dist/useMenuTrigger.module.js.map +0 -1
- package/dist/useSafelyMouseToSubmenu.main.js +0 -143
- package/dist/useSafelyMouseToSubmenu.main.js.map +0 -1
- package/dist/useSafelyMouseToSubmenu.mjs +0 -138
- package/dist/useSafelyMouseToSubmenu.module.js +0 -138
- package/dist/useSafelyMouseToSubmenu.module.js.map +0 -1
- package/dist/useSubmenuTrigger.main.js +0 -184
- package/dist/useSubmenuTrigger.main.js.map +0 -1
- package/dist/useSubmenuTrigger.mjs +0 -179
- package/dist/useSubmenuTrigger.module.js +0 -179
- package/dist/useSubmenuTrigger.module.js.map +0 -1
- package/dist/utils.main.js +0 -20
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -15
- package/dist/utils.module.js +0 -15
- package/dist/utils.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -6
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -8
- package/dist/zh-CN.module.js +0 -8
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -6
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -8
- package/dist/zh-TW.module.js +0 -8
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useMenu.ts +0 -86
- package/src/useMenuItem.ts +0 -362
- package/src/useMenuSection.ts +0 -61
- package/src/useMenuTrigger.ts +0 -156
- package/src/useSafelyMouseToSubmenu.ts +0 -178
- package/src/useSubmenuTrigger.ts +0 -262
- package/src/utils.ts +0 -22
package/dist/uk-UA.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var $ca4f6c8462244e62$exports = {};
|
|
2
|
-
$ca4f6c8462244e62$exports = {
|
|
3
|
-
"longPressMessage": `\u{414}\u{43E}\u{432}\u{433}\u{43E} \u{430}\u{431}\u{43E} \u{437}\u{432}\u{438}\u{447}\u{430}\u{439}\u{43D}\u{43E} \u{43D}\u{430}\u{442}\u{438}\u{441}\u{43D}\u{456}\u{442}\u{44C} \u{43A}\u{43E}\u{43C}\u{431}\u{456}\u{43D}\u{430}\u{446}\u{456}\u{44E} \u{43A}\u{43B}\u{430}\u{432}\u{456}\u{448} Alt \u{456} \u{441}\u{442}\u{440}\u{456}\u{43B}\u{43A}\u{430} \u{432}\u{43D}\u{438}\u{437}, \u{449}\u{43E}\u{431} \u{432}\u{456}\u{434}\u{43A}\u{440}\u{438}\u{442}\u{438} \u{43C}\u{435}\u{43D}\u{44E}`
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {$ca4f6c8462244e62$exports as default};
|
|
8
|
-
//# sourceMappingURL=uk-UA.module.js.map
|
package/dist/uk-UA.module.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var $ca4f6c8462244e62$exports = {};
|
|
2
|
-
$ca4f6c8462244e62$exports = {
|
|
3
|
-
"longPressMessage": `\u{414}\u{43E}\u{432}\u{433}\u{43E} \u{430}\u{431}\u{43E} \u{437}\u{432}\u{438}\u{447}\u{430}\u{439}\u{43D}\u{43E} \u{43D}\u{430}\u{442}\u{438}\u{441}\u{43D}\u{456}\u{442}\u{44C} \u{43A}\u{43E}\u{43C}\u{431}\u{456}\u{43D}\u{430}\u{446}\u{456}\u{44E} \u{43A}\u{43B}\u{430}\u{432}\u{456}\u{448} Alt \u{456} \u{441}\u{442}\u{440}\u{456}\u{43B}\u{43A}\u{430} \u{432}\u{43D}\u{438}\u{437}, \u{449}\u{43E}\u{431} \u{432}\u{456}\u{434}\u{43A}\u{440}\u{438}\u{442}\u{438} \u{43C}\u{435}\u{43D}\u{44E}`
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {$ca4f6c8462244e62$exports as default};
|
|
8
|
-
//# sourceMappingURL=uk-UA.module.js.map
|
package/dist/uk-UA.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAAA,4BAAiB;IAAG,oBAAoB,CAAC,4eAAoF,CAAC;AAC9H","sources":["packages/@react-aria/menu/intl/uk-UA.json"],"sourcesContent":["{\n \"longPressMessage\": \"Довго або звичайно натисніть комбінацію клавіш Alt і стрілка вниз, щоб відкрити меню\"\n}\n"],"names":[],"version":3,"file":"uk-UA.module.js.map"}
|
package/dist/useMenu.main.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var $815e346b11b84016$exports = require("./utils.main.js");
|
|
2
|
-
var $6CumN$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $6CumN$reactariaselection = require("@react-aria/selection");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function $parcel$export(e, n, v, s) {
|
|
7
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
$parcel$export(module.exports, "useMenu", () => $a3815f0132802737$export$38eaa17faae8f579);
|
|
11
|
-
/*
|
|
12
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $a3815f0132802737$export$38eaa17faae8f579(props, state, ref) {
|
|
25
|
-
let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
|
|
26
|
-
if (!props['aria-label'] && !props['aria-labelledby'] && process.env.NODE_ENV !== 'production') console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
27
|
-
let domProps = (0, $6CumN$reactariautils.filterDOMProps)(props, {
|
|
28
|
-
labelable: true
|
|
29
|
-
});
|
|
30
|
-
let { listProps: listProps } = (0, $6CumN$reactariaselection.useSelectableList)({
|
|
31
|
-
...otherProps,
|
|
32
|
-
ref: ref,
|
|
33
|
-
selectionManager: state.selectionManager,
|
|
34
|
-
collection: state.collection,
|
|
35
|
-
disabledKeys: state.disabledKeys,
|
|
36
|
-
shouldFocusWrap: shouldFocusWrap,
|
|
37
|
-
linkBehavior: 'override'
|
|
38
|
-
});
|
|
39
|
-
(0, $815e346b11b84016$exports.menuData).set(state, {
|
|
40
|
-
onClose: props.onClose,
|
|
41
|
-
onAction: props.onAction,
|
|
42
|
-
shouldUseVirtualFocus: props.shouldUseVirtualFocus
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
menuProps: (0, $6CumN$reactariautils.mergeProps)(domProps, {
|
|
46
|
-
onKeyDown: onKeyDown,
|
|
47
|
-
onKeyUp: onKeyUp
|
|
48
|
-
}, {
|
|
49
|
-
role: 'menu',
|
|
50
|
-
...listProps,
|
|
51
|
-
onKeyDown: (e)=>{
|
|
52
|
-
var _listProps_onKeyDown;
|
|
53
|
-
// don't clear the menu selected keys if the user is presses escape since escape closes the menu
|
|
54
|
-
if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=useMenu.main.js.map
|
package/dist/useMenu.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAChF,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;QACxB,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,gCAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,YAAY,MAAM,qBAAqB,GACnD,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {menuData} from './utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether the menu items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby'] && process.env.NODE_ENV !== 'production') {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape' || props.shouldUseVirtualFocus) {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.main.js.map"}
|
package/dist/useMenu.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.mjs";
|
|
2
|
-
import {filterDOMProps as $ieN2F$filterDOMProps, mergeProps as $ieN2F$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selection";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
|
|
19
|
-
let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
|
|
20
|
-
if (!props['aria-label'] && !props['aria-labelledby'] && process.env.NODE_ENV !== 'production') console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
21
|
-
let domProps = (0, $ieN2F$filterDOMProps)(props, {
|
|
22
|
-
labelable: true
|
|
23
|
-
});
|
|
24
|
-
let { listProps: listProps } = (0, $ieN2F$useSelectableList)({
|
|
25
|
-
...otherProps,
|
|
26
|
-
ref: ref,
|
|
27
|
-
selectionManager: state.selectionManager,
|
|
28
|
-
collection: state.collection,
|
|
29
|
-
disabledKeys: state.disabledKeys,
|
|
30
|
-
shouldFocusWrap: shouldFocusWrap,
|
|
31
|
-
linkBehavior: 'override'
|
|
32
|
-
});
|
|
33
|
-
(0, $fc79756100351201$export$6f49b4016bfc8d56).set(state, {
|
|
34
|
-
onClose: props.onClose,
|
|
35
|
-
onAction: props.onAction,
|
|
36
|
-
shouldUseVirtualFocus: props.shouldUseVirtualFocus
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
menuProps: (0, $ieN2F$mergeProps)(domProps, {
|
|
40
|
-
onKeyDown: onKeyDown,
|
|
41
|
-
onKeyUp: onKeyUp
|
|
42
|
-
}, {
|
|
43
|
-
role: 'menu',
|
|
44
|
-
...listProps,
|
|
45
|
-
onKeyDown: (e)=>{
|
|
46
|
-
var _listProps_onKeyDown;
|
|
47
|
-
// don't clear the menu selected keys if the user is presses escape since escape closes the menu
|
|
48
|
-
if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export {$d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
|
|
56
|
-
//# sourceMappingURL=useMenu.module.js.map
|
package/dist/useMenu.module.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.module.js";
|
|
2
|
-
import {filterDOMProps as $ieN2F$filterDOMProps, mergeProps as $ieN2F$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selection";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
|
|
19
|
-
let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
|
|
20
|
-
if (!props['aria-label'] && !props['aria-labelledby'] && process.env.NODE_ENV !== 'production') console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
21
|
-
let domProps = (0, $ieN2F$filterDOMProps)(props, {
|
|
22
|
-
labelable: true
|
|
23
|
-
});
|
|
24
|
-
let { listProps: listProps } = (0, $ieN2F$useSelectableList)({
|
|
25
|
-
...otherProps,
|
|
26
|
-
ref: ref,
|
|
27
|
-
selectionManager: state.selectionManager,
|
|
28
|
-
collection: state.collection,
|
|
29
|
-
disabledKeys: state.disabledKeys,
|
|
30
|
-
shouldFocusWrap: shouldFocusWrap,
|
|
31
|
-
linkBehavior: 'override'
|
|
32
|
-
});
|
|
33
|
-
(0, $fc79756100351201$export$6f49b4016bfc8d56).set(state, {
|
|
34
|
-
onClose: props.onClose,
|
|
35
|
-
onAction: props.onAction,
|
|
36
|
-
shouldUseVirtualFocus: props.shouldUseVirtualFocus
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
menuProps: (0, $ieN2F$mergeProps)(domProps, {
|
|
40
|
-
onKeyDown: onKeyDown,
|
|
41
|
-
onKeyUp: onKeyUp
|
|
42
|
-
}, {
|
|
43
|
-
role: 'menu',
|
|
44
|
-
...listProps,
|
|
45
|
-
onKeyDown: (e)=>{
|
|
46
|
-
var _listProps_onKeyDown;
|
|
47
|
-
// don't clear the menu selected keys if the user is presses escape since escape closes the menu
|
|
48
|
-
if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export {$d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
|
|
56
|
-
//# sourceMappingURL=useMenu.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAChF,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;QACxB,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,YAAY,MAAM,qBAAqB,GACnD,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {menuData} from './utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether the menu items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby'] && process.env.NODE_ENV !== 'production') {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape' || props.shouldUseVirtualFocus) {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.module.js.map"}
|
package/dist/useMenuItem.main.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
var $815e346b11b84016$exports = require("./utils.main.js");
|
|
2
|
-
var $byVdR$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $byVdR$reactstatelycollections = require("@react-stately/collections");
|
|
4
|
-
var $byVdR$reactariainteractions = require("@react-aria/interactions");
|
|
5
|
-
var $byVdR$react = require("react");
|
|
6
|
-
var $byVdR$reactariaselection = require("@react-aria/selection");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$export(e, n, v, s) {
|
|
10
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
$parcel$export(module.exports, "useMenuItem", () => $38191ed02615ec07$export$9d32628fc2aea7da);
|
|
14
|
-
/*
|
|
15
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
-
* governing permissions and limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
|
|
31
|
-
let { id: id, key: key, closeOnSelect: closeOnSelect, shouldCloseOnSelect: shouldCloseOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: onPressStart, onPressUp: pressUpProp, onPress: onPress, onPressChange: pressChangeProp, onPressEnd: onPressEnd, onClick: onClickProp, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
|
|
32
|
-
let isTrigger = !!hasPopup;
|
|
33
|
-
let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
|
|
34
|
-
var _props_isDisabled;
|
|
35
|
-
let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
|
|
36
|
-
var _props_isSelected;
|
|
37
|
-
let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
|
|
38
|
-
let data = (0, $815e346b11b84016$exports.menuData).get(state);
|
|
39
|
-
let item = state.collection.getItem(key);
|
|
40
|
-
let onClose = props.onClose || data.onClose;
|
|
41
|
-
let router = (0, $byVdR$reactariautils.useRouter)();
|
|
42
|
-
let performAction = ()=>{
|
|
43
|
-
var _item_props;
|
|
44
|
-
if (isTrigger) return;
|
|
45
|
-
if (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) item.props.onAction();
|
|
46
|
-
else if (props.onAction) props.onAction(key);
|
|
47
|
-
if (data.onAction) {
|
|
48
|
-
// Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.
|
|
49
|
-
let onAction = data.onAction;
|
|
50
|
-
onAction(key);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
let role = 'menuitem';
|
|
54
|
-
if (!isTrigger) {
|
|
55
|
-
if (selectionManager.selectionMode === 'single') role = 'menuitemradio';
|
|
56
|
-
else if (selectionManager.selectionMode === 'multiple') role = 'menuitemcheckbox';
|
|
57
|
-
}
|
|
58
|
-
let labelId = (0, $byVdR$reactariautils.useSlotId)();
|
|
59
|
-
let descriptionId = (0, $byVdR$reactariautils.useSlotId)();
|
|
60
|
-
let keyboardId = (0, $byVdR$reactariautils.useSlotId)();
|
|
61
|
-
let ariaProps = {
|
|
62
|
-
id: id,
|
|
63
|
-
'aria-disabled': isDisabled || undefined,
|
|
64
|
-
role: role,
|
|
65
|
-
'aria-label': props['aria-label'],
|
|
66
|
-
'aria-labelledby': labelId,
|
|
67
|
-
'aria-describedby': [
|
|
68
|
-
props['aria-describedby'],
|
|
69
|
-
descriptionId,
|
|
70
|
-
keyboardId
|
|
71
|
-
].filter(Boolean).join(' ') || undefined,
|
|
72
|
-
'aria-controls': props['aria-controls'],
|
|
73
|
-
'aria-haspopup': hasPopup,
|
|
74
|
-
'aria-expanded': props['aria-expanded']
|
|
75
|
-
};
|
|
76
|
-
if (selectionManager.selectionMode !== 'none' && !isTrigger) ariaProps['aria-checked'] = isSelected;
|
|
77
|
-
if (isVirtualized) {
|
|
78
|
-
let index = Number(item === null || item === void 0 ? void 0 : item.index);
|
|
79
|
-
ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;
|
|
80
|
-
ariaProps['aria-setsize'] = (0, $byVdR$reactstatelycollections.getItemCount)(state.collection);
|
|
81
|
-
}
|
|
82
|
-
let isPressedRef = (0, $byVdR$react.useRef)(false);
|
|
83
|
-
let onPressChange = (isPressed)=>{
|
|
84
|
-
pressChangeProp === null || pressChangeProp === void 0 ? void 0 : pressChangeProp(isPressed);
|
|
85
|
-
isPressedRef.current = isPressed;
|
|
86
|
-
};
|
|
87
|
-
let interaction = (0, $byVdR$react.useRef)(null);
|
|
88
|
-
let onPressUp = (e)=>{
|
|
89
|
-
if (e.pointerType !== 'keyboard') interaction.current = {
|
|
90
|
-
pointerType: e.pointerType
|
|
91
|
-
};
|
|
92
|
-
// If interacting with mouse, allow the user to mouse down on the trigger button,
|
|
93
|
-
// drag, and release over an item (matching native behavior).
|
|
94
|
-
if (e.pointerType === 'mouse') {
|
|
95
|
-
if (!isPressedRef.current) e.target.click();
|
|
96
|
-
}
|
|
97
|
-
pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
|
|
98
|
-
};
|
|
99
|
-
let onClick = (e)=>{
|
|
100
|
-
var _interaction_current, _interaction_current1;
|
|
101
|
-
onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(e);
|
|
102
|
-
performAction();
|
|
103
|
-
(0, $byVdR$reactariautils.handleLinkClick)(e, router, item.props.href, item === null || item === void 0 ? void 0 : item.props.routerOptions);
|
|
104
|
-
let shouldClose = ((_interaction_current = interaction.current) === null || _interaction_current === void 0 ? void 0 : _interaction_current.pointerType) === 'keyboard' ? ((_interaction_current1 = interaction.current) === null || _interaction_current1 === void 0 ? void 0 : _interaction_current1.key) === 'Enter' || selectionManager.selectionMode === 'none' || selectionManager.isLink(key) : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);
|
|
105
|
-
var _ref;
|
|
106
|
-
shouldClose = (_ref = shouldCloseOnSelect !== null && shouldCloseOnSelect !== void 0 ? shouldCloseOnSelect : closeOnSelect) !== null && _ref !== void 0 ? _ref : shouldClose;
|
|
107
|
-
if (onClose && !isTrigger && shouldClose) onClose();
|
|
108
|
-
interaction.current = null;
|
|
109
|
-
};
|
|
110
|
-
let { itemProps: itemProps, isFocused: isFocused } = (0, $byVdR$reactariaselection.useSelectableItem)({
|
|
111
|
-
id: id,
|
|
112
|
-
selectionManager: selectionManager,
|
|
113
|
-
key: key,
|
|
114
|
-
ref: ref,
|
|
115
|
-
shouldSelectOnPressUp: true,
|
|
116
|
-
allowsDifferentPressOrigin: true,
|
|
117
|
-
// Disable all handling of links in useSelectable item
|
|
118
|
-
// because we handle it ourselves. The behavior of menus
|
|
119
|
-
// is slightly different from other collections because
|
|
120
|
-
// actions are performed on key down rather than key up.
|
|
121
|
-
linkBehavior: 'none',
|
|
122
|
-
shouldUseVirtualFocus: data.shouldUseVirtualFocus
|
|
123
|
-
});
|
|
124
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $byVdR$reactariainteractions.usePress)({
|
|
125
|
-
onPressStart: onPressStart,
|
|
126
|
-
onPress: onPress,
|
|
127
|
-
onPressUp: onPressUp,
|
|
128
|
-
onPressChange: onPressChange,
|
|
129
|
-
onPressEnd: onPressEnd,
|
|
130
|
-
isDisabled: isDisabled
|
|
131
|
-
});
|
|
132
|
-
let { hoverProps: hoverProps } = (0, $byVdR$reactariainteractions.useHover)({
|
|
133
|
-
isDisabled: isDisabled,
|
|
134
|
-
onHoverStart (e) {
|
|
135
|
-
// Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
|
|
136
|
-
if (!(0, $byVdR$reactariainteractions.isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
|
|
137
|
-
selectionManager.setFocused(true);
|
|
138
|
-
selectionManager.setFocusedKey(key);
|
|
139
|
-
}
|
|
140
|
-
hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
|
|
141
|
-
},
|
|
142
|
-
onHoverChange: onHoverChange,
|
|
143
|
-
onHoverEnd: onHoverEnd
|
|
144
|
-
});
|
|
145
|
-
let { keyboardProps: keyboardProps } = (0, $byVdR$reactariainteractions.useKeyboard)({
|
|
146
|
-
onKeyDown: (e)=>{
|
|
147
|
-
// Ignore repeating events, which may have started on the menu trigger before moving
|
|
148
|
-
// focus to the menu item. We want to wait for a second complete key press sequence.
|
|
149
|
-
if (e.repeat) {
|
|
150
|
-
e.continuePropagation();
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
switch(e.key){
|
|
154
|
-
case ' ':
|
|
155
|
-
interaction.current = {
|
|
156
|
-
pointerType: 'keyboard',
|
|
157
|
-
key: ' '
|
|
158
|
-
};
|
|
159
|
-
(0, $byVdR$reactariautils.getEventTarget)(e).click();
|
|
160
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
161
|
-
// to the newly opened submenu's first item.
|
|
162
|
-
(0, $byVdR$reactariainteractions.setInteractionModality)('keyboard');
|
|
163
|
-
break;
|
|
164
|
-
case 'Enter':
|
|
165
|
-
interaction.current = {
|
|
166
|
-
pointerType: 'keyboard',
|
|
167
|
-
key: 'Enter'
|
|
168
|
-
};
|
|
169
|
-
// Trigger click unless this is a link. Links trigger click natively.
|
|
170
|
-
if ((0, $byVdR$reactariautils.getEventTarget)(e).tagName !== 'A') (0, $byVdR$reactariautils.getEventTarget)(e).click();
|
|
171
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
172
|
-
// to the newly opened submenu's first item.
|
|
173
|
-
(0, $byVdR$reactariainteractions.setInteractionModality)('keyboard');
|
|
174
|
-
break;
|
|
175
|
-
default:
|
|
176
|
-
if (!isTrigger) e.continuePropagation();
|
|
177
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
onKeyUp: onKeyUp
|
|
182
|
-
});
|
|
183
|
-
let { focusableProps: focusableProps } = (0, $byVdR$reactariainteractions.useFocusable)({
|
|
184
|
-
onBlur: onBlur,
|
|
185
|
-
onFocus: onFocus,
|
|
186
|
-
onFocusChange: onFocusChange
|
|
187
|
-
}, ref);
|
|
188
|
-
let domProps = (0, $byVdR$reactariautils.filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
189
|
-
delete domProps.id;
|
|
190
|
-
let linkProps = (0, $byVdR$reactariautils.useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
191
|
-
return {
|
|
192
|
-
menuItemProps: {
|
|
193
|
-
...ariaProps,
|
|
194
|
-
...(0, $byVdR$reactariautils.mergeProps)(domProps, linkProps, isTrigger ? {
|
|
195
|
-
onFocus: itemProps.onFocus,
|
|
196
|
-
'data-collection': itemProps['data-collection'],
|
|
197
|
-
'data-key': itemProps['data-key']
|
|
198
|
-
} : itemProps, pressProps, hoverProps, keyboardProps, focusableProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
|
|
199
|
-
data.shouldUseVirtualFocus || isTrigger ? {
|
|
200
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
201
|
-
} : undefined, isDisabled ? undefined : {
|
|
202
|
-
onClick: onClick
|
|
203
|
-
}),
|
|
204
|
-
// If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.
|
|
205
|
-
tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
|
|
206
|
-
},
|
|
207
|
-
labelProps: {
|
|
208
|
-
id: labelId
|
|
209
|
-
},
|
|
210
|
-
descriptionProps: {
|
|
211
|
-
id: descriptionId
|
|
212
|
-
},
|
|
213
|
-
keyboardShortcutProps: {
|
|
214
|
-
id: keyboardId
|
|
215
|
-
},
|
|
216
|
-
isFocused: isFocused,
|
|
217
|
-
isFocusVisible: isFocused && selectionManager.isFocused && (0, $byVdR$reactariainteractions.isFocusVisible)() && !isTriggerExpanded,
|
|
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ExC,OAAO;QACL,eAAe;YACb,GAAG,SAAS;YACZ,GAAG,CAAA,GAAA,gCAAS,EACV,UACA,WACA,YACI;gBAAC,SAAS,UAAU,OAAO;gBAAE,mBAAmB,SAAS,CAAC,kBAAkB;gBAAE,YAAY,SAAS,CAAC,WAAW;YAAA,IAC/G,WACJ,YACA,YACA,eACA,gBACA,+GAA+G;YAC/G,KAAK,qBAAqB,IAAI,YAAY;gBAAC,aAAa,CAAA,IAAK,EAAE,cAAc;YAAE,IAAI,WACnF,aAAa,YAAY;yBAAC;YAAO,EAClC;YACD,+HAA+H;YAC/H,UAAU,UAAU,QAAQ,IAAI,QAAQ,qBAAqB,CAAC,KAAK,qBAAqB,GAAG,KAAK,UAAU,QAAQ;QACpH;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,uBAAuB;YACrB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,iBAAiB,SAAS,IAAI,CAAA,GAAA,2CAAa,OAAO,CAAC;oBAChF;mBACA;oBACA;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenuItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, DOMProps, FocusableElement, FocusEvents, HoverEvents, Key, KeyboardEvents, PressEvent, PressEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, getEventTarget, handleLinkClick, mergeProps, useLinkProps, useRouter, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {isFocusVisible, setInteractionModality, useFocusable, useHover, useKeyboard, usePress} from '@react-aria/interactions';\nimport {menuData} from './utils';\nimport {MouseEvent, useRef} from 'react';\nimport {SelectionManager} from '@react-stately/selection';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface MenuItemAria {\n /** Props for the menu item element. */\n menuItemProps: DOMAttributes,\n\n /** Props for the main text element inside the menu item. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the menu item, if any. */\n descriptionProps: DOMAttributes,\n\n /** Props for the keyboard shortcut text element inside the item, if any. */\n keyboardShortcutProps: DOMAttributes,\n\n /** Whether the item is currently focused. */\n isFocused: boolean,\n /** Whether the item is keyboard focused. */\n isFocusVisible: boolean,\n /** Whether the item is currently selected. */\n isSelected: boolean,\n /** Whether the item is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the item is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaMenuItemProps extends DOMProps, PressEvents, HoverEvents, KeyboardEvents, FocusEvents {\n /**\n * Whether the menu item is disabled.\n * @deprecated - pass disabledKeys to useTreeState instead.\n */\n isDisabled?: boolean,\n\n /**\n * Whether the menu item is selected.\n * @deprecated - pass selectedKeys to useTreeState instead.\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the menu item. */\n 'aria-label'?: string,\n\n /** The unique key for the menu item. */\n key: Key,\n\n /**\n * Handler that is called when the menu should close after selecting an item.\n * @deprecated - pass to the menu instead.\n */\n onClose?: () => void,\n\n /**\n * Whether the menu should close when the menu item is selected.\n * @deprecated - use shouldCloseOnSelect instead.\n */\n closeOnSelect?: boolean,\n\n /** Whether the menu should close when the menu item is selected. */\n shouldCloseOnSelect?: boolean,\n\n /** Whether the menu item is contained in a virtual scrolling menu. */\n isVirtualized?: boolean,\n\n /**\n * Handler that is called when the user activates the item.\n * @deprecated - pass to the menu instead.\n */\n onAction?: (key: Key) => void,\n\n /** What kind of popup the item opens. */\n 'aria-haspopup'?: 'menu' | 'dialog',\n\n /** Indicates whether the menu item's popup element is expanded or collapsed. */\n 'aria-expanded'?: boolean | 'true' | 'false',\n\n /** Identifies the menu item's popup element whose contents or presence is controlled by the menu item. */\n 'aria-controls'?: string,\n\n /** Identifies the element(s) that describe the menu item. */\n 'aria-describedby'?: string,\n\n /** Override of the selection manager. By default, `state.selectionManager` is used. */\n selectionManager?: SelectionManager\n}\n\n/**\n * Provides the behavior and accessibility implementation for an item in a menu.\n * See `useMenu` for more details about menus.\n * @param props - Props for the item.\n * @param state - State for the menu, as returned by `useTreeState`.\n */\nexport function useMenuItem<T>(props: AriaMenuItemProps, state: TreeState<T>, ref: RefObject<FocusableElement | null>): MenuItemAria {\n let {\n id,\n key,\n closeOnSelect,\n shouldCloseOnSelect,\n isVirtualized,\n 'aria-haspopup': hasPopup,\n onPressStart,\n onPressUp: pressUpProp,\n onPress,\n onPressChange: pressChangeProp,\n onPressEnd,\n onClick: onClickProp,\n onHoverStart: hoverStartProp,\n onHoverChange,\n onHoverEnd,\n onKeyDown,\n onKeyUp,\n onFocus,\n onFocusChange,\n onBlur,\n selectionManager = state.selectionManager\n } = props;\n\n let isTrigger = !!hasPopup;\n let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';\n let isDisabled = props.isDisabled ?? selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? selectionManager.isSelected(key);\n let data = menuData.get(state)!;\n let item = state.collection.getItem(key);\n let onClose = props.onClose || data.onClose;\n let router = useRouter();\n let performAction = () => {\n if (isTrigger) {\n return;\n }\n\n if (item?.props?.onAction) {\n item.props.onAction();\n } else if (props.onAction) {\n props.onAction(key);\n }\n\n if (data.onAction) {\n // Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.\n let onAction = data.onAction;\n onAction(key);\n }\n };\n\n let role = 'menuitem';\n if (!isTrigger) {\n if (selectionManager.selectionMode === 'single') {\n role = 'menuitemradio';\n } else if (selectionManager.selectionMode === 'multiple') {\n role = 'menuitemcheckbox';\n }\n }\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n let keyboardId = useSlotId();\n\n let ariaProps = {\n id,\n 'aria-disabled': isDisabled || undefined,\n role,\n 'aria-label': props['aria-label'],\n 'aria-labelledby': labelId,\n 'aria-describedby': [props['aria-describedby'], descriptionId, keyboardId].filter(Boolean).join(' ') || undefined,\n 'aria-controls': props['aria-controls'],\n 'aria-haspopup': hasPopup,\n 'aria-expanded': props['aria-expanded']\n };\n\n if (selectionManager.selectionMode !== 'none' && !isTrigger) {\n ariaProps['aria-checked'] = isSelected;\n }\n\n if (isVirtualized) {\n let index = Number(item?.index);\n ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n ariaProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let isPressedRef = useRef(false);\n let onPressChange = (isPressed: boolean) => {\n pressChangeProp?.(isPressed);\n isPressedRef.current = isPressed;\n };\n\n let interaction = useRef<{pointerType: string, key?: string} | null>(null);\n let onPressUp = (e: PressEvent) => {\n if (e.pointerType !== 'keyboard') {\n interaction.current = {pointerType: e.pointerType};\n }\n\n // If interacting with mouse, allow the user to mouse down on the trigger button,\n // drag, and release over an item (matching native behavior).\n if (e.pointerType === 'mouse') {\n if (!isPressedRef.current) {\n (e.target as HTMLElement).click();\n }\n }\n\n pressUpProp?.(e);\n };\n\n let onClick = (e: MouseEvent<FocusableElement>) => {\n onClickProp?.(e);\n performAction();\n handleLinkClick(e, router, item!.props.href, item?.props.routerOptions);\n\n let shouldClose = interaction.current?.pointerType === 'keyboard'\n // Always close when pressing Enter key, or if item is not selectable.\n ? interaction.current?.key === 'Enter' || selectionManager.selectionMode === 'none' || selectionManager.isLink(key)\n // Close except if multi-select is enabled.\n : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);\n\n\n shouldClose = shouldCloseOnSelect ?? closeOnSelect ?? shouldClose;\n\n if (onClose && !isTrigger && shouldClose) {\n onClose();\n }\n\n interaction.current = null;\n };\n\n let {itemProps, isFocused} = useSelectableItem({\n id,\n selectionManager: selectionManager,\n key,\n ref,\n shouldSelectOnPressUp: true,\n allowsDifferentPressOrigin: true,\n // Disable all handling of links in useSelectable item\n // because we handle it ourselves. The behavior of menus\n // is slightly different from other collections because\n // actions are performed on key down rather than key up.\n linkBehavior: 'none',\n shouldUseVirtualFocus: data.shouldUseVirtualFocus\n });\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPress,\n onPressUp,\n onPressChange,\n onPressEnd,\n isDisabled\n });\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart(e) {\n // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.\n if (!isFocusVisible() && !(isTriggerExpanded && hasPopup)) {\n selectionManager.setFocused(true);\n selectionManager.setFocusedKey(key);\n }\n hoverStartProp?.(e);\n },\n onHoverChange,\n onHoverEnd\n });\n\n let {keyboardProps} = useKeyboard({\n onKeyDown: (e) => {\n // Ignore repeating events, which may have started on the menu trigger before moving\n // focus to the menu item. We want to wait for a second complete key press sequence.\n if (e.repeat) {\n e.continuePropagation();\n return;\n }\n\n switch (e.key) {\n case ' ':\n interaction.current = {pointerType: 'keyboard', key: ' '};\n (getEventTarget(e) as HTMLElement).click();\n\n // click above sets modality to \"virtual\", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus\n // to the newly opened submenu's first item.\n setInteractionModality('keyboard');\n break;\n case 'Enter':\n interaction.current = {pointerType: 'keyboard', key: 'Enter'};\n\n // Trigger click unless this is a link. Links trigger click natively.\n if ((getEventTarget(e) as HTMLElement).tagName !== 'A') {\n (getEventTarget(e) as HTMLElement).click();\n }\n\n // click above sets modality to \"virtual\", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus\n // to the newly opened submenu's first item.\n setInteractionModality('keyboard');\n break;\n default:\n if (!isTrigger) {\n e.continuePropagation();\n }\n\n onKeyDown?.(e);\n break;\n }\n },\n onKeyUp\n });\n\n let {focusableProps} = useFocusable({onBlur, onFocus, onFocusChange}, ref);\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n menuItemProps: {\n ...ariaProps,\n ...mergeProps(\n domProps,\n linkProps,\n isTrigger\n ? {onFocus: itemProps.onFocus, 'data-collection': itemProps['data-collection'], 'data-key': itemProps['data-key']}\n : itemProps,\n pressProps,\n hoverProps,\n keyboardProps,\n focusableProps,\n // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.\n data.shouldUseVirtualFocus || isTrigger ? {onMouseDown: e => e.preventDefault()} : undefined,\n isDisabled ? undefined : {onClick}\n ),\n // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.\n tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n keyboardShortcutProps: {\n id: keyboardId\n },\n isFocused,\n isFocusVisible: isFocused && selectionManager.isFocused && isFocusVisible() && !isTriggerExpanded,\n isSelected,\n isPressed,\n isDisabled\n };\n}\n"],"names":[],"version":3,"file":"useMenuItem.main.js.map"}
|