@trafilea/afrodita-components 5.0.0-beta.301 → 5.0.0-beta.303

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.d.ts CHANGED
@@ -1154,6 +1154,8 @@ declare const TextButton: ({ text, LeadingIcon, TrailingIcon, iconColor, disable
1154
1154
  interface DiscountTagProps {
1155
1155
  discount: number;
1156
1156
  offText: string;
1157
+ savings?: string;
1158
+ showSavings?: boolean;
1157
1159
  disabled?: boolean;
1158
1160
  backgroundColor?: string;
1159
1161
  borderColor?: string;
@@ -1161,7 +1163,7 @@ interface DiscountTagProps {
1161
1163
  size?: ComponentSize.Small | ComponentSize.Medium | ComponentSize.Large;
1162
1164
  style?: React.CSSProperties;
1163
1165
  }
1164
- declare const DiscountTag: ({ discount, offText, disabled, backgroundColor, borderColor, textColor, size, style, }: DiscountTagProps) => JSX.Element;
1166
+ declare const DiscountTag: ({ discount, offText, savings, showSavings, disabled, backgroundColor, borderColor, textColor, size, style, }: DiscountTagProps) => JSX.Element;
1165
1167
 
1166
1168
  interface ClubOfferTagProps {
1167
1169
  clubOfferText?: string;
@@ -1191,7 +1193,9 @@ interface PriceLabelProps {
1191
1193
  }
1192
1194
  declare const PriceLabel: ({ finalPrice, originalPrice, discount, color, testId, finalPriceStyled, finalPriceStyle, originalPriceStyled, originalPriceUnderlined, size, clubStyle, }: PriceLabelProps) => JSX.Element;
1193
1195
 
1194
- declare const PriceLabelV2: ({ finalPrice, originalPrice, discount, clubOffer, color, testId, originalPriceStyled, originalPriceUnderlined, size, }: PriceLabelProps) => JSX.Element;
1196
+ declare const PriceLabelV2: ({ finalPrice, originalPrice, discount, clubOffer, color, testId, originalPriceStyled, originalPriceUnderlined, size, savingsDisplay, }: PriceLabelProps & {
1197
+ savingsDisplay?: boolean | undefined;
1198
+ }) => JSX.Element;
1195
1199
 
1196
1200
  interface ColorPickerProps {
1197
1201
  options: ColorPickerOption[];
@@ -5240,9 +5240,9 @@ var H3$3 = newStyled.h3(templateObject_2$$ || (templateObject_2$$ = __makeTempla
5240
5240
  return (_b = getStylesBySize$8(size)) === null || _b === void 0 ? void 0 : _b.lineHeight;
5241
5241
  });
5242
5242
  var DiscountTag = function (_a) {
5243
- var discount = _a.discount, offText = _a.offText, disabled = _a.disabled, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? '#fff' : _b, _c = _a.borderColor, borderColor = _c === void 0 ? 'transparent' : _c, _d = _a.textColor, textColor = _d === void 0 ? '#fff' : _d, _e = _a.size, size = _e === void 0 ? ComponentSize.Medium : _e, style = _a.style;
5243
+ var discount = _a.discount, offText = _a.offText, savings = _a.savings, _b = _a.showSavings, showSavings = _b === void 0 ? false : _b, disabled = _a.disabled, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? '#fff' : _c, _d = _a.borderColor, borderColor = _d === void 0 ? 'transparent' : _d, _e = _a.textColor, textColor = _e === void 0 ? '#fff' : _e, _f = _a.size, size = _f === void 0 ? ComponentSize.Medium : _f, style = _a.style;
5244
5244
  var theme = useTheme();
5245
- return (jsx$1(Container$11, __assign$1({ backgroundColor: disabled ? theme.colors.shades['50'].color : backgroundColor, borderColor: disabled ? theme.colors.shades['50'].color : borderColor, size: size, "data-testid": "discount-container", style: style }, { children: jsxs$1(H3$3, __assign$1({ textColor: disabled ? theme.colors.shades['250'].color : textColor, size: size, style: style }, { children: [discount, "% ", offText] }), void 0) }), void 0));
5245
+ return (jsx$1(Container$11, __assign$1({ backgroundColor: disabled ? theme.colors.shades['50'].color : backgroundColor, borderColor: disabled ? theme.colors.shades['50'].color : borderColor, size: size, "data-testid": "discount-container", style: style }, { children: jsxs$1(H3$3, __assign$1({ textColor: disabled ? theme.colors.shades['250'].color : textColor, size: size, style: style }, { children: [discount, "% ", offText, " ", showSavings && savings && "- ".concat(savings)] }), void 0) }), void 0));
5246
5246
  };
5247
5247
  var templateObject_1$1u, templateObject_2$$;
5248
5248
 
@@ -5435,7 +5435,7 @@ var templateObject_1$1s, templateObject_2$Z;
5435
5435
  var FinalPriceStyledContainer = newStyled.div(templateObject_1$1r || (templateObject_1$1r = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
5436
5436
  var PriceLabelV2 = function (_a) {
5437
5437
  var _b;
5438
- var finalPrice = _a.finalPrice, originalPrice = _a.originalPrice, discount = _a.discount, clubOffer = _a.clubOffer, color = _a.color, testId = _a.testId, _c = _a.originalPriceStyled, originalPriceStyled = _c === void 0 ? false : _c, _d = _a.originalPriceUnderlined, originalPriceUnderlined = _d === void 0 ? true : _d, _e = _a.size, size = _e === void 0 ? ComponentSize.Medium : _e;
5438
+ var finalPrice = _a.finalPrice, originalPrice = _a.originalPrice, discount = _a.discount, clubOffer = _a.clubOffer, color = _a.color, testId = _a.testId, _c = _a.originalPriceStyled, originalPriceStyled = _c === void 0 ? false : _c, _d = _a.originalPriceUnderlined, originalPriceUnderlined = _d === void 0 ? true : _d, _e = _a.size, size = _e === void 0 ? ComponentSize.Medium : _e, _f = _a.savingsDisplay, savingsDisplay = _f === void 0 ? true : _f;
5439
5439
  var theme = useTheme();
5440
5440
  var isDiffFinalAndOriginalPrice = originalPrice !== finalPrice;
5441
5441
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
@@ -5462,8 +5462,26 @@ var PriceLabelV2 = function (_a) {
5462
5462
  : color || theme.colors.pallete.secondary.color,
5463
5463
  weight: 700,
5464
5464
  };
5465
+ var originalPriceNum, finalPriceNum;
5466
+ if (typeof originalPrice === 'string' && typeof finalPrice === 'string') {
5467
+ originalPriceNum = Number(originalPrice.replace(currencySymbol, ''));
5468
+ finalPriceNum = Number(finalPrice.replace(currencySymbol, ''));
5469
+ }
5470
+ else {
5471
+ originalPriceNum = typeof originalPrice === 'number' ? originalPrice : 0;
5472
+ finalPriceNum = typeof finalPrice === 'number' ? finalPrice : 0;
5473
+ }
5474
+ var saveto = originalPriceNum - finalPriceNum;
5475
+ var decimalPart = Number((saveto - Math.floor(saveto)).toFixed(2));
5476
+ if (decimalPart >= 0.01 && decimalPart < 0.5) {
5477
+ saveto = Math.floor(saveto) + 0.0;
5478
+ }
5479
+ else if (decimalPart >= 0.51 && decimalPart < 1.0) {
5480
+ saveto = Math.floor(saveto) + 0.5;
5481
+ }
5482
+ var savetoString = saveto.toFixed(2);
5465
5483
  var OriginalPrice = function () { return (jsx$1(Price, __assign$1({ size: originalPriceStyled ? size : ComponentSize.Small, color: theme.colors.shades['300'].color, margin: true, underlined: originalPriceUnderlined, "data-testid": getTestId(testId, 'original-product-price') }, { children: originalPrice }), void 0)); };
5466
- return (jsxs$1(Container$10, { children: [isOriginalPrice && jsx$1(OriginalPrice, {}, void 0), jsxs$1(FinalPriceStyledContainer, __assign$1({ "data-testid": getTestId(testId, 'final-product-price') }, { children: [jsx$1(Price, __assign$1({ margin: true, finalPriceStyledSmall: true, style: { fontSize: '14px', marginTop: '-5px' } }, priceCommonProps, { children: currencySymbol }), void 0), jsx$1(Price, __assign$1({ finalPriceStyled: true }, priceCommonProps, { children: finalPriceArray[0] ? finalPriceArray[0] : (_b = "".concat(finalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsx$1(Price, __assign$1({ finalPriceStyledSmall: true, style: { fontSize: '14px', marginTop: '-6px' } }, priceCommonProps, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0)] }), void 0), isDiscount && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Small }, { children: discount && (jsx$1(DiscountTag, __assign$1({}, discount, { size: ComponentSize.Medium, style: { fontSize: '14px', letterSpacing: '-0.05rem' } }), void 0)) }), void 0)), isClubOffer && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Medium }, { children: clubOffer && (jsx$1(ClubOfferTag, __assign$1({}, clubOffer, { size: ComponentSize.Small, style: {
5484
+ return (jsxs$1(Container$10, { children: [isOriginalPrice && jsx$1(OriginalPrice, {}, void 0), jsxs$1(FinalPriceStyledContainer, __assign$1({ "data-testid": getTestId(testId, 'final-product-price') }, { children: [jsx$1(Price, __assign$1({ margin: true, finalPriceStyledSmall: true, style: { fontSize: '14px', marginTop: '-5px' } }, priceCommonProps, { children: currencySymbol }), void 0), jsx$1(Price, __assign$1({ finalPriceStyled: true }, priceCommonProps, { children: finalPriceArray[0] ? finalPriceArray[0] : (_b = "".concat(finalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsx$1(Price, __assign$1({ finalPriceStyledSmall: true, style: { fontSize: '14px', marginTop: '-6px' } }, priceCommonProps, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0)] }), void 0), isDiscount && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Small }, { children: discount && (jsx$1(DiscountTag, __assign$1({}, discount, { size: ComponentSize.Medium, style: { fontSize: '14px', letterSpacing: '-0.05rem' }, savings: savingsDisplay ? "Save ".concat(currencySymbol).concat(savetoString) : undefined }), void 0)) }), void 0)), isClubOffer && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Medium }, { children: clubOffer && (jsx$1(ClubOfferTag, __assign$1({}, clubOffer, { size: ComponentSize.Small, style: {
5467
5485
  borderRadius: '8px',
5468
5486
  width: '107px',
5469
5487
  height: '28px',
@@ -14028,8 +14046,8 @@ function usePreventVerticalScroll(ref, dragThreshold) {
14028
14046
  if (Math.abs(clientX.current) > dragThreshold) {
14029
14047
  if (e.cancelable) {
14030
14048
  e.preventDefault();
14049
+ e.returnValue = false;
14031
14050
  }
14032
- e.returnValue = false;
14033
14051
  return false;
14034
14052
  }
14035
14053
  return true;