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

react-easy-edit

v2.0.0

Published

A react library for inline editing components

Downloads

22,262

Readme

Test NPM License: MIT CircleCI Known Vulnerabilities install size Quality Gate Status DeepScan grade

react-easy-edit

A React library that allows inline editing on HTML5 input components, try the sandbox here!

For full library documentation, visit this site!

:pencil: Features

  • Supports input (most types, even inputs with datalist), textarea,radio, checkbox, tel, url and select HTML types
  • Validates user input
  • Allows customisation on all elements including the save and cancel buttons
  • Supports custom editComponent and custom displayComponent for each type

:rocket: Installation

npm i react-easy-edit or yarn add react-easy-edit

:pray: Show your support

Give a :star: if this project helped you in any way!

paypal ko-fi

:cool: Props

For the full list of props, please visit our documentation site.

:page_facing_up: Examples

More examples can be found here

A simple example - Textbox

import React, { Component } from 'react';
import EasyEdit from 'react-easy-edit';

function App() {

  const save = (value) => {alert(value)}
  const cancel = () => {alert("Cancelled")}

  return (
    <EasyEdit
      type="text"
      onSave={save}
      onCancel={cancel}
      saveButtonLabel="Save Me"
      cancelButtonLabel="Cancel Me"
      inputAttributes={{ name: "awesome-input", id: 1}}
      instructions="Star this repo!"
    />
  );
}

Radio buttons

<EasyEdit
  type="radio"
  value="one"
  onSave={save}
  options={[
      {label: 'First option', value: 'one'},
      {label: 'Second option', value: 'two'}]}
  instructions="Custom instructions"
/>

Date

<EasyEdit
  type="date"
  onSave={save}
  instructions="Select your date of birth"
/>

Dropdown

<EasyEdit
  type="select"
  options={[
      {label: 'First option', value: 'one'},
      {label: 'Second option', value: 'two'}]}
  onSave={save}
  placeholder="My Placeholder"
  instructions="Custom instructions"
/>

Datalist

<EasyEdit
  type="datalist"
  options={[
      {label: 'First option', value: 'one'},
      {label: 'Second option', value: 'two'}]}
  onSave={save}
  instructions="Custom instructions"
/>

Checkboxes

<EasyEdit
  type="checkbox"
  options={[
      {label: 'First option', value: 'one'},
      {label: 'Second option', value: 'two'}]}
  onSave={save}
  value={['one', 'two']} // this will preselect both options
/>

Custom components

When using custom input components, they must be passed in as props, like so:

<EasyEdit
    type="text"
    onSave={() => {}}
    editComponent={<CustomInput />}
    displayComponent={<CustomDisplay />}
/>

When defining a custom input component, the function setParentValue is injected into your custom component, which must be called in order to pass the desired value up to the parent EasyEdit component.

For example, if your component was a text field that needed to set the EasyEdit value as a user id based on a username entered, you would need to pass the id to this.props.setParentValue in order to get that value to the EasyEdit component.

e.g.

// Inside your custom input

onChange(searchTerm) {
  getUserIdByUsername(searchTerm).then((userId) => {
    this.props.setParentValue(userId);
  })
}

You can use a custom EditComponent and still use the saveOnBlur behavior. An onBlur function will be passed to your custom component, for you to trigger the behavior.

class CustomComponent extends React.Component{
  constructor(props){
    super(props);
  }

  render(){
    return <div>
      <p>Custom editor</p>
      <input onBlur={this.props.onBlur} />
    </div>;
  }
}

:handshake: Contributing

Contributions, issues and feature requests are welcome.

Feel free to check issues page if you want to contribute.

Special thanks to all the contributors below for spending their time improving this library

:1234: Versioning

For transparency and insight into our release cycle, releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch
  • For more information on semantic versioning, please visit http://semver.org/.

:scroll: Licence

Copyright © 2023 George Artemiou.

This project is under MIT license.