@pelcro/react-pelcro-js 3.2.0-beta.22 → 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}
@@ -19415,6 +19415,7 @@ const CartRemoveItemButton = ({
19415
19415
 
19416
19416
  const CartSubmit = ({
19417
19417
  name,
19418
+ onClick,
19418
19419
  ...otherProps
19419
19420
  }) => {
19420
19421
  const {
@@ -19427,9 +19428,12 @@ const CartSubmit = ({
19427
19428
  t
19428
19429
  } = useTranslation("cart");
19429
19430
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({}, otherProps, {
19430
- onClick: () => dispatch({
19431
- type: HANDLE_SUBMIT
19432
- }),
19431
+ onClick: () => {
19432
+ dispatch({
19433
+ type: HANDLE_SUBMIT
19434
+ });
19435
+ onClick === null || onClick === void 0 ? void 0 : onClick();
19436
+ },
19433
19437
  disabled: buttonDisabled
19434
19438
  }), name !== null && name !== void 0 ? name : t("confirm"));
19435
19439
  };
@@ -19473,6 +19477,53 @@ const CartTotalPrice = () => {
19473
19477
  return null;
19474
19478
  };
19475
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
+
19476
19527
  const CartView = props => {
19477
19528
  const {
19478
19529
  cartItems
@@ -19480,6 +19531,9 @@ const CartView = props => {
19480
19531
  const {
19481
19532
  t
19482
19533
  } = useTranslation("cart");
19534
+ React.useEffect(() => {
19535
+ document.dispatchEvent(cartOpened(cartItems));
19536
+ }, []);
19483
19537
  return /*#__PURE__*/React__default['default'].createElement("div", {
19484
19538
  id: "pelcro-cart-view"
19485
19539
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -19509,7 +19563,8 @@ const CartView = props => {
19509
19563
  }, calcAndFormatItemsTotal([item], item.currency)), /*#__PURE__*/React__default['default'].createElement(CartRemoveItemButton, {
19510
19564
  itemId: item.id,
19511
19565
  id: `pelcro-remove-product-${item.id}`,
19512
- "aria-label": "remove item from cart"
19566
+ "aria-label": "remove item from cart",
19567
+ onClick: () => document.dispatchEvent(cartItemRemoved(item))
19513
19568
  }));
19514
19569
  })), /*#__PURE__*/React__default['default'].createElement("div", {
19515
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"
@@ -19630,7 +19685,8 @@ const ShopView = () => {
19630
19685
  className: "plc-font-bold pelcro-shop-product-description"
19631
19686
  }, item.description), /*#__PURE__*/React__default['default'].createElement(ShopSelectProductButton, {
19632
19687
  itemId: item.id,
19633
- className: "plc-mt-2"
19688
+ className: "plc-mt-2",
19689
+ onClick: () => document.dispatchEvent(cartItemAdded(item))
19634
19690
  }), /*#__PURE__*/React__default['default'].createElement(ShopPurchaseButton, {
19635
19691
  itemId: item.id,
19636
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}
@@ -19385,6 +19385,7 @@ const CartRemoveItemButton = ({
19385
19385
 
19386
19386
  const CartSubmit = ({
19387
19387
  name,
19388
+ onClick,
19388
19389
  ...otherProps
19389
19390
  }) => {
19390
19391
  const {
@@ -19397,9 +19398,12 @@ const CartSubmit = ({
19397
19398
  t
19398
19399
  } = useTranslation("cart");
19399
19400
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({}, otherProps, {
19400
- onClick: () => dispatch({
19401
- type: HANDLE_SUBMIT
19402
- }),
19401
+ onClick: () => {
19402
+ dispatch({
19403
+ type: HANDLE_SUBMIT
19404
+ });
19405
+ onClick === null || onClick === void 0 ? void 0 : onClick();
19406
+ },
19403
19407
  disabled: buttonDisabled
19404
19408
  }), name !== null && name !== void 0 ? name : t("confirm"));
19405
19409
  };
@@ -19443,6 +19447,53 @@ const CartTotalPrice = () => {
19443
19447
  return null;
19444
19448
  };
19445
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
+
19446
19497
  const CartView = props => {
19447
19498
  const {
19448
19499
  cartItems
@@ -19450,6 +19501,9 @@ const CartView = props => {
19450
19501
  const {
19451
19502
  t
19452
19503
  } = useTranslation("cart");
19504
+ useEffect(() => {
19505
+ document.dispatchEvent(cartOpened(cartItems));
19506
+ }, []);
19453
19507
  return /*#__PURE__*/React__default.createElement("div", {
19454
19508
  id: "pelcro-cart-view"
19455
19509
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -19479,7 +19533,8 @@ const CartView = props => {
19479
19533
  }, calcAndFormatItemsTotal([item], item.currency)), /*#__PURE__*/React__default.createElement(CartRemoveItemButton, {
19480
19534
  itemId: item.id,
19481
19535
  id: `pelcro-remove-product-${item.id}`,
19482
- "aria-label": "remove item from cart"
19536
+ "aria-label": "remove item from cart",
19537
+ onClick: () => document.dispatchEvent(cartItemRemoved(item))
19483
19538
  }));
19484
19539
  })), /*#__PURE__*/React__default.createElement("div", {
19485
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"
@@ -19600,7 +19655,8 @@ const ShopView = () => {
19600
19655
  className: "plc-font-bold pelcro-shop-product-description"
19601
19656
  }, item.description), /*#__PURE__*/React__default.createElement(ShopSelectProductButton, {
19602
19657
  itemId: item.id,
19603
- className: "plc-mt-2"
19658
+ className: "plc-mt-2",
19659
+ onClick: () => document.dispatchEvent(cartItemAdded(item))
19604
19660
  }), /*#__PURE__*/React__default.createElement(ShopPurchaseButton, {
19605
19661
  itemId: item.id,
19606
19662
  className: "plc-mt-2"
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.22",
4
+ "version": "3.2.0-beta.23",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",