Skip to content

saga95/paste-select

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ PasteBox

npm version npm version License: MIT

The ultimate bulk paste solution for React applications. Parse, validate, and handle thousands of pasted values with ease.

Perfect for enterprise dashboards, admin panels, and data filtering interfaces where users need to paste large lists of IDs, SKUs, emails, or codes.

โœจ Features

  • ๐Ÿš€ Fast: Handles 10,000+ values efficiently
  • ๐ŸŽฏ Smart Parsing: Auto-detects commas, newlines, tabs, semicolons
  • ๐Ÿ” Flexible Validation: In-memory sets or async API validation
  • ๐Ÿ“Š Visual Feedback: Real-time counts and lists of valid/invalid items
  • โš›๏ธ React Ready: Drop-in component with TypeScript support
  • ๐ŸŽจ Headless Core: Use with any UI framework
  • ๐Ÿ“ฆ Zero Dependencies: Lightweight and tree-shakeable

๐Ÿš€ Quick Start

npm install pastebox-react pastebox-core
import { PasteSelect } from "pastebox-react";
import { inMemorySetValidator } from "pastebox-core";

const allowedValues = new Set(["A123", "B456", "C789", "SKU-999"]);

function App() {
  return (
    <PasteSelect 
      validate={inMemorySetValidator(allowedValues)}
      onChange={(result) => {
        console.log(`${result.validate.valid.length} valid items found!`);
      }}
    />
  );
}

๐Ÿ“ฆ Packages

pastebox-core - Headless Utilities

npm install pastebox-core

Pure parsing and validation logic. Framework agnostic.

import { parse, inMemorySetValidator } from "pastebox-core";

const text = "A123,B456\nC789, A123"; // messy input
const result = parse(text);
console.log(result.uniques); // ["A123", "B456", "C789"]

const validator = inMemorySetValidator(new Set(["A123", "C789"]));
const validation = await validator(result.uniques);
// { valid: ["A123", "C789"], invalid: ["B456"] }

pastebox-react - React Component

npm install pastebox-react pastebox-core

Ready-to-use React component with visual feedback.

๐ŸŽฎ Try the Demo

Live Demo โ†’

Try pasting this sample data:

A123, B456
C789; INVALID-001
SKU-999    ITEM-001
A123 (duplicate)

๐Ÿ’ก Use Cases

  • SaaS Dashboards: Bulk SKU/product code filtering
  • Enterprise CRMs: Bulk email or customer ID validation
  • Admin Panels: Import/validate large datasets
  • Marketing Tools: Clean pasted contact lists
  • Internal Tools: Process ticket IDs, reference numbers

๐Ÿ”ง API Reference

Core Functions

parse(input, options)

Parse pasted text into structured data.

type ParseOptions = {
  delimiters?: string[];      // Default: [",", "\n", "\t", ";"]
  normalize?: (v: string) => string;  // Default: v => v.trim()
  caseSensitive?: boolean;    // Default: true
  maxValues?: number;         // Default: 10000
};

Validators

// In-memory validation
const validator = inMemorySetValidator(allowedSet);

// Batched API validation  
const validator = batchedValidator(
  async (batch) => {
    const response = await fetch('/api/validate', {
      method: 'POST',
      body: JSON.stringify({ values: batch })
    });
    return response.json(); // { valid: string[], invalid: string[] }
  },
  500 // batch size
);

React Component

<PasteSelect> Props

Prop Type Required Description
validate ValidateFn โœ… Function to validate values
delimiters string[] โŒ Custom delimiters
normalize (v: string) => string โŒ Value normalizer
maxValues number โŒ Max values (default: 10000)
caseSensitive boolean โŒ Case sensitivity (default: true)
onChange (result) => void โŒ Result callback
className string โŒ CSS class

๐Ÿ—๏ธ Development

# Clone the repository
git clone https://github.com/sagarah/paste-select.git
cd paste-select

# Install dependencies
pnpm install

# Build packages
pnpm build

# Run demo
pnpm dev

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

MIT ยฉ sagarah

๐Ÿ™ Acknowledgments

Built with:


โญ If this library helped you, please consider giving it a star!

About

๐ŸŽฏ The ultimate bulk paste solution for React - parse, validate, and handle thousands of pasted values with ease

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors