Skip to content

sdxmessaging/ui-widgets

Repository files navigation

ui-widgets Quality Gate Status

Build powerful form inputs/outputs with mithril and streams.

Open Example Page in Flems.io


Overview

ui-widgets is a simple collection of mithril components for generating rich form inputs or displaying values. These widgets use mithril streams to simplify avoid state management "boilerplate" and allow form complex interactions and validation.


Installation

3rd Party Dependencies

ui-widgets has several lightweight dependencies for building and styling widgets:

Install with NPM

Register the GitHub Package Registry for @sdxmessaging in your .npmrc file:

@sdxmessaging:registry=https://npm.pkg.github.com

Add @sdxmessaging/ui-widgets to your package:

npm i @sdxmessaging/ui-widgets

From CDN

A umd version of the library is available via jsDelivr:

<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/gh/sdxmessaging/ui-widgets/umd/index.js"></script>

Quick-start with example page

A simple demonstration page is available from ui-widgets, open the example.html file:

npm run example

The example page shows how widgets read/write shared streams and file streams. The page source can be found in the umd folder.

Concepts

All widgets accept a "field" configuration and a "value" stream, the streams contain either a simple property or a file list. Any input/display widget that supports the same "value" can share a common stream.

Properties

A property "value" consists of a stream of string, number, or boolean.

The SelectInput, RadioInput, and SelectText widgets require a list of options mapping the value to a label.

Files

A file "value" consists of a stream of file objects. These objects are simple wrappers for standard browser files with extra fields:

  • guid - Auto generated unique id
  • name - The file name, may be modified by image inputs
  • path - A path to the file, used by file display widgets
  • dataUrl (optional) - Scaled image preview generated by image inputs