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

data-fields

v5.0.0

Published

Render fields for various types of input.

Downloads

1,502

Readme

data-fields

Render fields for various types of input.

npm

Installation

npm install data-fields --save

API

fields.string(h, options[, value])

Create a field to display text. If editable is set to true the text will be placed inside a textarea element.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.size - String - Set the size of the field. Defaults to normal, other possible choices are small and large.
    • options.value - String - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - String - Value of the field. Takes precedence over options.value

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')
var stringField = fields.string(h, { className: 'MyField' }, 'Some string')

fields.number(h, options[, value])

Create a field to display a number. If editable is set to true the value will be placed inside an input element with type set to number.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.value - Number - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - Number - Value of the field. Takes precedence over options.value

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')
var numberField = fields.number(h, { className: 'MyField' }, 1000)

fields.url(h, options[, value])

Create a field to display a url. If editable is set to true the url will be placed inside an input element. If editable is set to false the url will be displayed as an a element.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.value - String - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - String - Value of the field. Takes precedence over options.value

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')
var urlField = fields.url(h, { className: 'MyField' }, 'http://example.com')

fields.list(h, options[, value])

Create a field to display a list, either from an array or an object. If editable is set to true list-editor will be used to display the list.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.value - Array|Object - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - Array|Object - Value of the field. Takes precedence over options.value.

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')
var listField = fields.list(h, { className: 'MyField' }, ['a', 'b', 'c'])

fields.image(h, options[, value])

Create a field to display an image. If editable is set to true the image's path will be placed inside an input field. If editable is set to false the image itself will be displayed.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.value - String - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - String - Value of the field. Takes precedence over options.value

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')
var imageField = fields.image(h, { className: 'MyField' }, 'http://example.com/example.jpg')

fields.geoJSON(h, options[, value])

Create a field to display geoJSON data on a leaflet map. If editable is set to true the map will include drawing controls.

Arguments

  • h - A hyperscript style DOM builder
  • options - Options object.
    • options.accessToken - String - Mapbox access token if you'd like to use Mapbox.
    • options.tileLayer - String - Leaflet tile layer to use.
    • options.imagePath - String - Path to leaflet images.
    • options.editable - Boolean - Set whether the value is editable or not. Defaults to true.
    • options.value - Object - The value of the field.
    • options.* - Extra properties will be passed to the DOM builder when creating the field.
  • value - Object - Value of the field. Takes precedence over options.value

Example

var fields = require('data-fields')
var h = require('virtual-dom/h')

var geoJSON = {
  type: 'Feature',
  geometry: {
    type: 'Point',
    coordinates: [-122.33636, 47.621958]
  }
}

var geoField = fields.geoJSON(h, { className: 'MyField' }, geoJSON)

Tests

npm install
npm test

License

MIT