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

@heartfulnessinstitute/react-hfn-forms

v0.6.12

Published

Forms for MySRCM / Heartfulness

Downloads

172

Readme

react-hfn-forms

Exports

import DynamicForm from '@heartfulnessinstitute/react-hfn-forms'

    <DynamicForm
      key={this.state.current.id}
      formClassName="form"
      formTitle={this.state.useLayout ? "Demo with Layout" : "Demo without Layout"}
      formLayout={this.state.useLayout ? layout : null}
      defaultValues={this.state.current}
      formFields={[
        { name: "name", label: "Name", props: { required: true } },
        { name: "age", label: "Age", type: "number", defaultValue: 5, },
        { name: "rating", label: "Rating", type: "number", props: { min: 0, max: 5 }},
        { name: "gender", label: "Gender", type: "radio", options: gender_options },
        { name: "qualification", label: "Qualification" },
        { name: "country", label: "Country", type: "select", options: countries_options },
        {
          name: "states", label: "States", type: "multiselect", options: [],
          dynamic: (r) => (r.country === 'India' ? { options: states_india } : { options: states_us })
        },
        { name: "date", label: "Start Date", type: "date", props: {maxDate: "2019-12-22"} },
        { name: "enddate", label: "End Date", type: "date", props: { minDate: "2019-10-22" } },

      ]}
      onSubmit={model => {
        this.onSubmit(model);
      }}
      onDiscard={() => this.setState({ current: {}})}
    />

import DynamicTable from '@heartfulnessinstitute/react-hfn-forms/DynamicTable'

    <DynamicTable
      table_columns={table_columns}
      table_style={{rTableCell: {padding: "10px"}}}
      paneLayout={paneLayout}
      renderRecord={renderRecord}
      data={this.state.data}
      allow={{ create: true, delete: true, update: true }}
      buttons={{createButton, deleteButton, editButton, submitButton }}
      form_props={{ formFields, formLayout }}
      onCUD={this.onCUD}
      table_edit_inline={true}
    />

    table_columns = [
        { name: 'name', label: "Name" },
        { name: 'gender' , label: "Gender", transform: "gender" },
        { name: 'date', label: "Start Date",  transform: "shortdate" }
    ];

    formFields = [
        { name: "name", label: "Name", props: { required: true } },
        { name: "age", label: "Age", type: "number", defaultValue: 5, },
        { name: "rating", label: "Rating", type: "number", props: { min: 0, max: 5 }},
        { name: "gender", label: "Gender", type: "radio", options: gender_options },
        { name: "qualification", label: "Qualification" },
        { name: "country", label: "Country", type: "select", options: countries_options },
        {
          name: "states", label: "States", type: "multiselect", options: [],
          dynamic: (r) => (r.country === 'India' ? { options: states_india } : { options: states_us })
        },
        { name: "date", label: "Start Date", type: "date", props: {maxDate: "2019-12-22"} },
        { name: "enddate", label: "End Date", type: "date", props: { minDate: "2019-10-22" } },

      ]

For detailed usage of DynamicForm and DynamicTable, see the code in the examples folder.

Choice Lists

The following lists could be passed as options for dropdown/radio/multiselect fields

gender_options - male, female, unspecified countries - list of countries indiastates - list of indian states and union territories

The format of each entry in the above lists is a dict with the keys name, label and value. e.g., gender_options is defined as follows:

[
    { name: "M", label: "Male", value: "M" },
    { name: "F", label: "Female", value: "F" },
    { name: "U", label: "Unspecified", value: "U" },
]

Validators

validateEmail(string) - returns true if the given string is a valid email validatePhoneNumber(string) - returns true if the given string is a valid phonenumber (according to google phoneutil lib)

validatePNR(string) - returns true if given string is a valid registrations PNR (Heartfulness specific) validateAbhyasiId(string) - returns true if given string is a valid Heartfulness ID (Heartfulness specific)

validateRE(regex, string) = returns true if the given string matches the given regex

Formatting Helpers

formatSys2MomentDate(date_object) = returns the string in moment format date(Dec 31, 2019 23:01:59) => str(20191231230159)

formatSys2ShortDate(date_object) - returns the string in short format date(Dec 31, 2019 23:01:59) => str(Dec 31, 2019) or str(Dec 31) if current year is 2019

formatSys2OdooDate(date_object) - returns the string in odoo date format date(Dec 31, 2019 23:01:59) => str(2019-12-31)

formatOdooDate2Sys(string) - returns the date object given a string in odoo date format str(2019-12-31) => date(Dec 31, 2019 23:01:59)

doFormatShortDate(string) - returns the string in short format given odoo date string str(2019-12-31) => str(Dec 31, 2019) or str(Dec 31) if current year is 2019

doFormatYesNo(boolean) - returns the string yes or no given a boolean value TRUE => yes FALSE => no

doFormatTitle(string) - returns the string in Title case andhRA praDEsh => Andhra Pradesh

doFormatLower(string) - returns the string in Lower case andhRA praDEsh => andhra pradesh

doFormatUpper(string) - returns the string in Upper case andhRA praDEsh => ANDHRA PRADESH

doFormatGender(string) - returns full name in string given the gender value M, F, or U M => Male F => Female U => Not Mentioned

JSON Files

monthnames.json

indiastates.json

countries.json

Setup

# npm i @heartfulnessinstitute/react-hfn-forms -S