@trafilea/afrodita-components 5.0.0-beta.23 → 5.0.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/build/index.d.ts CHANGED
@@ -1587,11 +1587,12 @@ interface SearchBarProps {
1587
1587
  resultOptions: SearchBarOptionItem[];
1588
1588
  onChange: (text: string) => void;
1589
1589
  onSearch: (term: string) => void;
1590
+ onClose: () => void;
1590
1591
  resultsPanelDataTestId?: string;
1591
1592
  allResults?: number;
1592
1593
  initialTerm?: string;
1593
1594
  }
1594
- declare const SearchBar: ({ suggestions, resultOptions, onChange, onSearch, resultsPanelDataTestId, allResults, initialTerm, }: SearchBarProps) => JSX.Element;
1595
+ declare const SearchBar: ({ suggestions, resultOptions, onChange, onSearch, onClose, resultsPanelDataTestId, allResults, initialTerm, }: SearchBarProps) => JSX.Element;
1595
1596
 
1596
1597
  interface ProductGalleryMobileProps {
1597
1598
  images: ImageType[];
@@ -10577,11 +10577,11 @@ var SearchIconContainer = newStyled.div({
10577
10577
  alignSelf: 'center',
10578
10578
  });
10579
10579
  var SearchControl = function (_a) {
10580
- var open = _a.open, onSearch = _a.onSearch, onClear = _a.onClear;
10580
+ var open = _a.open, onSearch = _a.onSearch, onClose = _a.onClose;
10581
10581
  var theme = useTheme();
10582
10582
  var isMobile = useWindowDimensions(theme.mediaQueries).isMobile;
10583
10583
  if (isMobile) {
10584
- return open ? (jsx(ClearButton, { onClick: onClear }, void 0)) : (jsx(SearchIconContainer, { children: jsx(Icon.Navigation.Search, { height: 1.25, width: 1.25 }, void 0) }, void 0));
10584
+ return open ? (jsx(ClearButton, { onClick: onClose }, void 0)) : (jsx(SearchIconContainer, { children: jsx(Icon.Navigation.Search, { height: 1.25, width: 1.25 }, void 0) }, void 0));
10585
10585
  }
10586
10586
  else {
10587
10587
  return (jsxs(Fragment, { children: [jsx(ButtonSecondary, { css: {
@@ -10591,7 +10591,7 @@ var SearchControl = function (_a) {
10591
10591
  borderTopLeftRadius: 0,
10592
10592
  borderBottomLeftRadius: 0,
10593
10593
  padding: '0.875rem 1.5rem',
10594
- }, text: "SEARCH", onClick: onSearch }, void 0), jsx(ClearButton, { onClick: onClear }, void 0)] }, void 0));
10594
+ }, text: "SEARCH", onClick: onSearch }, void 0), jsx(ClearButton, { onClick: onClose }, void 0)] }, void 0));
10595
10595
  }
10596
10596
  };
10597
10597
 
@@ -10604,9 +10604,6 @@ var reducer = function (state, action) {
10604
10604
  case 'TOGGLE_PANEL': {
10605
10605
  return __assign$1(__assign$1({}, state), { open: action.payload.open });
10606
10606
  }
10607
- case 'CLEAR': {
10608
- return __assign$1(__assign$1({}, state), { term: '', open: false });
10609
- }
10610
10607
  }
10611
10608
  };
10612
10609
  var Container$8 = newStyled.div({
@@ -10614,7 +10611,7 @@ var Container$8 = newStyled.div({
10614
10611
  display: 'flex',
10615
10612
  });
10616
10613
  var SearchBar = function (_a) {
10617
- var suggestions = _a.suggestions, resultOptions = _a.resultOptions, onChange = _a.onChange, onSearch = _a.onSearch, resultsPanelDataTestId = _a.resultsPanelDataTestId, allResults = _a.allResults, initialTerm = _a.initialTerm;
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;
10618
10615
  var theme = useTheme();
10619
10616
  if (initialTerm) {
10620
10617
  initialState$1.term = initialTerm;
@@ -10637,7 +10634,7 @@ var SearchBar = function (_a) {
10637
10634
  : shouldDisplaySuggestion()
10638
10635
  ? suggestions
10639
10636
  : [];
10640
- 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, onClear: function () { return dispatch({ type: 'CLEAR', payload: {} }); }, 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));
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));
10641
10638
  };
10642
10639
 
10643
10640
  function _extends() {