npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sourceloop/workflows-creator

v1.1.9

Published

Library for providing a smooth user workflow.

Downloads

4

Readme

An Angular Client to develop workflows using an intuitive statement based UI.

Installation


npm i @sourceloop/workflows-creator

Usage

  • Install the workflows-creator npm i @sourceloop/workflows-creator

  • Import the WorkflowBuilderModule in the required module -

      ...
      imports: [
          ...
          WorkflowBuilderModule,
          ...
      ],
  • Use the component selector in your application -

    <workflow-builder
      [(state)]="state"
      [(diagram)]="diagram"
      (eventAdded)="elementClick($event)"
      (actionAdded)="elementClick($event)"
      (itemChanged)="valueChanges($event)"
    ></workflow-builder>
    • state is the initial state object
    • diagram is initial BPMN Diagram respectively.
    • eventAdded - this event fires whenever a new event is added in the workflow
    • actionAdded - this event fires whenever a new action is added in the workflow
    • itemChange - this event fires whenever a user input changes

Configurations

Nodes

  • Each Statement is made up of nodes -

    • Events - Triggers or Checks that lead to an action
    • Action - Actually task performed by the workflow
  • You can create your own nodes by extending the WorkflowNode class.

  • To register this node for use, provide it to the BPMN_NODES token -

{provide: BPMN_NODES, useValue: CustomNode, multi: true},

Element

  • Each Node is based on certain base elements like tasks, gateways, etc.
  • You can create your own BPMN Elements by extending the BpmnElement class.
  • You can also create any custom element by extending the WorkflowElement class(in case working with a non-BPMN workflow engine).
  • To register this element for use, provide it to the BPMN_INPUTS token -
{provide: BPMN_ELEMENTS, useValue: CustomElement, multi: true},

Prompts

  • Each Node also has some prompts or inputs from the users.
  • You can create your own Prompt by extending the WorkflowPrompt class.
  • To register this prompt for use, provide it to the token -
{provide: BPMN_INPUTS, useValue: CustomInput, multi: true},

Web Component

  • This library is also available as a Web Component so users of frameworks like React and Vue can also integrate this workflow creator element in their application with minimal effort.

Installation

npm i @sourceloop/workflows-creator
  • In the node modules you can find two files relevant to the element - workflows-element/element/workflows-element.js & workflows-element/element/style.css. How you serve and include these files in your non Angular project depend on the framework that you are using. For example, for Vanilla JS and HTML you can simply import the js and styles in your HTML ->
<script type="text/javascript" src="workflows-element.js"></script>

Usage

The web component accepts all the same inputs and services as the regular Angular Module, but instead of passing them through bindings and DI, you pass them as properties of the element as shown below. NOTE: If envIdentifier is required it must be provided in the global window object as shown below, otherwise it will be rendered as undefined. This step is needed only in non-angular applications. For angular appplications it can be directly provided with the help of providers.

<!DOCTYPE html>
<html>
  <head>
    <link
      rel="stylesheet"
      type="text/css"
      href="/assets/icons/icomoon/style.css"
    />
    <link rel="stylesheet" type="text/css" href="styles.css" />
  </head>
  <body>
    <sourceloop-workflow-element></sourceloop-workflow-element>
    <script type="text/javascript" src="workflows-element.js"></script>
    <script>
      window.workflowEnv = {envIdentifier: 'Production'};
    </script>
    <script>
      document.addEventListener('DOMContentLoaded', () => {
        const element = document.querySelector('sourceloop-workflow-element');

        element.allColumns = [
          {
            text: 'Status',
            value: '{{Status}}',
          },
          {
            text: 'People',
            value: '{{People}}',
          },
          {
            text: 'Text',
            value: '{{Text}}',
          },
        ];

        const NORMALIZED_COLUMN = [
          {
            text: 'Status',
            value: '1952177d-9a3e-6ef4-ae8f-522c08153026',
          },
          {
            text: 'Priority',
            value: '1952177d-9a3e-6ef4-ae8f-522c08153026',
          },
          {
            text: 'Text',
            value: '2069d144-db46-0737-2c9d-bc339949d684',
          },
        ];

        const CONDITIONS = {
          date: DATE_CONDITIONS,
          datetime: DATE_CONDITIONS,
        };

        const DEFAULT_CONDITION = [
          {text: 'Equal', value: 'equal'},
          {text: 'Not Equal', value: 'notequal'},
        ];
        const DATE_CONDITIONS = [
          {text: 'Past Today', value: 'pastToday'},
          {text: 'Coming In', value: 'comingIn'},
          {text: 'Past by', value: 'pastby'},
        ];
        const VALUE_TYPES = [
          {
            text: 'ANYTHING',
            value: 'anyValue',
          },
          {
            text: 'CUSTOM_VALUE',
            value: 'customValue',
          },
        ];
      });

      element.addEventListener('eventAdded', event => {
        elementClick(event.detail);
      });
      element.addEventListener('actionAdded', event => {
        elementClick(event.detail);
      });
      element.addEventListener('itemChanged', event => {
        valueChanges(event.detail);
      });

      function elementClick(event) {
        const selectedElement = event.event ?? event.action;
        switch (selectedElement.getIdentifier()) {
          case window.OnIntervalEvent.identifier:
            selectedElement.state.change('intervalList', TIMESCALE);
            selectedElement.state.change('valuePlaceholder', 'n');
          case window.OnChangeEvent.identifier:
          case window.OnValueEvent.identifier:
            let columns = NORMALIZED_COLUMN.filter(
              col => col.text.toLowerCase() !== 'priority',
            );
            selectedElement.state.change('columns', columns);
            break;
          case window.ChangeColumnValueAction.identifier:
            selectedElement.state.change('columns', NORMALIZED_COLUMN);
            break;
        }
      }

      function valueChanges(event) {
        let selectedCol;

        switch (event.field) {
          case window.ValueInput.identifier:
            if (
              event.item.getIdentifier() === window.OnIntervalEvent.identifier
            ) {
              event.item.state.change('intervalList', TIMESCALE);
              return;
            }
            break;
          case window.IntervalInput.identifier:
            const timescale = TIMESCALE.find(
              time => time.value === event.value,
            )?.timescale;
            event.item.state.change('timescale', timescale);
            break;
          case window.TriggerColumnInput.identifier:

          case window.ColumnInput.identifier:
            selectedCol = NORMALIZED_COLUMN.find(
              col => col.value === event.value,
            );
            selectedColumnType = selectedCol.text?.toLowerCase();
            const condition =
              CONDITIONS[selectedCol.text?.toLowerCase()] || DEFAULT_CONDITION;
            if (selectedCol) {
              event.item.state.change('conditions', condition);
            }
          case window.ConditionInput.identifier:
          case window.ToColumnInput.identifier:
            selectedCol = NORMALIZED_COLUMN.find(
              col => col.value === event.value,
            );
            if (selectedCol)
              selectedColumnType = selectedCol.text?.toLowerCase();
            event.item.state.change(
              'valueInputType',
              FIELD_VALUES[selectedColumnType].valueInputType,
            );
            if (FIELD_VALUES[selectedColumnType].values) {
              event.item.state.change(
                'values',
                FIELD_VALUES[selectedColumnType].values,
              );
            }

            break;
          case window.EmailDataInput.identifier:
        }
      }
    </script>
  </body>
</html>