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

js-utils-react

v3.3.2

Published

A package where you will get react js utility hooks and small components

Downloads

831

Readme

Welcome to javascript Utility for React.(js-utils-react)🖐

(js-utils-react). This is npm package made for who are react developer and don't have much time to create small and effective utility functions or components from scratch. Like, complete reusable button with all kinds of feature, or an input field with validations, or hooks like click outside to close a toggle section download features, etc. The main defference amongs other packages and this package is: the others don't provide you complete utility components or functions, you have to modify after download or installation. But our case it's not same. you can just use it as it is. just declare and provide apropreate props, your work will be done. You will get step by step guidence bellow, and remember mose of the case props are almost same. If you stuck then you can see source code for better understanding. Please check it out. Or you can contribute to make it so powerful and popular, contributers are always welcome.👍

Authors

Input Fields documentation.

1. LTCustomTypeInput Component

The LTCustomTypeInput (Label top custom type input) component is a reusable and customizable input field built using React and TypeScript. It provides a simple interface for developers to include labeled input fields in their forms with ease. This component supports features like placeholder text, default values, required fields, and dynamic value updates via state.


Features

  • Customizable input container and field IDs for flexible integration.
  • Support for default values and placeholder text.
  • Labels that dynamically hide or appear based on the presence of a value.
  • Real-time value update via a state setter function.
  • Configurable input types (e.g., text, number, email, etc.).
  • Support for required fields.

Installation

npm install js-utils-react

Invocation

import React, { useState } from "react";
import LTCustomTypeInput from "./components/LTCustomTypeInput";

const App: React.FC = () => {
  const [inputValue, setInputValue] = useState<string>("");

  return (
    <div>
      <h1>Example Input</h1>
      <LTCustomTypeInput
        inputContainerId="username-container"
        inputFieldsId="username"
        fieldName="username"
        labelText="Username"
        placeholderText="Enter your username"
        isRequired={true}
        defaultVal=""
        targetCatcher={setInputValue}
        inputType="text"
      />
      <p>Current Value: {inputValue}</p>
    </div>
  );
};

export default App;

Props

The LTCustomTypeInput component accepts the following props:

| Prop Name | Type | Description | Required | |--------------------|-------------------------------------------|-----------------------------------------------------------------------------|----------| | inputContainerId | string | ID for the input container element. | Yes | | inputFieldsId | string | ID for the input field element. | Yes | | fieldName | string | Name attribute for the input field (used in forms). | Yes | | labelText | string | The text displayed as the input's label. | Yes | | placeholderText | string | undefined | Placeholder text displayed in the input field (optional). | No | | defaultVal | string | number | undefined | Default value for the input field (optional). | No | | isRequired | boolean | Whether the input field is required. | Yes | | targetCatcher | Dispatch<SetStateAction<string>> | Function to catch and update the input field's value in the parent state. | Yes | | inputType | string | The type of input (e.g., text, number, email, etc.). | Yes |

2. LTEmailInput Component

The LTEmailInput(Label top email input) component is a React-based reusable email input field with real-time validation. It allows users to input an email address, validates the domain against a predefined list, and provides feedback on validity. This component is built using TypeScript for type safety.


Features

  • Real-Time Validation: Validates the entered email's domain from a predefined list.
  • Dynamic Feedback: Displays feedback messages based on the validity of the email.
  • Customizable: Fully customizable props for labels, placeholders, and validation messages.
  • Styling Options: Conditional styling for valid, invalid, and neutral states.
  • Default Email Support: Supports default email values.

Installation

npm install js-utils-react

Invocation

import React, { useState } from "react";
import LTEmailInput from "./components/LTEmailInput";

const App: React.FC = () => {
  const [email, setEmail] = useState<string>("");

  return (
    <div>
      <h1>Email Input Example</h1>
      <LTEmailInput
        inputContainerId="email-container"
        inputFieldsId="email"
        fieldName="email"
        labelText="Email Address"
        placeholderText="Enter your email"
        isRequired={true}
        defaultEmail=""
        targetCatcher={setEmail}
        targetValue={email}
      />
      <p>Current Email Value: {email}</p>
    </div>
  );
};

export default App;

| Prop Name | Type | Description | Required | |---------------------|--------------------------------------|-------------------------------------------------------------------------------|--------------| | inputContainerId | string | ID for the input container element. | Yes | | inputFieldsId | string | ID for the input field element. | Yes | | fieldName | string | Name attribute for the input field (used in forms). | Yes | | labelText | string | The text displayed as the input's label. | Yes | | placeholderText | string | undefined | Placeholder text displayed in the input field (optional). | No | | defaultEmail | string | undefined | Default email value for the input field (optional). | No | | isRequired | boolean | Whether the input field is required. | Yes | | targetCatcher | Dispatch<SetStateAction<string>> | Function to catch and update the input field's value in the parent state. | Yes | | targetValue | string | The value of the input field to validate against the predefined domain list. | Yes |

3. LTMobileNoInput Component

The LTMobileNoInput(Label top mobile number input) component is a React component designed to handle mobile number inputs with country code selection. It validates the mobile number length and updates the parent component with the complete mobile number, including the country code.

Installation

To use the LTMobileNoInput component, first install the necessary dependencies:

npm install js-utils-react

Invocation

import LTMobileNoInput from './path-to-component/LTMobileNoInput';

function App() {
  const [mobileNumber, setMobileNumber] = useState('');

  return (
    <div className="App">
      <LTMobileNoInput
        inputContainerId="mobileInputContainer"
        inputFieldsId="mobileInputField"
        fieldName="mobileNumber"
        labelText="Mobile Number"
        placeholderText="Enter your mobile number"
        defaultMobileNo=""
        isRequired={true}
        targetCatcher={setMobileNumber}
      />
      <p>Mobile Number: {mobileNumber}</p>
    </div>
  );
}

export default App;

Props

The LTMobileNoInput component accepts the following props:

| Prop Name | Type | Description | Required | |------------------|----------------------------------------|-----------------------------------------------------------------------------|----------| | inputContainerId | string | The ID for the input container element. | Yes | | inputFieldsId | string | The ID for the input field element. | Yes | | fieldName | string | The name attribute for the input field. | Yes | | labelText | string | The label text for the input field. | Yes | | placeholderText | string | The placeholder text for the input field. | No | | defaultMobileNo | string | The default value for the mobile number input. | No | | isRequired | boolean | Indicates whether the input field is required. | Yes | | targetCatcher | Dispatch<SetStateAction<string>> | A callback function to catch the final mobile number value. | Yes |

4. LTPasswordInput Component

The LTPasswordInput (Label top password inputs) component is a React component designed to handle password inputs with validation and a feature to show/hide the password. It provides feedback on the password strength and updates the parent component with the password value.

Installation

To use the LTPasswordInput component, first install the necessary dependencies:

npm install js-utils-react

Invocation


import LTPasswordInput from './path-to-component/LTPasswordInput';

function App() {
  const [password, setPassword] = useState('');

  return (
    <div className="App">
      <LTPasswordInput
        inputContainerId="passwordInputContainer"
        inputFieldsId="passwordInputField"
        fieldName="password"
        labelText="Password"
        placeholderText="Enter your password"
        isRequired={true}
        targetCatcher={setPassword}
        targetValue={password}
      />
      <p>Password: {password}</p>
    </div>
  );
}

export default App;

Props

The LTMobileNoInput component accepts the following props:

| Prop Name | Type | Description | Required | |---------------------|-------------------------------|-------------------------------------------------|----------| | inputContainerId | string | The ID for the input container element. | Yes | | inputFieldsId | string | The ID for the input field element. | Yes | | fieldName | string | The name attribute for the input field. | Yes | | labelText | string | The label text for the input field. | Yes | | placeholderText | string | The placeholder text for the input field. | No | | isRequired | boolean | Indicates whether the input field is required. | Yes | | targetCatcher | Dispatch<SetStateAction<string>> | A callback function to catch the mobile number value. | Yes | | defaultMobileNo | string | The default value for the mobile number input. | No |

Styling

The Inputs component uses InputStyles.css for styling. You can customize these styles to match your design requirements.

Default Classes

| Class Name | Purpose | |---------------------|-------------------------------------------------------------------| | input_group | Styles the input container group. | | input | Styles the email input field. | | validBorder | Applied when the email is valid. | | invalidBorder | Applied when the email is invalid. | | hiddenLabel | Hides the label when a default value is present. | | user_label | Styles the label for visible input fields. | | valid_message | Styles the success message. | | not_valid_message | Styles the error message. | | initialStateStyle | Styles applied when no validation occurs. |


You can modify the classes as design requirements.

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

Developed by Kunal Chandra Das under MIT license © 2024