1.0.3 • Published 17 days ago

react-weblineindia-url v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
17 days ago

ReactJS - URL Component

A ReactJS based URL component provides option to add url (like Instagram url, Facebook url, web url, etc.) with validation. The URL value is automatically validated on blur event. You can even disable url field using disable props.

Table of contents

Browser Support

ChromeFirefoxSafariEdgeIE
83.0 ✔77.0 ✔13.1.1 ✔83.0 ✔11.9 ✔

Demo

npm.io

Getting started

Install the npm package:

npm install react-weblineindia-url
#OR
yarn add react-weblineindia-url

Usage

Use the <react-weblineindia-url> component:

import React ,{ Component } from 'react';
import UrlComponent from 'react-weblineindia-url'

class Test extends Component {
  constructor(props) {
    super(props);
    this.state = {
      vData: "",
      isInvalidUrl: false
    };
  }

  onChange(event, isError) {
    this.setState({
      vData: event.target.value,
      isInvalidUrl: isError
    });
  }

  onBlur(event, isError) {
    this.setState({
      isInvalidUrl: isError
    });
  }

  render() {
    return (
      <div>
        <Url
          value={this.state.vData}
          onChange={this.onChange.bind(this)}
          onBlur={this.onBlur.bind(this)}
          placeholder="Enter Url"
        />
        {this.state.isInvalidUrl ? (
          <div className="error-text">
            The URL is not valid
          </div>
        ) : ""}
      </div>
    );
  }
}

export default Test;

Available Props

PropTypedefaultDescription
idStringID for the input
nameStringName for the input
valuestringValue of the component
classnameobjectClass to the input
placeholderStringThe input field will get this placeholder text
hideBooleanfalseHide component
disabledBooleanfalseDisable component
tabindexNumber0Tab index of the component
maxlengthNumber25The input maxlength
regexRegExpThe input regex
autocompleteStringoffThe input of autocomplelete
typeStringtextType for the input
urlttpeString'facebook'Default url type for component 'facebook' you can pass 'instagram','web','linkedin','other'.based on that regex will set.if you pass other you have to pass regex value which you want

Methods

NameDescription
onFocusGets triggered when the autocomplete input field receives focus.
onBlurGets triggered when the autocomplete input field loses focus.
onChangeGets triggered when the autocomplete results got changed.
onKeypressGets triggered when a key gets pressed.
onKeyDownGets triggered when a key gets down.
onKeyUpGets triggered when a key gets up.

Want to Contribute?

  • Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).
  • Fork it.
  • Create new branch to contribute your changes.
  • Commit all your changes to your branch.
  • Submit a pull request.

Collection of Components

We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development


Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT

Keywords

react-weblineindia-url, url-component, react-url-component, react-url-input, reactjs-url, react-url