@trafilea/afrodita-components 4.1.0 → 4.2.0

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/build/index.js CHANGED
@@ -3498,7 +3498,7 @@ function jsxs(type, props, key) {
3498
3498
  var BaseButton = function (_a) {
3499
3499
  var children = _a.children, renderLeading = _a.renderLeading, renderTrailing = _a.renderTrailing, disabled = _a.disabled, _b = _a.type, type = _b === void 0 ? 'button' : _b, onClick = _a.onClick, className = _a.className, inline = _a.inline;
3500
3500
  return (jsxs("button", __assign({ onClick: onClick, disabled: disabled, className: className, type: type, css: {
3501
- display: inline ? 'inherit-flex' : 'flex',
3501
+ display: inline ? 'inline-flex' : 'flex',
3502
3502
  justifyContent: 'center',
3503
3503
  alignItems: 'center',
3504
3504
  padding: '0.75rem 2rem',
@@ -3534,20 +3534,19 @@ var getStylesBySize$9 = function (size, theme) {
3534
3534
  }
3535
3535
  };
3536
3536
  var BaseCTA = function (_a) {
3537
- var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? exports.ComponentSize.Medium : _d, type = _a.type, className = _a.className;
3537
+ var text = _a.text, _b = _a.wide, wide = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? exports.ComponentSize.Medium : _c, props = __rest(_a, ["text", "wide", "size"]);
3538
3538
  var theme = useTheme();
3539
3539
  var stylesBySize = getStylesBySize$9(size, theme);
3540
- return (jsx(BaseButton, __assign({ onClick: onClick, disabled: disabled, className: className, type: type, css: __assign(__assign({ width: wide ? '100%' : 'fit-content' }, stylesBySize), { fontWeight: theme.component.button.fontWeight, borderRadius: "".concat(theme.component.button.borderRadius), cursor: 'pointer', '&:disabled': {
3540
+ return (jsx(BaseButton, __assign({}, props, { css: __assign(__assign({ width: wide ? '100%' : 'fit-content' }, stylesBySize), { fontWeight: theme.component.button.fontWeight, borderRadius: "".concat(theme.component.button.borderRadius), cursor: 'pointer', '&:disabled': {
3541
3541
  backgroundColor: theme.colors.background.disabled,
3542
3542
  color: theme.colors.text.disabled,
3543
3543
  cursor: 'not-allowed',
3544
3544
  } }) }, { children: text }), void 0));
3545
3545
  };
3546
3546
 
3547
- var ButtonPrimary = function (_a) {
3548
- var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, type = _a.type;
3547
+ var ButtonPrimary = function (props) {
3549
3548
  var theme = useTheme();
3550
- return (jsx(BaseCTA, { onClick: onClick, disabled: disabled, wide: wide, size: size, css: {
3549
+ return (jsx(BaseCTA, __assign({}, props, { css: {
3551
3550
  backgroundColor: theme.component.button.primary.active.backgroundColor,
3552
3551
  color: theme.component.button.primary.active.color,
3553
3552
  border: theme.component.button.border,
@@ -3559,13 +3558,12 @@ var ButtonPrimary = function (_a) {
3559
3558
  backgroundColor: theme.colors.background.disabled,
3560
3559
  color: theme.colors.text.disabled,
3561
3560
  },
3562
- }, text: text, type: type }, void 0));
3561
+ } }), void 0));
3563
3562
  };
3564
3563
 
3565
- var ButtonSecondary = function (_a) {
3566
- var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, className = _a.className;
3564
+ var ButtonSecondary = function (props) {
3567
3565
  var theme = useTheme();
3568
- return (jsx(BaseCTA, { onClick: onClick, disabled: disabled, wide: wide, size: size, css: {
3566
+ return (jsx(BaseCTA, __assign({}, props, { css: {
3569
3567
  backgroundColor: theme.component.button.secondary.active.backgroundColor,
3570
3568
  color: theme.component.button.secondary.active.color,
3571
3569
  border: theme.component.button.border,
@@ -3576,13 +3574,12 @@ var ButtonSecondary = function (_a) {
3576
3574
  backgroundColor: theme.colors.shades['50'].color,
3577
3575
  color: theme.colors.shades['250'].color,
3578
3576
  },
3579
- }, text: text, className: className }, void 0));
3577
+ } }), void 0));
3580
3578
  };
3581
3579
 
3582
- var ButtonSecondaryOutline = function (_a) {
3583
- var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, className = _a.className;
3580
+ var ButtonSecondaryOutline = function (props) {
3584
3581
  var theme = useTheme();
3585
- return (jsx(BaseCTA, { onClick: onClick, disabled: disabled, wide: wide, size: size, className: className, css: {
3582
+ return (jsx(BaseCTA, __assign({}, props, { css: {
3586
3583
  backgroundColor: theme.component.button.secondary.active.color,
3587
3584
  color: theme.component.button.secondary.active.backgroundColor,
3588
3585
  border: "1px solid ".concat(theme.component.button.secondary.active.backgroundColor),
@@ -3595,7 +3592,7 @@ var ButtonSecondaryOutline = function (_a) {
3595
3592
  color: theme.colors.text.disabled,
3596
3593
  border: 'none',
3597
3594
  },
3598
- }, text: text }, void 0));
3595
+ } }), void 0));
3599
3596
  };
3600
3597
 
3601
3598
  function _extends() {
@@ -7544,14 +7541,53 @@ var InputLabel = function (_a) {
7544
7541
  };
7545
7542
  var templateObject_1$F, templateObject_2$q;
7546
7543
 
7544
+ /**
7545
+ * @returns number formatted with "," and 2 decimals as string
7546
+ */
7547
+ var decimalFormat = function (number) {
7548
+ return number.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
7549
+ };
7550
+
7547
7551
  var isEmpty = function (value) {
7548
7552
  return value.length === 0;
7553
+ };
7554
+ var isEmail = function (value) {
7555
+ return /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(value);
7556
+ };
7557
+ var isNumber = function (value) {
7558
+ return /^[0-9]*$/.test(value);
7559
+ };
7560
+ var isPhoneNumber = function (value) {
7561
+ return /^\d{10}$/.test(value);
7562
+ };
7563
+ var isValidDate = function (value) {
7564
+ return /^\d{4}-\d{2}-\d{2}$/.test(value);
7565
+ };
7566
+
7567
+ var mouseClickEvents = ['mousedown', 'click', 'mouseup'];
7568
+ var simulateMouseClick = function (element) {
7569
+ mouseClickEvents.forEach(function (mouseEventType) {
7570
+ return element.dispatchEvent(new MouseEvent(mouseEventType, {
7571
+ view: window,
7572
+ bubbles: true,
7573
+ cancelable: true,
7574
+ buttons: 1,
7575
+ }));
7576
+ });
7549
7577
  };
7550
7578
 
7551
7579
  var sliceString = function (str, maxLength) {
7552
7580
  return str.length > maxLength ? "".concat(str.slice(0, maxLength), "...") : str;
7553
7581
  };
7554
7582
 
7583
+ var formatPrice = function (value, _a) {
7584
+ var _b = _a === void 0 ? {} : _a, _c = _b.locale, locale = _c === void 0 ? 'en-US' : _c, _d = _b.currency, currency = _d === void 0 ? 'USD' : _d;
7585
+ return new Intl.NumberFormat(locale, {
7586
+ style: 'currency',
7587
+ currency: currency,
7588
+ }).format(value);
7589
+ };
7590
+
7555
7591
  var ErrorText = newStyled.h3(templateObject_1$E || (templateObject_1$E = __makeTemplateObject(["\n color: ", " !important;\n font-size: 0.75rem;\n font-weight: 600;\n margin: 0;\n font-height: 1rem;\n margin-left: 0.313rem;\n"], ["\n color: ", " !important;\n font-size: 0.75rem;\n font-weight: 600;\n margin: 0;\n font-height: 1rem;\n margin-left: 0.313rem;\n"])), function (props) { return props.color; });
7556
7592
  var ErrorContainer = newStyled.div(templateObject_2$p || (templateObject_2$p = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-top: 0.25rem;\n"], ["\n display: flex;\n align-items: center;\n margin-top: 0.25rem;\n"])));
7557
7593
  var Error$1 = function (_a) {
@@ -12448,6 +12484,12 @@ var index = /*#__PURE__*/Object.freeze({
12448
12484
  CrossSellCheckbox: CrossSellCheckbox
12449
12485
  });
12450
12486
 
12487
+ var Spacing = function (_a) {
12488
+ var size = _a.size, _b = _a.type, type = _b === void 0 ? 'block' : _b, children = _a.children, styleProp = _a.style;
12489
+ var style = React.useMemo(function () { return (__assign(__assign({}, styleProp), { width: size, height: size, verticalAlign: 'middle', display: type === 'block' ? 'block' : 'inline-block' })); }, [size, type, styleProp]);
12490
+ return jsxRuntime.jsx("div", __assign({ style: style }, { children: children }), void 0);
12491
+ };
12492
+
12451
12493
  var ImageContainer = newStyled.div(function (_a) {
12452
12494
  var width = _a.width, height = _a.height;
12453
12495
  return ({
@@ -12470,6 +12512,11 @@ var getStylesBySize = function (size) {
12470
12512
  width: '9.813rem',
12471
12513
  height: '13.125rem',
12472
12514
  };
12515
+ case exports.ComponentSize.Large:
12516
+ return {
12517
+ width: '262px',
12518
+ height: '350px',
12519
+ };
12473
12520
  /* istanbul ignore next */
12474
12521
  default:
12475
12522
  return {
@@ -12482,7 +12529,21 @@ var ProductItemMobile = function (_a) {
12482
12529
  var title = _a.title, image = _a.image, price = _a.price, rating = _a.rating, size = _a.size, tags = _a.tags, _b = _a.alignName, alignName = _b === void 0 ? 'center' : _b;
12483
12530
  var theme = useTheme();
12484
12531
  var styles = getStylesBySize(size);
12485
- return (jsxs(Container$d, { children: [tags ? (jsxs(ImageContainer, __assign({ width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height, "data-testid": "tags-image-container" }, { children: [jsx(Image, { src: image.src, alt: image.alt, width: "100%", height: "100%" }, void 0), jsx(SeasonOfferTag, { text: tags.seasonOfferTagText, size: exports.ComponentSize.Small, css: { position: 'absolute', top: 0, left: 0 } }, void 0), jsx(CategoryTag, { text: tags.categoryTagText, size: exports.ComponentSize.Small, css: { position: 'absolute', bottom: '1rem', left: 0 } }, void 0)] }), void 0)) : (jsx(Image, { src: image.src, alt: image.alt, width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height }, void 0)), jsx(H1, __assign({ theme: theme, align: alignName }, { children: title }), void 0), jsx(PriceLabel, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, color: price.color, size: exports.ComponentSize.Small }, void 0), jsx(Rating, { size: exports.ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "" }, void 0)] }, void 0));
12532
+ var spaces = React.useMemo(function () {
12533
+ var _a, _b;
12534
+ var first = (_a = {},
12535
+ _a[exports.ComponentSize.Large] = 20,
12536
+ _a[exports.ComponentSize.Medium] = 12,
12537
+ _a[exports.ComponentSize.Small] = 6,
12538
+ _a)[size];
12539
+ var second = (_b = {},
12540
+ _b[exports.ComponentSize.Large] = 12,
12541
+ _b[exports.ComponentSize.Medium] = 6,
12542
+ _b[exports.ComponentSize.Small] = 4,
12543
+ _b)[size];
12544
+ return [first, second];
12545
+ }, [size]);
12546
+ return (jsxs(Container$d, { children: [tags ? (jsxs(ImageContainer, __assign({ width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height, "data-testid": "tags-image-container" }, { children: [jsx(Image, { src: image.src, alt: image.alt, width: "100%", height: "100%" }, void 0), jsx(SeasonOfferTag, { text: tags.seasonOfferTagText, size: exports.ComponentSize.Small, css: { position: 'absolute', top: 0, left: 0 } }, void 0), jsx(CategoryTag, { text: tags.categoryTagText, size: exports.ComponentSize.Small, css: { position: 'absolute', bottom: '1rem', left: 0 } }, void 0)] }), void 0)) : (jsx(Image, { src: image.src, alt: image.alt, width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height }, void 0)), jsx(Spacing, { size: spaces[0] }, void 0), jsx(H1, __assign({ theme: theme, align: alignName }, { children: title }), void 0), jsx(Spacing, { size: spaces[1] }, void 0), jsx(PriceLabel, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, color: price.color, size: exports.ComponentSize.Small }, void 0), jsx(Rating, { size: size === exports.ComponentSize.Large ? exports.ComponentSize.Small : exports.ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "" }, void 0)] }, void 0));
12486
12547
  };
12487
12548
  var templateObject_1$j, templateObject_2$9;
12488
12549
 
@@ -13112,6 +13173,7 @@ exports.SizeFitGuide = SizeFitGuide;
13112
13173
  exports.SizeSelector = SizeSelector;
13113
13174
  exports.SizeTable = SizeTable;
13114
13175
  exports.SliderNavigation = SliderNavigation;
13176
+ exports.Spacing = Spacing;
13115
13177
  exports.Spinner = Spinner;
13116
13178
  exports.StarList = StarList;
13117
13179
  exports.Text = Text$5;
@@ -13121,7 +13183,16 @@ exports.ThemeVariables = ThemeVariables;
13121
13183
  exports.Timer = Timer;
13122
13184
  exports.Tooltip = Tooltip;
13123
13185
  exports.Totals = Totals;
13186
+ exports.decimalFormat = decimalFormat;
13187
+ exports.formatPrice = formatPrice;
13188
+ exports.isEmail = isEmail;
13189
+ exports.isEmpty = isEmpty;
13190
+ exports.isNumber = isNumber;
13191
+ exports.isPhoneNumber = isPhoneNumber;
13192
+ exports.isValidDate = isValidDate;
13124
13193
  exports.modalEvent = modalEvent;
13194
+ exports.simulateMouseClick = simulateMouseClick;
13195
+ exports.sliceString = sliceString;
13125
13196
  exports.useOnClickOutside = useOnClickOutside;
13126
13197
  exports.useTheme = useTheme;
13127
13198
  exports.useThemeAssets = useThemeAssets;