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

refillable

v2.0.1

Published

Saves Html form data when user leaves page data and refill when revisits that page again!

Downloads

11

Readme

Take a Snapshot of a form, for better UX.

Introduction

A client filling up the form on your site, Left that window/tab for xyz reasons. When client re-opens that page, Seeing their half filled form is fully empty now. This workflow is normal but we can optimize this. To make better UX!

So, actually instead of client re-enters the past filled information, What if we,

  • Store that past half-filled form for specific user and store it!
  • Next time user came back to same page, we reteieve that stored form and suggest to accept his/her past filled field values.

Looks interesting? Let's move to the workflow.

Workflow

So the idea is to take a snapshot of form whenever user fill it, No matter if its fully filled or not. Its looks like we are having track of their changes just like google form. but google form uses cloud storage option. However, Not all of the application use that approach.

Google Form doesn't store progress if user is offline

To make this functionality available in offline mode, we are previously using localStorage API to store the form. But now in newer versions (>2.0.0) we are using IndexedDB API as it can also supports Blob storage which is perfect for image/file uploads storage.

Implementation

There are currently two packages for this implementation.

  • VanillaJS version (pure/native support)
  • ReactJS Specific

If your site uses plain (html + css + js) format, you can move to this alternative

In past version we have introduced useRefillableState hook, and you have to manually assign value, onChange, onBlur property to each of the input elements. Which is kind of headache for developers. We've also got feedback about this painfull experience.

So, From version(V 2.0.0), it comes with a new powerfull, intelligent custom hook, useRefillableForm. Now you just need to add ref attribute to your form and it auto detects all of the nested input tags itself and assigns curresponding eventListeners to them. to take actions accordingly!

  • Enough talking, now code part!!

Install

npm i refillable

Live Demo on CodeSandBox

Usage

...
import { useRefillableForm } from "refillable";

const MyApp = () => {

  const { formRef } = useRefillableForm(configs);
  // configs = {threshold?: 50, unique_key?: 'sign_up'}
  // Provoding config is completely optional
  // threshold is amount in percentage. Only if form is (threshold)% filled, then only save it! (defaults to 50)

  return (
    <form ref={formRef}>
    
      <input type="text" placeholder="Username" name="username" />
      
      <div className="ui__needed_container">
      
        <a>Terms & Conditions</a>
        
        <div>
          <input type="checkbox" name="is_adult" />
        </div>
        
       </div>
      
    </form>
  )

}

Note

  • If you are using useRefillableState hook more than once per page (not component), You must assign unique_key value to differenciate multiple hooks on same page.
  • This is because it uses current page url as unique identifier to store data and for retrieving also, so it won't collide

Author

👤 Spade Dev(s)

Show your support

Give a ⭐️ if this project helped you!


License

MIT © spade-official