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

@senx/discovery-plugin-form

v0.1.0

Published

Discovery plugin for form

Readme

Discovery Form

This is a declarative form widget dedicated to Discovery.

Usage

In a Web Environment

With NPM/Yarn

$ npm install @senx/discovery-widgets
$ npm install @senx/discovery-plugin-form

With CDN

<script nomodule src="https://unpkg.com/@senx/discovery-widgets/dist/discovery/discovery.js"></script>
<script type="module" src="https://unpkg.com/@senx/discovery-widgets/dist/discovery/discovery.esm.js"></script>


<script type="module" src="https://unpkg.com/@senx/discovery-plugin-form/dist/discovery-plugin-form/discovery-plugin-form.esm.js"></script>
<script nomodule src="https://unpkg.com/@senx/discovery-plugin-form/dist/discovery-plugin-form/discovery-plugin-form.js"></script>

Usage


<html lang="en">
<head>
  <title>Test</title>
</head>
<body>
<discovery-dashboard url="https://warp.senx.io/api/v0/exec" dashboard-title="Test">
{
  'title' 'Test'
  'description' 'Dashboard test'
  'tiles' [
    {
      'title' 'test'
      'x' 0 'y' 0 'w' 12 'h' 4
      'type' 'form'
      'macro' <%
        {
          'events' [ { 'tags' [ 'test' ] 'type' 'variable' 'selector' 'myVar' } ]
          'data' [
            {
              'name' 'make' 'label' 'Choose a maker'
              'type' 'list'
              'data' [ "Toyota" "BMW" "Honda" "Ford" "Chevy" "VW" ]
              'required' T
              'options' { 'col' 4 }
            }
      %>
    }
  ]
}
</discovery-dashboard>
<script nomodule src="https://unpkg.com/@senx/discovery-widgets/dist/discovery/discovery.js"></script>
<script type="module" src="https://unpkg.com/@senx/discovery-widgets/dist/discovery/discovery.esm.js"></script>
<script type="module" src="https://unpkg.com/@senx/discovery-plugin-form/dist/discovery-plugin-form.esm.js"></script>
<script nomodule src="https://unpkg.com/@senx/discovery-plugin-form/dist/discovery-plugin-form.js"></script>

</body>
</html>

General options

  • options.button.label: Custom label for the submit button, "Ok" by default.
  • options.input.validation: Enable form validation
  • options.input.allLabel: Custom label for "All" button
  • options.input.noneLabel: Custom label for "None" button

Plugin options

Form plugin options are declared in extra:

      'options' { 
        'button' { 'label' 'Send' }
        'input' { 'validation' true } 
        'extra' { 'form' { 
          'stickyButton' true 
          'addFormUUID' true
          'diff' true
          } }
      } 
  • stickyButton make the form "Send" button always visible, even if the form is bigger than the tile.
  • addFormUUID add a uuid in the key formUUID of the output variable. It allows to build a logic for tiles listening to multiple events to avoid a replay of the same event, or to miss a new event.
  • diff remove the untouched keys from the output variable. Each send event only contains modifications since the component load or the previous send.

Main usage

Your Discovery macro should return a list of controls or a key value map with a field "data" containing a list of controls.

Each control is placed on a 12 columns width grid. By default, each control is 12 columns width.

Each control is described by:

{
  'name' 'make'                 // Mandatory. Unique control's name  
  'label' 'Choose a maker'      // Optional. Control's label. By default, the control's name is used as label
  'description' 'Bla bla'       // Optional short field description  
  'type' 'list'                 // Mandatory. Type of control (see below)
  'data' [ 'A' 'B' 'C' ]        // Data used by the list
  'default' 'B'                 // Optional default value.
  'required' T                  // Optional, if form validation is enable, mark this control as requiered
  'options' { 
    'col' 4                     // Optional, width of the control over the main grid
    'grid_break' true           // Optional, force a line return in the grid
    'placeholder' 'Choose...'   // Custom input placeholder  
  }         
}

The field by field disabled is not available for every controls type.

Available controls

text (default)

{
  'name' 'myText' 'label' 'Text input sample'  
  'type' 'text'
  'default' 'foo bar' 
  'options' {
    'min' 3         // Optional minimal string length   
    'max' 8         // Optional maximal string length
  }         
  'disabled' true  // cannot edit this field
}

secret

{
  'name' 'mySecret' 'label' 'Password input sample'  
  'type' 'secret'
  'default' 'foo bar' 
  'options' {
    'min' 3         // Optional minimal string length   
    'max' 8         // Optional maximal string length
  }         
}

hidden

{
  'name' 'myHidden' 'label' 'Invisible'  
  'type' 'hidden'
  'default' 'foo bar' 
}

number

{
  'name' 'myNumber' 'label' 'Number input sample'  
  'type' 'number'
  'default' 12 
  'options' {
    'min' 3         // Optional minimal value   
    'max' 80        // Optional maximal value
  }         
  'disabled' true  // cannot edit this field
}

list

Works with a list of strings or a list of numbers

{
  'name' 'myList' 'label' 'List input sample'  
  'type' 'list'
  'data' [ 1995 1996 1997 1998 1999 2000 2001 ] // Use data to set the available values
  'default' 1998
  'disabled' true  // cannot edit this field
}
{
  'name' 'myList' 'label' 'List input sample'  
  'type' 'list'
  'macro' <% [ 'A' 'B' 'C' ] %> // or use a macro to set the available values
  'default' 'B'
}

autocomplete

Like lists, works also with a macro.

Works only with a list of strings.

{
  'name' 'myAutocomplete' 'label' 'Autocomplete input sample'  
  'type' 'autocomplete'
  'data' [ "admiring" "adoring" "agitated" "tiny" "trusting" ] // Use data to set the available values
  'default' "adoring"
}

rating

Like lists, works also with a macro.

{
  'name' 'myRating' 'label' 'Rating input sample'  
  'type' 'rating'
  'data' [ "Beginner" "Skilled" "Experienced" "Advanced" "Expert" ]
  'default' 'Experienced'
}

date, time, datetime

{
  'name' 'myTime' 'label' 'Standard time field'  
  'type' 'time'
  'default' '12:44'
}
{
  'name' 'myDate' 'label' 'Standard date field'  
  'type' 'date'
  'default' NOW
}
{
  'name' 'myDateTime' 'label' 'Standard datetime field'  
  'type' 'datetime'
  'default' NOW
}

radio group

Like lists, works also with a macro.

{
  'name' 'myRadio' 'label' 'Radio'
  'type' 'radio'
  'default' [ "Work" ]
  'data' [ "Home" "Work" ]
}

checkbox, switch

{
  'name' 'myCheckbox' 'label' 'Checkbox'
  'type' 'checkbox'
  'default' true
}
{
  'name' 'mySwitch' 'label' 'Switch'
  'type' 'switch'
  'default' false
}

checkboxes group (multi-cb)

Like lists, works also with a macro.

Your data list can contain either a string or a key/value map.

{
  'name' 'myMultiCb' 'label' 'Multi checkboxes'
  'type' 'multi-cb'
  'default' [ true       false     true       false    false ]
  'data'    [ "admiring" "adoring" "agitated" "tiny" { "name" "opt1" "label" trusting" } ]
}

slider

{
  'name' 'mySlider' 'label' 'Slider sample'
  'type' 'slider'
  'default' 30 
  'options' {
    'min' 10        // Optional minimal value   
    'max' 80        // Optional maximal value
    'step' 10       // Optional increment 
  }  
}