@pelcro/react-pelcro-js 3.26.0-beta.65 → 3.26.0-beta.66

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/index.cjs.js CHANGED
@@ -7647,6 +7647,7 @@ function _defineProperty$3(obj, key, value) {
7647
7647
  return obj;
7648
7648
  }
7649
7649
 
7650
+ /* eslint-disable valid-jsdoc */
7650
7651
  // Polyfill
7651
7652
  (() => {
7652
7653
  if (typeof window.CustomEvent === "function") return false;
@@ -7678,6 +7679,17 @@ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded",
7678
7679
  * Should fire when an item removed from the cart and expects the removed item to be sent
7679
7680
  */
7680
7681
  const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
7682
+ const displayLogin = detail => createCustomEvent("PelcroLoginDisplayed", detail);
7683
+ const displayRegister = detail => createCustomEvent("PelcroRegisterDisplayed", detail);
7684
+ const displaySelect = detail => createCustomEvent("PelcroSelectDisplayed", detail);
7685
+ const displayAddressCreate = detail => createCustomEvent("PelcroAddressCreateDisplayed", detail);
7686
+ const displayPaymentForm = detail => createCustomEvent("PelcroPaymentFormDisplayed", detail);
7687
+ const submitLogin = detail => createCustomEvent("PelcroLoginSubmitted", detail);
7688
+ const submitRegister = detail => createCustomEvent("PelcroRegisterSubmitted", detail);
7689
+ const submitSelect = detail => createCustomEvent("PelcroSelectSubmitted", detail);
7690
+ const submitAddressCreate = detail => createCustomEvent("PelcroAddressCreateSubmitted", detail);
7691
+ const submitAddressSelect = detail => createCustomEvent("PelcroAddressSelectSubmitted", detail);
7692
+ const submitPaymentForm = detail => createCustomEvent("PelcroPaymentFormSubmitted", detail);
7681
7693
 
7682
7694
  /**
7683
7695
  * Check if the browser support custom events
@@ -13119,8 +13131,14 @@ const LoginContainer = _ref => {
13119
13131
  content: getErrorMessages(err)
13120
13132
  }
13121
13133
  });
13134
+ document.dispatchEvent(submitLogin({
13135
+ submissionSuccess: false
13136
+ }));
13122
13137
  onFailure(err);
13123
13138
  } else {
13139
+ document.dispatchEvent(submitLogin({
13140
+ submissionSuccess: true
13141
+ }));
13124
13142
  onSuccess(res);
13125
13143
  if (enableReactGA4) {
13126
13144
  ReactGA4.event("Logged in", {
@@ -13801,8 +13819,14 @@ const RegisterContainer = _ref => {
13801
13819
  content: getErrorMessages(err)
13802
13820
  }
13803
13821
  });
13822
+ document.dispatchEvent(submitRegister({
13823
+ submissionSuccess: false
13824
+ }));
13804
13825
  onFailure(err);
13805
13826
  } else {
13827
+ document.dispatchEvent(submitRegister({
13828
+ submissionSuccess: true
13829
+ }));
13806
13830
  onSuccess(res);
13807
13831
  }
13808
13832
  });
@@ -14632,6 +14656,12 @@ function LoginModal(_ref) {
14632
14656
  const onPasswordlessRequest = () => {
14633
14657
  switchView("passwordless-request");
14634
14658
  };
14659
+ React.useEffect(() => {
14660
+ document.dispatchEvent(displayLogin({
14661
+ product,
14662
+ plan
14663
+ }));
14664
+ }, []);
14635
14665
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
14636
14666
  id: "pelcro-login-modal",
14637
14667
  onDisplay: onDisplay,
@@ -15248,6 +15278,12 @@ function RegisterModal(props) {
15248
15278
  }
15249
15279
  return resetView();
15250
15280
  };
15281
+ React.useEffect(() => {
15282
+ document.dispatchEvent(displayRegister({
15283
+ product,
15284
+ plan
15285
+ }));
15286
+ }, []);
15251
15287
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
15252
15288
  id: "pelcro-register-modal",
15253
15289
  onDisplay: props === null || props === void 0 ? void 0 : props.onDisplay,
@@ -15320,6 +15356,12 @@ function SelectModalWithHook(props) {
15320
15356
  } = usePelcro();
15321
15357
  const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
15322
15358
  const entitlements = entitlementsProtectedElements.length > 0 ? getEntitlementsFromElem(entitlementsProtectedElements[0]) : null;
15359
+ React.useEffect(() => {
15360
+ document.dispatchEvent(displaySelect({
15361
+ product,
15362
+ plan
15363
+ }));
15364
+ }, []);
15323
15365
  return /*#__PURE__*/React__default['default'].createElement(SelectModalWithTrans, {
15324
15366
  isGift: isGift,
15325
15367
  disableGifting: isRenewingGift,
@@ -15605,7 +15647,8 @@ class SelectModal extends React.Component {
15605
15647
  this.props.setProductAndPlan(this.state.product, this.state.plan, this.state.isGift);
15606
15648
  const {
15607
15649
  product,
15608
- isGift
15650
+ isGift,
15651
+ plan
15609
15652
  } = this.state;
15610
15653
  const {
15611
15654
  setView
@@ -15615,6 +15658,11 @@ class SelectModal extends React.Component {
15615
15658
  switchToAddressView,
15616
15659
  switchToPaymentView
15617
15660
  } = usePelcro.getStore();
15661
+ document.dispatchEvent(submitSelect({
15662
+ submissionSuccess: true,
15663
+ product,
15664
+ plan
15665
+ }));
15618
15666
  if (!isAuthenticated) {
15619
15667
  return setView("register");
15620
15668
  }
@@ -24811,20 +24859,37 @@ function SubscriptionCreateModal(_ref) {
24811
24859
  } = _ref;
24812
24860
  useTranslation("common");
24813
24861
  const {
24814
- switchView
24862
+ switchView,
24863
+ product,
24864
+ plan
24815
24865
  } = usePelcro();
24816
24866
  const onSuccess = res => {
24817
24867
  var _otherProps$onSuccess;
24818
24868
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, res);
24819
24869
  trackSubscriptionOnGA();
24870
+ document.dispatchEvent(submitPaymentForm({
24871
+ submissionSuccess: true
24872
+ }));
24820
24873
  return switchView("subscription-success");
24821
24874
  };
24875
+ const onFailure = () => {
24876
+ return document.dispatchEvent(submitPaymentForm({
24877
+ submissionSuccess: false
24878
+ }));
24879
+ };
24880
+ React.useEffect(() => {
24881
+ document.dispatchEvent(displayPaymentForm({
24882
+ product,
24883
+ plan
24884
+ }));
24885
+ }, []);
24822
24886
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
24823
24887
  id: "pelcro-subscription-create-modal",
24824
24888
  onDisplay: onDisplay,
24825
24889
  onClose: onClose
24826
24890
  }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateView, Object.assign({}, otherProps, {
24827
- onSuccess: onSuccess
24891
+ onSuccess: onSuccess,
24892
+ onFailure: onFailure
24828
24893
  }))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
24829
24894
  }
24830
24895
  SubscriptionCreateModal.viewId = "subscription-create";
@@ -26205,12 +26270,18 @@ const AddressCreateContainer = _ref => {
26205
26270
  content: getErrorMessages(err)
26206
26271
  }
26207
26272
  });
26273
+ document.dispatchEvent(submitAddressCreate({
26274
+ submissionSuccess: false
26275
+ }));
26208
26276
  onFailure(err);
26209
26277
  return dispatch({
26210
26278
  type: LOADING,
26211
26279
  payload: false
26212
26280
  });
26213
26281
  }
26282
+ document.dispatchEvent(submitAddressCreate({
26283
+ submissionSuccess: true
26284
+ }));
26214
26285
  const newAddressId = String(getNewlyCreatedAddress(res.data.addresses).id);
26215
26286
  if (selectedMembership) {
26216
26287
  dispatch({
@@ -26831,7 +26902,9 @@ const AddressCreateModal = _ref => {
26831
26902
  const {
26832
26903
  switchView,
26833
26904
  switchToPaymentView,
26834
- resetView
26905
+ resetView,
26906
+ product,
26907
+ plan
26835
26908
  } = usePelcro();
26836
26909
  const onSuccess = newAddressId => {
26837
26910
  var _otherProps$onSuccess;
@@ -26850,6 +26923,12 @@ const AddressCreateModal = _ref => {
26850
26923
  (_otherProps$onMembers = otherProps.onMembershipAdressUpdateSuccess) === null || _otherProps$onMembers === void 0 ? void 0 : _otherProps$onMembers.call(otherProps);
26851
26924
  resetView();
26852
26925
  };
26926
+ React.useEffect(() => {
26927
+ document.dispatchEvent(displayAddressCreate({
26928
+ product,
26929
+ plan
26930
+ }));
26931
+ }, []);
26853
26932
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
26854
26933
  id: "pelcro-address-create-modal",
26855
26934
  onDisplay: onDisplay,
@@ -29780,6 +29859,9 @@ const AddressSelectContainer = _ref => {
29780
29859
  return onGiftRedemptionSuccess(res);
29781
29860
  });
29782
29861
  }
29862
+ document.dispatchEvent(submitAddressSelect({
29863
+ submissionSuccess: true
29864
+ }));
29783
29865
  onSuccess(selectedAddressId);
29784
29866
  };
29785
29867
  const [state, dispatch] = useReducerWithSideEffects((state, action) => {
package/dist/index.esm.js CHANGED
@@ -7617,6 +7617,7 @@ function _defineProperty$3(obj, key, value) {
7617
7617
  return obj;
7618
7618
  }
7619
7619
 
7620
+ /* eslint-disable valid-jsdoc */
7620
7621
  // Polyfill
7621
7622
  (() => {
7622
7623
  if (typeof window.CustomEvent === "function") return false;
@@ -7648,6 +7649,17 @@ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded",
7648
7649
  * Should fire when an item removed from the cart and expects the removed item to be sent
7649
7650
  */
7650
7651
  const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
7652
+ const displayLogin = detail => createCustomEvent("PelcroLoginDisplayed", detail);
7653
+ const displayRegister = detail => createCustomEvent("PelcroRegisterDisplayed", detail);
7654
+ const displaySelect = detail => createCustomEvent("PelcroSelectDisplayed", detail);
7655
+ const displayAddressCreate = detail => createCustomEvent("PelcroAddressCreateDisplayed", detail);
7656
+ const displayPaymentForm = detail => createCustomEvent("PelcroPaymentFormDisplayed", detail);
7657
+ const submitLogin = detail => createCustomEvent("PelcroLoginSubmitted", detail);
7658
+ const submitRegister = detail => createCustomEvent("PelcroRegisterSubmitted", detail);
7659
+ const submitSelect = detail => createCustomEvent("PelcroSelectSubmitted", detail);
7660
+ const submitAddressCreate = detail => createCustomEvent("PelcroAddressCreateSubmitted", detail);
7661
+ const submitAddressSelect = detail => createCustomEvent("PelcroAddressSelectSubmitted", detail);
7662
+ const submitPaymentForm = detail => createCustomEvent("PelcroPaymentFormSubmitted", detail);
7651
7663
 
7652
7664
  /**
7653
7665
  * Check if the browser support custom events
@@ -13089,8 +13101,14 @@ const LoginContainer = _ref => {
13089
13101
  content: getErrorMessages(err)
13090
13102
  }
13091
13103
  });
13104
+ document.dispatchEvent(submitLogin({
13105
+ submissionSuccess: false
13106
+ }));
13092
13107
  onFailure(err);
13093
13108
  } else {
13109
+ document.dispatchEvent(submitLogin({
13110
+ submissionSuccess: true
13111
+ }));
13094
13112
  onSuccess(res);
13095
13113
  if (enableReactGA4) {
13096
13114
  ReactGA4.event("Logged in", {
@@ -13771,8 +13789,14 @@ const RegisterContainer = _ref => {
13771
13789
  content: getErrorMessages(err)
13772
13790
  }
13773
13791
  });
13792
+ document.dispatchEvent(submitRegister({
13793
+ submissionSuccess: false
13794
+ }));
13774
13795
  onFailure(err);
13775
13796
  } else {
13797
+ document.dispatchEvent(submitRegister({
13798
+ submissionSuccess: true
13799
+ }));
13776
13800
  onSuccess(res);
13777
13801
  }
13778
13802
  });
@@ -14602,6 +14626,12 @@ function LoginModal(_ref) {
14602
14626
  const onPasswordlessRequest = () => {
14603
14627
  switchView("passwordless-request");
14604
14628
  };
14629
+ useEffect(() => {
14630
+ document.dispatchEvent(displayLogin({
14631
+ product,
14632
+ plan
14633
+ }));
14634
+ }, []);
14605
14635
  return /*#__PURE__*/React__default.createElement(Modal, {
14606
14636
  id: "pelcro-login-modal",
14607
14637
  onDisplay: onDisplay,
@@ -15218,6 +15248,12 @@ function RegisterModal(props) {
15218
15248
  }
15219
15249
  return resetView();
15220
15250
  };
15251
+ useEffect(() => {
15252
+ document.dispatchEvent(displayRegister({
15253
+ product,
15254
+ plan
15255
+ }));
15256
+ }, []);
15221
15257
  return /*#__PURE__*/React__default.createElement(Modal, {
15222
15258
  id: "pelcro-register-modal",
15223
15259
  onDisplay: props === null || props === void 0 ? void 0 : props.onDisplay,
@@ -15290,6 +15326,12 @@ function SelectModalWithHook(props) {
15290
15326
  } = usePelcro();
15291
15327
  const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
15292
15328
  const entitlements = entitlementsProtectedElements.length > 0 ? getEntitlementsFromElem(entitlementsProtectedElements[0]) : null;
15329
+ useEffect(() => {
15330
+ document.dispatchEvent(displaySelect({
15331
+ product,
15332
+ plan
15333
+ }));
15334
+ }, []);
15293
15335
  return /*#__PURE__*/React__default.createElement(SelectModalWithTrans, {
15294
15336
  isGift: isGift,
15295
15337
  disableGifting: isRenewingGift,
@@ -15575,7 +15617,8 @@ class SelectModal extends Component {
15575
15617
  this.props.setProductAndPlan(this.state.product, this.state.plan, this.state.isGift);
15576
15618
  const {
15577
15619
  product,
15578
- isGift
15620
+ isGift,
15621
+ plan
15579
15622
  } = this.state;
15580
15623
  const {
15581
15624
  setView
@@ -15585,6 +15628,11 @@ class SelectModal extends Component {
15585
15628
  switchToAddressView,
15586
15629
  switchToPaymentView
15587
15630
  } = usePelcro.getStore();
15631
+ document.dispatchEvent(submitSelect({
15632
+ submissionSuccess: true,
15633
+ product,
15634
+ plan
15635
+ }));
15588
15636
  if (!isAuthenticated) {
15589
15637
  return setView("register");
15590
15638
  }
@@ -24781,20 +24829,37 @@ function SubscriptionCreateModal(_ref) {
24781
24829
  } = _ref;
24782
24830
  useTranslation("common");
24783
24831
  const {
24784
- switchView
24832
+ switchView,
24833
+ product,
24834
+ plan
24785
24835
  } = usePelcro();
24786
24836
  const onSuccess = res => {
24787
24837
  var _otherProps$onSuccess;
24788
24838
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, res);
24789
24839
  trackSubscriptionOnGA();
24840
+ document.dispatchEvent(submitPaymentForm({
24841
+ submissionSuccess: true
24842
+ }));
24790
24843
  return switchView("subscription-success");
24791
24844
  };
24845
+ const onFailure = () => {
24846
+ return document.dispatchEvent(submitPaymentForm({
24847
+ submissionSuccess: false
24848
+ }));
24849
+ };
24850
+ useEffect(() => {
24851
+ document.dispatchEvent(displayPaymentForm({
24852
+ product,
24853
+ plan
24854
+ }));
24855
+ }, []);
24792
24856
  return /*#__PURE__*/React__default.createElement(Modal, {
24793
24857
  id: "pelcro-subscription-create-modal",
24794
24858
  onDisplay: onDisplay,
24795
24859
  onClose: onClose
24796
24860
  }, /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(SubscriptionCreateView, Object.assign({}, otherProps, {
24797
- onSuccess: onSuccess
24861
+ onSuccess: onSuccess,
24862
+ onFailure: onFailure
24798
24863
  }))), /*#__PURE__*/React__default.createElement(ModalFooter, null, /*#__PURE__*/React__default.createElement(Authorship, null)));
24799
24864
  }
24800
24865
  SubscriptionCreateModal.viewId = "subscription-create";
@@ -26175,12 +26240,18 @@ const AddressCreateContainer = _ref => {
26175
26240
  content: getErrorMessages(err)
26176
26241
  }
26177
26242
  });
26243
+ document.dispatchEvent(submitAddressCreate({
26244
+ submissionSuccess: false
26245
+ }));
26178
26246
  onFailure(err);
26179
26247
  return dispatch({
26180
26248
  type: LOADING,
26181
26249
  payload: false
26182
26250
  });
26183
26251
  }
26252
+ document.dispatchEvent(submitAddressCreate({
26253
+ submissionSuccess: true
26254
+ }));
26184
26255
  const newAddressId = String(getNewlyCreatedAddress(res.data.addresses).id);
26185
26256
  if (selectedMembership) {
26186
26257
  dispatch({
@@ -26801,7 +26872,9 @@ const AddressCreateModal = _ref => {
26801
26872
  const {
26802
26873
  switchView,
26803
26874
  switchToPaymentView,
26804
- resetView
26875
+ resetView,
26876
+ product,
26877
+ plan
26805
26878
  } = usePelcro();
26806
26879
  const onSuccess = newAddressId => {
26807
26880
  var _otherProps$onSuccess;
@@ -26820,6 +26893,12 @@ const AddressCreateModal = _ref => {
26820
26893
  (_otherProps$onMembers = otherProps.onMembershipAdressUpdateSuccess) === null || _otherProps$onMembers === void 0 ? void 0 : _otherProps$onMembers.call(otherProps);
26821
26894
  resetView();
26822
26895
  };
26896
+ useEffect(() => {
26897
+ document.dispatchEvent(displayAddressCreate({
26898
+ product,
26899
+ plan
26900
+ }));
26901
+ }, []);
26823
26902
  return /*#__PURE__*/React__default.createElement(Modal, {
26824
26903
  id: "pelcro-address-create-modal",
26825
26904
  onDisplay: onDisplay,
@@ -29750,6 +29829,9 @@ const AddressSelectContainer = _ref => {
29750
29829
  return onGiftRedemptionSuccess(res);
29751
29830
  });
29752
29831
  }
29832
+ document.dispatchEvent(submitAddressSelect({
29833
+ submissionSuccess: true
29834
+ }));
29753
29835
  onSuccess(selectedAddressId);
29754
29836
  };
29755
29837
  const [state, dispatch] = useReducerWithSideEffects((state, action) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.26.0-beta.65",
4
+ "version": "3.26.0-beta.66",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",