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

search-component-advanced

v1.0.2

Published

Componente de búsqueda avanzado con filtros e historial

Readme

search-component-advanced

Un componente de búsqueda avanzado para React con filtros, historial y sugerencias.

🚀 Instalación

npm install search-component-advanced

📖 Uso Básico

import React from 'react';
import SearchComponent from 'search-component-advanced';
import type { SearchItem } from 'search-component-advanced';

function App() {
  const handleSearch = async (query: string, filter?: string): Promise<SearchItem[]> => {
    // Tu lógica de búsqueda
    const response = await fetch(`/api/search?q=${query}&filter=${filter}`);
    return response.json();
  };

  const handleItemSelect = (item: SearchItem) => {
    console.log('Item seleccionado:', item);
  };

  return (
    <SearchComponent
      placeholder="Buscar eventos, equipos, jugadores..."
      onSearch={handleSearch}
      onItemSelect={handleItemSelect}
      showHistory={true}
      showFilters={true}
      maxResults={20}
      filters={[
        { id: "all", label: "Todos", icon: "🔍" },
        { id: "football", label: "Fútbol", icon: "⚽" },
        { id: "basketball", label: "Baloncesto", icon: "🏀" }
      ]}
      popularSuggestions={[
        "Real Madrid", "Barcelona", "Champions League"
      ]}
    />
  );
}

🎛️ Props

| Prop | Tipo | Default | Descripción | |------|------|---------|-------------| | onSearch | (query: string, filter?: string) => Promise<SearchItem[]> | - | Requerido. Función para realizar búsquedas | | placeholder | string | "Buscar..." | Placeholder del input | | maxResults | number | 10 | Máximo número de resultados | | showHistory | boolean | true | Mostrar historial de búsquedas | | showFilters | boolean | true | Mostrar filtros | | debounceMs | number | 300 | Delay del debounce en ms | | filters | SearchFilter[] | [] | Array de filtros disponibles | | popularSuggestions | string[] | [] | Sugerencias populares | | onItemSelect | (item: SearchItem) => void | - | Callback al seleccionar un item | | onHistoryClick | (query: string) => void | - | Callback al hacer click en historial | | onSuggestionClick | (suggestion: string) => void | - | Callback al hacer click en sugerencia |

📝 Tipos

interface SearchItem {
  id: number | string;
  title: string;
  description?: string;
  date?: string;
  imageUrl?: string;
  metadata?: Record<string, any>;
}

interface SearchFilter {
  id: string;
  label: string;
  icon: string;
}

✨ Características

  • ✅ Búsqueda en tiempo real con debounce
  • ✅ Historial de búsquedas persistente (localStorage)
  • ✅ Sugerencias populares personalizables
  • ✅ Sistema de filtros flexible
  • ✅ Navegación completa por teclado (↑↓ Enter Escape)
  • ✅ Diseño responsive y moderno
  • ✅ TypeScript completo
  • ✅ Sin dependencias externas (iconos incluidos)
  • ✅ Componentes modulares exportables individualmente

🎨 Personalización

El componente incluye clases CSS que puedes personalizar:

/* Contenedor principal */
.search-component { }

/* Estados del input */
.search-input-inactive { }
.search-input-active { }

/* Resultados */
.search-results { }
.search-result-item { }
.search-result-selected { }

/* Filtros */
.search-filters { }
.search-filter-active { }

/* Historial */
.search-history { }

🔧 Uso Avanzado

Componentes Individuales

import { 
  SearchInput, 
  SearchFilters, 
  SearchHistory, 
  SearchResults,
  useSearchInput 
} from 'search-component-advanced';

// Usar componentes individualmente
function CustomSearch() {
  const searchProps = useSearchInput({
    onSearch: handleSearch,
    filters: myFilters
  });

  return (
    <div>
      <SearchInput {...searchProps} />
      <SearchFilters {...searchProps} />
      <SearchResults {...searchProps} />
    </div>
  );
}

Hook Personalizado

import { useSearchInput } from 'search-component-advanced';

function MyCustomComponent() {
  const {
    inputValue,
    isActive,
    searchResults,
    handleInputChange,
    handleSearch
  } = useSearchInput({
    onSearch: mySearchFunction,
    debounceMs: 500
  });

  // Tu implementación personalizada
}

📦 Exportaciones

// Componente principal
import SearchComponent from 'search-component-advanced';

// Componentes individuales
import { 
  SearchInput, 
  SearchFilters, 
  SearchHistory, 
  SearchResults 
} from 'search-component-advanced';

// Hook
import { useSearchInput } from 'search-component-advanced';

// Tipos
import type { 
  SearchItem, 
  SearchFilter, 
  SearchProps 
} from 'search-component-advanced';

// Utilidades
import { debounce } from 'search-component-advanced';

🧪 Desarrollo

# Clonar repositorio
git clone https://github.com/tu-usuario/search-component.git

# Instalar dependencias
cd search-component
npm install

# Desarrollar con watch mode
npm run dev

# Build para producción
npm run build

# Ejecutar tests
npm test

# Linting
npm run lint

📄 Licencia

MIT


Desarrollado con ❤️ para mejorar la experiencia de búsqueda en aplicaciones React