@pelcro/react-pelcro-js 3.2.0-beta.30 → 3.2.0-beta.33

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
@@ -6849,6 +6849,53 @@ var ReactGA = _objectSpread({}, Defaults, {
6849
6849
  OutboundLink: OutboundLink
6850
6850
  });
6851
6851
 
6852
+ // Polyfill
6853
+ (() => {
6854
+ if (typeof window.CustomEvent === "function") return false;
6855
+
6856
+ function CustomEvent(event, params = {
6857
+ bubbles: false,
6858
+ cancelable: false,
6859
+ detail: undefined
6860
+ }) {
6861
+ const evt = document.createEvent("CustomEvent");
6862
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
6863
+ return evt;
6864
+ }
6865
+
6866
+ CustomEvent.prototype = window.Event.prototype;
6867
+ window.CustomEvent = CustomEvent;
6868
+ })();
6869
+ /**
6870
+ * Should fire when the cart is opened and expects the cartItems inside the card to be sent
6871
+ */
6872
+
6873
+
6874
+ const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
6875
+ /**
6876
+ * Should fire when an item added to the cart and expects the added item to be sent
6877
+ */
6878
+
6879
+ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
6880
+ /**
6881
+ * Should fire when an item removed from the cart and expects the removed item to be sent
6882
+ */
6883
+
6884
+ const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
6885
+ /**
6886
+ * Check if the browser support custom events
6887
+ */
6888
+
6889
+ function createCustomEvent(name, detail) {
6890
+ try {
6891
+ return new CustomEvent(name, {
6892
+ detail
6893
+ });
6894
+ } catch (e) {
6895
+ console.warn("Pelcro - Events are not supported in the browser");
6896
+ }
6897
+ }
6898
+
6852
6899
  class PelcroActions {
6853
6900
  constructor(storeSetter, storeGetter) {
6854
6901
  _defineProperty$3(this, "resetState", () => {
@@ -7016,8 +7063,10 @@ class PelcroActions {
7016
7063
  if (!itemToAdd) {
7017
7064
  console.error("invalid item SKU id");
7018
7065
  return false;
7019
- }
7066
+ } //Dispatch PelcroElementsCartItemAdded when an item added successfully to the
7067
+
7020
7068
 
7069
+ document.dispatchEvent(cartItemAdded(itemToAdd));
7021
7070
  const {
7022
7071
  cartItems
7023
7072
  } = this.get();
@@ -20523,53 +20572,6 @@ const CartTotalPrice = () => {
20523
20572
  return null;
20524
20573
  };
20525
20574
 
20526
- // Polyfill
20527
- (() => {
20528
- if (typeof window.CustomEvent === "function") return false;
20529
-
20530
- function CustomEvent(event, params = {
20531
- bubbles: false,
20532
- cancelable: false,
20533
- detail: undefined
20534
- }) {
20535
- const evt = document.createEvent("CustomEvent");
20536
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
20537
- return evt;
20538
- }
20539
-
20540
- CustomEvent.prototype = window.Event.prototype;
20541
- window.CustomEvent = CustomEvent;
20542
- })();
20543
- /**
20544
- * Should fire when the cart is opened and expects the cartItems inside the card to be sent
20545
- */
20546
-
20547
-
20548
- const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
20549
- /**
20550
- * Should fire when an item added to the cart and expects the added item to be sent
20551
- */
20552
-
20553
- const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
20554
- /**
20555
- * Should fire when an item removed from the cart and expects the removed item to be sent
20556
- */
20557
-
20558
- const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
20559
- /**
20560
- * Check if the browser support custom events
20561
- */
20562
-
20563
- function createCustomEvent(name, detail) {
20564
- try {
20565
- return new CustomEvent(name, {
20566
- detail
20567
- });
20568
- } catch (e) {
20569
- console.warn("Pelcro - Events are not supported in the browser");
20570
- }
20571
- }
20572
-
20573
20575
  const CartView = props => {
20574
20576
  const {
20575
20577
  cartItems
@@ -20660,7 +20662,7 @@ const CartModal = ({
20660
20662
  CartModal.viewId = "cart";
20661
20663
 
20662
20664
  const ShopSelectProductButton = ({
20663
- item,
20665
+ itemId,
20664
20666
  onClick,
20665
20667
  ...otherProps
20666
20668
  }) => {
@@ -20676,8 +20678,7 @@ const ShopSelectProductButton = ({
20676
20678
  const handleClick = () => {
20677
20679
  setDisabled(true);
20678
20680
  setTextContent(t("buttons.added"));
20679
- addToCart(item.id);
20680
- document.dispatchEvent(cartItemAdded(item));
20681
+ addToCart(itemId);
20681
20682
  onClick === null || onClick === void 0 ? void 0 : onClick();
20682
20683
  setTimeout(() => {
20683
20684
  setDisabled(false);
@@ -20686,8 +20687,8 @@ const ShopSelectProductButton = ({
20686
20687
  };
20687
20688
 
20688
20689
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
20689
- "data-sku-id": item.id,
20690
- id: `pelcro-shop-select-${item.id}`,
20690
+ "data-sku-id": itemId,
20691
+ id: `pelcro-shop-select-${itemId}`,
20691
20692
  onClick: handleClick,
20692
20693
  disabled: disabled
20693
20694
  }, otherProps), textContent);
@@ -20731,7 +20732,7 @@ const ShopView = () => {
20731
20732
  }, item.name), /*#__PURE__*/React__default['default'].createElement("p", {
20732
20733
  className: "plc-font-bold pelcro-shop-product-description"
20733
20734
  }, item.description), /*#__PURE__*/React__default['default'].createElement(ShopSelectProductButton, {
20734
- item: item,
20735
+ itemId: item.id,
20735
20736
  className: "plc-mt-2"
20736
20737
  }), /*#__PURE__*/React__default['default'].createElement(ShopPurchaseButton, {
20737
20738
  itemId: item.id,
package/dist/index.esm.js CHANGED
@@ -6819,6 +6819,53 @@ var ReactGA = _objectSpread({}, Defaults, {
6819
6819
  OutboundLink: OutboundLink
6820
6820
  });
6821
6821
 
6822
+ // Polyfill
6823
+ (() => {
6824
+ if (typeof window.CustomEvent === "function") return false;
6825
+
6826
+ function CustomEvent(event, params = {
6827
+ bubbles: false,
6828
+ cancelable: false,
6829
+ detail: undefined
6830
+ }) {
6831
+ const evt = document.createEvent("CustomEvent");
6832
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
6833
+ return evt;
6834
+ }
6835
+
6836
+ CustomEvent.prototype = window.Event.prototype;
6837
+ window.CustomEvent = CustomEvent;
6838
+ })();
6839
+ /**
6840
+ * Should fire when the cart is opened and expects the cartItems inside the card to be sent
6841
+ */
6842
+
6843
+
6844
+ const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
6845
+ /**
6846
+ * Should fire when an item added to the cart and expects the added item to be sent
6847
+ */
6848
+
6849
+ const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
6850
+ /**
6851
+ * Should fire when an item removed from the cart and expects the removed item to be sent
6852
+ */
6853
+
6854
+ const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
6855
+ /**
6856
+ * Check if the browser support custom events
6857
+ */
6858
+
6859
+ function createCustomEvent(name, detail) {
6860
+ try {
6861
+ return new CustomEvent(name, {
6862
+ detail
6863
+ });
6864
+ } catch (e) {
6865
+ console.warn("Pelcro - Events are not supported in the browser");
6866
+ }
6867
+ }
6868
+
6822
6869
  class PelcroActions {
6823
6870
  constructor(storeSetter, storeGetter) {
6824
6871
  _defineProperty$3(this, "resetState", () => {
@@ -6986,8 +7033,10 @@ class PelcroActions {
6986
7033
  if (!itemToAdd) {
6987
7034
  console.error("invalid item SKU id");
6988
7035
  return false;
6989
- }
7036
+ } //Dispatch PelcroElementsCartItemAdded when an item added successfully to the
7037
+
6990
7038
 
7039
+ document.dispatchEvent(cartItemAdded(itemToAdd));
6991
7040
  const {
6992
7041
  cartItems
6993
7042
  } = this.get();
@@ -20493,53 +20542,6 @@ const CartTotalPrice = () => {
20493
20542
  return null;
20494
20543
  };
20495
20544
 
20496
- // Polyfill
20497
- (() => {
20498
- if (typeof window.CustomEvent === "function") return false;
20499
-
20500
- function CustomEvent(event, params = {
20501
- bubbles: false,
20502
- cancelable: false,
20503
- detail: undefined
20504
- }) {
20505
- const evt = document.createEvent("CustomEvent");
20506
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
20507
- return evt;
20508
- }
20509
-
20510
- CustomEvent.prototype = window.Event.prototype;
20511
- window.CustomEvent = CustomEvent;
20512
- })();
20513
- /**
20514
- * Should fire when the cart is opened and expects the cartItems inside the card to be sent
20515
- */
20516
-
20517
-
20518
- const cartOpened = detail => createCustomEvent("PelcroElementsCartOpened", detail);
20519
- /**
20520
- * Should fire when an item added to the cart and expects the added item to be sent
20521
- */
20522
-
20523
- const cartItemAdded = detail => createCustomEvent("PelcroElementsCartItemAdded", detail);
20524
- /**
20525
- * Should fire when an item removed from the cart and expects the removed item to be sent
20526
- */
20527
-
20528
- const cartItemRemoved = detail => createCustomEvent("PelcroElementsCartItemRemoved", detail);
20529
- /**
20530
- * Check if the browser support custom events
20531
- */
20532
-
20533
- function createCustomEvent(name, detail) {
20534
- try {
20535
- return new CustomEvent(name, {
20536
- detail
20537
- });
20538
- } catch (e) {
20539
- console.warn("Pelcro - Events are not supported in the browser");
20540
- }
20541
- }
20542
-
20543
20545
  const CartView = props => {
20544
20546
  const {
20545
20547
  cartItems
@@ -20630,7 +20632,7 @@ const CartModal = ({
20630
20632
  CartModal.viewId = "cart";
20631
20633
 
20632
20634
  const ShopSelectProductButton = ({
20633
- item,
20635
+ itemId,
20634
20636
  onClick,
20635
20637
  ...otherProps
20636
20638
  }) => {
@@ -20646,8 +20648,7 @@ const ShopSelectProductButton = ({
20646
20648
  const handleClick = () => {
20647
20649
  setDisabled(true);
20648
20650
  setTextContent(t("buttons.added"));
20649
- addToCart(item.id);
20650
- document.dispatchEvent(cartItemAdded(item));
20651
+ addToCart(itemId);
20651
20652
  onClick === null || onClick === void 0 ? void 0 : onClick();
20652
20653
  setTimeout(() => {
20653
20654
  setDisabled(false);
@@ -20656,8 +20657,8 @@ const ShopSelectProductButton = ({
20656
20657
  };
20657
20658
 
20658
20659
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
20659
- "data-sku-id": item.id,
20660
- id: `pelcro-shop-select-${item.id}`,
20660
+ "data-sku-id": itemId,
20661
+ id: `pelcro-shop-select-${itemId}`,
20661
20662
  onClick: handleClick,
20662
20663
  disabled: disabled
20663
20664
  }, otherProps), textContent);
@@ -20701,7 +20702,7 @@ const ShopView = () => {
20701
20702
  }, item.name), /*#__PURE__*/React__default.createElement("p", {
20702
20703
  className: "plc-font-bold pelcro-shop-product-description"
20703
20704
  }, item.description), /*#__PURE__*/React__default.createElement(ShopSelectProductButton, {
20704
- item: item,
20705
+ itemId: item.id,
20705
20706
  className: "plc-mt-2"
20706
20707
  }), /*#__PURE__*/React__default.createElement(ShopPurchaseButton, {
20707
20708
  itemId: item.id,
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.30",
4
+ "version": "3.2.0-beta.33",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",