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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@solussd/storm-react-diagrams

v2.4.4

Published

A super simple, no-nonsense diagramming library written in React that just works.

Downloads

6

Readme

STORM React Diagrams

A super simple, no-nonsense diagramming library written in React that just works.

Join the chat at https://gitter.im/projectstorm/react-diagrams NPM NPM

Demo2

Introduction

A no-nonsense diagramming library written entirely in React with the help of Lodash. It aims to be:

  • Simple, and void of any fuss/complications when implementing it into your own application
  • Customizable without having to hack the core (adapters/factories etc..)
  • Simple to operate and understand without sugar and magic
  • Fast and optimized to handle large diagrams with hundreds of nodes/links
  • Super easy to use, and should work as you expect it to

How to install

npm install storm-react-diagrams

or

yarn add storm-react-diagrams
  • Its only dependency is Lodash and obviously React so it will install that too.

How to build

Simply run webpack in the root directory (or webpack -p if you want a production build) and it will spit out the transpiled code and typescript definitions into the dist directory as a single file. It will also compile the code for the demos .We use webpack for this because TSC cannot compile a single UMD file (TSC can currently only output multiple UMD files).

How to see the examples

  1. checkout the project
  2. run webpack in the root
  3. open up one of the demos folders and load the corresponding index.html file.

To see how to create your own nodes like the one below, take a look at demo3:

Demo2

How does it work

The library uses a Model Graph to represent the virtual diagram and then renders the diagram using 2 layers:

  • Node Layer -> which is responsible for rendering nodes as HTML components
  • Link Layer -> which renders the links as SVG paths

Each node and link is fed into a factory that then generates the corresponding node or link react widget. Therefore, to create custom nodes and links, register your own factories that return your own widgets.

As long as a node contains at least one port and the corresponding NodeWidget contains at least one PortWidget, a link can be connected to it.

Events

Event System

DiagramWidget props

  • onLinkStateChanged (link, isConnected)
  • diagramEngine

Questions

Why didn’t I render the nodes as SVG's?

Because its vastly better to render nodes as standard HTML so that we can embed input controls and not have to deal with the complexities of trying to get SVG to work like we want it to. I also created this primarily to embed into enterprise applications where the nodes themselves are highly interactive with buttons and other controls that cave when I try to use SVG.

Why Typescript?

Because it can transpile into any level of ECMA Script, and the library got really complicated, so I ported it to Typescript to accommodate the heavy architectural changes I was starting to make. <3 Type Script

Why is there no JSX?

Because most of the library is 95% all logic anyway, and I construct very complex DOM elements with many dynamic properties. JSX Would just get in the way, and I personally hate JSX for a multitude of reasons anyway.

How do I make my own elements?

Take a look at the defaults directory, with specific attention to the DefaultNodeWidget

How do I use the library?

Take a look at the demo folders, they have simple and complex examples of the complete usage.

Usage Demo and Guide

This is a demo of the interaction taken directly from the test folder.

Demo

Key commands

del key will remove anything selected including links

shift and drag will trigger a multi selection box

shift and select nodes/links/points will select multiple nodes

drag canvas will drag the complete diagram

mouse wheel will zoom in or out the entire diagram

click link and drag will create a new link anchor/point that you can then drag around

click node-port and drag will create a new link that is anchored to the port, allowing you to drag the link to another connecting port