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

@comparaonline/ui-form-fields-next

v3.51.0

Published

## Installation

Downloads

71

Readme

@comparaonline/ui-form-fields-next

Installation

yarn add @comparaonline/ui-form-fields-next

Usage

TextField

import { TextField } from '@comparaonline/ui-form-fields-next';
<TextField
  label="Text Field Demo"
  name="text-field-demo"
  placeholder="Demo placeholder"
/>

The only required prop is name, all the other can be any of the MUI's Text Field props.

RadioGroupField

import { RadioGroupField } from '@comparaonline/ui-form-fields-next';
<RadioGroupField
  name="radioGroupDemo"
  validate={validateWith(required)}
  errorMessage="Error"
  helperText="Radio button family"
  renderLabel={<span>Demo with emoji 🇨🇱</span>}
  options={[
    { label: 'Masculino', value: '99' },
    { label: 'Feminino', value: '100' }
  ]}
/>

CheckboxField

import { CheckboxField } from '@comparaonline/ui-form-fields-next';

Boolean List

<CheckboxField
  name="feature"
  validate={validateList}
  errorMessage="Error validating the Check List"
  helperText="Boolean approach"
  renderLabel={<span>Checkbox Field List ✅</span>}
  options={[
    { name: 'feature.a', label: 'A' },
    { name: 'feature.b', label: 'B' },
    { name: 'feature.c', label: 'C' },
    { name: 'feature.d', label: 'D' }
  ]}
/>

This will create a value like this

{
  "feature": {
    "a": true,
    "d": true
  }
}

Values Array

<CheckboxField
  name="feature"
  validate={validateList}
  errorMessage="Error validating the Check List"
  helperText="Boolean approach"
  renderLabel={<span>Checkbox Field List ✅</span>}
  options={[
    { name: 'feature', label: 'A', value: 'A' },
    { name: 'feature', label: 'B', value: 'B' },
    { name: 'feature', label: 'C', value: 'C' },
    { name: 'feature', label: 'D', value: 'D' }
  ]}
/>

This will create a value like this

{
  "feature": [
    "D",
    "B"
  ]
}

Input Listener

The input listener actually renders a Field component from react-final-form with the same input name that the field that we want to change and uses the onChange function to update its value.

import { Form } from 'react-final-form';
import { TextField } from '@comparaonline/ui-form-fields-next';
import { InputListener } from '@comparaonline/ui-input-listener';

const onSubmit = () => undefined;

<Form onSubmit={onSubmit}>
  {({ handleSubmit }) => (
    <form onSubmit={handleSubmit}>
      <TextField
        name="inputA"
        label="Placa"
      />
      <TextField
        name="inputB"
        label="Placa"
      />
      <InputListener field="inputA" when={value => value === 'foo'} set="inputB" to={new Promise(resolve => resolve('new value'))} />
    </form>}
</Form>;