@trafilea/afrodita-components 7.10.0 → 7.10.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{__assign as o}from"tslib";import{jsxs as i,jsx as
|
|
1
|
+
import{__assign as o}from"tslib";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as e}from"react";import{Container as n,Backdrop as d,Sidebar as a}from"./style.js";var l=function(l){var c=l.children,u=l.isOpen,s=l.onClose,p=l.onOpen,v=l.backgroundColor,f=void 0===v?"#fff":v,m=l.backdropColor,b=void 0===m?"rgba(0, 0, 0, 0.5)":m,h=l.position,k=void 0===h?"left":h,C=l.width,g=void 0===C?"33%":C,T=l.height,O=void 0===T?"100%":T,w=l.top,j=void 0===w?"0":w,x=l.onClickOutside,B=l.ssr,D=void 0!==B&&B,I=l.dataTestIdSidebar,S=void 0===I?"Drawer-Sidebar":I,y=l.dataTestIdBackdrop,q=void 0===y?"Drawer-Backdrop":y,z=r(u),A=z[0],E=z[1],F=r(u),G=F[0],H=F[1];return e((function(){if(!1===u){E(u);var o=setTimeout((function(){H(u),null==s||s()}),300);return function(){clearTimeout(o)}}H(u);var i=setTimeout((function(){E(u),null==p||p()}),100);return function(){clearTimeout(i)}}),[u,s,p]),G||D?i(n,o({visible:!D||G},{children:[t(d,{backgroundColor:b,isOpen:A,top:j,"data-testid":q,onClick:x&&x},void 0),t(a,o({position:k,width:g,height:O,top:j,backgroundColor:f,isOpen:A,"data-testid":S},{children:c}),void 0)]}),void 0):null};export{l as Drawer};
|
|
2
2
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as t}from"tslib";import{jsxs as n,Fragment as o,jsx as
|
|
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;
|
|
@@ -3235,8 +3237,10 @@ interface DrawerProps {
|
|
|
3235
3237
|
height?: string;
|
|
3236
3238
|
top?: string;
|
|
3237
3239
|
ssr?: boolean;
|
|
3240
|
+
dataTestIdSidebar?: string;
|
|
3241
|
+
dataTestIdBackdrop?: string;
|
|
3238
3242
|
}
|
|
3239
|
-
declare const Drawer: ({ children, isOpen, onClose, onOpen, backgroundColor, backdropColor, position, width, height, top, onClickOutside, ssr, }: DrawerProps) => JSX.Element | null;
|
|
3243
|
+
declare const Drawer: ({ children, isOpen, onClose, onOpen, backgroundColor, backdropColor, position, width, height, top, onClickOutside, ssr, dataTestIdSidebar, dataTestIdBackdrop, }: DrawerProps) => JSX.Element | null;
|
|
3240
3244
|
|
|
3241
3245
|
interface DropdownListIconsProps {
|
|
3242
3246
|
items: DropdownListIconsItem[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),r=require("react"),o=require("./style.js");exports.Drawer=function(t){var n=t.children,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),r=require("react"),o=require("./style.js");exports.Drawer=function(t){var n=t.children,d=t.isOpen,a=t.onClose,s=t.onOpen,u=t.backgroundColor,c=void 0===u?"#fff":u,l=t.backdropColor,v=void 0===l?"rgba(0, 0, 0, 0.5)":l,p=t.position,f=void 0===p?"left":p,b=t.width,h=void 0===b?"33%":b,k=t.height,g=void 0===k?"100%":k,C=t.top,j=void 0===C?"0":C,x=t.onClickOutside,O=t.ssr,T=void 0!==O&&O,_=t.dataTestIdSidebar,m=void 0===_?"Drawer-Sidebar":_,w=t.dataTestIdBackdrop,S=void 0===w?"Drawer-Backdrop":w,q=r.useState(d),B=q[0],D=q[1],y=r.useState(d),I=y[0],E=y[1];if(r.useEffect((function(){if(!1===d){D(d);var e=setTimeout((function(){E(d),null==a||a()}),300);return function(){clearTimeout(e)}}E(d);var i=setTimeout((function(){D(d),null==s||s()}),100);return function(){clearTimeout(i)}}),[d,a,s]),!I&&!T)return null;var M=!T||I;return i.jsxs(o.Container,e.__assign({visible:M},{children:[i.jsx(o.Backdrop,{backgroundColor:v,isOpen:B,top:j,"data-testid":S,onClick:x&&x},void 0),i.jsx(o.Sidebar,e.__assign({position:f,width:h,height:g,top:j,backgroundColor:c,isOpen:B,"data-testid":m},{children:n}),void 0)]}),void 0)};
|
|
2
2
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -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"),
|
|
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