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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pcnt_common_react

v1.4.1

Published

Generic components based on MUI

Readme

trak.e logo

Poincenot Common React

Poincenot Common React es una libreria de componentes genéricos de todo tipo escrita en React Typescript basada en el framework Material UI para Poincenot Tech Studio

Forms: React Hook Form

Instalación

npm install --save pcnt_common_react

Ejemplo de uso de un formulario basado en React Hook Form

import React from 'react'

import {
  FormGeneric,
  FieldText,
  FieldCheckbox,
  FieldSelect,
} from 'pcnt_common_react';

const countryOptions = [
  { value: '', label: '' },
  { value: 'AR', label: 'Argentina' },
  { value: 'US', label: 'United States' },
  { value: 'ES', label: 'España' },
];

const UsersForm = () => {
  const initialValues = {
    username: '',
    is_older_than_18: false,
    country: '',
  };

  const validationSchema = yup.object().shape({
    username: yup
      .string()
      // recordá agregarle la prop required en el campo
      // correspondiente si el mismo es requerido.
      .required('El campo nombre de usuario es requerido!'),
    country: yup
      .string()
  });

  const handleSubmit = (values) => {
    return backend(values)
      .then((success) => {
        // acá podes mostrar un toast
        // diciendo que todo salió bien!
        console.log(success);
      })
      .catch((error) => {
        // importante: FormGeneric toma
        // un error de tipo string para
        // mostrar un error al usuario final.
        throw error.message;
      })
  };

  return (
    <FormGeneric
      initialValues={initialValues}
      validationSchema={validationSchema}
      onSubmit={handleSubmit}
      {}
    >
      <FieldText
        name="username"
        label="Username"
        { /*
          gridProps para pasarle las props al wrapper de
          Grid que envuelve al <FieldGeneric> ver API.
          https://material-ui.com/api/grid/
        */ }
        gridProps={{ xs: 4 }}
        required
      />
      <FieldCheckbox
        name="is_older_than_18"
        label="Is older than eighteen"
        gridProps={{ xs: 4 }}
      />
      <FieldSelect
        name="country"
        label="Country"
        options={countryOptions}
        gridProps={{ xs: 4 }}
      />
    </FormGeneric>
  );
}

export default UsersForm;

Ejemplo de uso de FieldGenericTextField

FieldGenericTextField sirve para wrappear aquellos componentes que renderizen internamente un TextField de Material UI. Ya sea el mismo TextField, AutoComplete, DatePicker, etc.

import React from 'react';
import {
  KeyboardDatePicker,
  KeyboardDatePickerProps,
  MuiPickersUtilsProvider
} from '@material-ui/pickers';
import DateFnsUtils from '@date-io/date-fns';
import { 
  FieldGenericTextField,
  IFieldGenericRenderProps,
  IFieldGenericTextField,
} from './FieldGeneric';

type OmitKeyboardDatePickerProps = Omit<KeyboardDatePickerProps, "label" | "name" | "children" | "onChange" | "value">;

interface IFieldDatePicker extends IFieldGenericTextField, OmitKeyboardDatePickerProps {};

const FieldDatePicker = ({
  name,
  label,
  fullWidth = true,
  required,
  gridProps,
  ...props
}:IFieldDatePicker) => {
  return (
    <FieldGenericTextField
      name={name}
      gridProps={gridProps}
      required={required}
    >
      {({ controller, error }:IFieldGenericRenderProps) => (
        <MuiPickersUtilsProvider utils={DateFnsUtils}>
          <KeyboardDatePicker
            value={controller.field.value}
            label={label}
            error={!!error}
            required={required}
            // usa el helperText que hereda de TextField
            helperText={error}
            margin='normal'
            fullWidth={fullWidth}
            onChange={(e) => controller.field.onChange(e)}
            format='dd/MM/yyyy'
            KeyboardButtonProps={{
              'aria-label': 'change date'
            }}
            {...props}
          />
        </MuiPickersUtilsProvider>
      )}
    </FieldGenericTextField>
  );
};

export default FieldDatePicker;

Ejemplo de uso de FieldGenericCheckboxSwitchRadioButton

FieldGenericCheckboxSwitchRadioButton sirve para wrappear aquellos componentes que renderizen internamente componentes de valores booleanos como Checkbox, Switch o RadioButtons

import React from 'react';
import Switch, { SwitchProps } from '@material-ui/core/Switch';
import { 
  FieldGenericCheckboxSwitchRadioButton as FieldGeneric,
  IFieldGenericCheckboxSwitchRadioButton as IFieldGeneric,
  IFieldGenericRenderProps,
} from './FieldGeneric';

interface IFieldSwitch extends IFieldGeneric, Omit<SwitchProps, "name"> {};

// no incluye un helperText
const FieldSwitch = ({
  name,
  label,
  gridProps = {},
  ...props
}:IFieldSwitch) => {
  return (
    <FieldGeneric
      name={name}
      label={label}
      gridProps={gridProps}
      formControlLabelProps={{
        labelPlacement: 'end',
      }}
    >
      {({ controller }:IFieldGenericRenderProps) => (
        <Switch
          checked={controller.field.value}
          onChange={(e) => controller.field.onChange(e.target.checked)}
          color='primary'
          {...props}
        />
      )}
    </FieldGeneric>
  );
};

export default FieldSwitch;

Ejemplo de uso de FieldGenericWithLabelAndHelperText

FieldGenericWithLabelAndHelperText sirve para wrappear aquellos componentes que no correspondan a ninguno de los casos descriptos arriba. Se puede utilizar para wrappear cualquier componente de cualquier tipo que no incluya un label o un helperText.

En el ejemplo de abajo se puede ver como usamos un componente de Editor de código al cual le pasamos el objeto controller del formulario a las props value y onChange para manejarlo de forma controlada, además manejamos el focus con onBlur y onFocus para mostrar el label de FieldGeneric focuseado cuando corresponda.

import React, { useState } from "react";
import {
  FieldGenericWithLabelAndHelperText as FieldGeneric,
  IFieldGenericRenderProps,
  IFieldGenericWithLabelAndHelperText as IFieldGeneric
} from './FieldGeneric';
import { CodeEditor, IAceEditorProps } from '../..';

interface IFieldCodeEditor extends IFieldGeneric, Omit<IAceEditorProps, "name"> {
  height?: string;
};

const FieldCodeEditor = ({
  name,
  label,
  required,
  gridProps,
  height = '300px',
  ...props
}:IFieldCodeEditor) => {
  const [focused, setFocused] = useState(false);

  return (
    <FieldGeneric
      name={name}
      gridProps={gridProps}
      label={label}
      required={required}
      focused={focused}
    >
      {({ controller }:IFieldGenericRenderProps) => (
        <CodeEditor
          name={name}
          onChange={(e) => controller.field.onChange(e)}
          onFocus={() => setFocused(true)}
          onBlur={() => setFocused(false)}
          value={controller.field.value}
          height={height}
          {...props}
        />
      )}
    </FieldGeneric>
  );
};

export default FieldCodeEditor;