🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

hpv-checklist

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hpv-checklist

Hyper Parametrizable Vanilla checklist, the best independent checkbox selection tool.

latest
Source
npmnpm
Version
1.2.3
Version published
Maintainers
0
Created
Source

HPV-CHECKLIST

Hyper Parametrizable Vanilla Checklist

Design to offer flexibility across all environments with no dependecies. Hpv-Checklist is a First Class solution for webapps checkbox lists. Unlike other options, it is not tied to a select or floating UI. 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

  • 100% VanillaJS
  • Items from js model.
  • No external dependencies
  • Flexbox based
  • Not attached to any css framework
  • No forced style
  • Remote Search Interface for custom implementation.
  • Vast callback interfaces
  • Custom item renderer support
  • Multi state checkbox (tri-state or more)
  • Optgroup with collapse support
  • Search by items or optgroups
  • Single selection or Multi selections supported. ( All/Optgroup shortcuts )
  • 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-checklist

Or download the latest release.

CDN

Including Hpvm Menu

Script and Css tag

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hpv-checklist@1.0.0/dist/css/all.css">

<script src="https://cdn.jsdelivr.net/npm/hpv-checklist@1.0.0/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-checklist code is licensed under the Apache-2.0 licence.

Similar projects:

Keywords

list

FAQs

Package last updated on 19 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts