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

@iamjoberror/reactive-textarea

v2.1.1

Published

A plugin that enhances html <textarea> element

Downloads

2

Readme

Reactive Textarea 🎉️

This plugin provides features such as text and word counting, filtering, and limiting when an input is made in an HTML textarea element.

GitHub package.json version GitHub license Twitter URL

What's New

  • Added args.maxAllowed to callback function args.
  • Added .reset() feature to reset textarea and callbacks args
  • Improved README documentation

Features

  • Counter
  • Filter
  • Limiter
  • Custom callback
  • HTML class helpers

Highlights

  • Callback rich arguments noOfWordsFiltered, noOfInputsWords, inputsPercentage, etc.
  • Better documentation and improved code.
  • Feature On / Off.
  • Supports module loading option.
  • A simple test page

Installation

# NPM
npm install -D @iamjoberror/reactive-textarea

# Yarn
yarn add -D @iamjoberror/reactive-textarea

Examples

Load the script through import module option

import { reactiveTextArea } from "@iamjoberror/reactive-textarea"

// Nuxt 3 approach: please follow the link below as an example on how to use it as a plugin
// https://stackoverflow.com/a/74694711/245030
  1. Limit and Count text.

    <div>
        <textarea></textarea>
        <!-- Class helpers -->
        <!-- Current counter class -->
        <span class="reactiveTextArea_curCount"></span>
        <!-- Remainder counter class -->
        <span class="reactiveTextArea_remCount"></span>
        <!-- Maximum allowed texts or words class -->
        <span class="reactiveTextArea_maxAllowed"></span>
    </div>
    reactiveTextArea.config({
        // Enable counting
        enableCounter: true
        countOrLimitType: "word" // "text" or "word"
    
        // Enable and set limit
        enableLimiter: true
        maxAllowed: 90
    
        // set textarea element
        element: document.querySelector('textarea')
    });
    
    reactiveTextArea.init();
  2. Filter: restrict some words based on filter list

    <div>
        <textarea></textarea>
        <!-- No of filtered words count class -->
        <span class="reactiveTextArea_filterCount"></span>
    </div>
    reactiveTextArea.config({
        // Enable filter
        enableFilter: true,
        wordsToFilter: ["dumb", "shit"],
        enableStrictFiltering: false
    
        // set textarea element
        element: document.querySelector('textarea')
    });
    
    reactiveTextArea.init();
  3. Explore the limitless through Custom Function

    <!--HTML -->
    <textarea></textarea>
    <div>
        <span>0</span>
        <!--- HR element progress in width as the user types -->
        <hr />
    </div>
    /** CSS **/
    div {
        display: flex;
        flex-direction: row;
    }
    
    div hr {
        display: inline block;
        height: 1px;
        width: 0;
        border: 1px solid #000;
    }
    reactiveTextArea.config({
        // Enable counting
        enableCounter: true
        countOrLimitType: "text"
    
        // Enable and set limit
        enableLimiter: true
        maxAllowed: 120
    
        // Enable filter
        enableFilter: true,
        wordsToFilter: ["mad", "stupid"],
        enableStrictFiltering: true
    
        // Callback function
        callbackFunc: logAll
    
        // set textarea element
        element: document.querySelector('textarea')
    });
    
    reactiveTextArea.init();
    
    // Custom function
    
    let progress = document.querySelector('hr');
    
    function logAll(args) {
        // This function is exposed to the following helpers
    
        // 1. `args.events`: current event name triggered (copy, paste, etc).
        // 2. `args.inputs`: current texts in the textarea. (str)
        // 3. `args.inputsPercentage`: total texts count in percentage. (num)
        // 4. `args.inputsCount`: total count. (num)
        // 5. `args.noOfInputWords`: total words count. (num)
        // 6. `args.noOfInputTexts`: total texts count. (num)
        // 7. `args.noOfWordsFiltered`: total filtered words. (num)
        // 8. `args.maxAllowed`: max number of words or text allowed. (num)
    
        // eg: log no of words typed
        console.log(args.noOfInputWords);
    
        // HR width gets altered based on the percentage.
        Object.assign(progress.style, {width: args.inputsPercentage + "%"})
    }

Dev feature .reset()

The reactiveTextArea.reset() can be used to reset the plugin output to default.

// Resets callback args and helper classes to default
reactiveTextArea.reset()

// Defaults callback args and helper classes, then clears the textarea input.
reactiveTextArea.reset(true)

What's Next

  • Adds more features
  • Bugs and performance fixes

Please kindly follow me on twitter for updates. Thank you!