Full Code of bpmn-io/react-bpmn for AI

main 4c989b54e3f4 cached
13 files
22.5 KB
8.0k tokens
12 symbols
1 requests
Download .txt
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 (
    <ReactBpmn
      url="/public/diagram.bpmn"
      onShown={ onShown }
      onLoading={ onLoading }
      onError={ onError }
    />
  );
}
```

## 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
================================================
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd">
  <collaboration id="sid-c0e745ff-361e-4afb-8c8d-2a1fc32b1424">
    <participant id="sid-87F4C1D6-25E1-4A45-9DA7-AD945993D06F" name="Customer" processRef="sid-C3803939-0872-457F-8336-EAE484DC4A04" />
  </collaboration>
  <process id="sid-C3803939-0872-457F-8336-EAE484DC4A04" name="Customer" processType="None" isClosed="false" isExecutable="false">
    <extensionElements />
    <laneSet id="sid-b167d0d7-e761-4636-9200-76b7f0e8e83a">
      <lane id="sid-57E4FE0D-18E4-478D-BC5D-B15164E93254">
        <flowNodeRef>sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26</flowNodeRef>
        <flowNodeRef>sid-E49425CF-8287-4798-B622-D2A7D78EF00B</flowNodeRef>
        <flowNodeRef>sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138</flowNodeRef>
        <flowNodeRef>sid-E433566C-2289-4BEB-A19C-1697048900D2</flowNodeRef>
        <flowNodeRef>sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9</flowNodeRef>
        <flowNodeRef>SCAN_OK</flowNodeRef>
      </lane>
    </laneSet>
    <task id="sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26" name="Scan QR code">
      <incoming>sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D</incoming>
      <outgoing>sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A</outgoing>
    </task>
    <task id="sid-E49425CF-8287-4798-B622-D2A7D78EF00B" name="Open product information in mobile  app">
      <incoming>sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB</incoming>
      <outgoing>sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C</outgoing>
    </task>
    <startEvent id="sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138" name="Notices&#10;QR code">
      <outgoing>sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD</outgoing>
    </startEvent>
    <endEvent id="sid-E433566C-2289-4BEB-A19C-1697048900D2" name="Is informed">
      <incoming>sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C</incoming>
    </endEvent>
    <exclusiveGateway id="sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9">
      <incoming>sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD</incoming>
      <incoming>sid-337A23B9-A923-4CCE-B613-3E247B773CCE</incoming>
      <outgoing>sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D</outgoing>
    </exclusiveGateway>
    <exclusiveGateway id="SCAN_OK" name="Scan successful?&#10;">
      <incoming>sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A</incoming>
      <outgoing>sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB</outgoing>
      <outgoing>sid-337A23B9-A923-4CCE-B613-3E247B773CCE</outgoing>
    </exclusiveGateway>
    <sequenceFlow id="sid-337A23B9-A923-4CCE-B613-3E247B773CCE" name="Yes" sourceRef="SCAN_OK" targetRef="sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9" />
    <sequenceFlow id="sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D" sourceRef="sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9" targetRef="sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26" />
    <sequenceFlow id="sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB" name="No" sourceRef="SCAN_OK" targetRef="sid-E49425CF-8287-4798-B622-D2A7D78EF00B" />
    <sequenceFlow id="sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C" sourceRef="sid-E49425CF-8287-4798-B622-D2A7D78EF00B" targetRef="sid-E433566C-2289-4BEB-A19C-1697048900D2" />
    <sequenceFlow id="sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A" sourceRef="sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26" targetRef="SCAN_OK" />
    <sequenceFlow id="sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD" sourceRef="sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138" targetRef="sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9" />
  </process>
  <bpmndi:BPMNDiagram id="sid-74620812-92c4-44e5-949c-aa47393d3830">
    <bpmndi:BPMNPlane id="sid-cdcae759-2af7-4a6d-bd02-53f3352a731d" bpmnElement="sid-c0e745ff-361e-4afb-8c8d-2a1fc32b1424">
      <bpmndi:BPMNShape id="sid-87F4C1D6-25E1-4A45-9DA7-AD945993D06F_gui" bpmnElement="sid-87F4C1D6-25E1-4A45-9DA7-AD945993D06F" isHorizontal="true">
        <omgdc:Bounds x="83" y="105" width="933" height="250" />
        <bpmndi:BPMNLabel labelStyle="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b">
          <omgdc:Bounds x="47.49999999999999" y="170.42857360839844" width="12.000000000000014" height="59.142852783203125" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="sid-57E4FE0D-18E4-478D-BC5D-B15164E93254_gui" bpmnElement="sid-57E4FE0D-18E4-478D-BC5D-B15164E93254" isHorizontal="true">
        <omgdc:Bounds x="113" y="105" width="903" height="250" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26_gui" bpmnElement="sid-52EB1772-F36E-433E-8F5B-D5DFD26E6F26">
        <omgdc:Bounds x="393" y="170" width="100" height="80" />
        <bpmndi:BPMNLabel labelStyle="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b">
          <omgdc:Bounds x="360.5" y="172" width="84" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="sid-E49425CF-8287-4798-B622-D2A7D78EF00B_gui" bpmnElement="sid-E49425CF-8287-4798-B622-D2A7D78EF00B">
        <omgdc:Bounds x="728" y="170" width="100" height="80" />
        <bpmndi:BPMNLabel labelStyle="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b">
          <omgdc:Bounds x="695.9285736083984" y="162" width="83.14285278320312" height="36" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A_gui" bpmnElement="sid-EE8A7BA0-5D66-4F8B-80E3-CC2751B3856A">
        <omgdi:waypoint x="493" y="210" />
        <omgdi:waypoint x="585" y="210" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="494" y="185" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB_gui" bpmnElement="sid-8B820AF5-DC5C-4618-B854-E08B71FB55CB">
        <omgdi:waypoint x="635" y="210" />
        <omgdi:waypoint x="728" y="210" />
        <bpmndi:BPMNLabel labelStyle="sid-e0502d32-f8d1-41cf-9c4a-cbb49fecf581">
          <omgdc:Bounds x="642" y="185" width="16" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD_gui" bpmnElement="sid-7B791A11-2F2E-4D80-AFB3-91A02CF2B4FD">
        <omgdi:waypoint x="223" y="210" />
        <omgdi:waypoint x="275" y="210" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="204" y="185" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D_gui" bpmnElement="sid-4DC479E5-5C20-4948-BCFC-9EC5E2F66D8D">
        <omgdi:waypoint x="325" y="210" />
        <omgdi:waypoint x="393" y="210" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="314" y="185" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C_gui" bpmnElement="sid-57EB1F24-BD94-479A-BF1F-57F1EAA19C6C">
        <omgdi:waypoint x="828" y="210" />
        <omgdi:waypoint x="901" y="210" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="820" y="185" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="sid-337A23B9-A923-4CCE-B613-3E247B773CCE_gui" bpmnElement="sid-337A23B9-A923-4CCE-B613-3E247B773CCE">
        <omgdi:waypoint x="611" y="234" />
        <omgdi:waypoint x="610.5" y="299" />
        <omgdi:waypoint x="300.5" y="299" />
        <omgdi:waypoint x="301" y="234" />
        <bpmndi:BPMNLabel labelStyle="sid-e0502d32-f8d1-41cf-9c4a-cbb49fecf581">
          <omgdc:Bounds x="585" y="236" width="21" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="StartEvent_0l6sgn0_di" bpmnElement="sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138">
        <omgdc:Bounds x="187" y="192" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="182" y="229" width="46" height="24" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0xwuvv5_di" bpmnElement="sid-E433566C-2289-4BEB-A19C-1697048900D2">
        <omgdc:Bounds x="901" y="192" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="892" y="231" width="56" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ExclusiveGateway_1g0eih2_di" bpmnElement="sid-5134932A-1863-4FFA-BB3C-A4B4078B11A9" isMarkerVisible="true">
        <omgdc:Bounds x="275" y="185" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="210" y="160" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ExclusiveGateway_0vci1x5_di" bpmnElement="SCAN_OK" isMarkerVisible="true">
        <omgdc:Bounds x="585" y="185" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <omgdc:Bounds x="568" y="157" width="88" height="24" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
    <bpmndi:BPMNLabelStyle id="sid-e0502d32-f8d1-41cf-9c4a-cbb49fecf581">
      <omgdc:Font name="Arial" size="11" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" />
    </bpmndi:BPMNLabelStyle>
    <bpmndi:BPMNLabelStyle id="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b">
      <omgdc:Font name="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" />
    </bpmndi:BPMNLabelStyle>
  </bpmndi:BPMNDiagram>
</definitions>

================================================
FILE: example/public/index.html
================================================
<!DOCTYPE html>
<html>
<head>
  <title>react-bpmn example</title>

  <!-- app dependency -->
  <script src="https://unpkg.com/react@18/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>

  <!-- dependency for the UMD bundle -->
  <script src="../node_modules/bpmn-js/dist/bpmn-navigated-viewer.development.js"></script>

  <!-- react-bpmn umd distribution -->
  <script src="../node_modules/react-bpmn/dist/react-bpmn.umd.js"></script>

  <!-- Don't use this in production: -->
  <script src="https://unpkg.com/@babel/standalone@7.12.12/babel.min.js"></script>

  <style>
    .diagram-container {
      height:  400px;
    }

    .react-bpmn-diagram-container {
      width: 100%;
      height:  100%;
    }
  </style>
</head>
<body>
  <div>
    <h1>Display BPMN 2.0 Diagrams Using React</h1>

    <p>
      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.
    </p>

    <p>
      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.
    </p>

    <div id="diagram" class="diagram-container"></div>

    <p>
      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.
    </p>

    <p>
      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.
    </p>

    <p>
      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.
    </p>
  </div>
  <script type="text/babel">
    function onError(err) {
      console.error('failed to render diagram', err);
    }

    function onLoading() {
      console.log('loading diagram');
    }

    function onShown() {
      console.log('diagram shown');
    }

    function ExternalLoadedBpmn({ url }) {
      const [diagramXML, setDiagramXML] = React.useState();

      React.useEffect(() => {
        const abortController = new AbortController();
        const loadXml = async () => {
          try {
            const response = await fetch(url, {
              signal: abortController.signal
            });
            const result = await response.text();
            setDiagramXML(result);

          } catch (error) {
            if (!abortController.signal.aborted) {
              console.log(error);
            }
          }
        }

        loadXml();

        return () => abortController.abort();
      }, [url])

      return (
        diagramXML
          ? <ReactBpmn
            diagramXML={diagramXML}
            onLoading={onLoading}
            onShown={onShown}
            onError={onError}
          />
          : null
      );
    }

    const container = document.querySelector('#diagram');
    const root = ReactDOM.createRoot(container);
    root.render(
      <div>
        <ReactBpmn
          url="/public/diagram.bpmn"
          onLoading={onLoading}
          onShown={onShown}
          onError={onError}
        />
        <hr />

        <ExternalLoadedBpmn
          url="/public/diagram.bpmn"
          onLoading={onLoading}
          onShown={onShown}
          onError={onError}
        />
      </div>
    )
  </script>
</body>
</html>


================================================
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 (
      <div className="react-bpmn-diagram-container" ref={ this.containerRef }></div>
    );
  }
}
Download .txt
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
Download .txt
SYMBOL INDEX (12 symbols across 2 files)

FILE: rollup.config.js
  function pgl (line 11) | function pgl() {

FILE: src/index.jsx
  class ReactBpmn (line 6) | class ReactBpmn extends React.Component {
    method constructor (line 8) | constructor(props) {
    method componentDidMount (line 16) | componentDidMount() {
    method componentWillUnmount (line 51) | componentWillUnmount() {
    method componentDidUpdate (line 55) | componentDidUpdate(prevProps, prevState) {
    method displayDiagram (line 74) | displayDiagram(diagramXML) {
    method fetchDiagram (line 78) | fetchDiagram(url) {
    method handleLoading (line 88) | handleLoading() {
    method handleError (line 96) | handleError(err) {
    method handleShown (line 104) | handleShown(warnings) {
    method render (line 112) | render() {
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (25K chars).
[
  {
    "path": ".github/workflows/CI.yml",
    "chars": 467,
    "preview": "name: CI\non: [ push, pull_request ]\njobs:\n  Build:\n\n    strategy:\n      matrix:\n        os: [ ubuntu-latest ]\n        no"
  },
  {
    "path": ".gitignore",
    "chars": 17,
    "preview": "node_modules\ndist"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 392,
    "preview": "# Changelog\n\nAll notable changes to [react-bpmn](https://github.com/bpmn-io/react-bpmn) are documented here. We use [sem"
  },
  {
    "path": "LICENSE",
    "chars": 1095,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2019-present Camunda Services GmbH\n\nPermission is hereby granted, free of charge, t"
  },
  {
    "path": "README.md",
    "chars": 1161,
    "preview": "# react-bpmn\n\n[![CI](https://github.com/bpmn-io/react-bpmn/workflows/CI/badge.svg)](https://github.com/bpmn-io/react-bpm"
  },
  {
    "path": "example/README.md",
    "chars": 361,
    "preview": "# react-bpmn Example\n\nAn example how to use [react-bpmn](../) to display a BPMN 2.0 diagram in a React app.\n\n![react-bpm"
  },
  {
    "path": "example/package.json",
    "chars": 367,
    "preview": "{\n  \"name\": \"react-bpmn-example\",\n  \"version\": \"0.0.0\",\n  \"description\": \"An example using react-bpmn inside a React app"
  },
  {
    "path": "example/public/diagram.bpmn",
    "chars": 9687,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"ht"
  },
  {
    "path": "example/public/index.html",
    "chars": 5175,
    "preview": "<!DOCTYPE html>\n<html>\n<head>\n  <title>react-bpmn example</title>\n\n  <!-- app dependency -->\n  <script src=\"https://unpk"
  },
  {
    "path": "package.json",
    "chars": 1152,
    "preview": "{\n  \"name\": \"react-bpmn\",\n  \"version\": \"0.2.0\",\n  \"description\": \"Embed BPMN 2.0 diagrams in your React app\",\n  \"main\": "
  },
  {
    "path": "renovate.json",
    "chars": 138,
    "preview": "{\n  \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n  \"extends\": [\n    \"github>bpmn-io/renovate-config:r"
  },
  {
    "path": "rollup.config.js",
    "chars": 914,
    "preview": "import pkg from './package.json';\n\nimport cjs from '@rollup/plugin-commonjs';\n\nimport { babel } from '@rollup/plugin-bab"
  },
  {
    "path": "src/index.jsx",
    "chars": 2134,
    "preview": "import React from 'react';\n\nimport BpmnJS from 'bpmn-js/dist/bpmn-navigated-viewer.production.min.js';\n\n\nexport default "
  }
]

About this extraction

This page contains the full source code of the bpmn-io/react-bpmn GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (22.5 KB), approximately 8.0k tokens, and a symbol index with 12 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!