@pelcro/react-pelcro-js 3.2.0-beta.20 → 3.2.0-beta.23

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
@@ -6469,10 +6469,10 @@ if (process.env.NODE_ENV === "development") {
6469
6469
  /**
6470
6470
  * List of zero-decimal currencies.
6471
6471
  * @see https://stripe.com/docs/currencies#zero-decimal
6472
- *
6472
+ *
6473
6473
  */
6474
6474
 
6475
- const ZERO_DECIMAL_CURRENCIES = ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
6475
+ const ZERO_DECIMAL_CURRENCIES = ["BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW", "MGA", "PYG", "RWF", "UGX", "VND", "VUV", "XAF", "XOF", "XPF"];
6476
6476
  /**
6477
6477
  * @param {string}
6478
6478
  * @return {boolean}
@@ -9776,6 +9776,7 @@ function Email({
9776
9776
  initWithUserEmail = true,
9777
9777
  disableEmailValidation,
9778
9778
  store,
9779
+ enableEmailEdit,
9779
9780
  ...otherProps
9780
9781
  }) {
9781
9782
  const {
@@ -9801,6 +9802,10 @@ function Email({
9801
9802
  }
9802
9803
 
9803
9804
  if (isEmailValid(email)) {
9805
+ dispatch({
9806
+ type: SET_EMAIL_ERROR,
9807
+ payload: null
9808
+ });
9804
9809
  return dispatch({
9805
9810
  type: SET_EMAIL,
9806
9811
  payload: email
@@ -9821,6 +9826,11 @@ function Email({
9821
9826
  }
9822
9827
  }
9823
9828
  }, [dispatch, email, finishedTyping]);
9829
+ React.useEffect(() => {
9830
+ if (!enableEmailEdit) {
9831
+ loadEmailIntoField();
9832
+ }
9833
+ }, [enableEmailEdit]);
9824
9834
  React.useEffect(() => {
9825
9835
  handleInputChange(email);
9826
9836
  }, [finishedTyping, email, handleInputChange]); // Initialize email field with user's email
@@ -16522,6 +16532,7 @@ SubscriptionCreateModal.viewId = "subscription-create";
16522
16532
  var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
16523
16533
  const initialState$e = {
16524
16534
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
16535
+ emailError: null,
16525
16536
  firstName: (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.first_name,
16526
16537
  lastName: (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.last_name,
16527
16538
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
@@ -16640,6 +16651,11 @@ const UserUpdateContainer = ({
16640
16651
  email: action.payload
16641
16652
  });
16642
16653
 
16654
+ case SET_EMAIL_ERROR:
16655
+ return lib_7({ ...state,
16656
+ emailError: action.payload
16657
+ });
16658
+
16643
16659
  case SET_FIRST_NAME:
16644
16660
  return lib_7({ ...state,
16645
16661
  firstName: action.payload
@@ -16696,9 +16712,67 @@ const UserUpdateContainer = ({
16696
16712
  })));
16697
16713
  };
16698
16714
 
16699
- const UserUpdateEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
16700
- store: store$e
16701
- }, props));
16715
+ var _path$i;
16716
+
16717
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16718
+
16719
+ function SvgEdit(props) {
16720
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
16721
+ className: "plc-w-6 plc-h-6",
16722
+ xmlns: "http://www.w3.org/2000/svg",
16723
+ viewBox: "0 0 20 20",
16724
+ fill: "currentColor"
16725
+ }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
16726
+ d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16727
+ })));
16728
+ }
16729
+
16730
+ const UserUpdateEmail = props => {
16731
+ const {
16732
+ dispatch,
16733
+ state: {
16734
+ email,
16735
+ emailError
16736
+ }
16737
+ } = React.useContext(store$e);
16738
+ const [enableEmailEdit, setEnableEmailEdit] = React.useState(false);
16739
+ const {
16740
+ t
16741
+ } = useTranslation("userEdit");
16742
+
16743
+ const handleEnableEmailEdit = () => {
16744
+ if (enableEmailEdit) {
16745
+ dispatch({
16746
+ type: SET_EMAIL,
16747
+ payload: email
16748
+ });
16749
+ dispatch({
16750
+ type: SET_EMAIL_ERROR,
16751
+ payload: null
16752
+ });
16753
+ setEnableEmailEdit(false);
16754
+ } else {
16755
+ setEnableEmailEdit(true);
16756
+ }
16757
+ };
16758
+
16759
+ return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
16760
+ className: "plc-flex plc-items-start plc-relative"
16761
+ }, /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
16762
+ disabled: !enableEmailEdit,
16763
+ store: store$e,
16764
+ label: t("labels.email"),
16765
+ enableEmailEdit: enableEmailEdit
16766
+ }, props)), /*#__PURE__*/React__default['default'].createElement(Button, {
16767
+ variant: "icon",
16768
+ className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-7 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
16769
+ icon: enableEmailEdit ? /*#__PURE__*/React__default['default'].createElement(SvgXIcon, {
16770
+ className: "plc-w-6"
16771
+ }) : /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
16772
+ id: "pelcro-user-update-picture-button",
16773
+ onClick: handleEnableEmailEdit
16774
+ })));
16775
+ };
16702
16776
 
16703
16777
  const UserUpdateButton = ({
16704
16778
  name,
@@ -16707,7 +16781,8 @@ const UserUpdateButton = ({
16707
16781
  }) => {
16708
16782
  const {
16709
16783
  state: {
16710
- buttonDisabled
16784
+ buttonDisabled,
16785
+ emailError
16711
16786
  },
16712
16787
  dispatch
16713
16788
  } = React.useContext(store$e);
@@ -16721,8 +16796,8 @@ const UserUpdateButton = ({
16721
16796
  });
16722
16797
  onClick === null || onClick === void 0 ? void 0 : onClick();
16723
16798
  },
16724
- disabled: buttonDisabled,
16725
- isLoading: buttonDisabled
16799
+ disabled: buttonDisabled || emailError,
16800
+ isLoading: buttonDisabled && !emailError
16726
16801
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
16727
16802
  };
16728
16803
 
@@ -16765,21 +16840,6 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default['default'].createEl
16765
16840
 
16766
16841
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
16767
16842
 
16768
- var _path$i;
16769
-
16770
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16771
-
16772
- function SvgEdit(props) {
16773
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
16774
- className: "plc-w-6 plc-h-6",
16775
- xmlns: "http://www.w3.org/2000/svg",
16776
- viewBox: "0 0 20 20",
16777
- fill: "currentColor"
16778
- }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
16779
- d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16780
- })));
16781
- }
16782
-
16783
16843
  const UserUpdateProfilePic = ({
16784
16844
  onClick,
16785
16845
  ...otherProps
@@ -16820,18 +16880,14 @@ const UserUpdateView = props => {
16820
16880
  className: "plc-mt-2 pelcro-form"
16821
16881
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdateContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(UserUpdateProfilePic, {
16822
16882
  onClick: props.onPictureClick
16823
- }), /*#__PURE__*/React__default['default'].createElement("div", {
16824
- className: "plc-flex plc-items-start"
16825
- }, /*#__PURE__*/React__default['default'].createElement(UserUpdateEmail, {
16826
- label: t("labels.email"),
16827
- autoFocus: true
16828
- })), /*#__PURE__*/React__default['default'].createElement("div", {
16883
+ }), /*#__PURE__*/React__default['default'].createElement(UserUpdateEmail, null), /*#__PURE__*/React__default['default'].createElement("div", {
16829
16884
  className: "plc-flex plc-items-start"
16830
16885
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdateFirstName, {
16831
16886
  autoComplete: "first-name",
16832
16887
  id: "pelcro-input-first-name",
16833
16888
  errorId: "pelcro-input-first-name-error",
16834
- label: t("labels.firstName")
16889
+ label: t("labels.firstName"),
16890
+ autoFocus: true
16835
16891
  }), /*#__PURE__*/React__default['default'].createElement(UserUpdateLastName, {
16836
16892
  wrapperClassName: "plc-ml-3",
16837
16893
  autoComplete: "last-name",
@@ -19359,6 +19415,7 @@ const CartRemoveItemButton = ({
19359
19415
 
19360
19416
  const CartSubmit = ({
19361
19417
  name,
19418
+ onClick,
19362
19419
  ...otherProps
19363
19420
  }) => {
19364
19421
  const {
@@ -19371,9 +19428,12 @@ const CartSubmit = ({
19371
19428
  t
19372
19429
  } = useTranslation("cart");
19373
19430
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({}, otherProps, {
19374
- onClick: () => dispatch({
19375
- type: HANDLE_SUBMIT
19376
- }),
19431
+ onClick: () => {
19432
+ dispatch({
19433
+ type: HANDLE_SUBMIT
19434
+ });
19435
+ onClick === null || onClick === void 0 ? void 0 : onClick();
19436
+ },
19377
19437
  disabled: buttonDisabled
19378
19438
  }), name !== null && name !== void 0 ? name : t("confirm"));
19379
19439
  };
@@ -19417,6 +19477,53 @@ const CartTotalPrice = () => {
19417
19477
  return null;
19418
19478
  };
19419
19479
 
19480
+ // Polyfill
19481
+ (() => {
19482
+ if (typeof window.CustomEvent === "function") return false;
19483
+
19484
+ function CustomEvent(event, params = {
19485
+ bubbles: false,
19486
+ cancelable: false,
19487
+ detail: undefined
19488
+ }) {
19489
+ const evt = document.createEvent("CustomEvent");
19490
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
19491
+ return evt;
19492
+ }
19493
+
19494
+ CustomEvent.prototype = window.Event.prototype;
19495
+ window.CustomEvent = CustomEvent;
19496
+ })();
19497
+ /**
19498
+ * Should fire when the cart is opened and expects the cartItems inside the card to be sent
19499
+ */
19500
+
19501
+
19502
+ const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
19503
+ /**
19504
+ * Should fire when an item added to the cart and expects the added item to be sent
19505
+ */
19506
+
19507
+ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
19508
+ /**
19509
+ * Should fire when an item removed from the cart and expects the removed item to be sent
19510
+ */
19511
+
19512
+ const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
19513
+ /**
19514
+ * Check if the browser support custom events
19515
+ */
19516
+
19517
+ function createCustomEvent(name, detail) {
19518
+ try {
19519
+ return new CustomEvent(name, {
19520
+ detail
19521
+ });
19522
+ } catch (e) {
19523
+ console.warn("Pelcro - Events are not supported in the browser");
19524
+ }
19525
+ }
19526
+
19420
19527
  const CartView = props => {
19421
19528
  const {
19422
19529
  cartItems
@@ -19424,6 +19531,9 @@ const CartView = props => {
19424
19531
  const {
19425
19532
  t
19426
19533
  } = useTranslation("cart");
19534
+ React.useEffect(() => {
19535
+ document.dispatchEvent(cartOpened(cartItems));
19536
+ }, []);
19427
19537
  return /*#__PURE__*/React__default['default'].createElement("div", {
19428
19538
  id: "pelcro-cart-view"
19429
19539
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -19453,7 +19563,8 @@ const CartView = props => {
19453
19563
  }, calcAndFormatItemsTotal([item], item.currency)), /*#__PURE__*/React__default['default'].createElement(CartRemoveItemButton, {
19454
19564
  itemId: item.id,
19455
19565
  id: `pelcro-remove-product-${item.id}`,
19456
- "aria-label": "remove item from cart"
19566
+ "aria-label": "remove item from cart",
19567
+ onClick: () => document.dispatchEvent(cartItemRemoved(item))
19457
19568
  }));
19458
19569
  })), /*#__PURE__*/React__default['default'].createElement("div", {
19459
19570
  className: "plc-flex plc-items-center plc-justify-end plc-pt-2 plc-mt-2 plc-font-bold plc-border-t plc-border-gray-400 pelcro-cart-total-wrapper"
@@ -19574,7 +19685,8 @@ const ShopView = () => {
19574
19685
  className: "plc-font-bold pelcro-shop-product-description"
19575
19686
  }, item.description), /*#__PURE__*/React__default['default'].createElement(ShopSelectProductButton, {
19576
19687
  itemId: item.id,
19577
- className: "plc-mt-2"
19688
+ className: "plc-mt-2",
19689
+ onClick: () => document.dispatchEvent(cartItemAdded(item))
19578
19690
  }), /*#__PURE__*/React__default['default'].createElement(ShopPurchaseButton, {
19579
19691
  itemId: item.id,
19580
19692
  className: "plc-mt-2"
package/dist/index.esm.js CHANGED
@@ -6439,10 +6439,10 @@ if (process.env.NODE_ENV === "development") {
6439
6439
  /**
6440
6440
  * List of zero-decimal currencies.
6441
6441
  * @see https://stripe.com/docs/currencies#zero-decimal
6442
- *
6442
+ *
6443
6443
  */
6444
6444
 
6445
- const ZERO_DECIMAL_CURRENCIES = ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
6445
+ const ZERO_DECIMAL_CURRENCIES = ["BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW", "MGA", "PYG", "RWF", "UGX", "VND", "VUV", "XAF", "XOF", "XPF"];
6446
6446
  /**
6447
6447
  * @param {string}
6448
6448
  * @return {boolean}
@@ -9746,6 +9746,7 @@ function Email({
9746
9746
  initWithUserEmail = true,
9747
9747
  disableEmailValidation,
9748
9748
  store,
9749
+ enableEmailEdit,
9749
9750
  ...otherProps
9750
9751
  }) {
9751
9752
  const {
@@ -9771,6 +9772,10 @@ function Email({
9771
9772
  }
9772
9773
 
9773
9774
  if (isEmailValid(email)) {
9775
+ dispatch({
9776
+ type: SET_EMAIL_ERROR,
9777
+ payload: null
9778
+ });
9774
9779
  return dispatch({
9775
9780
  type: SET_EMAIL,
9776
9781
  payload: email
@@ -9791,6 +9796,11 @@ function Email({
9791
9796
  }
9792
9797
  }
9793
9798
  }, [dispatch, email, finishedTyping]);
9799
+ useEffect(() => {
9800
+ if (!enableEmailEdit) {
9801
+ loadEmailIntoField();
9802
+ }
9803
+ }, [enableEmailEdit]);
9794
9804
  useEffect(() => {
9795
9805
  handleInputChange(email);
9796
9806
  }, [finishedTyping, email, handleInputChange]); // Initialize email field with user's email
@@ -16492,6 +16502,7 @@ SubscriptionCreateModal.viewId = "subscription-create";
16492
16502
  var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
16493
16503
  const initialState$e = {
16494
16504
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
16505
+ emailError: null,
16495
16506
  firstName: (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.first_name,
16496
16507
  lastName: (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.last_name,
16497
16508
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
@@ -16610,6 +16621,11 @@ const UserUpdateContainer = ({
16610
16621
  email: action.payload
16611
16622
  });
16612
16623
 
16624
+ case SET_EMAIL_ERROR:
16625
+ return lib_7({ ...state,
16626
+ emailError: action.payload
16627
+ });
16628
+
16613
16629
  case SET_FIRST_NAME:
16614
16630
  return lib_7({ ...state,
16615
16631
  firstName: action.payload
@@ -16666,9 +16682,67 @@ const UserUpdateContainer = ({
16666
16682
  })));
16667
16683
  };
16668
16684
 
16669
- const UserUpdateEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
16670
- store: store$e
16671
- }, props));
16685
+ var _path$i;
16686
+
16687
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16688
+
16689
+ function SvgEdit(props) {
16690
+ return /*#__PURE__*/React.createElement("svg", _extends$k({
16691
+ className: "plc-w-6 plc-h-6",
16692
+ xmlns: "http://www.w3.org/2000/svg",
16693
+ viewBox: "0 0 20 20",
16694
+ fill: "currentColor"
16695
+ }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
16696
+ d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16697
+ })));
16698
+ }
16699
+
16700
+ const UserUpdateEmail = props => {
16701
+ const {
16702
+ dispatch,
16703
+ state: {
16704
+ email,
16705
+ emailError
16706
+ }
16707
+ } = useContext(store$e);
16708
+ const [enableEmailEdit, setEnableEmailEdit] = useState(false);
16709
+ const {
16710
+ t
16711
+ } = useTranslation("userEdit");
16712
+
16713
+ const handleEnableEmailEdit = () => {
16714
+ if (enableEmailEdit) {
16715
+ dispatch({
16716
+ type: SET_EMAIL,
16717
+ payload: email
16718
+ });
16719
+ dispatch({
16720
+ type: SET_EMAIL_ERROR,
16721
+ payload: null
16722
+ });
16723
+ setEnableEmailEdit(false);
16724
+ } else {
16725
+ setEnableEmailEdit(true);
16726
+ }
16727
+ };
16728
+
16729
+ return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
16730
+ className: "plc-flex plc-items-start plc-relative"
16731
+ }, /*#__PURE__*/React__default.createElement(Email, Object.assign({
16732
+ disabled: !enableEmailEdit,
16733
+ store: store$e,
16734
+ label: t("labels.email"),
16735
+ enableEmailEdit: enableEmailEdit
16736
+ }, props)), /*#__PURE__*/React__default.createElement(Button, {
16737
+ variant: "icon",
16738
+ className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-7 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
16739
+ icon: enableEmailEdit ? /*#__PURE__*/React__default.createElement(SvgXIcon, {
16740
+ className: "plc-w-6"
16741
+ }) : /*#__PURE__*/React__default.createElement(SvgEdit, null),
16742
+ id: "pelcro-user-update-picture-button",
16743
+ onClick: handleEnableEmailEdit
16744
+ })));
16745
+ };
16672
16746
 
16673
16747
  const UserUpdateButton = ({
16674
16748
  name,
@@ -16677,7 +16751,8 @@ const UserUpdateButton = ({
16677
16751
  }) => {
16678
16752
  const {
16679
16753
  state: {
16680
- buttonDisabled
16754
+ buttonDisabled,
16755
+ emailError
16681
16756
  },
16682
16757
  dispatch
16683
16758
  } = useContext(store$e);
@@ -16691,8 +16766,8 @@ const UserUpdateButton = ({
16691
16766
  });
16692
16767
  onClick === null || onClick === void 0 ? void 0 : onClick();
16693
16768
  },
16694
- disabled: buttonDisabled,
16695
- isLoading: buttonDisabled
16769
+ disabled: buttonDisabled || emailError,
16770
+ isLoading: buttonDisabled && !emailError
16696
16771
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
16697
16772
  };
16698
16773
 
@@ -16735,21 +16810,6 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default.createElement(Phone
16735
16810
 
16736
16811
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
16737
16812
 
16738
- var _path$i;
16739
-
16740
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16741
-
16742
- function SvgEdit(props) {
16743
- return /*#__PURE__*/React.createElement("svg", _extends$k({
16744
- className: "plc-w-6 plc-h-6",
16745
- xmlns: "http://www.w3.org/2000/svg",
16746
- viewBox: "0 0 20 20",
16747
- fill: "currentColor"
16748
- }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
16749
- d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16750
- })));
16751
- }
16752
-
16753
16813
  const UserUpdateProfilePic = ({
16754
16814
  onClick,
16755
16815
  ...otherProps
@@ -16790,18 +16850,14 @@ const UserUpdateView = props => {
16790
16850
  className: "plc-mt-2 pelcro-form"
16791
16851
  }, /*#__PURE__*/React__default.createElement(UserUpdateContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), /*#__PURE__*/React__default.createElement(UserUpdateProfilePic, {
16792
16852
  onClick: props.onPictureClick
16793
- }), /*#__PURE__*/React__default.createElement("div", {
16794
- className: "plc-flex plc-items-start"
16795
- }, /*#__PURE__*/React__default.createElement(UserUpdateEmail, {
16796
- label: t("labels.email"),
16797
- autoFocus: true
16798
- })), /*#__PURE__*/React__default.createElement("div", {
16853
+ }), /*#__PURE__*/React__default.createElement(UserUpdateEmail, null), /*#__PURE__*/React__default.createElement("div", {
16799
16854
  className: "plc-flex plc-items-start"
16800
16855
  }, /*#__PURE__*/React__default.createElement(UserUpdateFirstName, {
16801
16856
  autoComplete: "first-name",
16802
16857
  id: "pelcro-input-first-name",
16803
16858
  errorId: "pelcro-input-first-name-error",
16804
- label: t("labels.firstName")
16859
+ label: t("labels.firstName"),
16860
+ autoFocus: true
16805
16861
  }), /*#__PURE__*/React__default.createElement(UserUpdateLastName, {
16806
16862
  wrapperClassName: "plc-ml-3",
16807
16863
  autoComplete: "last-name",
@@ -19329,6 +19385,7 @@ const CartRemoveItemButton = ({
19329
19385
 
19330
19386
  const CartSubmit = ({
19331
19387
  name,
19388
+ onClick,
19332
19389
  ...otherProps
19333
19390
  }) => {
19334
19391
  const {
@@ -19341,9 +19398,12 @@ const CartSubmit = ({
19341
19398
  t
19342
19399
  } = useTranslation("cart");
19343
19400
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({}, otherProps, {
19344
- onClick: () => dispatch({
19345
- type: HANDLE_SUBMIT
19346
- }),
19401
+ onClick: () => {
19402
+ dispatch({
19403
+ type: HANDLE_SUBMIT
19404
+ });
19405
+ onClick === null || onClick === void 0 ? void 0 : onClick();
19406
+ },
19347
19407
  disabled: buttonDisabled
19348
19408
  }), name !== null && name !== void 0 ? name : t("confirm"));
19349
19409
  };
@@ -19387,6 +19447,53 @@ const CartTotalPrice = () => {
19387
19447
  return null;
19388
19448
  };
19389
19449
 
19450
+ // Polyfill
19451
+ (() => {
19452
+ if (typeof window.CustomEvent === "function") return false;
19453
+
19454
+ function CustomEvent(event, params = {
19455
+ bubbles: false,
19456
+ cancelable: false,
19457
+ detail: undefined
19458
+ }) {
19459
+ const evt = document.createEvent("CustomEvent");
19460
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
19461
+ return evt;
19462
+ }
19463
+
19464
+ CustomEvent.prototype = window.Event.prototype;
19465
+ window.CustomEvent = CustomEvent;
19466
+ })();
19467
+ /**
19468
+ * Should fire when the cart is opened and expects the cartItems inside the card to be sent
19469
+ */
19470
+
19471
+
19472
+ const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
19473
+ /**
19474
+ * Should fire when an item added to the cart and expects the added item to be sent
19475
+ */
19476
+
19477
+ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
19478
+ /**
19479
+ * Should fire when an item removed from the cart and expects the removed item to be sent
19480
+ */
19481
+
19482
+ const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
19483
+ /**
19484
+ * Check if the browser support custom events
19485
+ */
19486
+
19487
+ function createCustomEvent(name, detail) {
19488
+ try {
19489
+ return new CustomEvent(name, {
19490
+ detail
19491
+ });
19492
+ } catch (e) {
19493
+ console.warn("Pelcro - Events are not supported in the browser");
19494
+ }
19495
+ }
19496
+
19390
19497
  const CartView = props => {
19391
19498
  const {
19392
19499
  cartItems
@@ -19394,6 +19501,9 @@ const CartView = props => {
19394
19501
  const {
19395
19502
  t
19396
19503
  } = useTranslation("cart");
19504
+ useEffect(() => {
19505
+ document.dispatchEvent(cartOpened(cartItems));
19506
+ }, []);
19397
19507
  return /*#__PURE__*/React__default.createElement("div", {
19398
19508
  id: "pelcro-cart-view"
19399
19509
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -19423,7 +19533,8 @@ const CartView = props => {
19423
19533
  }, calcAndFormatItemsTotal([item], item.currency)), /*#__PURE__*/React__default.createElement(CartRemoveItemButton, {
19424
19534
  itemId: item.id,
19425
19535
  id: `pelcro-remove-product-${item.id}`,
19426
- "aria-label": "remove item from cart"
19536
+ "aria-label": "remove item from cart",
19537
+ onClick: () => document.dispatchEvent(cartItemRemoved(item))
19427
19538
  }));
19428
19539
  })), /*#__PURE__*/React__default.createElement("div", {
19429
19540
  className: "plc-flex plc-items-center plc-justify-end plc-pt-2 plc-mt-2 plc-font-bold plc-border-t plc-border-gray-400 pelcro-cart-total-wrapper"
@@ -19544,7 +19655,8 @@ const ShopView = () => {
19544
19655
  className: "plc-font-bold pelcro-shop-product-description"
19545
19656
  }, item.description), /*#__PURE__*/React__default.createElement(ShopSelectProductButton, {
19546
19657
  itemId: item.id,
19547
- className: "plc-mt-2"
19658
+ className: "plc-mt-2",
19659
+ onClick: () => document.dispatchEvent(cartItemAdded(item))
19548
19660
  }), /*#__PURE__*/React__default.createElement(ShopPurchaseButton, {
19549
19661
  itemId: item.id,
19550
19662
  className: "plc-mt-2"
package/dist/pelcro.css CHANGED
@@ -2514,6 +2514,10 @@ in order to scope selectors under pelcro-root
2514
2514
  bottom: 1rem;
2515
2515
  }
2516
2516
 
2517
+ .pelcro-root .plc-top-7 {
2518
+ top: 1.75rem;
2519
+ }
2520
+
2517
2521
  .pelcro-root .plc-top-16 {
2518
2522
  top: 4rem;
2519
2523
  }
@@ -2555,6 +2559,11 @@ in order to scope selectors under pelcro-root
2555
2559
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
2556
2560
  }
2557
2561
 
2562
+ .pelcro-root .focus\:plc-shadow-none:focus {
2563
+ --tw-shadow: 0 0 #0000;
2564
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
2565
+ }
2566
+
2558
2567
  * {
2559
2568
  --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
2560
2569
  --tw-ring-offset-width: 0px;
@@ -2576,6 +2585,12 @@ in order to scope selectors under pelcro-root
2576
2585
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
2577
2586
  }
2578
2587
 
2588
+ .pelcro-root .focus\:plc-ring-0:focus {
2589
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
2590
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
2591
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
2592
+ }
2593
+
2579
2594
  .pelcro-root .focus\:plc-ring-2:focus {
2580
2595
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
2581
2596
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
@@ -2755,6 +2770,11 @@ in order to scope selectors under pelcro-root
2755
2770
  color: rgba(107, 114, 128, var(--tw-text-opacity));
2756
2771
  }
2757
2772
 
2773
+ .pelcro-root .hover\:plc-text-gray-900:hover {
2774
+ --tw-text-opacity: 1;
2775
+ color: rgba(17, 24, 39, var(--tw-text-opacity));
2776
+ }
2777
+
2758
2778
  .pelcro-root .focus\:plc-text-black:focus {
2759
2779
  --tw-text-opacity: 1;
2760
2780
  color: rgba(0, 0, 0, var(--tw-text-opacity));
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.2.0-beta.20",
4
+ "version": "3.2.0-beta.23",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",