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

@ipscape/form-renderer-js

v1.0.11

Published

## Installation

Downloads

154

Readme

@ipscape/form-renderer

Installation

With NPM

npm i --save @ipscape/form-renderer-js

With Yarn

yarn add @ipscape/form-renderer-js

Get Started

import { FormRenderer } from '@ipscape/form-renderer-js';

// Data block that details the form schema
const pageData = {
  id: 1,
  name: 'Survey 1',
  meta: {
    version: 1,
    pages: [{ id: 1, name: 'Survey 1' }, { id: 2, name: 'Survey 2' }],
    fields: {
      contact: [
        { id: 1, name: 'phone1', caption: 'Phone1' },
        { id: 2, name: 'phone2', caption: 'Phone2' },
        { id: 3, name: 'phone3', caption: 'Phone3' },
        { id: 4, name: 'salesforceId', caption: 'Salesforce Id' },
        { id: 5, name: 'customer_key', caption: 'Customer Key' }
      ],
      activity: [
        { id: 11, name: 'street_address_1', caption: 'Street Address 1' },
        { id: 12, name: 'street_address_2', caption: 'Street Address 2' },
        { id: 13, name: 'postcode', caption: 'Postcode' }
      ]
    }
  },
  components: [
    {
      id: "6611a2ff-2914-4687-affe-44f53e8d99990",
      field: "Short answer",
      component: "input",
      attributes: {
        label: "Name",
        placeholder: "Your names here",
        required: true,
        validation: "none"
      }
    },
    {
      id: "6611a2ff-2914-4687-affe-44f53e8d111110",
      field: "Short answer",
      component: "input",
      attributes: {
        label: "Email",
        placeholder: "Your email here",
        required: true,
        mapping: {
          id: 5,
          name: "email",
          caption: "Customer Emaill"
        },
        validation: "email",
      }
    },
    {
      id:"8a314d10-09be-4907-9877-46aa9fa6cb6f",
      field:"Button",
      component:"button",
      attributes:{
        field:"Button",
        label:"Start chat",
        component:"Button",
        action:{
          name:"submitForm",
          target:{ id:null, page:null},
        },
      },
    },
  ]
};
// Mapping data to pre-populate a form
const mapping = [
  { id: 5, name: 'customer_key', value: '[email protected]' },
];
// Instantiate your form
const formRenderer = new FormRenderer(pageData, mapping);
// Set a listener for form submission
form.on('ipscape-submit', (data) => {
  if (data.detail.page !== '1') return;
  if (data.detail.action === 'submitForm') {
    data.detail.model.forEach((item) => {
      ... /* logic for form model here */
    });
  }
  
  // Switch to a different page
  if (data.detail.action === 'goToPage') {
    data.detail.target
  }
});

And the form to your HTML

<ipscapeui-form></ipscapeui-form>

Available Methods

| Name | Parameters | Description | |--------------|---------------------------------------|---------------------------------------------------------------| | addComponent | component: Component, data: FieldData | Add a component and data mapping to your form | | removeComponent | componentId: string | Removes component from form | | updateComponent | component: Component | Updates component with same component Id | | setNewForm | page: Form, map: Array | Reset form and load new form data. *Useful for changing pages |