Skip to content

Commit

Permalink
Merge pull request #187 from benhurott/1.13.0-dev
Browse files Browse the repository at this point in the history
1.13.0 dev
  • Loading branch information
Ben-hur Santos Ott authored Aug 13, 2019
2 parents 07952dd + ac07113 commit 2904556
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## Unreleased

## [1.13.0] - 2019-08-13

### Chore

- [BREAKING CHANGE] Migrating from `moment` to `date-and-time`.
- Thanks to [Marcin Krysiak](https://github.com/marcinkrysiak1979) for contributing!

### Fix

- [#184](https://github.com/benhurott/react-native-masked-text/issues/184) TextInputMask doesnt render mask correctly when type change.
- Thanks to [Rodrigo Weber](https://github.com/RodrigoAWeber) for contributing!

### Docs

- Fixing documentaion link.
- Thanks to [Luan Curti](https://github.com/luancurti) for contributing!

## [1.12.5] - 2019-08-03

### Fix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ console.log(numberValue) // Number

Mask: `accept only numbers`

Sample code ([source](https://github.com/benhurott/react-native-masked-text-samples/blob/master/ReactNativeMaskedTextSamples/Samples/ZipCode.js)):
Sample code ([source](https://github.com/benhurott/react-native-masked-text-samples/blob/master/ReactNativeMaskedTextSamples/Samples/OnlyNumbers.js)):


```jsx
Expand Down
8 changes: 4 additions & 4 deletions __tests__/mask/datetime.mask.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DatetimeMask } from '../../lib/masks'
var moment = require('moment')
import date from 'date-and-time';

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

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

expect(received).toBe(expected)
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/masks/datetime.mask.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/base-text-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default class BaseTextComponent extends PureComponent {
this._bindProps(this.props);
}

componentDidUpdate() {
this._bindProps(this.props);
componentDidUpdate(prevProps) {
this._bindProps(prevProps);
}

updateValue(text) {
Expand Down
10 changes: 5 additions & 5 deletions lib/masks/datetime.mask.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseMask from './_base.mask'
import CustomMask from './custom.mask'
var moment = require('moment')
import date from 'date-and-time'

const DATETIME_MASK_SETTINGS = {
format: 'DD/MM/YYYY HH:mm:ss'
Expand All @@ -20,13 +20,13 @@ export default class DatetimeMask extends BaseMask {

getRawValue(maskedValue, settings) {
let mergedSettings = this._getMergedSettings(settings)
return moment(maskedValue, mergedSettings.format, true)
return date.parse(maskedValue, mergedSettings.format)
}

validate(value, settings) {
var maskedValue = this.getValue(value, settings)
let maskedValue = this.getValue(value, settings)
let mergedSettings = this._getMergedSettings(settings)
var isValid = moment(maskedValue, mergedSettings.format, true).isValid()
let isValid = date.isValid(maskedValue, mergedSettings.format)
return isValid
}

Expand All @@ -37,7 +37,7 @@ export default class DatetimeMask extends BaseMask {
getMask(value, settings) {
let mask = ''

for (var i = 0; i < settings.format.length; i++) {
for (let i = 0; i < settings.format.length; i++) {
mask += settings.format[i].replace(/[a-zA-Z]+/g, '9')
}

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-masked-text",
"version": "1.12.5",
"version": "1.13.0",
"description": "Text and TextInput with mask for React Native applications",
"licenses": [
{
Expand Down Expand Up @@ -36,14 +36,14 @@
},
"homepage": "https://github.com/benhurott/react-native-masked-text#readme",
"dependencies": {
"moment": "2.19.3",
"tinymask": "^1.0.2"
"date-and-time": "0.9.0",
"tinymask": "1.0.2"
},
"devDependencies": {
"@types/react-native": "*",
"@types/react": "*",
"babel-cli": "^6.26.0",
"rimraf": "^2.6.2",
"babel-cli": "6.26.0",
"rimraf": "2.6.2",
"react": "16.3.1",
"react-native": "0.55.4",
"babel-jest": "23.4.2",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,11 @@ data-urls@^1.0.0:
whatwg-mimetype "^2.2.0"
whatwg-url "^7.0.0"

date-and-time@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-0.9.0.tgz#1524579e56dc07675c640b41735a7665c0659240"
integrity sha512-4JybB6PbR+EebpFx/KyR5Ybl+TcdXMLIJkyYsCx3P4M4CWGMuDyFF19yh6TyasMAIF5lrsgIxiSHBXh2FFc7Fg==

[email protected], debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down

0 comments on commit 2904556

Please sign in to comment.