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

store-dropdown-utils

v1.0.7

Published

A utility + React component package to manage **multi-select dropdowns for sites and stores**. It helps you build grouped options (Sites → Stores) and automatically handles selection logic like:

Downloads

36

Readme

📦 store-dropdown-utils

A utility + React component package to manage multi-select dropdowns for sites and stores. It helps you build grouped options (Sites → Stores) and automatically handles selection logic like:

  • ✅ Select a site → all its stores are selected
  • ✅ Unselect a site → all its stores are unselected
  • ✅ Select all stores → site auto-checks itself
  • ✅ Works seamlessly with react-multi-select-component

✨ Installation

Install with npm:

npm install store-dropdown-utils react react-dom react-multi-select-component

Or with yarn:

yarn add store-dropdown-utils react react-dom react-multi-select-component

🚀 Usage

1. Import the component

import React, { useState } from "react";
import { MultiSelectStores, Option } from "store-dropdown-utils";

const sites = [
  { siteId: "site-1", siteName: "Punjab" },
  { siteId: "site-2", siteName: "Sindh" },
  { siteId: "site-3", siteName: "Balochistan" },
];

const stores = [
  { storeId: "store-1", storeName: "Lahore Store", siteId: "site-1" },
  { storeId: "store-2", storeName: "Faisalabad Store", siteId: "site-1" },
  { storeId: "store-5", storeName: "Karachi Store", siteId: "site-2" },
  { storeId: "store-8", storeName: "Quetta Store", siteId: "site-3" },
];

export default function App() {
  const [selectedStores, setSelectedStores] = useState<Option[]>([]);

  return (
    <div>
      <h2>Store Selector</h2>
      <MultiSelectStores
        sites={sites}
        stores={stores}
        value={selectedStores}
        onChange={setSelectedStores}
        labelledBy="Select Stores"
      />
      <pre>{JSON.stringify(selectedStores, null, 2)}</pre>
    </div>
  );
}

2. Utility Functions

You can also use the pure utility functions without React:

import {
  buildGroupedOptions,
  handleStoreSelectionWrapper,
  Option,
} from "store-dropdown-utils";

const grouped = buildGroupedOptions(sites, stores);
console.log(grouped);

const selected = handleStoreSelectionWrapper([], "storeIds", [], sites, stores);
console.log(selected);

⚙️ API

<MultiSelectStores /> Props

| Prop | Type | Default | Description | | ------------ | ---------------------------------------------------------- | ----------------- | ------------------------------------ | | sites | { siteId: string; siteName: string }[] | required | List of sites (regions/categories). | | stores | { storeId: string; storeName: string; siteId: string }[] | required | List of stores under each site. | | value | Option[] | [] | Currently selected items. | | onChange | (selected: Option[]) => void | undefined | Callback when selected items change. | | labelledBy | string | "Select Stores" | Label for accessibility. | | className | string | undefined | Extra Tailwind/CSS classes. |


Utility Functions

buildGroupedOptions(sites, stores)

  • Builds a grouped list of site headings + stores, formatted for react-multi-select-component.

handleStoreSelectionWrapper(nextSelected, key, prevSelected, sites, stores)

  • Manages selection logic:

    • Site selected → adds all stores
    • Site unselected → removes all stores
    • Auto-manages site checkmarks if all stores are selected

📜 License

MIT © 2025 \Mehroz Farooq