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

mobi-dynamic-form

v0.1.26

Published

**MobiDynamicForm** is an Angular library designed to facilitate the creation of dynamic, step-based forms with a variety of field types. This library allows developers to easily configure form steps and fields, handle validation, and manage form navigati

Downloads

177

Readme

MobiDynamicForm

MobiDynamicForm is an Angular library designed to facilitate the creation of dynamic, step-based forms with a variety of field types. This library allows developers to easily configure form steps and fields, handle validation, and manage form navigation.

Table of Contents

Installation

To install and use MobiDynamicForm in your Angular project, you can include it by following the standard npm installation and Angular module setup procedures.

Usage

Code Scaffolding

Run the following command to generate a new component within the MobiDynamicForm project:

ng generate component component-name --project MobiDynamicForm

You can also generate other Angular elements like directives, pipes, services, etc., using:

ng generate directive|pipe|service|class|guard|interface|enum|module --project MobiDynamicForm

Note: Ensure to add the --project MobiDynamicForm flag; otherwise, the new elements will be added to the default project in your angular.json file.

Build

To build the project, run:

ng build MobiDynamicForm

The build artifacts will be stored in the dist/ directory.

Publishing

After building the library, navigate to the dist/mobi-dynamic-form directory and run:

npm publish

Running Unit Tests

Execute the unit tests via Karma with the following command:

ng test MobiDynamicForm

Input Configuration

The MobiDynamicForm uses the Int_StepConfig interface to configure each step of the form. Below is the structure of this interface:

export interface Int_StepConfig {
  buttonActionText: string;
  fieldType: "datePicker" | "timePicker" | "inputField" | "textArea" | "checkBox" | "radioList" | "dropDown" | "summary";
  field: {
    id: string;
    isRequired?: boolean;
    label: string;
    value: string;
    keyForAPI: string;
    placeholder?: string;
    multiple?: boolean;
    itemList?: Partial<Int_itemList>[];
  };
  label: string;
  inputType?: "text" | "number"; // inputType need to discuss
  order: number;
  minLength?: number;
  maxLength?: number;
  export?: (value: any) => any; // Function to handle exporting a value
  customValidation?: (value: any) => boolean; // Function for custom validation
}

Example Configuration

@Input() stepList: Int_StepConfig[] = [
  {
      buttonActionText: 'Next',
      fieldType: 'datePicker',
      field: {
        isRequired: true,
        label: 'Date',
        value: '',
        placeholder: '',
      },
      label: 'Date',
      order: 0,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'timePicker',
      field: {
        isRequired: true,
        label: 'Time',
        value: '',
        placeholder: '',
      },
      label: 'Time',
      order: 1,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'inputField',
      field: {
        isRequired: true,
        label: 'Input Field',
        value: '',
        placeholder: '',
      },
      label: 'Input Field',
      order: 2,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'textArea',
      field: {
        isRequired: false,
        label: 'Text Area',
        value: '',
        placeholder: 'Enter detailed text here',
      },
      label: 'Text Area',
      order: 3,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'checkBox',
      field: {
        isRequired: false,
        label: 'Check Box',
        value: 'false',
        placeholder: 'Tick if applicable',
        itemList: [
          {
            id: '1',
            label: 'Option 1',
            placeholder: 'First option',
          },
          {
            id: '2',
            label: 'Option 2',
            placeholder: 'Second option',
          },
        ],
      },
      label: 'Check Box',
      order: 4,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'radioList',
      field: {
        isRequired: true,
        label: 'Radio List',
        value: '',
        placeholder: 'Select one option',
        itemList: [
          {
            id: '1',
            label: 'Option 1',
            placeholder: 'First option',
          },
          {
            id: '2',
            label: 'Option 2',
            placeholder: 'Second option',
          },
        ],
      },
      label: 'Radio List',
      order: 5,
    },
    {
      buttonActionText: 'Next',
      fieldType: 'dropDown',
      field: {
        isRequired: true,
        label: 'Drop Down',
        value: '',
        placeholder: 'Select an option',
        itemList: [
          {
            id: '1',
            label: 'Choice 1',
            placeholder: '',
          },
          {
            id: '2',
            label: 'Choice 2',
            placeholder: '',
          },
        ],
      },
      label: 'Drop Down',
      order: 6,
    },
    {
      buttonActionText: 'Done',
      fieldType: 'summary',
      field: {
        isRequired: true,
        label: 'Summary',
        value: '',
        placeholder: 'Review your details',
      },
      label: 'Summary',
      order: 8,
    },

  // Additional step configurations
];

Usage

Make Sure to mention in module

Make sure to mention in module

Use as Selector

selector

Output Emitters

The following output emitters are provided for handling form actions:

  • submitEmitter: Triggered when the form is submitted.
  • nextEmitter: Triggered when the user proceeds to the next step.
  • prevEmitter: Triggered when the user returns to the previous step.
  • errorEmitter: Triggered when there is a validation or process error.
@Output() submitEmitter = new EventEmitter();
@Output() nextEmitter = new EventEmitter();
@Output() prevEmitter = new EventEmitter();
@Output() errorEmitter = new EventEmitter();

These emitters allow you to capture and handle various form events, enabling a seamless user experience.

Emitter Response

onSubmit

{
"messages": [
{
"label": "Select Host",
"value": {
"id": "919925030186",
"label": "Dipen"
},
"order": 0,
"keyForAPI": "whomToMeet",
"isRequired": true,
"fieldType": "dropDown"
}
],
"actionName": ""
}

Further Help

For more help with the Angular CLI, use ng help or visit the Angular CLI Overview and Command Reference page.


This README provides a quick start guide and configuration details for working with the MobiDynamicForm library. For detailed documentation and more advanced usage, refer to the official Angular and TypeScript documentation.