You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
**Breaking change:** Now uses a `mask` prop to define the input mask instead of `pattern`, to avoid preventing use of the the HTML5 `pattern` attribute in conjunction with the input mask.
2
+
1
3
**Breaking change:** React >= 0.14 is now required.
A [React](http://facebook.github.io/react/) component for `<input>` masking,
4
-
built on top of [inputmask-core](https://github.com/insin/inputmask-core).
3
+
A [React](http://facebook.github.io/react/) component for `<input>` masking, built on top of [inputmask-core](https://github.com/insin/inputmask-core).
`MaskedInput` can be used on the server, or bundled for the client using an
13
-
npm-compatible packaging system such as [Browserify](http://browserify.org/) or
14
-
[webpack](http://webpack.github.io/).
11
+
`MaskedInput` can be used on the server, or bundled for the client using an npm-compatible packaging system such as [Browserify](http://browserify.org/) or [webpack](http://webpack.github.io/).
15
12
16
13
```
17
14
npm install react-maskedinput --save
18
15
```
19
16
20
17
### Browser bundle
21
18
22
-
The browser bundle exposes a global `MaskedInput` variable and expects to find
23
-
a global `React` variable to work with.
19
+
The browser bundle exposes a global `MaskedInput` variable and expects to find a global `React` (>= 0.14.0) variable to work with.
24
20
25
21
You can find it in the [/dist directory](https://github.com/insin/react-maskedinput/tree/master/dist).
26
22
27
23
## Usage
28
24
29
-
Give `MaskedInput` a [`pattern`](#pattern-string) and an `onChange` callback:
25
+
Give `MaskedInput` a [`mask`](#mask-string) and an `onChange` callback:
30
26
31
27
```javascript
32
28
var React =require('react')
@@ -49,29 +45,28 @@ var CreditCardDetails = React.createClass({
Create some wrapper components if you have a masking configuration which will be
68
-
reused:
63
+
Create some wrapper components if you have a masking configuration which will be reused:
69
64
70
65
```javascript
71
66
var CustomInput =React.createClass({
72
67
render() {
73
68
return<MaskedInput
74
-
pattern="1111-WW-11"
69
+
mask="1111-WW-11"
75
70
placeholder="1234-WW-12"
76
71
size="11"
77
72
{...this.props}
@@ -88,30 +83,25 @@ var CustomInput = React.createClass({
88
83
89
84
## Props
90
85
91
-
### `pattern` : `string`
86
+
### `mask` : `string`
92
87
93
88
The masking pattern to be applied to the `<input>`.
94
89
95
-
See the [inputmask-core docs](https://github.com/insin/inputmask-core#pattern)
96
-
for supported formatting characters.
90
+
See the [inputmask-core docs](https://github.com/insin/inputmask-core#pattern) for supported formatting characters.
97
91
98
92
### `onChange` : `(event: SyntheticEvent) => any`
99
93
100
94
A callback which will be called any time the mask's value changes.
101
95
102
-
This will be passed a `SyntheticEvent` with the input accessible via
103
-
`event.target` as usual.
96
+
This will be passed a `SyntheticEvent` with the input accessible via `event.target` as usual.
104
97
105
-
**Note:** this component currently calls `onChange` directly, it does not
106
-
generate an `onChange` event which will bubble up like a regular `<input>`
107
-
component, so you *must* pass an `onChange` if you want to get a value back out.
98
+
**Note:** this component currently calls `onChange` directly, it does not generate an `onChange` event which will bubble up like a regular `<input>` component, so you *must* pass an `onChange` if you want to get a value back out.
108
99
109
100
### `formatCharacters`: `Object`
110
101
111
102
Customised format character definitions for use in the pattern.
112
103
113
-
See the [inputmask-core docs](https://github.com/insin/inputmask-core#formatcharacters)
114
-
for details of the structure of this object.
104
+
See the [inputmask-core docs](https://github.com/insin/inputmask-core#formatcharacters) for details of the structure of this object.
115
105
116
106
### `placeholderChar`: `string`
117
107
@@ -125,21 +115,17 @@ A default value for the mask.
125
115
126
116
### `placeholder` : `string`
127
117
128
-
A default `placeholder` will be generated from the mask's pattern, but you can
129
-
pass a `placeholder` prop to provide your own.
118
+
A default `placeholder` will be generated from the mask's pattern, but you can pass a `placeholder` prop to provide your own.
130
119
131
120
### `size` : `number | string`
132
121
133
-
By default, the rendered `<input>`'s `size` will be the length of the pattern,
134
-
but you can pass a `size` prop to override this.
122
+
By default, the rendered `<input>`'s `size` will be the length of the pattern, but you can pass a `size` prop to override this.
135
123
136
124
### Other props
137
125
138
-
Any other props passed in will be passed as props to the rendered `<input>`,
139
-
except for the following, which are managed by the component:
126
+
Any other props passed in will be passed as props to the rendered `<input>`, except for the following, which are managed by the component:
140
127
141
128
*`maxLength` - will always be equal to the pattern's `.length`
142
-
*`onKeyDown`, `onKeyPress` & `onPaste` - will each trigger a call to `onChange`
143
-
when necessary
129
+
*`onKeyDown`, `onKeyPress` & `onPaste` - will each trigger a call to `onChange` when necessary
0 commit comments