@stripe/react-stripe-js
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -290,5 +290,3 @@ import { FunctionComponent, ReactNode } from "react"; | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; /** | ||
* @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; | ||
/** | ||
@@ -300,5 +298,3 @@ * @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
children: (props: ElementsContextValue) => ReactNode; | ||
} /** | ||
* @docs https://stripe.com/docs/stripe-js/react#elements-consumer | ||
*/ | ||
} | ||
/** | ||
@@ -305,0 +301,0 @@ * @docs https://stripe.com/docs/stripe-js/react#elements-consumer |
@@ -290,5 +290,3 @@ import { FunctionComponent, ReactNode } from "react"; | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; /** | ||
* @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; | ||
/** | ||
@@ -300,5 +298,3 @@ * @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
children: (props: ElementsContextValue) => ReactNode; | ||
} /** | ||
* @docs https://stripe.com/docs/stripe-js/react#elements-consumer | ||
*/ | ||
} | ||
/** | ||
@@ -305,0 +301,0 @@ * @docs https://stripe.com/docs/stripe-js/react#elements-consumer |
@@ -57,3 +57,3 @@ import React from 'react'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -66,6 +66,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -96,4 +93,21 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -198,3 +212,3 @@ | ||
var ElementsContext = React.createContext(null); | ||
var ElementsContext = /*#__PURE__*/React.createContext(null); | ||
ElementsContext.displayName = 'ElementsContext'; | ||
@@ -293,6 +307,6 @@ var parseElementsContext = function parseElementsContext(ctx, useCase) { | ||
name: 'react-stripe-js', | ||
version: "1.1.2" | ||
version: "1.2.0" | ||
}); | ||
}, [ctx.stripe]); | ||
return React.createElement(ElementsContext.Provider, { | ||
return /*#__PURE__*/React.createElement(ElementsContext.Provider, { | ||
value: ctx | ||
@@ -438,9 +452,10 @@ }, children); | ||
React.useEffect(function () { | ||
var element = elementRef.current; | ||
return function () { | ||
if (elementRef.current) { | ||
elementRef.current.destroy(); | ||
if (element) { | ||
element.destroy(); | ||
} | ||
}; | ||
}, []); | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -458,3 +473,3 @@ className: className, | ||
className = props.className; | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -461,0 +476,0 @@ className: className |
@@ -63,3 +63,3 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -72,6 +72,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -102,4 +99,21 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -204,3 +218,3 @@ | ||
var ElementsContext = React.createContext(null); | ||
var ElementsContext = /*#__PURE__*/React.createContext(null); | ||
ElementsContext.displayName = 'ElementsContext'; | ||
@@ -299,6 +313,6 @@ var parseElementsContext = function parseElementsContext(ctx, useCase) { | ||
name: 'react-stripe-js', | ||
version: "1.1.2" | ||
version: "1.2.0" | ||
}); | ||
}, [ctx.stripe]); | ||
return React.createElement(ElementsContext.Provider, { | ||
return /*#__PURE__*/React.createElement(ElementsContext.Provider, { | ||
value: ctx | ||
@@ -444,9 +458,10 @@ }, children); | ||
React.useEffect(function () { | ||
var element = elementRef.current; | ||
return function () { | ||
if (elementRef.current) { | ||
elementRef.current.destroy(); | ||
if (element) { | ||
element.destroy(); | ||
} | ||
}; | ||
}, []); | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -464,3 +479,3 @@ className: className, | ||
className = props.className; | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -467,0 +482,0 @@ className: className |
@@ -290,5 +290,3 @@ import { FunctionComponent, ReactNode } from "react"; | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; /** | ||
* @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; | ||
/** | ||
@@ -300,5 +298,3 @@ * @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
children: (props: ElementsContextValue) => ReactNode; | ||
} /** | ||
* @docs https://stripe.com/docs/stripe-js/react#elements-consumer | ||
*/ | ||
} | ||
/** | ||
@@ -305,0 +301,0 @@ * @docs https://stripe.com/docs/stripe-js/react#elements-consumer |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
React = React && React.hasOwnProperty('default') ? React['default'] : React; | ||
React = React && Object.prototype.hasOwnProperty.call(React, 'default') ? React['default'] : React; | ||
@@ -63,3 +63,3 @@ function _typeof(obj) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -72,6 +72,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -102,4 +99,21 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -282,3 +296,3 @@ | ||
var ElementsContext = React.createContext(null); | ||
var ElementsContext = /*#__PURE__*/React.createContext(null); | ||
ElementsContext.displayName = 'ElementsContext'; | ||
@@ -377,6 +391,6 @@ var parseElementsContext = function parseElementsContext(ctx, useCase) { | ||
name: 'react-stripe-js', | ||
version: "1.1.2" | ||
version: "1.2.0" | ||
}); | ||
}, [ctx.stripe]); | ||
return React.createElement(ElementsContext.Provider, { | ||
return /*#__PURE__*/React.createElement(ElementsContext.Provider, { | ||
value: ctx | ||
@@ -522,9 +536,10 @@ }, children); | ||
React.useEffect(function () { | ||
var element = elementRef.current; | ||
return function () { | ||
if (elementRef.current) { | ||
elementRef.current.destroy(); | ||
if (element) { | ||
element.destroy(); | ||
} | ||
}; | ||
}, []); | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -542,3 +557,3 @@ className: className, | ||
className = props.className; | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
id: id, | ||
@@ -545,0 +560,0 @@ className: className |
@@ -290,5 +290,3 @@ import { FunctionComponent, ReactNode } from "react"; | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; /** | ||
* @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
*/ | ||
declare const useElements: () => stripeJs.StripeElements | null; | ||
/** | ||
@@ -300,5 +298,3 @@ * @docs https://stripe.com/docs/stripe-js/react#usestripe-hook | ||
children: (props: ElementsContextValue) => ReactNode; | ||
} /** | ||
* @docs https://stripe.com/docs/stripe-js/react#elements-consumer | ||
*/ | ||
} | ||
/** | ||
@@ -305,0 +301,0 @@ * @docs https://stripe.com/docs/stripe-js/react#elements-consumer |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],r=!0,o=!1,u=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){o=!0,u=e}finally{try{r||null==i.return||i.return()}finally{if(o)throw u}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}t=t&&t.hasOwnProperty("default")?t.default:t;function u(){}function c(){}c.resetWarningCache=u;var i=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(){function e(e,t,n,r,o,u){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==u){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:c,resetWarningCache:u};return n.PropTypes=n,n}()})),a=function(e){return null!==e&&"object"===n(e)},s=function e(t,n){if(!a(t)||!a(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o="[object Object]"===Object.prototype.toString.call(t);if(o!==("[object Object]"===Object.prototype.toString.call(n)))return!1;if(!o&&!r)return!1;var u=Object.keys(t),c=Object.keys(n);if(u.length!==c.length)return!1;for(var i={},s=0;s<u.length;s+=1)i[u[s]]=!0;for(var p=0;p<c.length;p+=1)i[c[p]]=!0;var f=Object.keys(i);if(f.length!==u.length)return!1;var l=t,y=n;return f.every((function(t){return e(l[t],y[t])}))},p=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},f=function(e){if(null===e||a(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;var t;throw new Error("Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},l=function(e){if(function(e){return a(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(f)};var t=f(e);return null===t?{tag:"empty"}:{tag:"sync",stripe:t}},y=t.createContext(null);y.displayName="ElementsContext";var m=function(e){var n=e.stripe,r=e.options,u=e.children,c=t.useRef(!1),i=t.useRef(!0),a=t.useMemo((function(){return l(n)}),[n]),f=o(t.useState((function(){return{stripe:null,elements:null}})),2),m=f[0],d=f[1],v=p(n),h=p(r);return null!==v&&(v!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it."),s(r,h)||console.warn("Unsupported prop change on Elements: You cannot change the `options` prop after setting the `stripe` prop.")),c.current||("sync"===a.tag&&(c.current=!0,d({stripe:a.stripe,elements:a.stripe.elements(r)})),"async"===a.tag&&(c.current=!0,a.stripePromise.then((function(e){e&&i.current&&d({stripe:e,elements:e.elements(r)})})))),t.useEffect((function(){return function(){i.current=!1}}),[]),t.useEffect((function(){var e=m.stripe;e&&e._registerWrapper&&e._registerWrapper({name:"react-stripe-js",version:"1.1.2"})}),[m.stripe]),t.createElement(y.Provider,{value:m},u)};m.propTypes={stripe:i.any,options:i.object};var d=function(e){return function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(t.useContext(y),e)},v=function(e){return(0,e.children)(d("mounts <ElementsConsumer>"))};v.propTypes={children:i.func.isRequired};var h=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),function(){n.current&&n.current.apply(n,arguments)}},b=function(e){if(!a(e))return{};e.paymentRequest;return r(e,["paymentRequest"])},E=function(){},g=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){d("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r=n.id,u=n.className,c=n.options,i=void 0===c?{}:c,a=n.onBlur,p=void 0===a?E:a,f=n.onFocus,l=void 0===f?E:f,y=n.onReady,m=void 0===y?E:y,v=n.onChange,g=void 0===v?E:v,O=n.onEscape,j=void 0===O?E:O,R=n.onClick,C=void 0===R?E:R,S=d("mounts <".concat(o,">")).elements,k=t.useRef(null),x=t.useRef(null),w=h(m),P=h(p),T=h(l),_=h(C),A=h(g),B=h(j);t.useLayoutEffect((function(){if(null==k.current&&S&&null!=x.current){var t=S.create(e,i);k.current=t,t.mount(x.current),t.on("ready",(function(){return w(t)})),t.on("change",A),t.on("blur",P),t.on("focus",T),t.on("escape",B),t.on("click",_)}}));var q=t.useRef(i);return t.useEffect((function(){q.current&&q.current.paymentRequest!==i.paymentRequest&&console.warn("Unsupported prop change: options.paymentRequest is not a customizable property.");var e=b(i);0===Object.keys(e).length||s(e,b(q.current))||k.current&&(k.current.update(e),q.current=i)}),[i]),t.useEffect((function(){return function(){k.current&&k.current.destroy()}}),[]),t.createElement("div",{id:r,className:u,ref:x})};return u.propTypes={id:i.string,className:i.string,onChange:i.func,onBlur:i.func,onFocus:i.func,onReady:i.func,onClick:i.func,options:i.object},u.displayName=o,u.__elementType=e,u},O="undefined"==typeof window,j=g("auBankAccount",O),R=g("card",O),C=g("cardNumber",O),S=g("cardExpiry",O),k=g("cardCvc",O),x=g("fpxBank",O),w=g("iban",O),P=g("idealBank",O),T=g("paymentRequestButton",O);e.AuBankAccountElement=j,e.CardCvcElement=k,e.CardElement=R,e.CardExpiryElement=S,e.CardNumberElement=C,e.Elements=m,e.ElementsConsumer=v,e.FpxBankElement=x,e.IbanElement=w,e.IdealBankElement=P,e.PaymentRequestButtonElement=T,e.useElements=function(){return d("calls useElements()").elements},e.useStripe=function(){return d("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,u=void 0;try{for(var c,i=e[Symbol.iterator]();!(r=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){o=!0,u=e}finally{try{r||null==i.return||i.return()}finally{if(o)throw u}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;function c(){}function i(){}i.resetWarningCache=c;var a=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(){function e(e,t,n,r,o,u){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==u){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:c};return n.PropTypes=n,n}()})),s=function(e){return null!==e&&"object"===n(e)},p=function e(t,n){if(!s(t)||!s(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o="[object Object]"===Object.prototype.toString.call(t);if(o!==("[object Object]"===Object.prototype.toString.call(n)))return!1;if(!o&&!r)return!1;var u=Object.keys(t),c=Object.keys(n);if(u.length!==c.length)return!1;for(var i={},a=0;a<u.length;a+=1)i[u[a]]=!0;for(var p=0;p<c.length;p+=1)i[c[p]]=!0;var f=Object.keys(i);if(f.length!==u.length)return!1;var l=t,y=n;return f.every((function(t){return e(l[t],y[t])}))},f=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},l=function(e){if(null===e||s(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;var t;throw new Error("Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},y=function(e){if(function(e){return s(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(l)};var t=l(e);return null===t?{tag:"empty"}:{tag:"sync",stripe:t}},m=t.createContext(null);m.displayName="ElementsContext";var d=function(e){var n=e.stripe,r=e.options,u=e.children,c=t.useRef(!1),i=t.useRef(!0),a=t.useMemo((function(){return y(n)}),[n]),s=o(t.useState((function(){return{stripe:null,elements:null}})),2),l=s[0],d=s[1],v=f(n),h=f(r);return null!==v&&(v!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it."),p(r,h)||console.warn("Unsupported prop change on Elements: You cannot change the `options` prop after setting the `stripe` prop.")),c.current||("sync"===a.tag&&(c.current=!0,d({stripe:a.stripe,elements:a.stripe.elements(r)})),"async"===a.tag&&(c.current=!0,a.stripePromise.then((function(e){e&&i.current&&d({stripe:e,elements:e.elements(r)})})))),t.useEffect((function(){return function(){i.current=!1}}),[]),t.useEffect((function(){var e=l.stripe;e&&e._registerWrapper&&e._registerWrapper({name:"react-stripe-js",version:"1.2.0"})}),[l.stripe]),t.createElement(m.Provider,{value:l},u)};d.propTypes={stripe:a.any,options:a.object};var v=function(e){return function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(t.useContext(m),e)},h=function(e){return(0,e.children)(v("mounts <ElementsConsumer>"))};h.propTypes={children:a.func.isRequired};var b=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),function(){n.current&&n.current.apply(n,arguments)}},g=function(e){if(!s(e))return{};e.paymentRequest;return r(e,["paymentRequest"])},E=function(){},O=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){v("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r=n.id,u=n.className,c=n.options,i=void 0===c?{}:c,a=n.onBlur,s=void 0===a?E:a,f=n.onFocus,l=void 0===f?E:f,y=n.onReady,m=void 0===y?E:y,d=n.onChange,h=void 0===d?E:d,O=n.onEscape,j=void 0===O?E:O,S=n.onClick,R=void 0===S?E:S,C=v("mounts <".concat(o,">")).elements,k=t.useRef(null),w=t.useRef(null),x=b(m),P=b(s),T=b(l),A=b(R),_=b(h),B=b(j);t.useLayoutEffect((function(){if(null==k.current&&C&&null!=w.current){var t=C.create(e,i);k.current=t,t.mount(w.current),t.on("ready",(function(){return x(t)})),t.on("change",_),t.on("blur",P),t.on("focus",T),t.on("escape",B),t.on("click",A)}}));var I=t.useRef(i);return t.useEffect((function(){I.current&&I.current.paymentRequest!==i.paymentRequest&&console.warn("Unsupported prop change: options.paymentRequest is not a customizable property.");var e=g(i);0===Object.keys(e).length||p(e,g(I.current))||k.current&&(k.current.update(e),I.current=i)}),[i]),t.useEffect((function(){var e=k.current;return function(){e&&e.destroy()}}),[]),t.createElement("div",{id:r,className:u,ref:w})};return u.propTypes={id:a.string,className:a.string,onChange:a.func,onBlur:a.func,onFocus:a.func,onReady:a.func,onClick:a.func,options:a.object},u.displayName=o,u.__elementType=e,u},j="undefined"==typeof window,S=O("auBankAccount",j),R=O("card",j),C=O("cardNumber",j),k=O("cardExpiry",j),w=O("cardCvc",j),x=O("fpxBank",j),P=O("iban",j),T=O("idealBank",j),A=O("paymentRequestButton",j);e.AuBankAccountElement=S,e.CardCvcElement=w,e.CardElement=R,e.CardExpiryElement=k,e.CardNumberElement=C,e.Elements=d,e.ElementsConsumer=h,e.FpxBankElement=x,e.IbanElement=P,e.IdealBankElement=T,e.PaymentRequestButtonElement=A,e.useElements=function(){return v("calls useElements()").elements},e.useStripe=function(){return v("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@stripe/react-stripe-js", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "React components for Stripe.js and Stripe Elements", | ||
@@ -12,3 +12,4 @@ "main": "dist/react-stripe.js", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "yarn run lint && yarn run lint:prettier && yarn run test:unit && yarn run typecheck", | ||
"test:unit": "jest", | ||
"lint": "eslint '{src,examples}/**/*.{ts,tsx,js}'", | ||
@@ -21,4 +22,3 @@ "lint:prettier": "prettier './**/*.js' './**/*.css' './**/*.md' --list-different", | ||
"prettier:fix": "prettier './**/*.js' './**/*.css' './**/*.md' --write", | ||
"ci": "yarn run lint && yarn run lint:prettier && yarn run test && yarn run typecheck && yarn run build", | ||
"prepublishOnly": "yarn run ci", | ||
"prepublishOnly": "echo \"\nPlease use ./scripts/publish instead\n\" && exit 1", | ||
"doctoc": "doctoc README.md", | ||
@@ -72,6 +72,8 @@ "storybook": "start-storybook -p 6006 " | ||
"@stripe/stripe-js": "^1.2.0", | ||
"@types/enzyme": "^3.10.4", | ||
"@testing-library/jest-dom": "^5.11.8", | ||
"@testing-library/react": "^11.2.3", | ||
"@testing-library/react-hooks": "^4.0.0", | ||
"@types/jest": "^25.1.1", | ||
"@types/react": "^16.9.19", | ||
"@types/react-dom": "^16.9.5", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.18.0", | ||
@@ -83,4 +85,2 @@ "@typescript-eslint/parser": "^2.18.0", | ||
"babel-loader": "^8.0.6", | ||
"enzyme": "3.10", | ||
"enzyme-adapter-react-16": "^1.14.0", | ||
"eslint": "6.6.0", | ||
@@ -98,5 +98,6 @@ "eslint-config-airbnb": "18.0.1", | ||
"prettier": "^1.19.1", | ||
"react": "~16.9.0", | ||
"react": "^17.0.1", | ||
"react-docgen-typescript-loader": "^3.6.0", | ||
"react-dom": "~16.9.0", | ||
"react-dom": "^17.0.1", | ||
"react-test-renderer": "16.9", | ||
"rimraf": "^2.6.2", | ||
@@ -115,5 +116,5 @@ "rollup": "^1.27.0", | ||
"@stripe/stripe-js": "^1.2.0", | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0" | ||
"react": "^16.8.0 || ^17.0.0", | ||
"react-dom": "^16.8.0 || ^17.0.0" | ||
} | ||
} |
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
201810
48
4308