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-edit-inline-iyobo

v0.1.0

Published

A simple inline text editor for React with ECMAScript 6 + JSX Harmony syntax

Downloads

4

Readme

Inline Edit Component for React

Before you continue, check out a successor to this repo: React Inline Edit Kit. It is more functional, and will be maintained in future.

This is a simple React component for in-place text editing. It turns into an <input /> when focused, and tries to validate and save input on Enter or blur. Esc works as well for cancelling.

Example animation gif

Watch a demo, then check out demo/index.jsx for a quick example.

Installation

npm install react-edit-inline --save-dev

Required props

  • text:string initial text
  • paramName:string name of the parameter to be returned to change function
  • change:function function to call when new text is changed and validated, it will receive {paramName: value}

Optional props

  • className:string CSS class name
  • activeClassName:string CSS class replacement for when in edit mode
  • validate:function boolean function for custom validation, using this overrides the two props below
  • minLength:number minimum text length, default 1
  • maxLength:number maximum text length, default 256
  • editingElement:string element name to use when in edit mode (DOM must have value property) default input
  • staticElement:string element name for displaying data default span
  • editing:boolean If true, element will be in edit mode
  • tabIndex:number tab index used for focusing with TAB key default 0
  • stopPropagation:boolean If true, the event onClick will not be further propagated.

Usage example

import React from 'react';
import InlineEdit from 'react-edit-inline';

class MyParentComponent extends React.Component {

    constructor(props){
      super(props);
      this.dataChanged = this.dataChanged.bind(this);
      this.state = {
        message: 'ReactInline demo'
      }
    }

    dataChanged(data) {
        // data = { description: "New validated text comes here" }
        // Update your model from here
        console.log(data)
        this.setState({...data})
    }

    customValidateText(text) {
      return (text.length > 0 && text.length < 64);
    }

    render() {
        return (<div>
            <h2>{this.state.message}</h2>
            <span>Edit me: </span>
            <InlineEdit
              validate={this.customValidateText}
              activeClassName="editing"
              text={this.state.message}
              paramName="message"
              change={this.dataChanged}
              style={{
                backgroundColor: 'yellow',
                minWidth: 150,
                display: 'inline-block',
                margin: 0,
                padding: 0,
                fontSize: 15,
                outline: 0,
                border: 0
              }}
            />
        </div>)
    }
}