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

@folo/values

v1.0.3

Published

> A from store returns input values with zero config

Downloads

20

Readme

📋 @folo/values

A from store returns input values with zero config

live example

NPM Version NPM Download npm bundle size (minified) npm bundle size (gzip) MIT License CI Codecov

Installation

npm install @folo/values
  • ☑️ A simple, lightweight package, comes with two components connected to global JavaScript store. That's it. No complexity, no unnecessary code.

  • ☑️ Instead of implementing your own store, @folo/values can do it for you with a store that holds inputs and knows exactly when to trigger connected components to re-render.

  • ☑️ Doesn't require using Redux/Mobx/Context. While these technologies are amazing it always comes with a cost. That's why every update that happens in Folo happens locally. The store is just the Maestro.

  • ☑️ You can add multiple forms connect them to the store or create branches yourself. It's all about StoreID my friends.

  • ☑️ Friendly code. What you do for a form written in JS, Can do it here. No external API. No external functionality. onSubmit, onChange are still here and not going anywhere.

  • ☑️ It's well tested code, with nearly 100% of code coverage 🥳

Usage

import { Form, Field } from "@folo/values";

const MyComponent = ({ onSubmit }) => (
  <Form onSubmit={onSubmit} storeID="example1">
    <label>
      username:
      <Field valueKey="myName" type="text" storeID="example1" />
    </label>
    <label>
      password:
      <Field valueKey="myPass" type="password" storeID="example1" />
    </label>
    <label>
      choose:
      <Field valueKey="alphabet" type="select" storeID="example1">
        <option valueKey="a">A</option>
        <option valueKey="b">B</option>
        <option valueKey="c">C</option>
      </Field>
    </label>
    <button type="submit">submit</button>
  </Form>
);
// submit function will return: (event, {myName: "" myPass: "", alphabet:""})

Available Components

import { Form, Field } from "@folo/values";

All components accept custom props + children which is required in all except Field

Form

| property | type | description | default | | ----------- | ------------------ | ---------------------------------------------------------------- | -------------- | | component | HTMLElement/string | custom render-component | form | | onSubmit | function | submit function returns values in all cells (event, {...values}) | () {} | | storeID | string | unique id shared with form and fields | unrecognized |

Field

Essential to register values in the store, returns its value when submit. Accepts all events handlers.

| property | type | description | default | | ----------- | ------------------ | ---------------------------------------- | ------------------- | | component | HTMLElement/string | custom render-component | div | | storeID | string | unique id shared with form and fields | unrecognized | | valueKey | string | key used to store value in values object | id or timestamp | | value | string | Initial value if type is not a button | "" | | checked | Boolean | Initial value if type is a button | false | | type | string | Input type | text | | groupName | string | only for button toggle group | null |

Examples

You can clone all the examples used in these packages here. With an example for Simple Form Or a Custom Form built with custom components. It includes All Available fields and examples that show you how to handle toggle button groups.

Test

yarn test folo-values

Contribution 😇

If you have ideas or issues don't hesitate. You are always welcome.

License

This project is licensed under the MIT License