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

mcfacetbox

v0.1.7

Published

A reusable Vue 3 + Vuetify facet box component supporting flat, tree, and switch facets.

Readme

MCFacetBox

Faceted filter UI for search results in Vue 3 + Vuetify. MCFacetBox provides three facet modes — flat list, tree view, and a boolean switch — to help users narrow down search results quickly and intuitively.

Installation

# Using pnpm or npm
pnpm add mcfacetbox
npm install mcfacetbox

Note: The package bundles Vuetify base styles and MDI icons internally — you do not need to configure icon sets or import @mdi/font in your app.


## Quick Start

Install as a plugin:

```ts
// main.ts
import { createApp } from 'vue'
import { createVuetify } from 'vuetify'
import App from './App.vue'
import MCFacetBoxPlugin from 'mcfacetbox'
import 'mcfacetbox/style.css'

const app = createApp(App)
// Important: register Vuetify in your app
const vuetify = createVuetify()
app.use(vuetify)

// Register MCFacetBox plugin (globally registers the component)
app.use(MCFacetBoxPlugin)
app.mount('#app')

Or import the component directly:

<script setup lang="ts">
import { MCFacetBox } from 'mcfacetbox'
import 'mcfacetbox/style.css'
</script>

<template>
  <MCFacetBox />
</template>

What It Does

MCFacetBox is designed for faceted filtering in search/result pages. Typical use cases:

  • Category filters (flat list) with multi-select and counts
  • Hierarchical filters (tree view) with single independent activation
  • Availability or flags (switch) for quick true/false toggles

Selections are emitted to the parent so you can apply them to your search query or API call.

Props

  • dataitems: IFacetItem[]: Facet items array. Each item includes key, title, count. For tree mode, provide parentKey.
  • searchable: boolean: Shows a search input for filtering.
  • facettitle: string: Title of the facet box (flat and tree modes).
  • istree?: boolean: Enables tree view when true; otherwise flat list.
  • scrollItemCount?: number: Max visible rows in flat list before scrolling.
  • scrollItemHeight?: number: Min height of flat list items; default value is 43.
  • selectedItems?: string[]: Initial selection. For switch mode, one value 'true' | 'false'. For flat/tree, an array of keys.
  • facettype?: FacetType: Facet mode: flat, tree, or switch. Defaults to flat unless istree is true.
  • direction?: 'ltr' | 'rtl': Optional layout direction override. If omitted, auto-detects from the page dir (defaults to ltr).

Type signature:

interface IFacetItem {
  key: string
  title: string
  count: number
  parentKey?: string // for tree mode
}

Emits

  • update:selectedItems: string[] — Emitted whenever selection changes.
    • Flat: selected item keys (multi-select)
    • Tree: activated node keys (single-independent)
    • Switch: ['true'] or ['false']

Behavior Details

  • Search box filters by title client-side using a compact text field.
  • Direction (ltr/rtl) auto-detects from document dir, unless overridden.
  • Tree view uses single-independent activation to avoid selecting parent and child simultaneously.
  • List rows show a checkbox on the left and an item count on the right.
  • Switch mode displays a label from dataitems[0].title and toggles 'true'/'false'.

Icons & Styles

  • No icon configuration required. The library imports Vuetify base CSS and MDI icon font internally.
  • App needs Vuetify installed and registered via app.use(createVuetify()).

Examples

Flat list (multi-select):

<script setup lang="ts">
import { ref } from 'vue'
import { MCFacetBox } from 'mcfacetbox'
import type { IFacetItem } from 'mcfacetbox'

const selected = ref<string[]>([])
const items: IFacetItem[] = [
  { key: 'history', title: 'History', count: 42 },
  { key: 'science', title: 'Science', count: 17 },
]
</script>

<template>
  <MCFacetBox
    :dataitems="items"
    :searchable="true"
    facettitle="Categories"
    facettype="flat"
    :selectedItems="selected"
    @update:selectedItems="selected = $event"
  />
  <div>Selected: {{ selected }}</div>
</template>

Tree view (single-independent):

<MCFacetBox
  :dataitems="[
    { key: 'root', title: 'All', count: 59 },
    { key: 'root/history', title: 'History', parentKey: 'root', count: 42 },
    { key: 'root/science', title: 'Science', parentKey: 'root', count: 17 },
  ]"
  facettitle="Subjects"
  :istree="true"
  facettype="tree"
  :selectedItems="selected"
  @update:selectedItems="selected = $event"
/>

Switch facet (boolean):

<MCFacetBox
  :dataitems="[{ key: 'false', title: 'Only Available', count: 23 }]"
  facettype="switch"
  :selectedItems="selected"
  @update:selectedItems="selected = $event"
/>

Direction override:

<MCFacetBox
  :dataitems="items"
  facettitle="Tags"
  facettype="flat"
  direction="rtl"
/>

Apply Selected Filters

Combine MCFacetBox with your search logic by watching selected and querying your backend accordingly:

watch(selected, (keys) => {
  // Example: build query params and call your API
  const params = new URLSearchParams()
  keys.forEach((k) => params.append('facet', k))
  fetch(`/api/search?${params.toString()}`)
})

Development

pnpm install
pnpm -C packages/mcfacetbox typecheck
pnpm -C packages/mcfacetbox build

License

MIT