Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sequential-workflow-designer

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequential-workflow-designer

![Sequential Workflow Designer](.github/cover.png)

  • 0.2.0
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
increased by6.85%
Maintainers
1
Weekly downloads
 
Created
Source

Sequential Workflow Designer

Sequential Workflow Designer

Build Status License: MIT View this project on NPM Twitter: b4rtaz

Sequential workflow designer with no dependencies for web. It's written in pure TypeScript and uses SVG for rendering. This designer is not associated with any workflow engine. It's full generic. You may create any kind application by this, from graphical programming languages to workflow designers.

Features:

  • no dependencies,
  • full generic & configurable,
  • light/dark themes,
  • works on modern browsers,
  • works on mobile.

👀 Examples

🚀 Installation

To use the designer you should add JS/TS files and CSS files to your project.

NPM

Install this package by NPM command:

npm i sequential-workflow-designer

To import the package:

import Designer from 'sequential-workflow-designer';

If you use css-loader or similar, you can add CSS files to your boundle:

import 'sequential-workflow-designer/css/designer.css';
import 'sequential-workflow-designer/css/designer-light.css';
import 'sequential-workflow-designer/css/designer-dark.css';

To create the designer write the below code:

// ...
Designer.create(placeholder, definition, configuration);

CDN

Add the below code to your head section in HTML document.

<head>
...
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.0/css/designer.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.0/css/designer-light.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.0/css/designer-dark.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.2.0/lib/designer.js"></script>

Call the designer by:

sequentialWorkflowDesigner.create(placeholder, definition, configuration);

🎬 Usage

Check examples directory.

import Designer from 'sequential-workflow-designer';

const placeholder = document.getElementById('placeholder');

const definition = {
  properties: {
    'myProperty': 'my-value',
    // global properties...
  },
  sequence: [
    // root steps...
  ]
};

const configuration = {
  theme: 'light',
  isReadonly: false,

  toolbox: {
    isHidden: false,
    groups: [
      {
        name: 'Files',
        steps: [
          // steps for the toolbox's group
        ]
      },
      {
        name: 'Notification',
        steps: [
          // steps for the toolbox's group
        ]
      }
    ]
  },

  steps: {
    iconUrlProvider: (componentType, type) => {
      return `icon-${componentType}-${type}.svg`;
    },
    validator: (step) => {
      return /^[a-z]+$/.test(step.name);
    },
    canInsertStep: (step, targetSequence, targetIndex) => {
      return targetSequence.length < 5;
    },
    canMoveStep: (sourceSequence, step, targetSequence, targetIndex) => {
      return !step.properties['isLocked'];
    },
    canDeleteStep: (step, parentSequence) => {
      return step.name !== 'x';
    }
  },

  editors: {
    isHidden: false,
    globalEditorProvider: (definition) => {
      const container = document.createElement('div');
      // ...
      return container;
    },
    stepEditorProvider: (step) => {
      const container = document.createElement('div');
      // ...
      return container;
    }
  }
};

const designer = Designer.create(placeholder, definition, configuration);
designer.onDefinitionChanged.subscribe((newDefinition) => {
  // ...
});

🚧 Supported Components

Task

Any atomic task.

const taskStep = {
  componentType: 'task',
  id: 'my-unique-id',
  type: 'my-type', // e.g. 'save-file', 'send-email', ...
  name: 'my-name',
  properties: {
    'myProperty': 'my-value',
    // ...
  }
};

Container

This component is mainly designed for for/while/foreach loops. It could be used as a context container too.

const containerStep = {
  componentType: 'container',
  id: 'my-unique-id',
  type: 'my-type', // e.g. 'for', 'while', 'foreach'...
  name: 'my-name',
  properties: {
    'myProperty': 'my-value',
    // ...
  },
  sequence: [
    // steps...
  ]
};

Switch

This component is designed for if/else expressions, but you may use it for switch/case expressions too. This component must have minimum 2 branches.

const switchStep = {
  componentType: 'switch',
  id: 'my-unique-id',
  type: 'my-type', // e.g. 'if', 'switch'...
  name: 'my-name',
  properties: {
    'myProperty': 'my-value',
    // ...
  },
  branches: {
    'true': [
      // steps...
    ],
    'false': [
      // steps...
    ],
    // ...
    'next': [
      // steps...
    ]
  }
};

💡 License

This project is released under the MIT license.

Keywords

FAQs

Package last updated on 09 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc