Skip to content

Commit

Permalink
Merge pull request #139 from benhurott/1.12.0
Browse files Browse the repository at this point in the history
1.12.0
  • Loading branch information
Ben-hur Santos Ott authored Apr 7, 2019
2 parents 5556de5 + 754cddf commit 1226357
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 5,491 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## Unreleased

## [1.12.0] - 2019-04-07

### Added

- Adding `rawText` in `onChangeText`. (Thanks to [questionablequestion](https://github.com/questionablequestion))

### Fixed

- Fixing return type of `getRawValue` in `ts definition`. (Thanks to [gabelerner](https://github.com/gabelerner))

### Changed

- Improving component initialization. (Thanks to [rsouthgate](https://github.com/rsouthgate))

## [1.11.1] - 2019-03-05

### Fixed
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
copy-to-test:
rm -rf ../rn-test/react-native-masked-text
npm run clean
npm run build
cp -R dist ../rn-test/react-native-masked-text
copy-to-samples:
rm -rf /Users/ben/Documents/dev/react-native-masked-text-samples/ReactNativeMaskedTextSamples/lib
mkdir /Users/ben/Documents/dev/react-native-masked-text-samples/ReactNativeMaskedTextSamples/lib
cp -R lib /Users/ben/Documents/dev/react-native-masked-text-samples/ReactNativeMaskedTextSamples
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,26 @@ const unmasked = this.zipCodeField.getRawValue()
// unmasked: 98765321
```

### ... Utils

#### Including the `rawText` in `onChangeText` [1.12.0+]

If you need the raw value in every text change, you can use the `includeRawValueInChangeText`.

It will provide the masked and the raw text in every text change.

```jsx
<TextInputMask
type={'cpf'}
value={this.state.value}
includeRawValueInChangeText={true}
onChangeText={(maskedText, rawText) => {
// maskedText: 123.456.789-01
// rawText: 12345678901
}}
/>
```

### ... Utils

#### Getting the `TextInput` instance
If you want to get the `TextInput` raw component, use the `getElement()` method:
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/base-text-component.js

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

2 changes: 1 addition & 1 deletion dist/lib/text-input-mask.js

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

9 changes: 6 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ export interface TextInputMaskOptionProp {
// Custom type.
mask?: string
validator?: (value: string, settings: TextInputMaskOptionProp) => boolean
getRawValue?: (value: string, settings: TextInputMaskOptionProp) => boolean
getRawValue?: (value: string, settings: TextInputMaskOptionProp) => any
translation?: { [s: string]: (val: string) => string | null | undefined }

// Options
includeRawValueInChangeText?: boolean
}

// TextInputMask Props
export interface TextInputMaskProps extends TextInputProps {
export interface TextInputMaskProps extends Pick<TextInputProps, Exclude<keyof TextInputProps, 'onChangeText'>> {
type: TextInputMaskTypeProp
options?: TextInputMaskOptionProp
checkText?: (previous: string, next: string) => boolean
onChangeText?: (text: string) => void
onChangeText?: (text: string, rawText?: string) => void
refInput?: (ref: any) => void
customTextInput?: any
customTextInputProps?: Object
Expand Down
Loading

0 comments on commit 1226357

Please sign in to comment.