Socket
Socket
Sign inDemoInstall

rifm

Package Overview
Dependencies
5
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rifm

Tiny react input formatter and mask


Version published
Maintainers
1
Install size
194 kB
Created

Readme

Source

RIFM - React Input Format & Mask

Is a tiny (≈ 800b) component to transform any input component into formatted or masked input.

Demo

Highlights

  • Requires React 16.4+
  • Dependency free
  • Tiny (≈ 800b)
  • Supports any input.
  • Can mask input and format

Example

import { Rifm } from 'rifm';
import { Value } from 'react-powerplug';
import TextField from '@material-ui/core/TextField';
import { css } from 'emotion';

const numberFormat = (str: string) => {
  const r = parseInt(str.replace(/[^\d]+/gi, ''), 10);
  return r ? r.toLocaleString('en') : '';
}

...

  <Value initial={''}>
    {text => (
      <Rifm
        value={text.value}
        onChange={text.set}
        format={numberFormat}
      >
        {({ value, onChange }) => (
          <TextField
            value={value}
            label={'Float'}
            onChange={onChange}
            className={css({input: {textAlign:"right"}})}
            type="tel"
          />
        )}
      </Rifm>
    )}
  </Value>

...

Demo

Demo source

Install

  yarn add rifm
  npm -i rifm

Thanks

@TrySound for incredible help and support on this

FAQs

Last updated on 21 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc