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

@codersandip/svelte-otp

v0.0.5

Published

Simple component to assign scores based on stars.

Downloads

358

Readme

@codersandip/svelte-otp

A Svelte component for creating OTP (One-Time Password) inputs. This component allows for customizable OTP input length, supports different input types, and handles various user interactions such as input, paste, and backspace events.

Screenshot

Screenshot of Svelte OTP Component

Features

  • Customizable OTP Input Length: Set the number of OTP input fields.
  • Supports Different Input Types: Choose between text and number input types.
  • Configurable Placeholder: Set a custom placeholder for the input fields.
  • CSS Class Customization: Apply custom CSS classes for styling.
  • Automatic Focus Management: Automatically focuses the next input field as the user types.

Installation

To install the package, use npm or yarn:

npm install @codersandip/svelte-otp

or

yarn add @codersandip/svelte-otp

Usage

Import the OTP component into your Svelte application and use it as follows:

<script>
  import {OtpInput} from '@codersandip/svelte-otp';

  let otpValue = '';

  function handleOtpChange(newOtpValue) {
    otpValue = newOtpValue;
  }
</script>

<OtpInput
  length={6}
  inputType="number"
  placeholder="•"
  value={otpValue}
  onChange={handleOtpChange}
  inputWrapClass="custom-inputwrapper-class"
  inputClass="custom-input-class"
  containerClass="custom-container-class"
/>

Props

| Prop Name | Type | Default | Required | Description | | ---------------- | ------------------------------------------------- | ---------- | -------- | ------------------------------------------------------------------------ | | length | number | 6 | No | The number of OTP input fields. | | inputType | "text" | "number" | "password" | "tel" | "number" | No | The type of input field. | | placeholder | string | "•" | No | The placeholder text for the input fields. | | value | string | "" | No | The initial value of the OTP input fields. | | inputWrapClass | string | "" | No | Custom CSS class for the input wrapper div. | | inputClass | string | "" | No | Custom CSS class for the input fields. | | containerClass | string | "" | No | Custom CSS class for the container. | | onChange | function | N/A | Yes | Callback function called with the current OTP value whenever it changes. |

Styling

Customize the appearance of the OTP inputs using the provided CSS classes or by adding your own styles. For example:

.custom-inputwrapper-class {
  /* Custom styles for the input wrap div */
}
.custom-input-class {
  /* Custom styles for the input fields */
}

.custom-container-class {
  /* Custom styles for the container */
}

Development

To build and test the package locally:

Clone the Repository:

git clone https://github.com/codersandipdas/svelte-otp.git
cd svelte-otp

Install Dependencies:

npm install

Build the Package:

npm run build

Link the Package Locally (for Testing):

npm link

Use the Linked Package in Your Svelte Project:

npm link @codersandip/svelte-otp

Contributing

Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.