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

@arcwp/gateway-filters

v1.0.2

Published

Reusable filter components for Gateway collections - supports select, text, range, and date range filters

Readme

@gateway/filters

Reusable filter components for Gateway collections. Provides a set of flexible, composable filter components for building search and filtering interfaces.

Installation

npm install @gateway/filters

Features

  • 🎯 Multiple Filter Types: Select, text, numeric range, and date range filters
  • 🎨 Tailwind CSS Styling: Beautiful, responsive design out of the box
  • Debounced Text Input: Optimized search performance
  • 🔄 Flexible Layout: Row or stack layout options
  • 🎪 Factory Pattern: Generic Filter component routes to specific types
  • 📦 Zero Dependencies: Only requires React and WordPress Element

Filter Types

SelectFilter

HTML5 select dropdown with configurable options.

import { SelectFilter } from '@gateway/filters';

<SelectFilter
  label="Status"
  choices={[
    { value: 'active', label: 'Active' },
    { value: 'inactive', label: 'Inactive' }
  ]}
  value={selectedValue}
  onChange={(value) => console.log(value)}
  placeholder="Select status..."
/>

TextFilter

Text input with automatic debouncing for search functionality.

import { TextFilter } from '@gateway/filters';

<TextFilter
  label="Search"
  value={searchText}
  onChange={(value) => console.log(value)}
  placeholder="Search..."
  debounce={300}
/>

RangeFilter

Min/max numeric range inputs.

import { RangeFilter } from '@gateway/filters';

<RangeFilter
  label="Price Range"
  value={{ min: '0', max: '100' }}
  onChange={({ min, max }) => console.log(min, max)}
  min={0}
  max={1000}
  minPlaceholder="Min"
  maxPlaceholder="Max"
/>

DateRangeFilter

Start/end date inputs using HTML5 date pickers.

import { DateRangeFilter } from '@gateway/filters';

<DateRangeFilter
  label="Date Range"
  value={{ start: '2024-01-01', end: '2024-12-31' }}
  onChange={({ start, end }) => console.log(start, end)}
  startPlaceholder="Start Date"
  endPlaceholder="End Date"
/>

Generic Filter Component

The Filter component acts as a factory that renders the appropriate filter type based on configuration:

import { Filter } from '@gateway/filters';

const filterConfig = {
  type: 'select',
  label: 'Status',
  field: 'status',
  choices: [
    { value: 'active', label: 'Active' },
    { value: 'inactive', label: 'Inactive' }
  ]
};

<Filter
  filter={filterConfig}
  value={value}
  onChange={(value) => console.log(value)}
/>

Filter Configuration Object

{
  type: 'select' | 'text' | 'range' | 'date_range',
  label: string,
  field: string,

  // For select filters
  choices?: Array<{ value: string, label: string }>,

  // For range filters
  min?: number,
  max?: number,

  // Placeholders
  placeholder?: string | { min?: string, max?: string, start?: string, end?: string }
}

Filters Layout Container

The Filters component provides a flex layout container for organizing multiple filters:

import { Filters, Filter } from '@gateway/filters';

<Filters direction="row">
  <Filter filter={filter1} value={value1} onChange={handler1} />
  <Filter filter={filter2} value={value2} onChange={handler2} />
  <Filter filter={filter3} value={value3} onChange={handler3} />
</Filters>

Layout Options

  • direction="row" - Horizontal layout (default)
  • direction="stack" - Vertical layout

Complete Example

import { useState } from 'react';
import { Filters, Filter } from '@gateway/filters';

function MyFilteredList() {
  const [filters, setFilters] = useState({
    search: '',
    status: '',
    priceRange: { min: '', max: '' },
    dateRange: { start: '', end: '' }
  });

  const filterConfigs = [
    {
      type: 'text',
      label: 'Search',
      field: 'search',
      placeholder: 'Search products...'
    },
    {
      type: 'select',
      label: 'Status',
      field: 'status',
      choices: [
        { value: 'active', label: 'Active' },
        { value: 'inactive', label: 'Inactive' }
      ]
    },
    {
      type: 'range',
      label: 'Price Range',
      field: 'priceRange',
      min: 0,
      max: 1000
    },
    {
      type: 'date_range',
      label: 'Created Date',
      field: 'dateRange'
    }
  ];

  const handleFilterChange = (field, value) => {
    setFilters(prev => ({ ...prev, [field]: value }));
  };

  return (
    <div>
      <Filters direction="row">
        {filterConfigs.map(config => (
          <Filter
            key={config.field}
            filter={config}
            value={filters[config.field]}
            onChange={(value) => handleFilterChange(config.field, value)}
          />
        ))}
      </Filters>

      {/* Your filtered content here */}
    </div>
  );
}

Styling

Components use Tailwind CSS classes. Ensure Tailwind is configured in your project:

// tailwind.config.js
module.exports = {
  content: [
    './src/**/*.{js,jsx,ts,tsx}',
    './node_modules/@gateway/filters/**/*.{js,jsx}'
  ],
  // ... other config
}

Requirements

  • React 18+
  • @wordpress/element 5+
  • Tailwind CSS (for styling)

License

MIT © ARCWP

Support