Repository: bpmn-io/react-bpmn Branch: main Commit: 4c989b54e3f4 Files: 13 Total size: 22.5 KB Directory structure: gitextract_v6q7w27_/ ├── .github/ │ └── workflows/ │ └── CI.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example/ │ ├── README.md │ ├── package.json │ └── public/ │ ├── diagram.bpmn │ └── index.html ├── package.json ├── renovate.json ├── rollup.config.js └── src/ └── index.jsx ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/CI.yml ================================================ name: CI on: [ push, pull_request ] jobs: Build: strategy: matrix: os: [ ubuntu-latest ] node-version: [ 16 ] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v6 - name: Use Node.js uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci - name: Build run: npm run all ================================================ FILE: .gitignore ================================================ node_modules dist ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to [react-bpmn](https://github.com/bpmn-io/react-bpmn) are documented here. We use [semantic versioning](http://semver.org/) for releases. ## Unreleased ___Note:__ Yet to be released changes appear here._ ## 0.2.0 * `FEAT`: allow open pre-loaded diagram (via `diagramXML` prop) ## 0.1.1 * `FIX`: correct url update handling ## 0.1.0 _Initial Release._ ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2019-present Camunda Services GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # react-bpmn [![CI](https://github.com/bpmn-io/react-bpmn/workflows/CI/badge.svg)](https://github.com/bpmn-io/react-bpmn/actions?query=workflow%3ACI) Use [bpmn-js](https://github.com/bpmn-io/bpmn-js) to display BPMN 2.0 diagrams in a [React](https://reactjs.org/) application. ## Usage ```javascript import ReactBpmn from 'react-bpmn'; function App(props) { function onShown() { console.log('diagram shown'); } function onLoading() { console.log('diagram loading'); } function onError(err) { console.log('failed to show diagram'); } return ( ); } ``` ## Development To get the development setup make sure to have [NodeJS](https://nodejs.org/en/download/) installed. As soon as you are set up, clone the project and execute ``` npm install npm run all ``` ## Example To run the example, execute `npm run start` and open http://localhost:9869/public in your Webbrowser. ## Resources * [Issues](https://github.com/bpmn-io/react-bpmn/issues) * [Example](./example) ## License MIT ================================================ FILE: example/README.md ================================================ # react-bpmn Example An example how to use [react-bpmn](../) to display a BPMN 2.0 diagram in a React app. ![react-bpmn example screenshot](./docs/screenshot.png) ## Run the Example To run the example: ``` npm install npm start ``` This puts up the example to [localhost:9869/public/index.html](http://localhost:9869/public/index.html). ## License MIT ================================================ FILE: example/package.json ================================================ { "name": "react-bpmn-example", "version": "0.0.0", "description": "An example using react-bpmn inside a React application", "private": true, "scripts": { "start": "sirv . start --dev --port=9869" }, "license": "MIT", "dependencies": { "bpmn-js": "^18.0.0", "react-bpmn": "^0.2.0" }, "devDependencies": { "sirv-cli": "^3.0.0" } } ================================================ FILE: example/public/diagram.bpmn ================================================ sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26 sid-E49425CF-8287-4798-B622-D2A7D78EF00B sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138 sid-E433566C-2289-4BEB-A19C-1697048900D2 sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9 SCAN_OK sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD sid-337A23B9-A923-4CCE-B613-3E247B773CCE sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB sid-337A23B9-A923-4CCE-B613-3E247B773CCE ================================================ FILE: example/public/index.html ================================================ react-bpmn example

Display BPMN 2.0 Diagrams Using React

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a tincidunt dolor. Nam semper est ut mauris cursus, vel laoreet nunc vehicula. Mauris nec semper ipsum. Integer feugiat mi at elementum fringilla. Nunc malesuada ante sed ligula pretium, eu lobortis lorem rhoncus. Praesent et ipsum ante. Aliquam est mi, ultrices ut neque eget, mollis pulvinar sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam auctor porta sapien in venenatis.

In fringilla suscipit odio quis tincidunt. Morbi felis elit, blandit a volutpat eget, rutrum ut mi. Duis ac orci at nibh semper vehicula. Quisque vulputate, nibh vitae laoreet convallis, urna erat imperdiet eros, et interdum arcu arcu ac risus. Maecenas in tellus nisi. Mauris quis lectus luctus, condimentum orci eu, rhoncus sapien. Aliquam at lobortis mauris, eget facilisis arcu. Quisque metus purus, rhoncus et tortor id, ornare maximus neque. Donec et ex tincidunt, malesuada lacus in, volutpat eros. Cras nisi arcu, dapibus quis odio sit amet, placerat blandit elit. Nullam at dictum mauris. Nulla feugiat elit ex, a pulvinar velit faucibus a. Nulla tincidunt velit purus, in faucibus ligula ornare venenatis.

Ut vestibulum, magna at molestie tempus, enim sem molestie est, vel tincidunt orci leo vel sapien. Vivamus convallis, purus in rhoncus ultricies, mauris sapien condimentum sapien, vel porta urna est eu leo. Nam dui erat, venenatis at metus ut, rutrum rutrum lacus. Fusce non eros vehicula, aliquet nibh vitae, bibendum dolor. Sed hendrerit lectus ex. Mauris id venenatis metus. In hac habitasse platea dictumst.

Etiam molestie, erat eget tincidunt rutrum, nulla odio pulvinar nibh, in pulvinar felis mauris a nunc. Sed eu ullamcorper ex, id tincidunt metus. Quisque lectus enim, vehicula eget aliquam sit amet, semper ut nisl. Vivamus ultrices, cras odio massa, sagittis in luctus sed, mattis eu massa. Nam erat nibh, pulvinar vel hendrerit quis, ultricies eu sapien. Integer fringilla sapien ex, et posuere arcu euismod et.

Suspendisse potenti. In ut lorem vitae dolor molestie commodo. Vivamus mattis gravida metus, porttitor ornare augue lacinia suscipit. Duis condimentum fringilla nisl, non consequat odio mollis id. Nulla tincidunt interdum elit, sed tristique ex laoreet lobortis. Suspendisse in felis vitae magna convallis semper. Nullam odio risus, venenatis eget erat ac, pretium aliquet urna. Duis luctus lobortis maximus.

================================================ FILE: package.json ================================================ { "name": "react-bpmn", "version": "0.2.0", "description": "Embed BPMN 2.0 diagrams in your React app", "main": "dist/index.js", "files": [ "dist", "src" ], "scripts": { "all": "npm run bundle", "bundle": "cross-env NODE_ENV=production rollup -c --bundleConfigAsCjs", "prepublishOnly": "npm run bundle", "postinstall": "cd example && npm install", "start": "cd example && npm start" }, "module": "dist/index.esm.js", "repository": { "type": "git", "url": "git+https://github.com/bpmn-io/react-bpmn.git" }, "keywords": [ "bpmn-js", "bpmn", "react-js", "react" ], "author": { "name": "Nico Rehwaldt", "url": "https://github.com/nikku" }, "license": "MIT", "devDependencies": { "@babel/core": "^7.19.0", "@babel/preset-env": "^7.19.0", "@rollup/plugin-babel": "^7.0.0", "@rollup/plugin-commonjs": "^29.0.0", "@rollup/plugin-node-resolve": "^16.0.0", "@rollup/plugin-replace": "^6.0.0", "babel-preset-react-app": "^10.0.1", "cross-env": "^10.0.0", "react": "^19.0.0", "react-dom": "^19.0.0", "rollup": "^4.18.0" } } ================================================ FILE: renovate.json ================================================ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "github>bpmn-io/renovate-config:recommended" ] } ================================================ FILE: rollup.config.js ================================================ import pkg from './package.json'; import cjs from '@rollup/plugin-commonjs'; import { babel } from '@rollup/plugin-babel'; import nodeResolve from '@rollup/plugin-node-resolve'; import replace from '@rollup/plugin-replace'; function pgl() { return [ cjs(), nodeResolve(), replace({ 'process.env.NODE_ENV': JSON.stringify( 'production' ) }), babel({ babelrc: false, babelHelpers: 'runtime', exclude: 'node_modules/**', presets: [ ['@babel/env', { modules: false }], 'react-app' ] }) ]; } export default [ { input: './src/index.jsx', output: { name: 'ReactBpmn', file: `dist/react-bpmn.umd.js`, format: 'umd' }, plugins: pgl() }, { input: './src/index.jsx', output: [ { file: pkg.main, format: 'cjs' }, { file: pkg.module, format: 'es' } ], plugins: pgl() } ]; ================================================ FILE: src/index.jsx ================================================ import React from 'react'; import BpmnJS from 'bpmn-js/dist/bpmn-navigated-viewer.production.min.js'; export default class ReactBpmn extends React.Component { constructor(props) { super(props); this.state = { }; this.containerRef = React.createRef(); } componentDidMount() { const { url, diagramXML } = this.props; const container = this.containerRef.current; this.bpmnViewer = new BpmnJS({ container }); this.bpmnViewer.on('import.done', (event) => { const { error, warnings } = event; if (error) { return this.handleError(error); } this.bpmnViewer.get('canvas').zoom('fit-viewport'); return this.handleShown(warnings); }); if (url) { return this.fetchDiagram(url); } if (diagramXML) { return this.displayDiagram(diagramXML); } } componentWillUnmount() { this.bpmnViewer.destroy(); } componentDidUpdate(prevProps, prevState) { const { props, state } = this; if (props.url !== prevProps.url) { return this.fetchDiagram(props.url); } const currentXML = props.diagramXML || state.diagramXML; const previousXML = prevProps.diagramXML || prevState.diagramXML; if (currentXML && currentXML !== previousXML) { return this.displayDiagram(currentXML); } } displayDiagram(diagramXML) { this.bpmnViewer.importXML(diagramXML); } fetchDiagram(url) { this.handleLoading(); fetch(url) .then(response => response.text()) .then(text => this.setState({ diagramXML: text })) .catch(err => this.handleError(err)); } handleLoading() { const { onLoading } = this.props; if (onLoading) { onLoading(); } } handleError(err) { const { onError } = this.props; if (onError) { onError(err); } } handleShown(warnings) { const { onShown } = this.props; if (onShown) { onShown(warnings); } } render() { return (
); } }