2.2.2 • Published 5 years ago

@ramenjs/formstepper v2.2.2

Weekly downloads
36
License
UNLICENSED
Repository
-
Last release
5 years ago

Ramen - FormStepper

Here Comes the FormStepper - a stepped form module for Ramen

Installation

npm i @ramenjs/formstepper -S

How to use

  import FormStepper from '@ramenjs/formstepper';
  FormStepper(config);

configuration

  • selector string The selector for the DOM element where the form will be rendered E.g. .js-form-stepper
  • onSubmit function A callback function thats fired on form submit, recives the form data as the first parameter
  • totalSteps integer Indication of how many steps the form has
  • fields array Array of fields to be rendered (See blow for examples)

Fields

Todo

Fields Types

Todo

Example Configuration

// Import Dependencies
import FormStepper from '@ramenjs/formstepper';
import { isRequired } from '@ramenjs/utilitybelt';

// Run Application
(() => {
  FormStepper({
    selector: '.js-form-stepper',
    totalSteps: 3,
    onSubmit: (data) => {
      console.log('SUBMIT', data); // eslint-disable-line
    },
    fields: [
      {
        id: 'step1Legend',
        type: 'legend',
        text: 'Step 1 legend',
        step: 1,
      },
      {
        id: 'exampleText',
        name: 'exampleText',
        label: 'Text input',
        type: 'text',
        placeholder: 'Text input placeholder',
        validate: [isRequired],
        step: 1,
      },
      {
        id: 'exampleSelect',
        name: 'exampleSelect',
        label: 'Select dropdown',
        type: 'select',
        options: [
          {
            id: 'option1',
            label: 'Select option 1',
            value: 'Select option 1',
          },
          {
            id: 'option2',
            label: 'Select option 2',
            value: 'Select option 2',
          },
          {
            id: 'option3',
            label: 'Select option 3',
            value: 'Select option 3',
          },
        ],
        step: 1,
      },
      {
        id: 'exampleCheckbox',
        name: 'exampleCheckbox',
        label: 'Checkbox',
        type: 'checkbox',
        options: [
          {
            id: 'exampleCheckbox-option1',
            label: 'Checkbox option 1',
            value: 'Checkbox option 1',
          },
        ],
        value: true,
        step: 1,
      },
      {
        id: 'exampleRadio',
        name: 'exampleRadio',
        label: 'Radio',
        type: 'radio',
        options: [
          {
            id: 'exampleRadio-option1',
            label: 'Radio option 1',
            value: 'Radio option 1',
          },
          {
            id: 'exampleRadio-option2',
            label: 'Radio option 2',
            value: 'Radio option 2',
          },
          {
            id: 'exampleRadio-option3',
            label: 'Radio option 3',
            value: 'Radio option 3',
          },
        ],
        value: 'Radio option 2',
        step: 1,
      },
      {
        id: 'step2Legend',
        type: 'legend',
        text: 'Step 2 legend',
        step: 2,
      },
      {
        id: 'exampleText3',
        name: 'exampleText3',
        label: 'Text input 3',
        type: 'text',
        placeholder: 'Text input placeholder',
        validate: [isRequired],
        step: 2,
      },
      {
        id: 'exampleText4',
        name: 'exampleText4',
        label: 'Text input 4',
        type: 'text',
        placeholder: 'Text input placeholder',
        validate: [isRequired],
        step: 2,
      },
      {
        id: 'secrettest',
        name: 'secrettest',
        label: 'Secret field if you type test ha',
        type: 'text',
        placeholder: 'Text input placeholder',
        showField: formData => formData.exampleText === 'test', // only show this field if 'exampleText' = 'test'
        step: 2,
      },
      {
        id: 'step3Legend',
        type: 'legend',
        text: 'Step 3 legend',
        step: 3,
      },
      {
        id: 'exampleText5',
        name: 'exampleText5',
        label: 'Text input 5',
        type: 'text',
        placeholder: 'Text input placeholder',
        step: 3,
      },
    ],
  });
})();
2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.15

5 years ago

2.1.14

5 years ago

2.1.13

5 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.7

6 years ago

1.7.6

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.4.7

6 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.16

6 years ago

1.3.15

6 years ago

1.3.14

6 years ago

1.3.13

6 years ago

1.3.12

6 years ago

1.3.11

6 years ago

1.3.10

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago