@pelcro/react-pelcro-js 2.6.0-beta.3 → 2.6.0-beta.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/index.cjs.js CHANGED
@@ -4494,7 +4494,7 @@ var messages$2 = {
4494
4494
  isSureToCancel: "Êtes-vous certain de vouloir annuler votre abonnement?",
4495
4495
  loading: "Annulation de l'abonnement",
4496
4496
  success: "L'abonnement a été annulé avec succès",
4497
- error: "Une erreure s'est produite lors de l'annulation de l'abonnement"
4497
+ error: "Une erreur s'est produite lors de l'annulation de l'abonnement"
4498
4498
  }
4499
4499
  };
4500
4500
  var dashboard_fr = {
@@ -6327,13 +6327,34 @@ const getAddressById = id => {
6327
6327
  };
6328
6328
  /**
6329
6329
  * Transforms locale names stored in our backend like
6330
- * "en_US" into the standerd accepted in core i18n methods: "en-US"
6330
+ * "en_US" into the standard accepted in core i18n methods: "en-US"
6331
6331
  * @param {string} localeName
6332
6332
  * @return {string | undefined}
6333
6333
  * @example getCanonicalLocaleFormat("en_US") => "en-US"
6334
6334
  */
6335
6335
 
6336
6336
  const getCanonicalLocaleFormat = localeName => localeName === null || localeName === void 0 ? void 0 : localeName.replace("_", "-");
6337
+ /**
6338
+ * @param {string} localeName
6339
+ * @return {string | undefined}
6340
+ * @example getLanguageWithoutRegion("en-US") => "en"
6341
+ */
6342
+
6343
+ const getLanguageWithoutRegion = localeName => {
6344
+ var _getCanonicalLocaleFo;
6345
+
6346
+ return (_getCanonicalLocaleFo = getCanonicalLocaleFormat(localeName)) === null || _getCanonicalLocaleFo === void 0 ? void 0 : _getCanonicalLocaleFo.split("-")[0];
6347
+ };
6348
+ /**
6349
+ * Gets the current page language or fallbacks to site default
6350
+ * @return {string | undefined}
6351
+ */
6352
+
6353
+ const getPageOrDefaultLanguage = () => {
6354
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6355
+
6356
+ return (_window$Pelcro$helper = window.Pelcro.helpers.getHtmlLanguageAttribute()) !== null && _window$Pelcro$helper !== void 0 ? _window$Pelcro$helper : getLanguageWithoutRegion((_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale);
6357
+ };
6337
6358
  /**
6338
6359
  * Returns a formatted price string depending on locale
6339
6360
  * @param {number} amount
@@ -6343,7 +6364,7 @@ const getCanonicalLocaleFormat = localeName => localeName === null || localeName
6343
6364
  * @example getFormattedPriceByLocal(10, 'USD', 'en-US') => "$10.00"
6344
6365
  */
6345
6366
 
6346
- const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en-US") => {
6367
+ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6347
6368
  const formatter = new Intl.NumberFormat(getCanonicalLocaleFormat(locale), {
6348
6369
  style: "currency",
6349
6370
  currency
@@ -6368,8 +6389,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6368
6389
  totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6369
6390
  }
6370
6391
 
6371
- const locale = window.Pelcro.site.read().default_locale;
6372
- return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, locale);
6392
+ return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
6373
6393
  };
6374
6394
  /**
6375
6395
  * returns true if the URL contains a supported view trigger URL
@@ -6383,12 +6403,15 @@ const isValidViewFromURL = viewID => {
6383
6403
  }
6384
6404
 
6385
6405
  return false;
6406
+ /**
6407
+ *
6408
+ */
6386
6409
 
6387
6410
  function hasValidNewsletterUpdateUrl() {
6388
- var _window$Pelcro, _window$Pelcro$uiSett;
6411
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
6389
6412
 
6390
6413
  if (viewID !== "newsletter-update") return false;
6391
- const newsletters = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.newsletters;
6414
+ const newsletters = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$uiSet = _window$Pelcro2.uiSettings) === null || _window$Pelcro2$uiSet === void 0 ? void 0 : _window$Pelcro2$uiSet.newsletters;
6392
6415
  const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6393
6416
 
6394
6417
  if (!siteHasNewslettersDefined) {
@@ -6561,10 +6584,20 @@ const getPaymentCardIcon$1 = name => {
6561
6584
  d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
6562
6585
  }));
6563
6586
  };
6587
+ /**
6588
+ * Gets the current date with time set to 0
6589
+ * @param {Date} dateObject
6590
+ * @return {Date}
6591
+ */
6592
+
6593
+ function getDateWithoutTime(dateObject) {
6594
+ const date = new Date(dateObject.getTime());
6595
+ date.setHours(0, 0, 0, 0);
6596
+ return date;
6597
+ }
6564
6598
 
6565
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6566
6599
  const resources = {
6567
- "en-US": {
6600
+ en: {
6568
6601
  common: common_en,
6569
6602
  paymentMethod: paymentMethod_en,
6570
6603
  newsletter: newsletter_en,
@@ -6586,7 +6619,7 @@ const resources = {
6586
6619
  select: select_en,
6587
6620
  notification: notification_en
6588
6621
  },
6589
- "fr-CA": {
6622
+ fr: {
6590
6623
  common: common_fr,
6591
6624
  paymentMethod: paymentMethod_fr,
6592
6625
  newsletter: newsletter_fr,
@@ -6608,13 +6641,14 @@ const resources = {
6608
6641
  select: select_fr,
6609
6642
  notification: notification_fr
6610
6643
  }
6611
- };
6612
- let locale = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale;
6613
- if (!locale) locale = "en-US";
6644
+ }; // set UI language to the page language or default to the language in site settings
6645
+
6646
+ const locale = getPageOrDefaultLanguage();
6614
6647
  i18next.use(initReactI18next) // passes i18n down to react-i18next,
6615
6648
  .init({
6616
6649
  resources,
6617
- lng: getCanonicalLocaleFormat(locale),
6650
+ lng: locale,
6651
+ fallbackLng: "en",
6618
6652
  // debug: true,
6619
6653
  interpolation: {
6620
6654
  escapeValue: false // react already safes from xss
@@ -6625,6 +6659,16 @@ i18next.use(initReactI18next) // passes i18n down to react-i18next,
6625
6659
 
6626
6660
  }
6627
6661
  });
6662
+ const pageLanguageObserver = new MutationObserver(mutationsList => {
6663
+ mutationsList.forEach(mutationRecord => {
6664
+ if (mutationRecord.attributeName === "lang") {
6665
+ i18next.changeLanguage(window.Pelcro.helpers.getHtmlLanguageAttribute());
6666
+ }
6667
+ });
6668
+ });
6669
+ pageLanguageObserver.observe(document.documentElement, {
6670
+ attributes: true
6671
+ });
6628
6672
 
6629
6673
  function _classPrivateFieldGet(receiver, privateMap) {
6630
6674
  var descriptor = privateMap.get(receiver);
@@ -8432,6 +8476,7 @@ const optionsController = options => {
8432
8476
  enableURLTriggers: initViewFromURL,
8433
8477
  enableTheme: applyPelcroTheme,
8434
8478
  enablePaywalls: initPaywalls,
8479
+ loadSecuritySDK: initSecuritySdk,
8435
8480
  enableGoogleAnalytics: initGATracking
8436
8481
  }; // Only execute enabled options
8437
8482
 
@@ -8493,6 +8538,18 @@ const loadPaymentSDKs = () => {
8493
8538
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8494
8539
  }
8495
8540
  };
8541
+ const initSecuritySdk = () => {
8542
+ const {
8543
+ whenSiteReady
8544
+ } = usePelcro.getStore();
8545
+ whenSiteReady(() => {
8546
+ var _window$Pelcro$site$r2;
8547
+
8548
+ const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
8549
+ if (!securityKey) return;
8550
+ window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
8551
+ });
8552
+ };
8496
8553
  const initGATracking = () => {
8497
8554
  var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
8498
8555
 
@@ -8579,9 +8636,9 @@ const applyPelcroTheme = () => {
8579
8636
  };
8580
8637
 
8581
8638
  whenSiteReady(() => {
8582
- var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
8639
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
8583
8640
 
8584
- const primaryColorHex = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : (_window$Pelcro$site$r3 = _window$Pelcro$site$r2.design_settings) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.primary_color;
8641
+ const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
8585
8642
 
8586
8643
  if (!primaryColorHex) {
8587
8644
  return;
@@ -8780,6 +8837,7 @@ const defaultOptions = {
8780
8837
  enableURLTriggers: true,
8781
8838
  enableTheme: true,
8782
8839
  enablePaywalls: true,
8840
+ loadSecuritySDK: true,
8783
8841
  enableGoogleAnalytics: false
8784
8842
  };
8785
8843
  const PelcroModalController = ({
@@ -9720,35 +9778,53 @@ const RegisterContainer = ({
9720
9778
  jobTitle,
9721
9779
  selectFields
9722
9780
  } = filteredData;
9723
- window.Pelcro.user.register({
9724
- email,
9725
- password,
9726
- first_name: firstName,
9727
- last_name: lastName,
9728
- metadata: {
9729
- organization,
9730
- jobTitle,
9731
- ...selectFields
9732
- }
9733
- }, (err, res) => {
9734
- dispatch({
9735
- type: DISABLE_REGISTRATION_BUTTON,
9736
- payload: false
9781
+
9782
+ if (!hasSecurityTokenEnabled()) {
9783
+ sendRegisterRequest();
9784
+ return;
9785
+ }
9786
+
9787
+ window.grecaptcha.enterprise.ready(async () => {
9788
+ var _window$Pelcro$site$r;
9789
+
9790
+ const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
9791
+ action: "register"
9737
9792
  });
9793
+ sendRegisterRequest(token);
9794
+ });
9738
9795
 
9739
- if (err) {
9796
+ function sendRegisterRequest(securityToken) {
9797
+ window.Pelcro.user.register({
9798
+ email,
9799
+ password,
9800
+ first_name: firstName,
9801
+ last_name: lastName,
9802
+ security_token: securityToken,
9803
+ metadata: {
9804
+ organization,
9805
+ jobTitle,
9806
+ ...selectFields
9807
+ }
9808
+ }, (err, res) => {
9740
9809
  dispatch({
9741
- type: SHOW_ALERT,
9742
- payload: {
9743
- type: "error",
9744
- content: getErrorMessages(err)
9745
- }
9810
+ type: DISABLE_REGISTRATION_BUTTON,
9811
+ payload: false
9746
9812
  });
9747
- onFailure(err);
9748
- } else {
9749
- onSuccess(res);
9750
- }
9751
- });
9813
+
9814
+ if (err) {
9815
+ dispatch({
9816
+ type: SHOW_ALERT,
9817
+ payload: {
9818
+ type: "error",
9819
+ content: getErrorMessages(err)
9820
+ }
9821
+ });
9822
+ onFailure(err);
9823
+ } else {
9824
+ onSuccess(res);
9825
+ }
9826
+ });
9827
+ }
9752
9828
  };
9753
9829
 
9754
9830
  const handleSocialLogin = ({
@@ -9899,6 +9975,15 @@ const RegisterContainer = ({
9899
9975
  store: store$e
9900
9976
  })));
9901
9977
  };
9978
+ /**
9979
+ * Checks if the current site has security token enabled
9980
+ * @return {boolean}
9981
+ */
9982
+
9983
+ function hasSecurityTokenEnabled() {
9984
+ const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
9985
+ return hasSecuritySdkLoaded;
9986
+ }
9902
9987
 
9903
9988
  var _path$l;
9904
9989
 
@@ -9920,7 +10005,7 @@ const FacebookLoginButton = ({
9920
10005
  labelClassName = "",
9921
10006
  iconClassName = ""
9922
10007
  }) => {
9923
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
10008
+ var _window$Pelcro$site$r;
9924
10009
 
9925
10010
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
9926
10011
  const {
@@ -9959,7 +10044,7 @@ const FacebookLoginButton = ({
9959
10044
 
9960
10045
  return facebookLoginEnabled ? /*#__PURE__*/React__default['default'].createElement(FacebookLogin, {
9961
10046
  appId: window.Pelcro.site.read().facebook_app_id,
9962
- language: (_window$Pelcro$site$r2 = window.Pelcro.site.read().default_locale) !== null && _window$Pelcro$site$r2 !== void 0 ? _window$Pelcro$site$r2 : "en_US",
10047
+ language: getPageOrDefaultLanguage(),
9963
10048
  fields: "first_name,last_name,email,picture",
9964
10049
  callback: onSuccess,
9965
10050
  onFailure: onFailure,
@@ -10288,8 +10373,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default['default'].createE
10288
10373
  const RegisterButton = ({
10289
10374
  name,
10290
10375
  onClick,
10376
+ className,
10291
10377
  ...otherProps
10292
10378
  }) => {
10379
+ var _window$Pelcro$site$r;
10380
+
10293
10381
  const {
10294
10382
  state: {
10295
10383
  emailError,
@@ -10315,7 +10403,10 @@ const RegisterButton = ({
10315
10403
  onClick === null || onClick === void 0 ? void 0 : onClick();
10316
10404
  },
10317
10405
  disabled: isDisabled,
10318
- isLoading: buttonDisabled
10406
+ isLoading: buttonDisabled,
10407
+ className: `${className} g-recaptcha`,
10408
+ "data-action": "register",
10409
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
10319
10410
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
10320
10411
  };
10321
10412
 
@@ -13493,7 +13584,7 @@ const PaymentMethodContainer = props => {
13493
13584
  return /*#__PURE__*/React__default['default'].createElement(es_13, {
13494
13585
  apiKey: window.Pelcro.environment.stripe,
13495
13586
  stripeAccount: window.Pelcro.site.read().account_id,
13496
- locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13587
+ locale: getPageOrDefaultLanguage()
13497
13588
  }, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
13498
13589
  store: store$d
13499
13590
  }, props))));
@@ -13605,9 +13696,6 @@ const DiscountedPrice = props => {
13605
13696
  percentOff
13606
13697
  }
13607
13698
  } = React.useContext(store$d);
13608
- const {
13609
- default_locale
13610
- } = Pelcro.site.read();
13611
13699
  const {
13612
13700
  order,
13613
13701
  plan
@@ -13615,7 +13703,7 @@ const DiscountedPrice = props => {
13615
13703
  const ecommOrderCurrency = (_order$currency = order === null || order === void 0 ? void 0 : order.currency) !== null && _order$currency !== void 0 ? _order$currency : order === null || order === void 0 ? void 0 : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
13616
13704
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13617
13705
  const discountedPriceWithoutTax = updatedPrice - taxAmount;
13618
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13706
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13619
13707
 
13620
13708
  if (percentOff) {
13621
13709
  return /*#__PURE__*/React__default['default'].createElement("div", Object.assign({
@@ -13648,12 +13736,9 @@ const SubmitPaymentMethod = ({
13648
13736
  updatedPrice
13649
13737
  }
13650
13738
  } = React.useContext(store$d);
13651
- const {
13652
- default_locale
13653
- } = Pelcro.site.read();
13654
13739
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13655
13740
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
13656
- const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13741
+ const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13657
13742
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
13658
13743
  role: "submit",
13659
13744
  className: "plc-w-full plc-py-3",
@@ -13898,7 +13983,7 @@ class PaypalClient {
13898
13983
  this.paypalButton = window.paypal.Buttons({
13899
13984
  fundingSource: window.paypal.FUNDING.PAYPAL,
13900
13985
  // button locale
13901
- locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : this.siteInfo.default_locale,
13986
+ locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : getPageOrDefaultLanguage(),
13902
13987
  // button style
13903
13988
  style: (_this$config$style = this.config.style) !== null && _this$config$style !== void 0 ? _this$config$style : defaultButtonStyle,
13904
13989
  // create payment handler
@@ -13995,7 +14080,7 @@ class PaypalClient {
13995
14080
  } : undefined,
13996
14081
  shippingAddressEditable: this.config.shippingAddressEditable,
13997
14082
  displayName: (_this$config$displayN = this.config.displayName) !== null && _this$config$displayN !== void 0 ? _this$config$displayN : this.siteInfo.name,
13998
- locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : this.siteInfo.default_locale
14083
+ locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : getPageOrDefaultLanguage()
13999
14084
  };
14000
14085
  }
14001
14086
  });
@@ -14004,7 +14089,7 @@ class PaypalClient {
14004
14089
  writable: true,
14005
14090
  value: () => {
14006
14091
  const totalAmount = (this.product.quantity || 1) * this.amount;
14007
- const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, this.siteInfo.default_locale);
14092
+ const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, getPageOrDefaultLanguage());
14008
14093
  const autoRenewed = this.product.auto_renew;
14009
14094
  const {
14010
14095
  interval,
@@ -14201,14 +14286,11 @@ const TaxAmount = () => {
14201
14286
  taxAmount
14202
14287
  }
14203
14288
  } = React.useContext(store$d);
14204
- const {
14205
- default_locale
14206
- } = Pelcro.site.read();
14207
14289
  const {
14208
14290
  plan
14209
14291
  } = usePelcro();
14210
14292
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14211
- const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14293
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14212
14294
 
14213
14295
  if (taxAmount) {
14214
14296
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -15081,10 +15163,7 @@ const SubscriptionCreateView = ({
15081
15163
  interval,
15082
15164
  count: interval_count
15083
15165
  });
15084
- const {
15085
- default_locale
15086
- } = Pelcro.site.read();
15087
- const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
15166
+ const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
15088
15167
  return /*#__PURE__*/React__default['default'].createElement("p", {
15089
15168
  className: "plc-text-gray-600"
15090
15169
  }, /*#__PURE__*/React__default['default'].createElement("span", {
@@ -18261,7 +18340,6 @@ const OrderConfirmModal = props => {
18261
18340
  const userOrders = window.Pelcro.user.read().orders;
18262
18341
  const latestOrder = userOrders === null || userOrders === void 0 ? void 0 : userOrders[userOrders.length - 1];
18263
18342
  const latestOrderDiscount = latestOrder === null || latestOrder === void 0 ? void 0 : (_latestOrder$coupon = latestOrder.coupon) === null || _latestOrder$coupon === void 0 ? void 0 : _latestOrder$coupon.percent_off;
18264
- const locale = window.Pelcro.site.read().default_locale;
18265
18343
  const {
18266
18344
  t
18267
18345
  } = useTranslation("shop");
@@ -18320,7 +18398,7 @@ const OrderConfirmModal = props => {
18320
18398
  className: "plc-mr-1 pelcro-summary-total-text"
18321
18399
  }, t("labels.total")), /*#__PURE__*/React__default['default'].createElement("p", {
18322
18400
  className: "pelcro-summary-total"
18323
- }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, locale)))), /*#__PURE__*/React__default['default'].createElement("div", {
18401
+ }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default['default'].createElement("div", {
18324
18402
  className: "plc-flex plc-justify-center plc-mt-6"
18325
18403
  }, /*#__PURE__*/React__default['default'].createElement(Button, {
18326
18404
  id: "pelcro-submit",
@@ -18382,9 +18460,9 @@ const GiftCreateContainer = ({
18382
18460
  }
18383
18461
 
18384
18462
  if (giftRecipient.startDate) {
18385
- const nowDate = new Date();
18386
- const yearFromNowDate = new Date(new Date().setFullYear(nowDate.getFullYear() + 1));
18387
- const submittedDate = new Date(giftRecipient.startDate);
18463
+ const nowDate = getDateWithoutTime(new Date());
18464
+ const yearFromNowDate = getDateWithoutTime(new Date(new Date().setFullYear(nowDate.getFullYear() + 1)));
18465
+ const submittedDate = getDateWithoutTime(new Date(giftRecipient.startDate));
18388
18466
 
18389
18467
  if (submittedDate < nowDate || submittedDate > yearFromNowDate) {
18390
18468
  dispatch({
@@ -20689,7 +20767,6 @@ const OrderItems = ({
20689
20767
  const {
20690
20768
  t
20691
20769
  } = useTranslation("dashboard");
20692
- const site = window.Pelcro.site.read();
20693
20770
  return !(orders !== null && orders !== void 0 && orders.length) ? /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", {
20694
20771
  colSpan: "3",
20695
20772
  className: "plc-text-center plc-text-gray-500"
@@ -20705,7 +20782,7 @@ const OrderItems = ({
20705
20782
  className: "plc-py-4 plc-pl-2"
20706
20783
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20707
20784
  className: "plc-text-xl plc-font-semibold "
20708
- }, getFormattedPriceByLocal(order.amount, order.currency, site.default_locale)), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
20785
+ }, getFormattedPriceByLocal(order.amount, order.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
20709
20786
  className: "plc-text-xs plc-text-gray-400 plc-uppercase"
20710
20787
  }, t("labels.orders.itemsAmount", {
20711
20788
  count: getItemsAmount(order.id)
@@ -20734,7 +20811,7 @@ const OrderItems = ({
20734
20811
  className: ""
20735
20812
  }, item.product_sku_name))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
20736
20813
  className: "plc-font-semibold"
20737
- }, getFormattedPriceByLocal(item.amount, order.currency, site.default_locale))));
20814
+ }, getFormattedPriceByLocal(item.amount, order.currency, getPageOrDefaultLanguage()))));
20738
20815
  }), /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", {
20739
20816
  colSpan: "3"
20740
20817
  }, /*#__PURE__*/React__default['default'].createElement("hr", {
@@ -21461,7 +21538,7 @@ class Dashboard extends React.Component {
21461
21538
  className: "plc-font-semibold plc-text-gray-500"
21462
21539
  }, sub.plan.nickname), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
21463
21540
  className: "plc-text-xs plc-text-gray-400"
21464
- }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, this.site.default_locale)))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21541
+ }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21465
21542
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(sub).bgColor} plc-uppercase ${this.getSubscriptionStatus(sub).textColor} plc-rounded-lg`
21466
21543
  }, this.getSubscriptionStatus(sub).icon, this.getSubscriptionStatus(sub).title), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("div", {
21467
21544
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
@@ -21564,7 +21641,7 @@ class Dashboard extends React.Component {
21564
21641
  className: "plc-font-semibold plc-text-gray-500"
21565
21642
  }, recipient.plan.nickname), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
21566
21643
  className: "plc-text-xs plc-text-gray-400"
21567
- }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, this.site.default_locale)))), recipient.status && /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21644
+ }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, getPageOrDefaultLanguage())))), recipient.status && /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21568
21645
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(recipient).bgColor} plc-uppercase ${this.getSubscriptionStatus(recipient).textColor} plc-rounded-lg`
21569
21646
  }, this.getSubscriptionStatus(recipient).icon, this.getSubscriptionStatus(recipient).title), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("div", {
21570
21647
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
package/dist/index.esm.js CHANGED
@@ -4464,7 +4464,7 @@ var messages$2 = {
4464
4464
  isSureToCancel: "Êtes-vous certain de vouloir annuler votre abonnement?",
4465
4465
  loading: "Annulation de l'abonnement",
4466
4466
  success: "L'abonnement a été annulé avec succès",
4467
- error: "Une erreure s'est produite lors de l'annulation de l'abonnement"
4467
+ error: "Une erreur s'est produite lors de l'annulation de l'abonnement"
4468
4468
  }
4469
4469
  };
4470
4470
  var dashboard_fr = {
@@ -6297,13 +6297,34 @@ const getAddressById = id => {
6297
6297
  };
6298
6298
  /**
6299
6299
  * Transforms locale names stored in our backend like
6300
- * "en_US" into the standerd accepted in core i18n methods: "en-US"
6300
+ * "en_US" into the standard accepted in core i18n methods: "en-US"
6301
6301
  * @param {string} localeName
6302
6302
  * @return {string | undefined}
6303
6303
  * @example getCanonicalLocaleFormat("en_US") => "en-US"
6304
6304
  */
6305
6305
 
6306
6306
  const getCanonicalLocaleFormat = localeName => localeName === null || localeName === void 0 ? void 0 : localeName.replace("_", "-");
6307
+ /**
6308
+ * @param {string} localeName
6309
+ * @return {string | undefined}
6310
+ * @example getLanguageWithoutRegion("en-US") => "en"
6311
+ */
6312
+
6313
+ const getLanguageWithoutRegion = localeName => {
6314
+ var _getCanonicalLocaleFo;
6315
+
6316
+ return (_getCanonicalLocaleFo = getCanonicalLocaleFormat(localeName)) === null || _getCanonicalLocaleFo === void 0 ? void 0 : _getCanonicalLocaleFo.split("-")[0];
6317
+ };
6318
+ /**
6319
+ * Gets the current page language or fallbacks to site default
6320
+ * @return {string | undefined}
6321
+ */
6322
+
6323
+ const getPageOrDefaultLanguage = () => {
6324
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6325
+
6326
+ return (_window$Pelcro$helper = window.Pelcro.helpers.getHtmlLanguageAttribute()) !== null && _window$Pelcro$helper !== void 0 ? _window$Pelcro$helper : getLanguageWithoutRegion((_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale);
6327
+ };
6307
6328
  /**
6308
6329
  * Returns a formatted price string depending on locale
6309
6330
  * @param {number} amount
@@ -6313,7 +6334,7 @@ const getCanonicalLocaleFormat = localeName => localeName === null || localeName
6313
6334
  * @example getFormattedPriceByLocal(10, 'USD', 'en-US') => "$10.00"
6314
6335
  */
6315
6336
 
6316
- const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en-US") => {
6337
+ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6317
6338
  const formatter = new Intl.NumberFormat(getCanonicalLocaleFormat(locale), {
6318
6339
  style: "currency",
6319
6340
  currency
@@ -6338,8 +6359,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6338
6359
  totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6339
6360
  }
6340
6361
 
6341
- const locale = window.Pelcro.site.read().default_locale;
6342
- return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, locale);
6362
+ return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
6343
6363
  };
6344
6364
  /**
6345
6365
  * returns true if the URL contains a supported view trigger URL
@@ -6353,12 +6373,15 @@ const isValidViewFromURL = viewID => {
6353
6373
  }
6354
6374
 
6355
6375
  return false;
6376
+ /**
6377
+ *
6378
+ */
6356
6379
 
6357
6380
  function hasValidNewsletterUpdateUrl() {
6358
- var _window$Pelcro, _window$Pelcro$uiSett;
6381
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
6359
6382
 
6360
6383
  if (viewID !== "newsletter-update") return false;
6361
- const newsletters = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.newsletters;
6384
+ const newsletters = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$uiSet = _window$Pelcro2.uiSettings) === null || _window$Pelcro2$uiSet === void 0 ? void 0 : _window$Pelcro2$uiSet.newsletters;
6362
6385
  const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6363
6386
 
6364
6387
  if (!siteHasNewslettersDefined) {
@@ -6531,10 +6554,20 @@ const getPaymentCardIcon$1 = name => {
6531
6554
  d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
6532
6555
  }));
6533
6556
  };
6557
+ /**
6558
+ * Gets the current date with time set to 0
6559
+ * @param {Date} dateObject
6560
+ * @return {Date}
6561
+ */
6562
+
6563
+ function getDateWithoutTime(dateObject) {
6564
+ const date = new Date(dateObject.getTime());
6565
+ date.setHours(0, 0, 0, 0);
6566
+ return date;
6567
+ }
6534
6568
 
6535
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6536
6569
  const resources = {
6537
- "en-US": {
6570
+ en: {
6538
6571
  common: common_en,
6539
6572
  paymentMethod: paymentMethod_en,
6540
6573
  newsletter: newsletter_en,
@@ -6556,7 +6589,7 @@ const resources = {
6556
6589
  select: select_en,
6557
6590
  notification: notification_en
6558
6591
  },
6559
- "fr-CA": {
6592
+ fr: {
6560
6593
  common: common_fr,
6561
6594
  paymentMethod: paymentMethod_fr,
6562
6595
  newsletter: newsletter_fr,
@@ -6578,13 +6611,14 @@ const resources = {
6578
6611
  select: select_fr,
6579
6612
  notification: notification_fr
6580
6613
  }
6581
- };
6582
- let locale = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale;
6583
- if (!locale) locale = "en-US";
6614
+ }; // set UI language to the page language or default to the language in site settings
6615
+
6616
+ const locale = getPageOrDefaultLanguage();
6584
6617
  i18next.use(initReactI18next) // passes i18n down to react-i18next,
6585
6618
  .init({
6586
6619
  resources,
6587
- lng: getCanonicalLocaleFormat(locale),
6620
+ lng: locale,
6621
+ fallbackLng: "en",
6588
6622
  // debug: true,
6589
6623
  interpolation: {
6590
6624
  escapeValue: false // react already safes from xss
@@ -6595,6 +6629,16 @@ i18next.use(initReactI18next) // passes i18n down to react-i18next,
6595
6629
 
6596
6630
  }
6597
6631
  });
6632
+ const pageLanguageObserver = new MutationObserver(mutationsList => {
6633
+ mutationsList.forEach(mutationRecord => {
6634
+ if (mutationRecord.attributeName === "lang") {
6635
+ i18next.changeLanguage(window.Pelcro.helpers.getHtmlLanguageAttribute());
6636
+ }
6637
+ });
6638
+ });
6639
+ pageLanguageObserver.observe(document.documentElement, {
6640
+ attributes: true
6641
+ });
6598
6642
 
6599
6643
  function _classPrivateFieldGet(receiver, privateMap) {
6600
6644
  var descriptor = privateMap.get(receiver);
@@ -8402,6 +8446,7 @@ const optionsController = options => {
8402
8446
  enableURLTriggers: initViewFromURL,
8403
8447
  enableTheme: applyPelcroTheme,
8404
8448
  enablePaywalls: initPaywalls,
8449
+ loadSecuritySDK: initSecuritySdk,
8405
8450
  enableGoogleAnalytics: initGATracking
8406
8451
  }; // Only execute enabled options
8407
8452
 
@@ -8463,6 +8508,18 @@ const loadPaymentSDKs = () => {
8463
8508
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8464
8509
  }
8465
8510
  };
8511
+ const initSecuritySdk = () => {
8512
+ const {
8513
+ whenSiteReady
8514
+ } = usePelcro.getStore();
8515
+ whenSiteReady(() => {
8516
+ var _window$Pelcro$site$r2;
8517
+
8518
+ const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
8519
+ if (!securityKey) return;
8520
+ window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
8521
+ });
8522
+ };
8466
8523
  const initGATracking = () => {
8467
8524
  var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
8468
8525
 
@@ -8549,9 +8606,9 @@ const applyPelcroTheme = () => {
8549
8606
  };
8550
8607
 
8551
8608
  whenSiteReady(() => {
8552
- var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
8609
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
8553
8610
 
8554
- const primaryColorHex = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : (_window$Pelcro$site$r3 = _window$Pelcro$site$r2.design_settings) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.primary_color;
8611
+ const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
8555
8612
 
8556
8613
  if (!primaryColorHex) {
8557
8614
  return;
@@ -8750,6 +8807,7 @@ const defaultOptions = {
8750
8807
  enableURLTriggers: true,
8751
8808
  enableTheme: true,
8752
8809
  enablePaywalls: true,
8810
+ loadSecuritySDK: true,
8753
8811
  enableGoogleAnalytics: false
8754
8812
  };
8755
8813
  const PelcroModalController = ({
@@ -9690,35 +9748,53 @@ const RegisterContainer = ({
9690
9748
  jobTitle,
9691
9749
  selectFields
9692
9750
  } = filteredData;
9693
- window.Pelcro.user.register({
9694
- email,
9695
- password,
9696
- first_name: firstName,
9697
- last_name: lastName,
9698
- metadata: {
9699
- organization,
9700
- jobTitle,
9701
- ...selectFields
9702
- }
9703
- }, (err, res) => {
9704
- dispatch({
9705
- type: DISABLE_REGISTRATION_BUTTON,
9706
- payload: false
9751
+
9752
+ if (!hasSecurityTokenEnabled()) {
9753
+ sendRegisterRequest();
9754
+ return;
9755
+ }
9756
+
9757
+ window.grecaptcha.enterprise.ready(async () => {
9758
+ var _window$Pelcro$site$r;
9759
+
9760
+ const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
9761
+ action: "register"
9707
9762
  });
9763
+ sendRegisterRequest(token);
9764
+ });
9708
9765
 
9709
- if (err) {
9766
+ function sendRegisterRequest(securityToken) {
9767
+ window.Pelcro.user.register({
9768
+ email,
9769
+ password,
9770
+ first_name: firstName,
9771
+ last_name: lastName,
9772
+ security_token: securityToken,
9773
+ metadata: {
9774
+ organization,
9775
+ jobTitle,
9776
+ ...selectFields
9777
+ }
9778
+ }, (err, res) => {
9710
9779
  dispatch({
9711
- type: SHOW_ALERT,
9712
- payload: {
9713
- type: "error",
9714
- content: getErrorMessages(err)
9715
- }
9780
+ type: DISABLE_REGISTRATION_BUTTON,
9781
+ payload: false
9716
9782
  });
9717
- onFailure(err);
9718
- } else {
9719
- onSuccess(res);
9720
- }
9721
- });
9783
+
9784
+ if (err) {
9785
+ dispatch({
9786
+ type: SHOW_ALERT,
9787
+ payload: {
9788
+ type: "error",
9789
+ content: getErrorMessages(err)
9790
+ }
9791
+ });
9792
+ onFailure(err);
9793
+ } else {
9794
+ onSuccess(res);
9795
+ }
9796
+ });
9797
+ }
9722
9798
  };
9723
9799
 
9724
9800
  const handleSocialLogin = ({
@@ -9869,6 +9945,15 @@ const RegisterContainer = ({
9869
9945
  store: store$e
9870
9946
  })));
9871
9947
  };
9948
+ /**
9949
+ * Checks if the current site has security token enabled
9950
+ * @return {boolean}
9951
+ */
9952
+
9953
+ function hasSecurityTokenEnabled() {
9954
+ const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
9955
+ return hasSecuritySdkLoaded;
9956
+ }
9872
9957
 
9873
9958
  var _path$l;
9874
9959
 
@@ -9890,7 +9975,7 @@ const FacebookLoginButton = ({
9890
9975
  labelClassName = "",
9891
9976
  iconClassName = ""
9892
9977
  }) => {
9893
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9978
+ var _window$Pelcro$site$r;
9894
9979
 
9895
9980
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
9896
9981
  const {
@@ -9929,7 +10014,7 @@ const FacebookLoginButton = ({
9929
10014
 
9930
10015
  return facebookLoginEnabled ? /*#__PURE__*/React__default.createElement(FacebookLogin, {
9931
10016
  appId: window.Pelcro.site.read().facebook_app_id,
9932
- language: (_window$Pelcro$site$r2 = window.Pelcro.site.read().default_locale) !== null && _window$Pelcro$site$r2 !== void 0 ? _window$Pelcro$site$r2 : "en_US",
10017
+ language: getPageOrDefaultLanguage(),
9933
10018
  fields: "first_name,last_name,email,picture",
9934
10019
  callback: onSuccess,
9935
10020
  onFailure: onFailure,
@@ -10258,8 +10343,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Pass
10258
10343
  const RegisterButton = ({
10259
10344
  name,
10260
10345
  onClick,
10346
+ className,
10261
10347
  ...otherProps
10262
10348
  }) => {
10349
+ var _window$Pelcro$site$r;
10350
+
10263
10351
  const {
10264
10352
  state: {
10265
10353
  emailError,
@@ -10285,7 +10373,10 @@ const RegisterButton = ({
10285
10373
  onClick === null || onClick === void 0 ? void 0 : onClick();
10286
10374
  },
10287
10375
  disabled: isDisabled,
10288
- isLoading: buttonDisabled
10376
+ isLoading: buttonDisabled,
10377
+ className: `${className} g-recaptcha`,
10378
+ "data-action": "register",
10379
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
10289
10380
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
10290
10381
  };
10291
10382
 
@@ -13463,7 +13554,7 @@ const PaymentMethodContainer = props => {
13463
13554
  return /*#__PURE__*/React__default.createElement(es_13, {
13464
13555
  apiKey: window.Pelcro.environment.stripe,
13465
13556
  stripeAccount: window.Pelcro.site.read().account_id,
13466
- locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13557
+ locale: getPageOrDefaultLanguage()
13467
13558
  }, /*#__PURE__*/React__default.createElement(es_11, null, /*#__PURE__*/React__default.createElement(UnwrappedForm, Object.assign({
13468
13559
  store: store$d
13469
13560
  }, props))));
@@ -13575,9 +13666,6 @@ const DiscountedPrice = props => {
13575
13666
  percentOff
13576
13667
  }
13577
13668
  } = useContext(store$d);
13578
- const {
13579
- default_locale
13580
- } = Pelcro.site.read();
13581
13669
  const {
13582
13670
  order,
13583
13671
  plan
@@ -13585,7 +13673,7 @@ const DiscountedPrice = props => {
13585
13673
  const ecommOrderCurrency = (_order$currency = order === null || order === void 0 ? void 0 : order.currency) !== null && _order$currency !== void 0 ? _order$currency : order === null || order === void 0 ? void 0 : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
13586
13674
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13587
13675
  const discountedPriceWithoutTax = updatedPrice - taxAmount;
13588
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13676
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13589
13677
 
13590
13678
  if (percentOff) {
13591
13679
  return /*#__PURE__*/React__default.createElement("div", Object.assign({
@@ -13618,12 +13706,9 @@ const SubmitPaymentMethod = ({
13618
13706
  updatedPrice
13619
13707
  }
13620
13708
  } = useContext(store$d);
13621
- const {
13622
- default_locale
13623
- } = Pelcro.site.read();
13624
13709
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13625
13710
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
13626
- const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13711
+ const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13627
13712
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
13628
13713
  role: "submit",
13629
13714
  className: "plc-w-full plc-py-3",
@@ -13868,7 +13953,7 @@ class PaypalClient {
13868
13953
  this.paypalButton = window.paypal.Buttons({
13869
13954
  fundingSource: window.paypal.FUNDING.PAYPAL,
13870
13955
  // button locale
13871
- locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : this.siteInfo.default_locale,
13956
+ locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : getPageOrDefaultLanguage(),
13872
13957
  // button style
13873
13958
  style: (_this$config$style = this.config.style) !== null && _this$config$style !== void 0 ? _this$config$style : defaultButtonStyle,
13874
13959
  // create payment handler
@@ -13965,7 +14050,7 @@ class PaypalClient {
13965
14050
  } : undefined,
13966
14051
  shippingAddressEditable: this.config.shippingAddressEditable,
13967
14052
  displayName: (_this$config$displayN = this.config.displayName) !== null && _this$config$displayN !== void 0 ? _this$config$displayN : this.siteInfo.name,
13968
- locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : this.siteInfo.default_locale
14053
+ locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : getPageOrDefaultLanguage()
13969
14054
  };
13970
14055
  }
13971
14056
  });
@@ -13974,7 +14059,7 @@ class PaypalClient {
13974
14059
  writable: true,
13975
14060
  value: () => {
13976
14061
  const totalAmount = (this.product.quantity || 1) * this.amount;
13977
- const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, this.siteInfo.default_locale);
14062
+ const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, getPageOrDefaultLanguage());
13978
14063
  const autoRenewed = this.product.auto_renew;
13979
14064
  const {
13980
14065
  interval,
@@ -14171,14 +14256,11 @@ const TaxAmount = () => {
14171
14256
  taxAmount
14172
14257
  }
14173
14258
  } = useContext(store$d);
14174
- const {
14175
- default_locale
14176
- } = Pelcro.site.read();
14177
14259
  const {
14178
14260
  plan
14179
14261
  } = usePelcro();
14180
14262
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14181
- const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14263
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14182
14264
 
14183
14265
  if (taxAmount) {
14184
14266
  return /*#__PURE__*/React__default.createElement("div", {
@@ -15051,10 +15133,7 @@ const SubscriptionCreateView = ({
15051
15133
  interval,
15052
15134
  count: interval_count
15053
15135
  });
15054
- const {
15055
- default_locale
15056
- } = Pelcro.site.read();
15057
- const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
15136
+ const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
15058
15137
  return /*#__PURE__*/React__default.createElement("p", {
15059
15138
  className: "plc-text-gray-600"
15060
15139
  }, /*#__PURE__*/React__default.createElement("span", {
@@ -18231,7 +18310,6 @@ const OrderConfirmModal = props => {
18231
18310
  const userOrders = window.Pelcro.user.read().orders;
18232
18311
  const latestOrder = userOrders === null || userOrders === void 0 ? void 0 : userOrders[userOrders.length - 1];
18233
18312
  const latestOrderDiscount = latestOrder === null || latestOrder === void 0 ? void 0 : (_latestOrder$coupon = latestOrder.coupon) === null || _latestOrder$coupon === void 0 ? void 0 : _latestOrder$coupon.percent_off;
18234
- const locale = window.Pelcro.site.read().default_locale;
18235
18313
  const {
18236
18314
  t
18237
18315
  } = useTranslation("shop");
@@ -18290,7 +18368,7 @@ const OrderConfirmModal = props => {
18290
18368
  className: "plc-mr-1 pelcro-summary-total-text"
18291
18369
  }, t("labels.total")), /*#__PURE__*/React__default.createElement("p", {
18292
18370
  className: "pelcro-summary-total"
18293
- }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, locale)))), /*#__PURE__*/React__default.createElement("div", {
18371
+ }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("div", {
18294
18372
  className: "plc-flex plc-justify-center plc-mt-6"
18295
18373
  }, /*#__PURE__*/React__default.createElement(Button, {
18296
18374
  id: "pelcro-submit",
@@ -18352,9 +18430,9 @@ const GiftCreateContainer = ({
18352
18430
  }
18353
18431
 
18354
18432
  if (giftRecipient.startDate) {
18355
- const nowDate = new Date();
18356
- const yearFromNowDate = new Date(new Date().setFullYear(nowDate.getFullYear() + 1));
18357
- const submittedDate = new Date(giftRecipient.startDate);
18433
+ const nowDate = getDateWithoutTime(new Date());
18434
+ const yearFromNowDate = getDateWithoutTime(new Date(new Date().setFullYear(nowDate.getFullYear() + 1)));
18435
+ const submittedDate = getDateWithoutTime(new Date(giftRecipient.startDate));
18358
18436
 
18359
18437
  if (submittedDate < nowDate || submittedDate > yearFromNowDate) {
18360
18438
  dispatch({
@@ -20659,7 +20737,6 @@ const OrderItems = ({
20659
20737
  const {
20660
20738
  t
20661
20739
  } = useTranslation("dashboard");
20662
- const site = window.Pelcro.site.read();
20663
20740
  return !(orders !== null && orders !== void 0 && orders.length) ? /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20664
20741
  colSpan: "3",
20665
20742
  className: "plc-text-center plc-text-gray-500"
@@ -20675,7 +20752,7 @@ const OrderItems = ({
20675
20752
  className: "plc-py-4 plc-pl-2"
20676
20753
  }, /*#__PURE__*/React__default.createElement("span", {
20677
20754
  className: "plc-text-xl plc-font-semibold "
20678
- }, getFormattedPriceByLocal(order.amount, order.currency, site.default_locale)), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20755
+ }, getFormattedPriceByLocal(order.amount, order.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20679
20756
  className: "plc-text-xs plc-text-gray-400 plc-uppercase"
20680
20757
  }, t("labels.orders.itemsAmount", {
20681
20758
  count: getItemsAmount(order.id)
@@ -20704,7 +20781,7 @@ const OrderItems = ({
20704
20781
  className: ""
20705
20782
  }, item.product_sku_name))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
20706
20783
  className: "plc-font-semibold"
20707
- }, getFormattedPriceByLocal(item.amount, order.currency, site.default_locale))));
20784
+ }, getFormattedPriceByLocal(item.amount, order.currency, getPageOrDefaultLanguage()))));
20708
20785
  }), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20709
20786
  colSpan: "3"
20710
20787
  }, /*#__PURE__*/React__default.createElement("hr", {
@@ -21431,7 +21508,7 @@ class Dashboard extends Component {
21431
21508
  className: "plc-font-semibold plc-text-gray-500"
21432
21509
  }, sub.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
21433
21510
  className: "plc-text-xs plc-text-gray-400"
21434
- }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, this.site.default_locale)))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21511
+ }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21435
21512
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(sub).bgColor} plc-uppercase ${this.getSubscriptionStatus(sub).textColor} plc-rounded-lg`
21436
21513
  }, this.getSubscriptionStatus(sub).icon, this.getSubscriptionStatus(sub).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21437
21514
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
@@ -21534,7 +21611,7 @@ class Dashboard extends Component {
21534
21611
  className: "plc-font-semibold plc-text-gray-500"
21535
21612
  }, recipient.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
21536
21613
  className: "plc-text-xs plc-text-gray-400"
21537
- }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, this.site.default_locale)))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21614
+ }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, getPageOrDefaultLanguage())))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21538
21615
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(recipient).bgColor} plc-uppercase ${this.getSubscriptionStatus(recipient).textColor} plc-rounded-lg`
21539
21616
  }, this.getSubscriptionStatus(recipient).icon, this.getSubscriptionStatus(recipient).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21540
21617
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
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": "2.6.0-beta.3",
4
+ "version": "2.6.0-beta.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",