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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tlx-editor

v0.1.1

Published

A single HTML component supporting all input types, select, textarea, radio groups, and star ratings.

Downloads

8

Readme

tlx-editor

A single HTML component supporting multiple input types, select, textarea, radio groups, and star ratings.

Installation

npm install tlx-editor

Usage

Load the files you need from the node_modules/tlx/browser/tlx.js and ./browser/tlx-editor.js directories. Or, copy files around as you need to fit your file system structure.

Use the custom tag <tlx-input> in place of <input>, <select> and <textarea>. Fields will behave like they are in a form and use native validation styling even if you do not put them inside a form tag.

All the base values for the <input> attribute type supported by your browser will work. In addtion, you can use:

  1. type="rating" for a star rating. It defaults to 5 stars, but you can add more by setting the attribute max to a value.

  2. type="radiogroup" with the attribute options="[<some values>...]". Optionally provide a value to have it pre-selected.

  3. type="select-one" with the attribute options="[<some values>...]" for a single value select. Optionally provide a value to have it pre-selected.

  4. type="select-multiple", also with the attribute options. Optionally provide an array for value to have them pre-selected, e.g. value="[1,3]".

  5. type="textarea" where you you would normally use <textarea>.

Since not all browsers support custom elements, you must perform an initial transform on the page. Once all browsers support custom elements, tlx will be enhanced to take advantage of it. See the tlx documentation for more detail. For now, using onload will work:

<body onload="tlx(document.getElementById('app'))">
<div id="app">
... your html here ...
<div>
</body>

Below is an example screen showing several editors:

example screen

Below is the code from examples/index.html. The use of JavaScript template literals requring tlx processing is optional.

<html>
<head>
<script src="../node_modules/tlx/browser/tlx.js"></script>
<script src="../browser/tlx-editor.js"></script>
<style>
input:invalid {border: 2px solid red;}
</style>
</head>
<body onload="tlx.bind({name:'Joe',age:20,honorific:'Mx.',seatingPreferences:['aisle','exit'],optIn:true,tier:'gold',notes:'',attest:'',rating:3})(document.getElementById('page'))">
<div id="page">
	<form>
	
	<p><tlx-editor type="text" value="${name}" label="Name:" t-on="${{input:this.linkState('name')}}" required></tlx-editor></p>
	
	<p><tlx-editor type="number" value="${age}" min="0" max="115" label="Age:" t-on="${{change:this.linkState('age')}}"></tlx-editor></p>
	
	<p><tlx-editor type="select-one" value="${honorific}" options="${['Ind.','Misc.','Mr.','Mrs.','Ms.','Mx.','Dr.','Msgr.','Rev.','Sir']}" label="Honorific:" t-on="${{change:this.linkState('honorific')}}"></tlx-editor></p>
	
	<p><tlx-editor type="select-multiple" value="${seatingPreferences}" options="${['aisle','middle','window','exit','bulkhead','rear']}" label="Seating Preference:" t-on="${{change:this.linkState('seatingPreferences')}}"></tlx-editor></p>
	
	<p><tlx-editor type="checkbox" value="${optIn}" label="Opt In:" t-on="${{click:this.linkState('optIn')}}"></tlx-editor></p>
	
	<p><tlx-editor type="radiogroup" value="${tier}" label="Tier:" options="${['bronze','silver','gold']}" t-on="${{click:this.linkState('tier')}}"></tlx-editor></p>
	
	<p><tlx-editor type="textarea" value="${notes}" label="Notes:" t-on="${{input:this.linkState('notes')}}"></tlx-editor></p>
	
	<p><tlx-editor type="rating" value="${rating}" label="Rating:" max="5" style="color:yellow" t-on="${{change:this.linkState('rating')}}"></tlx-editor></p>
	
	<p><tlx-editor type="text" value="no" options="${['yes','no']}" label="Verified (yes or no):" t-on="${{change:this.linkState('attest')}}"></tlx-editor></p>
	
	<p><input type="submit"></p>
	
	</form>
	
	<p>${honorific} ${name}, a ${rating} star customer, has opted ${(optIn ? "in" : "out")} and prefers the following seating: ${seatingPreferences.join(", ")} with ${tier} tier priority.</p>
	
	<table><tr><td>Notes: </td><td>${notes}</td></table>
	</body>
</div>
</html>

Rationale and Roadmap

  1. We needed a simple way to put edit controls in a table in a uniform way to simulate a spreadsheet.

  2. Over time we will enhance the control to provide cross browsers support for unsupported special types, e.g. date calendars are not supported in Firefox. we will also add additional types, e.g. range, which will operate like a like a tow sides slider with an array as a value containing its selected min and max rather than absolute min and max.

Release History

2017-12-02 v0.1.1 Updated for compatibility with tlx v0.1.7

2017-11-07 v0.1.0 Initial public release