@trafilea/afrodita-components 5.0.0-beta.25 → 5.0.0-beta.27

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
@@ -1413,6 +1413,7 @@ interface ProductItemProps {
1413
1413
 
1414
1414
  interface ProductItemSmallMobileProps extends ProductItemProps {
1415
1415
  size: ComponentSize.Medium | ComponentSize.Small | ComponentSize.Large;
1416
+ onClick?: () => void;
1416
1417
  }
1417
1418
 
1418
1419
  declare function withProductGrid<P extends ProductItemProps>(ProductItemComponent: React.FC<P>, data: ProductItemProps[]): {
@@ -1421,7 +1422,7 @@ declare function withProductGrid<P extends ProductItemProps>(ProductItemComponen
1421
1422
  };
1422
1423
 
1423
1424
  declare const Collection: {
1424
- ProductItemMobile: ({ title, image, price, rating, size, tags, alignName, url, className, }: ProductItemSmallMobileProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1425
+ ProductItemMobile: ({ title, image, price, rating, size, tags, alignName, url, className, onClick, }: ProductItemSmallMobileProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1425
1426
  withProductGrid: typeof withProductGrid;
1426
1427
  };
1427
1428
 
@@ -1591,8 +1592,9 @@ interface SearchBarProps {
1591
1592
  resultsPanelDataTestId?: string;
1592
1593
  allResults?: number;
1593
1594
  initialTerm?: string;
1595
+ shouldClear?: boolean;
1594
1596
  }
1595
- declare const SearchBar: ({ suggestions, resultOptions, onChange, onSearch, onClose, resultsPanelDataTestId, allResults, initialTerm, }: SearchBarProps) => JSX.Element;
1597
+ declare const SearchBar: ({ suggestions, resultOptions, onChange, onSearch, onClose, resultsPanelDataTestId, allResults, initialTerm, shouldClear, }: SearchBarProps) => JSX.Element;
1596
1598
 
1597
1599
  interface ProductGalleryMobileProps {
1598
1600
  images: ImageType[];
@@ -10249,7 +10249,7 @@ var getStylesBySize = function (size) {
10249
10249
  }
10250
10250
  };
10251
10251
  var ProductItemMobile = function (_a) {
10252
- 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, url = _a.url, className = _a.className;
10252
+ 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, url = _a.url, className = _a.className, onClick = _a.onClick;
10253
10253
  var theme = useTheme();
10254
10254
  var styles = getStylesBySize(size);
10255
10255
  var space = useMemo(function () {
@@ -10260,7 +10260,7 @@ var ProductItemMobile = function (_a) {
10260
10260
  _a[ComponentSize.Small] = 2,
10261
10261
  _a)[size];
10262
10262
  }, [size]);
10263
- return (jsxs(Container$f, __assign$1({ as: url ? 'a' : 'div', href: url, className: className }, { children: [tags ? (jsxs(ImageContainer, __assign$1({ 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), (tags === null || tags === void 0 ? void 0 : tags.seasonOfferTagText) && (jsx(SeasonOfferTag, { text: tags.seasonOfferTagText, size: ComponentSize.Small, css: { position: 'absolute', top: 0, left: 0 } }, void 0)), (tags === null || tags === void 0 ? void 0 : tags.categoryTagText) && (jsx(CategoryTag, { text: tags.categoryTagText, size: 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: space }, void 0), jsx(H1, __assign$1({ theme: theme, align: alignName }, { children: title }), void 0), jsx(Spacing, { size: space }, void 0), jsx(PriceLabel, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, color: price.color, size: ComponentSize.Small, testId: "volume-discount" }, void 0), jsx(Spacing, { size: space }, void 0), jsx(Rating, { size: size === ComponentSize.Large ? ComponentSize.Small : ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "", wrapWithParenthesis: true }, void 0)] }), void 0));
10263
+ return (jsxs(Container$f, __assign$1({ as: url ? 'a' : 'div', href: url, className: className, onClick: onClick }, { children: [tags ? (jsxs(ImageContainer, __assign$1({ 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), (tags === null || tags === void 0 ? void 0 : tags.seasonOfferTagText) && (jsx(SeasonOfferTag, { text: tags.seasonOfferTagText, size: ComponentSize.Small, css: { position: 'absolute', top: 0, left: 0 } }, void 0)), (tags === null || tags === void 0 ? void 0 : tags.categoryTagText) && (jsx(CategoryTag, { text: tags.categoryTagText, size: 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: space }, void 0), jsx(H1, __assign$1({ theme: theme, align: alignName }, { children: title }), void 0), jsx(Spacing, { size: space }, void 0), jsx(PriceLabel, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, color: price.color, size: ComponentSize.Small, testId: "volume-discount" }, void 0), jsx(Spacing, { size: space }, void 0), jsx(Rating, { size: size === ComponentSize.Large ? ComponentSize.Small : ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "", wrapWithParenthesis: true }, void 0)] }), void 0));
10264
10264
  };
10265
10265
  var templateObject_1$n, templateObject_2$d;
10266
10266
 
@@ -10601,6 +10601,9 @@ var reducer = function (state, action) {
10601
10601
  case 'UPDATE_TERM': {
10602
10602
  return __assign$1(__assign$1({}, state), { term: action.payload.term });
10603
10603
  }
10604
+ case 'CLEAR': {
10605
+ return __assign$1(__assign$1({}, state), { term: '', open: false });
10606
+ }
10604
10607
  case 'TOGGLE_PANEL': {
10605
10608
  return __assign$1(__assign$1({}, state), { open: action.payload.open });
10606
10609
  }
@@ -10611,12 +10614,12 @@ var Container$8 = newStyled.div({
10611
10614
  display: 'flex',
10612
10615
  });
10613
10616
  var SearchBar = function (_a) {
10614
- var suggestions = _a.suggestions, resultOptions = _a.resultOptions, onChange = _a.onChange, onSearch = _a.onSearch, onClose = _a.onClose, resultsPanelDataTestId = _a.resultsPanelDataTestId, allResults = _a.allResults, initialTerm = _a.initialTerm;
10617
+ var suggestions = _a.suggestions, resultOptions = _a.resultOptions, onChange = _a.onChange, onSearch = _a.onSearch, onClose = _a.onClose, resultsPanelDataTestId = _a.resultsPanelDataTestId, allResults = _a.allResults, initialTerm = _a.initialTerm, _b = _a.shouldClear, shouldClear = _b === void 0 ? false : _b;
10615
10618
  var theme = useTheme();
10616
10619
  if (initialTerm) {
10617
10620
  initialState$1.term = initialTerm;
10618
10621
  }
10619
- var _b = useReducer(reducer, initialState$1), state = _b[0], dispatch = _b[1];
10622
+ var _c = useReducer(reducer, initialState$1), state = _c[0], dispatch = _c[1];
10620
10623
  var ref = useRef(null);
10621
10624
  var shouldDisplaySuggestion = function () {
10622
10625
  return resultOptions.length === 0 && suggestions.length > 0 && !state.term;
@@ -10634,7 +10637,21 @@ var SearchBar = function (_a) {
10634
10637
  : shouldDisplaySuggestion()
10635
10638
  ? suggestions
10636
10639
  : [];
10637
- return (jsxs$1("form", __assign$1({ role: "search", onSubmit: function (e) { return e.preventDefault(); }, ref: ref, style: { position: 'relative' } }, { children: [jsxs$1(Container$8, __assign$1({ theme: theme }, { children: [jsx$1(Input, { value: state.term, placeholder: "Search for products", onChange: function (e) { return dispatch({ type: 'UPDATE_TERM', payload: { term: e.target.value } }); }, onFocus: function () { return dispatch({ type: 'TOGGLE_PANEL', payload: { open: true } }); }, id: "search", autoComplete: "off", theme: theme, "aria-label": "Search for products" }, void 0), jsx$1(SearchControl, { open: state.open, onClose: onClose, onSearch: function () { return onSearch(state.term); } }, void 0)] }), void 0), state.open && !!options.length && (jsx$1(ResultsPanel, { testId: resultsPanelDataTestId, options: options, header: shouldDisplaySuggestion() ? 'Most popular products' : undefined, footer: allResults ? "View all results (".concat(allResults, ")") : undefined, onViewAll: function () { return onSearch(state.term); } }, void 0))] }), void 0));
10640
+ var handleOnClose = function () {
10641
+ if (shouldClear) {
10642
+ dispatch({ type: 'CLEAR', payload: {} });
10643
+ }
10644
+ else {
10645
+ onClose();
10646
+ }
10647
+ };
10648
+ return (jsxs$1("form", __assign$1({ role: "search", onSubmit: function (e) { return e.preventDefault(); }, ref: ref, style: { position: 'relative' } }, { children: [jsxs$1(Container$8, __assign$1({ theme: theme }, { children: [jsx$1(Input, { value: state.term, placeholder: "Search for products", onChange: function (e) { return dispatch({ type: 'UPDATE_TERM', payload: { term: e.target.value } }); }, onFocus: function () { return dispatch({ type: 'TOGGLE_PANEL', payload: { open: true } }); }, id: "search", autoComplete: "off", theme: theme, "aria-label": "Search for products", onKeyDown: function (e) {
10649
+ if (e.key === 'Enter') {
10650
+ e.preventDefault();
10651
+ e.stopPropagation();
10652
+ onSearch(state.term);
10653
+ }
10654
+ } }, void 0), jsx$1(SearchControl, { open: state.open, onClose: handleOnClose, onSearch: function () { return onSearch(state.term); } }, void 0)] }), void 0), state.open && !!options.length && (jsx$1(ResultsPanel, { testId: resultsPanelDataTestId, options: options, header: shouldDisplaySuggestion() ? 'Most popular products' : undefined, footer: allResults ? "View all results (".concat(allResults, ")") : undefined, onViewAll: function () { return onSearch(state.term); } }, void 0))] }), void 0));
10638
10655
  };
10639
10656
 
10640
10657
  function _extends() {