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

visio-rhf-base

v0.2.0

Published

Here we have a set of reusable controlled input components designed to be used with [react-hook-form](https://react-hook-form.com/) to handle forms and [yup](https://github.com/jquense/yup) to handle validation.

Downloads

2

Readme

Visio React-Hook-Form base components

Here we have a set of reusable controlled input components designed to be used with react-hook-form to handle forms and yup to handle validation.

Installation

yarn add visio-react-base

npm install visio-react-base

Libraries we used

react-hook-form

yup

MUI

dayjs

react-number-format

axios-hooks

Basic usage

Import the component or components you want to use and plug them in your form. See example below:

import { useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
import {InputText} from "visio-rhf-base";
...

const schema = yup.object().shape({
  name: yup.string(),
})

const { ...methods } = useForm({
  resolver: yupResolver(schema),
  defaultValues: {
    name: "",
  },
});
<form>
  <InputText
    name="name"
    control={methods.control}
    label="Name"
    fullWidth
  />
  <Button type="submit">Send</Button>
</form>

We don't require the use of react-hook-form useFormContext wrapping the form for these simple components, but feel free to use it.

Available components

InputText

Most basic of the elements, designed to accept text or number, you can pass all the attributes available for TextField.

<InputText
  name="name"
  control={methods.control}
  label="Name"
/>

InputNumber

This is a TextField which is going to format your text as a number as you type, UI will look as a number field. We use react-number-format to handle formatting and value submission.

<InputNumber
  name="creditScore"
  control={methods.control}
  label="Credit Score"
/>

InputCurrency

This is a TextField which is going to format your text as a US currency while you type. This field displays a formatted US currency text and send a float value to the form. We use react-number-format to handle formatting and value submission.

<InputCurrency
  name="amount"
  control={methods.control}
  label="Amount"
/>

InputPhone

This is a TextField which is going to format your text as a US phone number while you type and send the formatted text to the form. We use react-number-format to handle formatting and value submission.

<InputPhone
  name="phone"
  control={methods.control}
  label="Phone"
/>

InputPercentage

This is a TextField which is going to format your text as a % number. Will display a percentage format but will send a decimal to the form, for example: a value of 0.9 will be displayed as 90%. We use react-number-format to handle formatting and value submission.

<InputPercentage
  name="progress"
  control={methods.control}
  label="Progress"
/>

InputSSN

This is a TextField which is going to format your text as a US Social Security Number. The maximum amount of characters accepted is 9 and the input will be masked by default, you can hide and show the value, clicking on the "eye" icon on the right. We send back a formatted value to the form. You can pass all the attributes available for TextField.

<InputSSN
  name="ssn"
  control={methods.control}
  label="Social Security Number"
/>

InputFEIN

This is a TextField which is going to format your text as a US Federal Identification Number (Tax Id). The maximum amount of characters accepted is 9 and the input will be formatted as you type "12-3456789". We send back a formatted value to the form. You can pass all the attributes available for TextField.

<InputFEIN
  name="fein"
  control={methods.control}
  label="FEIN"
/>

InputDate

This is a MUI Date-Picker, this field will handle dates and submit dates to the form.

<InputDate
  name="birthday"
  control={methods.control}
  label="Birthday"
/>

InputSelect

Select component which is going to accept a group of options and display them as a combobox.

<InputSelect
  name="contactMethod"
  control={methods.control}
  label="Contact Method"
  options={{label: "Phone", value: "Phone"},{label: "Email", value: "Email"}}
/>

InputRadio

Radio component which is going to accept a group of options and display them as radio options.

<InputRadio
  name="contactMethod"
  control={methods.control}
  label="Contact Method"
  options={{label: "Phone", value: "Phone"},{label: "Email", value: "Email"}}
/>

InputCheckbox

Checkbox component to render boolean fields. It will send a boolean value to the form

<InputCheckbox
  name="vaccinated"
  control={methods.control}
  label="Vaccinated?"
/>

InputMultiselect

Select component which is going to accept a group of options and display them as a combobox. The difference between this component and InputSelect is that you can select multiple options. Form will receive an array with the values.

<InputMultiselect
  name="colors"
  control={methods.control}
  label="Colors"
  options={{label: "Blue", value: "Blue"},{label: "Red", value: "Red"}}
/>

InputMultiselectCheckbox

Checkbox component which is going to accept a group of options and display them as a group of checkbox. The difference between this component and InputCheckbox is that you can select multiple options. Form will receive an array with the values.

<InputMultiselectCheckbox
  name="colors"
  control={methods.control}
  label="Colors"
  options={{label: "Blue", value: "Blue"},{label: "Red", value: "Red"}}
/>