From 3f74dd98a4dcda13ef06f4773aff9cf00cef2289 Mon Sep 17 00:00:00 2001 From: Charles Crete Date: Mon, 7 Oct 2019 21:54:20 -0400 Subject: [PATCH] v1.1.0: Add TypeScript typings --- CHANGELOG.md | 5 +++++ index.d.ts | 12 ++++++++++++ package.json | 9 ++++++--- src/index.js | 1 + yarn.lock | 23 +++++++++++++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 index.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 78314d5..775ae7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v1.1.0 (2019-10-07) + +- Add TypeScript typings (thanks @paulinfrancis!) +- Fix `preselectVaultedPaymentMethod` not being used + ## v1.0.11 (2019-10-07) - Upgrade dependencies diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..40c47c3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,12 @@ +import * as React from 'react'; +import { Options as BraintreeOptions, Dropin } from 'braintree-web-drop-in'; + +export type Options = Omit; + +export interface IDropInProps { + options: Options; + preselectVaultedPaymentMethod?: boolean, + onInstance?: (instance: Dropin) => void; +} + +export default class DropIn extends React.Component { } diff --git a/package.json b/package.json index 2b2dc87..3aeb082 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "braintree-web-drop-in-react", - "version": "1.0.11", + "version": "1.1.0", "description": "React component for Braintree Web Drop-In (v3)", "keywords": [ "braintree", @@ -18,12 +18,13 @@ "lib/*" ], "main": "lib/index.js", + "types": "index.d.ts", "scripts": { "build": "babel src -d lib --source-maps && terser lib/index.js -o lib/index.min.js --source-map 'content=lib/index.js.map'", "clean": "rimraf lib", + "example": "cd example && npm install && npm run start", "format": "prettier --write 'src/**.js' package.json CHANGELOG.md README.md .travis.yml example/index.html example/index.js example/README.md example/package.json", - "test": "jest", - "example": "cd example && npm install && npm run start" + "test": "jest" }, "dependencies": { "braintree-web-drop-in": "^1.20.2", @@ -37,6 +38,8 @@ "@babel/preset-env": "^7.6.2", "@babel/preset-react": "^7.0.0", "@babel/runtime": "^7.6.2", + "@types/braintree-web-drop-in": "^1.18.0", + "@types/react": "^16.9.5", "babel-jest": "^24.9.0", "jest": "^24.9.0", "prettier": "^1.18.2", diff --git a/src/index.js b/src/index.js index 6e93330..ee25653 100644 --- a/src/index.js +++ b/src/index.js @@ -25,6 +25,7 @@ export default class DropIn extends React.Component { async componentDidMount() { this.instance = await BraintreeWebDropIn.create({ container: ReactDOM.findDOMNode(this.wrapper), + preselectVaultedPaymentMethod: this.props.preselectVaultedPaymentMethod, ...this.props.options }); diff --git a/yarn.lock b/yarn.lock index 5363e18..5657141 100644 --- a/yarn.lock +++ b/yarn.lock @@ -975,6 +975,11 @@ dependencies: "@babel/types" "^7.3.0" +"@types/braintree-web-drop-in@^1.18.0": + version "1.18.0" + resolved "https://registry.yarnpkg.com/@types/braintree-web-drop-in/-/braintree-web-drop-in-1.18.0.tgz#bcf08748775708963e8faa05120c25445b6b0fab" + integrity sha512-DefnVXmGHd+z9racz7eKrtKH3I3HKqf0X45Pc1DUCH/dHTN3p5cpQ6E6g7l5RR6TuyZMh1fwjWtGa87kvjvR7A== + "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" @@ -995,6 +1000,19 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" +"@types/prop-types@*": + version "15.7.3" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" + integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== + +"@types/react@^16.9.5": + version "16.9.5" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.5.tgz#079dabd918b19b32118c25fd00a786bb6d0d5e51" + integrity sha512-jQ12VMiFOWYlp+j66dghOWcmDDwhca0bnlcTxS4Qz/fh5gi6wpaZDthPEu/Gc/YlAuO87vbiUXL8qKstFvuOaA== + dependencies: + "@types/prop-types" "*" + csstype "^2.2.0" + "@types/stack-utils@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" @@ -1560,6 +1578,11 @@ cssstyle@^1.0.0: dependencies: cssom "0.3.x" +csstype@^2.2.0: + version "2.6.7" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.7.tgz#20b0024c20b6718f4eda3853a1f5a1cce7f5e4a5" + integrity sha512-9Mcn9sFbGBAdmimWb2gLVDtFJzeKtDGIr76TUqmjZrw9LFXBMSU70lcs+C0/7fyCd6iBDqmksUcCOUIkisPHsQ== + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"