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

react-hook-form-next-ui

v2.0.5

Published

React Components with React Hook Form and NextUI

Downloads

431

Readme

Configure your project

This library is based on NextUI and React-hook-form. Here you will find form components where we combine these two libraries for easier and faster use. There is also refactoring of components (currently modal and table) for faster and more complete use of all functions.

Demo

Storybook - Demo

Install the library

npm i react-hook-form-next-ui

Update tailwind file (tailwind.config.js)

It is important to import the styles from NextUI and this library.

export default {
  content: [
    "./node_modules/react-hook-form-next-ui/dist/**/*.{js,ts,jsx,tsx}",
    "./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [
    nextui()
  ]
}

Example

import { FormProvider, SubmitHandler, useForm } from "react-hook-form"
import { Button } from "@nextui-org/react";
import RHFInput from "../components/RHFInput";
import schema from "../static/schema";
import { yupResolver } from "@hookform/resolvers/yup";
import { IForm } from "../types/app";

const App = () => {
  const methods = useForm<IForm>({
    resolver: yupResolver(schema),
  });

  const onSubmit: SubmitHandler<IForm> = async data => {
    console.log("🚀 ~ Event ~ data:", data)
  }

  return (
    <FormProvider {...methods}>
      <Panel title="Contact Form" collapse>
        <form onSubmit={methods.handleSubmit(onSubmit)}>
          <RHFInput name="user" label="User Name" color="primary" />
          <Button type="submit">Submit</Button>
        </form>
      </Panel>
    </FormProvider>
  )
}

Yup Schema Helpers (Helper)

This documentation provides an overview of custom helpers for validating dates and times, as well as their integration with yup.

Summary

This set of utilities includes:

  • dateMinMaxValidate: Validates a date within a minimum and maximum range.
  • dualDateValidate: Generates rules to validate date pairs (start and end) with range restrictions.
  • dualTimeValidate: Validates time pairs (start and end) with range restrictions.

Example

import * as yup  from "yup";
import { dateMinMaxValidate, dualDateValidate, dualTimeValidate } from "../helpers/yup/dates";

const { endDateRule, startDateRule } = dualDateValidate({
  startDate: "date1",
  endDate: "date2",
  range: 2,
  type: "months",
  maxEndDate: "2024-09-28",
  minEndDate: "2024-09-01",
  maxStartDate: "2024-09-28",
  minStartDate: "2024-09-01"
});

const { endTimeRule, startTimeRule } = dualTimeValidate({
  endTime: "dualtime2",
  startTime: "dualtime1",
  range: 1,
  type: "hours",
})

const rangeValue = dateMinMaxValidate({
  maxDate: "2024-09-05",
  minDate: "2024-09-02"
})

const schema = yup
  .object({
    date: rangeValue.required(),
    date1: startDateRule.required(),
    date2: endDateRule.required(),
    dualtime1: startTimeRule.required(),
    dualtime2: endTimeRule.required(),
  }).required();

export default schema