react-plaid-link
Advanced tools
Comparing version
@@ -89,3 +89,3 @@ import react, { useState, useEffect } from 'react'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -98,6 +98,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 = []; | ||
@@ -128,4 +125,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(n); | ||
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."); | ||
} | ||
@@ -143,47 +157,2 @@ | ||
var useIsMounted_1 = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function useIsMounted() { | ||
var ref = react.useRef(false); | ||
react.useEffect(function () { | ||
ref.current = true; | ||
return function () { | ||
ref.current = false; | ||
}; | ||
}, []); | ||
return function () { | ||
return ref.current; | ||
}; | ||
} | ||
exports.default = useIsMounted; | ||
}); | ||
unwrapExports(useIsMounted_1); | ||
var lib = createCommonjsModule(function (module, exports) { | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var use_is_mounted_1 = __importDefault(useIsMounted_1); | ||
exports.default = use_is_mounted_1.default; | ||
}); | ||
unwrapExports(lib); | ||
var useScript_1 = createCommonjsModule(function (module, exports) { | ||
@@ -202,8 +171,2 @@ | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -215,4 +178,2 @@ value: true | ||
var react_is_mounted_hook_1 = __importDefault(lib); | ||
function useScript(_a) { | ||
@@ -222,4 +183,2 @@ var src = _a.src, | ||
var isMounted = react_is_mounted_hook_1.default(); | ||
var _b = react.useState(true), | ||
@@ -235,11 +194,2 @@ loading = _b[0], | ||
if (!isBrowser) return; | ||
if (document.querySelector("script[src=\"" + src + "\"]")) { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
return; | ||
} | ||
var scriptEl = document.createElement('script'); | ||
@@ -256,11 +206,7 @@ scriptEl.setAttribute('src', src); | ||
var handleLoad = function () { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
setLoading(false); | ||
}; | ||
var handleError = function (error) { | ||
if (isMounted()) { | ||
setError(error); | ||
} | ||
setError(error); | ||
}; | ||
@@ -274,4 +220,5 @@ | ||
scriptEl.removeEventListener('error', handleError); | ||
}; | ||
}, [src, attributes, isMounted]); | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
return [loading, error]; | ||
@@ -286,3 +233,3 @@ } | ||
var lib$1 = createCommonjsModule(function (module, exports) { | ||
var lib = createCommonjsModule(function (module, exports) { | ||
@@ -298,3 +245,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var useScript = unwrapExports(lib$1); | ||
var useScript = unwrapExports(lib); | ||
@@ -301,0 +248,0 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { |
@@ -96,3 +96,3 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -105,6 +105,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 = []; | ||
@@ -135,4 +132,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(n); | ||
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."); | ||
} | ||
@@ -150,47 +164,2 @@ | ||
var useIsMounted_1 = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function useIsMounted() { | ||
var ref = react__default.useRef(false); | ||
react__default.useEffect(function () { | ||
ref.current = true; | ||
return function () { | ||
ref.current = false; | ||
}; | ||
}, []); | ||
return function () { | ||
return ref.current; | ||
}; | ||
} | ||
exports.default = useIsMounted; | ||
}); | ||
unwrapExports(useIsMounted_1); | ||
var lib = createCommonjsModule(function (module, exports) { | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var use_is_mounted_1 = __importDefault(useIsMounted_1); | ||
exports.default = use_is_mounted_1.default; | ||
}); | ||
unwrapExports(lib); | ||
var useScript_1 = createCommonjsModule(function (module, exports) { | ||
@@ -209,8 +178,2 @@ | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -222,4 +185,2 @@ value: true | ||
var react_is_mounted_hook_1 = __importDefault(lib); | ||
function useScript(_a) { | ||
@@ -229,4 +190,2 @@ var src = _a.src, | ||
var isMounted = react_is_mounted_hook_1.default(); | ||
var _b = react__default.useState(true), | ||
@@ -242,11 +201,2 @@ loading = _b[0], | ||
if (!isBrowser) return; | ||
if (document.querySelector("script[src=\"" + src + "\"]")) { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
return; | ||
} | ||
var scriptEl = document.createElement('script'); | ||
@@ -263,11 +213,7 @@ scriptEl.setAttribute('src', src); | ||
var handleLoad = function () { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
setLoading(false); | ||
}; | ||
var handleError = function (error) { | ||
if (isMounted()) { | ||
setError(error); | ||
} | ||
setError(error); | ||
}; | ||
@@ -281,4 +227,5 @@ | ||
scriptEl.removeEventListener('error', handleError); | ||
}; | ||
}, [src, attributes, isMounted]); | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
return [loading, error]; | ||
@@ -293,3 +240,3 @@ } | ||
var lib$1 = createCommonjsModule(function (module, exports) { | ||
var lib = createCommonjsModule(function (module, exports) { | ||
@@ -305,3 +252,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var useScript = unwrapExports(lib$1); | ||
var useScript = unwrapExports(lib); | ||
@@ -308,0 +255,0 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { |
@@ -95,3 +95,3 @@ (function (global, factory) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -104,6 +104,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 = []; | ||
@@ -134,4 +131,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(n); | ||
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."); | ||
} | ||
@@ -149,47 +163,2 @@ | ||
var useIsMounted_1 = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function useIsMounted() { | ||
var ref = react__default.useRef(false); | ||
react__default.useEffect(function () { | ||
ref.current = true; | ||
return function () { | ||
ref.current = false; | ||
}; | ||
}, []); | ||
return function () { | ||
return ref.current; | ||
}; | ||
} | ||
exports.default = useIsMounted; | ||
}); | ||
unwrapExports(useIsMounted_1); | ||
var lib = createCommonjsModule(function (module, exports) { | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var use_is_mounted_1 = __importDefault(useIsMounted_1); | ||
exports.default = use_is_mounted_1.default; | ||
}); | ||
unwrapExports(lib); | ||
var useScript_1 = createCommonjsModule(function (module, exports) { | ||
@@ -208,8 +177,2 @@ | ||
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -221,4 +184,2 @@ value: true | ||
var react_is_mounted_hook_1 = __importDefault(lib); | ||
function useScript(_a) { | ||
@@ -228,4 +189,2 @@ var src = _a.src, | ||
var isMounted = react_is_mounted_hook_1.default(); | ||
var _b = react__default.useState(true), | ||
@@ -241,11 +200,2 @@ loading = _b[0], | ||
if (!isBrowser) return; | ||
if (document.querySelector("script[src=\"" + src + "\"]")) { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
return; | ||
} | ||
var scriptEl = document.createElement('script'); | ||
@@ -262,11 +212,7 @@ scriptEl.setAttribute('src', src); | ||
var handleLoad = function () { | ||
if (isMounted()) { | ||
setLoading(false); | ||
} | ||
setLoading(false); | ||
}; | ||
var handleError = function (error) { | ||
if (isMounted()) { | ||
setError(error); | ||
} | ||
setError(error); | ||
}; | ||
@@ -280,4 +226,5 @@ | ||
scriptEl.removeEventListener('error', handleError); | ||
}; | ||
}, [src, attributes, isMounted]); | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
return [loading, error]; | ||
@@ -292,3 +239,3 @@ } | ||
var lib$1 = createCommonjsModule(function (module, exports) { | ||
var lib = createCommonjsModule(function (module, exports) { | ||
@@ -304,3 +251,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var useScript = unwrapExports(lib$1); | ||
var useScript = unwrapExports(lib); | ||
@@ -307,0 +254,0 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { |
@@ -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).PlaidLink={},e.React)}(this,(function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function l(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,i=void 0;try{for(var u,l=e[Symbol.iterator]();!(r=(u=l.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function f(e,t){return e(t={exports:{}},t.exports),t.exports}var d=f((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=n.useRef(!1);return n.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),function(){return e.current}}}));c(d);var p=f((function(e,t){var n=a&&a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(d);t.default=r.default}));c(p);var s=f((function(e,t){var r=a&&a.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},o=a&&a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=o(p);t.default=function(e){var t=e.src,o=r(e,["src"]),l=i.default(),a=n.useState(!0),c=a[0],f=a[1],d=n.useState(null),p=d[0],s=d[1];return n.useEffect((function(){if(u){if(!document.querySelector('script[src="'+t+'"]')){var e=document.createElement("script");e.setAttribute("src",t),Object.keys(o).forEach((function(t){void 0===e[t]?e.setAttribute(t,o[t]):e[t]=o[t]}));var n=function(){l()&&f(!1)},r=function(e){l()&&s(e)};return e.addEventListener("load",n),e.addEventListener("error",r),document.body.appendChild(e),function(){e.removeEventListener("load",n),e.removeEventListener("error",r)}}l()&&f(!1)}}),[t,o,l]),[c,p]};var u="undefined"!=typeof window&&void 0!==window.document}));c(s);var y=c(f((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s.default}))),b=function(e){var t={plaid:null,open:!1,onExitCallback:null};if("undefined"==typeof window||!window.Plaid)throw new Error("Plaid not loaded");var n,o,u,l,a=(n=e,o="publicKey",u="key",l={},delete Object.assign(l,n,r({},u,n[o]))[o],l);t.plaid=window.Plaid.create(i({},a,{onExit:function(){a.onExit&&a.onExit.apply(a,arguments),t.onExitCallback&&t.onExitCallback()}}));return{open:function(){t.plaid&&(t.open=!0,t.onExitCallback=null,t.plaid.open())},exit:function(e,n){t.open&&t.plaid?(t.onExitCallback=n,t.plaid.exit(e),e&&e.force&&(t.open=!1)):n&&n()},destroy:function(){t.plaid&&(t.plaid.destroy(),t.plaid=null)}}},v=function(){},O=function(e){var n=l(y({src:"https://cdn.plaid.com/link/v2/stable/link-initialize.js"}),2),r=n[0],o=n[1],u=l(t.useState(null),2),a=u[0],c=u[1],f=l(t.useState(!1),2),d=f[0],p=f[1];return t.useEffect((function(){if(!r){if(!o&&window.Plaid){null!=a&&a.exit({force:!0},(function(){return a.destroy()}));var t=b(i({},e,{onLoad:function(){p(!0),e.onLoad&&e.onLoad()}}));return c(t),function(){return t.exit({force:!0},(function(){return t.destroy()}))}}console.error("Error loading Plaid",o)}}),[r,o,e.token]),{error:o,ready:!r||d,exit:a?a.exit:v,open:a?a.open:v}},w=function(e){var t=e.children,r=e.style,o=e.className,l=u(e,["children","style","className"]),a=O(i({},l)),c=a.error,f=a.open;return n.createElement("button",{disabled:Boolean(c),type:"button",className:o,style:i({padding:"6px 4px",outline:"none",background:"#FFFFFF",border:"2px solid #F1F1F1",borderRadius:"4px"},r),onClick:function(){return f()}},t)};w.displayName="PlaidLink",e.PlaidLink=w,e.usePlaidLink=O,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).PlaidLink={},e.React)}(this,(function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function a(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,i=void 0;try{for(var l,a=e[Symbol.iterator]();!(r=(l=a.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}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(n);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}var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function d(e,t){return e(t={exports:{}},t.exports),t.exports}var p=d((function(e,t){var r=c&&c.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.src,i=r(e,["src"]),l=n.useState(!0),a=l[0],u=l[1],c=n.useState(null),f=c[0],d=c[1];return n.useEffect((function(){if(o){var e=document.createElement("script");e.setAttribute("src",t),Object.keys(i).forEach((function(t){void 0===e[t]?e.setAttribute(t,i[t]):e[t]=i[t]}));var n=function(){u(!1)},r=function(e){d(e)};return e.addEventListener("load",n),e.addEventListener("error",r),document.body.appendChild(e),function(){e.removeEventListener("load",n),e.removeEventListener("error",r)}}}),[t]),[a,f]};var o="undefined"!=typeof window&&void 0!==window.document}));f(p);var s=f(d((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p.default}))),y=function(e){var t={plaid:null,open:!1,onExitCallback:null};if("undefined"==typeof window||!window.Plaid)throw new Error("Plaid not loaded");var n,o,l,a,u=(n=e,o="publicKey",l="key",a={},delete Object.assign(a,n,r({},l,n[o]))[o],a);t.plaid=window.Plaid.create(i({},u,{onExit:function(){u.onExit&&u.onExit.apply(u,arguments),t.onExitCallback&&t.onExitCallback()}}));return{open:function(){t.plaid&&(t.open=!0,t.onExitCallback=null,t.plaid.open())},exit:function(e,n){t.open&&t.plaid?(t.onExitCallback=n,t.plaid.exit(e),e&&e.force&&(t.open=!1)):n&&n()},destroy:function(){t.plaid&&(t.plaid.destroy(),t.plaid=null)}}},b=function(){},v=function(e){var n=a(s({src:"https://cdn.plaid.com/link/v2/stable/link-initialize.js"}),2),r=n[0],o=n[1],l=a(t.useState(null),2),u=l[0],c=l[1],f=a(t.useState(!1),2),d=f[0],p=f[1];return t.useEffect((function(){if(!r){if(!o&&window.Plaid){null!=u&&u.exit({force:!0},(function(){return u.destroy()}));var t=y(i({},e,{onLoad:function(){p(!0),e.onLoad&&e.onLoad()}}));return c(t),function(){return t.exit({force:!0},(function(){return t.destroy()}))}}console.error("Error loading Plaid",o)}}),[r,o,e.token]),{error:o,ready:!r||d,exit:u?u.exit:b,open:u?u.open:b}},O=function(e){var t=e.children,r=e.style,o=e.className,a=l(e,["children","style","className"]),u=v(i({},a)),c=u.error,f=u.open;return n.createElement("button",{disabled:Boolean(c),type:"button",className:o,style:i({padding:"6px 4px",outline:"none",background:"#FFFFFF",border:"2px solid #F1F1F1",borderRadius:"4px"},r),onClick:function(){return f()}},t)};O.displayName="PlaidLink",e.PlaidLink=O,e.usePlaidLink=v,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "react-plaid-link", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A React component for Plaid Link", | ||
@@ -46,3 +46,3 @@ "files": [ | ||
"prop-types": "^15.7.2", | ||
"react-script-hook": "^1.0.15" | ||
"react-script-hook": "1.0.17" | ||
}, | ||
@@ -49,0 +49,0 @@ "peerDependencies": { |
69200
-2.49%1619
-6.47%+ Added
- Removed
Updated