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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hpv-filterbar

v1.2.1

Published

Hyper Parametrizable Vanilla filterbar, the best independent filter selection tool.

Downloads

13

Readme

HPV-CHECKLIST

Hyper Parametrizable Vanilla FilterBar

Designed to offer flexibility across all environments with no dependecies. Hpv-FilterBar is a First Class solution for webapps mass content filtering. Unlike other options, it is not tied to any css frameworks. It is very small (~8Kb) and customizable through a wide range of options.

Online Demo

Need extra help? Have a look at the examples folder. Fill an issue if necessary.


Features

  • [x] 100% VanillaJS
  • [x] Items from js model.
  • [x] No external dependencies
  • [x] Flexbox based
  • [x] Not attached to any css framework
  • [x] No forced style
  • [x] Remote Search Interface for custom implementation.
  • [x] Vast callback interfaces
  • [x] Custom item renderer support
  • [x] Multi state checkbox (tri-state or more)
  • [x] Optgroup with collapse support
  • [x] Search by items or optgroups
  • [x] Single selection or Multi selections supported. ( All/Optgroup shortcuts )
  • [x] Any translation support via constructor options.

Animation Full Search Search by OptGroup Status Text


Quick start

Install

This package can be installed with:

  • npm: npm install --save hpv-filterbar

Or download the latest release.

CDN

Including Hpvm Menu

Script and Css tag

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/all.css">

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/all.min.js"></script>

Usage

Be sure to call the Hpv once your menu element is available in the DOM.

HTML menu structure with all components

<div id="myFirstCheckList" />

Vanilla JS

document.addEventListener('DOMContentLoaded', function() {

	const checklist1 = new HpvCheckList('checklist1', {
		searchPlaceholder: "Buscar por...",
		selectAllMainText: "Selec. Todos Visíveis",
		selectAllGroupText: "Selec. Grupo",
		clearSearchTooltip: "Limpar a Busca",
		emptyText: "Nenhum item disponível",
		disabledText: "Este item está desabilitado",
		defaultOptGroupText: "Padrão",
		selectMode: 'multiple', // 'single' or 'multiple'
		states: [0, 1, 2, 3, 4],
		onSelect: (checkList, id, changedItem) => console.log('Selected:', id, changedItem),
		onDeselect: (checkList, id, changedItem) => console.log('Deselected:', id, changedItem),
		onSelectGroup: (checkList, groupName, group, changedItems) => console.log('Selected group:', groupName, changedItems),
		onDeselectGroup: (checkList, groupName, group, changedItems) => console.log('Deselected group:', groupName, changedItems),
		onCollapseGroup: (checkList, groupName, group, changedItems) => console.log('Collapsed group:', groupName, group, changedItems),
		onExpandGroup: (checkList, groupName, group, changedItems) => console.log('Expanded group:', groupName, group, changedItems),
		onSelectAll: (checkList, changedItems) => console.log('Selected all:', changedItems),
		onDeselectAll: (checkList, changedItems) => console.log('Deselected all:', changedItems),

		onLocalSearchResult: (searchTerm) => console.log('Search completed for term:', searchTerm),
		onSearchInputDelay: (searchTerm) => console.log('Delayed search for:', searchTerm),
		onClearSearch: () => console.log('Search cleared'),

		fieldMap: {
			keyField: 'id',
			labelField: 'label',
			valueField: 'value',
			optgroupField: 'optgroup',
			disabledField: 'disabled',
		},
	});

	const items = [
		{ id: 1, label: 'Apple', optgroup: 'Fruits', value: 1 },
		{ id: 2, label: 'Banana', optgroup: 'Fruits', disabled: true },
		{ id: 3, label: 'Cherry', optgroup: 'Fruits', value: 2 },
		{ id: 10, label: 'Carrot', optgroup: 'Vegetables', value: 3 },
		{ id: 11, label: 'Broccoli', optgroup: 'Vegetables' },
		{ id: 12, label: 'Spinach', optgroup: 'Vegetables' },
		{ id: 20, label: 'Gol Gti 1.0', optgroup: 'Cars' },
		{ id: 21, label: 'Fiat Palio V8', optgroup: 'Cars' },
		{ id: 22, label: 'Camaro Bubblebee', optgroup: 'Cars' },
	];

});

Methods

The HpvChecklist API offers a couple of methods to control component.

HpvChecklist.addItem(entry)

Register a new item entry.

checklist1.addItem({ 'id': 4, 'label': 'Abacaxi', value: 0 });

HpvChecklist.addItems(array)

Register multiples items at once.

checklist1.addItems([
	{ id: 1, label: 'Apple', optgroup: 'Fruits', value: 1 },
    { id: 2, label: 'Banana', optgroup: 'Fruits', disabled: true },
]);

HpvChecklist.removeAllItems()

Remove all items present on this instance.

checklist1.removeAllItems();

HpvChecklist.removeItem(id)

Remove an item from checklist by its ID, while displaying an beautiful transition effect.

checklist1.removeItem('1');

HpvChecklist.search.clearSearch()

Clear input field value and fire filter callback.

checklist1.search.clearSearch()

HpvChecklist.search.close()

Close sidebar if openned.

HpvChecklist.sidebar.close();

HpvChecklist.search.performLocalSearch(word)

Perform an list filter matching desired word and fire callback.

checklist1.search.performLocalSearch('morango');

HpvChecklist.ui.showEmptyStatus()

Display an user message informing that there is no items loaded in this instance.

checklist1.ui.showEmptyStatus();

HpvChecklist.ui.showCustomStatus( message )

Display an custom message to user.

checklist1.ui.showCustomStatus('This is a test');

HpvChecklist.items.getSelectedItems()

Return an internal model of current selected items, not original objects.

checklist1.items.getSelectedItems()

HpvChecklist.items.getVisibleItems()

Return an internal model of current visible items on list.

checklist1.items.getVisibleItems()

RoadMap

  • [ ] Virtual Scroll
  • [ ] Custom Item Renderer
  • [ ] Limit Max Selected Items

Learn more ( In Progress )

  • [Tutorial]
  • [Options]
  • [Add-ons]
  • [API]

Licence

The hpv-filterbar code is licensed under the Apache-2.0 licence.

Similar projects: