Skip to content

Commit

Permalink
fix(issue 79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-hur Santos Ott committed Jun 17, 2018
1 parent 3c6c419 commit 40a624d
Show file tree
Hide file tree
Showing 13 changed files with 6,170 additions and 1,185 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.7.2

* Fixing [ISSUE#79](https://github.com/benhurott/react-native-masked-text/issues/79). (thanks to [herlan-evocorp](https://github.com/herlan-evocorp))

## 1.7.1

* Updating moment lib.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CelPhoneMask } from '../lib/masks';
import { CelPhoneMask } from '../../lib/masks';

test('getType results cel-phone', () => {
var expected = 'cel-phone';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CnpjMask } from '../lib/masks'
import { CnpjMask } from '../../lib/masks'

test('getType results cnpj', () => {
var expected = 'cnpj'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CpfMask } from '../lib/masks'
import { CpfMask } from '../../lib/masks'

test('getType results cpf', () => {
var expected = 'cpf'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreditCardMask } from '../lib/masks';
import { CreditCardMask } from '../../lib/masks';

test('getType results credit-card', () => {
var expected = 'credit-card';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CustomMask } from '../lib/masks';
import { CustomMask } from '../../lib/masks';

test('getType results custom', () => {
var expected = 'custom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DatetimeMask } from '../lib/masks';
import { DatetimeMask } from '../../lib/masks';
var moment = require('moment');

function compareMomentObj(dateTimeA, dateTimeB) {
var momentA = moment(dateTimeA,"DD/MM/YYYY");
var momentB = moment(dateTimeB,"DD/MM/YYYY");
var momentA = moment(dateTimeA, "DD/MM/YYYY");
var momentB = moment(dateTimeB, "DD/MM/YYYY");
if (momentA > momentB) return 1;
else if (momentA < momentB) return -1;
else return 0;
Expand Down Expand Up @@ -96,7 +96,7 @@ test('01011990174030 with format DD/MM/YYYY HH:mm:ss results 01/01/1990 17:40:30
var received = mask.getValue('01011990174030');

var expectedRawValue = moment(received, 'DD/MM/YYYY HH:mm:ss', true);
var receivedRawValue = mask.getRawValue(received);
var receivedRawValue = mask.getRawValue(received);

expect(received).toBe(expected);
expect(compareMomentObj(receivedRawValue, expectedRawValue)).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MoneyMask } from '../lib/masks'
import { MoneyMask } from '../../lib/masks'

test('getType results money', () => {
var expected = 'money'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OnlyNumbersMask } from '../lib/masks';
import { OnlyNumbersMask } from '../../lib/masks';

test('getType results only-numbers', () => {
var expected = 'only-numbers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZipCodeMask } from '../lib/masks';
import { ZipCodeMask } from '../../lib/masks';

test('getType results zip-code', () => {
var expected = 'zip-code';
Expand Down
14 changes: 7 additions & 7 deletions lib/text-input-mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import {
} from 'react-native';
import BaseTextComponent from './base-text-component';

const INPUT_TEXT_REF = '$input-text';

export default class TextInputMask extends BaseTextComponent {
getElement() {
return this.refs[INPUT_TEXT_REF];
return this._inputElement;
}

_onChangeText(text) {
Expand Down Expand Up @@ -52,10 +50,12 @@ export default class TextInputMask extends BaseTextComponent {
return (
<Input
ref={(ref) => {
if(ref) {
if (typeof this.props.refInput === 'function') {
this.props.refInput(ref);
}
if (ref) {
this._inputElement = ref;

if (typeof this.props.refInput === 'function') {
this.props.refInput(ref);
}
}
}}
keyboardType={this._getKeyboardType()}
Expand Down
Loading

0 comments on commit 40a624d

Please sign in to comment.