1.0.2 • Published 5 years ago

react-router-event-manager v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

React Router Event Manager

Overview

Manager component for handling event driven changes to react router routes. This decouples lower level components from having to know their containing application is leveraging react-router-dom for route management. Instead of applicaiton components directly modifying the router history attribute (history.push()), components instead trigger ROUTE_CHANGE_EVENT or ROUTE_UPDATE_EVENT (which this manger subscribes to) and the manager handles modification of the route.

Installation

Run the following NPM command to install:

> npm install --save configurable-form-builder

Run the following NPM command to launch a sample demo:

> npm start

Usage

The Configurable Form Builder can be used as follows:

import ConfigurableForm from 'configurable-form-builder';

...

primaryCallback = (submittedFormValueMap) => {
    [do some logic with submitted form attribute value pairs]
}

...

<ConfigurableForm 
    title="Sample Config Form Title",
    fields=[
    {
      id: "id",
      type: "text",
      label: "Name"
    },
    {
      id: "status",
      type: "enum",
      label: "Status",
      values: ["active", "error", "pending"]
    }
  ],
  primaryButtonText: "Search",
  noAttrText: "No searchable attributes for selected entity types",
  breakpoints: {350: 1, 750: 2, 900: 3},
  primaryButtonCallback={this.primaryCallback} />

in order to generate the following:

Sample Form Screenshot

If no 'title' property is configured, there will be no title displayed.

Responsiveness

By default the form shall display all of it's attribute files in a single column. It is possible to spread the form fields out over multiple columns while keeping it responsive to varying screen sizes. By using the 'breakpoints' property, the form can be configured to spread it's content over a number of columns (order is dictated by the order of the 'fields' property).

Example: The following properties setting will render all fields in a single column when the form is 350px, 2 columns when 750px wide and 3 columns when 900px or more breakpoints: {350: 1, 750: 2, 900: 3}

Form width larger than 900px Form width larger than 750px Form width less than 350px

Configuration Properties

ConfigurableForm.propTypes = {
  title: PropTypes.string,
  fields: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.string.isRequired,
      type: PropTypes.string.isRequired,
      label: PropTypes.string,
      values: PropTypes.arrayOf(PropTypes.string)
    })
  ),
  values: PropTypes.object,
  primaryButtonText: PropTypes.string,
  primaryButtonCallback: PropTypes.func.isRequired,
  noAttrText: PropTypes.string,
  breakpoints: PropTypes.object
}

ConfigurableForm.defaultProps = {
  fields: [],
  primaryButtonText: PRIMARY_BUTTON_DEFAULT_TEXT,
  noAttrText: NO_FORM_ATTRIBUTES,
  breakpoints: {}
}

Form properties:

Property NameTypeRequiredDescriptionDefault
titleStringNoOptional title to display above the formN/A
fieldsArrayNoa list of form fields to be rendered[]
valuesObjectNoan object mapping the value set for each attributeN/A
primaryButtonTextStringNoOptional text to display in the primary form button"Submit"
primaryButtonCallbackFunctionYesThe callback method when the form is submittedN/A
noAttrTextStringNoText to display when there are no attribute fileds for the form to render"No available attributes"
breakpointsObjectNoConfigurable breakpoints to make the form responsive{}

Field Properties:

Property NameTypeRequiredDescription
idStringYesthe unique identifier of the form field
typeStringYesthe type of the form field
labelStringNoOptional text to display as the form field label
valuesArrayNooptional list of values for ENUM type fields

Valid Field Property Types:

TypeRendered Component
ENUMDropdown
Anything ElseTextfield
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago