mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2026-03-13 09:50:09 +08:00
Compare commits
66 Commits
v6.7.1-alp
...
@projectst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63b39cba79 | ||
|
|
a671b50e09 | ||
|
|
7a664d5b64 | ||
|
|
66c687afc6 | ||
|
|
23b5467806 | ||
|
|
1889c7cb40 | ||
|
|
c3146e1aa8 | ||
|
|
8fb8d04885 | ||
|
|
74e814ab5a | ||
|
|
3d4e0b24d7 | ||
|
|
efd64ad278 | ||
|
|
160b88fccf | ||
|
|
80cd9c9306 | ||
|
|
2de55fdf68 | ||
|
|
b8a4cbdf1a | ||
|
|
76a2659948 | ||
|
|
63e33c07d8 | ||
|
|
70b17a749c | ||
|
|
4ccc5d58f3 | ||
|
|
fb7d646bde | ||
|
|
e0d21f1435 | ||
|
|
6ed1e0f89d | ||
|
|
7da7fa4cc9 | ||
|
|
ed7988f722 | ||
|
|
e6b86321e2 | ||
|
|
17bb78b130 | ||
|
|
ddeea124b0 | ||
|
|
fcdbce54b5 | ||
|
|
f1c38fb84a | ||
|
|
74f9269869 | ||
|
|
a28bcc037d | ||
|
|
456e6b1b67 | ||
|
|
c9e819d78e | ||
|
|
8a2f5d198f | ||
|
|
251a1f9484 | ||
|
|
c1eac9873a | ||
|
|
95b35d6778 | ||
|
|
d2a197245b | ||
|
|
8f06e55127 | ||
|
|
b0e8e52077 | ||
|
|
0d23e933e8 | ||
|
|
4dfeb403be | ||
|
|
0e19827675 | ||
|
|
2b1f54bbc9 | ||
|
|
b3a6cc01fa | ||
|
|
918d8d741b | ||
|
|
d15fb13adf | ||
|
|
4f2b6132ba | ||
|
|
7d9d137c66 | ||
|
|
b051697791 | ||
|
|
8fc9fe3aae | ||
|
|
b4185dcb76 | ||
|
|
c1fa7ee865 | ||
|
|
05a5afb20e | ||
|
|
8bcc1436d3 | ||
|
|
9b39591d94 | ||
|
|
88296c28b4 | ||
|
|
2a810ca2d3 | ||
|
|
dfcf82e692 | ||
|
|
cd93bb96a3 | ||
|
|
5f49bbe5b1 | ||
|
|
d55790edcf | ||
|
|
a1b2f6a59e | ||
|
|
77011af27a | ||
|
|
580a26c73d | ||
|
|
4c03583d91 |
8
.changeset/README.md
Normal file
8
.changeset/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Changesets
|
||||
|
||||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
||||
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
||||
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
||||
|
||||
We have a quick list of common questions to get you started engaging with this project in
|
||||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
||||
11
.changeset/config.json
Normal file
11
.changeset/config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "master",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: buildkite/puppeteer
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "yarn.lock" }}
|
||||
- run: yarn install
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "yarn.lock" }}
|
||||
|
||||
# test building project
|
||||
- run: yarn run build
|
||||
|
||||
# test e2e tests and jest snapshots
|
||||
- run: cd diagrams-demo-gallery && yarn run test --ci
|
||||
- run: cd packages/react-diagrams-routing && yarn run test --ci
|
||||
@@ -1,27 +0,0 @@
|
||||
FROM node:8-slim
|
||||
|
||||
# Install latest chrome dev package.
|
||||
# Note: this installs the necessary libs to make the bundled version of Chromium that Pupppeteer
|
||||
# installs, work.
|
||||
RUN apt-get update && apt-get install -y wget --no-install-recommends \
|
||||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y google-chrome-unstable \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get purge --auto-remove -y curl \
|
||||
&& rm -rf /src/*.deb
|
||||
|
||||
RUN yarn add puppeteer
|
||||
|
||||
# Add pptr user.
|
||||
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
|
||||
&& mkdir -p /home/pptruser/Downloads \
|
||||
&& chown -R pptruser:pptruser /home/pptruser \
|
||||
&& chown -R pptruser:pptruser /node_modules
|
||||
|
||||
# Run user as non privileged.
|
||||
USER pptruser
|
||||
|
||||
CMD ["google-chrome-unstable"]
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 231 KiB |
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,24 +1,16 @@
|
||||
# Checklist
|
||||
|
||||
- [ ] The code has been run through pretty `yarn run pretty`
|
||||
- [ ] The tests pass on CircleCI
|
||||
- [ ] You have referenced the issue(s) or other PR(s) this fixes/relates-to
|
||||
- [ ] The PR Template has been filled out (see below)
|
||||
- [ ] Had a beer/coffee because you are awesome
|
||||
- [ ] The tests pass
|
||||
- [ ] I have referenced the issue(s) or other PR(s) this fixes/relates-to
|
||||
- [ ] I have run ```pnpm changeset``` and followed the instructions
|
||||
- [ ] I have explained in this PR, what I did and why
|
||||
- [ ] I replaced the image below
|
||||
- [ ] Had a beer/coffee/tea because I did something cool today
|
||||
|
||||
## What?
|
||||
## What, why and how?
|
||||
|
||||
|
||||
## Why?
|
||||
|
||||
|
||||
## How?
|
||||
|
||||
|
||||
## Feel good image:
|
||||
|
||||
(Add your own one below :])
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
23
.github/workflows/prettier.yml
vendored
Normal file
23
.github/workflows/prettier.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Prettier check
|
||||
|
||||
# This action works with pull requests and pushes
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
prettier:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Make sure the actual branch is checked out when running on pull requests
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
- uses: actions/checkout@v2 # Check out the repository first.
|
||||
- uses: actionsx/prettier@v2
|
||||
with:
|
||||
# prettier CLI arguments.
|
||||
args: --check --ignore-path .prettierignore --config .prettierrc '**/*.{ts,tsx,js,jsx}'
|
||||
47
.github/workflows/release.yml
vendored
Normal file
47
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Read .nvmrc
|
||||
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
|
||||
id: nvm
|
||||
|
||||
- name: Use Node.js (.nvmrc)
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "${{ steps.nvm.outputs.NVMRC }}"
|
||||
|
||||
- name: Install PNPM
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Create Release Pull Request
|
||||
uses: changesets/action@v1
|
||||
id: changesets
|
||||
with:
|
||||
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
||||
publish: pnpm release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: publish storybook
|
||||
if: steps.changesets.outputs.published == 'true'
|
||||
run: pnpm release:storybook
|
||||
30
.github/workflows/test.yml
vendored
Normal file
30
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Build and Test
|
||||
on:
|
||||
pull_request:
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Read .nvmrc
|
||||
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
|
||||
id: nvm
|
||||
|
||||
- name: Use Node.js (.nvmrc)
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "${{ steps.nvm.outputs.NVMRC }}"
|
||||
|
||||
- name: Install PNPM
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,5 @@ dist
|
||||
*.zip
|
||||
.env
|
||||
node_modules
|
||||
yarn-error.log
|
||||
tsconfig.tsbuildinfo
|
||||
.vscode
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"jsxBracketSameLine": true,
|
||||
"useTabs": true,
|
||||
"printWidth": 120,
|
||||
"trailingComma": "none"
|
||||
|
||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,3 +1,19 @@
|
||||
__V7!__
|
||||
|
||||
we are now using changesets! you can see the changes for individual packages in their corresponding folders.
|
||||
Here is the main changeset for the core package which depends on everything:
|
||||
|
||||
[Changelog for @projectstorm/react-diagrams](./packages/react-diagrams/CHANGELOG.md)
|
||||
|
||||
---
|
||||
|
||||
__6.7.4__
|
||||
|
||||
.0 -> .4 because I messed up the version / publishing
|
||||
|
||||
* (upgrade all dependencies, including a move to React 18)
|
||||
* https://github.com/projectstorm/react-diagrams/pull/947
|
||||
|
||||
__6.7.0__
|
||||
|
||||
bug fixes:
|
||||
@@ -141,7 +157,7 @@ __5.1.0__
|
||||
* (refactor) consistently use lodash where possible
|
||||
* (maintenance) upgrade node modules
|
||||
|
||||
__5.0.0__ http://dylanv.blog/2018/03/03/storm-react-diagrams-5-0-0/
|
||||
__5.0.0__ [http://dylanv.blog/2018/03/03/storm-react-diagrams-5-0-0/](https://dylanvorster.com/storm-react-diagrams-v5-0/)
|
||||
|
||||
PR: https://github.com/projectstorm/react-diagrams/pull/145
|
||||
|
||||
@@ -158,7 +174,7 @@ PR: https://github.com/projectstorm/react-diagrams/pull/145
|
||||
* (tests) automatically load JEST Snapshots
|
||||
* (feature) Link labels!
|
||||
|
||||
__4.0.0__ http://dylanv.blog/2018/01/18/storm-react-diagrams-v4-0-0/
|
||||
__4.0.0__ [http://dylanv.blog/2018/01/18/storm-react-diagrams-v4-0-0/](https://dylanvorster.com/storm-react-diagrams-v4-0/)
|
||||
|
||||
* (refactor) Events system was completely overhauled
|
||||
* (demo) Custom Link Sizes
|
||||
@@ -172,7 +188,7 @@ __4.0.0__ http://dylanv.blog/2018/01/18/storm-react-diagrams-v4-0-0/
|
||||
* (demo) Cloning
|
||||
* (feature) models control isLocked
|
||||
|
||||
__3.2.0__ http://dylanv.blog/2017/11/22/storm-react-diagrams-3-2-0/
|
||||
__3.2.0__ [http://dylanv.blog/2017/11/22/storm-react-diagrams-3-2-0/](https://dylanvorster.com/storm-react-diagrams-3-2-0/)
|
||||
* (feature) zoom to fit
|
||||
* added Circle CI tests
|
||||
* (demo) dagre automatic layouts
|
||||
@@ -195,14 +211,14 @@ __3.1.2__
|
||||
* Hotfix: fix zooming when canvas not in the top left corner
|
||||
(https://github.com/projectstorm/react-diagrams/pull/88)
|
||||
|
||||
__3.1.0__ http://dylanv.blog/2017/09/15/storm-react-diagrams-3-1-0/
|
||||
__3.1.0__ [http://dylanv.blog/2017/09/15/storm-react-diagrams-3-1-0/](https://dylanvorster.com/storm-react-diagrams-3-1-0/)
|
||||
* Zoom relative to mouse location
|
||||
* Fixed links not connecting when grid is larger than port size
|
||||
* Prevented points from dragging when connected to a port and the node itself is not selected
|
||||
* API fixes
|
||||
* Code cleanup
|
||||
|
||||
__3.0.0__ http://dylanv.blog/2017/09/13/storm-react-diagrams-v3/
|
||||
__3.0.0__ [http://dylanv.blog/2017/09/13/storm-react-diagrams-v3/](https://dylanvorster.com/storm-react-diagrams-3-0/)
|
||||
* Massive performance updates
|
||||
* Complete rewrite
|
||||
* Started a changelog and design documents for each revision
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Introduction
|
||||
|
||||
[](https://gitter.im/projectstorm/react-diagrams?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://npmjs.org/package/@projectstorm/react-diagrams) [](https://packagequality.com/#?package=storm-react-diagrams) [](https://circleci.com/gh/projectstorm/react-diagrams/tree/master) [](https://lerna.js.org/)
|
||||
[](https://gitter.im/projectstorm/react-diagrams?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://npmjs.org/package/@projectstorm/react-diagrams) [](https://packagequality.com/#?package=storm-react-diagrams)
|
||||
|
||||

|
||||
|
||||
@@ -70,7 +70,7 @@ yarn add @projectstorm/react-diagrams-routing
|
||||
|
||||
## How to use
|
||||
|
||||
Before running any of the examples, please run `yarn build` in the root. This project is a monorepo, and the packages (including the demos) require the packages to first be built.
|
||||
Before running any of the examples, please run `pnpm build` in the root. This project is a monorepo, and the packages (including the demos) require the packages to first be built.
|
||||
|
||||
|
||||
Take a look at the [diagram demos](https://github.com/projectstorm/react-diagrams/tree/master/diagrams-demo-gallery/demos)
|
||||
@@ -85,11 +85,11 @@ Take a look at the [demo project](https://github.com/projectstorm/react-diagrams
|
||||
|
||||
## Run the demos
|
||||
|
||||
After running `yarn install` and `yarn build`, you must then run: `cd diagrams-demo-gallery && yarn run start`
|
||||
After running `pnpm install` and `pnpm build`, you must then run: `cd diagrams-demo-gallery && pnpm run start`
|
||||
|
||||
## Building from source
|
||||
|
||||
Simply run `yarn` then `yarn build` or `yarn build:prod` in the root directory and it will spit out the transpiled code and typescript definitions into the dist directory as a single file.
|
||||
Simply run `pnpm` then `pnpm build` or `pnpm build:prod` in the root directory and it will spit out the transpiled code and typescript definitions into the dist directory as a single file.
|
||||
|
||||
## Built with react-diagrams
|
||||
|
||||
|
||||
18
diagrams-demo-gallery/.babelrc.json
Normal file
18
diagrams-demo-gallery/.babelrc.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"sourceType": "unambiguous",
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"chrome": 100,
|
||||
"safari": 15,
|
||||
"firefox": 91
|
||||
}
|
||||
}
|
||||
],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript"
|
||||
],
|
||||
"plugins": []
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
module.exports = {
|
||||
stories: ['../demos/*.stories.tsx'],
|
||||
core: {
|
||||
builder: 'webpack5'
|
||||
},
|
||||
addons: ['@storybook/addon-actions']
|
||||
addons: ['@storybook/addon-actions'],
|
||||
framework: {
|
||||
name: '@storybook/react-webpack5',
|
||||
options: {}
|
||||
}
|
||||
};
|
||||
|
||||
5
diagrams-demo-gallery/.storybook/preview-head.html
Normal file
5
diagrams-demo-gallery/.storybook/preview-head.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<style>
|
||||
html, body, #storybook-root {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
70
diagrams-demo-gallery/CHANGELOG.md
Normal file
70
diagrams-demo-gallery/CHANGELOG.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# @projectstorm/react-diagrams-gallery
|
||||
|
||||
## 7.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.2
|
||||
- @projectstorm/react-diagrams-core@7.0.2
|
||||
- @projectstorm/react-canvas-core@7.0.2
|
||||
- @projectstorm/react-diagrams@7.0.3
|
||||
|
||||
## 7.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/react-canvas-core@7.0.1
|
||||
- @projectstorm/react-diagrams@7.0.2
|
||||
- @projectstorm/react-diagrams-core@7.0.1
|
||||
- @projectstorm/react-diagrams-defaults@7.1.1
|
||||
|
||||
## 7.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e0d21f1: - [feature] new ability to refresh links in auto distribute system [PR 756](https://github.com/projectstorm/react-diagrams/pull/756)
|
||||
|
||||
- [fix] Default link now uses the correct method for creating a point allowing this to be overridden [PR 939](https://github.com/projectstorm/react-diagrams/pull/939)
|
||||
|
||||
Big thanks to @ToTheHit and @h0111in for your help on these, even though its very delayed on my part :)
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e0d21f1]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.0
|
||||
- @projectstorm/react-diagrams@7.0.1
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-diagrams-defaults@7.0.0
|
||||
- @projectstorm/react-diagrams-core@7.0.0
|
||||
- @projectstorm/react-canvas-core@7.0.0
|
||||
- @projectstorm/react-diagrams@7.0.0
|
||||
@@ -45,7 +45,8 @@ class DemoWidget extends React.Component<{ model: DiagramModel; engine: DiagramE
|
||||
marginx: 25,
|
||||
marginy: 25
|
||||
},
|
||||
includeLinks: true
|
||||
includeLinks: true,
|
||||
nodeMargin: 25
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,6 +58,13 @@ class DemoWidget extends React.Component<{ model: DiagramModel; engine: DiagramE
|
||||
this.props.engine.repaintCanvas();
|
||||
};
|
||||
|
||||
autoRefreshLinks = () => {
|
||||
this.engine.refreshLinks(this.props.model);
|
||||
|
||||
// only happens if pathfing is enabled (check line 25)
|
||||
this.reroute();
|
||||
this.props.engine.repaintCanvas();
|
||||
};
|
||||
componentDidMount(): void {
|
||||
setTimeout(() => {
|
||||
this.autoDistribute();
|
||||
@@ -72,7 +80,14 @@ class DemoWidget extends React.Component<{ model: DiagramModel; engine: DiagramE
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DemoWorkspaceWidget buttons={<DemoButton onClick={this.autoDistribute}>Re-distribute</DemoButton>}>
|
||||
<DemoWorkspaceWidget
|
||||
buttons={
|
||||
<div>
|
||||
<DemoButton onClick={this.autoDistribute}>Re-distribute</DemoButton>
|
||||
<DemoButton onClick={this.autoRefreshLinks}>Refresh Links</DemoButton>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<DemoCanvasWidget>
|
||||
<CanvasWidget engine={this.props.engine} />
|
||||
</DemoCanvasWidget>
|
||||
@@ -106,9 +121,11 @@ export default () => {
|
||||
});
|
||||
|
||||
// more links for more complicated diagram
|
||||
links.push(connectNodes(nodesFrom[0], nodesTo[1], engine));
|
||||
links.push(connectNodes(nodesTo[0], nodesFrom[1], engine));
|
||||
links.push(connectNodes(nodesFrom[1], nodesTo[2], engine));
|
||||
links.push(connectNodes(nodesTo[0], nodesTo[1], engine));
|
||||
links.push(connectNodes(nodesTo[1], nodesTo[2], engine));
|
||||
links.push(connectNodes(nodesTo[0], nodesTo[2], engine));
|
||||
links.push(connectNodes(nodesFrom[0], nodesFrom[2], engine));
|
||||
links.push(connectNodes(nodesFrom[0], nodesTo[2], engine));
|
||||
|
||||
// initial random position
|
||||
nodesFrom.forEach((node, index) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
#storybook-root {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
launch: {
|
||||
dumpio: true,
|
||||
headless: process.env.CI === 'true'
|
||||
},
|
||||
browserContext: 'default'
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
const path = require('path');
|
||||
module.exports = {
|
||||
preset: 'jest-puppeteer',
|
||||
transform: {
|
||||
'^.+\\.tsx?$': 'ts-jest'
|
||||
},
|
||||
roots: [path.join(__dirname, 'tests-e2e')],
|
||||
testMatch: ['**/*.test.{ts,tsx}']
|
||||
};
|
||||
13
diagrams-demo-gallery/package-lock.json
generated
13
diagrams-demo-gallery/package-lock.json
generated
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-gallery",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"gsap": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/gsap/-/gsap-3.0.1.tgz",
|
||||
"integrity": "sha512-9nzEBF7Ss9Ogyw6oEOXZxxVYH8WNRA/nHmIp3DrPOTKmlLxX9MN2ovSoH9TApA+rucBgp9veCedujp5oSQRvZw=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,53 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-gallery",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/projectstorm/react-diagrams.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./node_modules/.bin/start-storybook",
|
||||
"storybook:build": "./node_modules/.bin/build-storybook -c .storybook -o .out",
|
||||
"github": "./node_modules/.bin/storybook-to-ghpages",
|
||||
"test:run": "../node_modules/.bin/jest --no-cache",
|
||||
"test": "yarn storybook:build && yarn test:run"
|
||||
},
|
||||
"keywords": [
|
||||
"web",
|
||||
"diagram",
|
||||
"diagrams",
|
||||
"react",
|
||||
"typescript",
|
||||
"flowchart",
|
||||
"simple",
|
||||
"links",
|
||||
"nodes"
|
||||
],
|
||||
"dependencies": {
|
||||
"@storybook/addon-actions": "^6.5.6",
|
||||
"@storybook/addon-options": "^5.3.21",
|
||||
"@storybook/addons": "^6.5.6",
|
||||
"@storybook/builder-webpack5": "^6.5.6",
|
||||
"@storybook/manager-webpack5": "^6.5.6",
|
||||
"@storybook/react": "^6.5.6",
|
||||
"@storybook/storybook-deployer": "^2.8.11",
|
||||
"@storybook/theming": "^6.5.6",
|
||||
"gsap": "^3.10.4"
|
||||
}
|
||||
"name": "@projectstorm/react-diagrams-gallery",
|
||||
"version": "7.1.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/projectstorm/react-diagrams.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "pnpm storybook dev",
|
||||
"storybook:build": "./node_modules/.bin/build-storybook -c .storybook -o .out"
|
||||
},
|
||||
"keywords": [
|
||||
"web",
|
||||
"diagram",
|
||||
"diagrams",
|
||||
"react",
|
||||
"typescript",
|
||||
"flowchart",
|
||||
"simple",
|
||||
"links",
|
||||
"nodes"
|
||||
],
|
||||
"dependencies": {
|
||||
"@projectstorm/react-canvas-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams": "workspace:*",
|
||||
"@projectstorm/react-diagrams-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-defaults": "workspace:*",
|
||||
"gsap": "^3.12.2",
|
||||
"json-beautify": "^1.1.1",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.22.20",
|
||||
"@babel/preset-react": "^7.22.15",
|
||||
"@babel/preset-typescript": "^7.22.15",
|
||||
"@storybook/addon-actions": "^7.4.4",
|
||||
"@storybook/addon-options": "^5.3.21",
|
||||
"@storybook/addons": "^7.4.4",
|
||||
"@storybook/react": "^7.4.4",
|
||||
"@storybook/react-webpack5": "^7.4.4",
|
||||
"@storybook/storybook-deployer": "^2.8.16",
|
||||
"@storybook/theming": "^7.4.4",
|
||||
"@types/lodash": "^4.14.199",
|
||||
"@types/react": "^18.2.22",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"storybook": "^7.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { ElementHandle } from 'puppeteer';
|
||||
|
||||
export abstract class E2EBase {
|
||||
name: string;
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
async getSelector(): Promise<any> {
|
||||
return page;
|
||||
}
|
||||
|
||||
async getElement(): Promise<ElementHandle> {
|
||||
if (!(await this.getSelector())) {
|
||||
return null;
|
||||
}
|
||||
return (await this.getSelector()).$(this.selector());
|
||||
}
|
||||
|
||||
async waitForElement(): Promise<ElementHandle | null> {
|
||||
return (await this.getSelector()).waitForSelector(this.selector(), {
|
||||
timeout: 1000
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract selector(): string;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import { E2EBase } from './E2EBase';
|
||||
|
||||
export class E2ELink extends E2EBase {
|
||||
isID: boolean;
|
||||
|
||||
async select(): Promise<any> {
|
||||
const point = await page.evaluate((id) => {
|
||||
const path = document.querySelector(id) as SVGPathElement;
|
||||
const rect = path.getClientRects().item(0);
|
||||
return {
|
||||
x: rect.x + rect.width / 2,
|
||||
y: rect.y
|
||||
};
|
||||
}, this.selector());
|
||||
await page.keyboard.down('Shift');
|
||||
await page.mouse.move(point.x, point.y);
|
||||
await page.mouse.down();
|
||||
await page.keyboard.up('Shift');
|
||||
}
|
||||
|
||||
protected selector(): string {
|
||||
if (this.isID) {
|
||||
return `[data-linkid="${this.name}"] path`;
|
||||
}
|
||||
return `[data-default-link-test="${this.name}"] path`;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { E2EBase } from './E2EBase';
|
||||
import { E2EPort } from './E2EPort';
|
||||
|
||||
export class E2ENode extends E2EBase {
|
||||
async port(id: string): Promise<E2EPort> {
|
||||
return new E2EPort(id, this);
|
||||
}
|
||||
|
||||
selector(): string {
|
||||
return `[data-default-node-name="${this.name}"]`;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
import * as _ from 'lodash';
|
||||
import { E2EBase } from './E2EBase';
|
||||
import { E2ENode } from './E2ENode';
|
||||
import { E2ELink } from './E2ELink';
|
||||
|
||||
export class E2EPort extends E2EBase {
|
||||
parent: E2ENode;
|
||||
|
||||
constructor(name: string, parent: E2ENode) {
|
||||
super(name);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
async getLinks(): Promise<E2ELink[]> {
|
||||
const attribute = await page.evaluate((id) => {
|
||||
return document.querySelector(id).getAttribute('data-links');
|
||||
}, this.selector());
|
||||
if (attribute.trim() === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return _.map(attribute.split(','), (id) => {
|
||||
const e = new E2ELink(id);
|
||||
e.isID = true;
|
||||
return e;
|
||||
});
|
||||
}
|
||||
|
||||
async link(port: E2EPort): Promise<E2ELink> {
|
||||
let currentLinks = _.map(await this.getLinks(), 'name');
|
||||
|
||||
let bounds = await (await this.getElement()).boundingBox();
|
||||
|
||||
// click on this port
|
||||
page.mouse.move(bounds.x, bounds.y);
|
||||
page.mouse.down();
|
||||
//
|
||||
let bounds2 = await (await port.getElement()).boundingBox();
|
||||
|
||||
// drag to other port
|
||||
page.mouse.move(bounds2.x, bounds2.y);
|
||||
page.mouse.up();
|
||||
|
||||
let newLinks = _.map(await this.getLinks(), 'name');
|
||||
|
||||
const s = new E2ELink(_.difference(newLinks, currentLinks)[0]);
|
||||
s.isID = true;
|
||||
return s;
|
||||
}
|
||||
|
||||
async linkToPoint(x: number, y: number): Promise<E2ELink> {
|
||||
let currentLinks = _.map(await this.getLinks(), 'id');
|
||||
|
||||
let bounds = await (await this.getElement()).boundingBox();
|
||||
|
||||
// click on this port
|
||||
page.mouse.move(bounds.x, bounds.y);
|
||||
page.mouse.down();
|
||||
|
||||
// drag to point
|
||||
page.mouse.move(x, y);
|
||||
page.mouse.up();
|
||||
|
||||
let newLinks = _.map(await this.getLinks(), 'id');
|
||||
|
||||
const link = _.difference(newLinks, currentLinks)[0];
|
||||
if (!link) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// get the parent to get the link
|
||||
return new E2ELink(link);
|
||||
}
|
||||
|
||||
async getSelector(): Promise<any> {
|
||||
return (await this.parent.getElement()) as any;
|
||||
}
|
||||
|
||||
protected selector(): string {
|
||||
return `${this.parent.selector()} .port[data-name="${this.name}"]`;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'jest';
|
||||
import { E2ENode } from './helpers/E2ENode';
|
||||
|
||||
describe('simple flow test', () => {
|
||||
beforeEach(async () => {
|
||||
await page.goto(`file://${__dirname}/../.out/iframe.html?path=/story/simple-usage--simple-flow-example`);
|
||||
});
|
||||
|
||||
it('drag link to port adds a link', async () => {
|
||||
// create a new link
|
||||
let node1 = new E2ENode('Node 3');
|
||||
let node2 = new E2ENode('Node 2');
|
||||
|
||||
let port1 = await node1.port('Out');
|
||||
let port2 = await node2.port('In');
|
||||
|
||||
let newlink = await port1.link(port2);
|
||||
await expect(await newlink.waitForElement()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('drag link to node does not add a link', async () => {
|
||||
// create a new link
|
||||
let node1 = new E2ENode('Node 3');
|
||||
let node2 = new E2ENode('Node 2');
|
||||
|
||||
let port1 = await node1.port('Out');
|
||||
|
||||
let node2Bounds = await (await node2.waitForElement()).boundingBox();
|
||||
let newlink = await port1.linkToPoint(node2Bounds.x, node2Bounds.y);
|
||||
|
||||
await expect(newlink).toBeFalsy();
|
||||
});
|
||||
});
|
||||
@@ -1,31 +0,0 @@
|
||||
import 'jest';
|
||||
import { E2ELink } from './helpers/E2ELink';
|
||||
import { E2ENode } from './helpers/E2ENode';
|
||||
|
||||
describe('simple test', () => {
|
||||
beforeAll(async () => {
|
||||
await page.goto(`file://${__dirname}/../.out/iframe.html?path=/story/simple-usage--demo-simple`);
|
||||
});
|
||||
|
||||
it('should delete a link and create a new one', async () => {
|
||||
// get the existing link
|
||||
let link = new E2ELink('Test');
|
||||
await expect(await link.waitForElement()).toBeTruthy();
|
||||
|
||||
// remove it
|
||||
await link.select();
|
||||
await page.keyboard.press('Delete');
|
||||
|
||||
await expect(await link.getElement()).toBeFalsy();
|
||||
|
||||
// create a new link
|
||||
let node1 = new E2ENode('Node 1');
|
||||
let node2 = new E2ENode('Node 2');
|
||||
|
||||
let port1 = await node1.port('Out');
|
||||
let port2 = await node2.port('In');
|
||||
|
||||
let newlink = await port1.link(port2);
|
||||
await expect(await newlink.waitForElement()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
50
diagrams-demo-project/CHANGELOG.md
Normal file
50
diagrams-demo-project/CHANGELOG.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# @projectstorm/react-diagrams-demo
|
||||
|
||||
## 7.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- @projectstorm/react-diagrams@7.0.3
|
||||
|
||||
## 7.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/react-diagrams@7.0.2
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @projectstorm/react-diagrams@7.0.1
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-diagrams@7.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-demo",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.0.3",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
@@ -25,16 +25,22 @@
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/react-diagrams": "^6.7.1-alpha.0",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0"
|
||||
"@projectstorm/react-diagrams": "workspace:*",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.10",
|
||||
"@types/react-dom": "^18.0.5",
|
||||
"webpack": "^5.46.0",
|
||||
"webpack-cli": "^4.7.2",
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"source-map-loader": "^4.0.1",
|
||||
"html-webpack-plugin": "^5.5.3",
|
||||
"@babel/core": "^7.22.20",
|
||||
"@babel/preset-react": "^7.22.15",
|
||||
"@types/react": "^18.2.22",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"babel-loader": "^9.1.3",
|
||||
"css-loader": "^6.8.1",
|
||||
"style-loader": "^3.3.3",
|
||||
"webpack": "^5.88.2",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^4.15.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { DiagramEngine } from '@projectstorm/react-diagrams';
|
||||
import { CanvasWidget } from '@projectstorm/react-canvas-core';
|
||||
import { DiagramEngine, CanvasWidget } from '@projectstorm/react-diagrams';
|
||||
|
||||
export interface BodyWidgetProps {
|
||||
engine: DiagramEngine;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { JSCustomNodeModel } from './JSCustomNodeModel';
|
||||
import { JSCustomNodeWidget } from './JSCustomNodeWidget';
|
||||
import { AbstractReactFactory } from '@projectstorm/react-canvas-core';
|
||||
import { AbstractReactFactory } from '@projectstorm/react-diagrams';
|
||||
|
||||
export class JSCustomNodeFactory extends AbstractReactFactory {
|
||||
constructor() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import { TSCustomNodeModel } from './TSCustomNodeModel';
|
||||
import { TSCustomNodeWidget } from './TSCustomNodeWidget';
|
||||
import { AbstractReactFactory } from '@projectstorm/react-canvas-core';
|
||||
import { DiagramEngine } from '@projectstorm/react-diagrams-core';
|
||||
import { AbstractReactFactory } from '@projectstorm/react-diagrams';
|
||||
import { DiagramEngine } from '@projectstorm/react-diagrams';
|
||||
|
||||
export class TSCustomNodeFactory extends AbstractReactFactory<TSCustomNodeModel, DiagramEngine> {
|
||||
constructor() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { NodeModel, DefaultPortModel } from '@projectstorm/react-diagrams';
|
||||
import { BaseModelOptions } from '@projectstorm/react-canvas-core';
|
||||
import { BaseModelOptions, DefaultPortModel, NodeModel } from '@projectstorm/react-diagrams';
|
||||
|
||||
export interface TSCustomNodeModelOptions extends BaseModelOptions {
|
||||
color?: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { DiagramEngine, PortWidget } from '@projectstorm/react-diagrams-core';
|
||||
import { DiagramEngine, PortWidget } from '@projectstorm/react-diagrams';
|
||||
import { TSCustomNodeModel } from './TSCustomNodeModel';
|
||||
|
||||
export interface TSCustomNodeWidgetProps {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"jsx": "react",
|
||||
"allowJs": true,
|
||||
"target": "es6",
|
||||
"moduleResolution": "node"
|
||||
"module": "CommonJS"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const path = require('path');
|
||||
const production = process.env.NODE_ENV === 'production';
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
mode: production ? 'production' : 'development',
|
||||
@@ -23,8 +24,18 @@ module.exports = {
|
||||
})
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'index.html'
|
||||
})
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
enforce: 'pre',
|
||||
test: /\.js$/,
|
||||
loader: 'source-map-loader'
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'css-loader']
|
||||
@@ -36,18 +47,15 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true
|
||||
}
|
||||
loader: 'ts-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
compress: true,
|
||||
disableHostCheck: true,
|
||||
overlay: true
|
||||
client: {
|
||||
overlay: true
|
||||
},
|
||||
hot: false,
|
||||
compress: true
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ Joint JS \(a fantastic library\) + my need for rich HTML nodes + LabView + Blend
|
||||
|
||||
## Why render the nodes as HTML Elements and not SVG's?
|
||||
|
||||
My original requirement for this library stemmed from the requirement of wanting HTML nodes that would allow me to embed rich controls such as input fields, drop downs and have the system treat such nodes as first class citizens. I originally tried to make this work in JointJS, but ran into a number of problems of which this was a relatively big one.
|
||||
My original requirement for this library stemmed from the requirement of wanting HTML nodes that would allow me to embed rich controls such as input fields, dropdowns and have the system treat such nodes as first class citizens. I originally tried to make this work in JointJS, but ran into a number of problems of which this was a relatively big one.
|
||||
|
||||
JointJS does allow you to do this, but at the time of writing this library originally, I was having a lot of trouble to make it work exactly like I needed it, and therefore decided from the very beginning that I would attempt this with an HTML first mindset.
|
||||
|
||||
@@ -16,7 +16,7 @@ JointJS does allow you to do this, but at the time of writing this library origi
|
||||
|
||||
Firstly, because it can transpile into any level of ECMAScript. This means that I don't need to break our the refactor tractor every time ECMAScript decides it wants to add features which it should have done years ago.
|
||||
|
||||
I also ported it to Typescript to accommodate the heavy architectural changes I was starting to make. Since porting the library to typescript, and seeing the project explode in size and complexity, I consider this the best decision made with regards to this library so far.
|
||||
I also ported it to Typescript to accommodate the heavy architectural changes I was starting to make. Since porting the library to typescript, and seeing the project explode in size and complexity, I consider this the best decision made with regard to this library so far.
|
||||
|
||||
Porting to typescript also afforded us a set of powerful features such as generics and static analysis that all the project contributors have made exclusive use of.
|
||||
|
||||
@@ -24,11 +24,11 @@ Typescript is <3 typescript is life.
|
||||
|
||||
## Why not Flow instead of Typescript?
|
||||
|
||||
At the time when I first started evaluating languages that could transpile to ECMAScript, I was not so sold on the supporting environment surrounding flow, and and found that there was better tooling to support typescript, they are ultimately trying to do the same thing though, and I guess in the end, typescript just made more sense.
|
||||
At the time when I first started evaluating languages that could transpile to ECMAScript, I was not so sold on the supporting environment surrounding flow, and found that there was better tooling to support typescript, they are ultimately trying to do the same thing though, and I guess in the end, typescript just made more sense.
|
||||
|
||||
## Why React ?
|
||||
|
||||
React is really efficient at rendering and managing HTML in a declarative manner. React has also become one of the bigger industry standards and has a rich eco system that plays really well with typescript. Apart from these notable points, I am really fond of React and wanted a diagramming library that takes full advantage of it, and makes it easy for engineers to use its power as well, when extending this library.
|
||||
React is really efficient at rendering and managing HTML in a declarative manner. React has also become one of the bigger industry standards and has a rich ecosystem that plays really well with typescript. Apart from these notable points, I am really fond of React and wanted a diagramming library that takes full advantage of it, and makes it easy for engineers to use its power as well, when extending this library.
|
||||
|
||||
## Why cant the Default models and widgets do this or that ?
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## End to end testing
|
||||
|
||||
To test the functionality of the library, we make use of e2e tests \(end to end tests\). In this library, we spin up a headless chrome using pupeteer and interactively and programmatically tell the mouse pointer to click and drag on various elements while making assertions along the way.
|
||||
To test the functionality of the library, we make use of e2e tests \(end to end tests\). In this library, we spin up a headless chrome using puppeteer and interactively and programmatically tell the mouse pointer to click and drag on various elements while making assertions along the way.
|
||||
|
||||
We use Jest for the assertions and the interactivity is handled by puppeteer. Due to the laborious nature of writing e2e tests, there is a helper method that is provided in each test that makes interacting with the diagrams a lot easier. Using this helper, you can easily tell the mouse to drag links between nodes, select them and also easily assert information about them. The important thing here, is that this helper does not touch the model in any way, but is purely a helper for writing the tests themselves. Please make use of this helper when writing tests, as it ensure that the tests are defensive in nature, and also reduces the overhead of physically writing them.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Get the package
|
||||
|
||||
The first thing you need to do, is grab the distribution files on NPM. You can do this either using **yarn** or **npm.**
|
||||
The first thing you need to do, is grab the distribution files on NPM.
|
||||
|
||||
**Via yarn:**
|
||||
|
||||
@@ -16,25 +16,10 @@ yarn add @projectstorm/react-diagrams
|
||||
npm install @projectstorm/react-diagrams
|
||||
```
|
||||
|
||||
When you run this in your project directory, this will install the library into `./node_modules/@projectstorm/react-diagrams`. You will then find a **dist** folder that contains all the minified and production ready code.
|
||||
|
||||
## Install the peer dependencies
|
||||
|
||||
The library includes it's dependencies as peer-dependencies, so yarn will output warnings letting you know which ones are missing. Simple install them, specifically these ones:
|
||||
|
||||
**Via yarn:**
|
||||
**Via pnpm:**
|
||||
|
||||
```text
|
||||
yarn add closest lodash react dagre pathfinding paths-js @emotion/react @emotion/styled resize-observer-polyfill
|
||||
pnpm add @projectstorm/react-diagrams
|
||||
```
|
||||
|
||||
**Via npm:**
|
||||
|
||||
```text
|
||||
npm install closest lodash react dagre pathfinding paths-js @emotion/react @emotion/styled resize-observer-polyfill
|
||||
```
|
||||
|
||||
We do this, so that you can better control the versions of these libraries yourself since you might make use of `Lodash` in other parts of your software.
|
||||
|
||||
|
||||
|
||||
When you run this in your project directory, this will install the library into `./node_modules/@projectstorm/react-diagrams`. You will then find a **dist** folder that contains all the minified and production ready code.
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"version": "6.7.1-alpha.0"
|
||||
}
|
||||
90
package.json
90
package.json
@@ -6,11 +6,6 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/projectstorm/react-diagrams.git"
|
||||
},
|
||||
"workspaces": [
|
||||
"diagrams-demo-gallery",
|
||||
"diagrams-demo-project",
|
||||
"packages/*"
|
||||
],
|
||||
"keywords": [
|
||||
"web",
|
||||
"diagram",
|
||||
@@ -23,70 +18,31 @@
|
||||
"nodes"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "tsc --build --clean && lerna run clean --stream",
|
||||
"build": "tsc --build && lerna run build --stream",
|
||||
"build:prod": "NODE_ENV=production yarn build",
|
||||
"publish:dev": "yarn build:prod && lerna publish --force-publish --dist-tag=next",
|
||||
"publish:prod": "yarn build:prod && lerna publish --force-publish",
|
||||
"publish:storybook": "cd diagrams-demo-gallery && yarn storybook:build && ../node_modules/.bin/storybook-to-ghpages --existing-output-dir .out",
|
||||
"test:ci": "lerna run test --stream -- --runInBand --ci ",
|
||||
"test": "lerna run test --stream",
|
||||
"pretty": "prettier --write \"**/*.{ts,tsx,scss,js,jsx}\""
|
||||
},
|
||||
"peerDependencies": {
|
||||
"emotion": "11.*",
|
||||
"lodash": "4.*",
|
||||
"pathfinding": "^0.4.18",
|
||||
"paths-js": "^0.4.11",
|
||||
"react": "16.* || 17.*"
|
||||
"ncu": "ncu -u && pnpm recursive exec -- ncu -u",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,js,jsx}\"",
|
||||
"clean": "rm -rf packages/*/dist",
|
||||
"test": "pnpm run -r test",
|
||||
"build": "tsc --build && pnpm run -r build",
|
||||
"build:prod": "NODE_ENV=production pnpm build",
|
||||
"release": "pnpm build:prod && pnpm changeset publish",
|
||||
"release:storybook": "tsc --build && cd diagrams-demo-gallery && pnpm storybook:build && ./node_modules/.bin/storybook-to-ghpages --existing-output-dir .out"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.2",
|
||||
"@babel/preset-react": "^7.17.12",
|
||||
"@emotion/react": "^11.9.0",
|
||||
"@emotion/styled": "^11.8.1",
|
||||
"@types/dagre": "^0.7.47",
|
||||
"@types/jest": "^28.1.0",
|
||||
"@types/jest-environment-puppeteer": "^5.0.2",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/node": "^17.0.39",
|
||||
"@types/puppeteer": "^5.4.6",
|
||||
"@types/react": "^18.0.10",
|
||||
"babel-loader": "^8.2.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^6.7.1",
|
||||
"dagre": "^0.8.5",
|
||||
"emotion": "^11.0.0",
|
||||
"enzyme": "^3.11.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"glob": "^8.0.3",
|
||||
"jest": "^28.1.0",
|
||||
"jest-cli": "^28.1.0",
|
||||
"jest-puppeteer": "^6.1",
|
||||
"json-beautify": "^1.1.1",
|
||||
"lerna": "^5.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"pathfinding": "^0.4.18",
|
||||
"paths-js": "^0.4.11",
|
||||
"prettier": "^2.6.2",
|
||||
"puppeteer": "14.2.1",
|
||||
"raf": "^3.4.1",
|
||||
"raw-loader": "^4.0.2",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-test-renderer": "^18.1.0",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"source-map-loader": "^3.0.1",
|
||||
"style-loader": "^3.3.1",
|
||||
"terser-webpack-plugin": "^5.3.3",
|
||||
"ts-jest": "^28.0.4",
|
||||
"ts-loader": "^9.3.0",
|
||||
"typescript": "^4.7.3",
|
||||
"val-loader": "^5.0.0",
|
||||
"webpack": "^5.73.0",
|
||||
"webpack-cli": "^4.9.2",
|
||||
"webpack-dev-server": "^4.9.1",
|
||||
"@changesets/cli": "^2.26.2",
|
||||
"@types/jest": "^29.5.5",
|
||||
"@types/node": "^20.6.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-cli": "^29.7.0",
|
||||
"prettier": "^3.0.3",
|
||||
"rimraf": "^5.0.1",
|
||||
"source-map-loader": "^4.0.1",
|
||||
"terser-webpack-plugin": "^5.3.9",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-loader": "^9.4.4",
|
||||
"typescript": "^5.2.2",
|
||||
"webpack": "^5.88.2",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^4.15.1",
|
||||
"webpack-node-externals": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
|
||||
36
packages/geometry/CHANGELOG.md
Normal file
36
packages/geometry/CHANGELOG.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# @projectstorm/geometry
|
||||
|
||||
## 7.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/geometry",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.0.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -28,5 +28,10 @@
|
||||
"main": "./dist/index.umd.js",
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.199"
|
||||
}
|
||||
}
|
||||
|
||||
28
packages/geometry/src/Bounds.ts
Normal file
28
packages/geometry/src/Bounds.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Point } from './Point';
|
||||
|
||||
export enum BoundsCorner {
|
||||
TOP_LEFT = 'TL',
|
||||
TOP_RIGHT = 'TR',
|
||||
BOTTOM_RIGHT = 'BR',
|
||||
BOTTOM_LEFT = 'BL'
|
||||
}
|
||||
|
||||
export type Bounds = { [k in BoundsCorner]: Point };
|
||||
|
||||
export const boundsFromPositionAndSize = (x: number, y: number, width: number, height: number): Bounds => {
|
||||
return {
|
||||
[BoundsCorner.TOP_LEFT]: new Point(x, y),
|
||||
[BoundsCorner.TOP_RIGHT]: new Point(x + width, y),
|
||||
[BoundsCorner.BOTTOM_RIGHT]: new Point(x + width, y + height),
|
||||
[BoundsCorner.BOTTOM_LEFT]: new Point(x, y + height)
|
||||
};
|
||||
};
|
||||
|
||||
export const createEmptyBounds = () => {
|
||||
return {
|
||||
[BoundsCorner.TOP_LEFT]: new Point(),
|
||||
[BoundsCorner.TOP_RIGHT]: new Point(),
|
||||
[BoundsCorner.BOTTOM_RIGHT]: new Point(),
|
||||
[BoundsCorner.BOTTOM_LEFT]: new Point()
|
||||
};
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Point } from './Point';
|
||||
|
||||
export class Matrix {
|
||||
matrix: number[][];
|
||||
|
||||
@@ -19,4 +21,52 @@ export class Matrix {
|
||||
get(rowIndex: number, columnIndex: number): number {
|
||||
return this.asArray()[rowIndex][columnIndex];
|
||||
}
|
||||
|
||||
public static multiply(...matrices: Matrix[]): Matrix {
|
||||
let m: Matrix = matrices[0];
|
||||
for (let i = 1; i < matrices.length; i++) {
|
||||
m = m.mmul(matrices[i]);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
public static scaleMatrix(x: number, y: number): Matrix {
|
||||
return new Matrix([
|
||||
[x, 0, 0],
|
||||
[0, y, 0],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
public static translateMatrix(x: number, y: number): Matrix {
|
||||
return new Matrix([
|
||||
[1, 0, x],
|
||||
[0, 1, y],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
public static rotateMatrix(deg: number): Matrix {
|
||||
return new Matrix([
|
||||
[Math.cos(deg), -1 * Math.sin(deg), 0],
|
||||
[Math.sin(deg), Math.cos(deg), 0],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
static createScaleMatrix(x, y, origin: Point): Matrix {
|
||||
return this.multiply(
|
||||
Matrix.translateMatrix(origin.x, origin.y),
|
||||
Matrix.scaleMatrix(x, y),
|
||||
Matrix.translateMatrix(-origin.x, -origin.y)
|
||||
);
|
||||
}
|
||||
|
||||
static createRotateMatrix(deg: number, origin: Point): Matrix {
|
||||
return this.multiply(
|
||||
Matrix.translateMatrix(origin.x, origin.y),
|
||||
Matrix.rotateMatrix(deg),
|
||||
Matrix.translateMatrix(-origin.x, -origin.y)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export class Point {
|
||||
x: number;
|
||||
y: number;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
constructor(x: number = 0, y: number = 0) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
@@ -35,52 +35,4 @@ export class Point {
|
||||
public static middlePoint(pointA: Point, pointB: Point): Point {
|
||||
return new Point((pointB.x + pointA.x) / 2, (pointB.y + pointA.y) / 2);
|
||||
}
|
||||
|
||||
public static multiply(...matrices: Matrix[]): Matrix {
|
||||
let m: Matrix = matrices[0];
|
||||
for (let i = 1; i < matrices.length; i++) {
|
||||
m = m.mmul(matrices[i]);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
public static scaleMatrix(x: number, y: number): Matrix {
|
||||
return new Matrix([
|
||||
[x, 0, 0],
|
||||
[0, y, 0],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
public static translateMatrix(x: number, y: number): Matrix {
|
||||
return new Matrix([
|
||||
[1, 0, x],
|
||||
[0, 1, y],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
public static rotateMatrix(deg: number): Matrix {
|
||||
return new Matrix([
|
||||
[Math.cos(deg), -1 * Math.sin(deg), 0],
|
||||
[Math.sin(deg), Math.cos(deg), 0],
|
||||
[0, 0, 1]
|
||||
]);
|
||||
}
|
||||
|
||||
static createScaleMatrix(x, y, origin: Point): Matrix {
|
||||
return this.multiply(
|
||||
Point.translateMatrix(origin.x, origin.y),
|
||||
Point.scaleMatrix(x, y),
|
||||
Point.translateMatrix(-origin.x, -origin.y)
|
||||
);
|
||||
}
|
||||
|
||||
static createRotateMatrix(deg: number, origin: Point): Matrix {
|
||||
return this.multiply(
|
||||
Point.translateMatrix(origin.x, origin.y),
|
||||
Point.rotateMatrix(deg),
|
||||
Point.translateMatrix(-origin.x, -origin.y)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Point } from './Point';
|
||||
import * as _ from 'lodash';
|
||||
import { Matrix } from './Matrix';
|
||||
import { boundingBoxFromPoints } from './toolkit';
|
||||
import { Bounds, BoundsCorner } from './Bounds';
|
||||
|
||||
export class Polygon {
|
||||
protected points: Point[];
|
||||
@@ -22,7 +24,7 @@ export class Polygon {
|
||||
}
|
||||
|
||||
scale(x, y, origin: Point) {
|
||||
let matrix = Point.createScaleMatrix(x, y, origin);
|
||||
let matrix = Matrix.createScaleMatrix(x, y, origin);
|
||||
_.forEach(this.points, (point) => {
|
||||
point.transform(matrix);
|
||||
});
|
||||
@@ -43,7 +45,7 @@ export class Polygon {
|
||||
}
|
||||
|
||||
rotate(degrees: number) {
|
||||
this.transform(Point.createRotateMatrix(degrees / (180 / Math.PI), this.getOrigin()));
|
||||
this.transform(Matrix.createRotateMatrix(degrees / (180 / Math.PI), this.getOrigin()));
|
||||
}
|
||||
|
||||
translate(offsetX: number, offsetY: number) {
|
||||
@@ -68,69 +70,11 @@ export class Polygon {
|
||||
if (this.points.length === 0) {
|
||||
return null;
|
||||
}
|
||||
let dimensions = this.getBoundingBox();
|
||||
return Point.middlePoint(dimensions.getTopLeft(), dimensions.getBottomRight());
|
||||
let dimensions = boundingBoxFromPoints(this.points);
|
||||
return Point.middlePoint(dimensions[BoundsCorner.TOP_LEFT], dimensions[BoundsCorner.BOTTOM_RIGHT]);
|
||||
}
|
||||
|
||||
static boundingBoxFromPolygons(polygons: Polygon[]): Rectangle {
|
||||
return Polygon.boundingBoxFromPoints(
|
||||
_.flatMap(polygons, (polygon) => {
|
||||
return polygon.getPoints();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
static boundingBoxFromPoints(points: Point[]): Rectangle {
|
||||
if (points.length === 0) {
|
||||
return new Rectangle(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
let minX = points[0].x;
|
||||
let maxX = points[0].x;
|
||||
let minY = points[0].y;
|
||||
let maxY = points[0].y;
|
||||
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
if (points[i].x < minX) {
|
||||
minX = points[i].x;
|
||||
}
|
||||
if (points[i].x > maxX) {
|
||||
maxX = points[i].x;
|
||||
}
|
||||
if (points[i].y < minY) {
|
||||
minY = points[i].y;
|
||||
}
|
||||
if (points[i].y > maxY) {
|
||||
maxY = points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
return new Rectangle(new Point(minX, minY), new Point(maxX, minY), new Point(maxX, maxY), new Point(minX, maxY));
|
||||
}
|
||||
|
||||
getBoundingBox(): Rectangle {
|
||||
let minX = this.points[0].x;
|
||||
let maxX = this.points[0].x;
|
||||
let minY = this.points[0].y;
|
||||
let maxY = this.points[0].y;
|
||||
|
||||
for (let i = 1; i < this.points.length; i++) {
|
||||
if (this.points[i].x < minX) {
|
||||
minX = this.points[i].x;
|
||||
}
|
||||
if (this.points[i].x > maxX) {
|
||||
maxX = this.points[i].x;
|
||||
}
|
||||
if (this.points[i].y < minY) {
|
||||
minY = this.points[i].y;
|
||||
}
|
||||
if (this.points[i].y > maxY) {
|
||||
maxY = this.points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
return new Rectangle(new Point(minX, minY), new Point(maxX, minY), new Point(maxX, maxY), new Point(minX, maxY));
|
||||
getBoundingBox(): Bounds {
|
||||
return boundingBoxFromPoints(this.points);
|
||||
}
|
||||
}
|
||||
|
||||
import { Rectangle } from './Rectangle';
|
||||
|
||||
@@ -1,27 +1,37 @@
|
||||
import { Point } from './Point';
|
||||
import { Polygon } from './Polygon';
|
||||
import { Bounds, BoundsCorner, boundsFromPositionAndSize, createEmptyBounds } from './Bounds';
|
||||
|
||||
export class Rectangle extends Polygon {
|
||||
constructor(tl: Point, tr: Point, br: Point, bl: Point);
|
||||
constructor(position: Point, width: number, height: number);
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
|
||||
constructor(a: any = 0, b: any = 0, c: any = 0, d: any = 0) {
|
||||
if (a instanceof Point && b instanceof Point && c instanceof Point && d instanceof Point) {
|
||||
super([a, b, c, d]);
|
||||
} else if (a instanceof Point) {
|
||||
super([a, new Point(a.x + b, a.y), new Point(a.x + b, a.y + c), new Point(a.x, a.y + c)]);
|
||||
} else {
|
||||
super(Rectangle.pointsFromBounds(a, b, c, d));
|
||||
}
|
||||
static fromPositionAndSize(x: number, y: number, width: number, height: number) {
|
||||
return new Rectangle(boundsFromPositionAndSize(x, y, width, height));
|
||||
}
|
||||
|
||||
static pointsFromBounds(x: number, y: number, width: number, height: number): Point[] {
|
||||
return [new Point(x, y), new Point(x + width, y), new Point(x + width, y + height), new Point(x, y + height)];
|
||||
static fromPointAndSize(position: Point, width: number, height: number) {
|
||||
return new Rectangle(boundsFromPositionAndSize(position.x, position.y, width, height));
|
||||
}
|
||||
|
||||
constructor(points?: Bounds) {
|
||||
if (!points) {
|
||||
points = createEmptyBounds();
|
||||
}
|
||||
|
||||
super([
|
||||
points[BoundsCorner.TOP_LEFT],
|
||||
points[BoundsCorner.TOP_RIGHT],
|
||||
points[BoundsCorner.BOTTOM_RIGHT],
|
||||
points[BoundsCorner.BOTTOM_LEFT]
|
||||
]);
|
||||
}
|
||||
|
||||
updateDimensions(x: number, y: number, width: number, height: number) {
|
||||
this.points = Rectangle.pointsFromBounds(x, y, width, height);
|
||||
const points = boundsFromPositionAndSize(x, y, width, height);
|
||||
this.setPoints([
|
||||
points[BoundsCorner.TOP_LEFT],
|
||||
points[BoundsCorner.TOP_RIGHT],
|
||||
points[BoundsCorner.BOTTOM_RIGHT],
|
||||
points[BoundsCorner.BOTTOM_LEFT]
|
||||
]);
|
||||
}
|
||||
|
||||
setPoints(points: Point[]) {
|
||||
|
||||
@@ -3,3 +3,5 @@ export * from './Matrix';
|
||||
export * from './Polygon';
|
||||
export * from './Rectangle';
|
||||
export * from './BezierCurve';
|
||||
export * from './toolkit';
|
||||
export * from './Bounds';
|
||||
|
||||
45
packages/geometry/src/toolkit.ts
Normal file
45
packages/geometry/src/toolkit.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Point } from './Point';
|
||||
import * as _ from 'lodash';
|
||||
import { Polygon } from './Polygon';
|
||||
import { Bounds, BoundsCorner, createEmptyBounds } from './Bounds';
|
||||
|
||||
export const boundingBoxFromPoints = (points: Point[]): Bounds => {
|
||||
if (points.length === 0) {
|
||||
return createEmptyBounds();
|
||||
}
|
||||
|
||||
let minX = points[0].x;
|
||||
let maxX = points[0].x;
|
||||
let minY = points[0].y;
|
||||
let maxY = points[0].y;
|
||||
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
if (points[i].x < minX) {
|
||||
minX = points[i].x;
|
||||
}
|
||||
if (points[i].x > maxX) {
|
||||
maxX = points[i].x;
|
||||
}
|
||||
if (points[i].y < minY) {
|
||||
minY = points[i].y;
|
||||
}
|
||||
if (points[i].y > maxY) {
|
||||
maxY = points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
[BoundsCorner.TOP_LEFT]: new Point(minX, minY),
|
||||
[BoundsCorner.TOP_RIGHT]: new Point(maxX, minY),
|
||||
[BoundsCorner.BOTTOM_RIGHT]: new Point(maxX, maxY),
|
||||
[BoundsCorner.BOTTOM_LEFT]: new Point(minX, maxY)
|
||||
};
|
||||
};
|
||||
|
||||
export const boundingBoxFromPolygons = (polygons: Polygon[]): Bounds => {
|
||||
return boundingBoxFromPoints(
|
||||
_.flatMap(polygons, (polygon) => {
|
||||
return polygon.getPoints();
|
||||
})
|
||||
);
|
||||
};
|
||||
@@ -3,7 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"sourceMap": true,
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
|
||||
45
packages/react-canvas-core/CHANGELOG.md
Normal file
45
packages/react-canvas-core/CHANGELOG.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# @projectstorm/react-canvas-core
|
||||
|
||||
## 7.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/geometry@7.0.2
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/geometry@7.0.1
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/geometry@7.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-canvas-core",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.0.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -29,11 +29,14 @@
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/geometry": "^6.7.1-alpha.0"
|
||||
"@emotion/react": "^11.11.1",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@projectstorm/geometry": "workspace:*",
|
||||
"react": "^18.2.0",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"lodash": "4.*",
|
||||
"react": "16.* || 17.*"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.22",
|
||||
"@types/lodash": "^4.14.199"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Toolkit } from '../Toolkit';
|
||||
import * as _ from 'lodash';
|
||||
import { CanvasEngine } from '../CanvasEngine';
|
||||
import { BaseEvent, BaseListener, BaseObserver } from '../core/BaseObserver';
|
||||
import { AbstractModelFactory } from '../core/AbstractModelFactory';
|
||||
import { BaseModel } from './BaseModel';
|
||||
|
||||
export interface BaseEntityEvent<T extends BaseEntity = BaseEntity> extends BaseEvent {
|
||||
@@ -13,6 +12,9 @@ export interface BaseEntityListener<T extends BaseEntity = BaseEntity> extends B
|
||||
lockChanged?(event: BaseEntityEvent<T> & { locked: boolean }): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO move to enums
|
||||
*/
|
||||
export type BaseEntityType = 'node' | 'link' | 'port' | 'point';
|
||||
|
||||
export interface BaseEntityOptions {
|
||||
|
||||
@@ -39,7 +39,7 @@ export class BasePositionModel<G extends BasePositionModelGenerics = BasePositio
|
||||
}
|
||||
|
||||
getBoundingBox(): Rectangle {
|
||||
return new Rectangle(this.position, 0, 0);
|
||||
return Rectangle.fromPointAndSize(this.position, 0, 0);
|
||||
}
|
||||
|
||||
deserialize(event: DeserializeEvent<this>) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { LayerModel } from '../layer/LayerModel';
|
||||
import { BaseModel } from '../../core-models/BaseModel';
|
||||
import { CanvasEngine } from '../../CanvasEngine';
|
||||
|
||||
export interface DiagramListener extends BaseEntityListener {
|
||||
export interface CanvasModelListener extends BaseEntityListener {
|
||||
offsetUpdated?(event: BaseEntityEvent<CanvasModel> & { offsetX: number; offsetY: number }): void;
|
||||
|
||||
zoomUpdated?(event: BaseEntityEvent<CanvasModel> & { zoom: number }): void;
|
||||
@@ -19,7 +19,7 @@ export interface DiagramListener extends BaseEntityListener {
|
||||
gridUpdated?(event: BaseEntityEvent<CanvasModel> & { size: number }): void;
|
||||
}
|
||||
|
||||
export interface DiagramModelOptions extends BaseEntityOptions {
|
||||
export interface CanvasModelOptions extends BaseEntityOptions {
|
||||
offsetX?: number;
|
||||
offsetY?: number;
|
||||
zoom?: number;
|
||||
@@ -27,8 +27,8 @@ export interface DiagramModelOptions extends BaseEntityOptions {
|
||||
}
|
||||
|
||||
export interface CanvasModelGenerics extends BaseEntityGenerics {
|
||||
LISTENER: DiagramListener;
|
||||
OPTIONS: DiagramModelOptions;
|
||||
LISTENER: CanvasModelListener;
|
||||
OPTIONS: CanvasModelOptions;
|
||||
LAYER: LayerModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AbstractDisplacementState, AbstractDisplacementStateEvent } from '../co
|
||||
import { State } from '../core-state/State';
|
||||
import { SelectionLayerModel } from '../entities/selection/SelectionLayerModel';
|
||||
import { Point, Rectangle } from '@projectstorm/geometry';
|
||||
import { BasePositionModel } from '../core-models/BasePositionModel';
|
||||
import { ModelGeometryInterface } from '../core/ModelGeometryInterface';
|
||||
|
||||
export interface SimpleClientRect {
|
||||
@@ -67,7 +68,11 @@ export class SelectionBoxState extends AbstractDisplacementState {
|
||||
if (event.virtualDisplacementY < 0) {
|
||||
relative.y -= Math.abs(event.virtualDisplacementY);
|
||||
}
|
||||
const rect = new Rectangle(relative, Math.abs(event.virtualDisplacementX), Math.abs(event.virtualDisplacementY));
|
||||
const rect = Rectangle.fromPointAndSize(
|
||||
relative,
|
||||
Math.abs(event.virtualDisplacementX),
|
||||
Math.abs(event.virtualDisplacementY)
|
||||
);
|
||||
|
||||
for (let model of this.engine.getModel().getSelectionEntities()) {
|
||||
if ((model as unknown as ModelGeometryInterface).getBoundingBox) {
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../geometry"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
|
||||
@@ -1,15 +1,62 @@
|
||||
# Changelog
|
||||
|
||||
## 7.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/react-canvas-core@7.0.2
|
||||
- @projectstorm/geometry@7.0.2
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/geometry@7.0.1
|
||||
- @projectstorm/react-canvas-core@7.0.1
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-canvas-core@7.0.0
|
||||
- @projectstorm/geometry@7.0.0
|
||||
|
||||
## 6.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* `AbstractFactory:getNewInstance` renamed to `AbstractFactory:generateModel` and now gets given an event object
|
||||
so that we can add to the event object without relying on more parameters
|
||||
- `AbstractFactory:getNewInstance` renamed to `AbstractFactory:generateModel` and now gets given an event object
|
||||
so that we can add to the event object without relying on more parameters
|
||||
|
||||
* `AbstractFactory::generateReactWidget` now receives an event object
|
||||
- `AbstractFactory::generateReactWidget` now receives an event object
|
||||
|
||||
* Moved factories in the diagramEngine into `FactoryBank`'s, which means we can remove the listeners in the DiagramEngine.
|
||||
methods such as factoryAdded and factoryRemoved are now available on the FactoryBank (better design that allows more control)
|
||||
- Moved factories in the diagramEngine into `FactoryBank`'s, which means we can remove the listeners in the DiagramEngine.
|
||||
methods such as factoryAdded and factoryRemoved are now available on the FactoryBank (better design that allows more control)
|
||||
|
||||
* `addListener` renamed to `registerListener`
|
||||
- `addListener` renamed to `registerListener`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-core",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.0.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -31,13 +31,15 @@
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/geometry": "^6.7.1-alpha.0",
|
||||
"@projectstorm/react-canvas-core": "^6.7.1-alpha.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"lodash": "4.*",
|
||||
"react": "18.*",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@projectstorm/geometry": "workspace:*",
|
||||
"@projectstorm/react-canvas-core": "workspace:*",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.2.0",
|
||||
"resize-observer-polyfill": "^1.5.1"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.22",
|
||||
"@types/lodash": "^4.14.199"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ import { NodeModel } from './entities/node/NodeModel';
|
||||
import { PortModel } from './entities/port/PortModel';
|
||||
import { LinkModel } from './entities/link/LinkModel';
|
||||
import { LabelModel } from './entities/label/LabelModel';
|
||||
import { Point, Rectangle, Polygon } from '@projectstorm/geometry';
|
||||
import { boundingBoxFromPolygons, Point, Rectangle } from '@projectstorm/geometry';
|
||||
import { MouseEvent } from 'react';
|
||||
import {
|
||||
AbstractModelFactory,
|
||||
AbstractReactFactory,
|
||||
BaseModel,
|
||||
CanvasEngine,
|
||||
FactoryBank,
|
||||
Toolkit,
|
||||
CanvasEngineListener,
|
||||
CanvasEngineOptions
|
||||
CanvasEngineOptions,
|
||||
FactoryBank,
|
||||
Toolkit
|
||||
} from '@projectstorm/react-canvas-core';
|
||||
import { DiagramModel } from './models/DiagramModel';
|
||||
|
||||
@@ -187,7 +187,7 @@ export class DiagramEngine extends CanvasEngine<CanvasEngineListener, DiagramMod
|
||||
clientY: sourceRect.top
|
||||
});
|
||||
const zoom = this.model.getZoomLevel() / 100.0;
|
||||
return new Rectangle(point.x, point.y, sourceRect.width / zoom, sourceRect.height / zoom);
|
||||
return Rectangle.fromPointAndSize(point, sourceRect.width / zoom, sourceRect.height / zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,10 +214,9 @@ export class DiagramEngine extends CanvasEngine<CanvasEngineListener, DiagramMod
|
||||
getBoundingNodesRect(nodes: NodeModel[]): Rectangle {
|
||||
if (nodes) {
|
||||
if (nodes.length === 0) {
|
||||
return new Rectangle(0, 0, 0, 0);
|
||||
return new Rectangle();
|
||||
}
|
||||
|
||||
return Polygon.boundingBoxFromPolygons(nodes.map((node) => node.getBoundingBox()));
|
||||
return new Rectangle(boundingBoxFromPolygons(nodes.map((node) => node.getBoundingBox())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { DiagramEngine } from '../../DiagramEngine';
|
||||
import { LinkModel } from '../link/LinkModel';
|
||||
import { BaseModel, BaseModelGenerics, BaseModelOptions, DeserializeEvent } from '@projectstorm/react-canvas-core';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as _ from 'lodash';
|
||||
import { LabelModel } from '../label/LabelModel';
|
||||
import { DiagramEngine } from '../../DiagramEngine';
|
||||
import { DiagramModel } from '../../models/DiagramModel';
|
||||
import { Point, Polygon, Rectangle } from '@projectstorm/geometry';
|
||||
import { boundingBoxFromPoints, Point, Rectangle } from '@projectstorm/geometry';
|
||||
import {
|
||||
BaseEntityEvent,
|
||||
BaseModel,
|
||||
@@ -54,10 +54,12 @@ export class LinkModel<G extends LinkModelGenerics = LinkModelGenerics>
|
||||
}
|
||||
|
||||
getBoundingBox(): Rectangle {
|
||||
return Polygon.boundingBoxFromPoints(
|
||||
_.map(this.points, (point: PointModel) => {
|
||||
return point.getPosition();
|
||||
})
|
||||
return new Rectangle(
|
||||
boundingBoxFromPoints(
|
||||
_.map(this.points, (point: PointModel) => {
|
||||
return point.getPosition();
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import * as _ from 'lodash';
|
||||
import { NodeModel } from '../node/NodeModel';
|
||||
import { NodeWidget } from '../node/NodeWidget';
|
||||
@@ -11,10 +10,6 @@ export interface NodeLayerWidgetProps {
|
||||
engine: DiagramEngine;
|
||||
}
|
||||
|
||||
namespace S {
|
||||
export const Container = styled.div``;
|
||||
}
|
||||
|
||||
export class NodeLayerWidget extends React.Component<NodeLayerWidgetProps> {
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -36,7 +36,7 @@ export class NodeModel<G extends NodeModelGenerics = NodeModelGenerics> extends
|
||||
}
|
||||
|
||||
getBoundingBox(): Rectangle {
|
||||
return new Rectangle(this.getPosition(), this.width, this.height);
|
||||
return Rectangle.fromPointAndSize(this.getPosition(), this.width, this.height);
|
||||
}
|
||||
|
||||
setPosition(point: Point): void;
|
||||
|
||||
@@ -143,7 +143,7 @@ export class PortModel<G extends PortModelGenerics = PortModelGenerics> extends
|
||||
}
|
||||
|
||||
getBoundingBox(): Rectangle {
|
||||
return new Rectangle(this.position, this.width, this.height);
|
||||
return Rectangle.fromPointAndSize(this.position, this.width, this.height);
|
||||
}
|
||||
|
||||
updateCoords(coords: Rectangle) {
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../react-canvas-core"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
|
||||
61
packages/react-diagrams-defaults/CHANGELOG.md
Normal file
61
packages/react-diagrams-defaults/CHANGELOG.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# @projectstorm/react-diagrams-defaults
|
||||
|
||||
## 7.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/react-diagrams-core@7.0.2
|
||||
- @projectstorm/react-canvas-core@7.0.2
|
||||
- @projectstorm/geometry@7.0.2
|
||||
|
||||
## 7.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/geometry@7.0.1
|
||||
- @projectstorm/react-canvas-core@7.0.1
|
||||
- @projectstorm/react-diagrams-core@7.0.1
|
||||
|
||||
## 7.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e0d21f1: - [feature] new ability to refresh links in auto distribute system [PR 756](https://github.com/projectstorm/react-diagrams/pull/756)
|
||||
|
||||
- [fix] Default link now uses the correct method for creating a point allowing this to be overridden [PR 939](https://github.com/projectstorm/react-diagrams/pull/939)
|
||||
|
||||
Big thanks to @ToTheHit and @h0111in for your help on these, even though its very delayed on my part :)
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-diagrams-core@7.0.0
|
||||
- @projectstorm/react-canvas-core@7.0.0
|
||||
- @projectstorm/geometry@7.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-defaults",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.1.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -29,13 +29,16 @@
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/react-diagrams-core": "^6.7.1-alpha.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@emotion/react": "^11.*",
|
||||
"@emotion/react": "^11.11.1",
|
||||
"@emotion/styled": "^11.*",
|
||||
"lodash": "4.*",
|
||||
"react": "18.*"
|
||||
"@projectstorm/geometry": "workspace:*",
|
||||
"@projectstorm/react-canvas-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-core": "workspace:*",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.199",
|
||||
"@types/react": "^18.2.22"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DiagramEngine, LabelModel, LabelModelGenerics, LabelModelOptions } from '@projectstorm/react-diagrams-core';
|
||||
import { LabelModel, LabelModelGenerics, LabelModelOptions } from '@projectstorm/react-diagrams-core';
|
||||
import { DeserializeEvent } from '@projectstorm/react-canvas-core';
|
||||
|
||||
export interface DefaultLabelModelOptions extends LabelModelOptions {
|
||||
|
||||
@@ -58,11 +58,8 @@ export class DefaultLinkWidget extends React.Component<DefaultLinkProps, Default
|
||||
!this.props.link.isLocked() &&
|
||||
this.props.link.getPoints().length - 1 <= this.props.diagramEngine.getMaxNumberPointsPerLink()
|
||||
) {
|
||||
const point = new PointModel({
|
||||
link: this.props.link,
|
||||
position: this.props.diagramEngine.getRelativeMousePoint(event)
|
||||
});
|
||||
this.props.link.addPoint(point, index);
|
||||
const position = this.props.diagramEngine.getRelativeMousePoint(event);
|
||||
const point = this.props.link.point(position.x, position.y, index);
|
||||
event.persist();
|
||||
event.stopPropagation();
|
||||
this.forceUpdate(() => {
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../react-diagrams-core"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
69
packages/react-diagrams-routing/CHANGELOG.md
Normal file
69
packages/react-diagrams-routing/CHANGELOG.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# @projectstorm/react-diagrams-routing
|
||||
|
||||
## 7.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 66c687a: Upgrade all dependencies and fix Storybook after upgrade
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.2
|
||||
- @projectstorm/react-diagrams-core@7.0.2
|
||||
- @projectstorm/react-canvas-core@7.0.2
|
||||
- @projectstorm/geometry@7.0.2
|
||||
|
||||
## 7.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/geometry@7.0.1
|
||||
- @projectstorm/react-canvas-core@7.0.1
|
||||
- @projectstorm/react-diagrams-core@7.0.1
|
||||
- @projectstorm/react-diagrams-defaults@7.1.1
|
||||
|
||||
## 7.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e0d21f1: - [feature] new ability to refresh links in auto distribute system [PR 756](https://github.com/projectstorm/react-diagrams/pull/756)
|
||||
|
||||
- [fix] Default link now uses the correct method for creating a point allowing this to be overridden [PR 939](https://github.com/projectstorm/react-diagrams/pull/939)
|
||||
|
||||
Big thanks to @ToTheHit and @h0111in for your help on these, even though its very delayed on my part :)
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e0d21f1]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.0
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-diagrams-defaults@7.0.0
|
||||
- @projectstorm/react-diagrams-core@7.0.0
|
||||
- @projectstorm/react-canvas-core@7.0.0
|
||||
- @projectstorm/geometry@7.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams-routing",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.1.2",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -30,16 +30,19 @@
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/geometry": "^6.7.1-alpha.0",
|
||||
"@projectstorm/react-diagrams-core": "^6.7.1-alpha.0",
|
||||
"@projectstorm/react-diagrams-defaults": "^6.7.1-alpha.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@projectstorm/geometry": "workspace:*",
|
||||
"@projectstorm/react-canvas-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-defaults": "workspace:*",
|
||||
"dagre": "^0.8.5",
|
||||
"lodash": "4.*",
|
||||
"lodash": "^4.17.21",
|
||||
"pathfinding": "^0.4.18",
|
||||
"paths-js": "^0.4.11",
|
||||
"react": "18.*"
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"devDependencies": {
|
||||
"@types/dagre": "^0.7.50",
|
||||
"@types/lodash": "^4.14.199",
|
||||
"@types/react": "^18.2.22"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { DiagramModel, PointModel } from '@projectstorm/react-diagrams-core';
|
||||
import * as dagre from 'dagre';
|
||||
import * as _ from 'lodash';
|
||||
import { GraphLabel } from 'dagre';
|
||||
import * as _ from 'lodash';
|
||||
import { Point } from '@projectstorm/geometry';
|
||||
|
||||
export interface DagreEngineOptions {
|
||||
graph?: GraphLabel;
|
||||
/**
|
||||
* Will also layout links
|
||||
* Will also re-layout links
|
||||
*/
|
||||
includeLinks?: boolean;
|
||||
nodeMargin?: number;
|
||||
}
|
||||
|
||||
export class DagreEngine {
|
||||
@@ -68,4 +69,184 @@ export class DagreEngine {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO cleanup this method into smaller methods
|
||||
*/
|
||||
public refreshLinks(diagram: DiagramModel) {
|
||||
const { nodeMargin } = this.options;
|
||||
const nodes = diagram.getNodes();
|
||||
const links = diagram.getLinks();
|
||||
let maxChunkRowIndex = -1;
|
||||
// build the chunk matrix
|
||||
const chunks: { [id: number]: { [id: number]: boolean } } = {}; // true: occupied, false: blank
|
||||
const NodeXColumnIndexDictionary: { [id: number]: number } = {};
|
||||
let verticalLines: number[] = [];
|
||||
_.forEach(nodes, (node) => {
|
||||
// find vertical lines. vertical lines go through maximum number of nodes located under each other.
|
||||
const nodeColumnCenter = node.getX() + node.width / 2;
|
||||
if (
|
||||
_.every(verticalLines, (vLine) => {
|
||||
return Math.abs(nodeColumnCenter - vLine) > nodeMargin;
|
||||
})
|
||||
) {
|
||||
verticalLines.push(nodeColumnCenter);
|
||||
}
|
||||
});
|
||||
|
||||
// sort chunk columns
|
||||
verticalLines = verticalLines.sort((a, b) => a - b);
|
||||
_.forEach(verticalLines, (line, index) => {
|
||||
chunks[index] = {};
|
||||
chunks[index + 0.5] = {};
|
||||
});
|
||||
|
||||
// set occupied chunks
|
||||
_.forEach(nodes, (node) => {
|
||||
const nodeColumnCenter = node.getX() + node.width / 2;
|
||||
const startChunkIndex = Math.floor(node.getY() / nodeMargin);
|
||||
const endChunkIndex = Math.floor((node.getY() + node.height) / nodeMargin);
|
||||
// find max ChunkRowIndex
|
||||
if (endChunkIndex > maxChunkRowIndex) maxChunkRowIndex = endChunkIndex;
|
||||
const nodeColumnIndex = _.findIndex(verticalLines, (vLine) => {
|
||||
return Math.abs(nodeColumnCenter - vLine) <= nodeMargin;
|
||||
});
|
||||
_.forEach(_.range(startChunkIndex, endChunkIndex + 1), (chunkIndex) => {
|
||||
chunks[nodeColumnIndex][chunkIndex] = true;
|
||||
});
|
||||
NodeXColumnIndexDictionary[node.getX()] = nodeColumnIndex;
|
||||
});
|
||||
|
||||
// sort links based on their distances
|
||||
const edges = _.map(links, (link) => {
|
||||
if (link.getSourcePort() && link.getTargetPort()) {
|
||||
const source = link.getSourcePort().getNode();
|
||||
const target = link.getTargetPort().getNode();
|
||||
const sourceIndex = NodeXColumnIndexDictionary[source.getX()];
|
||||
const targetIndex = NodeXColumnIndexDictionary[target.getX()];
|
||||
|
||||
return sourceIndex > targetIndex
|
||||
? {
|
||||
link,
|
||||
sourceIndex,
|
||||
sourceY: source.getY() + source.height / 2,
|
||||
source,
|
||||
targetIndex,
|
||||
targetY: target.getY() + source.height / 2,
|
||||
target
|
||||
}
|
||||
: {
|
||||
link,
|
||||
sourceIndex: targetIndex,
|
||||
sourceY: target.getY() + target.height / 2,
|
||||
source: target,
|
||||
targetIndex: sourceIndex,
|
||||
targetY: source.getY() + source.height / 2,
|
||||
target: source
|
||||
};
|
||||
}
|
||||
});
|
||||
const sortedEdges = _.sortBy(edges, (link) => {
|
||||
return Math.abs(link.targetIndex - link.sourceIndex);
|
||||
});
|
||||
|
||||
// set link points
|
||||
if (this.options.includeLinks) {
|
||||
_.forEach(sortedEdges, (edge) => {
|
||||
const link = diagram.getLink(edge.link.getID());
|
||||
// re-draw
|
||||
if (Math.abs(edge.sourceIndex - edge.targetIndex) > 1) {
|
||||
// get the length of link in column
|
||||
const columns = _.range(edge.sourceIndex - 1, edge.targetIndex);
|
||||
|
||||
const chunkIndex = Math.floor(edge.sourceY / nodeMargin);
|
||||
const targetChunkIndex = Math.floor(edge.targetY / nodeMargin);
|
||||
|
||||
// check upper paths
|
||||
let northCost = 1;
|
||||
let aboveRowIndex = chunkIndex;
|
||||
for (; aboveRowIndex >= 0; aboveRowIndex--, northCost++) {
|
||||
if (
|
||||
_.every(columns, (columnIndex) => {
|
||||
return !(
|
||||
chunks[columnIndex][aboveRowIndex] ||
|
||||
chunks[columnIndex + 0.5][aboveRowIndex] ||
|
||||
chunks[columnIndex - 0.5][aboveRowIndex]
|
||||
);
|
||||
})
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check lower paths
|
||||
let southCost = 0;
|
||||
let belowRowIndex = chunkIndex;
|
||||
for (; belowRowIndex <= maxChunkRowIndex; belowRowIndex++, southCost++) {
|
||||
if (
|
||||
_.every(columns, (columnIndex) => {
|
||||
return !(
|
||||
chunks[columnIndex][belowRowIndex] ||
|
||||
chunks[columnIndex + 0.5][belowRowIndex] ||
|
||||
chunks[columnIndex - 0.5][belowRowIndex]
|
||||
);
|
||||
})
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// pick the cheapest path
|
||||
const pathRowIndex =
|
||||
southCost + (belowRowIndex - targetChunkIndex) < northCost + (targetChunkIndex - aboveRowIndex)
|
||||
? belowRowIndex + 1
|
||||
: aboveRowIndex - 1;
|
||||
|
||||
// Finally update the link points
|
||||
const points = [link.getFirstPoint()];
|
||||
points.push(
|
||||
new PointModel({
|
||||
link: link,
|
||||
position: new Point(
|
||||
(verticalLines[columns[0]] + verticalLines[columns[0] + 1]) / 2,
|
||||
(pathRowIndex + 0.5) * nodeMargin
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
_.forEach(columns, (column) => {
|
||||
points.push(
|
||||
new PointModel({
|
||||
link: link,
|
||||
position: new Point(verticalLines[column], (pathRowIndex + 0.5) * nodeMargin)
|
||||
})
|
||||
);
|
||||
points.push(
|
||||
new PointModel({
|
||||
link: link,
|
||||
position: new Point(
|
||||
(verticalLines[column] + verticalLines[column - 1]) / 2,
|
||||
(pathRowIndex + 0.5) * nodeMargin
|
||||
)
|
||||
})
|
||||
);
|
||||
chunks[column][pathRowIndex] = true;
|
||||
chunks[column][pathRowIndex + 1] = true;
|
||||
chunks[column + 0.5][pathRowIndex] = true;
|
||||
chunks[column + 0.5][pathRowIndex + 1] = true;
|
||||
});
|
||||
link.setPoints(points.concat(link.getLastPoint()));
|
||||
} else {
|
||||
// refresh
|
||||
link.setPoints([link.getFirstPoint(), link.getLastPoint()]);
|
||||
const columnIndex = (edge.sourceIndex + edge.targetIndex) / 2;
|
||||
if (!chunks[columnIndex]) {
|
||||
chunks[columnIndex] = {};
|
||||
}
|
||||
const rowIndex = Math.floor((edge.sourceY + edge.targetY) / 2 / nodeMargin);
|
||||
chunks[columnIndex][rowIndex] = true;
|
||||
chunks[columnIndex][rowIndex + 1] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { RightAngleLinkWidget } from './RightAngleLinkWidget';
|
||||
import { DiagramEngine } from '@projectstorm/react-diagrams-core';
|
||||
import { DefaultLinkFactory, DefaultLinkModel } from '@projectstorm/react-diagrams-defaults';
|
||||
import { DefaultLinkFactory } from '@projectstorm/react-diagrams-defaults';
|
||||
import { RightAngleLinkModel } from './RightAngleLinkModel';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src/**/*
|
||||
!dist/**/*
|
||||
!package.json
|
||||
!README.md
|
||||
dist/tsconfig.tsbuildinfo
|
||||
|
||||
61
packages/react-diagrams/CHANGELOG.md
Normal file
61
packages/react-diagrams/CHANGELOG.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# @projectstorm/react-diagrams
|
||||
|
||||
## 7.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [66c687a]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.2
|
||||
- @projectstorm/react-diagrams-routing@7.1.2
|
||||
- @projectstorm/react-diagrams-core@7.0.2
|
||||
- @projectstorm/react-canvas-core@7.0.2
|
||||
|
||||
## 7.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8a4cbd: Inline sources in sourcemap
|
||||
- Updated dependencies [b8a4cbd]
|
||||
- @projectstorm/react-canvas-core@7.0.1
|
||||
- @projectstorm/react-diagrams-core@7.0.1
|
||||
- @projectstorm/react-diagrams-defaults@7.1.1
|
||||
- @projectstorm/react-diagrams-routing@7.1.1
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e0d21f1]
|
||||
- @projectstorm/react-diagrams-defaults@7.1.0
|
||||
- @projectstorm/react-diagrams-routing@7.1.0
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- b051697: - [internal] moves to `Pnpm` (instead of yarn -\_-)
|
||||
- [internal]moves to `Changesets` for releases
|
||||
- [internal]removes `Lerna`
|
||||
- [internal] upgrades all dependencies
|
||||
- [internal] switches to workspace protocol syntax (Changesets will bake in the correct version when a publish occurs)
|
||||
- [internal] Changesets will open a release PR which can wrap up several changes in 1 go
|
||||
- [internal] Changesets will run the storybook deploy automatically upon merging the release PR
|
||||
- [internal] removes a lot of the stuff from the root package.json
|
||||
- [internal] cleans up the build and clean commands
|
||||
- [internal] remove E2E tests, they are a nightmare to maintain and the ROI is far too low
|
||||
- [fix] Wrong type name for react-canvas model listener
|
||||
- [fix] export more stuff form the main react-diagrams package
|
||||
- [fix] circular deps with Rectangle and Polygon (turns out this was a problem but only with UMD builds, sorry @everyone who I doubted, but this is also why I could never reproduce the issue)
|
||||
- [breaking change] compile both ES6 and UMD
|
||||
- [breaking change] moves dependencies back to each package. (After years of working on libraries, I've come to actually hate peer dependencies, and this is easily solved with build systems / package managers).
|
||||
- [breaking change] static methods on `Polygon` and `Rectangle` moved to standalone methods
|
||||
- [breaking change] static construction methods to rather deal with different Rectangle constructor overloads (I now consider this bad design)
|
||||
- [breaking change] introduce `Bounds` as a simpler point-array type to deal with boundary computation instead
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b051697]
|
||||
- @projectstorm/react-diagrams-defaults@7.0.0
|
||||
- @projectstorm/react-diagrams-routing@7.0.0
|
||||
- @projectstorm/react-diagrams-core@7.0.0
|
||||
- @projectstorm/react-canvas-core@7.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@projectstorm/react-diagrams",
|
||||
"version": "6.7.1-alpha.0",
|
||||
"version": "7.0.3",
|
||||
"author": "dylanvorster",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -29,9 +29,9 @@
|
||||
"module": "./dist/index.js",
|
||||
"typings": "./dist/@types/index",
|
||||
"dependencies": {
|
||||
"@projectstorm/react-diagrams-core": "^6.7.1-alpha.0",
|
||||
"@projectstorm/react-diagrams-defaults": "^6.7.1-alpha.0",
|
||||
"@projectstorm/react-diagrams-routing": "^6.7.1-alpha.0"
|
||||
},
|
||||
"gitHead": "bb878657ba0c2f81764f32901fd96158a0f8352e"
|
||||
"@projectstorm/react-canvas-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-core": "workspace:*",
|
||||
"@projectstorm/react-diagrams-defaults": "workspace:*",
|
||||
"@projectstorm/react-diagrams-routing": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { PathFindingLinkFactory } from '@projectstorm/react-diagrams-routing';
|
||||
import { SelectionBoxLayerFactory, CanvasEngineOptions } from '@projectstorm/react-canvas-core';
|
||||
|
||||
export * from '@projectstorm/react-canvas-core';
|
||||
export * from '@projectstorm/react-diagrams-core';
|
||||
export * from '@projectstorm/react-diagrams-defaults';
|
||||
export * from '@projectstorm/react-diagrams-routing';
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "dist/@types"
|
||||
"declarationDir": "dist/@types",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../react-canvas-core"
|
||||
|
||||
11761
pnpm-lock.yaml
generated
Normal file
11761
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
4
pnpm-workspace.yaml
Normal file
4
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
packages:
|
||||
- 'packages/*'
|
||||
- 'diagrams-demo-gallery'
|
||||
- 'diagrams-demo-project'
|
||||
@@ -1,16 +1,17 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"suppressExcessPropertyErrors": true,
|
||||
"declaration": true,
|
||||
"composite": true,
|
||||
"incremental": true,
|
||||
"strictNullChecks": false,
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "react",
|
||||
"target": "ES6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "Node",
|
||||
"module": "es6",
|
||||
"strict": false,
|
||||
"lib": [
|
||||
"DOM",
|
||||
|
||||
Reference in New Issue
Block a user