use-input-mask
v1.0.0
Published
![MIT License][license-badge] [![downloads][downloads-badge]][npmcharts] [![PRs Welcome][prs-badge]][prs]
Downloads
50
Readme
use-input-mask
Installation
$ yarn add use-input-mask
# or
$ npm i use-input-mask
Usage
import React from 'react'
import useInputMask from 'use-input-mask'
import { createAutoCorrectedDatePipe } from "text-mask-addons";
const MyDateInput = props => {
const input = useRef(null);
const autoCorrectedDatePipe = createAutoCorrectedDatePipe("dd/mm/yyyy HH:MM");
const onChange = useInputMask({
input,
onChange: props.onChange,
mask: [/\d/, /\d/, "/", /\d/, /\d/, "/", /\d/, /\d/, /\d/, /\d/],
pipe: autoCorrectedDatePipe,
keepCharPositions: true
});
return <input {...props} ref={input} onChange={onChange} />;
};
export default MyDateInput
Roadmap
- [ ] tests
- [ ] ci/cd
- [ ] semantic-release
- [ ] docs
- [ ] all-contributors
Inspiration
LIENSE
MIT