@trafilea/afrodita-components 7.4.0 → 7.4.1
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/es/components/search-bar/SearchBar.js +1 -1
- package/build/es/components/search-bar/components/ResultsPanel/ResultsPanel.js +1 -1
- package/build/index.d.ts +2 -0
- package/build/lib/components/search-bar/SearchBar.js +1 -1
- package/build/lib/components/search-bar/components/ResultsPanel/ResultsPanel.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useReducer as r,useRef as n,useEffect as i}from"react";import l from"../../hooks/click-outside.js";import"../../types/enums.js";import{useTheme as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useReducer as r,useRef as n,useEffect as i}from"react";import l from"../../hooks/click-outside.js";import"../../types/enums.js";import{useTheme as s}from"../../core/theme/Theme.js";import"../atoms/PriceLabel/PriceLabel.js";import"../atoms/PriceLabelV2/PriceLabelV2.js";import"../atoms/ClubPriceMemberLabel/ClubPriceMemberLabel.styled.js";import"../atoms/HorizontalDivider/HorizontalDivider.js";import"../atoms/Icon/Icon.js";import"../atoms/Image/styled.js";import"../atoms/Toggle/toggle.styled.js";import"./components/ClearButton/styled.js";import"../text/Text.js";import"./components/Footer/styled.js";import"../pricing/clubOffer/ClubOfferTag.js";import"../pricing/discount/styled.js";import"../pricing/styles.js";import"../tooltip/Styled.js";import"../pricing/priceLabelV3/PriceLabelV3.js";import"../pricing/priceLabelV5/PriceLabelV5.styled.js";import"./components/ProductItem/styled.js";import{ResultsPanel as a}from"./components/ResultsPanel/ResultsPanel.js";import{SearchControl as c}from"./components/SearchControl/SearchControl.js";import{Container as m,Input as p}from"./styled.js";var u={selectedOption:void 0,open:!1,term:""},d=function(o,t){switch(t.type){case"UPDATE_TERM":return e(e({},o),{term:t.payload.term});case"CLEAR":return e(e({},o),{term:"",open:!1});case"TOGGLE_PANEL":return e(e({},o),{open:t.payload.open})}},f=function(f){var h=f.suggestions,v=f.resultOptions,y=f.onChange,j=f.onSearch,b=f.onClose,g=f.resultsPanelDataTestId,L=f.allResults,P=f.initialTerm,C=f.shouldClear,T=void 0!==C&&C,E=f.isBlogSearchBar,S=void 0!==E&&E,I=f.ariaLabel,A=void 0===I?"Search for products":I,D=f.placeholder,V=void 0===D?"Search for products":D,O=f.id,R=void 0===O?"search":O,G=f.autoComplete,k=void 0===G?"off":G,w=f.onItemClick,M=f.onFocus,_=s();P&&(u.term=P);var x=r(d,u),B=x[0],F=x[1],N=n(null),z=function(){return 0===v.length&&h.length>0&&!B.term};l(N,(function(){return F({type:"TOGGLE_PANEL",payload:{open:!1}})})),i((function(){var e=setTimeout((function(){y(B.term)}),500);return function(){return clearTimeout(e)}}),[y,B.term]);var H=v&&v.length>0?v:z()?h:[];return o("form",e({role:"search",onSubmit:function(e){e.cancelable&&e.preventDefault()},ref:N,style:{position:"relative"}},{children:[o(m,e({theme:_},{children:[t(p,{value:B.term,placeholder:V,onChange:function(e){return F({type:"UPDATE_TERM",payload:{term:e.target.value}})},onFocus:function(){F({type:"TOGGLE_PANEL",payload:{open:!0}}),null==M||M()},id:R,autoComplete:k,theme:_,"aria-label":A,onKeyDown:function(e){"Enter"===e.key&&(e.cancelable&&e.preventDefault(),e.stopPropagation(),j(B.term))}},void 0),t(c,{showSearchIcon:S,open:B.open,onClose:function(){T?F({type:"CLEAR",payload:{}}):b()},onSearch:function(){return j(B.term)}},void 0)]}),void 0),B.open&&!!H.length&&t(a,{testId:g,options:H,header:z()?"Most popular products":void 0,footer:L?"View all results (".concat(L,")"):void 0,onViewAll:function(){return j(B.term)},onItemClick:w},void 0)]}),void 0)};export{f as SearchBar};
|
|
2
2
|
//# sourceMappingURL=SearchBar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as t}from"tslib";import{jsxs as
|
|
1
|
+
import{__assign as t}from"tslib";import{jsxs as r,jsx as e}from"react/jsx-runtime";import{useTheme as o}from"../../../../core/theme/Theme.js";import{Text as i}from"../../../text/Text.js";import{Footer as n}from"../Footer/Footer.js";import{ProductItem as m}from"../ProductItem/ProductItem.js";import{Container as d,Header as c,OptionsList as l,OptionItem as h,Anchor as p}from"./styled.js";var s=function(s){var v=s.options,a=s.header,f=s.footer,u=s.onViewAll,j=s.testId,x=s.onItemClick,I=o();return r(d,t({"data-testid":j,theme:I},{children:[a&&e(c,t({theme:I},{children:e(i,t({variant:"heading6",weight:"demi"},{children:a}),void 0)}),void 0),e(l,{children:v.map((function(r){var o=r.optionUrl,i=r.price,n=r.src,d=r.title;return e(h,t({theme:I},{children:e(p,t({href:o,onClick:function(){return t={optionUrl:o,price:i,src:n,title:d},void(null==x||x(t));var t}},{children:e(m,{src:n,title:d,price:i},void 0)}),void 0)}),d)}))},void 0),f&&e(n,{text:f,onClick:u},void 0)]}),void 0)};export{s as ResultsPanel};
|
|
2
2
|
//# sourceMappingURL=ResultsPanel.js.map
|
package/build/index.d.ts
CHANGED
|
@@ -3766,6 +3766,8 @@ declare type SearchBarProps = {
|
|
|
3766
3766
|
placeholder?: string;
|
|
3767
3767
|
id?: string;
|
|
3768
3768
|
autoComplete?: string;
|
|
3769
|
+
onItemClick?: (item: SearchBarOptionItem) => void;
|
|
3770
|
+
onFocus?: () => void;
|
|
3769
3771
|
};
|
|
3770
3772
|
declare const SearchBar: react__default.FC<SearchBarProps>;
|
|
3771
3773
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("react"),o=require("../../hooks/click-outside.js");require("../../types/enums.js");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("react"),o=require("../../hooks/click-outside.js");require("../../types/enums.js");var n=require("../../core/theme/Theme.js");require("../atoms/PriceLabel/PriceLabel.js"),require("../atoms/PriceLabelV2/PriceLabelV2.js"),require("../atoms/ClubPriceMemberLabel/ClubPriceMemberLabel.styled.js"),require("../atoms/HorizontalDivider/HorizontalDivider.js"),require("../atoms/Icon/Icon.js"),require("../atoms/Image/styled.js"),require("../atoms/Toggle/toggle.styled.js"),require("./components/ClearButton/styled.js"),require("../text/Text.js"),require("./components/Footer/styled.js"),require("../pricing/clubOffer/ClubOfferTag.js"),require("../pricing/discount/styled.js"),require("../pricing/styles.js"),require("../tooltip/Styled.js"),require("../pricing/priceLabelV3/PriceLabelV3.js"),require("../pricing/priceLabelV5/PriceLabelV5.styled.js"),require("./components/ProductItem/styled.js");var s=require("./components/ResultsPanel/ResultsPanel.js"),i=require("./components/SearchControl/SearchControl.js"),a=require("./styled.js"),l={selectedOption:void 0,open:!1,term:""},u=function(r,t){switch(t.type){case"UPDATE_TERM":return e.__assign(e.__assign({},r),{term:t.payload.term});case"CLEAR":return e.__assign(e.__assign({},r),{term:"",open:!1});case"TOGGLE_PANEL":return e.__assign(e.__assign({},r),{open:t.payload.open})}};exports.SearchBar=function(c){var p=c.suggestions,d=c.resultOptions,m=c.onChange,h=c.onSearch,f=c.onClose,g=c.resultsPanelDataTestId,j=c.allResults,v=c.initialTerm,y=c.shouldClear,q=void 0!==y&&y,b=c.isBlogSearchBar,_=void 0!==b&&b,P=c.ariaLabel,C=void 0===P?"Search for products":P,L=c.placeholder,T=void 0===L?"Search for products":L,E=c.id,S=void 0===E?"search":E,x=c.autoComplete,I=void 0===x?"off":x,R=c.onItemClick,A=c.onFocus,D=n.useTheme();v&&(l.term=v);var O=t.useReducer(u,l),V=O[0],G=O[1],M=t.useRef(null),k=function(){return 0===d.length&&p.length>0&&!V.term};o(M,(function(){return G({type:"TOGGLE_PANEL",payload:{open:!1}})})),t.useEffect((function(){var e=setTimeout((function(){m(V.term)}),500);return function(){return clearTimeout(e)}}),[m,V.term]);var w=d&&d.length>0?d:k()?p:[];return r.jsxs("form",e.__assign({role:"search",onSubmit:function(e){e.cancelable&&e.preventDefault()},ref:M,style:{position:"relative"}},{children:[r.jsxs(a.Container,e.__assign({theme:D},{children:[r.jsx(a.Input,{value:V.term,placeholder:T,onChange:function(e){return G({type:"UPDATE_TERM",payload:{term:e.target.value}})},onFocus:function(){G({type:"TOGGLE_PANEL",payload:{open:!0}}),null==A||A()},id:S,autoComplete:I,theme:D,"aria-label":C,onKeyDown:function(e){"Enter"===e.key&&(e.cancelable&&e.preventDefault(),e.stopPropagation(),h(V.term))}},void 0),r.jsx(i.SearchControl,{showSearchIcon:_,open:V.open,onClose:function(){q?G({type:"CLEAR",payload:{}}):f()},onSearch:function(){return h(V.term)}},void 0)]}),void 0),V.open&&!!w.length&&r.jsx(s.ResultsPanel,{testId:g,options:w,header:k()?"Most popular products":void 0,footer:j?"View all results (".concat(j,")"):void 0,onViewAll:function(){return h(V.term)},onItemClick:R},void 0)]}),void 0)};
|
|
2
2
|
//# sourceMappingURL=SearchBar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("../../../../core/theme/Theme.js"),i=require("../../../text/Text.js"),s=require("../Footer/Footer.js"),o=require("../ProductItem/ProductItem.js"),n=require("./styled.js");exports.ResultsPanel=function(d){var c=d.options,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("../../../../core/theme/Theme.js"),i=require("../../../text/Text.js"),s=require("../Footer/Footer.js"),o=require("../ProductItem/ProductItem.js"),n=require("./styled.js");exports.ResultsPanel=function(d){var c=d.options,l=d.header,u=d.footer,a=d.onViewAll,h=d.testId,j=d.onItemClick,x=t.useTheme();return r.jsxs(n.Container,e.__assign({"data-testid":h,theme:x},{children:[l&&r.jsx(n.Header,e.__assign({theme:x},{children:r.jsx(i.Text,e.__assign({variant:"heading6",weight:"demi"},{children:l}),void 0)}),void 0),r.jsx(n.OptionsList,{children:c.map((function(t){var i=t.optionUrl,s=t.price,d=t.src,c=t.title;return r.jsx(n.OptionItem,e.__assign({theme:x},{children:r.jsx(n.Anchor,e.__assign({href:i,onClick:function(){return e={optionUrl:i,price:s,src:d,title:c},void(null==j||j(e));var e}},{children:r.jsx(o.ProductItem,{src:d,title:c,price:s},void 0)}),void 0)}),c)}))},void 0),u&&r.jsx(s.Footer,{text:u,onClick:a},void 0)]}),void 0)};
|
|
2
2
|
//# sourceMappingURL=ResultsPanel.js.map
|
package/package.json
CHANGED