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

@localnerve/editable-object

v0.3.14

Published

A vanillajs editable-object web component for visual object display and editing

Downloads

299

Readme

editable-object

npm version

A small, fast, no-dependency, editable object web component.

Overview

A native web component for an editable object that allows a user to edit it's values, add or remove key/value pairs. JSON values only.
Non-browser module exports build helpers (for building CSP rules, etc).

A convenient, no-dependency drop-in 'todo' app component to test/round-trip data updates and mutations on the front end.

Quick Links

Events

This web component issues a 'changed' CustomEvent when an object property is added, edited, or removed.
The format of the event.detail is as follows:

{
  action: 'add' | 'edit' | 'remove',
  key: '<the property key name>',
  previous: '<the previous value, null if action: 'add'>',
  new: '<the new value, null if action: 'remove'>'
}

Event Usage Example

Attributes (and Properties)

  • object - Optional. The initial object to edit - Must be a JSON stringified object. Can be added later without JSON stringification via the javascript property object.

    Property name is also object.

  • add-property-placeholder - Optional. The text that prompts a user to add a new property to the object. Defaults to 'Add new property in key:value format'.

    Property name is addPropertyPlaceholder.

  • disable-edit - Optional. Disallow the editing functions. Makes this component a read-only view of the object.

    Property name is disableEdit.

Named Slots

  • "loading" - Optional. A named slot you can use to bring in content to display during loading. Hidden after initial object parse or later when object is set.

Javascript Public Properties and Methods

  • Property object {Object} - Assign a javascript Object to set the component's internals for editing. Any existing object is replaced. JSON compatible properties only (string, number, boolean, array, object, null).

  • Property addPropertyPlaceholder {String} - Assign a prompt to show the user in the new property/value input box to override the default 'Add new property in key:value format'.

  • Property disableEdit {Boolean} - Assign to true to make the control read-only and disallow any editing.

  • Property onEdit {Function} - Assign to a javascript function to be called on edit. Use to supply custom validation to an object property value before edit. Receives the property name and proposed new value from the user. Return true to allow the edit to proceed, or false to invalidate it.

  • Property onAdd {Function} - Assign to a javascript function to be called on add. Use to supply custom validation to an object property value before add. Receives the new property name and proposed value from the user. Return true to allow the add to proceed, or false to invalidate it.

  • Property onRemove {Function} - Assign to a javascript function to be called on remove. Can be used to supply custom validation to allow a property to be deleted. Receives the property name and value. Return true to allow the delete to proceed, or false to stop it.

  • Method mergeObject(newObject) - Call to merge more properties into the underlying object under edit.

Overridable CSS Variables

  • --eo-min-width - The min-width for the component. Defaults to 300px.
  • --eo-bg-color - The overall control background color. Defaults to #fafafa.
  • --eo-border-radius - The border-radius of the control. Defaults to 4px.
  • --eo-border-focused-color - The color of the control border when focused. Defaults to #444.
  • --eo-border-defocused-color - The color of the control border when not focused. Defaults to #aaa.
  • --eo-item-selected-bg-color - The background color of the property list item when selected. Defaults to #999.
  • --eo-item-selected-color - The foreground text color of the property list item when selected. Defaults to #222.
  • --eo-item-selected-border-radius - The border-radius of the item selection box. Defaults to 4px.
  • --eo-item-hover-border-width - The hover border width. Defaults to 1px.
  • --eo-item-hover-border-color - The hover border color. Defaults to #ddd.
  • --eo-item-hover-border-radius - The border-radius of the item hover box. Defaults to 4px.
  • --eo-icon-color - The color of the toolbar button icons. Defaults to #444.
  • --eo-add-new-icon-color - The color of the 'add new property' toolbar button icon. Defaults to #444.
  • --eo-input-focus-outline-color - The color of the focus ring on the input boxes. Defaults to #26b.
  • --eo-input-focus-outline-width- The width of the focus ring on the input boxes. Defaults to 1px.
  • --eo-input-focus-outline-style - The style of the focus ring on the input boxes. Defaults to 'auto'.
  • --eo-input-border-color - The border color of 'add' and 'edit' input boxes. Defaults to #bbb.
  • --eo-input-border-radius - The border radius of an input control. Defaults to 4px.
  • --eo-input-bg-color - The background color of input controls. Defaults to #444.
  • --eo-input-color - The foreground text color of input controls. Defaults to #eee.
  • --eo-input-font-family - The font family of input controls. Defaults to 'sans-serif'.
  • --eo-input-placeholder-color - The foreground text color of input placeholder text. Defaults to #aaa.

Usage Example

  <editable-object object="{'property1':'value1','property2':'value2'}" add-property-placeholder="Add property in key:value format"></editable-object>

See The test references for more usage examples, run them using npm run test:server.

Non-browser Exports

The non-browser version of the module exports methods to help with builds.

{Promise} getEditableObjectCssText()

Asynchronously gets the raw shadow css text.
Useful for computing the hash for a CSP style rule.
Returns a Promise that resolves to the full utf8 string of css text.

License

LocalNerve BSD-3-Clause Licensed

Contact

twitter: @localnerve email: [email protected]