@monei-js/components 1.7.5 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.cjs.development.js +39 -10
- package/dist/components.cjs.development.js.map +1 -1
- package/dist/components.cjs.production.min.js +1 -1
- package/dist/components.cjs.production.min.js.map +1 -1
- package/dist/components.esm.js +39 -10
- package/dist/components.esm.js.map +1 -1
- package/dist/paypal/index.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -820,19 +820,26 @@ var transformStyle = function transformStyle(style) {
|
|
|
820
820
|
return result;
|
|
821
821
|
}, {});
|
|
822
822
|
};
|
|
823
|
-
var loadScript = function loadScript(src, nonce, dataset) {
|
|
823
|
+
var loadScript = function loadScript(src, nonce, dataset, forceReload) {
|
|
824
824
|
return new Promise(function (resolve, reject) {
|
|
825
|
-
|
|
825
|
+
var existingScript = Array.from(document.scripts).find(function (s) {
|
|
826
826
|
return s.src === src;
|
|
827
|
-
})
|
|
828
|
-
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
if (existingScript) {
|
|
830
|
+
if (forceReload) {
|
|
831
|
+
existingScript.remove();
|
|
832
|
+
} else {
|
|
833
|
+
resolve(existingScript);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
829
836
|
}
|
|
830
837
|
|
|
831
838
|
var script = document.createElement('script');
|
|
832
839
|
script.src = src;
|
|
833
840
|
|
|
834
841
|
script.onload = function () {
|
|
835
|
-
return resolve();
|
|
842
|
+
return resolve(script);
|
|
836
843
|
};
|
|
837
844
|
|
|
838
845
|
script.onerror = function (error) {
|
|
@@ -15158,7 +15165,7 @@ var namespace = 'monei-paypal';
|
|
|
15158
15165
|
|
|
15159
15166
|
var onLoadPaypal = /*#__PURE__*/function () {
|
|
15160
15167
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(props, state, src) {
|
|
15161
|
-
var defaultStyle, token;
|
|
15168
|
+
var script, defaultStyle, token;
|
|
15162
15169
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
15163
15170
|
while (1) {
|
|
15164
15171
|
switch (_context2.prev = _context2.next) {
|
|
@@ -15167,15 +15174,17 @@ var onLoadPaypal = /*#__PURE__*/function () {
|
|
|
15167
15174
|
return loadScript(src, props.cspNonce, {
|
|
15168
15175
|
namespace: namespace,
|
|
15169
15176
|
cspNonce: props.cspNonce
|
|
15170
|
-
});
|
|
15177
|
+
}, true);
|
|
15171
15178
|
|
|
15172
15179
|
case 2:
|
|
15180
|
+
script = _context2.sent;
|
|
15181
|
+
state.__scriptId = script.dataset.uidAuto;
|
|
15173
15182
|
defaultStyle = {
|
|
15174
15183
|
layout: 'horizontal',
|
|
15175
15184
|
tagline: false
|
|
15176
15185
|
};
|
|
15177
15186
|
props.onLoad == null ? void 0 : props.onLoad(true);
|
|
15178
|
-
_context2.next =
|
|
15187
|
+
_context2.next = 8;
|
|
15179
15188
|
return window[namespace].Buttons({
|
|
15180
15189
|
createOrder: function () {
|
|
15181
15190
|
var _createOrder = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -15244,7 +15253,7 @@ var onLoadPaypal = /*#__PURE__*/function () {
|
|
|
15244
15253
|
style: _extends({}, defaultStyle, props.style)
|
|
15245
15254
|
}).render(state.__container);
|
|
15246
15255
|
|
|
15247
|
-
case
|
|
15256
|
+
case 8:
|
|
15248
15257
|
case "end":
|
|
15249
15258
|
return _context2.stop();
|
|
15250
15259
|
}
|
|
@@ -15272,13 +15281,33 @@ var options$2 = {
|
|
|
15272
15281
|
return undefined;
|
|
15273
15282
|
},
|
|
15274
15283
|
containerTemplate: function containerTemplate$1(params) {
|
|
15284
|
+
console.log({
|
|
15285
|
+
params: params
|
|
15286
|
+
});
|
|
15275
15287
|
params.state.__container = params.container;
|
|
15276
15288
|
|
|
15277
15289
|
if (!params.props.accountId && !params.props.paymentId) {
|
|
15278
15290
|
throw new Error('You need to provide paymentId or accountId');
|
|
15279
15291
|
}
|
|
15280
15292
|
|
|
15281
|
-
|
|
15293
|
+
var container = containerTemplate(params);
|
|
15294
|
+
|
|
15295
|
+
params.event.on(zoid.EVENT.DESTROY, function () {
|
|
15296
|
+
console.log('destroy');
|
|
15297
|
+
window[namespace].Buttons.instances.forEach(function (instance) {
|
|
15298
|
+
instance.close();
|
|
15299
|
+
});
|
|
15300
|
+
var scriptId = params.state.__scriptId;
|
|
15301
|
+
|
|
15302
|
+
if (scriptId) {
|
|
15303
|
+
var script = document.querySelector("script[data-uid-auto=\"" + scriptId + "\"]");
|
|
15304
|
+
|
|
15305
|
+
if (script) {
|
|
15306
|
+
script.remove();
|
|
15307
|
+
}
|
|
15308
|
+
}
|
|
15309
|
+
});
|
|
15310
|
+
return container;
|
|
15282
15311
|
},
|
|
15283
15312
|
props: {
|
|
15284
15313
|
accountId: {
|