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

@mannydiera/first-name

v1.0.3

Published

A first name input field component with validation/error messaging, styling, themes and ADA compliant.

Downloads

11

Readme

@mannydiera/first-name

First Name input field vanilla js component that can be used with or without a js framework

Install

$ npm install @mannydiera/first-name

Usage

After installing, you do not have to import it into your files because the web component is registered on the DOM. Just add the html tag as below.

    <first-name></first-name> 
      Or
    <first-name/>

We can use the concept of 'props' by passing values to the element's data- attributes. Let's call them props for simplicity.

This component contains no mandatory prop and 3 optional props. If any of these props are updated, the component will emit an 'attrChange' event.

optional data-label: Contains the label's text. (Default is 'First Name')

<first-name data-label="First Name"></first-name>

optional data-rules: Contains an array of 1 or more functions that will either return true or the validation message. The functions will be run in order and when one fails, that message will be shown.

// Somewhere in your file or in an imported file in your app
const isTooShort = (val) => (val && val.length > 12) || 'Input must be at least 12 characters';

rules.push(isTooShort);
    <first-name data-rules="rules"></first-name>

optional data-theme: An object containing styles you want to pass as the theme for the success/error messages.

// Sample theme object.
// Note: These colors are the default.
        const myTheme = {
            success: '#ffffff',
            error: 'red',
            default: 'blue',
        };
<first-name data-theme="myTheme"></first-name>

You can set the input field theme globally by using the following classes.

.input-wc-base-theme.success {}
.input-wc-base-theme.error {}
.input-wc-base-theme.defualt {}
.input-wc-base-theme.disabled {}

    

You can also set the root theme for the entire project (input fields and other @mannydiera components) by using these classes.

  .wc-base-global-theme.success {}     
  .wc-base-global-theme.error {}     
  .wc-base-global-theme.default {}     
  .wc-base-global-theme.disabled {}    

Sample 'In App' implementations below.


// Vanilla JS
    ...

// Angular 1.*
    ...

// Angular 2 +
    ...

// React
    ...
    
// Svelte
    ...
    
// Vue
    ...