Skip to content

Commit 7d5aee3

Browse files
Deprecate old input masks (#57)
1 parent e47d06b commit 7d5aee3

11 files changed

+230
-193
lines changed

README.md

+1-191
Original file line numberDiff line numberDiff line change
@@ -71,194 +71,4 @@ This component has the same interface as it's [ember-one-way-controls counterpar
7171
* [{{one-way-phone-mask}}](docs/one-way-phone-mask.md)
7272
* [{{one-way-ssn-mask}}](docs/one-way-ssn-mask.md)
7373
* [{{one-way-zip-code-mask}}](docs/one-way-zip-code-mask.md)
74-
75-
## Input Mask Component (deprecated)
76-
77-
The standard `input-mask` component:
78-
79-
```hbs
80-
{{input-mask mask='999-aaa-***' value=foo unmaskedValue=bar}}
81-
```
82-
83-
### Default Masking Definitions
84-
85-
- `9` : numeric
86-
- `a` : alphabetical
87-
- `*` : alphanumeric
88-
- `A` : automatically uppercased alphabetical
89-
- `#` : unicode
90-
91-
Optional portions of masks are delimited with brackets `[]`:
92-
93-
```hbs
94-
// Optionally lets the user add the last dash and characters
95-
{{input-mask mask='999-aaa[-***]' value=foo unmaskedValue=bar}}
96-
```
97-
98-
### Unmasked Value
99-
100-
The mask is applied directly to the input itself, meaning it alters the `value`
101-
attribute. There are times when you might want the value with the mask, and
102-
times when you might want the value without the mask. For example:
103-
104-
```hbs
105-
{{input-mask mask='99/99/9999' value=foo unmaskedValue=bar}}
106-
```
107-
108-
This is an ad hoc mask for a date (consider using the `date-input` component
109-
instead). If the user were to enter `12/12/2014`, the value of `foo` would be
110-
just that, whereas the value of `bar` would be `12122014`, which may not be as
111-
useful to you. Either way, both values are accessible and bound to each other,
112-
so choose whichever one you want.
113-
114-
### Options
115-
116-
- `maskPlaceholder` (default: `null`)
117-
118-
Override Inputmask's default
119-
[`placeholder`](https://github.com/RobinHerbots/Inputmask#placeholder-1)
120-
option.
121-
122-
- `showMaskOnFocus` (default: `true`)
123-
124-
Shows the user a preview of the mask when the field is focussed.
125-
126-
- `showMaskOnHover` (default: `true`)
127-
128-
Shows the user a preview of the mask when the field is hovered.
129-
130-
- `rightAlign` (default: `false`)
131-
132-
This is an option on the original plugin, but I highly recommend using CSS
133-
classes because all it does is apply a style directly to the input.
134-
135-
- `clearIncomplete` (default: `false`)
136-
137-
If the user does not completely fill in the mask before defocus, it will
138-
clear the input.
139-
140-
- `greedyMask` (default: `false`)
141-
142-
If there are any optional portions of the mask this decides whether or not
143-
to display them in the preview.
144-
145-
## Other Components
146-
147-
As mentioned above, this addon include other components that extend the base
148-
`input-mask` component. Some of simple aliases, but some add additional options.
149-
150-
### Credit Card Inputs (deprecated)
151-
152-
```hbs
153-
{{credit-card-input unmaskedValue=foo cardType=bar separator=' '}}
154-
```
155-
156-
The `credit-card-input` dynamically determines the type of the credit card and
157-
changes the mask as appropriate. It currently has support for:
158-
159-
- Visa
160-
- MasterCard
161-
- Amex
162-
- Diners Club
163-
- Discover
164-
- JCB
165-
166-
The card type is stored in `cardType`, which can be bound to. The separator for
167-
numbers can be specified with the `separator` option, and defaults to `-`.
168-
169-
### Currency Inputs (deprecated)
170-
171-
```hbs
172-
{{currency-input unmaskedValue=foo}}
173-
```
174-
175-
This is just a wrapper for the Inputmask alias and is equivalent to the
176-
following:
177-
178-
```hbs
179-
{{input-mask mask='currency' unmaskedValue=foo}}
180-
```
181-
182-
### Date Inputs (deprecated)
183-
184-
```hbs
185-
{{date-input unmaskedValue=foo}}
186-
```
187-
188-
This is just a wrapper for the Inputmask alias and is equivalent to the
189-
following:
190-
191-
```hbs
192-
{{input-mask mask='date' unmaskedValue=foo}}
193-
```
194-
195-
### Email Inputs (deprecated)
196-
197-
```hbs
198-
{{email-input unmaskedValue=foo}}
199-
```
200-
201-
This is just a wrapper for the Inputmask alias and is equivalent to the
202-
following:
203-
204-
```hbs
205-
{{input-mask mask='email' unmaskedValue=foo}}
206-
```
207-
208-
### Number Inputs (deprecated)
209-
210-
```hbs
211-
{{number-input unmaskedValue=foo group=false groupSize=3 separator=',''
212-
decimal=false radix='.'}}
213-
```
214-
215-
Number inputs only accept numbers, and can be modified using the following
216-
options:
217-
218-
- `group`: Display the number grouped for readability (e.g. `1,234` vs.
219-
`1234`).
220-
- `groupSize`: Change the size of the groups.
221-
- `separator`: Change the group separator. (Caveat: If radix and separator are
222-
the same, then the radix will default to '.'.)
223-
- `decimal`: If set to `true` then the input will be given 2 decimal places,
224-
if set some number then the input will be given that many decimal places.
225-
- `radix`: Sets the radix that separates the decimal places.
226-
- `digitsOptional`: Specify whether digits are optional (e.g. `97.00` vs. `97`)
227-
- `prefix`: Sets a prefix to be displayed before the number (e.g. `$97.00`)
228-
- `suffix`: Sets a suffix to be displayed after the number (e.g. `100%`)
229-
- `min`: Sets the minimum value for the field
230-
- `max`: Sets the maximum value for the field
231-
- `unmaskAsNumber`: Unmasks the input as a number rather than a string (e.g. `1234.56` vs. `'1234,56'`)
232-
233-
### US/Canada Phone Number Inputs (deprecated)
234-
235-
```hbs
236-
{{phone-number-input unmaskedValue=foo extensions=false}}
237-
```
238-
239-
Masks a US/Canada phone number with the format `(999) 999-9999`. The
240-
`extensions` option can be set to `true` to allow up to 4 digit extensions
241-
`(999) 999-9999 x 9999`. Note that if `greedyMask` is set to `false`, which is
242-
the default, then you have to press space or 'x' to activate the extension part
243-
of the mask when entering.
244-
245-
NOTE: There is a "phone" alias included in Inputmask, but when
246-
I tried using it, I encountered slowness and freezeups. It is much more general
247-
than this tag, however.
248-
249-
### US SSN Inputs
250-
251-
```hbs
252-
{{ssn-input unmaskedValue=foo}}
253-
```
254-
255-
Masks a US SSN code (`999-99-9999`).
256-
257-
### US ZIP Code Inputs (deprecated)
258-
259-
```hbs
260-
{{zip-code-input unmaskedValue=foo fullCode=false}}
261-
```
262-
263-
Masks a US ZIP code. If `fullCode` is set to `true`, then it will enable the
264-
user to enter an extended ZIP+4 code.
74+
* [Deprecated Masks](docs/deprecated-masks.md)

addon/components/credit-card-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
1515
*/
1616

1717
export default InputMaskComponent.extend({
18+
oldComponent: '{{credit-card-input}}',
19+
newComponent: '{{one-way-credit-card-mask}}',
20+
1821
updateMask: function() {
1922
var cardType = this.get('cardType'),
2023
s = this.get('separator') || '-', // s for separator for convenience

addon/components/currency-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
77
*/
88

99
export default InputMaskComponent.extend({
10+
oldComponent: '{{currency-input}}',
11+
newComponent: '{{one-way-currency-mask}}',
1012
mask: 'currency'
1113
});

addon/components/date-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
77
*/
88

99
export default InputMaskComponent.extend({
10+
oldComponent: '{{date-input}}',
11+
newComponent: '{{one-way-date-mask}}',
1012
mask: 'date'
1113
});

addon/components/email-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
77
*/
88

99
export default InputMaskComponent.extend({
10+
oldComponent: '{{email-input}}',
11+
newComponent: '{{one-way-email-mask}}',
1012
mask: 'email'
1113
});

addon/components/input-mask.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* global Inputmask */
22

33
import { once, debounce } from '@ember/runloop';
4-
4+
import { deprecate } from '@ember/debug';
55
import { isPresent } from '@ember/utils';
66
import { on } from '@ember/object/evented';
7-
import { computed, observer } from '@ember/object';
7+
import { computed, observer, get } from '@ember/object';
88
import TextField from '@ember/component/text-field';
99

1010
/**
@@ -46,6 +46,18 @@ export default TextField.extend({
4646

4747
value: 'value',
4848

49+
oldComponent: '{{input-mask}}',
50+
newComponent: '{{one-way-input-mask}}',
51+
52+
init() {
53+
this._super(...arguments);
54+
let message = `${get(this, 'oldComponent')} is deprecated in favor of ${get(this, 'newComponent')} and will be removed in 1.0.0`;
55+
deprecate(message, false, {
56+
id: 'non-one-way-mask',
57+
until: '1.0.0',
58+
});
59+
},
60+
4961
options: computed(function() {
5062
return {};
5163
}),

addon/components/number-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export default InputMaskComponent.extend({
5050
suffix: '',
5151
unmaskAsNumber: false,
5252

53+
oldComponent: '{{number-input}}',
54+
newComponent: '{{one-way-number-mask}}',
55+
5356
updateMask: function() {
5457
this.setProperties({
5558
'options.autoGroup': this.get('group'),

addon/components/phone-number-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
1919
export default InputMaskComponent.extend({
2020
mask: '(299) 999-9999',
2121

22+
oldComponent: '{{phone-number-input}}',
23+
newComponent: '{{one-way-phone-mask}}',
24+
2225
updateMask: function() {
2326
if (this.get('extensions')) {
2427
this.set('mask', '(299) 999-9999[ x 9{1,4}]');

addon/components/ssn-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import InputMaskComponent from 'ember-inputmask/components/input-mask';
1010
export default InputMaskComponent.extend({
1111
mask: '999-99-9999',
1212

13+
oldComponent: '{{ssn-input}}',
14+
newComponent: '{{one-way-ssn-mask}}',
15+
1316
updateMask() {
1417
this.set('mask', '999-99-9999');
1518
this._super();

addon/components/zip-code-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default InputMaskComponent.extend({
2020

2121
fullCode: false,
2222

23+
oldComponent: '{{zip-code-input}}',
24+
newComponent: '{{one-way-zip-code-mask}}',
25+
2326
updateMask: function() {
2427
if (this.get('fullCode')) {
2528
this.set('mask', '99999[-9999]');

0 commit comments

Comments
 (0)