0.19.0 • Published 2 years ago

react-mutliple-diagram v0.19.0

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

Package to view block diagram and make blocks connections

demo

install

npm i react-mutliple-diagram

Usage

import React, { ComponentProps, useCallback, useEffect, useState } from 'react';
import { SVGReactDiagram, DiagramItemsType } from 'react-mutliple-diagram';

...

function App() {

  const [ items, setItems ] = useState<DiagramItemsType>({});

  useEffect(() => {
    console.log('items', items);
  }, [items]);

  const onChange: ComponentProps<typeof SVGReactDiagram>['onChange'] = useCallback((newItems) => {
    setItems(newItems);
  }, []);

  return (
    <div className="App">
      <SVGReactDiagram
        items={items}
        onChange={onChange}
      />
      onItemChangeClick={(item) => {
        console.log('item to change', item);
      }}
      onItemDeleteClick={(item) => {
        console.log('item to delete', item);
        const confirm = window.confirm('Are you sure want to remove that item?');
        return confirm;
      }}
    </div>
  );
}

Props

NameDescription
itemsObject with items to view
onChangefunction (newItems) => void
loadingTexttext on initializing plug
isLoadingisLoading state to show plug
onItemChangeClickfunction (item) => void fro edit item, if defined then show edit button
onItemDeleteClickfunction (item) => void for confirm delete item, need return true for delete, or false to disable delete, if defined then show remove button
0.19.0

2 years ago

0.18.1

2 years ago

0.18.0

2 years ago

0.17.2

2 years ago

0.16.3

2 years ago

0.17.3

2 years ago

0.16.4

2 years ago

0.17.5

2 years ago

0.17.6

2 years ago

0.17.7

2 years ago

0.17.8

2 years ago

0.17.9

2 years ago

0.16.0

2 years ago

0.17.0

2 years ago

0.16.1

2 years ago

0.17.1

2 years ago

0.16.2

2 years ago

0.15.11

2 years ago

0.15.10

2 years ago

0.15.9

2 years ago

0.15.8

2 years ago

0.15.7

2 years ago

0.15.5

2 years ago

0.15.4

2 years ago

0.15.3

2 years ago

0.15.2

2 years ago

0.15.1

2 years ago

0.15.0

2 years ago

0.14.2

2 years ago

0.14.1

2 years ago

0.14.0

2 years ago

0.13.0

2 years ago

0.12.0

2 years ago

0.11.0

2 years ago

0.1.0

2 years ago