@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
package/dist/components.esm.js
CHANGED
|
@@ -816,19 +816,26 @@ var transformStyle = function transformStyle(style) {
|
|
|
816
816
|
return result;
|
|
817
817
|
}, {});
|
|
818
818
|
};
|
|
819
|
-
var loadScript = function loadScript(src, nonce, dataset) {
|
|
819
|
+
var loadScript = function loadScript(src, nonce, dataset, forceReload) {
|
|
820
820
|
return new Promise(function (resolve, reject) {
|
|
821
|
-
|
|
821
|
+
var existingScript = Array.from(document.scripts).find(function (s) {
|
|
822
822
|
return s.src === src;
|
|
823
|
-
})
|
|
824
|
-
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
if (existingScript) {
|
|
826
|
+
if (forceReload) {
|
|
827
|
+
existingScript.remove();
|
|
828
|
+
} else {
|
|
829
|
+
resolve(existingScript);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
825
832
|
}
|
|
826
833
|
|
|
827
834
|
var script = document.createElement('script');
|
|
828
835
|
script.src = src;
|
|
829
836
|
|
|
830
837
|
script.onload = function () {
|
|
831
|
-
return resolve();
|
|
838
|
+
return resolve(script);
|
|
832
839
|
};
|
|
833
840
|
|
|
834
841
|
script.onerror = function (error) {
|
|
@@ -15154,7 +15161,7 @@ var namespace = 'monei-paypal';
|
|
|
15154
15161
|
|
|
15155
15162
|
var onLoadPaypal = /*#__PURE__*/function () {
|
|
15156
15163
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(props, state, src) {
|
|
15157
|
-
var defaultStyle, token;
|
|
15164
|
+
var script, defaultStyle, token;
|
|
15158
15165
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
15159
15166
|
while (1) {
|
|
15160
15167
|
switch (_context2.prev = _context2.next) {
|
|
@@ -15163,15 +15170,17 @@ var onLoadPaypal = /*#__PURE__*/function () {
|
|
|
15163
15170
|
return loadScript(src, props.cspNonce, {
|
|
15164
15171
|
namespace: namespace,
|
|
15165
15172
|
cspNonce: props.cspNonce
|
|
15166
|
-
});
|
|
15173
|
+
}, true);
|
|
15167
15174
|
|
|
15168
15175
|
case 2:
|
|
15176
|
+
script = _context2.sent;
|
|
15177
|
+
state.__scriptId = script.dataset.uidAuto;
|
|
15169
15178
|
defaultStyle = {
|
|
15170
15179
|
layout: 'horizontal',
|
|
15171
15180
|
tagline: false
|
|
15172
15181
|
};
|
|
15173
15182
|
props.onLoad == null ? void 0 : props.onLoad(true);
|
|
15174
|
-
_context2.next =
|
|
15183
|
+
_context2.next = 8;
|
|
15175
15184
|
return window[namespace].Buttons({
|
|
15176
15185
|
createOrder: function () {
|
|
15177
15186
|
var _createOrder = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
@@ -15240,7 +15249,7 @@ var onLoadPaypal = /*#__PURE__*/function () {
|
|
|
15240
15249
|
style: _extends({}, defaultStyle, props.style)
|
|
15241
15250
|
}).render(state.__container);
|
|
15242
15251
|
|
|
15243
|
-
case
|
|
15252
|
+
case 8:
|
|
15244
15253
|
case "end":
|
|
15245
15254
|
return _context2.stop();
|
|
15246
15255
|
}
|
|
@@ -15268,13 +15277,33 @@ var options$2 = {
|
|
|
15268
15277
|
return undefined;
|
|
15269
15278
|
},
|
|
15270
15279
|
containerTemplate: function containerTemplate$1(params) {
|
|
15280
|
+
console.log({
|
|
15281
|
+
params: params
|
|
15282
|
+
});
|
|
15271
15283
|
params.state.__container = params.container;
|
|
15272
15284
|
|
|
15273
15285
|
if (!params.props.accountId && !params.props.paymentId) {
|
|
15274
15286
|
throw new Error('You need to provide paymentId or accountId');
|
|
15275
15287
|
}
|
|
15276
15288
|
|
|
15277
|
-
|
|
15289
|
+
var container = containerTemplate(params);
|
|
15290
|
+
|
|
15291
|
+
params.event.on(zoid.EVENT.DESTROY, function () {
|
|
15292
|
+
console.log('destroy');
|
|
15293
|
+
window[namespace].Buttons.instances.forEach(function (instance) {
|
|
15294
|
+
instance.close();
|
|
15295
|
+
});
|
|
15296
|
+
var scriptId = params.state.__scriptId;
|
|
15297
|
+
|
|
15298
|
+
if (scriptId) {
|
|
15299
|
+
var script = document.querySelector("script[data-uid-auto=\"" + scriptId + "\"]");
|
|
15300
|
+
|
|
15301
|
+
if (script) {
|
|
15302
|
+
script.remove();
|
|
15303
|
+
}
|
|
15304
|
+
}
|
|
15305
|
+
});
|
|
15306
|
+
return container;
|
|
15278
15307
|
},
|
|
15279
15308
|
props: {
|
|
15280
15309
|
accountId: {
|