react-braintree-fields
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -11,2 +11,4 @@ import { render } from 'react-dom'; | ||
super(props); | ||
this.numberField = React.createRef(); | ||
this.braintree = React.createRef(); | ||
[ | ||
@@ -71,3 +73,3 @@ 'onError', | ||
onAuthorizationSuccess() { | ||
this.numberField.focus(); | ||
this.numberField.current.focus(); | ||
} | ||
@@ -83,2 +85,3 @@ | ||
<Braintree | ||
ref={this.braintree} | ||
authorization={this.state.authorization} | ||
@@ -108,3 +111,3 @@ onAuthorizationSuccess={this.onAuthorizationSuccess} | ||
prefill="4111 1111 1111 1111" | ||
ref={numberField => { this.numberField = numberField; }} | ||
ref={this.numberField} | ||
/> | ||
@@ -111,0 +114,0 @@ <p>Card type: {this.state.card}</p> |
@@ -85,3 +85,3 @@ (function (global, factory) { | ||
this.fields = {}; | ||
this._nextFieldId = 1; | ||
this._nextFieldId = 0; | ||
this.fieldHandlers = {}; | ||
@@ -143,2 +143,3 @@ | ||
this.client = client; | ||
HostedFields.create({ | ||
@@ -183,5 +184,7 @@ client: client, | ||
prefill = _ref2.prefill, | ||
handlers = objectWithoutProperties(_ref2, ['formatInput', 'maxlength', 'minlength', 'placeholder', 'select', 'type', 'prefill']); | ||
_ref2$id = _ref2.id, | ||
id = _ref2$id === undefined ? 'braintree-field-wrapper-' + this.nextFieldId() : _ref2$id, | ||
rejectUnsupportedCards = _ref2.rejectUnsupportedCards, | ||
handlers = objectWithoutProperties(_ref2, ['formatInput', 'maxlength', 'minlength', 'placeholder', 'select', 'type', 'prefill', 'id', 'rejectUnsupportedCards']); | ||
var id = 'field-wrapper-' + this.nextFieldId(); | ||
this.fieldHandlers[type] = handlers; | ||
@@ -197,2 +200,5 @@ this.fields[type] = { | ||
}; | ||
if ('number' === type && rejectUnsupportedCards) { | ||
this.fields.number.rejectUnsupportedCards = true; | ||
} | ||
return id; | ||
@@ -378,2 +384,3 @@ } | ||
type: PropTypes.oneOf(['number', 'expirationDate', 'expirationMonth', 'expirationYear', 'cvv', 'postalCode']).isRequired, | ||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
placeholder: PropTypes.string, | ||
@@ -380,0 +387,0 @@ className: PropTypes.string, |
@@ -79,3 +79,3 @@ import Braintree from 'braintree-web/client'; | ||
this.fields = {}; | ||
this._nextFieldId = 1; | ||
this._nextFieldId = 0; | ||
this.fieldHandlers = {}; | ||
@@ -137,2 +137,3 @@ | ||
this.client = client; | ||
HostedFields.create({ | ||
@@ -177,5 +178,7 @@ client: client, | ||
prefill = _ref2.prefill, | ||
handlers = objectWithoutProperties(_ref2, ['formatInput', 'maxlength', 'minlength', 'placeholder', 'select', 'type', 'prefill']); | ||
_ref2$id = _ref2.id, | ||
id = _ref2$id === undefined ? 'braintree-field-wrapper-' + this.nextFieldId() : _ref2$id, | ||
rejectUnsupportedCards = _ref2.rejectUnsupportedCards, | ||
handlers = objectWithoutProperties(_ref2, ['formatInput', 'maxlength', 'minlength', 'placeholder', 'select', 'type', 'prefill', 'id', 'rejectUnsupportedCards']); | ||
var id = 'field-wrapper-' + this.nextFieldId(); | ||
this.fieldHandlers[type] = handlers; | ||
@@ -191,2 +194,5 @@ this.fields[type] = { | ||
}; | ||
if ('number' === type && rejectUnsupportedCards) { | ||
this.fields.number.rejectUnsupportedCards = true; | ||
} | ||
return id; | ||
@@ -372,2 +378,3 @@ } | ||
type: PropTypes.oneOf(['number', 'expirationDate', 'expirationMonth', 'expirationYear', 'cvv', 'postalCode']).isRequired, | ||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
placeholder: PropTypes.string, | ||
@@ -374,0 +381,0 @@ className: PropTypes.string, |
{ | ||
"name": "react-braintree-fields", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "React component for braintree hosted fields", | ||
@@ -57,4 +57,4 @@ "browser": "dist/build.full.js", | ||
"rollup-plugin-babel": "^3.0.4", | ||
"webpack": "^4.8.2", | ||
"webpack-cli": "^2.1.3", | ||
"webpack": "^4.30.0", | ||
"webpack-cli": "^3.3.2", | ||
"webpack-dev-server": "^3.1.4" | ||
@@ -66,2 +66,4 @@ }, | ||
"jest": { | ||
"testEnvironment": "jsdom", | ||
"testURL": "http://localhost/", | ||
"setupFiles": [ | ||
@@ -68,0 +70,0 @@ "raf/polyfill" |
@@ -13,3 +13,3 @@ import Braintree from 'braintree-web/client'; | ||
_nextFieldId = 1; | ||
_nextFieldId = 0; | ||
@@ -60,2 +60,3 @@ fieldHandlers = {}; | ||
create(client, onAuthorizationSuccess) { | ||
this.client = client; | ||
HostedFields.create({ | ||
@@ -90,5 +91,13 @@ client, | ||
checkInField({ | ||
formatInput, maxlength, minlength, placeholder, select, type, prefill, ...handlers | ||
formatInput, | ||
maxlength, | ||
minlength, | ||
placeholder, | ||
select, | ||
type, | ||
prefill, | ||
id = `braintree-field-wrapper-${this.nextFieldId()}`, | ||
rejectUnsupportedCards, | ||
...handlers | ||
}) { | ||
const id = `field-wrapper-${this.nextFieldId()}`; | ||
this.fieldHandlers[type] = handlers; | ||
@@ -104,2 +113,5 @@ this.fields[type] = { | ||
}; | ||
if (('number' === type) && rejectUnsupportedCards) { | ||
this.fields.number.rejectUnsupportedCards = true; | ||
} | ||
return id; | ||
@@ -106,0 +118,0 @@ } |
@@ -11,2 +11,3 @@ import React from 'react'; | ||
]).isRequired, | ||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
placeholder: PropTypes.string, | ||
@@ -34,5 +35,5 @@ className: PropTypes.string, | ||
} | ||
setPlaceholder(text) { | ||
this.context.braintreeApi.setAttribute(this.props.type, 'placeholder', text); | ||
this.context.braintreeApi.setAttribute(this.props.type, 'placeholder', text); | ||
} | ||
@@ -39,0 +40,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2980737
32526