React Input Format & Mask, tiny (≈800b) component to transform any input component into formatted or masked input. Supports number, date, phone, currency, credit card, etc

Related tags

Input Types rifm
Overview

RIFM - React Input Format & Mask

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

Demo

Highlights

  • Requires React 16.8+
  • Dependency free
  • Tiny (≈ 800b)
  • Supports any input.
  • Can mask input, format and more
  • Small readable source
  • flow + typescript definitions

Example

Rifm offers both a Render Prop and a Hook API:

Render Prop

)} ... ">
import { Rifm } from 'rifm';
import { TextField } from '@material-ui/core';

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

...

  const [value, setValue] = React.useState('')

  <Rifm
    value={value}
    onChange={setValue}
    format={numberFormat}
  >
    {({ value, onChange }) => (
      <TextField
        type="tel"
        value={value}
        onChange={onChange}
      />
    )}
  </Rifm>

...

Hook

... ">
import { useRifm } from 'rifm';
import { TextField } from '@material-ui/core';

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

...

  const [value, setValue] = React.useState('')

  const rifm = useRifm({
    value,
    onChange: setValue,
    format: numberFormat
  })

  <TextField
    type="tel"
    value={rifm.value}
    onChange={rifm.onChange}
  />

...

Install

yarn add rifm

API

Terminology

Rifm is based on simple idea (*):

  • format operation applied to input value after edit doesn't change the order of some symbols before cursor

* This is not always true, but we solve some edge cases where it's not.

Imagine you have simple integer number formatter with ` as thousands separator and current input state is 123`4|67 ("|" shows current cursor position).

User press 5 then formatted input must be equal to 1`234`5|67.

The overall order of elements has changed (was 1->2->3->`->4->... became 1->`->2->3->4...) but the order of digits before cursor hasn't changed (was 1->2->3->4 and hasn't changed).

The same is true for float numbers formatting, dates and more. Symbols with preserved order are different and depends on format. We call this kind of symbols - "accepted" symbols.

Rifm solves only one task - find the right place for cursor after formatting.

Knowledge about what symbols are "accepted" and cursor position after any user action is enough to find the final cursor position.

Most operations which are not covered with above idea like case enforcements, masks guides, floating point ","=>"." replacement can be done using simple postprocessing step - replace. This operation works well if you need to change input value without loosing cursor position.

And finaly masks - masks are usually is format with replace editing mode + some small cursor visual hacks.

Input Props

These are accepted by the Rifm component as props and the useRifm hook as named arguments.

Prop type default Description
accept RegExp (optional) /\d/g Regular expression to detect "accepted" symbols
format string => string format function
value string input value
onChange string => void event fired on input change
children ({ value, onChange }) => Node value and onChange handler you need to pass to underlying input element
mask boolean (optional) use replace input mode if true, use cursor visual hacks if prop provided
replace string => string (optional) format postprocessor allows you to fully replace any/all symbol/s preserving cursor
append string => string (optional) format postprocessor called only if cursor is in the last position and new symbols added, used for specific use-case to add non accepted symbol when you type

Output Props

These will be passed into the children render prop for the Rifm component as named arguments, and returned from the useRifm hook as an object.

Prop type default Description
value string A formatted string value to pass as a prop to your input element
onChange SyntheticEvent => void The change handler to pass as a prop to your input element

See the Demo there are a lot of examples there.

Thanks

@TrySound for incredible help and support on this

Comments
  • Refactor Rifm into useRifm hook and Rifm component

    Refactor Rifm into useRifm hook and Rifm component

    To address #38

    Happy to add some tests specifically for the hook if desired, but it didn't feel super vital atm as all the code paths in the hook are exercised by the existing render props tests.

    Also happy to help in updating docs as well.

    I have these changes currently published as @lewisl9029/[email protected] in case anyone wants to try it out.

    opened by lewisl9029 13
  • React Hooks

    React Hooks

    Any plans to support hooks in the future?

    export const numberFormat = (str: string) => {
      const r = parseInt(str.replace(/[^\d]+/gi, ''), 10);
    
      return r ? r.toLocaleString('en') : '';
    };
    
    const RifmHooks = () => {
      const { value, onChange } = useRifm(numberFormat)
    
      return (
        <input onChange={onChange} value={value} />
      )
    }
    
    opened by renatorib 12
  • refuse is not working

    refuse is not working

    the prop refuse seems to be wonky in the npm package. you can type anything in the field, it accepts. this bug defeats the usability of the component.

    it works in my instance of docz, as does in yours, but it fails on my private project.

    reproduction: with-powerplug vanilla-react

    opened by leonardodino 7
  • Is RIFM stable?

    Is RIFM stable?

    I stumbled on RIFM when looking for something smaller and more focused than imask. I'd love to use this library in production, but I have a couple of questions:

    Is RIFM stable? What is holding it back from a 1.0 release?

    opened by marcbizal 3
  • Fix cursor position after delete with multiple non-accepted chars after

    Fix cursor position after delete with multiple non-accepted chars after

    Hi! I just recently noticed a bug with using Rifm with phone formatting. It can be reproduced in the official example as well:

    https://realadvisor.github.io/rifm/

    May-21-2020 16-08-43

    When we try to delete right before a string of multiple non-accepted characters (in this case it's the ) part), the cursor only moves forward by 1 character, and subsequent deletes end up doing nothing, causing the user to be stuck.

    Here's my first attempt at a fix and a test to cover this case. Let me know if there's anything you'd like to see changed, I suspect there might be some nuance I might be missing in the implementation.

    Another gif of what the new behavior looks like in action: May-21-2020 16-16-15

    opened by lewisl9029 3
  • The form function is performed 5 times

    The form function is performed 5 times

    Just open console and try to change input value. Every keypress triggers format 5 times. https://codesandbox.io/s/istarkovrifm-enforcement-vx86k Why? Is input re-rendered 5 times?

    opened by mlnchk 3
  • weird behaviour with recompose's withStateHandlers

    weird behaviour with recompose's withStateHandlers

    Please, take a look on the code example https://codesandbox.io/s/72pppx8kl1

    Try to enter any non-numeric value into each of the fields.

    As you can see, withState and React class examples work as expected. But not withStateHandlers.

    opened by denisborovikov 3
  • using identity as a transform

    using identity as a transform

    hi, why is a transform of identity putting the caret at the beginning of the text?

    if there are no changes the caret shouldn't move i think

    example: https://codesandbox.io/s/ecstatic-dhawan-xefet?file=/index.js

    opened by belgac 2
  • Need help with formatting international phone numbers

    Need help with formatting international phone numbers

    Hi! Thx for cool idea of input formatters. But I need help with understanding, how can I implement international phone numbers.

    The main idea, is to help users:

    1. When types some number, we need to add "+7" at start of the input. Like, type "9", in input shows "+7 9"
    2. When paste number in format "79876543210", need to format and display "+7 987 654-32-10"
    3. When paste number in format "9876543210", need to display same "+7 987 654-32-10".

    2nd and 3rd point I solved, but with typing from scratch, cursor won't forward to end of input.

    See example: https://codesandbox.io/embed/istarkovrifm-phone-format-qw8c3

    1. If type from scratch manually "+ 7" it's good.
    2. If type from scratch "9" and then put cursor at the end of input and continue typing, it's good, too.

    Maybe I need to use not only this library, but make some third-party solutions?

    opened by DTupalov 2
  • improves caret handling

    improves caret handling

    handleFormat = (str: string) => {
        const mask = new StringMask('000.000.000-00');
    
        const r = parseInt(str.replace(/[^\d]+/gi, ''), 10)
    
        return mask.apply(r);
      };
    
    <Rifm
              value={value}
              onChange={this.handleChange}
              format={this.handleFormat}
            >
              {({ value, onChange }) => (
                <TextField
                  onChange={onChange}
                  value={value}
                  onBlur={handleBlur}
                  error={!!fieldError}
                  helperText={fieldError || helperText}
                  name={name}
                  {...props}
                />
              )}
            </Rifm>
    

    When I type: 123

    it shows 123., and the caret is before ., I think it should be after it

    opened by sibelius 2
  • Bump next from 9.4.2 to 11.1.0

    Bump next from 9.4.2 to 11.1.0

    Bumps next from 9.4.2 to 11.1.0.

    Release notes

    Sourced from next's releases.

    v11.1.0

    A security team from one of our partners noticed an issue in Next.js that allowed for an open redirect to occur.

    Specially encoded paths could be used when pages/_error.js was statically generated allowing an open redirect to occur to an external site.

    In general, this redirect does not directly harm users although can allow for phishing attacks by redirecting to an attacker's domain from a trusted domain.

    We recommend upgrading to the latest version of Next.js to improve the overall security of your application.

    How to Upgrade

    • We have released patch versions for both the stable and canary channels of Next.js.
    • To upgrade run npm install [email protected] --save

    Impact

    • Affected: Users of Next.js between 10.0.5 and 10.2.0
    • Affected: Users of Next.js between 11.0.0 and 11.0.1 using pages/_error.js without getInitialProps
    • Affected: Users of Next.js between 11.0.0 and 11.0.1 using pages/_error.js and next export
    • Not affected: Deployments on Vercel (vercel.com) are not affected
    • Not affected: Deployments with pages/404.js

    We recommend everyone to upgrade regardless of whether you can reproduce the issue or not.

    How to Assess Impact

    If you think sensitive code or data could have been exposed, you can filter logs of affected sites by // (double slash at the start of the url) followed by a domain.

    What is Being Done

    As Next.js has grown in popularity and usage by enterprises, it has received the attention of security researchers and auditors. We are thankful to Gabriel Benmergui from Robinhood for their investigation and discovery of the original bug and subsequent responsible disclosure.

    We've landed a patch that ensures path parsing is handled properly for these paths so that the open redirect can no longer occur.

    Regression tests for this attack were added to the security integration test suite

    • We have notified known Next.js users in advance of this publication.
    • A public CVE was released.
    • We encourage responsible disclosure of future reports. Please email us at [email protected]. We are actively monitoring this mailbox.

    Release notes

    Core Changes

    • Don't test image domains in test env: #26502
    • Fix props not updating when changing the locale and keeping hash: #26205
    • Allow user to override next-image-loader: #26548
    • Add logging when a custom babelrc is loaded: #26570

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump qs from 6.5.2 to 6.5.3

    Bump qs from 6.5.2 to 6.5.3

    Bumps qs from 6.5.2 to 6.5.3.

    Changelog

    Sourced from qs's changelog.

    6.5.3

    • [Fix] parse: ignore __proto__ keys (#428)
    • [Fix] utils.merge: avoid a crash with a null target and a truthy non-array source
    • [Fix] correctly parse nested arrays
    • [Fix] stringify: fix a crash with strictNullHandling and a custom filter/serializeDate (#279)
    • [Fix] utils: merge: fix crash when source is a truthy primitive & no options are provided
    • [Fix] when parseArrays is false, properly handle keys ending in []
    • [Fix] fix for an impossible situation: when the formatter is called with a non-string value
    • [Fix] utils.merge: avoid a crash with a null target and an array source
    • [Refactor] utils: reduce observable [[Get]]s
    • [Refactor] use cached Array.isArray
    • [Refactor] stringify: Avoid arr = arr.concat(...), push to the existing instance (#269)
    • [Refactor] parse: only need to reassign the var once
    • [Robustness] stringify: avoid relying on a global undefined (#427)
    • [readme] remove travis badge; add github actions/codecov badges; update URLs
    • [Docs] Clean up license text so it’s properly detected as BSD-3-Clause
    • [Docs] Clarify the need for "arrayLimit" option
    • [meta] fix README.md (#399)
    • [meta] add FUNDING.yml
    • [actions] backport actions from main
    • [Tests] always use String(x) over x.toString()
    • [Tests] remove nonexistent tape option
    • [Dev Deps] backport from main
    Commits
    • 298bfa5 v6.5.3
    • ed0f5dc [Fix] parse: ignore __proto__ keys (#428)
    • 691e739 [Robustness] stringify: avoid relying on a global undefined (#427)
    • 1072d57 [readme] remove travis badge; add github actions/codecov badges; update URLs
    • 12ac1c4 [meta] fix README.md (#399)
    • 0338716 [actions] backport actions from main
    • 5639c20 Clean up license text so it’s properly detected as BSD-3-Clause
    • 51b8a0b add FUNDING.yml
    • 45f6759 [Fix] fix for an impossible situation: when the formatter is called with a no...
    • f814a7f [Dev Deps] backport from main
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Using rifm for masking time in HH:MM format

    Using rifm for masking time in HH:MM format

    Is it possible to mask time in HH:MM format using rifm?

    I need to implement following behavior: | User Input | Mask result | |------------|-------------| | 39:60 | _9:_0 | | 21:00 | 21:00 |

    I tried using a replace with regex of such kind /(([012])|[3-9_])((?<=2)(([0-3])|[4-9])|([\d_]))(.)(([0-5])|[6-9_])([\d_])/; But the problem is that Safari doesn't support positive lookbehind and throws an error

    Is there any other way?

    opened by R-Oscar 0
  • Bump jsdom from 16.2.2 to 16.7.0

    Bump jsdom from 16.2.2 to 16.7.0

    Bumps jsdom from 16.2.2 to 16.7.0.

    Release notes

    Sourced from jsdom's releases.

    Version 16.7.0

    • Added AbortSignal.abort(). (ninevra)
    • Added dummy x and y properties to the return value of getBoundingClientRect(). (eiko)
    • Implemented wrapping for textareaEl.value if the wrap="" attribute is specified. (ninevra)
    • Changed newline normalization in <textarea>s according to recent HTML Standard updates. (ninevra)
    • Fixed some bad cascade computation in getComputedStyle(). (romain-trotard)

    Version 16.6.0

    • Added parentNode.replaceChildren(). (@​ninevra)
    • Fixed jsdom's handling of when code running inside the jsdom throws null or undefined as an exception. (@​mbest)
    • Removed the dependency on the deprecated request package, in the process fixing several issues with the XMLHttpRequest implementation around header processing. Thanks go to @​tobyhinloopen, @​andrewaylett, and especially @​vegardbb, for completing this months-long effort!

    Version 16.5.3

    • Fixed infinite recursion when using MutationObservers to observe elements inside a MutationObserver callback.

    Version 16.5.2

    • Fixed Access-Control-Allow-Headers: * to work with XMLHttpRequest. (silviot)
    • Fixed xhr.response to strip any leading BOM when xhr.responseType is "json".
    • Fixed new Text() and new Comment() constructors to properly set the resulting node's ownerDocument.
    • Fixed customElements.whenDefined() to resolve its returned promise with the custom element constructor, per recent spec updates. (ExE-Boss)
    • Fixed parsing to ensure that <svg>\<template></template></svg> does not throw an exception, but instead correctly produces a SVG-namespace \<template> element.
    • Fixed domParser.parseFromString() to treat <noscript> elements appropriately.
    • Fixed form control validity checking when the control was outside the <form> element and instead associated using the form="" attribute.
    • Fixed legendEl.form to return the correct result based on its parent <fieldset>.
    • Fixed optionEl.text to exclude <script> descendants.
    • Fixed radio buttons and checkboxes to not fire input and change events when disconnected.
    • Fixed inputEl.indeterminate to reset to its previous value when canceling a click event on a checkbox or radio button.
    • Fixed the behavior of event handler attributes (e.g. onclick="...code...") when there were global variables named element or formOwner. (ExE-Boss)
    • On Node.js v14.6.0+ where WeakRefs are available, fixed NodeIterator to no longer stop working when more than ten NodeIterator instances are created, and to use less memory due to inactive NodeIterators sticking around. (ExE-Boss)

    Version 16.5.1

    • Fixed a regression that broke customElements.get() in v16.5.0. (fdesforges)
    • Fixed window.event to have a setter which overwrites the window.event property with the given value, per the specification. This fixes an issue where after upgrading to jsdom v16.5.0 you would no longer be able to set a global variable named event in the jsdom context.

    Version 16.5.0

    • Added window.queueMicrotask().
    • Added window.event.
    • Added inputEvent.inputType. (diegohaz)
    • Removed ondragexit from Window and friends, per a spec update.
    • Fixed the URL of about:blank iframes. Previously it was getting set to the parent's URL. (SimonMueller)
    • Fixed the loading of subresources from the filesystem when they had non-ASCII filenames.
    • Fixed the hidden="" attribute to cause display: none per the user-agent stylesheet. (ph-fritsche)
    • Fixed the new File() constructor to no longer convert / to :, per a pending spec update.
    • Fixed mutation observer callbacks to be called with the MutationObserver instance as their this value.
    • Fixed <input type=checkbox> and <input type=radio> to be mutable even when disabled, per a spec update.
    • Fixed XMLHttpRequest to not fire a redundant final progress event if a progress event was previously fired with the same loaded value. This would usually occur with small files.
    • Fixed XMLHttpRequest to expose the Content-Length header on cross-origin responses.
    • Fixed xhr.response to return null for failures that occur during the middle of the download.
    • Fixed edge cases around passing callback functions or event handlers. (ExE-Boss)
    • Fixed edge cases around the properties of proxy-like objects such as localStorage or dataset. (ExE-Boss)

    ... (truncated)

    Changelog

    Sourced from jsdom's changelog.

    16.7.0

    • Added AbortSignal.abort(). (ninevra)
    • Added dummy x and y properties to the return value of getBoundingClientRect(). (eiko)
    • Implemented wrapping for textareaEl.value if the wrap="" attribute is specified. (ninevra)
    • Changed newline normalization in <textarea>s according to recent HTML Standard updates. (ninevra)
    • Fixed some bad cascade computation in getComputedStyle(). (romain-trotard)

    16.6.0

    • Added parentNode.replaceChildren(). (ninevra)
    • Fixed jsdom's handling of when code running inside the jsdom throws null or undefined as an exception. (mbest)
    • Removed the dependency on the deprecated request package, in the process fixing several issues with the XMLHttpRequest implementation around header processing. Special thanks to vegardbb for completing this months-long effort!

    16.5.3

    • Fixed infinite recursion when using MutationObservers to observe elements inside a MutationObserver callback.

    16.5.2

    • Fixed Access-Control-Allow-Headers: * to work with XMLHttpRequest. (silviot)
    • Fixed xhr.response to strip any leading BOM when xhr.responseType is "json".
    • Fixed new Text() and new Comment() constructors to properly set the resulting node's ownerDocument.
    • Fixed customElements.whenDefined() to resolve its returned promise with the custom element constructor, per recent spec updates. (ExE-Boss)
    • Fixed parsing to ensure that <svg>\<template></template></svg> does not throw an exception, but instead correctly produces a SVG-namespace \<template> element.
    • Fixed domParser.parseFromString() to treat <noscript> elements appropriately.
    • Fixed form control validity checking when the control was outside the <form> element and instead associated using the form="" attribute.
    • Fixed legendEl.form to return the correct result based on its parent <fieldset>.
    • Fixed optionEl.text to exclude <script> descendants.
    • Fixed radio buttons and checkboxes to not fire input and change events when disconnected.
    • Fixed inputEl.indeterminate to reset to its previous value when canceling a click event on a checkbox or radio button.
    • Fixed the behavior of event handler attributes (e.g. onclick="...code...") when there were global variables named element or formOwner. (ExE-Boss)
    • On Node.js v14.6.0+ where WeakRefs are available, fixed NodeIterator to no longer stop working when more than ten NodeIterator instances are created, and to use less memory due to inactive NodeIterators sticking around. (ExE-Boss)

    16.5.1

    • Fixed a regression that broke customElements.get() in v16.5.0. (fdesforges)
    • Fixed window.event to have a setter which overwrites the window.event property with the given value, per the specification. This fixes an issue where after upgrading to jsdom v16.5.0 you would no longer be able to set a global variable named event in the jsdom context.

    16.5.0

    • Added window.queueMicrotask().
    • Added window.event.
    • Added inputEvent.inputType. (diegohaz)
    • Removed ondragexit from Window and friends, per a spec update.
    • Fixed the URL of about:blank iframes. Previously it was getting set to the parent's URL. (SimonMueller)
    • Fixed the loading of subresources from the filesystem when they had non-ASCII filenames.
    • Fixed the hidden="" attribute to cause display: none per the user-agent stylesheet. (ph-fritsche)
    • Fixed the new File() constructor to no longer convert / to :, per a pending spec update.
    • Fixed mutation observer callbacks to be called with the MutationObserver instance as their this value.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v0.12.0)
  • v0.12.0(Jun 1, 2020)

    • fix cursor position after delete with multiple non-accepted chars after (Thanks to @lewisl9029)
    • transpile only for >1% and not ie browsers
    • size dropped from 768b to 753b
    • dropped UMD bundles, use codesandbox instead
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Feb 7, 2020)

    In this release added react hook version of rifm. Thanks to @lewisl9029

    import { useRifm } from 'rifm'
    
    const rifm = useRifm({
      format,
      value,
      onChange
    })
    
    <TextField
      type="tel"
      value={rifm.value}
      onChange={rifm.onChange}
    />
    

    Also rifm will warn if type=date is passed to input. Thanks to @ethanwillis

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Oct 21, 2019)

  • v0.9.0(Jun 3, 2019)

    This is a big release with new features

    1. We discovered that passed values are formatted in all our cases so we decided to automatically format passed value.
     <Rifm
       format={format}
    -  value={format(current)}
    +  value={current}
       ...
     >
    
    1. The edge case with fixed point numbers is solved:

    You have 0|.00, then press 1, it becomes 01|.00 and after format 1.00, this breaks our assumption that order of accepted symbols is not changed after format. The result is 1.0|0.

    1. replace function is changed to mask boolean. Now you may pass boolean value based on current state.
     <Rifm
    -  replace={v => 10 <= v.length}
    +  mask={10 <= current.length}
     >
    

    Note: we still discovering how to make this api cleaner.

    1. We added the new api for formatting with preserving cursor. It's called replace (don't confuse with previous api) and has the same type as format.
    <Rifm
      format={v => v}
      replace={v =>
        'Rifm is the best mask and formatting library. I love it! '
          .repeat(20)
          .slice(0, v.length)
      }
      ...
    >
    

    This api is now responsible for case enforcement which is no longer supported by format

     <Rifm
    -  format={v => v.toLowerCase()}
    +  format={v => v}
    +  replace(v => v.toLowerCase())
     ...
     >
    
    1. The new docs should shed light on ideas behind RIFM and better describe api https://github.com/istarkov/rifm#api

    Thank you for using RIFM

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(May 27, 2019)

    In this release rifm is refactored with hooks. Gzipped size is reduced from 909 to 627 bytes. This big win allows us to add more features and still fit into 1kb lib. Note: api is still render prop based.

    Confusing refuse prop is replaced with inverted version accept. We decided that whitelist (regexp) is more straightforward way to parse values. For example

    • refuse={/$^/} becomes accept={/.+/g}
    • refuse={/[^\d]+/g} becomes accept={/\d+/g}

    In Saturday we deployed our new website. With this release we handled a few edge cases for number and date formats and added some styles to make examples nicer

    image

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Feb 21, 2019)

    It's often useful to enforce lower or upper case in inputs but it's not enough to run string.toLowerCase() in value/onChange data flow. In this release we added support for casing.

    <Rifm format={v => v.toLowerCase()} refuse={/$^/} value={value} onChange={setValue}>
      {({ value, onChange }) => (
        <input value={value} onChange={onChange} />
      )}
    </Rifm>
    

    There is also a small DX improvement. Rifm shows error when you are trying to bind input with type="number" which manipulates only numbers when rifm manipulates strings.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jan 21, 2019)

  • v0.5.0(Jan 15, 2019)

  • v0.4.3(Sep 9, 2018)

    #35 fixes this #27

    Before if value wasn't changed (for example if user enters incorrect symbol) rifm produced onChange event, and then provided incorrect output if state above had optimization like do not change state if value has not been changed

    Having that a lot of state libraries have similar optimizations (selectors in redux etc) this was a must have fix.

    Source code(tar.gz)
    Source code(zip)
  • v0.4.2(Sep 9, 2018)

    Fix https://github.com/istarkov/rifm/pull/33

    18-08|-1978 where | is cursor, delete causes cursor move in incorrect position 18-08-1|978 must be 18-08-|1978

    New example with string-mask library usage added see https://istarkov.github.io/rifm/docs-readme#string-mask-input

    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Sep 9, 2018)

Owner
RealAdvisor
Get Property Smart
RealAdvisor
React component for international phone number input

react-phone-number-input International phone number input for React. See Demo Install npm install react-phone-number-input --save If you're not us

Nikolay 837 Dec 21, 2022
International phone number input component for react

Welcome to react-contact-number-input ?? International phone number input component for react Install npm install react-contact-number-input Author ??

Vaibhav Gurnani 15 Nov 9, 2022
Masked input React component

MaskedInput A React component for input masking, built on top of inputmask-core. Live Demo Install npm npm install react-maskedinput --save Browser

Jonny Buchanan 721 Nov 30, 2022
A React hook for building phone number inputs

use-telephone A React hook for building phone number inputs Installation use-telephone depends on React >= 16.8, so make sure you have it installed. y

Alistair Smith 16 Sep 15, 2022
Input mask for React, Angular, Ember, Vue, & plain JavaScript

⚠️ This library is not maintained. Pull-requests and issues are not monitored. Alternatives to text-mask include: https://github.com/uNmAnNeR/imaskjs

Text Mask 8.2k Jan 2, 2023
Input mask for React, Angular, Ember, Vue, & plain JavaScript

Text Mask is an input mask library. It can create input masks for phone, date, currency, zip code, percentage, email, and literally anything!

Text Mask 8.2k Jan 4, 2023
React Currency Input Field Component

React Currency Input Field Component

Chun 357 Dec 30, 2022
A numpad for number, date and time, built with and for React.

React numpad A numpad for number, date and time, built with and for React. It's written with the extensibility in mind. The idea of this project is to

Pietro Ghezzi 130 Dec 21, 2022
An edit mask for React based on regular expression syntax with cursor handling.

react-editmask An edit mask for React based on regular expression syntax with cursor handling. Installation react-editmask requires React 0.14 or late

Andy Krumel 2 Jul 2, 2019
Beautiful credit cards for your payment forms

React Credit Cards A slick credit card component for React. Demo Install npm install --save react-credit-cards Usage import React from 'react'; impor

AMARO 2.4k Dec 30, 2022
React Input Number

rc-input-number Input number control.

react-component 275 Dec 13, 2022
A React Hook & Container to help with payment card input fields.

React Payment Inputs A React Hook & Container to help with payment card input fields. React Payment Inputs Demos Requirements Installation Usage With

medipass 303 Dec 22, 2022
Format-as-you-type - A simple field formatting and masking tool for React

Format As You Type The simplest field formatting and masking tool for React. For

Mark Kopani 3 Jan 27, 2022
Input masking component for React. Made with attention to UX.

react-input-mask Input masking component for React. Made with attention to UX. This is a development branch for version 3.0. For the latest stable ver

Nikita Lobachev 2.1k Dec 30, 2022
A fully customizable, one-time password input component for the web built with React.

react-otp-input A fully customizable, one-time password input component for the web built with React. Live Demo CodeSandbox Installation To install th

Devfolio 402 Dec 30, 2022
React component that handles csv file input and its parsing

react-csv-reader React component that handles csv file input. It handles file input and returns its content as a matrix. Docs: nzambello.github.io/rea

Nicola Zambello 180 Dec 26, 2022
Time-input - A keyboard friendly react component for capturing time

time-input A keyboard friendly react component for capturing time features small UI surface area (just a form input) keyboard friendly (can type times

Alan Clarke 28 Jun 6, 2019
A fully customizable, one-time password input component for the web built with React

block-code A fully customizable, one-time password input component for the web built with React Live demo Highlights Easy to use Fully customizable Re

EUI Official 9 Sep 5, 2022
A ReactJS component that allows for multiple text field input, built using the FluentUI library

A ReactJS component that allows for multiple text field input, built using the FluentUI library

Boia Alexandru 1 Sep 22, 2021