@paypal/react-paypal-js
Advanced tools
Comparing version 5.1.0 to 5.1.1-beta.1
@@ -5,2 +5,4 @@ # Changelog | ||
### [5.1.1](https://github.com/paypal/react-paypal-js/compare/v5.1.0...v5.1.1) (2021-03-30) | ||
## [5.1.0](https://github.com/paypal/react-paypal-js/compare/v5.0.1...v5.1.0) (2021-03-22) | ||
@@ -7,0 +9,0 @@ |
@@ -27,3 +27,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
/*! | ||
* paypal-js v3.1.4 (2021-03-22T00:09:09.837Z) | ||
* paypal-js v3.1.5 (2021-03-29T22:14:31.678Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -280,5 +280,9 @@ * | ||
case "resetOptions": | ||
// destroy existing script to make sure only one script loads at a time | ||
destroySDKScript(state.options["data-react-paypal-script-id"]); | ||
return { | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING, | ||
options: action.value | ||
options: _objectSpread(_objectSpread({}, action.value), {}, { | ||
"data-react-paypal-script-id": "".concat(getNewScriptID()) | ||
}) | ||
}; | ||
@@ -293,2 +297,16 @@ | ||
function getNewScriptID() { | ||
return "react-paypal-js-".concat(Math.random().toString(36).substring(7)); | ||
} | ||
function destroySDKScript() { | ||
var reactPayPalScriptID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; | ||
var scriptNode = document.querySelector("script[data-react-paypal-script-id=\"".concat(reactPayPalScriptID, "\"]")); | ||
if (scriptNode === null) return; | ||
if (scriptNode.parentNode) { | ||
scriptNode.parentNode.removeChild(scriptNode); | ||
} | ||
} | ||
function usePayPalScriptReducer() { | ||
@@ -318,3 +336,5 @@ var scriptContext = useContext(ScriptContext); | ||
var initialState = { | ||
options: options, | ||
options: _objectSpread(_objectSpread({}, options), {}, { | ||
"data-react-paypal-script-id": "".concat(getNewScriptID()) | ||
}), | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING | ||
@@ -321,0 +341,0 @@ }; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
/*! | ||
* paypal-js v3.1.4 (2021-03-22T00:09:09.837Z) | ||
* paypal-js v3.1.5 (2021-03-29T22:14:31.678Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -262,5 +262,10 @@ * | ||
case "resetOptions": | ||
// destroy existing script to make sure only one script loads at a time | ||
destroySDKScript(state.options["data-react-paypal-script-id"]); | ||
return { | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING, | ||
options: action.value, | ||
options: { | ||
...action.value, | ||
"data-react-paypal-script-id": `${getNewScriptID()}`, | ||
}, | ||
}; | ||
@@ -272,2 +277,13 @@ default: { | ||
} | ||
function getNewScriptID() { | ||
return `react-paypal-js-${Math.random().toString(36).substring(7)}`; | ||
} | ||
function destroySDKScript(reactPayPalScriptID = "") { | ||
const scriptNode = document.querySelector(`script[data-react-paypal-script-id="${reactPayPalScriptID}"]`); | ||
if (scriptNode === null) | ||
return; | ||
if (scriptNode.parentNode) { | ||
scriptNode.parentNode.removeChild(scriptNode); | ||
} | ||
} | ||
function usePayPalScriptReducer() { | ||
@@ -290,3 +306,6 @@ const scriptContext = React.useContext(ScriptContext); | ||
const initialState = { | ||
options, | ||
options: { | ||
...options, | ||
"data-react-paypal-script-id": `${getNewScriptID()}`, | ||
}, | ||
loadingStatus: SCRIPT_LOADING_STATE.PENDING, | ||
@@ -293,0 +312,0 @@ }; |
import React, { FunctionComponent } from "react"; | ||
import type { PayPalScriptOptions } from "@paypal/paypal-js/types/script-options"; | ||
export interface ReactPayPalScriptOptions extends PayPalScriptOptions { | ||
"data-react-paypal-script-id"?: string; | ||
} | ||
declare enum SCRIPT_LOADING_STATE { | ||
@@ -9,3 +12,3 @@ PENDING = "pending", | ||
interface ScriptContextDerivedState { | ||
options: PayPalScriptOptions; | ||
options: ReactPayPalScriptOptions; | ||
isPending: boolean; | ||
@@ -20,3 +23,3 @@ isRejected: boolean; | ||
type: "resetOptions"; | ||
value: PayPalScriptOptions; | ||
value: ReactPayPalScriptOptions; | ||
}; | ||
@@ -29,3 +32,3 @@ declare type ScriptReducerDispatch = (action: ScriptReducerAction) => void; | ||
interface ScriptProviderProps { | ||
options: PayPalScriptOptions; | ||
options: ReactPayPalScriptOptions; | ||
children?: React.ReactNode; | ||
@@ -32,0 +35,0 @@ } |
{ | ||
"name": "@paypal/react-paypal-js", | ||
"version": "5.1.0", | ||
"version": "5.1.1-beta.1", | ||
"description": "React components for the PayPal JS SDK", | ||
@@ -44,9 +44,9 @@ "keywords": [ | ||
"dependencies": { | ||
"@paypal/paypal-js": "^3.1.4", | ||
"@paypal/paypal-js": "^3.1.5", | ||
"@paypal/sdk-constants": "^1.0.96" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.13.10", | ||
"@babel/preset-env": "^7.13.10", | ||
"@babel/preset-react": "^7.12.13", | ||
"@babel/core": "^7.13.14", | ||
"@babel/preset-env": "^7.13.12", | ||
"@babel/preset-react": "^7.13.13", | ||
"@babel/preset-typescript": "^7.13.0", | ||
@@ -56,5 +56,5 @@ "@commitlint/cli": "^12.0.1", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@rollup/plugin-node-resolve": "^11.2.0", | ||
"@rollup/plugin-replace": "^2.4.1", | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"@rollup/plugin-node-resolve": "^11.2.1", | ||
"@rollup/plugin-replace": "^2.4.2", | ||
"@rollup/plugin-typescript": "^8.2.1", | ||
"@storybook/addon-actions": "^6.1.21", | ||
@@ -65,13 +65,13 @@ "@storybook/addon-essentials": "^6.1.21", | ||
"@storybook/storybook-deployer": "^2.8.7", | ||
"@testing-library/react": "^11.2.5", | ||
"@testing-library/react": "^11.2.6", | ||
"@types/react": "^17.0.3", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"babel-jest": "^26.6.3", | ||
"babel-loader": "^8.2.2", | ||
"eslint": "^7.22.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react": "^7.23.1", | ||
"http-server": "^0.12.3", | ||
"husky": "^5.2.0", | ||
"husky": "^6.0.0", | ||
"jest": "^26.6.3", | ||
@@ -83,4 +83,4 @@ "lint-staged": "^10.5.4", | ||
"react-dom": "^16.13.1", | ||
"react-is": "^17.0.1", | ||
"rollup": "^2.42.1", | ||
"react-is": "^17.0.2", | ||
"rollup": "^2.44.0", | ||
"shelljs": "^0.8.4", | ||
@@ -87,0 +87,0 @@ "standard-version": "^9.1.1", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
80376
1291
1
Updated@paypal/paypal-js@^3.1.5