@react-stately/menu 3.8.3-nightly.5042 → 3.9.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/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import { MenuTriggerProps } from "@react-types/menu";
3
3
  import { OverlayTriggerState } from "@react-stately/overlays";
4
4
  export interface MenuTriggerState extends OverlayTriggerState {
5
5
  /** Controls which item will be auto focused when the menu opens. */
6
- readonly focusStrategy: FocusStrategy;
6
+ readonly focusStrategy: FocusStrategy | null;
7
7
  /** Opens the menu. */
8
8
  open(focusStrategy?: FocusStrategy | null): void;
9
9
  /** Toggles the menu. */
@@ -1 +1 @@
1
- {"mappings":";;;AAiBA,iCAAkC,SAAQ,mBAAmB;IAC3D,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEtC,sBAAsB;IACtB,IAAI,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjD,wBAAwB;IACxB,MAAM,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAAA;CACnD;AAED,qCAAsC,SAAQ,gBAAgB;IAC5D,iFAAiF;IACjF,WAAW,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtD,kFAAkF;IAClF,YAAY,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvD;;OAEG;IACH,iBAAiB,EAAE,GAAG,EAAE,CAAC;IAEzB,yDAAyD;IACzD,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED;;;;GAIG;AACH,oCAAoC,KAAK,EAAE,gBAAgB,GAAG,oBAAoB,CAiDjF;ACjFD;IACE,+BAA+B;IAC/B,UAAU,EAAE,GAAG,CAAA;CAChB;AAED,oCAAqC,SAAQ,mBAAmB;IAC9D,6CAA6C;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,yBAAyB;IACzB,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,0BAA0B;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,MAAM,EAAE,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,eAAe;IACf,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;GAGG;AACH,uCAAuC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,CAsCnH;ACpED,YAAY,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-stately/menu/src/packages/@react-stately/menu/src/useMenuTriggerState.ts","packages/@react-stately/menu/src/packages/@react-stately/menu/src/useSubmenuTriggerState.ts","packages/@react-stately/menu/src/packages/@react-stately/menu/src/index.ts","packages/@react-stately/menu/src/index.ts"],"sourcesContent":[null,null,null,"/*\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\nexport {useMenuTriggerState} from './useMenuTriggerState';\nexport {useSubmenuTriggerState} from './useSubmenuTriggerState';\n\nexport type {MenuTriggerProps} from '@react-types/menu';\nexport type {MenuTriggerState, RootMenuTriggerState} from './useMenuTriggerState';\nexport type {SubmenuTriggerProps, SubmenuTriggerState} from './useSubmenuTriggerState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAiBA,iCAAkC,SAAQ,mBAAmB;IAC3D,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C,sBAAsB;IACtB,IAAI,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjD,wBAAwB;IACxB,MAAM,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAAA;CACnD;AAED,qCAAsC,SAAQ,gBAAgB;IAC5D,iFAAiF;IACjF,WAAW,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtD,kFAAkF;IAClF,YAAY,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvD;;OAEG;IACH,iBAAiB,EAAE,GAAG,EAAE,CAAC;IAEzB,yDAAyD;IACzD,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED;;;;GAIG;AACH,oCAAoC,KAAK,EAAE,gBAAgB,GAAG,oBAAoB,CAiDjF;ACjFD;IACE,+BAA+B;IAC/B,UAAU,EAAE,GAAG,CAAA;CAChB;AAED,oCAAqC,SAAQ,mBAAmB;IAC9D,6CAA6C;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,yBAAyB;IACzB,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,0BAA0B;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,MAAM,EAAE,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,eAAe;IACf,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;GAGG;AACH,uCAAuC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,CAsCnH;ACpED,YAAY,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-stately/menu/src/packages/@react-stately/menu/src/useMenuTriggerState.ts","packages/@react-stately/menu/src/packages/@react-stately/menu/src/useSubmenuTriggerState.ts","packages/@react-stately/menu/src/packages/@react-stately/menu/src/index.ts","packages/@react-stately/menu/src/index.ts"],"sourcesContent":[null,null,null,"/*\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\nexport {useMenuTriggerState} from './useMenuTriggerState';\nexport {useSubmenuTriggerState} from './useSubmenuTriggerState';\n\nexport type {MenuTriggerProps} from '@react-types/menu';\nexport type {MenuTriggerState, RootMenuTriggerState} from './useMenuTriggerState';\nexport type {SubmenuTriggerProps, SubmenuTriggerState} from './useSubmenuTriggerState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAuCM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,sBAAsB,CAAA,GAAA,kDAAqB,EAAE;IACjD,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAChE,IAAI,CAAC,mBAAmB,qBAAqB,GAAG,CAAA,GAAA,qBAAO,EAAS,EAAE;IAElE,IAAI,WAAW;QACb,qBAAqB,EAAE;QACvB,oBAAoB,KAAK;IAC3B;IAEA,IAAI,cAAc,CAAC,YAAiB;QAClC,qBAAqB,CAAA;YACnB,IAAI,QAAQ,SAAS,MAAM,EACzB,OAAO;YAGT,OAAO;mBAAI,SAAS,KAAK,CAAC,GAAG;gBAAQ;aAAW;QAClD;IACF;IAEA,IAAI,eAAe,CAAC,YAAiB;QACnC,qBAAqB,CAAA;YACnB,IAAI,MAAM,QAAQ,CAAC,MAAM;YACzB,IAAI,QAAQ,YACV,OAAO,SAAS,KAAK,CAAC,GAAG;iBAEzB,OAAO;QAEX;IACF;IAEA,OAAO;uBACL;QACA,GAAG,mBAAmB;QACtB,MAAK,gBAA+B,IAAI;YACtC,iBAAiB;YACjB,oBAAoB,IAAI;QAC1B;QACA,QAAO,gBAA+B,IAAI;YACxC,iBAAiB;YACjB,oBAAoB,MAAM;QAC5B;QACA;YACE;QACF;2BACA;qBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/menu/src/useMenuTriggerState.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 {FocusStrategy, Key} from '@react-types/shared';\nimport {MenuTriggerProps} from '@react-types/menu';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {useState} from 'react';\n\nexport interface MenuTriggerState extends OverlayTriggerState {\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\nexport interface RootMenuTriggerState extends MenuTriggerState {\n /** Opens a specific submenu tied to a specific menu item at a specific level. */\n openSubmenu: (triggerKey: Key, level: number) => void,\n\n /** Closes a specific submenu tied to a specific menu item at a specific level. */\n closeSubmenu: (triggerKey: Key, level: number) => void,\n\n /** An array of open submenu trigger keys within the menu tree.\n * The index of key within array matches the submenu level in the tree.\n */\n expandedKeysStack: Key[],\n\n /** Closes the menu and all submenus in the menu tree. */\n close: () => void\n}\n\n/**\n * Manages state for a menu trigger. Tracks whether the menu is currently open,\n * and controls which item will receive focus when it opens. Also tracks the open submenus within\n * the menu tree via their trigger keys.\n */\nexport function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState {\n let overlayTriggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let [expandedKeysStack, setExpandedKeysStack] = useState<Key[]>([]);\n\n let closeAll = () => {\n setExpandedKeysStack([]);\n overlayTriggerState.close();\n };\n\n let openSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n if (level > oldStack.length) {\n return oldStack;\n }\n\n return [...oldStack.slice(0, level), triggerKey];\n });\n };\n\n let closeSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n let key = oldStack[level];\n if (key === triggerKey) {\n return oldStack.slice(0, level);\n } else {\n return oldStack;\n }\n });\n };\n\n return {\n focusStrategy,\n ...overlayTriggerState,\n open(focusStrategy: FocusStrategy = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.open();\n },\n toggle(focusStrategy: FocusStrategy = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.toggle();\n },\n close() {\n closeAll();\n },\n expandedKeysStack,\n openSubmenu,\n closeSubmenu\n };\n}\n"],"names":[],"version":3,"file":"useMenuTriggerState.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAuCM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,sBAAsB,CAAA,GAAA,kDAAqB,EAAE;IACjD,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAwB;IACvE,IAAI,CAAC,mBAAmB,qBAAqB,GAAG,CAAA,GAAA,qBAAO,EAAS,EAAE;IAElE,IAAI,WAAW;QACb,qBAAqB,EAAE;QACvB,oBAAoB,KAAK;IAC3B;IAEA,IAAI,cAAc,CAAC,YAAiB;QAClC,qBAAqB,CAAA;YACnB,IAAI,QAAQ,SAAS,MAAM,EACzB,OAAO;YAGT,OAAO;mBAAI,SAAS,KAAK,CAAC,GAAG;gBAAQ;aAAW;QAClD;IACF;IAEA,IAAI,eAAe,CAAC,YAAiB;QACnC,qBAAqB,CAAA;YACnB,IAAI,MAAM,QAAQ,CAAC,MAAM;YACzB,IAAI,QAAQ,YACV,OAAO,SAAS,KAAK,CAAC,GAAG;iBAEzB,OAAO;QAEX;IACF;IAEA,OAAO;uBACL;QACA,GAAG,mBAAmB;QACtB,MAAK,gBAAsC,IAAI;YAC7C,iBAAiB;YACjB,oBAAoB,IAAI;QAC1B;QACA,QAAO,gBAAsC,IAAI;YAC/C,iBAAiB;YACjB,oBAAoB,MAAM;QAC5B;QACA;YACE;QACF;2BACA;qBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/menu/src/useMenuTriggerState.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 {FocusStrategy, Key} from '@react-types/shared';\nimport {MenuTriggerProps} from '@react-types/menu';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {useState} from 'react';\n\nexport interface MenuTriggerState extends OverlayTriggerState {\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy | null,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\nexport interface RootMenuTriggerState extends MenuTriggerState {\n /** Opens a specific submenu tied to a specific menu item at a specific level. */\n openSubmenu: (triggerKey: Key, level: number) => void,\n\n /** Closes a specific submenu tied to a specific menu item at a specific level. */\n closeSubmenu: (triggerKey: Key, level: number) => void,\n\n /** An array of open submenu trigger keys within the menu tree.\n * The index of key within array matches the submenu level in the tree.\n */\n expandedKeysStack: Key[],\n\n /** Closes the menu and all submenus in the menu tree. */\n close: () => void\n}\n\n/**\n * Manages state for a menu trigger. Tracks whether the menu is currently open,\n * and controls which item will receive focus when it opens. Also tracks the open submenus within\n * the menu tree via their trigger keys.\n */\nexport function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState {\n let overlayTriggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);\n let [expandedKeysStack, setExpandedKeysStack] = useState<Key[]>([]);\n\n let closeAll = () => {\n setExpandedKeysStack([]);\n overlayTriggerState.close();\n };\n\n let openSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n if (level > oldStack.length) {\n return oldStack;\n }\n\n return [...oldStack.slice(0, level), triggerKey];\n });\n };\n\n let closeSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n let key = oldStack[level];\n if (key === triggerKey) {\n return oldStack.slice(0, level);\n } else {\n return oldStack;\n }\n });\n };\n\n return {\n focusStrategy,\n ...overlayTriggerState,\n open(focusStrategy: FocusStrategy | null = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.open();\n },\n toggle(focusStrategy: FocusStrategy | null = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.toggle();\n },\n close() {\n closeAll();\n },\n expandedKeysStack,\n openSubmenu,\n closeSubmenu\n };\n}\n"],"names":[],"version":3,"file":"useMenuTriggerState.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAuCM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,sBAAsB,CAAA,GAAA,6BAAqB,EAAE;IACjD,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAiB;IAChE,IAAI,CAAC,mBAAmB,qBAAqB,GAAG,CAAA,GAAA,eAAO,EAAS,EAAE;IAElE,IAAI,WAAW;QACb,qBAAqB,EAAE;QACvB,oBAAoB,KAAK;IAC3B;IAEA,IAAI,cAAc,CAAC,YAAiB;QAClC,qBAAqB,CAAA;YACnB,IAAI,QAAQ,SAAS,MAAM,EACzB,OAAO;YAGT,OAAO;mBAAI,SAAS,KAAK,CAAC,GAAG;gBAAQ;aAAW;QAClD;IACF;IAEA,IAAI,eAAe,CAAC,YAAiB;QACnC,qBAAqB,CAAA;YACnB,IAAI,MAAM,QAAQ,CAAC,MAAM;YACzB,IAAI,QAAQ,YACV,OAAO,SAAS,KAAK,CAAC,GAAG;iBAEzB,OAAO;QAEX;IACF;IAEA,OAAO;uBACL;QACA,GAAG,mBAAmB;QACtB,MAAK,gBAA+B,IAAI;YACtC,iBAAiB;YACjB,oBAAoB,IAAI;QAC1B;QACA,QAAO,gBAA+B,IAAI;YACxC,iBAAiB;YACjB,oBAAoB,MAAM;QAC5B;QACA;YACE;QACF;2BACA;qBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/menu/src/useMenuTriggerState.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 {FocusStrategy, Key} from '@react-types/shared';\nimport {MenuTriggerProps} from '@react-types/menu';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {useState} from 'react';\n\nexport interface MenuTriggerState extends OverlayTriggerState {\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\nexport interface RootMenuTriggerState extends MenuTriggerState {\n /** Opens a specific submenu tied to a specific menu item at a specific level. */\n openSubmenu: (triggerKey: Key, level: number) => void,\n\n /** Closes a specific submenu tied to a specific menu item at a specific level. */\n closeSubmenu: (triggerKey: Key, level: number) => void,\n\n /** An array of open submenu trigger keys within the menu tree.\n * The index of key within array matches the submenu level in the tree.\n */\n expandedKeysStack: Key[],\n\n /** Closes the menu and all submenus in the menu tree. */\n close: () => void\n}\n\n/**\n * Manages state for a menu trigger. Tracks whether the menu is currently open,\n * and controls which item will receive focus when it opens. Also tracks the open submenus within\n * the menu tree via their trigger keys.\n */\nexport function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState {\n let overlayTriggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let [expandedKeysStack, setExpandedKeysStack] = useState<Key[]>([]);\n\n let closeAll = () => {\n setExpandedKeysStack([]);\n overlayTriggerState.close();\n };\n\n let openSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n if (level > oldStack.length) {\n return oldStack;\n }\n\n return [...oldStack.slice(0, level), triggerKey];\n });\n };\n\n let closeSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n let key = oldStack[level];\n if (key === triggerKey) {\n return oldStack.slice(0, level);\n } else {\n return oldStack;\n }\n });\n };\n\n return {\n focusStrategy,\n ...overlayTriggerState,\n open(focusStrategy: FocusStrategy = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.open();\n },\n toggle(focusStrategy: FocusStrategy = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.toggle();\n },\n close() {\n closeAll();\n },\n expandedKeysStack,\n openSubmenu,\n closeSubmenu\n };\n}\n"],"names":[],"version":3,"file":"useMenuTriggerState.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAuCM,SAAS,0CAAoB,KAAuB;IACzD,IAAI,sBAAsB,CAAA,GAAA,6BAAqB,EAAE;IACjD,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAwB;IACvE,IAAI,CAAC,mBAAmB,qBAAqB,GAAG,CAAA,GAAA,eAAO,EAAS,EAAE;IAElE,IAAI,WAAW;QACb,qBAAqB,EAAE;QACvB,oBAAoB,KAAK;IAC3B;IAEA,IAAI,cAAc,CAAC,YAAiB;QAClC,qBAAqB,CAAA;YACnB,IAAI,QAAQ,SAAS,MAAM,EACzB,OAAO;YAGT,OAAO;mBAAI,SAAS,KAAK,CAAC,GAAG;gBAAQ;aAAW;QAClD;IACF;IAEA,IAAI,eAAe,CAAC,YAAiB;QACnC,qBAAqB,CAAA;YACnB,IAAI,MAAM,QAAQ,CAAC,MAAM;YACzB,IAAI,QAAQ,YACV,OAAO,SAAS,KAAK,CAAC,GAAG;iBAEzB,OAAO;QAEX;IACF;IAEA,OAAO;uBACL;QACA,GAAG,mBAAmB;QACtB,MAAK,gBAAsC,IAAI;YAC7C,iBAAiB;YACjB,oBAAoB,IAAI;QAC1B;QACA,QAAO,gBAAsC,IAAI;YAC/C,iBAAiB;YACjB,oBAAoB,MAAM;QAC5B;QACA;YACE;QACF;2BACA;qBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/menu/src/useMenuTriggerState.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 {FocusStrategy, Key} from '@react-types/shared';\nimport {MenuTriggerProps} from '@react-types/menu';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {useState} from 'react';\n\nexport interface MenuTriggerState extends OverlayTriggerState {\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy | null,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\nexport interface RootMenuTriggerState extends MenuTriggerState {\n /** Opens a specific submenu tied to a specific menu item at a specific level. */\n openSubmenu: (triggerKey: Key, level: number) => void,\n\n /** Closes a specific submenu tied to a specific menu item at a specific level. */\n closeSubmenu: (triggerKey: Key, level: number) => void,\n\n /** An array of open submenu trigger keys within the menu tree.\n * The index of key within array matches the submenu level in the tree.\n */\n expandedKeysStack: Key[],\n\n /** Closes the menu and all submenus in the menu tree. */\n close: () => void\n}\n\n/**\n * Manages state for a menu trigger. Tracks whether the menu is currently open,\n * and controls which item will receive focus when it opens. Also tracks the open submenus within\n * the menu tree via their trigger keys.\n */\nexport function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState {\n let overlayTriggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);\n let [expandedKeysStack, setExpandedKeysStack] = useState<Key[]>([]);\n\n let closeAll = () => {\n setExpandedKeysStack([]);\n overlayTriggerState.close();\n };\n\n let openSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n if (level > oldStack.length) {\n return oldStack;\n }\n\n return [...oldStack.slice(0, level), triggerKey];\n });\n };\n\n let closeSubmenu = (triggerKey: Key, level: number) => {\n setExpandedKeysStack(oldStack => {\n let key = oldStack[level];\n if (key === triggerKey) {\n return oldStack.slice(0, level);\n } else {\n return oldStack;\n }\n });\n };\n\n return {\n focusStrategy,\n ...overlayTriggerState,\n open(focusStrategy: FocusStrategy | null = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.open();\n },\n toggle(focusStrategy: FocusStrategy | null = null) {\n setFocusStrategy(focusStrategy);\n overlayTriggerState.toggle();\n },\n close() {\n closeAll();\n },\n expandedKeysStack,\n openSubmenu,\n closeSubmenu\n };\n}\n"],"names":[],"version":3,"file":"useMenuTriggerState.module.js.map"}
@@ -27,8 +27,8 @@ function $38ab7fb105c54ad2$export$cfc51cf86138bf98(props, state) {
27
27
  submenuLevel
28
28
  ]);
29
29
  let [focusStrategy, setFocusStrategy] = (0, $9cbje$react.useState)(null);
30
- let open = (0, $9cbje$react.useCallback)((focusStrategy = null)=>{
31
- setFocusStrategy(focusStrategy);
30
+ let open = (0, $9cbje$react.useCallback)((focusStrategy)=>{
31
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
32
32
  openSubmenu(triggerKey, submenuLevel);
33
33
  }, [
34
34
  openSubmenu,
@@ -43,8 +43,8 @@ function $38ab7fb105c54ad2$export$cfc51cf86138bf98(props, state) {
43
43
  submenuLevel,
44
44
  triggerKey
45
45
  ]);
46
- let toggle = (0, $9cbje$react.useCallback)((focusStrategy = null)=>{
47
- setFocusStrategy(focusStrategy);
46
+ let toggle = (0, $9cbje$react.useCallback)((focusStrategy)=>{
47
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
48
48
  if (isOpen) close();
49
49
  else open(focusStrategy);
50
50
  }, [
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAmCM,SAAS,0CAAuB,KAA0B,EAAE,KAA2B;IAC5F,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,qBAAC,iBAAiB,eAAE,WAAW,gBAAE,YAAY,EAAE,OAAO,QAAQ,EAAC,GAAG;IACtE,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE,8BAAA,wCAAA,kBAAmB,MAAM;IACvD,IAAI,SAAS,CAAA,GAAA,oBAAM,EAAE,IAAM,iBAAiB,CAAC,aAAa,KAAK,YAAY;QAAC;QAAmB;QAAY;KAAa;IACxH,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAEhE,IAAI,OAAO,CAAA,GAAA,wBAAU,EAAE,CAAC,gBAA+B,IAAI;QACzD,iBAAiB;QACjB,YAAY,YAAY;IAC1B,GAAG;QAAC;QAAa;QAAc;KAAW;IAE1C,IAAI,QAAQ,CAAA,GAAA,wBAAU,EAAE;QACtB,iBAAiB;QACjB,aAAa,YAAY;IAC3B,GAAG;QAAC;QAAc;QAAc;KAAW;IAE3C,IAAI,SAAS,CAAA,GAAA,wBAAU,EAAE,CAAC,gBAA+B,IAAI;QAC3D,iBAAiB;QACjB,IAAI,QACF;aAEA,KAAK;IAET,GAAG;QAAC;QAAO;QAAM;KAAO;IAExB,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;2BACpB;oBACA;kBACA;mBACA;sBACA;0BACA;YACA,mJAAmJ;YACnJ,2EAA2E;YAC3E,SAAS,KAAO;oBAChB;QACF,CAAA,GAAI;QAAC;QAAQ;QAAM;QAAO;QAAU;QAAe;QAAQ;KAAa;AAC1E","sources":["packages/@react-stately/menu/src/useSubmenuTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FocusStrategy, Key} from '@react-types/shared';\nimport type {OverlayTriggerState} from '@react-stately/overlays';\nimport {RootMenuTriggerState} from './useMenuTriggerState';\nimport {useCallback, useMemo, useState} from 'react';\n\nexport interface SubmenuTriggerProps {\n /** Key of the trigger item. */\n triggerKey: Key\n}\n\nexport interface SubmenuTriggerState extends OverlayTriggerState {\n /** Whether the submenu is currently open. */\n isOpen: boolean,\n /** Controls which item will be auto focused when the submenu opens. */\n focusStrategy: FocusStrategy | null,\n /** Opens the submenu. */\n open: (focusStrategy?: FocusStrategy | null) => void,\n /** Closes the submenu. */\n close: () => void,\n /** Closes all menus and submenus in the menu tree. */\n closeAll: () => void,\n /** The level of the submenu. */\n submenuLevel: number,\n /** Toggles the submenu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void,\n /** @private */\n setOpen: () => void\n}\n\n/**\n * Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of the submenu, and\n * controls which item will receive focus when it opens.\n */\nexport function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState {\n let {triggerKey} = props;\n let {expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll} = state;\n let [submenuLevel] = useState(expandedKeysStack?.length);\n let isOpen = useMemo(() => expandedKeysStack[submenuLevel] === triggerKey, [expandedKeysStack, triggerKey, submenuLevel]);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n\n let open = useCallback((focusStrategy: FocusStrategy = null) => {\n setFocusStrategy(focusStrategy);\n openSubmenu(triggerKey, submenuLevel);\n }, [openSubmenu, submenuLevel, triggerKey]);\n\n let close = useCallback(() => {\n setFocusStrategy(null);\n closeSubmenu(triggerKey, submenuLevel);\n }, [closeSubmenu, submenuLevel, triggerKey]);\n\n let toggle = useCallback((focusStrategy: FocusStrategy = null) => {\n setFocusStrategy(focusStrategy);\n if (isOpen) {\n close();\n } else {\n open(focusStrategy);\n }\n }, [close, open, isOpen]);\n\n return useMemo(() => ({\n focusStrategy,\n isOpen,\n open,\n close,\n closeAll,\n submenuLevel,\n // TODO: Placeholders that aren't used but give us parity with OverlayTriggerState so we can use this in Popover. Refactor if we update Popover via\n // https://github.com/adobe/react-spectrum/pull/4976#discussion_r1336472863\n setOpen: () => {},\n toggle\n }), [isOpen, open, close, closeAll, focusStrategy, toggle, submenuLevel]);\n}\n"],"names":[],"version":3,"file":"useSubmenuTriggerState.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAmCM,SAAS,0CAAuB,KAA0B,EAAE,KAA2B;IAC5F,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,qBAAC,iBAAiB,eAAE,WAAW,gBAAE,YAAY,EAAE,OAAO,QAAQ,EAAC,GAAG;IACtE,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE,8BAAA,wCAAA,kBAAmB,MAAM;IACvD,IAAI,SAAS,CAAA,GAAA,oBAAM,EAAE,IAAM,iBAAiB,CAAC,aAAa,KAAK,YAAY;QAAC;QAAmB;QAAY;KAAa;IACxH,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAwB;IAEvE,IAAI,OAAO,CAAA,GAAA,wBAAU,EAAE,CAAC;QACtB,iBAAiB,0BAAA,2BAAA,gBAAiB;QAClC,YAAY,YAAY;IAC1B,GAAG;QAAC;QAAa;QAAc;KAAW;IAE1C,IAAI,QAAQ,CAAA,GAAA,wBAAU,EAAE;QACtB,iBAAiB;QACjB,aAAa,YAAY;IAC3B,GAAG;QAAC;QAAc;QAAc;KAAW;IAE3C,IAAI,SAAS,CAAA,GAAA,wBAAU,EAAE,CAAC;QACxB,iBAAiB,0BAAA,2BAAA,gBAAiB;QAClC,IAAI,QACF;aAEA,KAAK;IAET,GAAG;QAAC;QAAO;QAAM;KAAO;IAExB,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;2BACpB;oBACA;kBACA;mBACA;sBACA;0BACA;YACA,mJAAmJ;YACnJ,2EAA2E;YAC3E,SAAS,KAAO;oBAChB;QACF,CAAA,GAAI;QAAC;QAAQ;QAAM;QAAO;QAAU;QAAe;QAAQ;KAAa;AAC1E","sources":["packages/@react-stately/menu/src/useSubmenuTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FocusStrategy, Key} from '@react-types/shared';\nimport type {OverlayTriggerState} from '@react-stately/overlays';\nimport {RootMenuTriggerState} from './useMenuTriggerState';\nimport {useCallback, useMemo, useState} from 'react';\n\nexport interface SubmenuTriggerProps {\n /** Key of the trigger item. */\n triggerKey: Key\n}\n\nexport interface SubmenuTriggerState extends OverlayTriggerState {\n /** Whether the submenu is currently open. */\n isOpen: boolean,\n /** Controls which item will be auto focused when the submenu opens. */\n focusStrategy: FocusStrategy | null,\n /** Opens the submenu. */\n open: (focusStrategy?: FocusStrategy | null) => void,\n /** Closes the submenu. */\n close: () => void,\n /** Closes all menus and submenus in the menu tree. */\n closeAll: () => void,\n /** The level of the submenu. */\n submenuLevel: number,\n /** Toggles the submenu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void,\n /** @private */\n setOpen: () => void\n}\n\n/**\n * Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of the submenu, and\n * controls which item will receive focus when it opens.\n */\nexport function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState {\n let {triggerKey} = props;\n let {expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll} = state;\n let [submenuLevel] = useState(expandedKeysStack?.length);\n let isOpen = useMemo(() => expandedKeysStack[submenuLevel] === triggerKey, [expandedKeysStack, triggerKey, submenuLevel]);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);\n\n let open = useCallback((focusStrategy?: FocusStrategy | null) => {\n setFocusStrategy(focusStrategy ?? null);\n openSubmenu(triggerKey, submenuLevel);\n }, [openSubmenu, submenuLevel, triggerKey]);\n\n let close = useCallback(() => {\n setFocusStrategy(null);\n closeSubmenu(triggerKey, submenuLevel);\n }, [closeSubmenu, submenuLevel, triggerKey]);\n\n let toggle = useCallback((focusStrategy?: FocusStrategy | null) => {\n setFocusStrategy(focusStrategy ?? null);\n if (isOpen) {\n close();\n } else {\n open(focusStrategy);\n }\n }, [close, open, isOpen]);\n\n return useMemo(() => ({\n focusStrategy,\n isOpen,\n open,\n close,\n closeAll,\n submenuLevel,\n // TODO: Placeholders that aren't used but give us parity with OverlayTriggerState so we can use this in Popover. Refactor if we update Popover via\n // https://github.com/adobe/react-spectrum/pull/4976#discussion_r1336472863\n setOpen: () => {},\n toggle\n }), [isOpen, open, close, closeAll, focusStrategy, toggle, submenuLevel]);\n}\n"],"names":[],"version":3,"file":"useSubmenuTriggerState.main.js.map"}
@@ -21,8 +21,8 @@ function $e5614764aa47eb35$export$cfc51cf86138bf98(props, state) {
21
21
  submenuLevel
22
22
  ]);
23
23
  let [focusStrategy, setFocusStrategy] = (0, $7exkJ$useState)(null);
24
- let open = (0, $7exkJ$useCallback)((focusStrategy = null)=>{
25
- setFocusStrategy(focusStrategy);
24
+ let open = (0, $7exkJ$useCallback)((focusStrategy)=>{
25
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
26
26
  openSubmenu(triggerKey, submenuLevel);
27
27
  }, [
28
28
  openSubmenu,
@@ -37,8 +37,8 @@ function $e5614764aa47eb35$export$cfc51cf86138bf98(props, state) {
37
37
  submenuLevel,
38
38
  triggerKey
39
39
  ]);
40
- let toggle = (0, $7exkJ$useCallback)((focusStrategy = null)=>{
41
- setFocusStrategy(focusStrategy);
40
+ let toggle = (0, $7exkJ$useCallback)((focusStrategy)=>{
41
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
42
42
  if (isOpen) close();
43
43
  else open(focusStrategy);
44
44
  }, [
@@ -21,8 +21,8 @@ function $e5614764aa47eb35$export$cfc51cf86138bf98(props, state) {
21
21
  submenuLevel
22
22
  ]);
23
23
  let [focusStrategy, setFocusStrategy] = (0, $7exkJ$useState)(null);
24
- let open = (0, $7exkJ$useCallback)((focusStrategy = null)=>{
25
- setFocusStrategy(focusStrategy);
24
+ let open = (0, $7exkJ$useCallback)((focusStrategy)=>{
25
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
26
26
  openSubmenu(triggerKey, submenuLevel);
27
27
  }, [
28
28
  openSubmenu,
@@ -37,8 +37,8 @@ function $e5614764aa47eb35$export$cfc51cf86138bf98(props, state) {
37
37
  submenuLevel,
38
38
  triggerKey
39
39
  ]);
40
- let toggle = (0, $7exkJ$useCallback)((focusStrategy = null)=>{
41
- setFocusStrategy(focusStrategy);
40
+ let toggle = (0, $7exkJ$useCallback)((focusStrategy)=>{
41
+ setFocusStrategy(focusStrategy !== null && focusStrategy !== void 0 ? focusStrategy : null);
42
42
  if (isOpen) close();
43
43
  else open(focusStrategy);
44
44
  }, [
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAmCM,SAAS,0CAAuB,KAA0B,EAAE,KAA2B;IAC5F,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,qBAAC,iBAAiB,eAAE,WAAW,gBAAE,YAAY,EAAE,OAAO,QAAQ,EAAC,GAAG;IACtE,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE,8BAAA,wCAAA,kBAAmB,MAAM;IACvD,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IAAM,iBAAiB,CAAC,aAAa,KAAK,YAAY;QAAC;QAAmB;QAAY;KAAa;IACxH,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAiB;IAEhE,IAAI,OAAO,CAAA,GAAA,kBAAU,EAAE,CAAC,gBAA+B,IAAI;QACzD,iBAAiB;QACjB,YAAY,YAAY;IAC1B,GAAG;QAAC;QAAa;QAAc;KAAW;IAE1C,IAAI,QAAQ,CAAA,GAAA,kBAAU,EAAE;QACtB,iBAAiB;QACjB,aAAa,YAAY;IAC3B,GAAG;QAAC;QAAc;QAAc;KAAW;IAE3C,IAAI,SAAS,CAAA,GAAA,kBAAU,EAAE,CAAC,gBAA+B,IAAI;QAC3D,iBAAiB;QACjB,IAAI,QACF;aAEA,KAAK;IAET,GAAG;QAAC;QAAO;QAAM;KAAO;IAExB,OAAO,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;2BACpB;oBACA;kBACA;mBACA;sBACA;0BACA;YACA,mJAAmJ;YACnJ,2EAA2E;YAC3E,SAAS,KAAO;oBAChB;QACF,CAAA,GAAI;QAAC;QAAQ;QAAM;QAAO;QAAU;QAAe;QAAQ;KAAa;AAC1E","sources":["packages/@react-stately/menu/src/useSubmenuTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FocusStrategy, Key} from '@react-types/shared';\nimport type {OverlayTriggerState} from '@react-stately/overlays';\nimport {RootMenuTriggerState} from './useMenuTriggerState';\nimport {useCallback, useMemo, useState} from 'react';\n\nexport interface SubmenuTriggerProps {\n /** Key of the trigger item. */\n triggerKey: Key\n}\n\nexport interface SubmenuTriggerState extends OverlayTriggerState {\n /** Whether the submenu is currently open. */\n isOpen: boolean,\n /** Controls which item will be auto focused when the submenu opens. */\n focusStrategy: FocusStrategy | null,\n /** Opens the submenu. */\n open: (focusStrategy?: FocusStrategy | null) => void,\n /** Closes the submenu. */\n close: () => void,\n /** Closes all menus and submenus in the menu tree. */\n closeAll: () => void,\n /** The level of the submenu. */\n submenuLevel: number,\n /** Toggles the submenu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void,\n /** @private */\n setOpen: () => void\n}\n\n/**\n * Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of the submenu, and\n * controls which item will receive focus when it opens.\n */\nexport function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState {\n let {triggerKey} = props;\n let {expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll} = state;\n let [submenuLevel] = useState(expandedKeysStack?.length);\n let isOpen = useMemo(() => expandedKeysStack[submenuLevel] === triggerKey, [expandedKeysStack, triggerKey, submenuLevel]);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n\n let open = useCallback((focusStrategy: FocusStrategy = null) => {\n setFocusStrategy(focusStrategy);\n openSubmenu(triggerKey, submenuLevel);\n }, [openSubmenu, submenuLevel, triggerKey]);\n\n let close = useCallback(() => {\n setFocusStrategy(null);\n closeSubmenu(triggerKey, submenuLevel);\n }, [closeSubmenu, submenuLevel, triggerKey]);\n\n let toggle = useCallback((focusStrategy: FocusStrategy = null) => {\n setFocusStrategy(focusStrategy);\n if (isOpen) {\n close();\n } else {\n open(focusStrategy);\n }\n }, [close, open, isOpen]);\n\n return useMemo(() => ({\n focusStrategy,\n isOpen,\n open,\n close,\n closeAll,\n submenuLevel,\n // TODO: Placeholders that aren't used but give us parity with OverlayTriggerState so we can use this in Popover. Refactor if we update Popover via\n // https://github.com/adobe/react-spectrum/pull/4976#discussion_r1336472863\n setOpen: () => {},\n toggle\n }), [isOpen, open, close, closeAll, focusStrategy, toggle, submenuLevel]);\n}\n"],"names":[],"version":3,"file":"useSubmenuTriggerState.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAmCM,SAAS,0CAAuB,KAA0B,EAAE,KAA2B;IAC5F,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,qBAAC,iBAAiB,eAAE,WAAW,gBAAE,YAAY,EAAE,OAAO,QAAQ,EAAC,GAAG;IACtE,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE,8BAAA,wCAAA,kBAAmB,MAAM;IACvD,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IAAM,iBAAiB,CAAC,aAAa,KAAK,YAAY;QAAC;QAAmB;QAAY;KAAa;IACxH,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAwB;IAEvE,IAAI,OAAO,CAAA,GAAA,kBAAU,EAAE,CAAC;QACtB,iBAAiB,0BAAA,2BAAA,gBAAiB;QAClC,YAAY,YAAY;IAC1B,GAAG;QAAC;QAAa;QAAc;KAAW;IAE1C,IAAI,QAAQ,CAAA,GAAA,kBAAU,EAAE;QACtB,iBAAiB;QACjB,aAAa,YAAY;IAC3B,GAAG;QAAC;QAAc;QAAc;KAAW;IAE3C,IAAI,SAAS,CAAA,GAAA,kBAAU,EAAE,CAAC;QACxB,iBAAiB,0BAAA,2BAAA,gBAAiB;QAClC,IAAI,QACF;aAEA,KAAK;IAET,GAAG;QAAC;QAAO;QAAM;KAAO;IAExB,OAAO,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;2BACpB;oBACA;kBACA;mBACA;sBACA;0BACA;YACA,mJAAmJ;YACnJ,2EAA2E;YAC3E,SAAS,KAAO;oBAChB;QACF,CAAA,GAAI;QAAC;QAAQ;QAAM;QAAO;QAAU;QAAe;QAAQ;KAAa;AAC1E","sources":["packages/@react-stately/menu/src/useSubmenuTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FocusStrategy, Key} from '@react-types/shared';\nimport type {OverlayTriggerState} from '@react-stately/overlays';\nimport {RootMenuTriggerState} from './useMenuTriggerState';\nimport {useCallback, useMemo, useState} from 'react';\n\nexport interface SubmenuTriggerProps {\n /** Key of the trigger item. */\n triggerKey: Key\n}\n\nexport interface SubmenuTriggerState extends OverlayTriggerState {\n /** Whether the submenu is currently open. */\n isOpen: boolean,\n /** Controls which item will be auto focused when the submenu opens. */\n focusStrategy: FocusStrategy | null,\n /** Opens the submenu. */\n open: (focusStrategy?: FocusStrategy | null) => void,\n /** Closes the submenu. */\n close: () => void,\n /** Closes all menus and submenus in the menu tree. */\n closeAll: () => void,\n /** The level of the submenu. */\n submenuLevel: number,\n /** Toggles the submenu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void,\n /** @private */\n setOpen: () => void\n}\n\n/**\n * Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of the submenu, and\n * controls which item will receive focus when it opens.\n */\nexport function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState {\n let {triggerKey} = props;\n let {expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll} = state;\n let [submenuLevel] = useState(expandedKeysStack?.length);\n let isOpen = useMemo(() => expandedKeysStack[submenuLevel] === triggerKey, [expandedKeysStack, triggerKey, submenuLevel]);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);\n\n let open = useCallback((focusStrategy?: FocusStrategy | null) => {\n setFocusStrategy(focusStrategy ?? null);\n openSubmenu(triggerKey, submenuLevel);\n }, [openSubmenu, submenuLevel, triggerKey]);\n\n let close = useCallback(() => {\n setFocusStrategy(null);\n closeSubmenu(triggerKey, submenuLevel);\n }, [closeSubmenu, submenuLevel, triggerKey]);\n\n let toggle = useCallback((focusStrategy?: FocusStrategy | null) => {\n setFocusStrategy(focusStrategy ?? null);\n if (isOpen) {\n close();\n } else {\n open(focusStrategy);\n }\n }, [close, open, isOpen]);\n\n return useMemo(() => ({\n focusStrategy,\n isOpen,\n open,\n close,\n closeAll,\n submenuLevel,\n // TODO: Placeholders that aren't used but give us parity with OverlayTriggerState so we can use this in Popover. Refactor if we update Popover via\n // https://github.com/adobe/react-spectrum/pull/4976#discussion_r1336472863\n setOpen: () => {},\n toggle\n }), [isOpen, open, close, closeAll, focusStrategy, toggle, submenuLevel]);\n}\n"],"names":[],"version":3,"file":"useSubmenuTriggerState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/menu",
3
- "version": "3.8.3-nightly.5042+68403fe55",
3
+ "version": "3.9.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,16 +22,16 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/overlays": "3.6.11-nightly.5042+68403fe55",
26
- "@react-types/menu": "3.9.12-nightly.5042+68403fe55",
27
- "@react-types/shared": "3.0.0-nightly.3114+68403fe55",
25
+ "@react-stately/overlays": "^3.6.12",
26
+ "@react-types/menu": "^3.9.13",
27
+ "@react-types/shared": "^3.26.0",
28
28
  "@swc/helpers": "^0.5.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
31
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "68403fe55489dce3de1b3094c957d598ad719861"
36
+ "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
37
37
  }
@@ -17,7 +17,7 @@ import {useState} from 'react';
17
17
 
18
18
  export interface MenuTriggerState extends OverlayTriggerState {
19
19
  /** Controls which item will be auto focused when the menu opens. */
20
- readonly focusStrategy: FocusStrategy,
20
+ readonly focusStrategy: FocusStrategy | null,
21
21
 
22
22
  /** Opens the menu. */
23
23
  open(focusStrategy?: FocusStrategy | null): void,
@@ -49,7 +49,7 @@ export interface RootMenuTriggerState extends MenuTriggerState {
49
49
  */
50
50
  export function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState {
51
51
  let overlayTriggerState = useOverlayTriggerState(props);
52
- let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);
52
+ let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);
53
53
  let [expandedKeysStack, setExpandedKeysStack] = useState<Key[]>([]);
54
54
 
55
55
  let closeAll = () => {
@@ -81,11 +81,11 @@ export function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerSta
81
81
  return {
82
82
  focusStrategy,
83
83
  ...overlayTriggerState,
84
- open(focusStrategy: FocusStrategy = null) {
84
+ open(focusStrategy: FocusStrategy | null = null) {
85
85
  setFocusStrategy(focusStrategy);
86
86
  overlayTriggerState.open();
87
87
  },
88
- toggle(focusStrategy: FocusStrategy = null) {
88
+ toggle(focusStrategy: FocusStrategy | null = null) {
89
89
  setFocusStrategy(focusStrategy);
90
90
  overlayTriggerState.toggle();
91
91
  },
@@ -48,10 +48,10 @@ export function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMe
48
48
  let {expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll} = state;
49
49
  let [submenuLevel] = useState(expandedKeysStack?.length);
50
50
  let isOpen = useMemo(() => expandedKeysStack[submenuLevel] === triggerKey, [expandedKeysStack, triggerKey, submenuLevel]);
51
- let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);
51
+ let [focusStrategy, setFocusStrategy] = useState<FocusStrategy | null>(null);
52
52
 
53
- let open = useCallback((focusStrategy: FocusStrategy = null) => {
54
- setFocusStrategy(focusStrategy);
53
+ let open = useCallback((focusStrategy?: FocusStrategy | null) => {
54
+ setFocusStrategy(focusStrategy ?? null);
55
55
  openSubmenu(triggerKey, submenuLevel);
56
56
  }, [openSubmenu, submenuLevel, triggerKey]);
57
57
 
@@ -60,8 +60,8 @@ export function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMe
60
60
  closeSubmenu(triggerKey, submenuLevel);
61
61
  }, [closeSubmenu, submenuLevel, triggerKey]);
62
62
 
63
- let toggle = useCallback((focusStrategy: FocusStrategy = null) => {
64
- setFocusStrategy(focusStrategy);
63
+ let toggle = useCallback((focusStrategy?: FocusStrategy | null) => {
64
+ setFocusStrategy(focusStrategy ?? null);
65
65
  if (isOpen) {
66
66
  close();
67
67
  } else {