
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@bastinjafari/react-flow-chart-with-tooltips-and-multi-select
Advanced tools
A flexible, stateless flow chart library for react.
https://github.com/MrBlenny/react-flow-chart/pull/204
This project aims to build a highly customisable, declarative flow chart library. Critically, you control the state. Pick from Redux, MobX, React or any other state managment library - simply pass in the current state and hook up the callbacks.
For example:
The flow chart is designed as a collection of Nodes, Ports and Links. You can specify your own custom properties, making this format quite flexible. See types/chart.ts. Note, nodes, ports and links should have a unique id.
export const chart: IChart = {
offset: {
x: 0,
y: 0,
},
scale: 1,
nodes: {
node1: {
id: 'node1',
type: 'output-only',
position: {
x: 300,
y: 100,
},
ports: {
port1: {
id: 'port1',
type: 'output',
properties: {
value: 'yes',
},
},
port2: {
id: 'port2',
type: 'output',
properties: {
value: 'no',
},
},
},
},
node2: {
id: 'node2',
type: 'input-output',
position: {
x: 300,
y: 300,
},
ports: {
port1: {
id: 'port1',
type: 'input',
},
port2: {
id: 'port2',
type: 'output',
},
},
},
},
links: {
link1: {
id: 'link1',
from: {
nodeId: 'node1',
portId: 'port2',
},
to: {
nodeId: 'node2',
portId: 'port1',
},
},
},
selected: {},
hovered: {},
}
This will produce a simple 2 noded chart which looks like:
npm i @mrblenny/react-flow-chart
Most components/types are available as a root level export. Check the storybook demo for more examples.
import { FlowChartWithState } from "@mrblenny/react-flow-chart";
const chartSimple = {
offset: {
x: 0,
y: 0
},
nodes: {
node1: {
id: "node1",
type: "output-only",
position: {
x: 300,
y: 100
},
ports: {
port1: {
id: "port1",
type: "output",
properties: {
value: "yes"
}
},
port2: {
id: "port2",
type: "output",
properties: {
value: "no"
}
}
}
},
node2: {
id: "node2",
type: "input-output",
position: {
x: 300,
y: 300
},
ports: {
port1: {
id: "port1",
type: "input"
},
port2: {
id: "port2",
type: "output"
}
}
},
},
links: {
link1: {
id: "link1",
from: {
nodeId: "node1",
portId: "port2"
},
to: {
nodeId: "node2",
portId: "port1"
},
},
},
selected: {},
hovered: {}
};
const Example = (
<FlowChartWithState initialValue={chartSimple} />
);
stories/InternalReactState.tsx
stories/ExternalReactState.tsx
You can add tooltips by adding tooltipsGlobal
into the chartState (IChart
) or tooltip
to the node objects.
tooltipsGlobal
will apply for all nodes and tooltip
for individual nodes.
export const tooltipChart: IChart = {
tooltipsGlobal: {
showTooltip: true,
toogleOffWhenClicked: 'global',
text: 'This is the global tooltip and will be toggled off, when clicked',
},
offset: {
x: 0,
y: 0,
},
scale: 1,
nodes: {
node1: {
tooltip: {
showTooltip: true,
text: 'this is the tooltip for node1',
},
...
node2: {
tooltip: {
showTooltip: true,
toogleOffWhenClicked: 'node',
text: 'this is the tooltip for node2 and will be toggled off when clicked',
},
id: 'node2',
...
node3: {
tooltip: {
showTooltip: false,
text: 'this is the tooltip for node3 but its off',
},
id: 'node3',
type: 'input-output',
position: {
x: 100,
y: 600,
},
...
You can also customize the tooltipComponent by adding it to Component props of flowChart:
const ExampleToolTipComponent = (props: ITooltipComponentDefaultProps) => {
return (
<div className="ExampleToolTipComponent" style={{ width: '300px', textAlign: 'center' }}>
<h2 style={{ margin: 'auto' }}>{props.tooltip}</h2>
</div>
)
}
export class Tooltips extends React.Component {
...
return (
<Page>
<FlowChart
chart={chart}
callbacks={stateActions}
Components={{TooltipComponent: ExampleToolTipComponent}}/>
</Page>)
}
stories/ExternalReactState.tsx
If you're interested in helping out, let me know.
In particular, would be great to get a hand with docs and redux / mobx integrations.
npm install
npm run start:storybook
FAQs
A flexible, stateless flow chart library for react.
The npm package @bastinjafari/react-flow-chart-with-tooltips-and-multi-select receives a total of 0 weekly downloads. As such, @bastinjafari/react-flow-chart-with-tooltips-and-multi-select popularity was classified as not popular.
We found that @bastinjafari/react-flow-chart-with-tooltips-and-multi-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.