@trafilea/afrodita-components 6.2.0 → 6.4.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
@@ -3133,6 +3133,20 @@ var formatPrice = function (value, _a) {
3133
3133
  }).format(valueToFormat);
3134
3134
  };
3135
3135
 
3136
+ var Viewports = {
3137
+ mobile: 'mobile',
3138
+ tablet: 'tablet',
3139
+ desktop: 'desktop',
3140
+ desktopLarge: 'desktopLarge',
3141
+ };
3142
+
3143
+ //ANNOTATION: Those values are up to.
3144
+ var DEFAULT_BREAKPOINTS = {
3145
+ mobile: 640,
3146
+ tablet: 1024,
3147
+ desktop: 1280,
3148
+ };
3149
+
3136
3150
  var Container$17 = newStyled.div(templateObject_1$1O || (templateObject_1$1O = __makeTemplateObject(["\n @keyframes shimmer {\n 100% {\n transform: translateX(100%);\n }\n }\n\n display: inline-block;\n height: ", ";\n width: ", ";\n position: relative;\n overflow: hidden;\n background-color: ", ";\n border-radius: ", ";\n box-sizing: border-box;\n\n ::after {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transform: translateX(-100%);\n background-image: linear-gradient(\n 90deg,\n ", ",\n ", ",\n ", "\n );\n animation: shimmer 2s infinite;\n content: '';\n box-sizing: border-box;\n }\n"], ["\n @keyframes shimmer {\n 100% {\n transform: translateX(100%);\n }\n }\n\n display: inline-block;\n height: ", ";\n width: ", ";\n position: relative;\n overflow: hidden;\n background-color: ", ";\n border-radius: ", ";\n box-sizing: border-box;\n\n ::after {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transform: translateX(-100%);\n background-image: linear-gradient(\n 90deg,\n ", ",\n ", ",\n ", "\n );\n animation: shimmer 2s infinite;\n content: '';\n box-sizing: border-box;\n }\n"])), function (_a) {
3137
3151
  var height = _a.height;
3138
3152
  return (height ? height : '1.5em');
@@ -3227,19 +3241,26 @@ var fetchWithCache = function (request, saveToCacheFn) {
3227
3241
  var createIconImage = function (_a) {
3228
3242
  var src = _a.src;
3229
3243
  return __awaiter(void 0, void 0, void 0, function () {
3230
- var blob, localUrl_1, cleanup, error_1;
3244
+ var localUrl, error_1;
3231
3245
  return __generator(this, function (_b) {
3232
3246
  switch (_b.label) {
3233
3247
  case 0:
3234
3248
  _b.trys.push([0, 2, , 3]);
3235
- return [4 /*yield*/, fetchWithCache(src, function (response) { return response.blob(); })];
3249
+ return [4 /*yield*/, fetchWithCache(src, function (response) { return __awaiter(void 0, void 0, void 0, function () {
3250
+ var blob;
3251
+ return __generator(this, function (_a) {
3252
+ switch (_a.label) {
3253
+ case 0: return [4 /*yield*/, response.blob()];
3254
+ case 1:
3255
+ blob = _a.sent();
3256
+ return [2 /*return*/, URL.createObjectURL(blob)];
3257
+ }
3258
+ });
3259
+ }); })];
3236
3260
  case 1:
3237
- blob = _b.sent();
3238
- localUrl_1 = URL.createObjectURL(blob);
3239
- cleanup = function () { return URL.revokeObjectURL(localUrl_1); };
3261
+ localUrl = _b.sent();
3240
3262
  return [2 /*return*/, {
3241
- src: localUrl_1,
3242
- cleanup: cleanup,
3263
+ src: localUrl,
3243
3264
  }];
3244
3265
  case 2:
3245
3266
  error_1 = _b.sent();
@@ -3288,11 +3309,10 @@ var IconFromExtSource = function (_a) {
3288
3309
  if (!localSource) {
3289
3310
  fetchIcon();
3290
3311
  }
3291
- return localSource === null || localSource === void 0 ? void 0 : localSource.cleanup;
3292
- }, [iconURL, localSource === null || localSource === void 0 ? void 0 : localSource.cleanup]);
3312
+ }, [iconURL]);
3293
3313
  var imageProperties = __assign$1({ alt: title !== null && title !== void 0 ? title : name, 'data-testid': testId, height: height, width: width }, rest);
3294
3314
  if (error) {
3295
- return jsxRuntime.jsx(StyledImageWrapper, __assign$1({}, imageProperties, rest, { src: iconURL }), void 0);
3315
+ return jsxRuntime.jsx(StyledImageWrapper, __assign$1({}, imageProperties, { src: iconURL }), void 0);
3296
3316
  }
3297
3317
  if (!localSource) {
3298
3318
  return jsxRuntime.jsx(SkeletonBox, { width: width, height: height }, void 0);
@@ -3304,7 +3324,7 @@ var IconFromExtSource = function (_a) {
3304
3324
  };
3305
3325
 
3306
3326
  /* eslint-disable react/forbid-component-props */
3307
- var Icon$1 = function (_a) {
3327
+ var UnmemoIcon = function (_a) {
3308
3328
  var height = _a.height, _b = _a.width, width = _b === void 0 ? 1 : _b, title = _a.title, testId = _a.testId, fill = _a.fill, name = _a.name, svgProps = _a.svgProps, rest = __rest(_a, ["height", "width", "title", "testId", "fill", "name", "svgProps"]);
3309
3329
  var assets = useTheme().assets;
3310
3330
  var newWidth = width && getIconDimension(width);
@@ -3316,7 +3336,8 @@ var Icon$1 = function (_a) {
3316
3336
  return (jsxRuntime.jsxs(StyledSvgWrapper, __assign$1({ "data-testid": testId, fill: fill, height: newHeight, type: "image/svg+xml", width: newWidth }, rest, svgProps, { children: [jsxRuntime.jsx("title", { children: title !== null && title !== void 0 ? title : name }, void 0), jsxRuntime.jsx("use", { xlinkHref: "".concat(iconURL, "#").concat(svgId) }, void 0)] }), void 0));
3317
3337
  }
3318
3338
  return (jsxRuntime.jsx(IconFromExtSource, __assign$1({ svgId: svgId, iconURL: iconURL, testId: testId, fill: fill, height: newHeight, svgProps: svgProps, width: newWidth, name: name, title: title }, rest), void 0));
3319
- };
3339
+ };
3340
+ var Icon$1 = React__default["default"].memo(UnmemoIcon, function (prevProps, nextProps) { return prevProps.name !== nextProps.name; });
3320
3341
 
3321
3342
  var Add = function (props) { return jsxRuntime.jsx(Icon$1, __assign$1({}, props, { name: "actions/add" }), void 0); };
3322
3343
 
@@ -5236,27 +5257,56 @@ var DiscountTag = function (_a) {
5236
5257
  var templateObject_1$1A, templateObject_2$10;
5237
5258
 
5238
5259
  function getWindowDimensions() {
5260
+ if (typeof window === 'undefined')
5261
+ return { width: 0, height: 0 };
5239
5262
  var width = window.innerWidth, height = window.innerHeight;
5240
5263
  return {
5241
5264
  width: width,
5242
5265
  height: height,
5243
5266
  };
5244
5267
  }
5245
- var useWindowDimensions = function (breakpoints) {
5246
- var _a = React$2.useState({ width: 0, height: 0 }), windowDimensions = _a[0], setWindowDimensions = _a[1];
5268
+ var getViewport = function (breakpoints, width) {
5269
+ if (width <= breakpoints.mobile)
5270
+ return Viewports.mobile;
5271
+ if (width <= breakpoints.tablet)
5272
+ return Viewports.tablet;
5273
+ if (width <= breakpoints.desktop)
5274
+ return Viewports.desktop;
5275
+ return Viewports.desktopLarge;
5276
+ };
5277
+ var useWindowDimensions = function (breakpoints, _a) {
5278
+ if (breakpoints === void 0) { breakpoints = DEFAULT_BREAKPOINTS; }
5279
+ var _b = _a === void 0 ? {} : _a, shouldListenChanges = _b.shouldListenChanges;
5280
+ var _c = React$2.useState(function () {
5281
+ var dimension = getWindowDimensions();
5282
+ return {
5283
+ windowDimensions: dimension,
5284
+ viewport: getViewport(breakpoints, dimension.width),
5285
+ };
5286
+ }), state = _c[0], setState = _c[1];
5247
5287
  React$2.useEffect(function () {
5248
5288
  function handleResize() {
5249
- setWindowDimensions(getWindowDimensions());
5289
+ var newDimension = getWindowDimensions();
5290
+ var newViewport = getViewport(breakpoints, newDimension.width);
5291
+ setState(function (oldState) {
5292
+ if (shouldListenChanges || oldState.viewport !== newViewport) {
5293
+ return {
5294
+ windowDimensions: newDimension,
5295
+ viewport: newViewport,
5296
+ };
5297
+ }
5298
+ return oldState;
5299
+ });
5250
5300
  }
5251
- // calling it here updates the dimensions on first render
5252
5301
  handleResize();
5253
5302
  window.addEventListener('resize', handleResize);
5254
5303
  return function () { return window.removeEventListener('resize', handleResize); };
5255
- }, []);
5256
- return {
5257
- isMobile: windowDimensions.width < breakpoints.desktop,
5258
- windowDimensions: windowDimensions,
5259
- };
5304
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5305
+ }, [shouldListenChanges]);
5306
+ var isMobile = state.viewport === Viewports.mobile;
5307
+ var isTablet = state.viewport === Viewports.tablet;
5308
+ var isDesktop = state.viewport === Viewports.desktop || state.viewport === Viewports.desktopLarge;
5309
+ return __assign$1(__assign$1({}, state), { isMobile: isMobile, isTablet: isTablet, isDesktop: isDesktop });
5260
5310
  };
5261
5311
 
5262
5312
  var getStylesBySize$c = function (size, theme) {
@@ -5339,7 +5389,7 @@ function getTestId() {
5339
5389
  var PriceLabel = function (_a) {
5340
5390
  var finalPrice = _a.finalPrice, originalPrice = _a.originalPrice, discount = _a.discount, color = _a.color, testId = _a.testId, _b = _a.finalPriceStyled, finalPriceStyled = _b === void 0 ? false : _b, finalPriceStyle = _a.finalPriceStyle, _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 ? exports.ComponentSize.Medium : _e, _f = _a.clubStyle, clubStyle = _f === void 0 ? false : _f, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "color", "testId", "finalPriceStyled", "finalPriceStyle", "originalPriceStyled", "originalPriceUnderlined", "size", "clubStyle"]);
5341
5391
  var theme = useTheme();
5342
- var isMobile = useWindowDimensions({ mobile: 0, desktop: 768 }).isMobile;
5392
+ var isMobile = useWindowDimensions().isMobile;
5343
5393
  var priceCommonProps = {
5344
5394
  size: finalPriceStyled ? exports.ComponentSize.Small : size,
5345
5395
  color: color || theme.colors.pallete.secondary.color,
@@ -5885,7 +5935,7 @@ var DesktopDollarPart = newStyled(DollarPart)(templateObject_7$e || (templateObj
5885
5935
  var DesktopClubMembersText = newStyled(ClubMembersText)(templateObject_8$a || (templateObject_8$a = __makeTemplateObject(["\n font-size: 13px;\n"], ["\n font-size: 13px;\n"])));
5886
5936
  var ClubPriceLabel = function (_a) {
5887
5937
  var clubPrice = _a.clubPrice;
5888
- var isMobile = useWindowDimensions({ mobile: 0, desktop: 768 }).isMobile;
5938
+ var isMobile = useWindowDimensions().isMobile;
5889
5939
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isMobile ? (jsxRuntime.jsxs(MobileContainer, { children: [jsxRuntime.jsx(MobileDollarPart, { children: clubPrice }, void 0), jsxRuntime.jsx(MobileClubMembersText, { children: "FOR CLUB MEMBERS" }, void 0)] }, void 0)) : (jsxRuntime.jsxs(Container$S, { children: [jsxRuntime.jsx(DesktopDollarPart, { children: clubPrice }, void 0), jsxRuntime.jsx(DesktopClubMembersText, { children: "FOR CLUB MEMBERS" }, void 0)] }, void 0)) }, void 0));
5890
5940
  };
5891
5941
  var templateObject_1$1h, templateObject_2$T, templateObject_3$I, templateObject_4$x, templateObject_5$m, templateObject_6$k, templateObject_7$e, templateObject_8$a;
@@ -6082,7 +6132,7 @@ var ProductItemMobile = function (_a) {
6082
6132
  } : _g, _h = _a.clubPrice, clubPrice = _h === void 0 ? '' : _h, _j = _a.showClubPriceLabel, showClubPriceLabel = _j === void 0 ? false : _j, isRatingLoading = _a.isRatingLoading;
6083
6133
  var theme = useTheme();
6084
6134
  var styles = getStylesBySize$9(size);
6085
- var isMobile = useWindowDimensions({ mobile: 0, desktop: 768 }).isMobile;
6135
+ var isMobile = useWindowDimensions().isMobile;
6086
6136
  var space = React$2.useMemo(function () {
6087
6137
  var _a;
6088
6138
  return (_a = {},
@@ -6181,7 +6231,7 @@ var ProductItemTK = function (_a) {
6181
6231
  } : _h, _j = _a.clubPrice, clubPrice = _j === void 0 ? '' : _j, _k = _a.showClubPriceLabel, showClubPriceLabel = _k === void 0 ? false : _k;
6182
6232
  var theme = useTheme();
6183
6233
  var styles = getStylesBySize$8(size);
6184
- var isMobile = useWindowDimensions({ mobile: 0, desktop: 768 }).isMobile;
6234
+ var isMobile = useWindowDimensions().isMobile;
6185
6235
  var space = React$2.useMemo(function () {
6186
6236
  var _a;
6187
6237
  return (_a = {},
@@ -13067,7 +13117,7 @@ var IconWrapper = newStyled.div(function (props) { return ({
13067
13117
  var IconsWithTitle = function (_a) {
13068
13118
  var _b;
13069
13119
  var iconName = _a.iconName, iconTitle = _a.iconTitle, _c = _a.iconFolder, iconFolder = _c === void 0 ? 'MyAccount' : _c, _d = _a.withWrapper, withWrapper = _d === void 0 ? true : _d, backgroundColor = _a.backgroundColor, iconColor = _a.iconColor, _e = _a.iconSizeDesktop, iconSizeDesktop = _e === void 0 ? 4 : _e, _f = _a.iconSizeMobile, iconSizeMobile = _f === void 0 ? 3 : _f, _g = _a.iconTitlePosition, iconTitlePosition = _g === void 0 ? 'bottom' : _g, _h = _a.iconTitleStyle, iconTitleStyle = _h === void 0 ? '' : _h, _j = _a.iconStyle, iconStyle = _j === void 0 ? '' : _j, _k = _a.isTitleInnerHtml, isTitleInnerHtml = _k === void 0 ? false : _k;
13070
- var isMobile = useWindowDimensions({ mobile: 0, desktop: 768 }).isMobile;
13120
+ var isMobile = useWindowDimensions().isMobile;
13071
13121
  // @ts-ignore
13072
13122
  var IconComponent = (_b = Icon[iconFolder][iconName]) !== null && _b !== void 0 ? _b : (function () { return 'Not found'; });
13073
13123
  if (IconComponent == null) {
@@ -13102,7 +13152,7 @@ var StyledTitle = newStyled.div(templateObject_3$s || (templateObject_3$s = __ma
13102
13152
  });
13103
13153
  var ImageCardWithDescription = function (_a) {
13104
13154
  var image = _a.image, title = _a.title, description = _a.description, _b = _a.titlePosition, titlePosition = _b === void 0 ? 'left' : _b;
13105
- var isMobile = useWindowDimensions({ desktop: 768, mobile: 0 }).isMobile;
13155
+ var isMobile = useWindowDimensions().isMobile;
13106
13156
  return (jsxRuntime.jsxs(Container$B, __assign$1({ "data-testid": "Container", isMobile: isMobile }, { children: [jsxRuntime.jsx(ImageContainer$2, __assign$1({ "data-testid": "ImageContainer", isMobile: isMobile }, { children: jsxRuntime.jsx(Image$3, { src: image, borderRadius: "40px", alt: "before", height: "100%", width: "100%" }, void 0) }), void 0), jsxRuntime.jsx(StyledTitle, __assign$1({ titlePosition: titlePosition, "data-testid": "StyledTitle" }, { children: isMobile ? (jsxRuntime.jsx(Text$8, __assign$1({ variant: "link", weight: "demi" }, { children: title }), void 0)) : (jsxRuntime.jsx(Text$8, __assign$1({ variant: "heading6", weight: "demi" }, { children: title }), void 0)) }), void 0), jsxRuntime.jsx(Text$8, __assign$1({ variant: "link", weight: "regular" }, { children: description }), void 0)] }), void 0));
13107
13157
  };
13108
13158
  var templateObject_1$P, templateObject_2$y, templateObject_3$s;
@@ -13727,9 +13777,9 @@ var range = function (limit) { return __spreadArray([], new Array(limit), true).
13727
13777
  var SlideDots = function (_a) {
13728
13778
  var quantity = _a.quantity, selectedIndex = _a.selectedIndex, containerDataTestId = _a.containerDataTestId;
13729
13779
  var theme = useTheme();
13730
- return (jsxRuntime.jsx(Container$u, __assign$1({ "data-testid": containerDataTestId }, { children: range(quantity).map(function (index) { return (jsxRuntime.jsx(Icon.SlideDots.SlideDot, { height: 0.75, width: 0.75, fill: index === selectedIndex
13780
+ return (jsxRuntime.jsx(Container$u, __assign$1({ "data-testid": containerDataTestId }, { children: range(quantity).map(function (index) { return (jsxRuntime.jsx(Icon$1, { name: "navigation/slide_dot".concat(index === selectedIndex ? '_solid' : ''), height: 0.75, width: 0.75, fill: index === selectedIndex
13731
13781
  ? theme.component.slideNavigation.slideDots.selectedDotColor
13732
- : theme.component.slideNavigation.slideDots.unselectedDotColor, opacity: theme.component.slideNavigation.slideDots.dotsOpacity, testId: "slide-dot-".concat(index) }, index)); }) }), void 0));
13782
+ : theme.component.slideNavigation.slideDots.unselectedDotColor, opacity: theme.component.slideNavigation.slideDots.dotsOpacity, testId: "slide-dot-".concat(index) }, "Icon-".concat(index, "-navigation/slide_dot").concat(index === selectedIndex ? '_solid' : ''))); }) }), void 0));
13733
13783
  };
13734
13784
  var templateObject_1$E;
13735
13785
 
@@ -18972,7 +19022,7 @@ var TextContainer = newStyled.div(templateObject_4$4 || (templateObject_4$4 = __
18972
19022
  var TextWithImage = function (_a) {
18973
19023
  var _b, _c, _d, _e;
18974
19024
  var title = _a.title, text = _a.text, children = _a.children, buttomText = _a.buttomText, backgroundColor = _a.backgroundColor, imageLeftSide = _a.imageLeftSide, titleStyle = _a.titleStyle, textStyle = _a.textStyle, _f = _a.buttonWideOnMobile, buttonWideOnMobile = _f === void 0 ? false : _f, props = __rest(_a, ["title", "text", "children", "buttomText", "backgroundColor", "imageLeftSide", "titleStyle", "textStyle", "buttonWideOnMobile"]);
18975
- var isMobile = useWindowDimensions({ desktop: 768, mobile: 0 }).isMobile;
19025
+ var isMobile = useWindowDimensions().isMobile;
18976
19026
  var ImageTitle = function () { return (jsx(Fragment, { children: !isMobile ? (jsx(Text$8, __assign$1({ variant: "heading2", weight: "bold", style: titleStyle
18977
19027
  ? titleStyle
18978
19028
  : {
@@ -19227,7 +19277,7 @@ var getDefaultCountdown = function () {
19227
19277
  var HurryUp = function (_a) {
19228
19278
  var hurryUpText = _a.hurryUpText, backgroundColor = _a.backgroundColor, _b = _a.iconSize, iconSize = _b === void 0 ? 1.5 : _b, _c = _a.textPosition, textPosition = _c === void 0 ? 'center' : _c, _d = _a.showTimer, showTimer = _d === void 0 ? false : _d, _e = _a.clockPosition, clockPosition = _e === void 0 ? 'left' : _e, _f = _a.countdown, countdown = _f === void 0 ? getDefaultCountdown() : _f, timerProps = __rest(_a, ["hurryUpText", "backgroundColor", "iconSize", "textPosition", "showTimer", "clockPosition", "countdown"]);
19229
19279
  var theme = useTheme();
19230
- return (jsxRuntime.jsxs(TimerContainer, __assign$1({ backgroundColor: backgroundColor || theme.component.card.backgroundColor, textPosition: textPosition, borderRadius: theme.component.hurryUp.borderRadius, "data-testid": "HurryUp" }, { children: [clockPosition === 'left' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Icon.PDP.Stopwatch, { width: iconSize, height: iconSize, fill: theme.colors.pallete.secondary.color }, void 0), "\u00A0"] }, void 0)), jsxRuntime.jsx(Text$8, __assign$1({ testId: "HurryUpText", variant: "body", size: "small", weight: "demi" }, { children: hurryUpText }), void 0), clockPosition === 'right' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Icon.PDP.Stopwatch, { width: iconSize, height: iconSize, fill: theme.colors.pallete.secondary.color }, void 0), "\u00A0"] }, void 0)), showTimer && jsxRuntime.jsx(Timer, __assign$1({ countdown: countdown, onTimeUp: function () { } }, timerProps), void 0)] }), void 0));
19280
+ return (jsxRuntime.jsxs(TimerContainer, __assign$1({ backgroundColor: backgroundColor || theme.component.card.backgroundColor, textPosition: textPosition, borderRadius: theme.component.hurryUp.borderRadius, "data-testid": "HurryUp" }, { children: [clockPosition === 'left' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Icon.PDP.Stopwatch, { width: iconSize, height: iconSize, fill: theme.colors.pallete.secondary.color }, void 0), "\u00A0"] }, void 0)), jsxRuntime.jsx(Text$8, __assign$1({ testId: "HurryUpText", variant: "body", size: "small", weight: "demi" }, { children: hurryUpText }), void 0), "\u00A0", clockPosition === 'right' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Icon.PDP.Stopwatch, { width: iconSize, height: iconSize, fill: theme.colors.pallete.secondary.color }, void 0), "\u00A0"] }, void 0)), showTimer && jsxRuntime.jsx(Timer, __assign$1({ countdown: countdown, onTimeUp: function () { } }, timerProps), void 0)] }), void 0));
19231
19281
  };
19232
19282
 
19233
19283
  var Container = newStyled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n svg {\n vertical-align: unset;\n }\n"], ["\n width: ", ";\n height: ", ";\n svg {\n vertical-align: unset;\n }\n"])), function (_a) {