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 🙏

© 2025 – Pkg Stats / Ryan Hefner

formwiz-publicweb-controls

v1.3.37

Published

Dynamic form builder package for FormWiz project.

Readme

Dynamic form builder

This is an dynamic form builder empowered FormWiz project.

How to use

  • Install peer dependencies:
npm install --save react react-dom react-redux redux moment
  • This package relies on redux-form so you need to install it (if you haven't):
npm install --save redux-form
  • Install it:
npm install --save formwiz-publicweb-controls
  • Load form options:

    • Since the form builder relies on redux, you can only load its rendered form's options to state and then the form will load them automatically.

    • First you need to register its store inredux's state tree:

      /**
       * rootReducer.js
       */
      
      import { formBuilder } from 'formwiz-publicweb-controls';
      const rootReducer = combineReducers({
        ...
        // Register formwiz-publicweb-controls's store
        formBuilder
        ...
      });
    • Then dispatch formOptionsUpdate action from inside your action for loading form's options:

      /**
       * actions.js
       */
      import { formOptionsUpdate } from 'formwiz-publicweb-controls';
      // Using redux-thunk (learn more at https://github.com/gaearon/redux-thunk)
      export const loadFormOptions = (payload: {
        uuid,
        data,
        currentSection
      }) => {
        return (
          dispatch,
          getState
        ) => {
          const { uuid, data, currentSection } = payload;
          fetch('http://www.my-api.com/my-form-options')
            .then(
              (formOptions) => {
                // Set uuid back to new form options
                formOptions.uuid = uuid; // optional
                // Update form options
                dispatch(formOptionsUpdate(uuid, formOptions));
              }
            )
        };
      };
  • Load default form data:

    /**
     * actions.js
     */
    import { formOptionsUpdate, fillData } from 'formwiz-publicweb-controls';
    // Using redux-thunk (learn more at https://github.com/gaearon/redux-thunk)
    export const loadFormOptions = (payload: {
      uuid,
      data,
      currentSection
    }) => {
      return (
        dispatch,
        getState
      ) => {
        const { uuid, data, currentSection } = payload;
        fetch('http://www.my-api.com/my-form-options')
          .then(
            (formOptions) => {
              // Set uuid back to new form options
              formOptions.uuid = uuid; // optional
              // Assume you already have form data stored in `reduxStore.formDataState`
              const {
                formDataState,
                currentSectionState
              } = getState().application;
    
              // Get current form data state
              const formData = formDataState[formOptions.uuid];
              if (formData) {
                // fill data in current form
                formOptions = fillData(
                  dispatch,
                  formOptions,
                  formData,
                  currentSection,
                  formMeta.isSubmitted
                );
              } else {
                // Activate first section
                formOptions.sections = formOptions.sections.map(
                  (section, index) => ({
                    ...section,
                    isActive:
                      currentSection && currentSectionState
                        ? currentSection.uuid === currentSectionState.uuid
                        : index === 0
                  })
                );
              }
              // Update form options
              dispatch(formOptionsUpdate(uuid, formOptions));
            }
          )
      };
    };
  • Submit form data:

    /**
     * actions.js
     */
    import { formSubmit } from 'formwiz-publicweb-controls';
    export const submit = ({ formUUID, formModel }) =>
      formSubmit(
        formUUID,
        // onSubmitAction
        // Call API to submit form model
        () =>
          fetch('http://www.my-api.com/my-form-data', {
            method: 'POST', // or 'PUT'
            body: JSON.stringify(formModel),
            headers: new Headers({
              'Content-Type': 'application/json'
            })
          })
        // onStartAction?: Function
        undefined,
        // onErrorAction?: Function,
        undefined,
        // onSuccessAction?: Function,
        undefined,
        // onEndAction?: Function,
        undefined,
        // onCatchAction?: Function
      );
  • Import and then render it:

    /**
     * MyFormComponent.js
     */
    import React from 'react';
    import { ReduxDynamicFormBuilder } from 'formwiz-publicweb-controls';
    
    class MyFormComponent extends React.Component {
      ...
      render() {
        const DynamicFormBuilder = ReduxDynamicFormBuilder({
          // Form's UUID
          form: 'MyDynamicForm',
          // Other `redux-form` configurations
          ...
        });
        return (<DynamicFormBuilder />);
      }
    }
  • Advance configurations:

    • Validation:

      /**
        * MyFormComponent.js
        */
      import React from 'react';
      import { ReduxDynamicFormBuilder } from 'formwiz-publicweb-controls';
      
      class MyFormComponent extends React.Component {
        ...
        render() {
          const DynamicFormBuilder = ReduxDynamicFormBuilder({
            // Form's UUID
            form: 'MyDynamicForm',
            // Other `redux-form` configurations
            ...
          });
          return (<DynamicFormBuilder onValidate={(fieldName, errors, form) => {
            // Validating field's name
            console.log(fieldName);
            // Validation's errors
            console.log(errors);
            // Rendered form's ref object
            console.log(form);
          }}/>);
        }
      }
    • Localization

      • Date time:

        • This package use moment as a date parser.
        • You can change its locale via adding moment.locale('<LOCALE>'); anywhere in your app, as long as it's executed before rendering the form.
        • Best practice is to add it in app.js - where you bootstrapped your root React component.
        /**
         * app.js
         */
        import React from 'react';
        import { render } from 'react-dom';
        import moment from 'moment';
        import 'moment/locale/hr';
        
        moment.locale('en');
        const App = props => (
          ...
        );
        ...
        render(
          <App />,
          document.querySelector('#root')
        );
    • Other examples: COMING SOON.

  • API docs:

Contribution Guide

Note: This package is currently receives contribution only from FormWiz team members. We're sorry about that.

  • Clone FormWiz project repo.
  • Run npm install and npm run bootstrap at repo's root folder. This will run lerna's bootstrap commands.
  • Navigate to cloned-repo/src/FormWiz.DynamicFormBuilder in terminal.
  • Run npm start. This will build formwiz-publicweb-controls package, copy it to packages which depends on it in this project and then watch for formwiz-publicweb-controls's changes.