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-input-with-html

v2.1.0

Published

A react input component that uses contenteditable on a div to display the input value with html cut in for that touch of fancy.

Downloads

1

Readme

react-input-with-html

A react input component that uses contenteditable on a div to display the input value with html cut in for that touch of fancy

NPM JavaScript Style Guide bundle size

Install

npm install --save react-input-with-html

Usage

This is starting as a bit of a custom thing for Stocksy, but I plan on making it into a more broadly useful library.

Most of the custom props and usage just arn't in this readme.

Use this at your own risk for now.

import React, { useState } from 'react'
import HTMLInput from 'react-input-with-html'
// have to import style sheet for basic input styles and special hex option style
import 'react-input-with-html/dist/index.css'

const App = () => {
  const [input, setInput] = useState('')

  const handleSubmit = () => {
    // submit what is in the input state however you want here
    console.log('input on submit: ', input)
  }

  // basic style for +'s
  const modifierArr = [
    {
      regexMatch: /\+/g,
      htmlMod: `<span style="color: #a3a3a3">+</span>`
    }
  ]

  return (
    <HTMLInput
      id='input'
      value={input}
      onChange={setInput}
      onSubmit={handleSubmit}
      modifierArr={modifierArr}
      spellCheck={false}
      hexDot={true}
    />
  )
}

Available props

|prop|description|type| |--|----|----| |id|required: unique id|String| |modifierArr|required: more on this below|Array of Objects| |disabled|use true to disable editing|Boolean| |onChange|required: react hook for keeping input state|Function| |onBlur|called whenever the html element is blurred|Function| |onFocus|event fires when an element has received focus|Function| |onKeyUp|called whenever a key is released|Function| |onKeyDown|called whenever a key is pressed |Function| |spellCheck|toggles auto underlining spelling errors|Boolean| |hexDot|info for how to show hex dots after hex codes|Obj|

hexDot obj = { enable: boolean style: { width: string height: string top: string left: string } }

Modifier Arr

This is the customizable part of this component.

You need to pass an Array of ModifierObj(s) see type below

type ModifierObj = {
  regexMatch: RegExp
  htmlModification: string | Function // need better function definition, it has to return a html represented as string
}

The regexMatch is a regular expression to find the instances you want to modify

The htmlModification is the string that includes the html for what you're changing it to. This can be a string or a function that returns the string.

put examples here...

Playground

will be more of a playground in the future

Try it out

Important Notes

don't use v1 of this library. It's a very limited concept with lots of bugs.

License

MIT © cbot83