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

@webhandle/object-list-in-input

v1.0.1

Published

This solves the problem for me where I have a screen to edit an object (an event, a newsletter, etc) and the object has multiple of some sub type of object (like performance dates, documents, etc.)

Readme

Object List in Input

This solves the problem for me where I have a screen to edit an object (an event, a newsletter, etc) and the object has multiple of some sub type of object (like performance dates, documents, etc.)

This code works by using a text/hidden input element to store a JSON list. It then creates UI to visualize that list as a sortable list of objects. The code renders boxes, to show the items, and dialogs to create and edit the items, and the ability to remove options. It writes back to the input element whenever anything changes.

While I intend to use this with a input element as the data store, it's set up to be flexible and asynchronus so that the data could be stored across the network.

Install

npm install @webhandle/object-list-in-input

Dependencies

It uses a number of dependencies to create dialogs, do dragable reordering, etc, but all of these are pretty light, making the use of this code pretty light as well.

Usage

There are lots HTML setups that could work. One of them is like:

<label> Items
	<div class="data">
		<input name="items" type="hidden" class="object-list-view" value="[{&quot;name&quot;: &quot;one&quot;},{&quot;name&quot;: &quot;Angie&quot;},{&quot;name&quot;: &quot;two&quot;}]" />
	</div>
</label>
import ObjectListView from "@webhandle/object-list-in-input"

let inputs = document.querySelectorAll('input[type="hidden"].object-list-view')
for(let input of inputs) {
	let view = new ObjectListView({

		// The input element which holds the data
		input: input
		
		// A string or function to create the fields
		, renderEditForm: 
		` <label>
			Name:
			<br>
			<input name="name" type="text" />
		</label> `
		
		// A string or function that renders summary data
		, renderTileDetails: function(data) {
			return `Name: ${data.name}`
		}
		// Code that gets run after the create/edit dialog opens
		, afterOpen(dialogBodyElement, self) {
			bodyElement.style.backgroundColor = '#eeeeee'
		}
	})
	
	// render all the html, set up listeners
	view.render()
	
	// put it on the page someplace
	input.after(view.el)
}

You have to implement the renderEditForm and renderTileDetails so it matches your data type.

The element in the html with class data is just there to contain the UI elements. The UI could be added anywhere to any element.

Make sure to escape the JSON for the input element value. It's pretty easy to do, but at least one way is to use the package @dankolz/escape-html-attribute-value (which is already used by this package).