@react-aria/menu 3.13.2-nightly.4555 → 3.13.2-nightly.4560

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.
Files changed (75) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +5 -721
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +10 -726
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +5 -721
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useMenu.main.js +59 -0
  44. package/dist/useMenu.main.js.map +1 -0
  45. package/dist/useMenu.mjs +53 -0
  46. package/dist/useMenu.module.js +53 -0
  47. package/dist/useMenu.module.js.map +1 -0
  48. package/dist/useMenuItem.main.js +175 -0
  49. package/dist/useMenuItem.main.js.map +1 -0
  50. package/dist/useMenuItem.mjs +170 -0
  51. package/dist/useMenuItem.module.js +170 -0
  52. package/dist/useMenuItem.module.js.map +1 -0
  53. package/dist/useMenuSection.main.js +43 -0
  54. package/dist/useMenuSection.main.js.map +1 -0
  55. package/dist/useMenuSection.mjs +38 -0
  56. package/dist/useMenuSection.module.js +38 -0
  57. package/dist/useMenuSection.module.js.map +1 -0
  58. package/dist/useMenuTrigger.main.js +103 -0
  59. package/dist/useMenuTrigger.main.js.map +1 -0
  60. package/dist/useMenuTrigger.mjs +98 -0
  61. package/dist/useMenuTrigger.module.js +98 -0
  62. package/dist/useMenuTrigger.module.js.map +1 -0
  63. package/dist/useSafelyMouseToSubmenu.main.js +134 -0
  64. package/dist/useSafelyMouseToSubmenu.main.js.map +1 -0
  65. package/dist/useSafelyMouseToSubmenu.mjs +129 -0
  66. package/dist/useSafelyMouseToSubmenu.module.js +129 -0
  67. package/dist/useSafelyMouseToSubmenu.module.js.map +1 -0
  68. package/dist/useSubmenuTrigger.main.js +169 -0
  69. package/dist/useSubmenuTrigger.main.js.map +1 -0
  70. package/dist/useSubmenuTrigger.mjs +164 -0
  71. package/dist/useSubmenuTrigger.module.js +164 -0
  72. package/dist/useSubmenuTrigger.module.js.map +1 -0
  73. package/dist/zh-CN.mjs +1 -1
  74. package/dist/zh-TW.mjs +1 -1
  75. package/package.json +14 -14
package/dist/main.js CHANGED
@@ -1,437 +1,19 @@
1
- var $429891642bf97c51$exports = require("./ar-AE.main.js");
2
- var $40d90b799072e111$exports = require("./bg-BG.main.js");
3
- var $587b89d60e4f3e24$exports = require("./cs-CZ.main.js");
4
- var $79eb8045886465e9$exports = require("./da-DK.main.js");
5
- var $9c6faa2088d34bf1$exports = require("./de-DE.main.js");
6
- var $ee6e1292c61a8135$exports = require("./el-GR.main.js");
7
- var $f479187898d153cc$exports = require("./en-US.main.js");
8
- var $1e6a91f77efbb11f$exports = require("./es-ES.main.js");
9
- var $f2fb75e964082636$exports = require("./et-EE.main.js");
10
- var $75cc65c4b616fac1$exports = require("./fi-FI.main.js");
11
- var $82a179939aabd1ee$exports = require("./fr-FR.main.js");
12
- var $40aa37345f1f8748$exports = require("./he-IL.main.js");
13
- var $c00088e5c377e2c5$exports = require("./hr-HR.main.js");
14
- var $51f736a409b7d295$exports = require("./hu-HU.main.js");
15
- var $65bb74747bd8f2fb$exports = require("./it-IT.main.js");
16
- var $1bc11da108727c27$exports = require("./ja-JP.main.js");
17
- var $118d77e4be898c17$exports = require("./ko-KR.main.js");
18
- var $4db9ebadbf792309$exports = require("./lt-LT.main.js");
19
- var $51288b53bc93ac3d$exports = require("./lv-LV.main.js");
20
- var $1a4b31206cd66e98$exports = require("./nb-NO.main.js");
21
- var $21e944c6af0b8453$exports = require("./nl-NL.main.js");
22
- var $20509ccafe6fe6aa$exports = require("./pl-PL.main.js");
23
- var $8006eac1d5d4665b$exports = require("./pt-BR.main.js");
24
- var $4875d1b529941a0a$exports = require("./pt-PT.main.js");
25
- var $37939d04a40a865b$exports = require("./ro-RO.main.js");
26
- var $fd1c8a4521d30c69$exports = require("./ru-RU.main.js");
27
- var $2940d0a4ba6cbd64$exports = require("./sk-SK.main.js");
28
- var $cb481a56d5c8fa56$exports = require("./sl-SI.main.js");
29
- var $ecbdeaa2c85d1b32$exports = require("./sr-SP.main.js");
30
- var $aeca4735c8d1bab6$exports = require("./sv-SE.main.js");
31
- var $68243426be5c9f01$exports = require("./tr-TR.main.js");
32
- var $bde63de8df74e87d$exports = require("./uk-UA.main.js");
33
- var $2d16ab23cbf254d4$exports = require("./zh-CN.main.js");
34
- var $bd9ff3a1da9d944a$exports = require("./zh-TW.main.js");
35
- var $fHYTQ$reactariautils = require("@react-aria/utils");
36
- var $fHYTQ$reactariai18n = require("@react-aria/i18n");
37
- var $fHYTQ$reactariainteractions = require("@react-aria/interactions");
38
- var $fHYTQ$reactariaoverlays = require("@react-aria/overlays");
39
- var $fHYTQ$reactariaselection = require("@react-aria/selection");
40
- var $fHYTQ$reactstatelycollections = require("@react-stately/collections");
41
- var $fHYTQ$react = require("react");
1
+ var $7211ab9328763fb9$exports = require("./useMenuTrigger.main.js");
2
+ var $a3815f0132802737$exports = require("./useMenu.main.js");
3
+ var $38191ed02615ec07$exports = require("./useMenuItem.main.js");
4
+ var $63008655e23408c5$exports = require("./useMenuSection.main.js");
5
+ var $5f4753043c9f6cdf$exports = require("./useSubmenuTrigger.main.js");
42
6
 
43
7
 
44
8
  function $parcel$export(e, n, v, s) {
45
9
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
46
10
  }
47
11
 
48
- function $parcel$interopDefault(a) {
49
- return a && a.__esModule ? a.default : a;
50
- }
51
-
52
- $parcel$export(module.exports, "useMenuTrigger", () => $7211ab9328763fb9$export$dc9c12ed27dd1b49);
53
- $parcel$export(module.exports, "useMenu", () => $a3815f0132802737$export$38eaa17faae8f579);
54
- $parcel$export(module.exports, "useMenuItem", () => $38191ed02615ec07$export$9d32628fc2aea7da);
55
- $parcel$export(module.exports, "useMenuSection", () => $63008655e23408c5$export$73f7a44322579622);
56
- $parcel$export(module.exports, "UNSTABLE_useSubmenuTrigger", () => $5f4753043c9f6cdf$export$3819f8ee9f4ce664);
57
- /*
58
- * Copyright 2020 Adobe. All rights reserved.
59
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
60
- * you may not use this file except in compliance with the License. You may obtain a copy
61
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
62
- *
63
- * Unless required by applicable law or agreed to in writing, software distributed under
64
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
65
- * OF ANY KIND, either express or implied. See the License for the specific language
66
- * governing permissions and limitations under the License.
67
- */ /*
68
- * Copyright 2020 Adobe. All rights reserved.
69
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
70
- * you may not use this file except in compliance with the License. You may obtain a copy
71
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
72
- *
73
- * Unless required by applicable law or agreed to in writing, software distributed under
74
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
75
- * OF ANY KIND, either express or implied. See the License for the specific language
76
- * governing permissions and limitations under the License.
77
- */ var $d1742ec2644a0949$exports = {};
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- $d1742ec2644a0949$exports = {
113
- "ar-AE": $429891642bf97c51$exports,
114
- "bg-BG": $40d90b799072e111$exports,
115
- "cs-CZ": $587b89d60e4f3e24$exports,
116
- "da-DK": $79eb8045886465e9$exports,
117
- "de-DE": $9c6faa2088d34bf1$exports,
118
- "el-GR": $ee6e1292c61a8135$exports,
119
- "en-US": $f479187898d153cc$exports,
120
- "es-ES": $1e6a91f77efbb11f$exports,
121
- "et-EE": $f2fb75e964082636$exports,
122
- "fi-FI": $75cc65c4b616fac1$exports,
123
- "fr-FR": $82a179939aabd1ee$exports,
124
- "he-IL": $40aa37345f1f8748$exports,
125
- "hr-HR": $c00088e5c377e2c5$exports,
126
- "hu-HU": $51f736a409b7d295$exports,
127
- "it-IT": $65bb74747bd8f2fb$exports,
128
- "ja-JP": $1bc11da108727c27$exports,
129
- "ko-KR": $118d77e4be898c17$exports,
130
- "lt-LT": $4db9ebadbf792309$exports,
131
- "lv-LV": $51288b53bc93ac3d$exports,
132
- "nb-NO": $1a4b31206cd66e98$exports,
133
- "nl-NL": $21e944c6af0b8453$exports,
134
- "pl-PL": $20509ccafe6fe6aa$exports,
135
- "pt-BR": $8006eac1d5d4665b$exports,
136
- "pt-PT": $4875d1b529941a0a$exports,
137
- "ro-RO": $37939d04a40a865b$exports,
138
- "ru-RU": $fd1c8a4521d30c69$exports,
139
- "sk-SK": $2940d0a4ba6cbd64$exports,
140
- "sl-SI": $cb481a56d5c8fa56$exports,
141
- "sr-SP": $ecbdeaa2c85d1b32$exports,
142
- "sv-SE": $aeca4735c8d1bab6$exports,
143
- "tr-TR": $68243426be5c9f01$exports,
144
- "uk-UA": $bde63de8df74e87d$exports,
145
- "zh-CN": $2d16ab23cbf254d4$exports,
146
- "zh-TW": $bd9ff3a1da9d944a$exports
147
- };
148
-
149
-
150
-
151
-
152
-
153
-
154
- function $7211ab9328763fb9$export$dc9c12ed27dd1b49(props, state, ref) {
155
- let { type: type = "menu", isDisabled: isDisabled, trigger: trigger = "press" } = props;
156
- let menuTriggerId = (0, $fHYTQ$reactariautils.useId)();
157
- let { triggerProps: triggerProps, overlayProps: overlayProps } = (0, $fHYTQ$reactariaoverlays.useOverlayTrigger)({
158
- type: type
159
- }, state, ref);
160
- let onKeyDown = (e)=>{
161
- if (isDisabled) return;
162
- if (trigger === "longPress" && !e.altKey) return;
163
- if (ref && ref.current) switch(e.key){
164
- case "Enter":
165
- case " ":
166
- if (trigger === "longPress") return;
167
- // fallthrough
168
- case "ArrowDown":
169
- // Stop propagation, unless it would already be handled by useKeyboard.
170
- if (!("continuePropagation" in e)) e.stopPropagation();
171
- e.preventDefault();
172
- state.toggle("first");
173
- break;
174
- case "ArrowUp":
175
- if (!("continuePropagation" in e)) e.stopPropagation();
176
- e.preventDefault();
177
- state.toggle("last");
178
- break;
179
- default:
180
- // Allow other keys.
181
- if ("continuePropagation" in e) e.continuePropagation();
182
- }
183
- };
184
- let stringFormatter = (0, $fHYTQ$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($d1742ec2644a0949$exports))), "@react-aria/menu");
185
- let { longPressProps: longPressProps } = (0, $fHYTQ$reactariainteractions.useLongPress)({
186
- isDisabled: isDisabled || trigger !== "longPress",
187
- accessibilityDescription: stringFormatter.format("longPressMessage"),
188
- onLongPressStart () {
189
- state.close();
190
- },
191
- onLongPress () {
192
- state.open("first");
193
- }
194
- });
195
- let pressProps = {
196
- onPressStart (e) {
197
- // For consistency with native, open the menu on mouse/key down, but touch up.
198
- if (e.pointerType !== "touch" && e.pointerType !== "keyboard" && !isDisabled) // If opened with a screen reader, auto focus the first item.
199
- // Otherwise, the menu itself will be focused.
200
- state.open(e.pointerType === "virtual" ? "first" : null);
201
- },
202
- onPress (e) {
203
- if (e.pointerType === "touch" && !isDisabled) state.toggle();
204
- }
205
- };
206
- // omit onPress from triggerProps since we override it above.
207
- delete triggerProps.onPress;
208
- return {
209
- menuTriggerProps: {
210
- ...triggerProps,
211
- ...trigger === "press" ? pressProps : longPressProps,
212
- id: menuTriggerId,
213
- onKeyDown: onKeyDown
214
- },
215
- menuProps: {
216
- ...overlayProps,
217
- "aria-labelledby": menuTriggerId,
218
- autoFocus: state.focusStrategy || true,
219
- onClose: state.close
220
- }
221
- };
222
- }
223
-
224
-
225
- /*
226
- * Copyright 2020 Adobe. All rights reserved.
227
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
228
- * you may not use this file except in compliance with the License. You may obtain a copy
229
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
230
- *
231
- * Unless required by applicable law or agreed to in writing, software distributed under
232
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
233
- * OF ANY KIND, either express or implied. See the License for the specific language
234
- * governing permissions and limitations under the License.
235
- */
236
-
237
- const $a3815f0132802737$export$6f49b4016bfc8d56 = new WeakMap();
238
- function $a3815f0132802737$export$38eaa17faae8f579(props, state, ref) {
239
- let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
240
- if (!props["aria-label"] && !props["aria-labelledby"]) console.warn("An aria-label or aria-labelledby prop is required for accessibility.");
241
- let domProps = (0, $fHYTQ$reactariautils.filterDOMProps)(props, {
242
- labelable: true
243
- });
244
- let { listProps: listProps } = (0, $fHYTQ$reactariaselection.useSelectableList)({
245
- ...otherProps,
246
- ref: ref,
247
- selectionManager: state.selectionManager,
248
- collection: state.collection,
249
- disabledKeys: state.disabledKeys,
250
- shouldFocusWrap: shouldFocusWrap,
251
- linkBehavior: "override"
252
- });
253
- $a3815f0132802737$export$6f49b4016bfc8d56.set(state, {
254
- onClose: props.onClose,
255
- onAction: props.onAction
256
- });
257
- return {
258
- menuProps: (0, $fHYTQ$reactariautils.mergeProps)(domProps, {
259
- onKeyDown: onKeyDown,
260
- onKeyUp: onKeyUp
261
- }, {
262
- role: "menu",
263
- ...listProps,
264
- onKeyDown: (e)=>{
265
- // don't clear the menu selected keys if the user is presses escape since escape closes the menu
266
- if (e.key !== "Escape") listProps.onKeyDown(e);
267
- }
268
- })
269
- };
270
- }
271
-
272
-
273
- /*
274
- * Copyright 2020 Adobe. All rights reserved.
275
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
276
- * you may not use this file except in compliance with the License. You may obtain a copy
277
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
278
- *
279
- * Unless required by applicable law or agreed to in writing, software distributed under
280
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
281
- * OF ANY KIND, either express or implied. See the License for the specific language
282
- * governing permissions and limitations under the License.
283
- */
284
-
285
-
286
-
287
-
288
- function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
289
- let { key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, "aria-haspopup": hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: onPress, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur } = props;
290
- let isTrigger = !!hasPopup;
291
- var _props_isDisabled;
292
- let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
293
- var _props_isSelected;
294
- let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
295
- let data = (0, $a3815f0132802737$export$6f49b4016bfc8d56).get(state);
296
- let item = state.collection.getItem(key);
297
- let onClose = props.onClose || data.onClose;
298
- let router = (0, $fHYTQ$reactariautils.useRouter)();
299
- let performAction = (e)=>{
300
- var _item_props;
301
- if (isTrigger) return;
302
- 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();
303
- if (props.onAction) props.onAction(key);
304
- else if (data.onAction) data.onAction(key);
305
- if (e.target instanceof HTMLAnchorElement) router.open(e.target, e, item.props.href, item.props.routerOptions);
306
- };
307
- let role = "menuitem";
308
- if (!isTrigger) {
309
- if (state.selectionManager.selectionMode === "single") role = "menuitemradio";
310
- else if (state.selectionManager.selectionMode === "multiple") role = "menuitemcheckbox";
311
- }
312
- let labelId = (0, $fHYTQ$reactariautils.useSlotId)();
313
- let descriptionId = (0, $fHYTQ$reactariautils.useSlotId)();
314
- let keyboardId = (0, $fHYTQ$reactariautils.useSlotId)();
315
- let ariaProps = {
316
- "aria-disabled": isDisabled || undefined,
317
- role: role,
318
- "aria-label": props["aria-label"],
319
- "aria-labelledby": labelId,
320
- "aria-describedby": [
321
- descriptionId,
322
- keyboardId
323
- ].filter(Boolean).join(" ") || undefined,
324
- "aria-controls": props["aria-controls"],
325
- "aria-haspopup": hasPopup,
326
- "aria-expanded": props["aria-expanded"]
327
- };
328
- if (state.selectionManager.selectionMode !== "none" && !isTrigger) ariaProps["aria-checked"] = isSelected;
329
- if (isVirtualized) {
330
- ariaProps["aria-posinset"] = item === null || item === void 0 ? void 0 : item.index;
331
- ariaProps["aria-setsize"] = (0, $fHYTQ$reactstatelycollections.getItemCount)(state.collection);
332
- }
333
- let onPressStart = (e)=>{
334
- if (e.pointerType === "keyboard") performAction(e);
335
- pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
336
- };
337
- let onPressUp = (e)=>{
338
- if (e.pointerType !== "keyboard") {
339
- performAction(e);
340
- // Pressing a menu item should close by default in single selection mode but not multiple
341
- // selection mode, except if overridden by the closeOnSelect prop.
342
- if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : state.selectionManager.selectionMode !== "multiple" || state.selectionManager.isLink(key))) onClose();
343
- }
344
- pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
345
- };
346
- let { itemProps: itemProps, isFocused: isFocused } = (0, $fHYTQ$reactariaselection.useSelectableItem)({
347
- selectionManager: state.selectionManager,
348
- key: key,
349
- ref: ref,
350
- shouldSelectOnPressUp: true,
351
- allowsDifferentPressOrigin: true,
352
- // Disable all handling of links in useSelectable item
353
- // because we handle it ourselves. The behavior of menus
354
- // is slightly different from other collections because
355
- // actions are performed on key down rather than key up.
356
- linkBehavior: "none"
357
- });
358
- let { pressProps: pressProps, isPressed: isPressed } = (0, $fHYTQ$reactariainteractions.usePress)({
359
- onPressStart: onPressStart,
360
- onPress: onPress,
361
- onPressUp: onPressUp,
362
- onPressChange: onPressChange,
363
- onPressEnd: onPressEnd,
364
- isDisabled: isDisabled
365
- });
366
- let { hoverProps: hoverProps } = (0, $fHYTQ$reactariainteractions.useHover)({
367
- isDisabled: isDisabled,
368
- onHoverStart (e) {
369
- if (!(0, $fHYTQ$reactariainteractions.isFocusVisible)()) {
370
- state.selectionManager.setFocused(true);
371
- state.selectionManager.setFocusedKey(key);
372
- }
373
- hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
374
- },
375
- onHoverChange: onHoverChange,
376
- onHoverEnd: onHoverEnd
377
- });
378
- let { keyboardProps: keyboardProps } = (0, $fHYTQ$reactariainteractions.useKeyboard)({
379
- onKeyDown: (e)=>{
380
- // Ignore repeating events, which may have started on the menu trigger before moving
381
- // focus to the menu item. We want to wait for a second complete key press sequence.
382
- if (e.repeat) {
383
- e.continuePropagation();
384
- return;
385
- }
386
- switch(e.key){
387
- case " ":
388
- if (!isDisabled && state.selectionManager.selectionMode === "none" && !isTrigger && closeOnSelect !== false && onClose) onClose();
389
- break;
390
- case "Enter":
391
- // The Enter key should always close on select, except if overridden.
392
- if (!isDisabled && closeOnSelect !== false && !isTrigger && onClose) onClose();
393
- break;
394
- default:
395
- if (!isTrigger) e.continuePropagation();
396
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
397
- break;
398
- }
399
- },
400
- onKeyUp: onKeyUp
401
- });
402
- let { focusProps: focusProps } = (0, $fHYTQ$reactariainteractions.useFocus)({
403
- onBlur: onBlur,
404
- onFocus: onFocus,
405
- onFocusChange: onFocusChange
406
- });
407
- let domProps = (0, $fHYTQ$reactariautils.filterDOMProps)(item.props);
408
- delete domProps.id;
409
- let linkProps = (0, $fHYTQ$reactariautils.useLinkProps)(item.props);
410
- return {
411
- menuItemProps: {
412
- ...ariaProps,
413
- ...(0, $fHYTQ$reactariautils.mergeProps)(domProps, linkProps, isTrigger ? {
414
- onFocus: itemProps.onFocus
415
- } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
416
- tabIndex: itemProps.tabIndex != null ? -1 : undefined
417
- },
418
- labelProps: {
419
- id: labelId
420
- },
421
- descriptionProps: {
422
- id: descriptionId
423
- },
424
- keyboardShortcutProps: {
425
- id: keyboardId
426
- },
427
- isFocused: isFocused,
428
- isSelected: isSelected,
429
- isPressed: isPressed,
430
- isDisabled: isDisabled
431
- };
432
- }
433
-
434
-
12
+ $parcel$export(module.exports, "useMenuTrigger", () => $7211ab9328763fb9$exports.useMenuTrigger);
13
+ $parcel$export(module.exports, "useMenu", () => $a3815f0132802737$exports.useMenu);
14
+ $parcel$export(module.exports, "useMenuItem", () => $38191ed02615ec07$exports.useMenuItem);
15
+ $parcel$export(module.exports, "useMenuSection", () => $63008655e23408c5$exports.useMenuSection);
16
+ $parcel$export(module.exports, "UNSTABLE_useSubmenuTrigger", () => $5f4753043c9f6cdf$exports.UNSTABLE_useSubmenuTrigger);
435
17
  /*
436
18
  * Copyright 2020 Adobe. All rights reserved.
437
19
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -443,306 +25,8 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
443
25
  * OF ANY KIND, either express or implied. See the License for the specific language
444
26
  * governing permissions and limitations under the License.
445
27
  */
446
- function $63008655e23408c5$export$73f7a44322579622(props) {
447
- let { heading: heading, "aria-label": ariaLabel } = props;
448
- let headingId = (0, $fHYTQ$reactariautils.useId)();
449
- return {
450
- itemProps: {
451
- role: "presentation"
452
- },
453
- headingProps: heading ? {
454
- // Techincally, menus cannot contain headings according to ARIA.
455
- // We hide the heading from assistive technology, using role="presentation",
456
- // and only use it as a label for the nested group.
457
- id: headingId,
458
- role: "presentation"
459
- } : {},
460
- groupProps: {
461
- role: "group",
462
- "aria-label": ariaLabel,
463
- "aria-labelledby": heading ? headingId : undefined
464
- }
465
- };
466
- }
467
28
 
468
29
 
469
- /*
470
- * Copyright 2023 Adobe. All rights reserved.
471
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
472
- * you may not use this file except in compliance with the License. You may obtain a copy
473
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
474
- *
475
- * Unless required by applicable law or agreed to in writing, software distributed under
476
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
477
- * OF ANY KIND, either express or implied. See the License for the specific language
478
- * governing permissions and limitations under the License.
479
- */
480
-
481
-
482
-
483
-
484
-
485
- const $62347d8c4183e713$var$ALLOWED_INVALID_MOVEMENTS = 2;
486
- const $62347d8c4183e713$var$THROTTLE_TIME = 50;
487
- const $62347d8c4183e713$var$TIMEOUT_TIME = 1000;
488
- const $62347d8c4183e713$var$ANGLE_PADDING = Math.PI / 12; // 15°
489
- function $62347d8c4183e713$export$85ec83e04c95f50a(options) {
490
- let { menuRef: menuRef, submenuRef: submenuRef, isOpen: isOpen, isDisabled: isDisabled } = options;
491
- let prevPointerPos = (0, $fHYTQ$react.useRef)();
492
- let submenuRect = (0, $fHYTQ$react.useRef)();
493
- let lastProcessedTime = (0, $fHYTQ$react.useRef)(0);
494
- let timeout = (0, $fHYTQ$react.useRef)();
495
- let autoCloseTimeout = (0, $fHYTQ$react.useRef)();
496
- let submenuSide = (0, $fHYTQ$react.useRef)();
497
- let movementsTowardsSubmenuCount = (0, $fHYTQ$react.useRef)(2);
498
- let [preventPointerEvents, setPreventPointerEvents] = (0, $fHYTQ$react.useState)(false);
499
- let updateSubmenuRect = ()=>{
500
- if (submenuRef.current) {
501
- submenuRect.current = submenuRef.current.getBoundingClientRect();
502
- submenuSide.current = undefined;
503
- }
504
- };
505
- (0, $fHYTQ$reactariautils.useResizeObserver)({
506
- ref: submenuRef,
507
- onResize: updateSubmenuRect
508
- });
509
- let reset = ()=>{
510
- setPreventPointerEvents(false);
511
- movementsTowardsSubmenuCount.current = $62347d8c4183e713$var$ALLOWED_INVALID_MOVEMENTS;
512
- prevPointerPos.current = undefined;
513
- };
514
- let modality = (0, $fHYTQ$reactariainteractions.useInteractionModality)();
515
- (0, $fHYTQ$react.useEffect)(()=>{
516
- if (preventPointerEvents && menuRef.current) menuRef.current.style.pointerEvents = "none";
517
- else menuRef.current.style.pointerEvents = "";
518
- }, [
519
- menuRef,
520
- preventPointerEvents
521
- ]);
522
- (0, $fHYTQ$react.useEffect)(()=>{
523
- let submenu = submenuRef.current;
524
- let menu = menuRef.current;
525
- if (isDisabled || !submenu || !isOpen || modality !== "pointer") {
526
- reset();
527
- return;
528
- }
529
- submenuRect.current = submenu.getBoundingClientRect();
530
- let onPointerMove = (e)=>{
531
- if (e.pointerType === "touch" || e.pointerType === "pen") return;
532
- let currentTime = Date.now();
533
- // Throttle
534
- if (currentTime - lastProcessedTime.current < $62347d8c4183e713$var$THROTTLE_TIME) return;
535
- clearTimeout(timeout.current);
536
- clearTimeout(autoCloseTimeout.current);
537
- let { clientX: mouseX, clientY: mouseY } = e;
538
- if (!prevPointerPos.current) {
539
- prevPointerPos.current = {
540
- x: mouseX,
541
- y: mouseY
542
- };
543
- return;
544
- }
545
- if (!submenuRect.current) return;
546
- if (!submenuSide.current) submenuSide.current = mouseX > submenuRect.current.right ? "left" : "right";
547
- // Pointer is outside of parent menu
548
- if (mouseX < menu.getBoundingClientRect().left || mouseX > menu.getBoundingClientRect().right || mouseY < menu.getBoundingClientRect().top || mouseY > menu.getBoundingClientRect().bottom) {
549
- reset();
550
- return;
551
- }
552
- /* Check if pointer is moving towards submenu.
553
- Uses the 2-argument arctangent (https://en.wikipedia.org/wiki/Atan2) to calculate:
554
- - angle between previous pointer and top of submenu
555
- - angle between previous pointer and bottom of submenu
556
- - angle between previous pointer and current pointer (delta)
557
- If the pointer delta angle value is between the top and bottom angle values, we know the pointer is moving towards the submenu.
558
- */ let prevMouseX = prevPointerPos.current.x;
559
- let prevMouseY = prevPointerPos.current.y;
560
- let toSubmenuX = submenuSide.current === "right" ? submenuRect.current.left - prevMouseX : prevMouseX - submenuRect.current.right;
561
- let angleTop = Math.atan2(prevMouseY - submenuRect.current.top, toSubmenuX) + $62347d8c4183e713$var$ANGLE_PADDING;
562
- let angleBottom = Math.atan2(prevMouseY - submenuRect.current.bottom, toSubmenuX) - $62347d8c4183e713$var$ANGLE_PADDING;
563
- let anglePointer = Math.atan2(prevMouseY - mouseY, submenuSide.current === "left" ? -(mouseX - prevMouseX) : mouseX - prevMouseX);
564
- let isMovingTowardsSubmenu = anglePointer < angleTop && anglePointer > angleBottom;
565
- movementsTowardsSubmenuCount.current = isMovingTowardsSubmenu ? Math.min(movementsTowardsSubmenuCount.current + 1, $62347d8c4183e713$var$ALLOWED_INVALID_MOVEMENTS) : Math.max(movementsTowardsSubmenuCount.current - 1, 0);
566
- if (movementsTowardsSubmenuCount.current >= $62347d8c4183e713$var$ALLOWED_INVALID_MOVEMENTS) setPreventPointerEvents(true);
567
- else setPreventPointerEvents(false);
568
- lastProcessedTime.current = currentTime;
569
- prevPointerPos.current = {
570
- x: mouseX,
571
- y: mouseY
572
- };
573
- // If the pointer is moving towards the submenu, start a timeout to close if no other movements are made after 500ms.
574
- if (isMovingTowardsSubmenu) timeout.current = setTimeout(()=>{
575
- reset();
576
- autoCloseTimeout.current = setTimeout(()=>{
577
- // Fire a pointerover event to trigger the menu to close.
578
- // Wait until pointer-events:none is no longer applied
579
- let target = document.elementFromPoint(mouseX, mouseY);
580
- if (target && menu.contains(target)) target.dispatchEvent(new PointerEvent("pointerover", {
581
- bubbles: true,
582
- cancelable: true
583
- }));
584
- }, 100);
585
- }, $62347d8c4183e713$var$TIMEOUT_TIME);
586
- };
587
- window.addEventListener("pointermove", onPointerMove);
588
- return ()=>{
589
- window.removeEventListener("pointermove", onPointerMove);
590
- clearTimeout(timeout.current);
591
- clearTimeout(autoCloseTimeout.current);
592
- movementsTowardsSubmenuCount.current = $62347d8c4183e713$var$ALLOWED_INVALID_MOVEMENTS;
593
- };
594
- }, [
595
- isDisabled,
596
- isOpen,
597
- menuRef,
598
- modality,
599
- setPreventPointerEvents,
600
- submenuRef
601
- ]);
602
- }
603
-
604
-
605
- function $5f4753043c9f6cdf$export$3819f8ee9f4ce664(props, state, ref) {
606
- let { parentMenuRef: parentMenuRef, submenuRef: submenuRef, type: type = "menu", isDisabled: isDisabled, node: node, delay: delay = 200 } = props;
607
- let submenuTriggerId = (0, $fHYTQ$reactariautils.useId)();
608
- let overlayId = (0, $fHYTQ$reactariautils.useId)();
609
- let { direction: direction } = (0, $fHYTQ$reactariai18n.useLocale)();
610
- let openTimeout = (0, $fHYTQ$react.useRef)();
611
- let cancelOpenTimeout = (0, $fHYTQ$react.useCallback)(()=>{
612
- if (openTimeout.current) {
613
- clearTimeout(openTimeout.current);
614
- openTimeout.current = undefined;
615
- }
616
- }, [
617
- openTimeout
618
- ]);
619
- let onSubmenuOpen = (0, $fHYTQ$reactariautils.useEffectEvent)((focusStrategy)=>{
620
- cancelOpenTimeout();
621
- state.open(focusStrategy);
622
- });
623
- let onSubmenuClose = (0, $fHYTQ$reactariautils.useEffectEvent)(()=>{
624
- cancelOpenTimeout();
625
- state.close();
626
- });
627
- (0, $fHYTQ$reactariautils.useLayoutEffect)(()=>{
628
- return ()=>{
629
- cancelOpenTimeout();
630
- };
631
- }, [
632
- cancelOpenTimeout
633
- ]);
634
- let submenuKeyDown = (e)=>{
635
- switch(e.key){
636
- case "ArrowLeft":
637
- if (direction === "ltr" && e.currentTarget.contains(e.target)) {
638
- e.stopPropagation();
639
- onSubmenuClose();
640
- ref.current.focus();
641
- }
642
- break;
643
- case "ArrowRight":
644
- if (direction === "rtl" && e.currentTarget.contains(e.target)) {
645
- e.stopPropagation();
646
- onSubmenuClose();
647
- ref.current.focus();
648
- }
649
- break;
650
- case "Escape":
651
- e.stopPropagation();
652
- state.closeAll();
653
- break;
654
- }
655
- };
656
- let submenuProps = {
657
- id: overlayId,
658
- "aria-label": node.textValue,
659
- submenuLevel: state.submenuLevel,
660
- ...type === "menu" && {
661
- onClose: state.closeAll,
662
- autoFocus: state.focusStrategy,
663
- onKeyDown: submenuKeyDown
664
- }
665
- };
666
- let submenuTriggerKeyDown = (e)=>{
667
- switch(e.key){
668
- case "ArrowRight":
669
- if (!isDisabled) {
670
- if (direction === "ltr") {
671
- if (!state.isOpen) onSubmenuOpen("first");
672
- if (type === "menu" && !!(submenuRef === null || submenuRef === void 0 ? void 0 : submenuRef.current) && document.activeElement === (ref === null || ref === void 0 ? void 0 : ref.current)) submenuRef.current.focus();
673
- } else if (state.isOpen) onSubmenuClose();
674
- else e.continuePropagation();
675
- }
676
- break;
677
- case "ArrowLeft":
678
- if (!isDisabled) {
679
- if (direction === "rtl") {
680
- if (!state.isOpen) onSubmenuOpen("first");
681
- if (type === "menu" && !!(submenuRef === null || submenuRef === void 0 ? void 0 : submenuRef.current) && document.activeElement === (ref === null || ref === void 0 ? void 0 : ref.current)) submenuRef.current.focus();
682
- } else if (state.isOpen) onSubmenuClose();
683
- else e.continuePropagation();
684
- }
685
- break;
686
- case "Escape":
687
- state.closeAll();
688
- break;
689
- default:
690
- e.continuePropagation();
691
- break;
692
- }
693
- };
694
- let onPressStart = (e)=>{
695
- if (!isDisabled && (e.pointerType === "virtual" || e.pointerType === "keyboard")) // If opened with a screen reader or keyboard, auto focus the first submenu item.
696
- onSubmenuOpen("first");
697
- };
698
- let onPress = (e)=>{
699
- if (!isDisabled && (e.pointerType === "touch" || e.pointerType === "mouse")) // For touch or on a desktop device with a small screen open on press up to possible problems with
700
- // press up happening on the newly opened tray items
701
- onSubmenuOpen();
702
- };
703
- let onHoverChange = (isHovered)=>{
704
- if (!isDisabled) {
705
- if (isHovered && !state.isOpen) {
706
- if (!openTimeout.current) openTimeout.current = setTimeout(()=>{
707
- onSubmenuOpen();
708
- }, delay);
709
- } else if (!isHovered) cancelOpenTimeout();
710
- }
711
- };
712
- let onBlur = (e)=>{
713
- if (state.isOpen && parentMenuRef.current.contains(e.relatedTarget)) onSubmenuClose();
714
- };
715
- let shouldCloseOnInteractOutside = (target)=>{
716
- if (target !== ref.current) return true;
717
- return false;
718
- };
719
- (0, $62347d8c4183e713$export$85ec83e04c95f50a)({
720
- menuRef: parentMenuRef,
721
- submenuRef: submenuRef,
722
- isOpen: state.isOpen,
723
- isDisabled: isDisabled
724
- });
725
- return {
726
- submenuTriggerProps: {
727
- id: submenuTriggerId,
728
- "aria-controls": state.isOpen ? overlayId : undefined,
729
- "aria-haspopup": !isDisabled ? type : undefined,
730
- "aria-expanded": state.isOpen ? "true" : "false",
731
- onPressStart: onPressStart,
732
- onPress: onPress,
733
- onHoverChange: onHoverChange,
734
- onKeyDown: submenuTriggerKeyDown,
735
- onBlur: onBlur,
736
- isOpen: state.isOpen
737
- },
738
- submenuProps: submenuProps,
739
- popoverProps: {
740
- isNonModal: true,
741
- disableFocusManagement: true,
742
- shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
743
- }
744
- };
745
- }
746
30
 
747
31
 
748
32