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

jb-input-react

v3.4.0

Published

input react component

Downloads

271

Readme

JBInput React

this component is React.js wrapper for jb-input web component.

text input react component with these benefits:

  • easy to add custom regex or function validation.

  • multiple validation with different message.

  • support both RTL and LTR.

  • add label and message in UX friendly format.

  • customizable ui with css variable so you can have multiple style in different scope of your app.

  • custom display for password and number input.

  • support typescript

Demo : Demo: codeSandbox preview for just see the demo and codeSandbox editor if you want to see and play with code

install

using npm

npm i jb-input-react

in your jsx file

import {JBInput} from 'jb-input-react';
<JBInput label="label:" message="hint message under textbox"></JBInput>

events

    //when default property are defined best time for impl your config
    <JBInput onInit={(event) => {}}></JBInput>

    //when dom bound and rendered in browser dom 3 and you can access all property
    <JBInput onLoad={(event) => {}}></JBInput>

    //keyboard event
    <JBInput onKeyDown={(event) => console.log(event.target.value)}></JBInput>
    <JBInput onKeyUp={(event) => console.log(event.target.value)}></JBInput>
    <JBInput onKeyPress={(event) => console.log(event.target.value)}></JBInput>
    <JBInput onChange={(event) => console.log(event.target.value)}></JBInput>
    // when user press enter on type good for situation you want so submit form or call search function on user press enter. 
    <JBInput onEnter={(event) => console.log(event.target.value)}></JBInput>
    //focus event
    <JBInput onFocus={(event) => console.log(event.target.value)}></JBInput>
    <JBInput onBlur={(event) => console.log(event.target.value)}></JBInput>
    //input Event
    <JBInput onInput={(event) => console.log(event.target.value)}></JBInput>
    <JBInput onBeforeInput={(event) => console.log(event.target.value)}></JBInput>

set validation

you can set validation to your input by creating a validationList array and passing in to validationList props:

    const validationList = [
        {
            validator: /.{3}/g,
            message: 'عنوان حداقل باید سه کارکتر طول داشته باشد'
        },
        #you can use function as a validator too
        {
            validator: ({displayValue,value})=>{return value == "سلام"},
            message: 'شما تنها میتوانید عبارت سلام را وارد کنید'
        },
    ]
    <JBInput validationList={validationList}></JBInput>

check validation

you can check if an input value meet your validation standad by creating a ref of the element using React.createRef().

    const elementRef = React.createRef();
    const isValid = elementRef.current.validation.checkValidity(true).isAllValid;

if isValid is true the value of input is valid.

other props

|props name | description | | --------- | ------------------ | | disabled | disable the input | | inputmode | set input mode help mobile device to open proper keyboard for your input like url, search and numeric | | direction | set web-component direction default set is rtl but if you need ltr use |

set custom style

since jb-input-react use jb-input underneath, read jb-input custom style section.

add custom element in input box

in JBInput you can put icon or any other custom html DOM in input box. to doing so you just have to place custom DOM in JBInput tag and add slot="start-section" or slot="end-section" to place it before or after input field.

<JBInput>
    <div slot="end-section">after</div>
    <div slot="start-section">before</div>
</JBInput>

Other Related Docs: