@pelcro/react-pelcro-js 3.2.0-beta.21 → 3.2.0-beta.24

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,16 +6469,16 @@ 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}
6479
6479
  */
6480
6480
 
6481
- const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency);
6481
+ const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase());
6482
6482
  const sortCountries = countries => {
6483
6483
  const sortable = [];
6484
6484
  delete countries.CA;
@@ -16765,7 +16765,7 @@ const UserUpdateEmail = props => {
16765
16765
  enableEmailEdit: enableEmailEdit
16766
16766
  }, props)), /*#__PURE__*/React__default['default'].createElement(Button, {
16767
16767
  variant: "icon",
16768
- className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-6 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
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
16769
  icon: enableEmailEdit ? /*#__PURE__*/React__default['default'].createElement(SvgXIcon, {
16770
16770
  className: "plc-w-6"
16771
16771
  }) : /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
@@ -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,16 +6439,16 @@ 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}
6449
6449
  */
6450
6450
 
6451
- const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency);
6451
+ const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase());
6452
6452
  const sortCountries = countries => {
6453
6453
  const sortable = [];
6454
6454
  delete countries.CA;
@@ -16735,7 +16735,7 @@ const UserUpdateEmail = props => {
16735
16735
  enableEmailEdit: enableEmailEdit
16736
16736
  }, props)), /*#__PURE__*/React__default.createElement(Button, {
16737
16737
  variant: "icon",
16738
- className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-6 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
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
16739
  icon: enableEmailEdit ? /*#__PURE__*/React__default.createElement(SvgXIcon, {
16740
16740
  className: "plc-w-6"
16741
16741
  }) : /*#__PURE__*/React__default.createElement(SvgEdit, null),
@@ -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/dist/pelcro.css CHANGED
@@ -2514,8 +2514,8 @@ in order to scope selectors under pelcro-root
2514
2514
  bottom: 1rem;
2515
2515
  }
2516
2516
 
2517
- .pelcro-root .plc-top-6 {
2518
- top: 1.5rem;
2517
+ .pelcro-root .plc-top-7 {
2518
+ top: 1.75rem;
2519
2519
  }
2520
2520
 
2521
2521
  .pelcro-root .plc-top-16 {
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.21",
4
+ "version": "3.2.0-beta.24",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",