Socket
Socket
Sign inDemoInstall

@react-stately/menu

Package Overview
Dependencies
Maintainers
2
Versions
736
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/menu - npm Package Compare versions

Comparing version 3.0.0-alpha.1 to 3.0.0-nightly-086ad3115-240911

dist/import.mjs

52

dist/main.js

@@ -1,41 +0,25 @@

var _babelRuntimeHelpersSlicedToArray = $parcel$interopDefault(require("@babel/runtime/helpers/slicedToArray"));
var $f39cdb649cd48930$exports = require("./useMenuTriggerState.main.js");
var $38ab7fb105c54ad2$exports = require("./useSubmenuTriggerState.main.js");
var useControlledState = require("@react-stately/utils").useControlledState;
var useState = require("react").useState;
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function useMenuTriggerState(props) {
var _useControlledState = useControlledState(props.isOpen, props.defaultOpen || false, props.onOpenChange),
_useControlledState2 = _babelRuntimeHelpersSlicedToArray(_useControlledState, 2),
isOpen = _useControlledState2[0],
setOpen = _useControlledState2[1];
$parcel$export(module.exports, "useMenuTriggerState", () => $f39cdb649cd48930$exports.useMenuTriggerState);
$parcel$export(module.exports, "useSubmenuTriggerState", () => $38ab7fb105c54ad2$exports.useSubmenuTriggerState);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
var _useState = useState('first'),
_useState2 = _babelRuntimeHelpersSlicedToArray(_useState, 2),
focusStrategy = _useState2[0],
setFocusStrategy = _useState2[1];
return {
isOpen: isOpen,
setOpen: setOpen,
focusStrategy: focusStrategy,
setFocusStrategy: setFocusStrategy,
open: function open() {
setOpen(true);
},
close: function close() {
setOpen(false);
},
toggle: function toggle() {
var focusStrategy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'first';
setFocusStrategy(focusStrategy);
setOpen(!isOpen);
}
};
}
exports.useMenuTriggerState = useMenuTriggerState;
//# sourceMappingURL=main.js.map

@@ -1,26 +0,19 @@

import { useControlledState } from "@react-stately/utils";
import { useState } from "react";
export function useMenuTriggerState(props) {
let [isOpen, setOpen] = useControlledState(props.isOpen, props.defaultOpen || false, props.onOpenChange);
let [focusStrategy, setFocusStrategy] = useState('first');
return {
isOpen,
setOpen,
focusStrategy,
setFocusStrategy,
import {useMenuTriggerState as $a28c903ee9ad8dc5$export$79fefeb1c2091ac3} from "./useMenuTriggerState.module.js";
import {useSubmenuTriggerState as $e5614764aa47eb35$export$cfc51cf86138bf98} from "./useSubmenuTriggerState.module.js";
open() {
setOpen(true);
},
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
close() {
setOpen(false);
},
toggle(focusStrategy = 'first') {
setFocusStrategy(focusStrategy);
setOpen(!isOpen);
}
};
}
export {$a28c903ee9ad8dc5$export$79fefeb1c2091ac3 as useMenuTriggerState, $e5614764aa47eb35$export$cfc51cf86138bf98 as useSubmenuTriggerState};
//# sourceMappingURL=module.js.map

@@ -1,13 +0,59 @@

import { FocusStrategy, MenuTriggerProps } from "@react-types/menu";
export interface MenuTriggerState {
import { FocusStrategy, Key } from "@react-types/shared";
import { MenuTriggerProps } from "@react-types/menu";
import { OverlayTriggerState } from "@react-stately/overlays";
export interface MenuTriggerState extends OverlayTriggerState {
/** Controls which item will be auto focused when the menu opens. */
readonly focusStrategy: FocusStrategy;
/** Opens the menu. */
open(focusStrategy?: FocusStrategy | null): void;
/** Toggles the menu. */
toggle(focusStrategy?: FocusStrategy | null): void;
}
export interface RootMenuTriggerState extends MenuTriggerState {
/** Opens a specific submenu tied to a specific menu item at a specific level. */
openSubmenu: (triggerKey: Key, level: number) => void;
/** Closes a specific submenu tied to a specific menu item at a specific level. */
closeSubmenu: (triggerKey: Key, level: number) => void;
/** An array of open submenu trigger keys within the menu tree.
* The index of key within array matches the submenu level in the tree.
*/
expandedKeysStack: Key[];
/** Closes the menu and all submenus in the menu tree. */
close: () => void;
}
/**
* Manages state for a menu trigger. Tracks whether the menu is currently open,
* and controls which item will receive focus when it opens. Also tracks the open submenus within
* the menu tree via their trigger keys.
*/
export function useMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState;
export interface SubmenuTriggerProps {
/** Key of the trigger item. */
triggerKey: Key;
}
export interface SubmenuTriggerState extends OverlayTriggerState {
/** Whether the submenu is currently open. */
isOpen: boolean;
setOpen(value: boolean): void;
focusStrategy: FocusStrategy;
setFocusStrategy(value: FocusStrategy): void;
open(): void;
close(): void;
toggle(focusStrategy?: FocusStrategy): void;
/** Controls which item will be auto focused when the submenu opens. */
focusStrategy: FocusStrategy | null;
/** Opens the submenu. */
open: (focusStrategy?: FocusStrategy | null) => void;
/** Closes the submenu. */
close: () => void;
/** Closes all menus and submenus in the menu tree. */
closeAll: () => void;
/** The level of the submenu. */
submenuLevel: number;
/** Toggles the submenu. */
toggle: (focusStrategy?: FocusStrategy | null) => void;
/** @private */
setOpen: () => void;
}
export function useMenuTriggerState(props: MenuTriggerProps): MenuTriggerState;
/**
* Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of the submenu, and
* controls which item will receive focus when it opens.
*/
export function useSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState;
export type { MenuTriggerProps } from '@react-types/menu';
//# sourceMappingURL=types.d.ts.map
{
"name": "@react-stately/menu",
"version": "3.0.0-alpha.1",
"version": "3.0.0-nightly-086ad3115-240911",
"description": "Spectrum UI components in React",

@@ -8,6 +8,12 @@ "license": "Apache-2.0",

"module": "dist/module.js",
"exports": {
"types": "./dist/types.d.ts",
"import": "./dist/import.mjs",
"require": "./dist/main.js"
},
"types": "dist/types.d.ts",
"source": "src/index.ts",
"files": [
"dist"
"dist",
"src"
],

@@ -17,11 +23,12 @@ "sideEffects": false,

"type": "git",
"url": "https://github.com/adobe-private/react-spectrum-v3"
"url": "https://github.com/adobe/react-spectrum"
},
"dependencies": {
"@babel/runtime": "^7.6.2",
"@react-stately/utils": "^3.0.0-rc.2",
"@react-types/menu": "^3.0.0-alpha.1"
"@react-stately/overlays": "^3.0.0-nightly-086ad3115-240911",
"@react-types/menu": "^3.0.0-nightly-086ad3115-240911",
"@react-types/shared": "^3.0.0-nightly-086ad3115-240911",
"@swc/helpers": "^0.5.0"
},
"peerDependencies": {
"react": "^16.8.0"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
},

@@ -31,3 +38,3 @@ "publishConfig": {

},
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410"
}
"stableVersion": "3.8.2"
}
# @react-stately/menu
This package is part of [react-spectrum](https://github.com/adobe-private/react-spectrum-v3). See the repo for more details.
This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc