├── .github └── workflows │ └── gh-pages.yml ├── .gitignore ├── LICENSE ├── examples └── approval-process-designer-react │ ├── .gitignore │ ├── README.md │ ├── eslint.config.js │ ├── index.html │ ├── package.json │ ├── public │ └── vite.svg │ ├── src │ ├── App.css │ ├── App.tsx │ ├── activities │ │ ├── ApprovalActivity.tsx │ │ ├── CcActivity.tsx │ │ ├── ConditionActivity.tsx │ │ ├── Icons.tsx │ │ ├── RouteActivity.tsx │ │ ├── StartActivity.tsx │ │ └── index.tsx │ ├── assets │ │ └── react.svg │ ├── index.css │ ├── main.tsx │ └── vite-env.d.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts ├── images ├── img.png └── shuque_wx.jpg ├── lerna.json ├── package.json ├── packages └── approval-process-designer-react │ ├── .fatherrc.ts │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── src │ ├── Icons.tsx │ ├── activity │ │ ├── Activity.tsx │ │ ├── AddActivityBox.tsx │ │ ├── ApprovalActivity.tsx │ │ ├── BranchBox.tsx │ │ ├── CcActivity.tsx │ │ ├── CondiitionActivity.tsx │ │ ├── EndActivity.tsx │ │ ├── RouteActivity.tsx │ │ ├── RouteBranches.tsx │ │ ├── StartActivity.tsx │ │ └── index.tsx │ ├── components │ │ ├── Popover │ │ │ ├── Popover.tsx │ │ │ └── index.tsx │ │ ├── Row │ │ │ ├── Col.tsx │ │ │ ├── Row.tsx │ │ │ └── index.tsx │ │ ├── Tooltip │ │ │ ├── Tooltip.tsx │ │ │ └── index.tsx │ │ └── index.tsx │ ├── container │ │ ├── ApprovalProcessDesigner.tsx │ │ └── index.tsx │ ├── context.tsx │ ├── hooks │ │ ├── index.tsx │ │ ├── useActivities.tsx │ │ ├── useProcess.tsx │ │ ├── useProcessEngine.tsx │ │ └── useProcessNode.tsx │ ├── index.ts │ ├── model │ │ ├── ApprovalProcessEngine.ts │ │ ├── ProcessNode.ts │ │ └── index.ts │ ├── panel │ │ ├── StudioPanel.tsx │ │ └── index.tsx │ ├── store.tsx │ ├── types.tsx │ ├── util.ts │ └── widget │ │ ├── ActivityWidget.tsx │ │ ├── AddActivityItemWidget.tsx │ │ ├── IconWidget.tsx │ │ ├── ProcessWidget.tsx │ │ └── index.tsx │ └── tsconfig.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml └── readme.md /.github/workflows/gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: github pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop # default branch 7 | pull_request: 8 | branches: 9 | - develop 10 | 11 | jobs: 12 | deploy: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - run: yarn install 17 | - run: yarn run build 18 | - name: Deploy 19 | uses: peaceiris/actions-gh-pages@v3 20 | with: 21 | deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} 22 | # github_token: ${{ secrets.GITHUB_TOKEN }} 23 | # 文档目录,如果是 react 模板需要修改为 docs-dist 24 | publish_dir: ./examples/approval-process-designer-react/dist -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .idea 3 | .npmrc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) fengxiaotx@163.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /examples/approval-process-designer-react/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/approval-process-designer-react/README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | export default tseslint.config({ 18 | languageOptions: { 19 | // other options... 20 | parserOptions: { 21 | project: ['./tsconfig.node.json', './tsconfig.app.json'], 22 | tsconfigRootDir: import.meta.dirname, 23 | }, 24 | }, 25 | }) 26 | ``` 27 | 28 | - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` 29 | - Optionally add `...tseslint.configs.stylisticTypeChecked` 30 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: 31 | 32 | ```js 33 | // eslint.config.js 34 | import react from 'eslint-plugin-react' 35 | 36 | export default tseslint.config({ 37 | // Set the react version 38 | settings: { react: { version: '18.3' } }, 39 | plugins: { 40 | // Add the react plugin 41 | react, 42 | }, 43 | rules: { 44 | // other rules... 45 | // Enable its recommended rules 46 | ...react.configs.recommended.rules, 47 | ...react.configs['jsx-runtime'].rules, 48 | }, 49 | }) 50 | ``` 51 | -------------------------------------------------------------------------------- /examples/approval-process-designer-react/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /examples/approval-process-designer-react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |= React.FC
& {
28 | Resource?: IResource;
29 | }
--------------------------------------------------------------------------------
/packages/approval-process-designer-react/src/util.ts:
--------------------------------------------------------------------------------
1 | import {IResource, IResourceCreator} from "./types";
2 | import _ from "lodash";
3 | import {ProcessNode} from "./model";
4 |
5 | export namespace DesignerCore {
6 | export function createResource(resource: IResourceCreator): IResource {
7 | return _.assign(resource, {
8 | node: new ProcessNode({
9 | isSourceNode: true,
10 | type: resource.type,
11 | componentName: resource.componentName,
12 | title: resource.title,
13 | description: resource.description,
14 | props: resource.props
15 | })
16 | })
17 | }
18 |
19 | export function transformToSchema(processNode: ProcessNode) {
20 | function toSchema(processNode: ProcessNode) {
21 | if (!processNode) {
22 | return null
23 | }
24 | return {
25 | id: processNode.id,
26 | prevNodeId: processNode.prevNodeId,
27 | type: processNode.type,
28 | componentName: processNode.componentName,
29 | title: processNode.title,
30 | description: processNode.description,
31 | props: _.isEmpty(processNode.props) ? null : processNode.props,
32 | nextNode: toSchema(processNode.nextNode),
33 | conditionNodes: processNode.conditionNodes?.map(toSchema) || [],
34 | defaultCondition: processNode.defaultCondition
35 | }
36 | }
37 |
38 | return toSchema(processNode)
39 | }
40 | }
--------------------------------------------------------------------------------
/packages/approval-process-designer-react/src/widget/ActivityWidget.tsx:
--------------------------------------------------------------------------------
1 | import React, {FC} from "react";
2 | import {ProcessNode} from "../model";
3 | import {observer} from "@formily/react";
4 | import {useActivities} from "../hooks";
5 | import {ActivityFC} from "../types";
6 | import _ from "lodash"
7 | import {ProcessNodeContext} from "../context";
8 |
9 | type ActivityWidgetProps = {
10 | processNode: ProcessNode;
11 | [key: string]: any
12 | }
13 |
14 | export const ActivityWidget: FC
44 |