npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yandex/ymaps3-context-menu

v0.0.2

Published

Yandex Maps JS API 3.0 example ymaps3-context-menu

Downloads

32,290

Readme

ymaps3-context-menu package


Yandex JS API package

npm version npm

Props

The package is located in the dist folder:

  • dist/types TypeScript types
  • dist/esm es6 modules for direct connection in your project
  • dist/index.js Yandex JS Module

Recommended use ymaps3-context-menu as usual npm package:

npm install @yandex/ymaps3-context-menu

You also need to import css styles into your project:

/* index.css */
@import '@yandex/ymaps3-context-menu/dist/esm/index.css';

and dynamic import

main();
async function main() {
  await ymaps3.ready;
  const {YMapContextMenu, YMapContextMenuItem} = await import('@yandex/ymaps3-context-menu');
  map = new ymaps3.YMap(document.getElementById('app'), {location: LOCATION});

  map.addChild(new ymaps3.YMapDefaultSchemeLayer({}));
  map.addChild(new ymaps3.YMapDefaultFeaturesLayer({}));

  const contextMenu = new YMapContextMenu({
    visible: false,
    screenCoordinates: [0, 0]
  });
  contextMenu.addChild(
    new YMapContextMenuItem({
      text: 'Click',
      visible: true,
      onClick: () => {
        contextMenu.update({visible: false});
      }
    })
  );
  map.addChild(contextMenu);

  const listener = new ymaps3.YMapListener({
    onContextMenu: (object, event) => {
      contextMenu.update({
        visible: true,
        screenCoordinates: event.screenCoordinates
      });
    },
    onActionStart: () => {
      contextMenu.update({visible: false});
    }
  });
  map.addChild(listener);
}
main();
async function main() {
  const [ymaps3React] = await Promise.all([ymaps3.import('@yandex/ymaps3-reactify'), ymaps3.ready]);
  const reactify = ymaps3React.reactify.bindTo(React, ReactDOM);

  const {YMap, YMapDefaultSchemeLayer, YMapDefaultFeaturesLayer, YMapListener} = reactify.module(ymaps3);

  const {useState} = React;

  const {YMapContextMenu, YMapContextMenuItem} = reactify.module(await import('@yandex/ymaps3-context-menu'));

  const App = () => {
    const [location, setLocation] = useState(LOCATION);
    const [visibleContextMenu, setVisibleContextMenu] = useState(false);
    const [screenCoordinates, setScreenCoordinates] = useState<[number, number]>();
    const [contextMenuLngLat, setContextMenuLngLat] = useState<LngLat>();

    const onContextMenu: DomEventHandler = (object, event) => {
      setContextMenuLngLat(event.coordinates);
      setVisibleContextMenu(true);
      setScreenCoordinates(event.screenCoordinates);
    };

    const onActionStart: BehaviorMapEventHandler = () => {
      setVisibleContextMenu(false);
    };

    const zoomIn = () => {
      setLocation({zoom: (location as YMapZoomLocation).zoom + 1, duration: 600, easing: 'ease-in-out'});
      setVisibleContextMenu(false);
    };

    const zoomOut = () => {
      setLocation({zoom: (location as YMapZoomLocation).zoom - 1, duration: 400, easing: 'ease-in-out'});
      setVisibleContextMenu(false);
    };

    const centerByIt = () => {
      setLocation({center: contextMenuLngLat, duration: 500, easing: 'ease-in-out'});
      setVisibleContextMenu(false);
    };

    return (
      <YMap location={location}>
        <YMapDefaultSchemeLayer />

        <YMapDefaultFeaturesLayer />

        <YMapContextMenu visible={visibleContextMenu} screenCoordinates={screenCoordinates}>
          <YMapContextMenuItem text="Zoom in" visible={true} onClick={zoomIn} />
          <YMapContextMenuItem text="Zoom out" visible={true} onClick={zoomOut} />
          <YMapContextMenuItem text="Center by it" visible={true} onClick={centerByIt} />
        </YMapContextMenu>

        <YMapListener onContextMenu={onContextMenu} onActionStart={onActionStart} />
      </YMap>
    );
  };

  ReactDOM.render(
    <React.StrictMode>
      <App />
    </React.StrictMode>,
    document.getElementById('app')
  );
}

Usage without npm

You can use CDN with module loading handler in JS API on your page.

By default ymaps3.import can load self modules. If you want also load your package, should register cdn:

ymaps3.import.registerCdn('https://cdn.jsdelivr.net/npm/{package}', '@yandex/ymaps3-context-menu@latest');

Just use ymaps3.import:

const {YMapContextMenu, YMapContextMenuItem} = await ymaps3.import('@yandex/ymaps3-context-menu');

YMapContextMenu props description

| Name | Type | Default | Description | | :---------------- | :--------------- | :----------- | :------------------------------------------------------- | | visible | boolean | | Shows or hides the context menu. | | screenCoordinates | [number, number] | | Screen coordinates where the context menu should appear. | | width | number | 240 | Width of the context menu in pixels. | | position | Position | bottom right | Position of the context menu relative to the pointer. |

YMapContextMenuItem props description

| Name | Type | Default | Description | | :----------- | :-------------------- | :------ | :--------------------------------------------------------------------------------- | | visible | boolean | | Shows or hides the context menu item. | | text | string | | Text of the menu item. | | icon | string or HTMLElement | | Reference to an icon or an HTML element with an icon for the menu item (optional). | | iconPosition | 'start' or 'end' | start | Position of the icon. | | onClick | function | | Callback function to handle a click on the menu item. | | disabled | boolean | false | Flag indicating whether the menu item is disabled. | | order | number | 0 | Sets the order of the menu item in the list. |