@trafilea/afrodita-components 7.10.0 → 7.10.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.
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as t}from"tslib";import{jsxs as n,Fragment as o,jsx as c}from"react/jsx-runtime";import{useState as i,useEffect as l,useCallback as r}from"react";import{useTheme as d}from"../../core/theme/Theme.js";import{ComponentSize as a}from"../../types/enums.js";import"../../utils/constants/offerAtCart.js";import"../../utils/media.js";import"../../utils/mock-content/CancellationFlowAccordion.js";import{simulateMouseClick as s}from"../../utils/simulateClick/simulateClick.js";import{Checkbox as u}from"../checkbox/Checkbox.js";import"@emotion/react/jsx-runtime";import"../cta/styled.js";import m from"../cta/secondary/ButtonSecondary.js";import{Icon as h}from"../icons/index.js";import f from"../selector/simple/SelectorSecondary.js";import{Accordion as k}from"./Accordion.js";import{Header as x,H4 as b,ClearAll as p,MobileHeader as v,MobileIconsContainer as I,OptionContainer as g,FilterLink as C,SectionContent as j,MobileFooter as y,MobileClearContainer as w}from"./FiltersStyled.js";import{Tags as A}from"./Tags/Tags.js";var T=function(u){var T=u.values,B=u.onChange,S=u.tagsColor,O=void 0===S?"#fff6ef":S,z=u.filterByText,E=u.clearAllText,$=u.isMobile,D=u.filtersSelectText,F=u.showSelectedNumberInSection,L=void 0!==F&&F,H=u.applyText,R=u.mobileApplyButtonClick,V=u.mobileBackArrowClick,N=u.onResetValues,q=d(),G=i(T),J=G[0],K=G[1],P=i(function(){var e=[];return T.forEach((function(t,n){t.items.forEach((function(t,o){t.checked&&!t.blockUncheck&&e.push({sectionIndex:n,sectionTitle:t.label,itemIndex:o,label:t.label})}))})),e}()),Q=P[0],W=P[1],X=i(),Y=X[0],Z=X[1];l((function(){J.length&&Y&&B(J,Y)}),[Y,J,B]);var _=r((function(e){e.forEach((function(e){var t=e.sectionIndex,n=e.itemIndex;te({sectionIndex:t,itemIndex:n})}))}),[]),ee=r((function(n){var o=n.sectionIndex,c=n.itemIndex,i=n.checked;Z({sectionIndex:o,itemIndex:c,checked:i});var l=J[o],r=null==l?void 0:l.items[c];(null==r?void 0:r.isLinkItem)&&(null==r?void 0:r.link)?i&&window.location.assign(r.link):(W((function(t){return l.isMultiselect||t.length>0&&_([]),i?e(e([],l.isMultiselect?t:t.filter((function(e){return e.sectionIndex!==o})),!0),[{sectionIndex:o,itemIndex:c,label:J[o].items[c].label,sectionTitle:J[o].title}],!1):t.filter((function(e){return e.sectionIndex!==o||e.itemIndex!==c}))})),K((function(e){return e.map((function(e,n){return o!==n?e:t(t({},e),{items:e.items.map((function(n,o){return t(t({},n),{label:n.label,checked:c===o?i:!!e.isMultiselect&&n.checked})}))})}))})))}),[J,_]),te=function(e){var t=e.sectionIndex,n=e.itemIndex,o=document.getElementById("filter[".concat(t,",").concat(n,"]"));s(o)},ne=function(){_(Q),W([]),K((function(e){return e.map((function(e){return t(t({},e),{items:e.items.map((function(e){return t(t({},e),{checked:!!e.blockUncheck&&e.checked})}))})}))})),N()};return n(o,{children:[$?n(v,t({"data-testid":"MobileHeader"},{children:[c(I,t({onClick:V,"data-testid":"mobileBackArrow"},{children:c(h.Arrows.ChevronRightVariant,{fill:q.colors.shades[700].color},void 0)}),void 0),!!Q.length&&n(b,t({color:q.colors.shades[700].color},{children:[D," (",Q.length,")"]}),void 0)]}),void 0):c("div",t({"data-testid":"DesktopHeader"},{children:!!Q.length&&n(o,{children:[n(x,{children:[n(b,t({color:q.colors.shades[700].color},{children:[z," (",Q.length,")"]}),void 0),c(p,t({onClick:ne,color:q.colors.shades[700].color,"data-testid":"desktop-clear-all"},{children:E}),void 0)]},void 0),c(A,{color:O,items:Q.map((function(e){return"$75 And Above"===e.label?"+$75":e.label})),onCloseClick:function(e){return te(Q[e])}},void 0)]},void 0)}),void 0),J.filter((function(e){return e.isLinkOption})).map((function(e,n){return c(g,t({showInMobile:e.showInMobile,showInTablet:e.showInTablet,"data-testid":"linkOption"},{children:c(C,t({color:e.color||q.colors.shades[550].color,href:e.link},{children:e.title}),void 0)}),"option-container-".concat(n))})),J.filter((function(e){return!e.isLinkOption})).map((function(e){var o=function(e){var t=0,n="";return L&&(n=(t=Q.filter((function(t){return t.sectionTitle==e.title})).length)>0&&L?"(".concat(t,")"):""),n}(e);return c(k,t({title:"".concat(e.title," ").concat(o),isOpenByDefault:e.isOpenByDefault,showInMobile:e.showInMobile},{children:n(j,t({cols:e.columns},{children:["size"===e.type&&e.items.map((function(t,n){var o=J.findIndex((function(t){return t.title===e.title}));return c(f,{size:a.Medium,text:t.label,active:t.checked,disabled:t.blockUncheck,onClick:function(){return ee({sectionIndex:o,itemIndex:n,checked:!t.checked})},width:"50px",id:"filter[".concat(o,",").concat(n,"]")},t.label)})),"color"===e.type&&e.items.map((function(t,n){var o;return c(U,{onChange:ee,text:t.label,checked:t.checked,itemIndex:n,sectionIndex:J.findIndex((function(t){return t.title===e.title})),blockUncheck:t.blockUncheck,color:null!==(o=t.value)&&void 0!==o?o:"",backgroundImage:t.backgroundImage},"".concat(t.checked,"-").concat(t.label))})),!e.type&&e.items.map((function(t,n){return c(M,{onChange:ee,text:"$75 And Above"===t.label?"+$75":t.label,checked:t.checked,itemIndex:n,sectionIndex:J.findIndex((function(t){return t.title===e.title})),blockUncheck:t.blockUncheck},"".concat(t.checked,"-").concat(t.label))}))]}),void 0)}),J.findIndex((function(t){return t.title===e.title})))})),$&&n(y,t({"data-testid":"MobileFooter"},{children:[n(w,t({onClick:ne},{children:[c(I,{children:c(h.Actions.Trash,{fill:q.colors.shades[700].color},void 0)},void 0),c(p,t({color:q.colors.shades[700].color},{children:E}),void 0)]}),void 0),c(m,{text:H,onClick:R},void 0)]}),void 0)]},void 0)},M=function(e){var t=e.sectionIndex,n=e.text,o=e.itemIndex,i=e.onChange,l=e.checked,d=e.blockUncheck,s=r((function(e){i({sectionIndex:t,itemIndex:o,checked:e})}),[i,t,o]);return c(u,{onChange:s,checked:l,text:n,id:"filter[".concat(t,",").concat(o,"]"),size:a.Small,variant:"secondary",blockUncheck:d},o)},U=function(e){var t=e.sectionIndex,n=e.text,o=e.itemIndex,i=e.onChange,l=e.checked,d=e.blockUncheck,s=e.color,m=e.backgroundImage,h=r((function(e){i({sectionIndex:t,itemIndex:o,checked:e})}),[i,t,o]);return c(u,{onChange:h,checked:l,text:n,id:"filter[".concat(t,",").concat(o,"]"),size:a.Medium,variant:"color",blockUncheck:d,backgroundColor:s,backgroundImage:m},o)};export{T as Filters};
1
+ import{__spreadArray as e,__assign as t}from"tslib";import{jsxs as n,Fragment as o,jsx as i}from"react/jsx-runtime";import{useState as c,useEffect as l,useCallback as r}from"react";import{useTheme as a}from"../../core/theme/Theme.js";import{ComponentSize as d}from"../../types/enums.js";import"../../utils/constants/offerAtCart.js";import"../../utils/media.js";import"../../utils/mock-content/CancellationFlowAccordion.js";import{simulateMouseClick as s}from"../../utils/simulateClick/simulateClick.js";import{Checkbox as u}from"../checkbox/Checkbox.js";import"@emotion/react/jsx-runtime";import"../cta/styled.js";import m from"../cta/secondary/ButtonSecondary.js";import{Icon as h}from"../icons/index.js";import f from"../selector/simple/SelectorSecondary.js";import{Accordion as k}from"./Accordion.js";import{Header as b,H4 as x,ClearAll as v,MobileHeader as p,MobileIconsContainer as I,OptionContainer as g,FilterLink as C,SectionContent as j,MobileFooter as y,MobileClearContainer as T}from"./FiltersStyled.js";import{Tags as w}from"./Tags/Tags.js";var A=function(u){var A=u.values,U=u.onChange,B=u.tagsColor,S=void 0===B?"#fff6ef":B,O=u.filterByText,z=u.clearAllText,E=u.isMobile,$=u.filtersSelectText,D=u.showSelectedNumberInSection,F=void 0!==D&&D,H=u.applyText,R=u.mobileApplyButtonClick,V=u.mobileBackArrowClick,N=u.onResetValues,q=a(),G=c(A),J=G[0],K=G[1],P=c(function(){var e=[];return A.forEach((function(t,n){t.items.forEach((function(t,o){t.checked&&!t.blockUncheck&&e.push({sectionIndex:n,sectionTitle:t.label,itemIndex:o,label:t.label,translatedLabel:t.translatedLabel})}))})),e}()),Q=P[0],W=P[1],X=c(),Y=X[0],Z=X[1];l((function(){J.length&&Y&&U(J,Y)}),[Y,J,U]);var _=r((function(e){e.forEach((function(e){var t=e.sectionIndex,n=e.itemIndex;te({sectionIndex:t,itemIndex:n})}))}),[]),ee=r((function(n){var o=n.sectionIndex,i=n.itemIndex,c=n.checked;Z({sectionIndex:o,itemIndex:i,checked:c});var l=J[o],r=null==l?void 0:l.items[i];(null==r?void 0:r.isLinkItem)&&(null==r?void 0:r.link)?c&&window.location.assign(r.link):(W((function(t){return l.isMultiselect||t.length>0&&_([]),c?e(e([],l.isMultiselect?t:t.filter((function(e){return e.sectionIndex!==o})),!0),[{sectionIndex:o,itemIndex:i,label:J[o].items[i].label,translatedLabel:J[o].items[i].translatedLabel,sectionTitle:J[o].title}],!1):t.filter((function(e){return e.sectionIndex!==o||e.itemIndex!==i}))})),K((function(e){return e.map((function(e,n){return o!==n?e:t(t({},e),{items:e.items.map((function(n,o){return t(t({},n),{label:n.label,checked:i===o?c:!!e.isMultiselect&&n.checked})}))})}))})))}),[J,_]),te=function(e){var t=e.sectionIndex,n=e.itemIndex,o=document.getElementById("filter[".concat(t,",").concat(n,"]"));s(o)},ne=function(){_(Q),W([]),K((function(e){return e.map((function(e){return t(t({},e),{items:e.items.map((function(e){return t(t({},e),{checked:!!e.blockUncheck&&e.checked})}))})}))})),N()};return n(o,{children:[E?n(p,t({"data-testid":"MobileHeader"},{children:[i(I,t({onClick:V,"data-testid":"mobileBackArrow"},{children:i(h.Arrows.ChevronRightVariant,{fill:q.colors.shades[700].color},void 0)}),void 0),!!Q.length&&n(x,t({color:q.colors.shades[700].color},{children:[$," (",Q.length,")"]}),void 0)]}),void 0):i("div",t({"data-testid":"DesktopHeader"},{children:!!Q.length&&n(o,{children:[n(b,{children:[n(x,t({color:q.colors.shades[700].color},{children:[O," (",Q.length,")"]}),void 0),i(v,t({onClick:ne,color:q.colors.shades[700].color,"data-testid":"desktop-clear-all"},{children:z}),void 0)]},void 0),i(w,{color:S,items:Q.map((function(e){var t=e.translatedLabel||e.label;return"$75 And Above"===t?"+$75":t})),onCloseClick:function(e){return te(Q[e])}},void 0)]},void 0)}),void 0),J.filter((function(e){return e.isLinkOption})).map((function(e,n){return i(g,t({showInMobile:e.showInMobile,showInTablet:e.showInTablet,"data-testid":"linkOption"},{children:i(C,t({color:e.color||q.colors.shades[550].color,href:e.link},{children:e.translatedTitle||e.title}),void 0)}),"option-container-".concat(n))})),J.filter((function(e){return!e.isLinkOption})).map((function(e){var o=function(e){var t=0,n="";return F&&(n=(t=Q.filter((function(t){return t.sectionTitle==e.title})).length)>0&&F?"(".concat(t,")"):""),n}(e);return i(k,t({title:"".concat(e.translatedTitle||e.title," ").concat(o),isOpenByDefault:e.isOpenByDefault,showInMobile:e.showInMobile},{children:n(j,t({cols:e.columns},{children:["size"===e.type&&e.items.map((function(t,n){var o=J.findIndex((function(t){return t.title===e.title}));return i(f,{size:d.Medium,text:t.translatedLabel||t.label,active:t.checked,disabled:t.blockUncheck,onClick:function(){return ee({sectionIndex:o,itemIndex:n,checked:!t.checked})},width:"50px",id:"filter[".concat(o,",").concat(n,"]")},t.label)})),"color"===e.type&&e.items.map((function(t,n){var o;return i(L,{onChange:ee,text:t.translatedLabel||t.label,checked:t.checked,itemIndex:n,sectionIndex:J.findIndex((function(t){return t.title===e.title})),blockUncheck:t.blockUncheck,color:null!==(o=t.value)&&void 0!==o?o:"",backgroundImage:t.backgroundImage},"".concat(t.checked,"-").concat(t.label))})),!e.type&&e.items.map((function(t,n){return i(M,{onChange:ee,text:t.translatedLabel||("$75 And Above"===t.label?"+$75":t.label),checked:t.checked,itemIndex:n,sectionIndex:J.findIndex((function(t){return t.title===e.title})),blockUncheck:t.blockUncheck},"".concat(t.checked,"-").concat(t.label))}))]}),void 0)}),J.findIndex((function(t){return t.title===e.title})))})),E&&n(y,t({"data-testid":"MobileFooter"},{children:[n(T,t({onClick:ne},{children:[i(I,{children:i(h.Actions.Trash,{fill:q.colors.shades[700].color},void 0)},void 0),i(v,t({color:q.colors.shades[700].color},{children:z}),void 0)]}),void 0),i(m,{text:H,onClick:R},void 0)]}),void 0)]},void 0)},M=function(e){var t=e.sectionIndex,n=e.text,o=e.itemIndex,c=e.onChange,l=e.checked,a=e.blockUncheck,s=r((function(e){c({sectionIndex:t,itemIndex:o,checked:e})}),[c,t,o]);return i(u,{onChange:s,checked:l,text:n,id:"filter[".concat(t,",").concat(o,"]"),size:d.Small,variant:"secondary",blockUncheck:a},o)},L=function(e){var t=e.sectionIndex,n=e.text,o=e.itemIndex,c=e.onChange,l=e.checked,a=e.blockUncheck,s=e.color,m=e.backgroundImage,h=r((function(e){c({sectionIndex:t,itemIndex:o,checked:e})}),[c,t,o]);return i(u,{onChange:h,checked:l,text:n,id:"filter[".concat(t,",").concat(o,"]"),size:d.Medium,variant:"color",blockUncheck:a,backgroundColor:s,backgroundImage:m},o)};export{A as Filters};
2
2
  //# sourceMappingURL=Filters.js.map
package/build/index.d.ts CHANGED
@@ -2870,6 +2870,7 @@ declare type DropdownListIconsSubItem = {
2870
2870
  };
2871
2871
  declare type Filter = {
2872
2872
  title: string;
2873
+ translatedTitle?: string;
2873
2874
  columns: number;
2874
2875
  isOpenByDefault?: boolean;
2875
2876
  isLinkOption?: boolean;
@@ -2879,6 +2880,7 @@ declare type Filter = {
2879
2880
  type?: string;
2880
2881
  items: Array<{
2881
2882
  label: string;
2883
+ translatedLabel?: string;
2882
2884
  checked?: boolean;
2883
2885
  isLinkItem?: boolean;
2884
2886
  link?: string;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("../../core/theme/Theme.js"),c=require("../../types/enums.js");require("../../utils/constants/offerAtCart.js"),require("../../utils/media.js"),require("../../utils/mock-content/CancellationFlowAccordion.js");var o=require("../../utils/simulateClick/simulateClick.js"),r=require("../checkbox/Checkbox.js");require("@emotion/react/jsx-runtime"),require("../cta/styled.js");var s=require("../cta/secondary/ButtonSecondary.js"),l=require("../icons/index.js"),a=require("../selector/simple/SelectorSecondary.js"),d=require("./Accordion.js"),u=require("./FiltersStyled.js"),h=require("./Tags/Tags.js"),x=function(e){var i=e.sectionIndex,o=e.text,s=e.itemIndex,l=e.onChange,a=e.checked,d=e.blockUncheck,u=t.useCallback((function(e){l({sectionIndex:i,itemIndex:s,checked:e})}),[l,i,s]);return n.jsx(r.Checkbox,{onChange:u,checked:a,text:o,id:"filter[".concat(i,",").concat(s,"]"),size:c.ComponentSize.Small,variant:"secondary",blockUncheck:d},s)},k=function(e){var i=e.sectionIndex,o=e.text,s=e.itemIndex,l=e.onChange,a=e.checked,d=e.blockUncheck,u=e.color,h=e.backgroundImage,x=t.useCallback((function(e){l({sectionIndex:i,itemIndex:s,checked:e})}),[l,i,s]);return n.jsx(r.Checkbox,{onChange:x,checked:a,text:o,id:"filter[".concat(i,",").concat(s,"]"),size:c.ComponentSize.Medium,variant:"color",blockUncheck:d,backgroundColor:u,backgroundImage:h},s)};exports.Filters=function(r){var f=r.values,m=r.onChange,b=r.tagsColor,g=void 0===b?"#fff6ef":b,I=r.filterByText,v=r.clearAllText,_=r.isMobile,j=r.filtersSelectText,C=r.showSelectedNumberInSection,p=void 0!==C&&C,y=r.applyText,M=r.mobileApplyButtonClick,q=r.mobileBackArrowClick,A=r.onResetValues,S=i.useTheme(),T=t.useState(f),w=T[0],U=T[1],B=t.useState(function(){var e=[];return f.forEach((function(n,t){n.items.forEach((function(n,i){n.checked&&!n.blockUncheck&&e.push({sectionIndex:t,sectionTitle:n.label,itemIndex:i,label:n.label})}))})),e}()),F=B[0],z=B[1],O=t.useState(),H=O[0],E=O[1];t.useEffect((function(){w.length&&H&&m(w,H)}),[H,w,m]);var L=t.useCallback((function(e){e.forEach((function(e){var n=e.sectionIndex,t=e.itemIndex;D({sectionIndex:n,itemIndex:t})}))}),[]),$=t.useCallback((function(n){var t=n.sectionIndex,i=n.itemIndex,c=n.checked;E({sectionIndex:t,itemIndex:i,checked:c});var o=w[t],r=null==o?void 0:o.items[i];(null==r?void 0:r.isLinkItem)&&(null==r?void 0:r.link)?c&&window.location.assign(r.link):(z((function(n){return o.isMultiselect||n.length>0&&L([]),c?e.__spreadArray(e.__spreadArray([],o.isMultiselect?n:n.filter((function(e){return e.sectionIndex!==t})),!0),[{sectionIndex:t,itemIndex:i,label:w[t].items[i].label,sectionTitle:w[t].title}],!1):n.filter((function(e){return e.sectionIndex!==t||e.itemIndex!==i}))})),U((function(n){return n.map((function(n,o){return t!==o?n:e.__assign(e.__assign({},n),{items:n.items.map((function(t,o){return e.__assign(e.__assign({},t),{label:t.label,checked:i===o?c:!!n.isMultiselect&&t.checked})}))})}))})))}),[w,L]),D=function(e){var n=e.sectionIndex,t=e.itemIndex,i=document.getElementById("filter[".concat(n,",").concat(t,"]"));o.simulateMouseClick(i)},R=function(){L(F),z([]),U((function(n){return n.map((function(n){return e.__assign(e.__assign({},n),{items:n.items.map((function(n){return e.__assign(e.__assign({},n),{checked:!!n.blockUncheck&&n.checked})}))})}))})),A()};return n.jsxs(n.Fragment,{children:[_?n.jsxs(u.MobileHeader,e.__assign({"data-testid":"MobileHeader"},{children:[n.jsx(u.MobileIconsContainer,e.__assign({onClick:q,"data-testid":"mobileBackArrow"},{children:n.jsx(l.Icon.Arrows.ChevronRightVariant,{fill:S.colors.shades[700].color},void 0)}),void 0),!!F.length&&n.jsxs(u.H4,e.__assign({color:S.colors.shades[700].color},{children:[j," (",F.length,")"]}),void 0)]}),void 0):n.jsx("div",e.__assign({"data-testid":"DesktopHeader"},{children:!!F.length&&n.jsxs(n.Fragment,{children:[n.jsxs(u.Header,{children:[n.jsxs(u.H4,e.__assign({color:S.colors.shades[700].color},{children:[I," (",F.length,")"]}),void 0),n.jsx(u.ClearAll,e.__assign({onClick:R,color:S.colors.shades[700].color,"data-testid":"desktop-clear-all"},{children:v}),void 0)]},void 0),n.jsx(h.Tags,{color:g,items:F.map((function(e){return"$75 And Above"===e.label?"+$75":e.label})),onCloseClick:function(e){return D(F[e])}},void 0)]},void 0)}),void 0),w.filter((function(e){return e.isLinkOption})).map((function(t,i){return n.jsx(u.OptionContainer,e.__assign({showInMobile:t.showInMobile,showInTablet:t.showInTablet,"data-testid":"linkOption"},{children:n.jsx(u.FilterLink,e.__assign({color:t.color||S.colors.shades[550].color,href:t.link},{children:t.title}),void 0)}),"option-container-".concat(i))})),w.filter((function(e){return!e.isLinkOption})).map((function(t){var i=function(e){var n=0,t="";return p&&(t=(n=F.filter((function(n){return n.sectionTitle==e.title})).length)>0&&p?"(".concat(n,")"):""),t}(t);return n.jsx(d.Accordion,e.__assign({title:"".concat(t.title," ").concat(i),isOpenByDefault:t.isOpenByDefault,showInMobile:t.showInMobile},{children:n.jsxs(u.SectionContent,e.__assign({cols:t.columns},{children:["size"===t.type&&t.items.map((function(e,i){var o=w.findIndex((function(e){return e.title===t.title}));return n.jsx(a,{size:c.ComponentSize.Medium,text:e.label,active:e.checked,disabled:e.blockUncheck,onClick:function(){return $({sectionIndex:o,itemIndex:i,checked:!e.checked})},width:"50px",id:"filter[".concat(o,",").concat(i,"]")},e.label)})),"color"===t.type&&t.items.map((function(e,i){var c;return n.jsx(k,{onChange:$,text:e.label,checked:e.checked,itemIndex:i,sectionIndex:w.findIndex((function(e){return e.title===t.title})),blockUncheck:e.blockUncheck,color:null!==(c=e.value)&&void 0!==c?c:"",backgroundImage:e.backgroundImage},"".concat(e.checked,"-").concat(e.label))})),!t.type&&t.items.map((function(e,i){return n.jsx(x,{onChange:$,text:"$75 And Above"===e.label?"+$75":e.label,checked:e.checked,itemIndex:i,sectionIndex:w.findIndex((function(e){return e.title===t.title})),blockUncheck:e.blockUncheck},"".concat(e.checked,"-").concat(e.label))}))]}),void 0)}),w.findIndex((function(e){return e.title===t.title})))})),_&&n.jsxs(u.MobileFooter,e.__assign({"data-testid":"MobileFooter"},{children:[n.jsxs(u.MobileClearContainer,e.__assign({onClick:R},{children:[n.jsx(u.MobileIconsContainer,{children:n.jsx(l.Icon.Actions.Trash,{fill:S.colors.shades[700].color},void 0)},void 0),n.jsx(u.ClearAll,e.__assign({color:S.colors.shades[700].color},{children:v}),void 0)]}),void 0),n.jsx(s,{text:y,onClick:M},void 0)]}),void 0)]},void 0)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("../../core/theme/Theme.js"),c=require("../../types/enums.js");require("../../utils/constants/offerAtCart.js"),require("../../utils/media.js"),require("../../utils/mock-content/CancellationFlowAccordion.js");var o=require("../../utils/simulateClick/simulateClick.js"),l=require("../checkbox/Checkbox.js");require("@emotion/react/jsx-runtime"),require("../cta/styled.js");var r=require("../cta/secondary/ButtonSecondary.js"),s=require("../icons/index.js"),a=require("../selector/simple/SelectorSecondary.js"),d=require("./Accordion.js"),u=require("./FiltersStyled.js"),h=require("./Tags/Tags.js"),x=function(e){var i=e.sectionIndex,o=e.text,r=e.itemIndex,s=e.onChange,a=e.checked,d=e.blockUncheck,u=t.useCallback((function(e){s({sectionIndex:i,itemIndex:r,checked:e})}),[s,i,r]);return n.jsx(l.Checkbox,{onChange:u,checked:a,text:o,id:"filter[".concat(i,",").concat(r,"]"),size:c.ComponentSize.Small,variant:"secondary",blockUncheck:d},r)},k=function(e){var i=e.sectionIndex,o=e.text,r=e.itemIndex,s=e.onChange,a=e.checked,d=e.blockUncheck,u=e.color,h=e.backgroundImage,x=t.useCallback((function(e){s({sectionIndex:i,itemIndex:r,checked:e})}),[s,i,r]);return n.jsx(l.Checkbox,{onChange:x,checked:a,text:o,id:"filter[".concat(i,",").concat(r,"]"),size:c.ComponentSize.Medium,variant:"color",blockUncheck:d,backgroundColor:u,backgroundImage:h},r)};exports.Filters=function(l){var f=l.values,b=l.onChange,m=l.tagsColor,g=void 0===m?"#fff6ef":m,v=l.filterByText,I=l.clearAllText,_=l.isMobile,j=l.filtersSelectText,C=l.showSelectedNumberInSection,p=void 0!==C&&C,y=l.applyText,M=l.mobileApplyButtonClick,q=l.mobileBackArrowClick,A=l.onResetValues,T=i.useTheme(),S=t.useState(f),w=S[0],L=S[1],U=t.useState(function(){var e=[];return f.forEach((function(n,t){n.items.forEach((function(n,i){n.checked&&!n.blockUncheck&&e.push({sectionIndex:t,sectionTitle:n.label,itemIndex:i,label:n.label,translatedLabel:n.translatedLabel})}))})),e}()),B=U[0],F=U[1],z=t.useState(),O=z[0],H=z[1];t.useEffect((function(){w.length&&O&&b(w,O)}),[O,w,b]);var E=t.useCallback((function(e){e.forEach((function(e){var n=e.sectionIndex,t=e.itemIndex;D({sectionIndex:n,itemIndex:t})}))}),[]),$=t.useCallback((function(n){var t=n.sectionIndex,i=n.itemIndex,c=n.checked;H({sectionIndex:t,itemIndex:i,checked:c});var o=w[t],l=null==o?void 0:o.items[i];(null==l?void 0:l.isLinkItem)&&(null==l?void 0:l.link)?c&&window.location.assign(l.link):(F((function(n){return o.isMultiselect||n.length>0&&E([]),c?e.__spreadArray(e.__spreadArray([],o.isMultiselect?n:n.filter((function(e){return e.sectionIndex!==t})),!0),[{sectionIndex:t,itemIndex:i,label:w[t].items[i].label,translatedLabel:w[t].items[i].translatedLabel,sectionTitle:w[t].title}],!1):n.filter((function(e){return e.sectionIndex!==t||e.itemIndex!==i}))})),L((function(n){return n.map((function(n,o){return t!==o?n:e.__assign(e.__assign({},n),{items:n.items.map((function(t,o){return e.__assign(e.__assign({},t),{label:t.label,checked:i===o?c:!!n.isMultiselect&&t.checked})}))})}))})))}),[w,E]),D=function(e){var n=e.sectionIndex,t=e.itemIndex,i=document.getElementById("filter[".concat(n,",").concat(t,"]"));o.simulateMouseClick(i)},R=function(){E(B),F([]),L((function(n){return n.map((function(n){return e.__assign(e.__assign({},n),{items:n.items.map((function(n){return e.__assign(e.__assign({},n),{checked:!!n.blockUncheck&&n.checked})}))})}))})),A()};return n.jsxs(n.Fragment,{children:[_?n.jsxs(u.MobileHeader,e.__assign({"data-testid":"MobileHeader"},{children:[n.jsx(u.MobileIconsContainer,e.__assign({onClick:q,"data-testid":"mobileBackArrow"},{children:n.jsx(s.Icon.Arrows.ChevronRightVariant,{fill:T.colors.shades[700].color},void 0)}),void 0),!!B.length&&n.jsxs(u.H4,e.__assign({color:T.colors.shades[700].color},{children:[j," (",B.length,")"]}),void 0)]}),void 0):n.jsx("div",e.__assign({"data-testid":"DesktopHeader"},{children:!!B.length&&n.jsxs(n.Fragment,{children:[n.jsxs(u.Header,{children:[n.jsxs(u.H4,e.__assign({color:T.colors.shades[700].color},{children:[v," (",B.length,")"]}),void 0),n.jsx(u.ClearAll,e.__assign({onClick:R,color:T.colors.shades[700].color,"data-testid":"desktop-clear-all"},{children:I}),void 0)]},void 0),n.jsx(h.Tags,{color:g,items:B.map((function(e){var n=e.translatedLabel||e.label;return"$75 And Above"===n?"+$75":n})),onCloseClick:function(e){return D(B[e])}},void 0)]},void 0)}),void 0),w.filter((function(e){return e.isLinkOption})).map((function(t,i){return n.jsx(u.OptionContainer,e.__assign({showInMobile:t.showInMobile,showInTablet:t.showInTablet,"data-testid":"linkOption"},{children:n.jsx(u.FilterLink,e.__assign({color:t.color||T.colors.shades[550].color,href:t.link},{children:t.translatedTitle||t.title}),void 0)}),"option-container-".concat(i))})),w.filter((function(e){return!e.isLinkOption})).map((function(t){var i=function(e){var n=0,t="";return p&&(t=(n=B.filter((function(n){return n.sectionTitle==e.title})).length)>0&&p?"(".concat(n,")"):""),t}(t);return n.jsx(d.Accordion,e.__assign({title:"".concat(t.translatedTitle||t.title," ").concat(i),isOpenByDefault:t.isOpenByDefault,showInMobile:t.showInMobile},{children:n.jsxs(u.SectionContent,e.__assign({cols:t.columns},{children:["size"===t.type&&t.items.map((function(e,i){var o=w.findIndex((function(e){return e.title===t.title}));return n.jsx(a,{size:c.ComponentSize.Medium,text:e.translatedLabel||e.label,active:e.checked,disabled:e.blockUncheck,onClick:function(){return $({sectionIndex:o,itemIndex:i,checked:!e.checked})},width:"50px",id:"filter[".concat(o,",").concat(i,"]")},e.label)})),"color"===t.type&&t.items.map((function(e,i){var c;return n.jsx(k,{onChange:$,text:e.translatedLabel||e.label,checked:e.checked,itemIndex:i,sectionIndex:w.findIndex((function(e){return e.title===t.title})),blockUncheck:e.blockUncheck,color:null!==(c=e.value)&&void 0!==c?c:"",backgroundImage:e.backgroundImage},"".concat(e.checked,"-").concat(e.label))})),!t.type&&t.items.map((function(e,i){return n.jsx(x,{onChange:$,text:e.translatedLabel||("$75 And Above"===e.label?"+$75":e.label),checked:e.checked,itemIndex:i,sectionIndex:w.findIndex((function(e){return e.title===t.title})),blockUncheck:e.blockUncheck},"".concat(e.checked,"-").concat(e.label))}))]}),void 0)}),w.findIndex((function(e){return e.title===t.title})))})),_&&n.jsxs(u.MobileFooter,e.__assign({"data-testid":"MobileFooter"},{children:[n.jsxs(u.MobileClearContainer,e.__assign({onClick:R},{children:[n.jsx(u.MobileIconsContainer,{children:n.jsx(s.Icon.Actions.Trash,{fill:T.colors.shades[700].color},void 0)},void 0),n.jsx(u.ClearAll,e.__assign({color:T.colors.shades[700].color},{children:I}),void 0)]}),void 0),n.jsx(r,{text:y,onClick:M},void 0)]}),void 0)]},void 0)};
2
2
  //# sourceMappingURL=Filters.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.10.0",
6
+ "version": "7.10.1",
7
7
  "private": false,
8
8
  "main": "build/lib/index.js",
9
9
  "style": "build/es/index.css",