@trafilea/afrodita-components 7.4.0 → 7.4.2

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.
@@ -1,2 +1,2 @@
1
- import{__makeTemplateObject as n}from"tslib";import e from"@emotion/styled";var i,t,r,o,a=e.div(i||(i=n(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n padding: 0.625rem 0;\n border-radius: ".concat(n.borderRadius,";\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n max-width: 3.75rem;\n\n * {\n color: ").concat(n.color,";\n }\n "),i="\n ".concat(e,"\n border: none;\n "),t="\n ".concat(e,"\n border: 0.063rem solid ").concat(n.borderColor,";\n ");return n.isOutlined?i:t})),d=e.span(t||(t=n(["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"],["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"]))),c=e(d)(r||(r=n(["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"],["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"]))),l=e(d)(o||(o=n(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n cursor: pointer;\n user-select: none;\n padding: 0 0.313rem;\n font-weight: 400;\n color: ".concat(n.isMaxSelected?"var(--colors-shades-175-color)":"inherit",";\n "),i="\n ".concat(e,"\n border: 1px solid ").concat(n.borderColor,";\n border-radius: 8px;\n min-width: 26px;\n min-height: 26px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n img {\n width: 14px;\n height: 14px;\n }\n "),t="\n ".concat(e,"\n border: none;\n border-radius: 0;\n min-width: auto;\n min-height: auto;\n display: inline;\n align-items: initial;\n justify-content: initial;\n ");return n.isOutlined?i:t}));export{a as Container,l as IncreaseDecrease,d as Item,c as NumberContainer};
1
+ import{__makeTemplateObject as n}from"tslib";import e from"@emotion/styled";var i,t,r,o,a=e.div(i||(i=n(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n padding: 0.625rem 0;\n border-radius: ".concat(n.borderRadius,";\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n max-width: 3.75rem;\n\n * {\n color: ").concat(n.color,";\n }\n "),i="\n ".concat(e,"\n border: none;\n margin-right: 4px;\n "),t="\n ".concat(e,"\n border: 0.063rem solid ").concat(n.borderColor,";\n ");return n.isOutlined?i:t})),d=e.span(t||(t=n(["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"],["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"]))),c=e(d)(r||(r=n(["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"],["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"]))),l=e(d)(o||(o=n(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n cursor: pointer;\n user-select: none;\n padding: 0 0.313rem;\n font-weight: 400;\n color: ".concat(n.isMaxSelected?"var(--colors-shades-175-color)":"inherit",";\n "),i="\n ".concat(e,"\n border: 1px solid ").concat(n.borderColor,";\n border-radius: 8px;\n min-width: 26px;\n min-height: 26px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n img {\n width: 14px;\n height: 14px;\n }\n "),t="\n ".concat(e,"\n border: none;\n border-radius: 0;\n min-width: auto;\n min-height: auto;\n display: inline;\n align-items: initial;\n justify-content: initial;\n ");return n.isOutlined?i:t}));export{a as Container,l as IncreaseDecrease,d as Item,c as NumberContainer};
2
2
  //# sourceMappingURL=styled.js.map
@@ -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 a}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 s}from"./components/ResultsPanel/ResultsPanel.js";import{SearchControl as p}from"./components/SearchControl/SearchControl.js";import{Container as m,Input as c}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,A=f.ariaLabel,D=void 0===A?"Search for products":A,V=f.placeholder,I=void 0===V?"Search for products":V,O=f.id,R=void 0===O?"search":O,G=f.autoComplete,w=void 0===G?"off":G,M=a();P&&(u.term=P);var _=r(d,u),x=_[0],k=_[1],B=n(null),N=function(){return 0===v.length&&h.length>0&&!x.term};l(B,(function(){return k({type:"TOGGLE_PANEL",payload:{open:!1}})})),i((function(){var e=setTimeout((function(){y(x.term)}),500);return function(){return clearTimeout(e)}}),[y,x.term]);var z=v&&v.length>0?v:N()?h:[];return o("form",e({role:"search",onSubmit:function(e){e.cancelable&&e.preventDefault()},ref:B,style:{position:"relative"}},{children:[o(m,e({theme:M},{children:[t(c,{value:x.term,placeholder:I,onChange:function(e){return k({type:"UPDATE_TERM",payload:{term:e.target.value}})},onFocus:function(){return k({type:"TOGGLE_PANEL",payload:{open:!0}})},id:R,autoComplete:w,theme:M,"aria-label":D,onKeyDown:function(e){"Enter"===e.key&&(e.cancelable&&e.preventDefault(),e.stopPropagation(),j(x.term))}},void 0),t(p,{showSearchIcon:S,open:x.open,onClose:function(){T?k({type:"CLEAR",payload:{}}):b()},onSearch:function(){return j(x.term)}},void 0)]}),void 0),x.open&&!!z.length&&t(s,{testId:g,options:z,header:N()?"Most popular products":void 0,footer:L?"View all results (".concat(L,")"):void 0,onViewAll:function(){return j(x.term)}},void 0)]}),void 0)};export{f as SearchBar};
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 e,jsx as r}from"react/jsx-runtime";import{useTheme as o}from"../../../../core/theme/Theme.js";import{Text as i}from"../../../text/Text.js";import{Footer as m}from"../Footer/Footer.js";import{ProductItem as d}from"../ProductItem/ProductItem.js";import{Container as n,Header as c,OptionsList as h,OptionItem as l,Anchor as p}from"./styled.js";var s=function(s){var a=s.options,f=s.header,v=s.footer,u=s.onViewAll,j=s.testId,x=o();return e(n,t({"data-testid":j,theme:x},{children:[f&&r(c,t({theme:x},{children:r(i,t({variant:"heading6",weight:"demi"},{children:f}),void 0)}),void 0),r(h,{children:a.map((function(e){var o=e.optionUrl,i=e.price,m=e.src,n=e.title;return r(l,t({theme:x},{children:r(p,t({href:o},{children:r(d,{src:m,title:n,price:i},void 0)}),void 0)}),n)}))},void 0),v&&r(m,{text:v,onClick:u},void 0)]}),void 0)};export{s as ResultsPanel};
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 n=require("tslib");function e(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var t,i,r,o,a=e(require("@emotion/styled")),d=a.default.div(t||(t=n.__makeTemplateObject(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n padding: 0.625rem 0;\n border-radius: ".concat(n.borderRadius,";\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n max-width: 3.75rem;\n\n * {\n color: ").concat(n.color,";\n }\n "),t="\n ".concat(e,"\n border: none;\n "),i="\n ".concat(e,"\n border: 0.063rem solid ").concat(n.borderColor,";\n ");return n.isOutlined?t:i})),c=a.default.span(i||(i=n.__makeTemplateObject(["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"],["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"]))),l=a.default(c)(r||(r=n.__makeTemplateObject(["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"],["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"]))),s=a.default(c)(o||(o=n.__makeTemplateObject(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n cursor: pointer;\n user-select: none;\n padding: 0 0.313rem;\n font-weight: 400;\n color: ".concat(n.isMaxSelected?"var(--colors-shades-175-color)":"inherit",";\n "),t="\n ".concat(e,"\n border: 1px solid ").concat(n.borderColor,";\n border-radius: 8px;\n min-width: 26px;\n min-height: 26px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n img {\n width: 14px;\n height: 14px;\n }\n "),i="\n ".concat(e,"\n border: none;\n border-radius: 0;\n min-width: auto;\n min-height: auto;\n display: inline;\n align-items: initial;\n justify-content: initial;\n ");return n.isOutlined?t:i}));exports.Container=d,exports.IncreaseDecrease=s,exports.Item=c,exports.NumberContainer=l;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib");function e(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var t,i,r,o,a=e(require("@emotion/styled")),d=a.default.div(t||(t=n.__makeTemplateObject(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n padding: 0.625rem 0;\n border-radius: ".concat(n.borderRadius,";\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n max-width: 3.75rem;\n\n * {\n color: ").concat(n.color,";\n }\n "),t="\n ".concat(e,"\n border: none;\n margin-right: 4px;\n "),i="\n ".concat(e,"\n border: 0.063rem solid ").concat(n.borderColor,";\n ");return n.isOutlined?t:i})),c=a.default.span(i||(i=n.__makeTemplateObject(["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"],["\n font-size: 0.875rem;\n line-height: 1.125rem;\n margin: 0;\n padding: 0;\n"]))),l=a.default(c)(r||(r=n.__makeTemplateObject(["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"],["\n width: 1.25rem;\n text-align: center;\n font-weight: 600;\n"]))),s=a.default(c)(o||(o=n.__makeTemplateObject(["\n ","\n"],["\n ","\n"])),(function(n){var e="\n cursor: pointer;\n user-select: none;\n padding: 0 0.313rem;\n font-weight: 400;\n color: ".concat(n.isMaxSelected?"var(--colors-shades-175-color)":"inherit",";\n "),t="\n ".concat(e,"\n border: 1px solid ").concat(n.borderColor,";\n border-radius: 8px;\n min-width: 26px;\n min-height: 26px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n img {\n width: 14px;\n height: 14px;\n }\n "),i="\n ".concat(e,"\n border: none;\n border-radius: 0;\n min-width: auto;\n min-height: auto;\n display: inline;\n align-items: initial;\n justify-content: initial;\n ");return n.isOutlined?t:i}));exports.Container=d,exports.IncreaseDecrease=s,exports.Item=c,exports.NumberContainer=l;
2
2
  //# sourceMappingURL=styled.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("react"),o=require("../../hooks/click-outside.js");require("../../types/enums.js");var s=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 n=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,L=void 0===P?"Search for products":P,C=c.placeholder,T=void 0===C?"Search for products":C,E=c.id,S=void 0===E?"search":E,x=c.autoComplete,R=void 0===x?"off":x,A=s.useTheme();v&&(l.term=v);var D=t.useReducer(u,l),I=D[0],O=D[1],V=t.useRef(null),G=function(){return 0===d.length&&p.length>0&&!I.term};o(V,(function(){return O({type:"TOGGLE_PANEL",payload:{open:!1}})})),t.useEffect((function(){var e=setTimeout((function(){m(I.term)}),500);return function(){return clearTimeout(e)}}),[m,I.term]);var M=d&&d.length>0?d:G()?p:[];return r.jsxs("form",e.__assign({role:"search",onSubmit:function(e){e.cancelable&&e.preventDefault()},ref:V,style:{position:"relative"}},{children:[r.jsxs(a.Container,e.__assign({theme:A},{children:[r.jsx(a.Input,{value:I.term,placeholder:T,onChange:function(e){return O({type:"UPDATE_TERM",payload:{term:e.target.value}})},onFocus:function(){return O({type:"TOGGLE_PANEL",payload:{open:!0}})},id:S,autoComplete:R,theme:A,"aria-label":L,onKeyDown:function(e){"Enter"===e.key&&(e.cancelable&&e.preventDefault(),e.stopPropagation(),h(I.term))}},void 0),r.jsx(i.SearchControl,{showSearchIcon:_,open:I.open,onClose:function(){q?O({type:"CLEAR",payload:{}}):f()},onSearch:function(){return h(I.term)}},void 0)]}),void 0),I.open&&!!M.length&&r.jsx(n.ResultsPanel,{testId:g,options:M,header:G()?"Most popular products":void 0,footer:j?"View all results (".concat(j,")"):void 0,onViewAll:function(){return h(I.term)}},void 0)]}),void 0)};
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,a=d.header,u=d.footer,l=d.onViewAll,h=d.testId,j=t.useTheme();return r.jsxs(n.Container,e.__assign({"data-testid":h,theme:j},{children:[a&&r.jsx(n.Header,e.__assign({theme:j},{children:r.jsx(i.Text,e.__assign({variant:"heading6",weight:"demi"},{children:a}),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:j},{children:r.jsx(n.Anchor,e.__assign({href:i},{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:l},void 0)]}),void 0)};
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
@@ -3,7 +3,7 @@
3
3
  "description": "Trafilea's Design System",
4
4
  "author": "Trafilea",
5
5
  "repository": "https://github.com/trafilea/afrodita-components",
6
- "version": "7.4.0",
6
+ "version": "7.4.2",
7
7
  "private": false,
8
8
  "main": "build/lib/index.js",
9
9
  "style": "build/es/index.css",