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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-custom-fields-autocomplete

v1.0.2

Published

A reusable React component for managing custom fields with autocomplete functionality

Downloads

10

Readme

Custom Fields Autocomplete

A flexible and reusable React component for managing custom fields with autocomplete functionality, built with Material-UI.

Features

  • 🎯 Provider Pattern: Easy configuration and state management
  • 🔄 Reusable: Drop-in component for any React application
  • 🎨 Customizable: Extensive customization options for styling and behavior
  • 📱 Responsive: Works seamlessly across different screen sizes
  • 🔧 TypeScript Ready: Full TypeScript support (types included)
  • Performance: Optimized for smooth user experience

Installation

npm install react-custom-fields-autocomplete

Peer Dependencies

Make sure you have these peer dependencies installed:

npm install react react-dom @mui/material @emotion/react @emotion/styled

Basic Usage

import React, { useState } from 'react';
import { 
  CustomFieldsAutocomplete, 
  CustomFieldsProvider 
} from 'react-custom-fields-autocomplete';

const App = () => {
  const [fields, setFields] = useState([]);

  return (
    <CustomFieldsProvider 
      initialFields={fields}
      onFieldsChange={setFields}
    >
      <CustomFieldsAutocomplete />
    </CustomFieldsProvider>
  );
};

Advanced Configuration

const AdvancedExample = () => {
  const [fields, setFields] = useState([
    { id: 1, label: 'Priority', value: 'High' }
  ]);

  return (
    <CustomFieldsProvider 
      initialFields={fields}
      onFieldsChange={setFields}
      labelOptions={['Priority', 'Category', 'Status']}
      valueOptions={['High', 'Medium', 'Low']}
      labelProps={{
        placeholder: 'Select field name...',
        variant: 'outlined'
      }}
      valueProps={{
        placeholder: 'Select value...',
        variant: 'outlined'
      }}
      buttonProps={{
        addText: 'Add Field',
        removeText: 'Remove'
      }}
    >
      <CustomFieldsAutocomplete />
    </CustomFieldsProvider>
  );
};

API Reference

CustomFieldsProvider Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | initialFields | Array | [] | Initial array of custom fields | | onFieldsChange | Function | undefined | Callback when fields change | | labelOptions | Array | [] | Options for label autocomplete | | valueOptions | Array | [] | Options for value autocomplete | | labelProps | Object | {} | Props passed to label autocomplete | | valueProps | Object | {} | Props passed to value autocomplete | | fieldProps | Object | {} | Props for field container styling | | buttonProps | Object | {} | Props for button customization |

useCustomFields Hook

Returns an object with:

  • customFields: Current array of fields
  • setCustomFields: Function to update all fields
  • addCustomField: Function to add a new field
  • removeCustomField: Function to remove a field by ID
  • updateField: Function to update a specific field
  • Configuration props (labelOptions, valueOptions, etc.)

Field Object Structure

{
  id: number,      // Unique identifier
  label: string,   // Field label/name
  value: string    // Field value
}

Customization Examples

Custom Styling

<CustomFieldsProvider
  fieldProps={{
    paperSx: { 
      backgroundColor: '#f5f5f5',
      border: '2px solid #e0e0e0'
    }
  }}
  buttonProps={{
    addSx: { mt: 2, backgroundColor: 'primary.main' },
    removeSx: { color: 'error.main' }
  }}
>
  <CustomFieldsAutocomplete />
</CustomFieldsProvider>

Custom Implementation

import { useCustomFields } from 'react-custom-fields-autocomplete';

const CustomComponent = () => {
  const { customFields, addCustomField, removeCustomField } = useCustomFields();
  
  return (
    <div>
      <h3>Total Fields: {customFields.length}</h3>
      {/* Your custom UI here */}
    </div>
  );
};

Development

# Install dependencies
npm install

# Build the package
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT © Andrei-Constantin Alexandru

Support