@monei-js/components 1.7.4 → 1.7.6

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.
@@ -816,12 +816,19 @@ 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
- if (Array.from(document.scripts).findIndex(function (s) {
821
+ var existingScript = Array.from(document.scripts).find(function (s) {
822
822
  return s.src === src;
823
- }) !== -1) {
824
- resolve();
823
+ });
824
+
825
+ if (existingScript) {
826
+ if (forceReload) {
827
+ existingScript.remove();
828
+ } else {
829
+ resolve();
830
+ return;
831
+ }
825
832
  }
826
833
 
827
834
  var script = document.createElement('script');
@@ -15163,7 +15170,7 @@ 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:
15169
15176
  defaultStyle = {
@@ -15274,7 +15281,14 @@ var options$2 = {
15274
15281
  throw new Error('You need to provide paymentId or accountId');
15275
15282
  }
15276
15283
 
15277
- return containerTemplate(params);
15284
+ var container = containerTemplate(params);
15285
+
15286
+ params.event.on(zoid.EVENT.DESTROY, function () {
15287
+ window[namespace].Buttons.instances.forEach(function (instance) {
15288
+ instance.close();
15289
+ });
15290
+ });
15291
+ return container;
15278
15292
  },
15279
15293
  props: {
15280
15294
  accountId: {
@@ -15605,12 +15619,14 @@ var options$4 = {
15605
15619
  type: zoid.PROP_TYPE.FUNCTION,
15606
15620
  required: false,
15607
15621
  value: function value(_ref2) {
15608
- var props = _ref2.props;
15622
+ var props = _ref2.props,
15623
+ state = _ref2.state;
15609
15624
  var rootNode = document.createElement('div');
15610
15625
  document.body.appendChild(rootNode);
15611
15626
  return function (_ref3) {
15612
15627
  var amount = _ref3.amount,
15613
15628
  currency = _ref3.currency;
15629
+ if (state.isOpen) return;
15614
15630
  var shouldOpen = true;
15615
15631
 
15616
15632
  if (props.onBeforeOpen) {
@@ -15618,11 +15634,13 @@ var options$4 = {
15618
15634
  }
15619
15635
 
15620
15636
  if (!shouldOpen) return;
15637
+ state.isOpen = true;
15621
15638
  var bizumModal = new BizumModal(_extends({
15622
15639
  amount: amount,
15623
15640
  currency: currency
15624
15641
  }, props, {
15625
15642
  onClose: function onClose() {
15643
+ state.isOpen = false;
15626
15644
  window.onpopstate = null;
15627
15645
  document.body.style.overflow = '';
15628
15646
  },