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

@inovando/react-components

v1.5.13

Published

> :atom: Very opinionated reusable components (some binded to final-form exclusively)

Downloads

32

Readme

@inovando/react-components

:atom: Very opinionated reusable components (some binded to final-form exclusively)

NPM code style: prettier

Demo

Install

npm install --save @inovando/react-components
# or
yarn add @inovando/react-components

Usage

<Upload />

Upload Component Demo

import React, { Component } from "react";

import { Upload } from "@inovando/react-components";
import "@inovando/react-components/dist/index.css";

const App = () => {
  const [files, setFiles] = useState([]);

  return (
    <Upload
      onChange={(files) => {
        setFiles(files);
      }}
      value={files}

      // This overrides "locale" prop
      label="Arraste arquivos ou clique aqui para fazer upload"

      // Only "pt" or "en" yet, defaults to "pt"
      locale="pt"

      // Accept file type range (Optional)
      // https://react-dropzone.js.org/#section-accepting-specific-file-types
      accept="image/*"

      // in mb (Optional)
      maxSize={3}

      // custom style for container
      style={{ margin: '0 auto', maxWidth: 400 }}
    />
  );
};

Final-Form Adapters

Install final-form

npm install --save final-form react-final-form
# or
yarn add final-form react-final-form

<UploadField /> (based on React Dropzone)

Check out "initialValues" example

import React from 'react';
import { Form, Field } from 'react-final-form';
import { UploadField } from '@inovando/react-components';
import '@inovando/react-components/dist/index.css';

function ExampleForm() {
  const onSubmit = values => {
    console.log('values:', values)
  }

  return (
    <Form
      onSubmit={onSubmit}
      initialValues={{
        files: [],
      }}
      render={({ handleSubmit, submitting }) => (
        <form onSubmit={handleSubmit} noValidate>
          <Field
            name="files"
            component={UploadField}
            label="Arraste arquivos ou clique aqui para fazer upload"
            validate={(value) =>
              value.length ? undefined : 'Campo obrigatório'
            }
          />
          <button disabled={submitting} type="submit">
            submit
          </button>
        </form>
      )}
    />
  );
}

<MoneyField /> (based on React Number Format)

Check out "initialValues" example

import React from 'react';
import { Form, Field } from 'react-final-form';
import { MoneyField } from '@inovando/react-components';
import '@inovando/react-components/dist/index.css';

function ExampleForm() {
  const onSubmit = values => {
    console.log('values:', values)
  }

  return (
    <Form
      onSubmit={onSubmit}
      initialValues={{
        money: 0.5,
      }}
      render={({ handleSubmit, submitting }) => (
        <form onSubmit={handleSubmit} noValidate>
          <Field
            name="money"
            component={MoneyField}
            fullWidth
            margin="normal"
            variant="outlined"
            label="Valor (R$)"
            validate={(value) => (value ? undefined : 'Campo obrigatório')}
          />
          <button disabled={submitting} type="submit">
            submit
          </button>
        </form>
      )}
    />
  );
}

<AutocompleteField /> (based on Material-UI Autocomplete)

Check out "initialValues" example

import React from 'react';
import { Form, Field } from 'react-final-form';
import { AutocompleteField } from '@inovando/react-components';
import '@inovando/react-components/dist/index.css';

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

function ExampleForm() {
  const [loading, setLoading] = useState(false);

  const onSubmit = values => {
    console.log('values:', values)
  }

  return (
    <Form
      onSubmit={onSubmit}
      render={({ handleSubmit, submitting }) => (
        <form onSubmit={handleSubmit} noValidate>
          <Field
            name="state"
            component={AutocompleteField}
            fullWidth
            margin="normal"
            variant="outlined"
            label="Estado"
            options={[
              { label: 'Paraná', value: 'PR'},
              // ...
            ]}
            handleChange={(value) => {
              console.log('value:', value);
            }}
            onSearch={async (text) => {
              setLoading(true);
              await sleep(1000);
              setLoading(false);
            }}
            kind="value" // expects "initialValue" as anything but an object, defaults to "object"
            delay={500} // "onSearch" debounce delay in ms, defaults to 250
            loading={loading}
            validate={(value) => (value ? undefined : 'Campo obrigatório')}
          />
          <button disabled={submitting} type="submit">
            submit
          </button>
        </form>
      )}
    />
  );
}

<DateField /> (based on Material-UI Pickers)

Check out "initialValues" example

import React from 'react';
import { Form, Field } from 'react-final-form';
import { DateField } from '@inovando/react-components';
import '@inovando/react-components/dist/index.css';

// Material-UI Pickers Dependencies
import { MuiPickersUtilsProvider } from '@material-ui/pickers';
import DateFnsUtils from '@date-io/date-fns';
import ptLocale from 'date-fns/locale/pt';

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

function ExampleForm() {
  const [loading, setLoading] = useState(false);

  const onSubmit = values => {
    console.log('values:', values)
  }

  return (
     // this tag can be at your global scope, such as "App.js"
     <MuiPickersUtilsProvider utils={DateFnsUtils} locale={ptLocale}>
      <Form
        onSubmit={onSubmit}
        render={({ handleSubmit, submitting }) => (
          <form onSubmit={handleSubmit} noValidate>
            <Field
              name="dataInicio"
              component={DateField}
              minDate={new Date()} // final-form validation logic must be at "validate" prop
              fullWidth
              margin="normal"
              variant="outlined"
              label="Data de início"
              validate={(value) =>
                value && isBefore(subDays(new Date(), 1), parseISO(value))
                  ? undefined
                  : 'Campo inválido'
              }
            />
            <button disabled={submitting} type="submit">
              submit
            </button>
          </form>
        )}
      />
    </MuiPickersUtilsProvider>
  );
}

License

MIT © inovando