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

@juice789/tf2items-selector

v1.0.2

Published

TF2 item selector React hook

Readme

@juice789/tf2items-selector

A React hook that renders a TF2 item selector: pick a category, quality, killstreak tier, effect, filters and so on, stage the resulting SKUs in a preview list and hand them to your app.

The item data comes from @juice789/tf2items.

Install

Two entry points, pick one:

| Import | Peer dependencies | Theming | | --- | --- | --- | | @juice789/tf2items-selector | react, react-dom | theme option only | | @juice789/tf2items-selector/themed | react, react-dom, styled-components@6 | your ThemeProvider + theme option |

Everything else (react-select, react-window, react-icons, the item schema...) is bundled.

npm i @juice789/tf2items-selector
# for /themed, if you don't have it already:
npm i styled-components

Both builds include the item schema, so expect around 4.3 MB unminified / 0.5 MB gzipped.

Usage

import { useItemSelector } from '@juice789/tf2items-selector'

const AddItems = () => {
    const { ItemSelector } = useItemSelector({
        onSave: async (items, { clear }) => {
            await saveToServer(Object.keys(items)) // ['513;11', '205;6', ...]
            clear() // skip this to keep the items if saving failed
        },
        onClose: ({ clear }) => {
            clear()
            hidePanel()
        }
    })

    // the selector fills its container, so the container decides the size
    return <div style={{ width: '25rem', height: '100vh' }}>
        <ItemSelector />
    </div>
}

Options

| Option | Type | Description | | --- | --- | --- | | pages | { [id]: string } | Shows a page picker when it has at least one entry, e.g. { 0: 'Page 1', 1: 'Page 2' }. Each staged item gets the selected page id. Without pages every item gets page '0'. | | onSave | (items, { clear, close }) => void | Called when Save is pressed in the preview list. items is { [sku]: { sku, page } }. Nothing is cleared automatically. | | onClose | ({ clear }) => void | Called after the X button hides the selector. The staged items are kept unless you call clear. | | theme | object | Partial theme, see Theming. | | selectStyle | (theme, options) => object | Returns the react-select styles object. Defaults to the exported selectStyle. | | toggleStyle | object | Styles for the yes/no toggles (@juice789/react-toggle format). Defaults to the exported toggleStyle. |

Return value

| Key | Description | | --- | --- | | ItemSelector | The component. Its identity is stable for the lifetime of the hook, so the form keeps its state across rerenders. | | items | The staged items, { [sku]: { sku, page } }. | | isOpen | false after X or close(). A closed selector renders nothing. | | open() / close() | Show or hide the selector. close() does not call onClose. | | clear() | Empty the staged items and leave the preview list. |

Theming

The selector reads these keys:

import { defaultTheme } from '@juice789/tf2items-selector'

// {
//     fontColorHighlight, fontColor, fontColorDim, fontColorDisabled, buttonTextColor,
//     background1, background2, background3, background4,
//     mainColor, mainColorFade, successColor, errorColor, errorColorFade
// }

The final theme is merged per key: { ...defaultTheme, ...yourThemeProviderTheme, ...themeOption }. Missing keys fall back to the defaults (a dark theme), so a theme with different key names still works. Map your own names in through the theme option:

const { ItemSelector } = useItemSelector({
    theme: { mainColor: myTheme.accent, background1: myTheme.surface }
})

With /themed, a styled-components ThemeProvider above the selector is picked up automatically. The default entry has its own copy of styled-components, so it can't see your ThemeProvider. Use the theme option there.

selectStyle and toggleStyle are exported too, so you can extend them instead of starting from scratch:

import { selectStyle } from '@juice789/tf2items-selector'

const mySelectStyle = (theme, options) => selectStyle(theme, { ...options, controlHeight: '2rem' })

Notes

  • The selector sets its own box-sizing, [hidden] and number-input styles, and inherits font-family from its container.
  • The default entry's styled components use the tf2items-selector- class prefix, so they don't collide with your app's styled-components classes. In development, styled-components may still log a warning about multiple instances. Switch to /themed if you already use styled-components.
  • ESM only. Requires React 18 or newer.