@bikdotai/bik-component-library 0.0.461-4 → 0.0.462

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.
Files changed (31) hide show
  1. package/dist/cjs/components/add-variableV2/AddVariableV2.js +1 -1
  2. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Legend/Legend.js +1 -1
  3. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  4. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  5. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  6. package/dist/cjs/components/product-picker-v2/product.js +1 -1
  7. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  8. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  9. package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
  10. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +0 -1
  11. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  12. package/dist/cjs/components/product-picker-v2/utility.d.ts +2 -2
  13. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  14. package/dist/esm/components/add-variableV2/AddVariableV2.js +1 -1
  15. package/dist/esm/components/analytics-chips-and-dropdowns/chart/Legend/Legend.js +1 -1
  16. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  17. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  18. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  19. package/dist/esm/components/product-picker-v2/product.js +1 -1
  20. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  21. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  22. package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
  23. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +0 -1
  24. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  25. package/dist/esm/components/product-picker-v2/utility.d.ts +2 -2
  26. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
  29. package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
  30. package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
  31. package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),a=require("react/jsx-runtime"),s=require("../../assets/icons/back_icon.svg.js"),i=require("../../assets/icons/chevronRightAlt.svg.js"),t=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/plus.svg.js"),n=require("../../assets/icons/undo.svg.js"),r=require("react"),c=require("./AddVariableV2.styled.js"),o=require("../button/Button.js"),d=require("../icon-button/IconButton.js"),b=require("../searchBar/searchBar.js"),u=require("../tooltips/Tooltip.js"),v=require("../../constants/Theme.js"),j=require("../modals/modal.styled.js"),g=require("../switch/Switch.js"),h=require("../TypographyStyle.js");const m=r.memo((m=>{const{data:p,hasHeader:y=!0,needsBorder:x=!0,styledCloseBtn:f=!1,readonly:O=!1}=m,[S,N]=r.useState({}),[C,V]=r.useState(),[w,_]=r.useState(""),[T,B]=r.useState(""),[k,q]=r.useState(!0),L=/^[^.]+\.[^.]+$/,[F,I]=r.useState(m.data),[E,A]=r.useState(!0);r.useEffect((()=>{const e={};p.forEach((a=>{e[a.displayName]=[]})),V(e)}),[p]),r.useEffect((()=>{$(!0)}),[]),r.useEffect((()=>{$(E,!w)}),[S,w]),r.useEffect((()=>{A(!0),B(""),R([],w),V((e=>Object.assign(Object.assign({},e),{[w]:[]}))),_("");const e=m.data.map((e=>z(e))).filter((e=>null!==e));I(e),e.length>0?q(!0):q(!1)}),[m.reRender]),r.useEffect((()=>{let e=m.data;w&&(e=[S[w]]);H(e,E).length>0?q(!0):q(!1)}),[T]);const H=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.flatMap((e=>Object.keys(e.variables).filter((s=>{var i;return(null===(i=e.variables[s].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))&&(!a||e.variables[s].isAvailable===a)||P(e.variables[s])}))))},R=(e,a)=>{const s=p.find((e=>e.displayName===a));if(s){let i=s;e.forEach(((e,a)=>{i=i.variables[e]})),N((e=>Object.assign(Object.assign({},e),{[a]:i})))}},P=e=>{let a=!1;if(e.isSubHeader&&e.variables){const s=Object.keys(e.variables);for(let i=0;i<s.length;i++){const t=s[i];if(e.variables&&e.variables[t].displayName.toLowerCase().includes(T.toLowerCase())&&e.variables[t].isAvailable===E){a=!0;break}}}return a},$=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(A(e),e){let s=[];if(!w||a)s=m.data.map((e=>z(e))).filter((e=>null!==e));else{const e=S[w];s=m.data.filter((e=>e.displayName===w)).map((a=>z(a,e))).filter((e=>null!=e))}I(s),T&&(s=H(s,e)),s.length>0?q(!0):q(!1)}else if(I(m.data),T){H(m.data,e).length>0?q(!0):q(!1)}else q(!0)};function z(e,a){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(a)for(const i in e.variables)if(e.variables[i].displayName===a.displayName)for(const a in e.variables[i].variables)e.variables[i].variables[a].isAvailable&&(s[a]=e.variables[i].variables[a]);else e.variables[i].isSubHeader&&z(e.variables[i],a,s);else for(const a in e.variables)e.variables[a].isAvailable&&(s[a]=e.variables[a]);return 0===Object.keys(s).length?null:Object.assign(Object.assign({},e),{variables:s})}const M=e=>{const s=e.item.description;return e.readonly?a.jsx("div",{children:a.jsx(W,{item:e.item,readonly:e.readonly})}):a.jsx(a.Fragment,{children:a.jsx(u.Tooltip,Object.assign({body:"",tooltipContent:a.jsx(h.BodyCaption,Object.assign({color:v.COLORS.content.primaryInverse,style:{whiteSpace:"pre-line",padding:8}},{children:e.item.isAvailable?s?`• ${s}\n• Recommended here`:"Recommended here":"Not recommended here"})),width:300,delay:300,placement:"bottom"},{children:a.jsx("div",{children:a.jsx(W,{item:e.item})})}))})},W=e=>a.jsx(o.Button,{darkMode:m.enableVariable?m.enableVariable:e.item.isAvailable,size:"chip",disabled:!!e.readonly&&!e.item.isSubHeader,LeadingIcon:e.item.isSubHeader||e.readonly?void 0:l.default,TrailingIcon:()=>e.item.isSubHeader?a.jsx("div",Object.assign({className:"icon-trailing",style:{display:"flex"}},{children:a.jsx(i.default,{})})):a.jsx(a.Fragment,{}),buttonText:e.item.displayName}),D=(e,s)=>E&&!e.isAvailable?a.jsx(a.Fragment,{}):a.jsx("div",Object.assign({onClick:e.isSubHeader?()=>{H([e],E).length||q(!1),B("");const a=[...C[w],s];R(a,w),V((e=>Object.assign(Object.assign({},e),{[w]:a})))}:()=>{m.customTrigger?(m.customTrigger(e),m.setShowVariable(!1)):m.isEvaluationList?J(e):m.setVariableValue(m.selectWithTypes?{actualValue:e.actualValue,variableType:e.variableType,needsFetching:e.needsFetching}:e.actualValue)}},{children:a.jsx(M,{item:e,readonly:O})})),G=(e,a)=>{const s=[...C[e.displayName],a];R(s,e.displayName),V((a=>Object.assign(Object.assign({},a),{[e.displayName]:s}))),_(e.displayName)},J=e=>{if(e.actualValue.match(L)){const a=e.actualValue.replace("{{","").replace("}}","").split(".");let s=a[0];a.forEach(((e,a)=>{if(0===a)return;const i=(e=>/\w+\[\d+\]/g.test(e))(e);if(i){const a=e.match(/(\w+)\[(\d+)\]/);if(a){const e=a[1],i=a[2];s+=`['${e}'][${i}]`}}else s+=`['${e}']`})),m.setVariableValue(m.selectWithTypes?{actualValue:s,variableType:e.variableType,needsFetching:e.needsFetching}:s)}else{const a=e.actualValueEval?e.actualValueEval:e.actualValue;m.setVariableValue(m.selectWithTypes?{actualValue:a,variableType:e.variableType,needsFetching:e.needsFetching}:a)}},K=(e,a)=>{if(m.customTrigger)m.customTrigger(e.variables[a]),m.setShowVariable(!1);else if(m.isEvaluationList){const s=e.variables[a];J(s)}else m.setVariableValue(m.selectWithTypes?{actualValue:e.variables[a].actualValue,variableType:e.variables[a].variableType,needsFetching:e.variables[a].needsFetching}:e.variables[a].actualValue)},Q=m.isModalState?void 0:{top:`${m.topPosition?m.topPosition:"small"===m.pickerSize?"300px":"60px"}`,left:`${m.leftPosition?m.leftPosition+24:430}px`};return a.jsx("div",Object.assign({id:"varList",tabIndex:-1},{children:a.jsxs(c.AddVariableStyled,Object.assign({style:Q,onClick:e=>{e.stopPropagation()},pickerSize:m.pickerSize||"large",isModalState:m.isModalState,positionStrategy:m.positionStrategy,zIndex:m.zindex,height:m.height,needsBorder:x,width:m.width},{children:[f&&a.jsx(j.CloseButtonContainer,Object.assign({onClick:()=>{m.setShowVariable(!1)},style:{zIndex:300}},{children:a.jsx(t.default,{height:20,width:20,color:v.COLORS.content.secondary})})),m.showVariable&&a.jsxs("div",Object.assign({className:"popup"},{children:[a.jsxs("div",Object.assign({className:"sticky__bar"},{children:[y&&a.jsxs("div",Object.assign({className:"header__bar"},{children:[a.jsx("div",Object.assign({className:"add__variable"},{children:"Add a new variable"})),!f&&a.jsx("div",Object.assign({onClick:()=>{m.setShowVariable(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center"}},{children:a.jsx(d.IconButton,{iconButtonType:"default",Icon:t.default})}))]})),a.jsxs("div",Object.assign({className:"search__bar",onBlur:e=>{m.onSearchBlur&&m.onSearchBlur(e)}},{children:[a.jsx(b.SearchBar,{width:"100%",isEnabled:!0,onChange:e=>{B(e)},onEnter:()=>{},reset:!T,placeholder:"Search...",variant:"default"}),a.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",marginTop:8,justifyContent:"space-between"}},{children:[a.jsx(h.BodySecondary,Object.assign({style:{color:v.COLORS.content.secondary}},{children:"Show only recommended variables"})),a.jsx(g.Switch,{value:E,onValueChange:a=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield $(a)}))})]}))]})),w&&C[w].length>0&&a.jsxs("div",Object.assign({className:"nav__bar"},{children:[a.jsxs("div",Object.assign({className:"left__nav"},{children:[a.jsx(d.IconButton,{Icon:s.default,style:{color:"#919191",display:"flex"},onClick:()=>{B("");const e=C[w].slice(0,-1);R(e,w),V((a=>Object.assign(Object.assign({},a),{[w]:e}))),e.length||_("")}}),a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx(h.TitleSmall,{children:S[w].displayName}),S[w].description&&a.jsx(h.BodyCaption,{children:S[w].description})]}))]})),a.jsxs("div",Object.assign({className:"right__nav"},{children:[a.jsx(d.IconButton,{Icon:n.default,style:{display:"flex"},onClick:()=>{B(""),R([],w),V((e=>Object.assign(Object.assign({},e),{[w]:[]}))),_("")}}),a.jsx("div",{children:"First page"})]}))]}))]})),!k&&a.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginTop:16}},{children:[a.jsx(h.TitleSmall,{children:"No results found!"}),E?a.jsx(h.BodyCaption,{children:"Sorry we could not find any recommended variables"}):a.jsx(h.BodyCaption,{children:`Sorry we could not find any results for "${T}"`})]})),a.jsx("div",Object.assign({className:"wrapper"},{children:a.jsx("div",Object.assign({className:"list__map"},{children:a.jsxs("div",Object.assign({className:"items"},{children:[!w&&F.map((e=>{let s=[];return T&&(s=Object.keys(e.variables).filter((a=>{var s;return(null===(s=e.variables[a].displayName)||void 0===s?void 0:s.toLowerCase().includes(T.toLowerCase()))||P(e.variables[a])}))),a.jsxs(a.Fragment,{children:[T?s.length>0?a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a.jsx(h.BodyCaption,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})):a.jsx(a.Fragment,{}):a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a.jsx(h.BodyCaption,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})),Object.keys(e.variables).map((s=>{var i;return T?(null===(i=e.variables[s].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))||P(e.variables[s])?a.jsx("div",Object.assign({onClick:e.variables[s].isSubHeader?()=>G(e,s):()=>K(e,s)},{children:a.jsx(M,{item:e.variables[s],readonly:O})})):a.jsx(a.Fragment,{}):a.jsx("div",Object.assign({onClick:e.variables[s].isSubHeader?()=>G(e,s):()=>K(e,s)},{children:a.jsx(M,{item:e.variables[s],readonly:O})}))}))]})})),w&&a.jsx("div",Object.assign({className:"list__map"},{children:a.jsx("div",Object.assign({className:"items",style:{marginTop:16}},{children:Object.keys(S[w].variables).map(((e,s)=>{var i;return T?(null===(i=S[w].variables[e].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))||P(S[w].variables[e])?D(S[w].variables[e],e):a.jsx(a.Fragment,{}):D(S[w].variables[e],e)}))}))}))]}))}))})),a.jsx("div",{className:"bottom__padding"})]}))]}))}))}),((e,a)=>e.enableVariable===a.enableVariable&&(e.leftPosition===a.leftPosition&&e.reRender===a.reRender)));exports.AddVariableV2=m;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),a=require("react/jsx-runtime"),s=require("../../assets/icons/back_icon.svg.js"),i=require("../../assets/icons/chevronRightAlt.svg.js"),t=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/plus.svg.js"),n=require("../../assets/icons/undo.svg.js"),r=require("react"),c=require("./AddVariableV2.styled.js"),o=require("../button/Button.js"),d=require("../icon-button/IconButton.js"),b=require("../searchBar/searchBar.js"),u=require("../tooltips/Tooltip.js"),v=require("../../constants/Theme.js"),j=require("../modals/modal.styled.js"),g=require("../switch/Switch.js"),h=require("../TypographyStyle.js");const m=r.memo((m=>{const{data:p,hasHeader:y=!0,needsBorder:x=!0,styledCloseBtn:f=!1,readonly:O=!1}=m,[S,N]=r.useState({}),[C,V]=r.useState(),[w,_]=r.useState(""),[T,B]=r.useState(""),[k,q]=r.useState(!0),L=/.*\..*/,[F,I]=r.useState(m.data),[E,A]=r.useState(!0);r.useEffect((()=>{const e={};p.forEach((a=>{e[a.displayName]=[]})),V(e)}),[p]),r.useEffect((()=>{z(!0)}),[]),r.useEffect((()=>{z(E,!w)}),[S,w]),r.useEffect((()=>{A(!0),B(""),R([],w),V((e=>Object.assign(Object.assign({},e),{[w]:[]}))),_("");const e=m.data.map((e=>$(e))).filter((e=>null!==e));I(e),e.length>0?q(!0):q(!1)}),[m.reRender]),r.useEffect((()=>{let e=m.data;w&&(e=[S[w]]);H(e,E).length>0?q(!0):q(!1)}),[T]);const H=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.flatMap((e=>Object.keys(e.variables).filter((s=>{var i;return(null===(i=e.variables[s].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))&&(!a||e.variables[s].isAvailable===a)||P(e.variables[s])}))))},R=(e,a)=>{const s=p.find((e=>e.displayName===a));if(s){let i=s;e.forEach(((e,a)=>{i=i.variables[e]})),N((e=>Object.assign(Object.assign({},e),{[a]:i})))}},P=e=>{let a=!1;if(e.isSubHeader&&e.variables){const s=Object.keys(e.variables);for(let i=0;i<s.length;i++){const t=s[i];if(e.variables&&e.variables[t].displayName.toLowerCase().includes(T.toLowerCase())&&e.variables[t].isAvailable===E){a=!0;break}}}return a},z=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(A(e),e){let s=[];if(!w||a)s=m.data.map((e=>$(e))).filter((e=>null!==e));else{const e=S[w];s=m.data.filter((e=>e.displayName===w)).map((a=>$(a,e))).filter((e=>null!=e))}I(s),T&&(s=H(s,e)),s.length>0?q(!0):q(!1)}else if(I(m.data),T){H(m.data,e).length>0?q(!0):q(!1)}else q(!0)};function $(e,a){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(a)for(const i in e.variables)if(e.variables[i].displayName===a.displayName)for(const a in e.variables[i].variables)e.variables[i].variables[a].isAvailable&&(s[a]=e.variables[i].variables[a]);else e.variables[i].isSubHeader&&$(e.variables[i],a,s);else for(const a in e.variables)e.variables[a].isAvailable&&(s[a]=e.variables[a]);return 0===Object.keys(s).length?null:Object.assign(Object.assign({},e),{variables:s})}const M=e=>{const s=e.item.description;return e.readonly?a.jsx("div",{children:a.jsx(W,{item:e.item,readonly:e.readonly})}):a.jsx(a.Fragment,{children:a.jsx(u.Tooltip,Object.assign({body:"",tooltipContent:a.jsx(h.BodyCaption,Object.assign({color:v.COLORS.content.primaryInverse,style:{whiteSpace:"pre-line",padding:8}},{children:e.item.isAvailable?s?`• ${s}\n• Recommended here`:"Recommended here":"Not recommended here"})),width:300,delay:300,placement:"bottom"},{children:a.jsx("div",{children:a.jsx(W,{item:e.item})})}))})},W=e=>a.jsx(o.Button,{darkMode:m.enableVariable?m.enableVariable:e.item.isAvailable,size:"chip",disabled:!!e.readonly&&!e.item.isSubHeader,LeadingIcon:e.item.isSubHeader||e.readonly?void 0:l.default,TrailingIcon:()=>e.item.isSubHeader?a.jsx("div",Object.assign({className:"icon-trailing",style:{display:"flex"}},{children:a.jsx(i.default,{})})):a.jsx(a.Fragment,{}),buttonText:e.item.displayName}),D=(e,s)=>E&&!e.isAvailable?a.jsx(a.Fragment,{}):a.jsx("div",Object.assign({onClick:e.isSubHeader?()=>{H([e],E).length||q(!1),B("");const a=[...C[w],s];R(a,w),V((e=>Object.assign(Object.assign({},e),{[w]:a})))}:()=>{m.customTrigger?(m.customTrigger(e),m.setShowVariable(!1)):m.isEvaluationList?J(e):m.setVariableValue(m.selectWithTypes?{actualValue:e.actualValue,variableType:e.variableType,needsFetching:e.needsFetching}:e.actualValue)}},{children:a.jsx(M,{item:e,readonly:O})})),G=(e,a)=>{const s=[...C[e.displayName],a];R(s,e.displayName),V((a=>Object.assign(Object.assign({},a),{[e.displayName]:s}))),_(e.displayName)},J=e=>{if(e.actualValue.match(L)){const a=e.actualValue.replace("{{","").replace("}}","").split(".");let s=a[0];a.forEach(((e,a)=>{if(0===a)return;const i=(e=>/\w+\[\d+\]/g.test(e))(e);if(i){const a=e.match(/(\w+)\[(\d+)\]/);if(a){const e=a[1],i=a[2];s+=`['${e}'][${i}]`}}else s+=`['${e}']`})),m.setVariableValue(m.selectWithTypes?{actualValue:s,variableType:e.variableType,needsFetching:e.needsFetching}:s)}else{const a=e.actualValueEval?e.actualValueEval:e.actualValue;m.setVariableValue(m.selectWithTypes?{actualValue:a,variableType:e.variableType,needsFetching:e.needsFetching}:a)}},K=(e,a)=>{if(m.customTrigger)m.customTrigger(e.variables[a]),m.setShowVariable(!1);else if(m.isEvaluationList){const s=e.variables[a];J(s)}else m.setVariableValue(m.selectWithTypes?{actualValue:e.variables[a].actualValue,variableType:e.variables[a].variableType,needsFetching:e.variables[a].needsFetching}:e.variables[a].actualValue)},Q=m.isModalState?void 0:{top:`${m.topPosition?m.topPosition:"small"===m.pickerSize?"300px":"60px"}`,left:`${m.leftPosition?m.leftPosition+24:430}px`};return a.jsx("div",Object.assign({id:"varList",tabIndex:-1},{children:a.jsxs(c.AddVariableStyled,Object.assign({style:Q,onClick:e=>{e.stopPropagation()},pickerSize:m.pickerSize||"large",isModalState:m.isModalState,positionStrategy:m.positionStrategy,zIndex:m.zindex,height:m.height,needsBorder:x,width:m.width},{children:[f&&a.jsx(j.CloseButtonContainer,Object.assign({onClick:()=>{m.setShowVariable(!1)},style:{zIndex:300}},{children:a.jsx(t.default,{height:20,width:20,color:v.COLORS.content.secondary})})),m.showVariable&&a.jsxs("div",Object.assign({className:"popup"},{children:[a.jsxs("div",Object.assign({className:"sticky__bar"},{children:[y&&a.jsxs("div",Object.assign({className:"header__bar"},{children:[a.jsx("div",Object.assign({className:"add__variable"},{children:"Add a new variable"})),!f&&a.jsx("div",Object.assign({onClick:()=>{m.setShowVariable(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center"}},{children:a.jsx(d.IconButton,{iconButtonType:"default",Icon:t.default})}))]})),a.jsxs("div",Object.assign({className:"search__bar",onBlur:e=>{m.onSearchBlur&&m.onSearchBlur(e)}},{children:[a.jsx(b.SearchBar,{width:"100%",isEnabled:!0,onChange:e=>{B(e)},onEnter:()=>{},reset:!T,placeholder:"Search...",variant:"default"}),a.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",marginTop:8,justifyContent:"space-between"}},{children:[a.jsx(h.BodySecondary,Object.assign({style:{color:v.COLORS.content.secondary}},{children:"Show only recommended variables"})),a.jsx(g.Switch,{value:E,onValueChange:a=>e.__awaiter(void 0,void 0,void 0,(function*(){return yield z(a)}))})]}))]})),w&&C[w].length>0&&a.jsxs("div",Object.assign({className:"nav__bar"},{children:[a.jsxs("div",Object.assign({className:"left__nav"},{children:[a.jsx(d.IconButton,{Icon:s.default,style:{color:"#919191",display:"flex"},onClick:()=>{B("");const e=C[w].slice(0,-1);R(e,w),V((a=>Object.assign(Object.assign({},a),{[w]:e}))),e.length||_("")}}),a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx(h.TitleSmall,{children:S[w].displayName}),S[w].description&&a.jsx(h.BodyCaption,{children:S[w].description})]}))]})),a.jsxs("div",Object.assign({className:"right__nav"},{children:[a.jsx(d.IconButton,{Icon:n.default,style:{display:"flex"},onClick:()=>{B(""),R([],w),V((e=>Object.assign(Object.assign({},e),{[w]:[]}))),_("")}}),a.jsx("div",{children:"First page"})]}))]}))]})),!k&&a.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginTop:16}},{children:[a.jsx(h.TitleSmall,{children:"No results found!"}),E?a.jsx(h.BodyCaption,{children:"Sorry we could not find any recommended variables"}):a.jsx(h.BodyCaption,{children:`Sorry we could not find any results for "${T}"`})]})),a.jsx("div",Object.assign({className:"wrapper"},{children:a.jsx("div",Object.assign({className:"list__map"},{children:a.jsxs("div",Object.assign({className:"items"},{children:[!w&&F.map((e=>{let s=[];return T&&(s=Object.keys(e.variables).filter((a=>{var s;return(null===(s=e.variables[a].displayName)||void 0===s?void 0:s.toLowerCase().includes(T.toLowerCase()))||P(e.variables[a])}))),a.jsxs(a.Fragment,{children:[T?s.length>0?a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a.jsx(h.BodyCaption,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})):a.jsx(a.Fragment,{}):a.jsxs("div",Object.assign({className:"block"},{children:[a.jsx("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a.jsx(h.BodyCaption,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})),Object.keys(e.variables).map((s=>{var i;return T?(null===(i=e.variables[s].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))||P(e.variables[s])?a.jsx("div",Object.assign({onClick:e.variables[s].isSubHeader?()=>G(e,s):()=>K(e,s)},{children:a.jsx(M,{item:e.variables[s],readonly:O})})):a.jsx(a.Fragment,{}):a.jsx("div",Object.assign({onClick:e.variables[s].isSubHeader?()=>G(e,s):()=>K(e,s)},{children:a.jsx(M,{item:e.variables[s],readonly:O})}))}))]})})),w&&a.jsx("div",Object.assign({className:"list__map"},{children:a.jsx("div",Object.assign({className:"items",style:{marginTop:16}},{children:Object.keys(S[w].variables).map(((e,s)=>{var i;return T?(null===(i=S[w].variables[e].displayName)||void 0===i?void 0:i.toLowerCase().includes(T.toLowerCase()))||P(S[w].variables[e])?D(S[w].variables[e],e):a.jsx(a.Fragment,{}):D(S[w].variables[e],e)}))}))}))]}))}))})),a.jsx("div",{className:"bottom__padding"})]}))]}))}))}),((e,a)=>e.enableVariable===a.enableVariable&&(e.leftPosition===a.leftPosition&&e.reRender===a.reRender)));exports.AddVariableV2=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}"}:{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblx0ZmxleC1kaXJlY3Rpb246IHJvdztcblx0ZmxleDogMTtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdFx0ZmxleDogMTtcblx0fVxuYDtcclxuZXhwb3J0IGNvbnN0IExlZ2VuZCA9ICh7IGNvbG9yLCB0ZXh0IH0pID0+IHtcclxuICAgIGNvbnN0IHRvVXBwZXJDYXNlID0gKG5hbWUpID0+IHtcclxuICAgICAgICByZXR1cm4gbmFtZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG5hbWUuc2xpY2UoMSk7XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIChfanN4cyhMZWdlbmRTdHlsZWQsIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2xhc3NOYW1lOiAnY29sb3InLCBzdHlsZTogeyBiYWNrZ3JvdW5kQ29sb3I6IGNvbG9yIH0gfSksIF9qc3goQm9keVByaW1hcnksIE9iamVjdC5hc3NpZ24oeyBjbGFzc05hbWU6ICd0aXRsZScgfSwgeyBjaGlsZHJlbjogdG9VcHBlckNhc2UodGV4dCkgfSkpXSB9KSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxlZ2VuZC5qcy5tYXAiXX0= */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:i}=e;return t.jsxs(o,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(a=i,a.charAt(0).toUpperCase()+a.slice(1))}))]});var a};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const i=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}"}:{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdH1cbmA7XHJcbmV4cG9ydCBjb25zdCBMZWdlbmQgPSAoeyBjb2xvciwgdGV4dCB9KSA9PiB7XHJcbiAgICBjb25zdCB0b1VwcGVyQ2FzZSA9IChuYW1lKSA9PiB7XHJcbiAgICAgICAgcmV0dXJuIG5hbWUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBuYW1lLnNsaWNlKDEpO1xyXG4gICAgfTtcclxuICAgIHJldHVybiAoX2pzeHMoTGVnZW5kU3R5bGVkLCB7IGNoaWxkcmVuOiBbX2pzeChcImRpdlwiLCB7IGNsYXNzTmFtZTogJ2NvbG9yJywgc3R5bGU6IHsgYmFja2dyb3VuZENvbG9yOiBjb2xvciB9IH0pLCBfanN4KEJvZHlQcmltYXJ5LCBPYmplY3QuYXNzaWduKHsgY2xhc3NOYW1lOiAndGl0bGUnIH0sIHsgY2hpbGRyZW46IHRvVXBwZXJDYXNlKHRleHQpIH0pKV0gfSkpO1xyXG59O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1MZWdlbmQuanMubWFwIl19 */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:a}=e;return t.jsxs(i,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(s=a,s.charAt(0).toUpperCase()+s.slice(1))}))]});var s};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),c=require("../tag/Tag.js"),o=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),d=require("./ProductPickerShimmer.js"),a=require("./style.js"),u=require("./utility.js");const h=i=>{const{customCollectionRestriction:n,data:d,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:j,setScreen:p,id:y,isChecked:g,isDisabled:x,hideCollectionCheckbox:b,pickerType:m,selectedCollections:v,usedInSearch:k}=i;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===m)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:y,val:d,isRestricted:n}}),void h(y);h(y),p("products")}},isActive:!!v[y],usedInSearch:null!=k&&k},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!b&&e.jsx(s.CheckBox,{isDisabled:x,isChecked:g,isPartiallyChecked:j,onValueChange:function(e,t,i){null==i||i.stopPropagation(),u(e?{type:"selected",data:{id:y,val:d,isRestricted:n}}:{type:"unselected",data:{id:y}}),C(e?y:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(o.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(a.CollectionNameHolder,{children:[k?e.jsx(r.BodyPrimary,Object.assign({numberOfLines:1},{children:d.name})):e.jsx(r.TitleRegular,Object.assign({numberOfLines:1},{children:d.name})),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(l.IconButton,{height:12,width:12,disabled:x,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{var s;const{customCollectionRestriction:l,dataLoading:c,collections:o,selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,selectedCollections:j,setScreen:p,collectionFetcher:y,collectionsDispatch:g,pagingControls:x,storeId:b,setSaveDisabled:m,hideCollectionCheckbox:v,renderWithoutModal:k,pickerType:S}=t,f=i.useRef(null),I=i.useRef(x.curPage),P=!!l&&(null==j?void 0:j.isCustom),[O,q]=i.useState(!1),T=i.useRef(!1);return i.useEffect((()=>{I.current=x.curPage}),[x.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&I.current>0&&!T.current&&(m(!0),q(!0),y(I.current,b).then((e=>{g({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(I.current+1),q(!1),m(!1),Object.keys(e).length||(T.current=!0)})).catch())}),{threshold:1});return f.current&&e.observe(f.current),()=>{f.current&&e.unobserve(f.current)}}),[f]),e.jsxs("div",{children:[(null===(s=Object.keys(null!=o?o:{}))||void 0===s?void 0:s.length)?Object.keys(o).map((t=>e.jsx(h,{customCollectionRestriction:l,data:o[t],isDisabled:P&&!(null==j?void 0:j[t]),isChecked:!!(null==j?void 0:j[t]),isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==o?void 0:o[t],j),selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,setScreen:p,id:t,hideCollectionCheckbox:v||"-1"===t,selectedCollections:j,renderWithoutModal:k,pickerType:S},t))):c?e.jsx(d.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:f}),O&&e.jsx(d.ProductPickerShimmer,{})]})},exports.truncate=(e,t,i)=>{if(!e)return"";if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),c=require("../tag/Tag.js"),o=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./ProductPickerShimmer.js"),d=require("./style.js"),u=require("./utility.js");const h=i=>{const{customCollectionRestriction:n,data:a,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:j,setScreen:p,id:y,isChecked:g,isDisabled:x,hideCollectionCheckbox:b,pickerType:m,selectedCollections:k,usedInSearch:S}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===m)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:y,val:a,isRestricted:n}}),void h(y);h(y),p("products")}},isActive:!!k[y],usedInSearch:null!=S&&S},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!b&&e.jsx(s.CheckBox,{isDisabled:x,isChecked:g,isPartiallyChecked:j,onValueChange:function(e,t,i){null==i||i.stopPropagation(),u(e?{type:"selected",data:{id:y,val:a,isRestricted:n}}:{type:"unselected",data:{id:y}}),C(e?y:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(o.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(d.CollectionNameHolder,{children:[S?e.jsx(r.BodyPrimary,Object.assign({numberOfLines:1},{children:a.name})):e.jsx(r.TitleRegular,Object.assign({numberOfLines:1},{children:a.name})),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(l.IconButton,{height:12,width:12,disabled:x,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:l,collections:c,selectedCollectionsDispatch:o,setCollectionId:r,setSelectedCollectionId:d,selectedCollections:C,setScreen:j,collectionFetcher:p,collectionsDispatch:y,pagingControls:g,storeId:x,setSaveDisabled:b,hideCollectionCheckbox:m,renderWithoutModal:k,pickerType:S}=t,v=i.useRef(null),f=i.useRef(g.curPage),I=!!s&&(null==C?void 0:C.isCustom),[P,O]=i.useState(!1),q=i.useRef(!1);return i.useEffect((()=>{f.current=g.curPage}),[g.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&!q.current&&(b(!0),O(!0),p(f.current,x).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(f.current+1),O(!1),b(!1),Object.keys(e).length||(q.current=!0)})).catch())}),{threshold:1});return v.current&&e.observe(v.current),()=>{v.current&&e.unobserve(v.current)}}),[v]),e.jsxs("div",{children:[Object.keys(c).length?Object.keys(c).map((t=>e.jsx(h,{customCollectionRestriction:s,data:c[t],isDisabled:I&&!(null==C?void 0:C[t]),isChecked:!!(null==C?void 0:C[t]),isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==c?void 0:c[t],C),selectedCollectionsDispatch:o,setCollectionId:r,setSelectedCollectionId:d,setScreen:j,id:t,hideCollectionCheckbox:m||"-1"===t,selectedCollections:C,renderWithoutModal:k,pickerType:S},t))):l?e.jsx(a.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:v}),P&&e.jsx(a.ProductPickerShimmer,{})]})},exports.truncate=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:m,visible:f,zIndex:v,exactLimit:P,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:E,width:D,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:V,selectSingleItem:$=!1,showProductDetails:L}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,le]=c.useState(!1),[ie,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;B?Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&he[-1]&&(null===(c=he[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)}),[he,B]),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(le(!0),e.searchFetcher(y,re).then((e=>{"collections"in e&&"products"in e?(ue({type:"set",data:e}),z({type:"searched",data:e.collections})):(ue({type:"set",data:{collections:{},products:e}}),z({type:"searched",data:e})),G("searchProducts"),te(!1),le(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{$&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[$,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se,screenName:W},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ie,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:L})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,hideProductVariants:B,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:I})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(l.StyledModal,Object.assign({zIndex:v,open:f,onClose:()=>{null==m||m(),ye()},headingTitle:E||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Results":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:D||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||P&&oe<P||!P&&k&&oe>k||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):P&&oe>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):k&&oe>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G(V?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${oe}/${P} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${oe}/${P} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:m,visible:f,zIndex:P,exactLimit:v,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:L=!1,showProductDetails:V}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,le]=c.useState(!1),[ie,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)})),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(le(!0),e.searchFetcher(y,re).then((e=>{"collections"in e&&"products"in e?(ue({type:"set",data:e}),z({type:"searched",data:e.collections})):(ue({type:"set",data:{collections:{},products:e}}),z({type:"searched",data:e})),G("searchProducts"),te(!1),le(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{L&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[L,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se,screenName:W},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ie,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:V})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:I})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(l.StyledModal,Object.assign({zIndex:P,open:f,onClose:()=>{null==m||m(),ye()},headingTitle:D||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Results":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||v&&oe<v||!v&&k&&oe>k||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):v&&oe>v?t.jsx(a.Tag,{tagText:`You can only select ${v} products`,type:"negative"}):k&&oe>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../constants/Theme.js"),i=require("../../assets/icons/info.svg.js"),o=require("../checkBox/CheckBox.js"),c=require("../icon-button/IconButton.js"),d=require("../shimmer-image/ShimmerImage.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./ProductPickerTag.js"),l=require("./style.js"),s=require("./utility.js");const u=s=>{const{isVariant:u,data:h,productId:p,collectionId:v,variantId:I,isSelected:j,selectedCollectionsDispatch:k,viewOnly:x,upliftAdditions:y,isPartiallyChecked:C,hideProductCheckbox:P,outOfStockAction:f,hideVariantCheckbox:m,hideProductVariants:b,pickerType:O,onProductDetailClick:g,showProductDetailInfoIcon:S}=s;return e.jsxs(l.ProductCardStyle,Object.assign({isVariant:u,onClick:e=>{if(e.stopPropagation(),"PRODUCT"===O){const e=Object.keys(h.variants);b?y("productSelected",{productId:p,variantId:I,collectionId:v,product:b?h.variants[e[0]]:h}):y("variantSelected",{productId:p,variantId:I||e[0],collectionId:v,variant:h})}},isActive:j},{children:[u&&!x&&!m||!u&&!x&&!P?e.jsx(o.CheckBox,{isChecked:j,isPartiallyChecked:C||!1,onValueChange:function(e){if(u)e?y(b?"productSelected":"variantSelected",{productId:p,variantId:I,collectionId:v,variant:h}):k({type:b?"productUnselected":"variantUnselected",data:{productId:p,variantId:I,collectionId:v}});else if(e){const e=Object.keys(h.variants);y(b?"productSelected":"variantSelected",{productId:p,collectionId:v,product:b?h.variants[e[0]]:h})}else k({type:b?"productUnselected":"variantUnselected",data:{productId:p,collectionId:v}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(d.ShimmerImage,{width:40,height:40,imageUrl:h.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(r.Tooltip,Object.assign({variant:"light",body:h.name,placement:"bottom",delay:400},{children:e.jsx(n.BodyPrimary,Object.assign({numberOfLines:1},{children:h.name}))})),S&&e.jsx(c.IconButton,{onClick:()=>{null==g||g(h)},Icon:()=>e.jsx(i.default,{width:20,height:20,color:t.COLORS.content.placeholder})})]})),e.jsx(a.ProductPickerTag,{isVariant:u,data:h,outOfStockAction:f})]}))]}))};exports.ProductCard=u,exports.ProductGroup=t=>{const{collectionId:i,productId:o,data:c,selectedData:d,selectedCollectionsDispatch:r,viewOnly:n,upliftAdditions:a,isProductPartiallyChecked:l,hideProductCheckbox:h,outOfStockAction:p,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,onProductDetailClick:k,showProductDetailInfoIcon:x}=t,y=e=>{var t,c,r,n,a,l;if(!(null===(c=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(l=null===(a=null===(n=null===(r=null==d?void 0:d[i])||void 0===r?void 0:r.products)||void 0===n?void 0:n[o])||void 0===a?void 0:a.variants)||void 0===l?void 0:l[e])};return e.jsxs("div",{children:[e.jsx(u,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(P=null===(C=null==d?void 0:d[i])||void 0===C?void 0:C.products)||void 0===P?void 0:P[o]),isPartiallyChecked:l,selectedCollectionsDispatch:r,upliftAdditions:a,viewOnly:n,hideProductCheckbox:h,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},o),I?null:s.shouldShowVariant(c)&&Object.keys(c.variants||[]).map((t=>e.jsx(u,{isVariant:!0,hideVariantCheckbox:v,data:c.variants[t],variantId:t,productId:o,viewOnly:n,upliftAdditions:a,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:r,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},t)))]});var C,P};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../constants/Theme.js"),i=require("../../assets/icons/info.svg.js"),o=require("../checkBox/CheckBox.js"),c=require("../icon-button/IconButton.js"),d=require("../shimmer-image/ShimmerImage.js"),r=require("../tooltips/Tooltip.js"),a=require("../TypographyStyle.js"),n=require("./ProductPickerTag.js"),l=require("./style.js"),s=require("./utility.js");const u=s=>{const{isVariant:u,data:h,productId:p,collectionId:v,variantId:I,isSelected:j,selectedCollectionsDispatch:k,viewOnly:x,upliftAdditions:y,isPartiallyChecked:C,hideProductCheckbox:P,outOfStockAction:f,hideVariantCheckbox:m,hideProductVariants:b,pickerType:g,onProductDetailClick:O,showProductDetailInfoIcon:S}=s;return e.jsxs(l.ProductCardStyle,Object.assign({isVariant:u,onClick:e=>{"PRODUCT"===g&&b&&(e.stopPropagation(),k({type:"reset",data:{}}),y("variantSelected",{productId:p,variantId:I||Object.keys(h.variants)[0],collectionId:v,variant:h}))},isActive:j},{children:[u&&!x&&!m||!u&&!x&&!P?e.jsx(o.CheckBox,{isChecked:j,isPartiallyChecked:C||!1,onValueChange:function(e){u?e?y("variantSelected",{productId:p,variantId:I,collectionId:v,variant:h}):k({type:"variantUnselected",data:{productId:p,variantId:I,collectionId:v}}):e?y("productSelected",{productId:p,collectionId:v,product:h}):k({type:"productUnselected",data:{productId:p,collectionId:v}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(d.ShimmerImage,{width:40,height:40,imageUrl:h.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(r.Tooltip,Object.assign({variant:"light",body:h.name,placement:"bottom",delay:400},{children:e.jsx(a.BodyPrimary,Object.assign({numberOfLines:1},{children:h.name}))})),S&&e.jsx(c.IconButton,{onClick:()=>{null==O||O(h)},Icon:()=>e.jsx(i.default,{width:20,height:20,color:t.COLORS.content.placeholder})})]})),e.jsx(n.ProductPickerTag,{isVariant:u,data:h,outOfStockAction:f})]}))]}))};exports.ProductCard=u,exports.ProductGroup=t=>{const{collectionId:i,productId:o,data:c,selectedData:d,selectedCollectionsDispatch:r,viewOnly:a,upliftAdditions:n,isProductPartiallyChecked:l,hideProductCheckbox:h,outOfStockAction:p,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,onProductDetailClick:k,showProductDetailInfoIcon:x}=t,y=e=>{var t,c,r,a,n,l;if(!(null===(c=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(l=null===(n=null===(a=null===(r=null==d?void 0:d[i])||void 0===r?void 0:r.products)||void 0===a?void 0:a[o])||void 0===n?void 0:n.variants)||void 0===l?void 0:l[e])};return e.jsxs("div",{children:[e.jsx(u,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(P=null===(C=null==d?void 0:d[i])||void 0===C?void 0:C.products)||void 0===P?void 0:P[o]),isPartiallyChecked:l,selectedCollectionsDispatch:r,upliftAdditions:n,viewOnly:a,hideProductCheckbox:h,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},o),I?null:s.shouldShowVariant(c)&&Object.keys(c.variants||[]).map((t=>e.jsx(u,{isVariant:!0,hideVariantCheckbox:v,data:c.variants[t],variantId:t,productId:o,viewOnly:a,upliftAdditions:n,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:r,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},t)))]});var C,P};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),u=require("../input/Input.js"),d=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=b=>{const{data:C,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:x,productFetcher:f,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:q,customCollectionRestriction:A,hideProductCheckbox:E,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:w,onProductDetailClick:F,showProductDetailInfoIcon:B}=b,_=o.useContext(v.CollectionIdContext),U=o.useRef(null),H=o.useRef(0),[J,K]=o.useState(!1),[M,N]=o.useState(""),[W,z]=o.useState(!1),[G,Q]=o.useState(C),X=o.useRef(!1);o.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),b.searchInCollectionFetcher(S,_,M).then((e=>{const t=s.cloneDeep(C);t.products=e,Q(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});Z(r,null!=e?e:{},!0),I(!1),z(!1)}))):Q(C)}),800);return()=>clearTimeout(e)}),[M]),o.useEffect((()=>{var e,t,r,c;X.current=!1,H.current=Math.floor((null===(t=Object.keys(null!==(e=C.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=P.getVariantIdsToFetchAtProductLevel(null!==(r=C.products)&&void 0!==r?r:{});Z(s,null!==(c=C.products)&&void 0!==c?c:{})}),[_]);const Y=!!A&&C.isSmartCollection;o.useEffect((()=>{(null==C?void 0:C.products)||$(10)}),[]);const Z=(e,t,r)=>{w||(r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)),e.length>0&&w&&w(S,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var s,o;Object.keys(null!==(o=null===(s=null==t?void 0:t[r])||void 0===s?void 0:s.variants)&&void 0!==o?o:{}).forEach((s=>{var o,n;const i=null===(o=null==t?void 0:t[r].variants)||void 0===o?void 0:o[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),r?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),O({type:"productsPaged",data:{collectionId:_,products:c}})):O({type:"productsPaged",data:{collectionId:_,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)}))};o.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&H.current>=0&&!X.current&&!M&&(I(!0),K(!0),f(_,S,10,H.current).then((e=>{if(Object.keys(e).length||(X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const r=P.getVariantIdsToFetchAtProductLevel(e);Z(r,e),H.current+=1}K(!1),I(!1)})).catch())}),{threshold:1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}}),[U,M]);const $=e=>{I(!0),z(!0),f(_,S,e,0).then((t=>{if(Object.keys(t).length||(X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);Z(e,t),H.current=1}e||x({type:"selected",data:{id:_,val:Object.assign(Object.assign({},C),{products:t})}}),I(!1),z(!1)})).catch()},ee=(e,t)=>{const r=P.liftTheStateUp(t,C);x({type:e,data:Object.assign(Object.assign({},r),{isRestricted:A})})};return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:C.name}))]}),!q&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!E&&"-1"!==_&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==k?void 0:k[_]),isPartiallyChecked:P.isCollectionPartiallyChecked(_,G,k,L),onValueChange:function(e){e?$():x({type:"unselected",data:{id:_}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:_,isProductPartiallyChecked:P.isProductPartiallyChecked(_,t,k,G,L),productId:t,data:G.products[t],selectedData:k,selectedCollectionsDispatch:x,viewOnly:!V&&!!Y,upliftAdditions:ee,hideProductCheckbox:E,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:F,showProductDetailInfoIcon:B},t))):W?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:U})]}),J&&e.jsx(j.ProductPickerShimmer,{})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),u=require("../input/Input.js"),d=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=b=>{const{data:C,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:x,productFetcher:f,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:q,customCollectionRestriction:A,hideProductCheckbox:E,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:w,onProductDetailClick:F,showProductDetailInfoIcon:B}=b,_=o.useContext(v.CollectionIdContext),U=o.useRef(null),H=o.useRef(0),[J,K]=o.useState(!1),[M,N]=o.useState(""),[W,z]=o.useState(!1),[G,Q]=o.useState(C),X=o.useRef(!1);o.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),b.searchInCollectionFetcher(S,_,M).then((e=>{const t=s.cloneDeep(C);t.products=e,Q(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});Z(r,null!=e?e:{},!0),I(!1),z(!1)}))):Q(C)}),800);return()=>clearTimeout(e)}),[M]),o.useEffect((()=>{var e,t,r,c;X.current=!1,H.current=Math.floor((null===(t=Object.keys(null!==(e=C.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=P.getVariantIdsToFetchAtProductLevel(null!==(r=C.products)&&void 0!==r?r:{});Z(s,null!==(c=C.products)&&void 0!==c?c:{})}),[_]);const Y=!!A&&C.isSmartCollection;o.useEffect((()=>{(null==C?void 0:C.products)||$(10)}),[]);const Z=(e,t,r)=>{w||(r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)),e.length>0&&w&&w(S,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var s,o;Object.keys(null!==(o=null===(s=null==t?void 0:t[r])||void 0===s?void 0:s.variants)&&void 0!==o?o:{}).forEach((s=>{var o,n;const i=null===(o=null==t?void 0:t[r].variants)||void 0===o?void 0:o[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),r?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),O({type:"productsPaged",data:{collectionId:_,products:c}})):O({type:"productsPaged",data:{collectionId:_,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)}))};o.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&H.current>=0&&!X.current&&!M&&(I(!0),K(!0),f(_,S,10,H.current).then((e=>{if(Object.keys(e).length||(X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const r=P.getVariantIdsToFetchAtProductLevel(e);Z(r,e),H.current+=1}K(!1),I(!1)})).catch())}),{threshold:1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}}),[U,M]);const $=e=>{I(!0),z(!0),f(_,S,e,0).then((t=>{if(Object.keys(t).length||(X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);Z(e,t),H.current=1}e||x({type:"selected",data:{id:_,val:Object.assign(Object.assign({},C),{products:t})}}),I(!1),z(!1)})).catch()},ee=(e,t)=>{const r=P.liftTheStateUp(t,C);x({type:e,data:Object.assign(Object.assign({},r),{isRestricted:A})})};return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:C.name}))]}),!q&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!E&&"-1"!==_&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==k?void 0:k[_]),isPartiallyChecked:P.isCollectionPartiallyChecked(_,C,k),onValueChange:function(e){e?$():x({type:"unselected",data:{id:_}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:_,isProductPartiallyChecked:P.isProductPartiallyChecked(_,t,k,G),productId:t,data:G.products[t],selectedData:k,selectedCollectionsDispatch:x,viewOnly:!V&&!!Y,upliftAdditions:ee,hideProductCheckbox:E,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:F,showProductDetailInfoIcon:B},t))):W?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:U})]}),J&&e.jsx(j.ProductPickerShimmer,{})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return a=Object.assign({},t),a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;case"searched":a=Object.assign({},t);for(const t in e.data)t in a||(a[t]=e.data[t]);return a;default:return{}}},exports.paginationReducer=function(t,e){let a={};switch(e.type){case"paginate":a=Object.assign({},t);for(const t in e.data)if(Object.prototype.hasOwnProperty.call(e.data,t)){const s=e.data[t];if(Object.prototype.hasOwnProperty.call(a,t)){const e=a[t];a[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),s.products)})}else a[t]=s}return a;case"update":return a=Object.assign({},t),a;case"set":return a=Object.assign(Object.assign({},t),e.data),a;case"filter":a={};for(const s in t)if(s in e.data){const c=Object.assign({},t[s]),d=e.data[s],o={};for(const t in c.products)if(t in d.products){const e=Object.assign({},c.products[t]),a=d.products[t],s={};for(const t in e.variants)t in a.variants&&(s[t]=Object.assign({},e.variants[t]));Object.keys(s).length>0&&(e.variants=s,o[t]=e)}Object.keys(o).length>0&&(c.products=o,a[s]=c)}return a;default:return t}},exports.searchReducer=function(t,e){let a={collections:{},products:{}};switch(e.type){case"set":return e.data;case"setProducts":return a=Object.assign({},t),a.products=e.data,a;default:return t}},exports.selectedColectionsReducer=function(e,a){var s,c,d,o,r,n,i,l,u,p,v;let O={},g="",b="",j="";switch(a.type){case"selected":return O=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(O={}),O.isCustom=!0),O[a.data.id]=a.data.val,O;case"unselected":return O=t.cloneDeep(e),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[a.data.id],O;case"productUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={}),O[b].products[g]=a.data.product,O;case"variantSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={},O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),(null===(o=null===(d=null==O?void 0:O[b])||void 0===d?void 0:d.products)||void 0===o?void 0:o[g])||((null===(r=null==O?void 0:O[b])||void 0===r?void 0:r.products)||(O[b].products={}),O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants[j]=a.data.variant,O;case"variantUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(u=null===(l=O[b].products)||void 0===l?void 0:l[g])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},e),O;case"reset":return{};default:return e}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return a=Object.assign({},t),a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;case"searched":a=Object.assign({},t);for(const t in e.data)t in a||(a[t]=e.data[t]);return a;default:return{}}},exports.paginationReducer=function(t,e){let a={};switch(e.type){case"paginate":a=Object.assign({},t);for(const t in e.data)if(Object.prototype.hasOwnProperty.call(e.data,t)){const s=e.data[t];if(Object.prototype.hasOwnProperty.call(a,t)){const e=a[t];a[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),s.products)})}else a[t]=s}return a;case"update":return a=Object.assign({},t),a;case"set":return a=Object.assign(Object.assign({},t),e.data),a;case"filter":a={};for(const s in t)if(s in e.data){const c=Object.assign({},t[s]),d=e.data[s],o={};for(const t in c.products)if(t in d.products){const e=Object.assign({},c.products[t]),a=d.products[t],s={};for(const t in e.variants)t in a.variants&&(s[t]=Object.assign({},e.variants[t]));Object.keys(s).length>0&&(e.variants=s,o[t]=e)}Object.keys(o).length>0&&(c.products=o,a[s]=c)}return a;default:return t}},exports.searchReducer=function(t,e){let a={collections:{},products:{}};switch(e.type){case"set":return e.data;case"setProducts":return a=Object.assign({},t),a.products=e.data,a;default:return t}},exports.selectedColectionsReducer=function(e,a){var s,c,d,o,r,n;let i={},u="",l="",p="";switch(a.type){case"selected":return i=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(i={}),i.isCustom=!0),i[a.data.id]=a.data.val,i;case"unselected":return i=t.cloneDeep(e),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[a.data.id],i;case"productUnselected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,delete i[l].products[u],Object.keys(i[l].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[l]),i;case"productSelected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=a.data.catalogOnlyData,i[l].products={}),i[l].products[u]=a.data.product,i;case"variantSelected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,p=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=a.data.catalogOnlyData,i[l].products={},i[l].products[u]=a.data.productOnlyData,i[l].products[u].variants={}),(null===(o=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===o?void 0:o[u])||((null===(r=null==i?void 0:i[l])||void 0===r?void 0:r.products)||(i[l].products={}),i[l].products[u]=a.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=a.data.variant,i;case"variantUnselected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,p=a.data.variantId,delete i[l].products[u].variants[p],Object.keys(i[l].products[u].variants).length||(delete i[l].products[u],Object.keys(i[l].products).length||((null===(n=i[l])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[l])),i;case"update":return i=Object.assign({},e),i;case"reset":return{};default:return e}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:v,searchedCollections:p,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:y,collections:k,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:m,storeId:f,fbStatusFetcher:g,setCollectionId:I,setSelectedCollectionId:q,hideCollectionCheckbox:O,renderWithoutModal:D}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=p.products)&&void 0!==e?e:{},f,C,g,"setProducts")}),[null==p?void 0:p.products]);const F=!!h&&(null==v?void 0:v.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{y("collections"),b()}}),e.jsx(i.BodyCaption,{children:(null===(a=Object.keys(null==p?void 0:p.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==p?void 0:p.products).length||Object.keys(null==p?void 0:p.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.collections).map((t=>e.jsx(c.CollectionCard,{customCollectionRestriction:h,data:null==k?void 0:k[t],isDisabled:F&&!(null==v?void 0:v[t]),isChecked:!!(null==v?void 0:v[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==k?void 0:k[t],v,P),selectedCollectionsDispatch:j,setCollectionId:I,setSelectedCollectionId:q,setScreen:y,id:t,hideCollectionCheckbox:O||"-1"===t,selectedCollections:v,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==p?void 0:p.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,i,c;let s=!1;return(null===(l=null==p?void 0:p.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const i=n.liftTheStateUp(o,null===(l=null==p?void 0:p.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},i),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(i=null==p?void 0:p.products)||void 0===i?void 0:i[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,v,null===(c=p.products)||void 0===c?void 0:c[t],P),selectedData:v,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:m,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:v,searchedCollections:p,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:y,collections:k,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:m,storeId:f,fbStatusFetcher:g,setCollectionId:I,setSelectedCollectionId:q,hideCollectionCheckbox:O,renderWithoutModal:D}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=p.products)&&void 0!==e?e:{},f,C,g,"setProducts")}),[null==p?void 0:p.products]);const F=!!h&&(null==v?void 0:v.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{y("collections"),b()}}),e.jsx(i.BodyCaption,{children:(null===(a=Object.keys(null==p?void 0:p.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==p?void 0:p.products).length||Object.keys(null==p?void 0:p.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.collections).map((t=>e.jsx(c.CollectionCard,{customCollectionRestriction:h,data:null==k?void 0:k[t],isDisabled:F&&!(null==v?void 0:v[t]),isChecked:!!(null==v?void 0:v[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==k?void 0:k[t],v),selectedCollectionsDispatch:j,setCollectionId:I,setSelectedCollectionId:q,setScreen:y,id:t,hideCollectionCheckbox:O||"-1"===t,selectedCollections:v,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==p?void 0:p.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,i,c;let s=!1;return(null===(l=null==p?void 0:p.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const i=n.liftTheStateUp(o,null===(l=null==p?void 0:p.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},i),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(i=null==p?void 0:p.products)||void 0===i?void 0:i[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,v,null===(c=p.products)||void 0===c?void 0:c[t]),selectedData:v,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:m,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -9,7 +9,6 @@ interface SelectedScreenInterface {
9
9
  collections: {
10
10
  [key: string]: Collection;
11
11
  };
12
- hideProductVariants?: boolean;
13
12
  outOfStockAction?: OUT_OF_STOCK_ACTION;
14
13
  storeId: string;
15
14
  fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),l=require("./emptyState.js"),o=require("./helpers/AllProductHelper.js"),n=require("./product.js"),u=require("./reducers.js"),i=require("./style.js"),d=require("./utility.js");exports.SelectedScreen=a=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:f,collections:h,hideProductVariants:S=!1,outOfStockAction:y,storeId:v,fbStatusFetcher:b}=a,P=r.useRef(0),g=r.useRef(null),[x,q]=r.useReducer(u.paginationReducer,{});r.useEffect((()=>{P.current=0;const e=d.paginateSelectedItems(p,10,0);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"set"),P.current+=1}),[]),r.useEffect((()=>{q({type:"filter",data:p})}),[p]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&P.current>0){const e=d.paginateSelectedItems(p,10,P.current);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"update"),P.current+=1}}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g,p]);const C=S?o.AllProductHelper.removeDuplicatesForAllProducts(Object.assign({},p)):p;return console.log({curScreenData:x,selectedCollections:p}),e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{f("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(x).length>0?e.jsx(e.Fragment,{children:Object.keys(x).map((t=>{var r;return Object.keys((null===(r=null==x?void 0:x[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==C?void 0:C.isCustom)&&(c=!0),e.jsx(n.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:x[t].products[r],isProductPartiallyChecked:d.isProductPartiallyChecked(t,r,C,null==h?void 0:h[t],S),selectedData:C,selectedCollectionsDispatch:j,viewOnly:c,hideProductVariants:S,outOfStockAction:y},r)}))}))}):e.jsx(l.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:g})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),n=require("./emptyState.js"),o=require("./product.js"),u=require("./reducers.js"),i=require("./style.js"),l=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:a,selectedCollectionsDispatch:p,setScreen:j,collections:f,outOfStockAction:y,storeId:S,fbStatusFetcher:h}=d,v=r.useRef(0),b=r.useRef(null),[x,g]=r.useReducer(u.paginationReducer,{});return r.useEffect((()=>{v.current=0;const e=l.paginateSelectedItems(a,10,0);g({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,g,h,"set"),v.current+=1}),[]),r.useEffect((()=>{g({type:"filter",data:a})}),[a]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&v.current>0){const e=l.paginateSelectedItems(a,10,v.current);g({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,g,h,"update"),v.current+=1}}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b,a]),e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{j("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(x).length>0?e.jsx(e.Fragment,{children:Object.keys(x).map((t=>{var r;return Object.keys((null===(r=null==x?void 0:x[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==a?void 0:a.isCustom)&&(c=!0),e.jsx(o.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:x[t].products[r],isProductPartiallyChecked:l.isProductPartiallyChecked(t,r,a,null==f?void 0:f[t]),selectedData:a,selectedCollectionsDispatch:p,viewOnly:c,outOfStockAction:y},r)}))}))}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:b})]})]})};
@@ -34,5 +34,5 @@ export declare const markVariantsAsApprovedProductsLevel: (products: {
34
34
  * Other cases returns true.
35
35
  */
36
36
  export declare const shouldShowVariant: (data: Product) => boolean;
37
- export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection, hideProductVariants?: boolean) => boolean;
38
- export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems, hideProductVariants?: boolean) => boolean;
37
+ export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection) => boolean;
38
+ export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems) => boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,l){if(!o)return{};const i=Object.keys(o).slice(l,l+t),n={};return i.forEach((t=>{n[t]=o[t]})),n}const l=(o,t,l)=>{Object.keys(o).forEach((t=>{var l,i;const n=null!==(i=null===(l=o[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(n).forEach((l=>{var i,n,d,v;const e=null!==(v=null===(d=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[l])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(e).forEach((i=>{var n,d,v,e;const s=null===(e=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[l])||void 0===v?void 0:v.variants)||void 0===e?void 0:e[i];s&&!s.fbStatus&&(s.fbStatus="APPROVED")}))}))})),t({type:l,data:o})};exports.fetchFbStatusCollection=function(o,t,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||l(o,i,d);const v=(o=>{const t=[];return Object.keys(o).forEach((l=>{var i,n;const d=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,e;const s=null!==(e=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,v,e,s;const c=null===(s=null===(e=null===(v=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];(null==c?void 0:c.fbStatus)||t.push(n)}))}))})),t})(o);v.length>0&&n&&n(t,v).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var i,n;const d=null!==(n=null===(i=l[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,e;const s=null!==(e=null===(v=null===(d=null===(n=l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,v,e,s;const c=null===(s=null===(e=null===(v=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];c&&"REJECTED"===t[n]?c.fbStatus="REJECTED":c&&"APPROVED"===t[n]&&(c.fbStatus="APPROVED")}))}))})),i({type:d,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),l(o,i,d)}))},exports.getVariantIdsToFetchAtProductLevel=(o,t)=>{const l=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,e,s,c;let r;r=t?null===(e=null===(v=null===(d=null==t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===e?void 0:e[n]:null===(c=null===(s=null==o?void 0:o[i])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n],(null==r?void 0:r.fbStatus)||l.push(n)}))})),l},exports.isCollectionPartiallyChecked=function(o,t,l){var i,n,d,v;let e=0,s=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==t?void 0:t.products)&&void 0!==i?i:{};e=Object.keys(v).length;const c=null!==(d=null===(n=l[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};s=Object.keys(c).length}else if(l[o]){const i=null==t?void 0:t.products;i&&Object.keys(i).forEach((o=>{var t;const l=null===(t=i[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>e+=1))}));const n=null===(v=l[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var t;const l=null===(t=n[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>s+=1))})),e<=0&&s>0)return!1}return s>0&&e!==s},exports.isProductPartiallyChecked=(o,t,l,i,n)=>{var d,v,e,s,c,r,u,a,p,f,b,h,O,y,j,E,k,g,P;let D=0,S=0;if(console.log({collectionId:o,productId:t,selectedData:l,currentCollection:i,hideProductVariants:n}),null===(v=null===(d=null==l?void 0:l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[t]){if(n)return!1;const d=(null===(c=null===(s=null===(e=null==l?void 0:l[o])||void 0===e?void 0:e.products)||void 0===s?void 0:s[t])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const i in d){const n=null===(u=null===(r=null==l?void 0:l[o])||void 0===r?void 0:r.products)||void 0===u?void 0:u[t],d=null===(b=null===(f=null===(p=null===(a=null==l?void 0:l[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[t])||void 0===f?void 0:f.variants)||void 0===b?void 0:b[i];if(null===(h=null==d?void 0:d.name)||void 0===h?void 0:h.includes(null!==(O=null==n?void 0:n.name)&&void 0!==O?O:""))return!1}if(null===(E=Object.keys((null===(j=null===(y=null==i?void 0:i.products)||void 0===y?void 0:y[t])||void 0===j?void 0:j.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(g=null===(k=null==l?void 0:l[o])||void 0===k?void 0:k.products)||void 0===g?void 0:g[t])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},exports.liftTheStateUp=(t,l)=>{const i=o.cloneDeep(l);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&l.products){const n=o.cloneDeep(l.products[t.productId]);(null==n?void 0:n.variants)&&delete n.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:n})}return t},exports.markVariantsAsApprovedProductsLevel=(o,t,l,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((t=>{var l,i;Object.keys(null!==(i=null===(l=null==o?void 0:o[t])||void 0===l?void 0:l.variants)&&void 0!==i?i:{}).forEach((l=>{var i,n;const v=null===(i=null==o?void 0:o[t].variants)||void 0===i?void 0:i[l];v&&(v.fbStatus="APPROVED");const e=null===(n=null==d?void 0:d[t])||void 0===n?void 0:n.variants;e&&e[l]&&(e[l]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),t({type:"productsPaged",data:{collectionId:l,products:d}})}else t({type:"productsPaged",data:{collectionId:l,products:d}})},exports.paginateSelectedItems=function(o,l,i){var n;const d={};let v=0;for(const e in o)if(Object.prototype.hasOwnProperty.call(o,e)){const s=o[e],c=t(s.products,l,i-v);c&&Object.keys(c).length>0&&(d[e]=Object.assign(Object.assign({},s),{products:c})),v+=Object.keys(null!==(n=s.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const t=Object.keys(o.variants||[]);let l=!1;return!(t.length<=1)||(t.forEach((t=>{var i,n;l=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[t].name.includes(o.name))&&void 0!==n&&n})),!l)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,l){if(!o)return{};const i=Object.keys(o).slice(l,l+t),n={};return i.forEach((t=>{n[t]=o[t]})),n}const l=(o,t,l)=>{Object.keys(o).forEach((t=>{var l,i;const n=null!==(i=null===(l=o[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(n).forEach((l=>{var i,n,d,v;const s=null!==(v=null===(d=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[l])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((i=>{var n,d,v,s;const e=null===(s=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[l])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i];e&&!e.fbStatus&&(e.fbStatus="APPROVED")}))}))})),t({type:l,data:o})};exports.fetchFbStatusCollection=function(o,t,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||l(o,i,d);const v=(o=>{const t=[];return Object.keys(o).forEach((l=>{var i,n;const d=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const r=null===(e=null===(s=null===(v=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];(null==r?void 0:r.fbStatus)||t.push(n)}))}))})),t})(o);v.length>0&&n&&n(t,v).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var i,n;const d=null!==(n=null===(i=l[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const r=null===(e=null===(s=null===(v=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];r&&"REJECTED"===t[n]?r.fbStatus="REJECTED":r&&"APPROVED"===t[n]&&(r.fbStatus="APPROVED")}))}))})),i({type:d,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),l(o,i,d)}))},exports.getVariantIdsToFetchAtProductLevel=(o,t)=>{const l=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,s,e,r;let u;u=t?null===(s=null===(v=null===(d=null==t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n]:null===(r=null===(e=null==o?void 0:o[i])||void 0===e?void 0:e.variants)||void 0===r?void 0:r[n],(null==u?void 0:u.fbStatus)||l.push(n)}))})),l},exports.isCollectionPartiallyChecked=(o,t,l)=>{var i;let n=0,d=0;if(l[o]){const v=null==t?void 0:t.products;v&&Object.keys(v).forEach((o=>{var t;const l=null===(t=v[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>n+=1))}));const s=null===(i=l[o])||void 0===i?void 0:i.products;return s&&Object.keys(s).forEach((o=>{var t;const l=null===(t=s[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>d+=1))})),!(n<=0&&d>0)&&(d>0&&n!==d)}return!1},exports.isProductPartiallyChecked=(o,t,l,i)=>{var n,d,v,s,e,r,u,c,a,p,f,b,O,h,y,j,E,k,g;let P=0,S=0;if(null===(d=null===(n=null==l?void 0:l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[t]){const n=(null===(e=null===(s=null===(v=null==l?void 0:l[o])||void 0===v?void 0:v.products)||void 0===s?void 0:s[t])||void 0===e?void 0:e.variants)||[];if(1===Object.keys(n).length)for(const i in n){const n=null===(u=null===(r=null==l?void 0:l[o])||void 0===r?void 0:r.products)||void 0===u?void 0:u[t],d=null===(f=null===(p=null===(a=null===(c=null==l?void 0:l[o])||void 0===c?void 0:c.products)||void 0===a?void 0:a[t])||void 0===p?void 0:p.variants)||void 0===f?void 0:f[i];if(null===(b=null==d?void 0:d.name)||void 0===b?void 0:b.includes(null!==(O=null==n?void 0:n.name)&&void 0!==O?O:""))return!1}if(null===(j=Object.keys((null===(y=null===(h=null==i?void 0:i.products)||void 0===h?void 0:h[t])||void 0===y?void 0:y.variants)||[]))||void 0===j||j.forEach((()=>S++)),Object.keys((null===(g=null===(k=null===(E=null==l?void 0:l[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[t])||void 0===g?void 0:g.variants)||[]).forEach((()=>P++)),P>0&&S!==P)return!0}return!1},exports.liftTheStateUp=(t,l)=>{const i=o.cloneDeep(l);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&l.products){const n=o.cloneDeep(l.products[t.productId]);(null==n?void 0:n.variants)&&delete n.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:n})}return t},exports.markVariantsAsApprovedProductsLevel=(o,t,l,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((t=>{var l,i;Object.keys(null!==(i=null===(l=null==o?void 0:o[t])||void 0===l?void 0:l.variants)&&void 0!==i?i:{}).forEach((l=>{var i,n;const v=null===(i=null==o?void 0:o[t].variants)||void 0===i?void 0:i[l];v&&(v.fbStatus="APPROVED");const s=null===(n=null==d?void 0:d[t])||void 0===n?void 0:n.variants;s&&s[l]&&(s[l]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),t({type:"productsPaged",data:{collectionId:l,products:d}})}else t({type:"productsPaged",data:{collectionId:l,products:d}})},exports.paginateSelectedItems=function(o,l,i){var n;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const e=o[s],r=t(e.products,l,i-v);r&&Object.keys(r).length>0&&(d[s]=Object.assign(Object.assign({},e),{products:r})),v+=Object.keys(null!==(n=e.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const t=Object.keys(o.variants||[]);let l=!1;return!(t.length<=1)||(t.forEach((t=>{var i,n;l=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[t].name.includes(o.name))&&void 0!==n&&n})),!l)};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as a,jsxs as i,Fragment as s}from"react/jsx-runtime";import l from"../../assets/icons/back_icon.svg.js";import t from"../../assets/icons/chevronRightAlt.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/plus.svg.js";import o from"../../assets/icons/undo.svg.js";import{memo as c,useState as d,useEffect as b}from"react";import{AddVariableStyled as v}from"./AddVariableV2.styled.js";import{Button as m}from"../button/Button.js";import{IconButton as h}from"../icon-button/IconButton.js";import{SearchBar as g}from"../searchBar/searchBar.js";import{Tooltip as p}from"../tooltips/Tooltip.js";import{COLORS as u}from"../../constants/Theme.js";import{CloseButtonContainer as y}from"../modals/modal.styled.js";import{Switch as f}from"../switch/Switch.js";import{BodySecondary as j,TitleSmall as O,BodyCaption as N}from"../TypographyStyle.js";const V=c((c=>{const{data:V,hasHeader:w=!0,needsBorder:S=!0,styledCloseBtn:_=!1,readonly:C=!1}=c,[T,k]=d({}),[x,L]=d(),[B,I]=d(""),[A,E]=d(""),[F,H]=d(!0),$=/^[^.]+\.[^.]+$/,[z,P]=d(c.data),[R,M]=d(!0);b((()=>{const e={};V.forEach((a=>{e[a.displayName]=[]})),L(e)}),[V]),b((()=>{G(!0)}),[]),b((()=>{G(R,!B)}),[T,B]),b((()=>{M(!0),E(""),D([],B),L((e=>Object.assign(Object.assign({},e),{[B]:[]}))),I("");const e=c.data.map((e=>J(e))).filter((e=>null!==e));P(e),e.length>0?H(!0):H(!1)}),[c.reRender]),b((()=>{let e=c.data;B&&(e=[T[B]]);W(e,R).length>0?H(!0):H(!1)}),[A]);const W=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.flatMap((e=>Object.keys(e.variables).filter((i=>{var s;return(null===(s=e.variables[i].displayName)||void 0===s?void 0:s.toLowerCase().includes(A.toLowerCase()))&&(!a||e.variables[i].isAvailable===a)||q(e.variables[i])}))))},D=(e,a)=>{const i=V.find((e=>e.displayName===a));if(i){let s=i;e.forEach(((e,a)=>{s=s.variables[e]})),k((e=>Object.assign(Object.assign({},e),{[a]:s})))}},q=e=>{let a=!1;if(e.isSubHeader&&e.variables){const i=Object.keys(e.variables);for(let s=0;s<i.length;s++){const l=i[s];if(e.variables&&e.variables[l].displayName.toLowerCase().includes(A.toLowerCase())&&e.variables[l].isAvailable===R){a=!0;break}}}return a},G=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(M(e),e){let i=[];if(!B||a)i=c.data.map((e=>J(e))).filter((e=>null!==e));else{const e=T[B];i=c.data.filter((e=>e.displayName===B)).map((a=>J(a,e))).filter((e=>null!=e))}P(i),A&&(i=W(i,e)),i.length>0?H(!0):H(!1)}else if(P(c.data),A){W(c.data,e).length>0?H(!0):H(!1)}else H(!0)};function J(e,a){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(a)for(const s in e.variables)if(e.variables[s].displayName===a.displayName)for(const a in e.variables[s].variables)e.variables[s].variables[a].isAvailable&&(i[a]=e.variables[s].variables[a]);else e.variables[s].isSubHeader&&J(e.variables[s],a,i);else for(const a in e.variables)e.variables[a].isAvailable&&(i[a]=e.variables[a]);return 0===Object.keys(i).length?null:Object.assign(Object.assign({},e),{variables:i})}const K=e=>{const i=e.item.description;return e.readonly?a("div",{children:a(Q,{item:e.item,readonly:e.readonly})}):a(s,{children:a(p,Object.assign({body:"",tooltipContent:a(N,Object.assign({color:u.content.primaryInverse,style:{whiteSpace:"pre-line",padding:8}},{children:e.item.isAvailable?i?`• ${i}\n• Recommended here`:"Recommended here":"Not recommended here"})),width:300,delay:300,placement:"bottom"},{children:a("div",{children:a(Q,{item:e.item})})}))})},Q=e=>a(m,{darkMode:c.enableVariable?c.enableVariable:e.item.isAvailable,size:"chip",disabled:!!e.readonly&&!e.item.isSubHeader,LeadingIcon:e.item.isSubHeader||e.readonly?void 0:r,TrailingIcon:()=>e.item.isSubHeader?a("div",Object.assign({className:"icon-trailing",style:{display:"flex"}},{children:a(t,{})})):a(s,{}),buttonText:e.item.displayName}),U=(e,i)=>R&&!e.isAvailable?a(s,{}):a("div",Object.assign({onClick:e.isSubHeader?()=>{W([e],R).length||H(!1),E("");const a=[...x[B],i];D(a,B),L((e=>Object.assign(Object.assign({},e),{[B]:a})))}:()=>{c.customTrigger?(c.customTrigger(e),c.setShowVariable(!1)):c.isEvaluationList?Y(e):c.setVariableValue(c.selectWithTypes?{actualValue:e.actualValue,variableType:e.variableType,needsFetching:e.needsFetching}:e.actualValue)}},{children:a(K,{item:e,readonly:C})})),X=(e,a)=>{const i=[...x[e.displayName],a];D(i,e.displayName),L((a=>Object.assign(Object.assign({},a),{[e.displayName]:i}))),I(e.displayName)},Y=e=>{if(e.actualValue.match($)){const a=e.actualValue.replace("{{","").replace("}}","").split(".");let i=a[0];a.forEach(((e,a)=>{if(0===a)return;const s=(e=>/\w+\[\d+\]/g.test(e))(e);if(s){const a=e.match(/(\w+)\[(\d+)\]/);if(a){const e=a[1],s=a[2];i+=`['${e}'][${s}]`}}else i+=`['${e}']`})),c.setVariableValue(c.selectWithTypes?{actualValue:i,variableType:e.variableType,needsFetching:e.needsFetching}:i)}else{const a=e.actualValueEval?e.actualValueEval:e.actualValue;c.setVariableValue(c.selectWithTypes?{actualValue:a,variableType:e.variableType,needsFetching:e.needsFetching}:a)}},Z=(e,a)=>{if(c.customTrigger)c.customTrigger(e.variables[a]),c.setShowVariable(!1);else if(c.isEvaluationList){const i=e.variables[a];Y(i)}else c.setVariableValue(c.selectWithTypes?{actualValue:e.variables[a].actualValue,variableType:e.variables[a].variableType,needsFetching:e.variables[a].needsFetching}:e.variables[a].actualValue)},ee=c.isModalState?void 0:{top:`${c.topPosition?c.topPosition:"small"===c.pickerSize?"300px":"60px"}`,left:`${c.leftPosition?c.leftPosition+24:430}px`};return a("div",Object.assign({id:"varList",tabIndex:-1},{children:i(v,Object.assign({style:ee,onClick:e=>{e.stopPropagation()},pickerSize:c.pickerSize||"large",isModalState:c.isModalState,positionStrategy:c.positionStrategy,zIndex:c.zindex,height:c.height,needsBorder:S,width:c.width},{children:[_&&a(y,Object.assign({onClick:()=>{c.setShowVariable(!1)},style:{zIndex:300}},{children:a(n,{height:20,width:20,color:u.content.secondary})})),c.showVariable&&i("div",Object.assign({className:"popup"},{children:[i("div",Object.assign({className:"sticky__bar"},{children:[w&&i("div",Object.assign({className:"header__bar"},{children:[a("div",Object.assign({className:"add__variable"},{children:"Add a new variable"})),!_&&a("div",Object.assign({onClick:()=>{c.setShowVariable(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center"}},{children:a(h,{iconButtonType:"default",Icon:n})}))]})),i("div",Object.assign({className:"search__bar",onBlur:e=>{c.onSearchBlur&&c.onSearchBlur(e)}},{children:[a(g,{width:"100%",isEnabled:!0,onChange:e=>{E(e)},onEnter:()=>{},reset:!A,placeholder:"Search...",variant:"default"}),i("div",Object.assign({style:{display:"flex",alignItems:"center",marginTop:8,justifyContent:"space-between"}},{children:[a(j,Object.assign({style:{color:u.content.secondary}},{children:"Show only recommended variables"})),a(f,{value:R,onValueChange:a=>e(void 0,void 0,void 0,(function*(){return yield G(a)}))})]}))]})),B&&x[B].length>0&&i("div",Object.assign({className:"nav__bar"},{children:[i("div",Object.assign({className:"left__nav"},{children:[a(h,{Icon:l,style:{color:"#919191",display:"flex"},onClick:()=>{E("");const e=x[B].slice(0,-1);D(e,B),L((a=>Object.assign(Object.assign({},a),{[B]:e}))),e.length||I("")}}),i("div",Object.assign({className:"block"},{children:[a(O,{children:T[B].displayName}),T[B].description&&a(N,{children:T[B].description})]}))]})),i("div",Object.assign({className:"right__nav"},{children:[a(h,{Icon:o,style:{display:"flex"},onClick:()=>{E(""),D([],B),L((e=>Object.assign(Object.assign({},e),{[B]:[]}))),I("")}}),a("div",{children:"First page"})]}))]}))]})),!F&&i("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginTop:16}},{children:[a(O,{children:"No results found!"}),a(N,R?{children:"Sorry we could not find any recommended variables"}:{children:`Sorry we could not find any results for "${A}"`})]})),a("div",Object.assign({className:"wrapper"},{children:a("div",Object.assign({className:"list__map"},{children:i("div",Object.assign({className:"items"},{children:[!B&&z.map((e=>{let l=[];return A&&(l=Object.keys(e.variables).filter((a=>{var i;return(null===(i=e.variables[a].displayName)||void 0===i?void 0:i.toLowerCase().includes(A.toLowerCase()))||q(e.variables[a])}))),i(s,{children:[A?l.length>0?i("div",Object.assign({className:"block"},{children:[a("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a(N,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})):a(s,{}):i("div",Object.assign({className:"block"},{children:[a("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a(N,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})),Object.keys(e.variables).map((i=>{var l;return A?(null===(l=e.variables[i].displayName)||void 0===l?void 0:l.toLowerCase().includes(A.toLowerCase()))||q(e.variables[i])?a("div",Object.assign({onClick:e.variables[i].isSubHeader?()=>X(e,i):()=>Z(e,i)},{children:a(K,{item:e.variables[i],readonly:C})})):a(s,{}):a("div",Object.assign({onClick:e.variables[i].isSubHeader?()=>X(e,i):()=>Z(e,i)},{children:a(K,{item:e.variables[i],readonly:C})}))}))]})})),B&&a("div",Object.assign({className:"list__map"},{children:a("div",Object.assign({className:"items",style:{marginTop:16}},{children:Object.keys(T[B].variables).map(((e,i)=>{var l;return A?(null===(l=T[B].variables[e].displayName)||void 0===l?void 0:l.toLowerCase().includes(A.toLowerCase()))||q(T[B].variables[e])?U(T[B].variables[e],e):a(s,{}):U(T[B].variables[e],e)}))}))}))]}))}))})),a("div",{className:"bottom__padding"})]}))]}))}))}),((e,a)=>e.enableVariable===a.enableVariable&&(e.leftPosition===a.leftPosition&&e.reRender===a.reRender)));export{V as AddVariableV2};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as a,jsxs as i,Fragment as s}from"react/jsx-runtime";import l from"../../assets/icons/back_icon.svg.js";import t from"../../assets/icons/chevronRightAlt.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/plus.svg.js";import o from"../../assets/icons/undo.svg.js";import{memo as c,useState as d,useEffect as b}from"react";import{AddVariableStyled as v}from"./AddVariableV2.styled.js";import{Button as m}from"../button/Button.js";import{IconButton as h}from"../icon-button/IconButton.js";import{SearchBar as g}from"../searchBar/searchBar.js";import{Tooltip as p}from"../tooltips/Tooltip.js";import{COLORS as u}from"../../constants/Theme.js";import{CloseButtonContainer as y}from"../modals/modal.styled.js";import{Switch as f}from"../switch/Switch.js";import{BodySecondary as j,TitleSmall as O,BodyCaption as N}from"../TypographyStyle.js";const V=c((c=>{const{data:V,hasHeader:w=!0,needsBorder:S=!0,styledCloseBtn:_=!1,readonly:C=!1}=c,[T,k]=d({}),[x,L]=d(),[B,I]=d(""),[A,E]=d(""),[F,H]=d(!0),z=/.*\..*/,[P,$]=d(c.data),[R,M]=d(!0);b((()=>{const e={};V.forEach((a=>{e[a.displayName]=[]})),L(e)}),[V]),b((()=>{G(!0)}),[]),b((()=>{G(R,!B)}),[T,B]),b((()=>{M(!0),E(""),D([],B),L((e=>Object.assign(Object.assign({},e),{[B]:[]}))),I("");const e=c.data.map((e=>J(e))).filter((e=>null!==e));$(e),e.length>0?H(!0):H(!1)}),[c.reRender]),b((()=>{let e=c.data;B&&(e=[T[B]]);W(e,R).length>0?H(!0):H(!1)}),[A]);const W=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.flatMap((e=>Object.keys(e.variables).filter((i=>{var s;return(null===(s=e.variables[i].displayName)||void 0===s?void 0:s.toLowerCase().includes(A.toLowerCase()))&&(!a||e.variables[i].isAvailable===a)||q(e.variables[i])}))))},D=(e,a)=>{const i=V.find((e=>e.displayName===a));if(i){let s=i;e.forEach(((e,a)=>{s=s.variables[e]})),k((e=>Object.assign(Object.assign({},e),{[a]:s})))}},q=e=>{let a=!1;if(e.isSubHeader&&e.variables){const i=Object.keys(e.variables);for(let s=0;s<i.length;s++){const l=i[s];if(e.variables&&e.variables[l].displayName.toLowerCase().includes(A.toLowerCase())&&e.variables[l].isAvailable===R){a=!0;break}}}return a},G=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(M(e),e){let i=[];if(!B||a)i=c.data.map((e=>J(e))).filter((e=>null!==e));else{const e=T[B];i=c.data.filter((e=>e.displayName===B)).map((a=>J(a,e))).filter((e=>null!=e))}$(i),A&&(i=W(i,e)),i.length>0?H(!0):H(!1)}else if($(c.data),A){W(c.data,e).length>0?H(!0):H(!1)}else H(!0)};function J(e,a){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(a)for(const s in e.variables)if(e.variables[s].displayName===a.displayName)for(const a in e.variables[s].variables)e.variables[s].variables[a].isAvailable&&(i[a]=e.variables[s].variables[a]);else e.variables[s].isSubHeader&&J(e.variables[s],a,i);else for(const a in e.variables)e.variables[a].isAvailable&&(i[a]=e.variables[a]);return 0===Object.keys(i).length?null:Object.assign(Object.assign({},e),{variables:i})}const K=e=>{const i=e.item.description;return e.readonly?a("div",{children:a(Q,{item:e.item,readonly:e.readonly})}):a(s,{children:a(p,Object.assign({body:"",tooltipContent:a(N,Object.assign({color:u.content.primaryInverse,style:{whiteSpace:"pre-line",padding:8}},{children:e.item.isAvailable?i?`• ${i}\n• Recommended here`:"Recommended here":"Not recommended here"})),width:300,delay:300,placement:"bottom"},{children:a("div",{children:a(Q,{item:e.item})})}))})},Q=e=>a(m,{darkMode:c.enableVariable?c.enableVariable:e.item.isAvailable,size:"chip",disabled:!!e.readonly&&!e.item.isSubHeader,LeadingIcon:e.item.isSubHeader||e.readonly?void 0:r,TrailingIcon:()=>e.item.isSubHeader?a("div",Object.assign({className:"icon-trailing",style:{display:"flex"}},{children:a(t,{})})):a(s,{}),buttonText:e.item.displayName}),U=(e,i)=>R&&!e.isAvailable?a(s,{}):a("div",Object.assign({onClick:e.isSubHeader?()=>{W([e],R).length||H(!1),E("");const a=[...x[B],i];D(a,B),L((e=>Object.assign(Object.assign({},e),{[B]:a})))}:()=>{c.customTrigger?(c.customTrigger(e),c.setShowVariable(!1)):c.isEvaluationList?Y(e):c.setVariableValue(c.selectWithTypes?{actualValue:e.actualValue,variableType:e.variableType,needsFetching:e.needsFetching}:e.actualValue)}},{children:a(K,{item:e,readonly:C})})),X=(e,a)=>{const i=[...x[e.displayName],a];D(i,e.displayName),L((a=>Object.assign(Object.assign({},a),{[e.displayName]:i}))),I(e.displayName)},Y=e=>{if(e.actualValue.match(z)){const a=e.actualValue.replace("{{","").replace("}}","").split(".");let i=a[0];a.forEach(((e,a)=>{if(0===a)return;const s=(e=>/\w+\[\d+\]/g.test(e))(e);if(s){const a=e.match(/(\w+)\[(\d+)\]/);if(a){const e=a[1],s=a[2];i+=`['${e}'][${s}]`}}else i+=`['${e}']`})),c.setVariableValue(c.selectWithTypes?{actualValue:i,variableType:e.variableType,needsFetching:e.needsFetching}:i)}else{const a=e.actualValueEval?e.actualValueEval:e.actualValue;c.setVariableValue(c.selectWithTypes?{actualValue:a,variableType:e.variableType,needsFetching:e.needsFetching}:a)}},Z=(e,a)=>{if(c.customTrigger)c.customTrigger(e.variables[a]),c.setShowVariable(!1);else if(c.isEvaluationList){const i=e.variables[a];Y(i)}else c.setVariableValue(c.selectWithTypes?{actualValue:e.variables[a].actualValue,variableType:e.variables[a].variableType,needsFetching:e.variables[a].needsFetching}:e.variables[a].actualValue)},ee=c.isModalState?void 0:{top:`${c.topPosition?c.topPosition:"small"===c.pickerSize?"300px":"60px"}`,left:`${c.leftPosition?c.leftPosition+24:430}px`};return a("div",Object.assign({id:"varList",tabIndex:-1},{children:i(v,Object.assign({style:ee,onClick:e=>{e.stopPropagation()},pickerSize:c.pickerSize||"large",isModalState:c.isModalState,positionStrategy:c.positionStrategy,zIndex:c.zindex,height:c.height,needsBorder:S,width:c.width},{children:[_&&a(y,Object.assign({onClick:()=>{c.setShowVariable(!1)},style:{zIndex:300}},{children:a(n,{height:20,width:20,color:u.content.secondary})})),c.showVariable&&i("div",Object.assign({className:"popup"},{children:[i("div",Object.assign({className:"sticky__bar"},{children:[w&&i("div",Object.assign({className:"header__bar"},{children:[a("div",Object.assign({className:"add__variable"},{children:"Add a new variable"})),!_&&a("div",Object.assign({onClick:()=>{c.setShowVariable(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center"}},{children:a(h,{iconButtonType:"default",Icon:n})}))]})),i("div",Object.assign({className:"search__bar",onBlur:e=>{c.onSearchBlur&&c.onSearchBlur(e)}},{children:[a(g,{width:"100%",isEnabled:!0,onChange:e=>{E(e)},onEnter:()=>{},reset:!A,placeholder:"Search...",variant:"default"}),i("div",Object.assign({style:{display:"flex",alignItems:"center",marginTop:8,justifyContent:"space-between"}},{children:[a(j,Object.assign({style:{color:u.content.secondary}},{children:"Show only recommended variables"})),a(f,{value:R,onValueChange:a=>e(void 0,void 0,void 0,(function*(){return yield G(a)}))})]}))]})),B&&x[B].length>0&&i("div",Object.assign({className:"nav__bar"},{children:[i("div",Object.assign({className:"left__nav"},{children:[a(h,{Icon:l,style:{color:"#919191",display:"flex"},onClick:()=>{E("");const e=x[B].slice(0,-1);D(e,B),L((a=>Object.assign(Object.assign({},a),{[B]:e}))),e.length||I("")}}),i("div",Object.assign({className:"block"},{children:[a(O,{children:T[B].displayName}),T[B].description&&a(N,{children:T[B].description})]}))]})),i("div",Object.assign({className:"right__nav"},{children:[a(h,{Icon:o,style:{display:"flex"},onClick:()=>{E(""),D([],B),L((e=>Object.assign(Object.assign({},e),{[B]:[]}))),I("")}}),a("div",{children:"First page"})]}))]}))]})),!F&&i("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginTop:16}},{children:[a(O,{children:"No results found!"}),a(N,R?{children:"Sorry we could not find any recommended variables"}:{children:`Sorry we could not find any results for "${A}"`})]})),a("div",Object.assign({className:"wrapper"},{children:a("div",Object.assign({className:"list__map"},{children:i("div",Object.assign({className:"items"},{children:[!B&&P.map((e=>{let l=[];return A&&(l=Object.keys(e.variables).filter((a=>{var i;return(null===(i=e.variables[a].displayName)||void 0===i?void 0:i.toLowerCase().includes(A.toLowerCase()))||q(e.variables[a])}))),i(s,{children:[A?l.length>0?i("div",Object.assign({className:"block"},{children:[a("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a(N,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})):a(s,{}):i("div",Object.assign({className:"block"},{children:[a("div",Object.assign({className:"heading__font"},{children:null==e?void 0:e.displayName})),a(N,Object.assign({style:{marginBottom:8,color:"#616161"}},{children:null==e?void 0:e.description}))]})),Object.keys(e.variables).map((i=>{var l;return A?(null===(l=e.variables[i].displayName)||void 0===l?void 0:l.toLowerCase().includes(A.toLowerCase()))||q(e.variables[i])?a("div",Object.assign({onClick:e.variables[i].isSubHeader?()=>X(e,i):()=>Z(e,i)},{children:a(K,{item:e.variables[i],readonly:C})})):a(s,{}):a("div",Object.assign({onClick:e.variables[i].isSubHeader?()=>X(e,i):()=>Z(e,i)},{children:a(K,{item:e.variables[i],readonly:C})}))}))]})})),B&&a("div",Object.assign({className:"list__map"},{children:a("div",Object.assign({className:"items",style:{marginTop:16}},{children:Object.keys(T[B].variables).map(((e,i)=>{var l;return A?(null===(l=T[B].variables[e].displayName)||void 0===l?void 0:l.toLowerCase().includes(A.toLowerCase()))||q(T[B].variables[e])?U(T[B].variables[e],e):a(s,{}):U(T[B].variables[e],e)}))}))}))]}))}))})),a("div",{className:"bottom__padding"})]}))]}))}))}),((e,a)=>e.enableVariable===a.enableVariable&&(e.leftPosition===a.leftPosition&&e.reRender===a.reRender)));export{V as AddVariableV2};
@@ -1 +1 @@
1
- import c from"@emotion/styled/base";import{jsxs as t,jsx as e}from"react/jsx-runtime";import{BodyPrimary as l}from"../../../TypographyStyle.js";const o=c("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}"}:{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblx0ZmxleC1kaXJlY3Rpb246IHJvdztcblx0ZmxleDogMTtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdFx0ZmxleDogMTtcblx0fVxuYDtcclxuZXhwb3J0IGNvbnN0IExlZ2VuZCA9ICh7IGNvbG9yLCB0ZXh0IH0pID0+IHtcclxuICAgIGNvbnN0IHRvVXBwZXJDYXNlID0gKG5hbWUpID0+IHtcclxuICAgICAgICByZXR1cm4gbmFtZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG5hbWUuc2xpY2UoMSk7XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIChfanN4cyhMZWdlbmRTdHlsZWQsIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2xhc3NOYW1lOiAnY29sb3InLCBzdHlsZTogeyBiYWNrZ3JvdW5kQ29sb3I6IGNvbG9yIH0gfSksIF9qc3goQm9keVByaW1hcnksIE9iamVjdC5hc3NpZ24oeyBjbGFzc05hbWU6ICd0aXRsZScgfSwgeyBjaGlsZHJlbjogdG9VcHBlckNhc2UodGV4dCkgfSkpXSB9KSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxlZ2VuZC5qcy5tYXAiXX0= */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),i=c=>{let{color:i,text:a}=c;return t(o,{children:[e("div",{className:"color",style:{backgroundColor:i}}),e(l,Object.assign({className:"title"},{children:(r=a,r.charAt(0).toUpperCase()+r.slice(1))}))]});var r};export{i as Legend};
1
+ import t from"@emotion/styled/base";import{jsxs as c,jsx as l}from"react/jsx-runtime";import{BodyPrimary as e}from"../../../TypographyStyle.js";const i=t("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}"}:{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdH1cbmA7XHJcbmV4cG9ydCBjb25zdCBMZWdlbmQgPSAoeyBjb2xvciwgdGV4dCB9KSA9PiB7XHJcbiAgICBjb25zdCB0b1VwcGVyQ2FzZSA9IChuYW1lKSA9PiB7XHJcbiAgICAgICAgcmV0dXJuIG5hbWUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBuYW1lLnNsaWNlKDEpO1xyXG4gICAgfTtcclxuICAgIHJldHVybiAoX2pzeHMoTGVnZW5kU3R5bGVkLCB7IGNoaWxkcmVuOiBbX2pzeChcImRpdlwiLCB7IGNsYXNzTmFtZTogJ2NvbG9yJywgc3R5bGU6IHsgYmFja2dyb3VuZENvbG9yOiBjb2xvciB9IH0pLCBfanN4KEJvZHlQcmltYXJ5LCBPYmplY3QuYXNzaWduKHsgY2xhc3NOYW1lOiAndGl0bGUnIH0sIHsgY2hpbGRyZW46IHRvVXBwZXJDYXNlKHRleHQpIH0pKV0gfSkpO1xyXG59O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1MZWdlbmQuanMubWFwIl19 */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),o=t=>{let{color:o,text:a}=t;return c(i,{children:[l("div",{className:"color",style:{backgroundColor:o}}),l(e,Object.assign({className:"title"},{children:(n=a,n.charAt(0).toUpperCase()+n.slice(1))}))]});var n};export{o as Legend};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"../../assets/icons/chevronRight.svg.js";import{useRef as l,useState as c,useEffect as n}from"react";import{CheckBox as s}from"../checkBox/CheckBox.js";import{IconButton as r}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as m}from"./ProductPickerShimmer.js";import{CollectionCardStyle as C,CollectionCardInfoStyle as g,CollectionCardDetailStyle as y,CollectionNameHolder as b}from"./style.js";import{isCollectionPartiallyChecked as f}from"./utility.js";const v=(e,t,i)=>{if(!e)return"";if(e.length<=t)return e;const o=e.slice(0,t-1);return(i?o.slice(0,o.lastIndexOf(" ")):o)+"..."},k=i=>{var o;const{customCollectionRestriction:s,dataLoading:r,collections:d,selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,selectedCollections:C,setScreen:g,collectionFetcher:y,collectionsDispatch:b,pagingControls:v,storeId:k,setSaveDisabled:I,hideCollectionCheckbox:O,renderWithoutModal:S,pickerType:P}=i,x=l(null),D=l(v.curPage),T=!!s&&(null==C?void 0:C.isCustom),[L,R]=c(!1),w=l(!1);return n((()=>{D.current=v.curPage}),[v.curPage]),n((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&D.current>0&&!w.current&&(I(!0),R(!0),y(D.current,k).then((e=>{b({type:"paged",data:(null==e?void 0:e.collections)||{}}),v.setCurPage(D.current+1),R(!1),I(!1),Object.keys(e).length||(w.current=!0)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]),e("div",{children:[(null===(o=Object.keys(null!=d?d:{}))||void 0===o?void 0:o.length)?Object.keys(d).map((e=>t(j,{customCollectionRestriction:s,data:d[e],isDisabled:T&&!(null==C?void 0:C[e]),isChecked:!!(null==C?void 0:C[e]),isPartiallyChecked:f(e,null==d?void 0:d[e],C),selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,setScreen:g,id:e,hideCollectionCheckbox:O||"-1"===e,selectedCollections:C,renderWithoutModal:S,pickerType:P},e))):r?t(m,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:x}),L&&t(m,{})]})},j=l=>{const{customCollectionRestriction:c,data:n,selectedCollectionsDispatch:p,setCollectionId:m,setSelectedCollectionId:f,isPartiallyChecked:v,setScreen:k,id:j,isChecked:I,isDisabled:O,hideCollectionCheckbox:S,pickerType:P,selectedCollections:x,usedInSearch:D}=l;return e(C,Object.assign({isDisabled:O,onClick:e=>{if(!O){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:n,isRestricted:c}}),void m(j);m(j),k("products")}},isActive:!!x[j],usedInSearch:null!=D&&D},{children:[e(g,{children:[!S&&t(s,{isDisabled:O,isChecked:I,isPartiallyChecked:v,onValueChange:function(e,t,i){null==i||i.stopPropagation(),p(e?{type:"selected",data:{id:j,val:n,isRestricted:c}}:{type:"unselected",data:{id:j}}),f(e?j:"")}}),t(y,{children:t(a,Object.assign({body:n.name,placement:"bottom",delay:400,variant:"light"},{children:e(b,{children:[t(D?h:u,Object.assign({numberOfLines:1},{children:n.name})),n.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(i,{})]})}))})]}),"COLLECTION"!==P&&t(r,{height:12,width:12,disabled:O,Icon:o})]}))};export{j as CollectionCard,k as CollectionsScreen,v as truncate};
1
+ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as l,useEffect as s}from"react";import{CheckBox as n}from"../checkBox/CheckBox.js";import{IconButton as r}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as m}from"./ProductPickerShimmer.js";import{CollectionCardStyle as C,CollectionCardInfoStyle as g,CollectionCardDetailStyle as y,CollectionNameHolder as b}from"./style.js";import{isCollectionPartiallyChecked as f}from"./utility.js";const k=(e,t,i)=>{if(e.length<=t)return e;const o=e.slice(0,t-1);return(i?o.slice(0,o.lastIndexOf(" ")):o)+"..."},v=i=>{const{customCollectionRestriction:o,dataLoading:n,collections:r,selectedCollectionsDispatch:d,setCollectionId:a,setSelectedCollectionId:u,selectedCollections:h,setScreen:C,collectionFetcher:g,collectionsDispatch:y,pagingControls:b,storeId:k,setSaveDisabled:v,hideCollectionCheckbox:I,renderWithoutModal:O,pickerType:S}=i,P=c(null),x=c(b.curPage),D=!!o&&(null==h?void 0:h.isCustom),[T,L]=l(!1),R=c(!1);return s((()=>{x.current=b.curPage}),[b.curPage]),s((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&x.current>0&&!R.current&&(v(!0),L(!0),g(x.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),b.setCurPage(x.current+1),L(!1),v(!1),Object.keys(e).length||(R.current=!0)})).catch())}),{threshold:1});return P.current&&e.observe(P.current),()=>{P.current&&e.unobserve(P.current)}}),[P]),e("div",{children:[Object.keys(r).length?Object.keys(r).map((e=>t(j,{customCollectionRestriction:o,data:r[e],isDisabled:D&&!(null==h?void 0:h[e]),isChecked:!!(null==h?void 0:h[e]),isPartiallyChecked:f(e,null==r?void 0:r[e],h),selectedCollectionsDispatch:d,setCollectionId:a,setSelectedCollectionId:u,setScreen:C,id:e,hideCollectionCheckbox:I||"-1"===e,selectedCollections:h,renderWithoutModal:O,pickerType:S},e))):n?t(m,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:P}),T&&t(m,{})]})},j=c=>{const{customCollectionRestriction:l,data:s,selectedCollectionsDispatch:p,setCollectionId:m,setSelectedCollectionId:f,isPartiallyChecked:k,setScreen:v,id:j,isChecked:I,isDisabled:O,hideCollectionCheckbox:S,pickerType:P,selectedCollections:x,usedInSearch:D}=c;return e(C,Object.assign({isDisabled:O,onClick:e=>{if(!O){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:s,isRestricted:l}}),void m(j);m(j),v("products")}},isActive:!!x[j],usedInSearch:null!=D&&D},{children:[e(g,{children:[!S&&t(n,{isDisabled:O,isChecked:I,isPartiallyChecked:k,onValueChange:function(e,t,i){null==i||i.stopPropagation(),p(e?{type:"selected",data:{id:j,val:s,isRestricted:l}}:{type:"unselected",data:{id:j}}),f(e?j:"")}}),t(y,{children:t(a,Object.assign({body:s.name,placement:"bottom",delay:400,variant:"light"},{children:e(b,{children:[t(D?h:u,Object.assign({numberOfLines:1},{children:s.name})),s.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(i,{})]})}))})]}),"COLLECTION"!==P&&t(r,{height:12,width:12,disabled:O,Icon:o})]}))};export{j as CollectionCard,v as CollectionsScreen,k as truncate};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as l}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const O=O=>{const{storeId:T,selectedItems:D,onClose:R,visible:w,zIndex:E,exactLimit:A,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:N,hideProductVariants:U=!1,startupScreen:q=F.Collections,rearrangeEnabled:J,selectSingleItem:Q=!1,showProductDetails:X}=O,[Z,_]=r(f,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(q)?q:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ie,le]=s(""),[ne,de]=s(0),[ae,ue]=s(!1),[he,pe]=s(0),[me,Ce]=s(""),[ge,be]=s(!1),[fe,ye]=s(!1),[Se,ve]=r(y,{collections:{},products:{}}),[ke,Pe]=r(S,Object.keys(D).length>0?D:{}),xe=i(null),[je,Ie]=s(!1),[Fe,Oe]=s();l((()=>{ue(!0),ye(!0),O.collectionFetcher(ne,T).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ue(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),l((()=>{let e=0;U?Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&ke[-1]&&(null===(c=ke[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ke[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)}),[ke,U]),l((()=>{ie&&(ue(!0),O.productFetcher(ie,T).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ie,products:e}}),ue(!1)})).catch())}),[ie]),l((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(be(!0),O.searchFetcher(T,me).then((e=>{"collections"in e&&"products"in e?(ve({type:"set",data:e}),_({type:"searched",data:e.collections})):(ve({type:"set",data:{collections:{},products:e}}),_({type:"searched",data:e})),te("searchProducts"),ue(!1),be(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),l((()=>{K&&(O.onAdd(ke,he),Te())}),[K]),l((()=>{Q&&Object.keys(ke||{}).length&&he&&(O.onAdd(ke,he),Te())}),[Q,ke,he]);const Te=()=>{Pe({type:"reset",data:{}})},De=e(x,{children:[O.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:O.postHeader})),!O.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(h,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(j,Object.assign({ref:xe,screenName:ee},{children:["collections"===ee&&t(m,{customCollectionRestriction:O.customCollectionRestriction,dataLoading:fe,collections:Z,selectedCollectionsDispatch:Pe,setCollectionId:se,setSelectedCollectionId:le,setScreen:te,selectedCollections:ke,collectionFetcher:O.collectionFetcher,storeId:T,collectionsDispatch:_,setSaveDisabled:ue,pagingControls:{curPage:ne,setCurPage:de},hideCollectionCheckbox:$,renderWithoutModal:Y,pickerType:N}),"products"===ee&&re&&t(v.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:O.hideInCollectionSearch,customCollectionRestriction:O.customCollectionRestriction,productFetcher:O.productFetcher,setScreen:te,storeId:T,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:Pe,selectedData:ke,setSaveDisabled:ue,searchInCollectionFetcher:O.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:N,hideProductVariants:U,fbStatusFetcher:O.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Oe(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(P,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,hideProductVariants:U,outOfStockAction:L,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"rearrange"===ee&&t(b,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:xe,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"searchProducts"===ee&&t(k,{customCollectionRestriction:O.customCollectionRestriction,selectedCollections:ke||{},searchedCollections:Se||{},searchedCollectionsDispatch:ve,selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),ve({type:"set",data:{collections:{},products:{}}})},pickerType:N,hideProductCheckbox:B,hideProductVariants:U,hideVariantCheckbox:M,storeId:T,fbStatusFetcher:O.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:le,renderWithoutModal:Y,hideCollectionCheckbox:$})]}))]});return t(o,{children:Y?De:e(u,Object.assign({zIndex:E,open:w,onClose:()=>{null==R||R(),Te()},headingTitle:G||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Results":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),footerContainerStyle:O.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||he<1||A&&he<A||!A&&V&&he>V||!1,onClick:()=>{O.onAdd(ke,he),Te()}},wrapperStyle:O.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&he>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):V&&he>V?t(p,{tagText:`You can only select ${V} products`,type:"negative"}):t(d,he>0?{onClick:()=>{te(J?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:je},{children:[De,je&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{O as ProductPickerModal,F as ScreenName};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as l}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as h}from"../modals/styledModal.js";import{Spinner as u}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as S,selectedColectionsReducer as y,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:D,selectedItems:O,onClose:R,visible:w,zIndex:E,exactLimit:A,limit:$,hideCollectionCheckbox:V,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:N,hideProductVariants:U=!1,startupScreen:q=F.Collections,rearrangeEnabled:J,selectSingleItem:Q=!1,showProductDetails:X}=T,[Z,_]=r(f,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(q)?q:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ie,le]=s(""),[ne,de]=s(0),[ae,he]=s(!1),[ue,pe]=s(0),[me,Ce]=s(""),[ge,be]=s(!1),[fe,Se]=s(!1),[ye,ve]=r(S,{collections:{},products:{}}),[ke,Pe]=r(y,Object.keys(O).length>0?O:{}),xe=i(null),[je,Ie]=s(!1),[Fe,Te]=s();l((()=>{he(!0),Se(!0),T.collectionFetcher(ne,D).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),he(!1),de((e=>e+1)),Se(!1)})).catch()}),[]),l((()=>{let e=0;Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ke[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)})),l((()=>{ie&&(he(!0),T.productFetcher(ie,D).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ie,products:e}}),he(!1)})).catch())}),[ie]),l((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(be(!0),T.searchFetcher(D,me).then((e=>{"collections"in e&&"products"in e?(ve({type:"set",data:e}),_({type:"searched",data:e.collections})):(ve({type:"set",data:{collections:{},products:e}}),_({type:"searched",data:e})),te("searchProducts"),he(!1),be(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),l((()=>{K&&(T.onAdd(ke,ue),De())}),[K]),l((()=>{Q&&Object.keys(ke||{}).length&&ue&&(T.onAdd(ke,ue),De())}),[Q,ke,ue]);const De=()=>{Pe({type:"reset",data:{}})},Oe=e(x,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(u,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(j,Object.assign({ref:xe,screenName:ee},{children:["collections"===ee&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:fe,collections:Z,selectedCollectionsDispatch:Pe,setCollectionId:se,setSelectedCollectionId:le,setScreen:te,selectedCollections:ke,collectionFetcher:T.collectionFetcher,storeId:D,collectionsDispatch:_,setSaveDisabled:he,pagingControls:{curPage:ne,setCurPage:de},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:N}),"products"===ee&&re&&t(v.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:te,storeId:D,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:Pe,selectedData:ke,setSaveDisabled:he,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:N,hideProductVariants:U,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Te(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(P,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,outOfStockAction:L,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===ee&&t(b,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:xe,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===ee&&t(k,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ke||{},searchedCollections:ye||{},searchedCollectionsDispatch:ve,selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),ve({type:"set",data:{collections:{},products:{}}})},pickerType:N,hideProductCheckbox:B,hideProductVariants:U,hideVariantCheckbox:M,storeId:D,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:le,renderWithoutModal:Y,hideCollectionCheckbox:V})]}))]});return t(o,{children:Y?Oe:e(h,Object.assign({zIndex:E,open:w,onClose:()=>{null==R||R(),De()},headingTitle:G||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Results":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||ue<1||A&&ue<A||!A&&$&&ue>$||!1,onClick:()=>{T.onAdd(ke,ue),De()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&ue>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):$&&ue>$?t(p,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,ue>0?{onClick:()=>{te(J?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${ue}/${A} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${ue}/${A} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:je},{children:[Oe,je&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as i,Fragment as e}from"react/jsx-runtime";import{COLORS as o}from"../../constants/Theme.js";import c from"../../assets/icons/info.svg.js";import{CheckBox as d}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{ShimmerImage as l}from"../shimmer-image/ShimmerImage.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{BodyPrimary as r}from"../TypographyStyle.js";import{ProductPickerTag as s}from"./ProductPickerTag.js";import{ProductCardStyle as u}from"./style.js";import{shouldShowVariant as p}from"./utility.js";const h=e=>{const{collectionId:o,productId:c,data:d,selectedData:n,selectedCollectionsDispatch:l,viewOnly:a,upliftAdditions:r,isProductPartiallyChecked:s,hideProductCheckbox:u,outOfStockAction:h,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,onProductDetailClick:k,showProductDetailInfoIcon:y}=e,C=t=>{var i,e,d,l,a,r;if(!(null===(e=null===(i=null==n?void 0:n[o])||void 0===i?void 0:i.products)||void 0===e?void 0:e[c]))return!1;return!!(null===(r=null===(a=null===(l=null===(d=null==n?void 0:n[o])||void 0===d?void 0:d.products)||void 0===l?void 0:l[c])||void 0===a?void 0:a.variants)||void 0===r?void 0:r[t])};return t("div",{children:[i(v,{isVariant:!1,data:d,productId:c,collectionId:o,isSelected:!!(null===(b=null===(P=null==n?void 0:n[o])||void 0===P?void 0:P.products)||void 0===b?void 0:b[c]),isPartiallyChecked:s,selectedCollectionsDispatch:l,upliftAdditions:r,viewOnly:a,hideProductCheckbox:u,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},c),I?null:p(d)&&Object.keys(d.variants||[]).map((t=>i(v,{isVariant:!0,hideVariantCheckbox:m,data:d.variants[t],variantId:t,productId:c,viewOnly:a,upliftAdditions:r,collectionId:o,isSelected:C(t),selectedCollectionsDispatch:l,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},t)))]});var P,b},v=p=>{const{isVariant:h,data:v,productId:m,collectionId:I,variantId:f,isSelected:k,selectedCollectionsDispatch:y,viewOnly:C,upliftAdditions:P,isPartiallyChecked:b,hideProductCheckbox:j,outOfStockAction:O,hideVariantCheckbox:g,hideProductVariants:S,pickerType:x,onProductDetailClick:D,showProductDetailInfoIcon:V}=p;return t(u,Object.assign({isVariant:h,onClick:t=>{if(t.stopPropagation(),"PRODUCT"===x){const t=Object.keys(v.variants);S?P("productSelected",{productId:m,variantId:f,collectionId:I,product:S?v.variants[t[0]]:v}):P("variantSelected",{productId:m,variantId:f||t[0],collectionId:I,variant:v})}},isActive:k},{children:[h&&!C&&!g||!h&&!C&&!j?i(d,{isChecked:k,isPartiallyChecked:b||!1,onValueChange:function(t){if(h)t?P(S?"productSelected":"variantSelected",{productId:m,variantId:f,collectionId:I,variant:v}):y({type:S?"productUnselected":"variantUnselected",data:{productId:m,variantId:f,collectionId:I}});else if(t){const t=Object.keys(v.variants);P(S?"productSelected":"variantSelected",{productId:m,collectionId:I,product:S?v.variants[t[0]]:v})}else y({type:S?"productUnselected":"variantUnselected",data:{productId:m,collectionId:I}})}}):i(e,{}),i("div",{children:i(l,{width:40,height:40,imageUrl:v.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[i(a,Object.assign({variant:"light",body:v.name,placement:"bottom",delay:400},{children:i(r,Object.assign({numberOfLines:1},{children:v.name}))})),V&&i(n,{onClick:()=>{null==D||D(v)},Icon:()=>i(c,{width:20,height:20,color:o.content.placeholder})})]})),i(s,{isVariant:h,data:v,outOfStockAction:O})]}))]}))};export{v as ProductCard,h as ProductGroup};
1
+ import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{COLORS as e}from"../../constants/Theme.js";import c from"../../assets/icons/info.svg.js";import{CheckBox as d}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{ShimmerImage as l}from"../shimmer-image/ShimmerImage.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{BodyPrimary as r}from"../TypographyStyle.js";import{ProductPickerTag as s}from"./ProductPickerTag.js";import{ProductCardStyle as u}from"./style.js";import{shouldShowVariant as p}from"./utility.js";const h=o=>{const{collectionId:e,productId:c,data:d,selectedData:n,selectedCollectionsDispatch:l,viewOnly:a,upliftAdditions:r,isProductPartiallyChecked:s,hideProductCheckbox:u,outOfStockAction:h,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,onProductDetailClick:k,showProductDetailInfoIcon:y}=o,C=t=>{var i,o,d,l,a,r;if(!(null===(o=null===(i=null==n?void 0:n[e])||void 0===i?void 0:i.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(r=null===(a=null===(l=null===(d=null==n?void 0:n[e])||void 0===d?void 0:d.products)||void 0===l?void 0:l[c])||void 0===a?void 0:a.variants)||void 0===r?void 0:r[t])};return t("div",{children:[i(v,{isVariant:!1,data:d,productId:c,collectionId:e,isSelected:!!(null===(b=null===(P=null==n?void 0:n[e])||void 0===P?void 0:P.products)||void 0===b?void 0:b[c]),isPartiallyChecked:s,selectedCollectionsDispatch:l,upliftAdditions:r,viewOnly:a,hideProductCheckbox:u,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},c),I?null:p(d)&&Object.keys(d.variants||[]).map((t=>i(v,{isVariant:!0,hideVariantCheckbox:m,data:d.variants[t],variantId:t,productId:c,viewOnly:a,upliftAdditions:r,collectionId:e,isSelected:C(t),selectedCollectionsDispatch:l,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},t)))]});var P,b},v=p=>{const{isVariant:h,data:v,productId:m,collectionId:I,variantId:f,isSelected:k,selectedCollectionsDispatch:y,viewOnly:C,upliftAdditions:P,isPartiallyChecked:b,hideProductCheckbox:j,outOfStockAction:g,hideVariantCheckbox:O,hideProductVariants:x,pickerType:D,onProductDetailClick:S,showProductDetailInfoIcon:V}=p;return t(u,Object.assign({isVariant:h,onClick:t=>{"PRODUCT"===D&&x&&(t.stopPropagation(),y({type:"reset",data:{}}),P("variantSelected",{productId:m,variantId:f||Object.keys(v.variants)[0],collectionId:I,variant:v}))},isActive:k},{children:[h&&!C&&!O||!h&&!C&&!j?i(d,{isChecked:k,isPartiallyChecked:b||!1,onValueChange:function(t){h?t?P("variantSelected",{productId:m,variantId:f,collectionId:I,variant:v}):y({type:"variantUnselected",data:{productId:m,variantId:f,collectionId:I}}):t?P("productSelected",{productId:m,collectionId:I,product:v}):y({type:"productUnselected",data:{productId:m,collectionId:I}})}}):i(o,{}),i("div",{children:i(l,{width:40,height:40,imageUrl:v.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[i(a,Object.assign({variant:"light",body:v.name,placement:"bottom",delay:400},{children:i(r,Object.assign({numberOfLines:1},{children:v.name}))})),V&&i(n,{onClick:()=>{null==S||S(v)},Icon:()=>i(c,{width:20,height:20,color:e.content.placeholder})})]})),i(s,{isVariant:h,data:v,outOfStockAction:g})]}))]}))};export{v as ProductCard,h as ProductGroup};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,rt,R,U),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt,U),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,w,R),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
@@ -1 +1 @@
1
- import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,d,c,o,r,n,i,u,l,p,v;let O={},g="",b="",j="";switch(e.type){case"selected":return O=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(O={}),O.isCustom=!0),O[e.data.id]=e.data.val,O;case"unselected":return O=t(a),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[e.data.id],O;case"productUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={}),O[b].products[g]=e.data.product,O;case"variantSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(d=e.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={},O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),(null===(o=null===(c=null==O?void 0:O[b])||void 0===c?void 0:c.products)||void 0===o?void 0:o[g])||((null===(r=null==O?void 0:O[b])||void 0===r?void 0:r.products)||(O[b].products={}),O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants[j]=e.data.variant,O;case"variantUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(l=null===(u=O[b].products)||void 0===u?void 0:u[g])||void 0===l?void 0:l.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},a),O;case"reset":return{};default:return a}}function s(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,e;case"paged":return e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return e=Object.assign({},t),e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;case"searched":e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return e;default:return{}}}function d(t,a){let e={};switch(a.type){case"paginate":e=Object.assign({},t);for(const t in a.data)if(Object.prototype.hasOwnProperty.call(a.data,t)){const s=a.data[t];if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];e[t]=Object.assign(Object.assign({},a),{products:Object.assign(Object.assign({},a.products),s.products)})}else e[t]=s}return e;case"update":return e=Object.assign({},t),e;case"set":return e=Object.assign(Object.assign({},t),a.data),e;case"filter":e={};for(const s in t)if(s in a.data){const d=Object.assign({},t[s]),c=a.data[s],o={};for(const t in d.products)if(t in c.products){const a=Object.assign({},d.products[t]),e=c.products[t],s={};for(const t in a.variants)t in e.variants&&(s[t]=Object.assign({},a.variants[t]));Object.keys(s).length>0&&(a.variants=s,o[t]=a)}Object.keys(o).length>0&&(d.products=o,e[s]=d)}return e;default:return t}}function c(t,a){let e={collections:{},products:{}};switch(a.type){case"set":return a.data;case"setProducts":return e=Object.assign({},t),e.products=a.data,e;default:return t}}const o=a("");export{o as CollectionIdContext,s as collectionsReducer,d as paginationReducer,c as searchReducer,e as selectedColectionsReducer};
1
+ import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,c,d,r,o,n;let i={},u="",l="",p="";switch(e.type){case"selected":return i=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(i={}),i.isCustom=!0),i[e.data.id]=e.data.val,i;case"unselected":return i=t(a),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[e.data.id],i;case"productUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,delete i[l].products[u],Object.keys(i[l].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[l]),i;case"productSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={}),i[l].products[u]=e.data.product,i;case"variantSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={},i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),(null===(r=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===r?void 0:r[u])||((null===(o=null==i?void 0:i[l])||void 0===o?void 0:o.products)||(i[l].products={}),i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=e.data.variant,i;case"variantUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,delete i[l].products[u].variants[p],Object.keys(i[l].products[u].variants).length||(delete i[l].products[u],Object.keys(i[l].products).length||((null===(n=i[l])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[l])),i;case"update":return i=Object.assign({},a),i;case"reset":return{};default:return a}}function s(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,e;case"paged":return e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return e=Object.assign({},t),e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;case"searched":e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return e;default:return{}}}function c(t,a){let e={};switch(a.type){case"paginate":e=Object.assign({},t);for(const t in a.data)if(Object.prototype.hasOwnProperty.call(a.data,t)){const s=a.data[t];if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];e[t]=Object.assign(Object.assign({},a),{products:Object.assign(Object.assign({},a.products),s.products)})}else e[t]=s}return e;case"update":return e=Object.assign({},t),e;case"set":return e=Object.assign(Object.assign({},t),a.data),e;case"filter":e={};for(const s in t)if(s in a.data){const c=Object.assign({},t[s]),d=a.data[s],r={};for(const t in c.products)if(t in d.products){const a=Object.assign({},c.products[t]),e=d.products[t],s={};for(const t in a.variants)t in e.variants&&(s[t]=Object.assign({},a.variants[t]));Object.keys(s).length>0&&(a.variants=s,r[t]=a)}Object.keys(r).length>0&&(c.products=r,e[s]=c)}return e;default:return t}}function d(t,a){let e={collections:{},products:{}};switch(a.type){case"set":return a.data;case"setProducts":return e=Object.assign({},t),e.products=a.data,e;default:return t}}const r=a("");export{r as CollectionIdContext,s as collectionsReducer,c as paginationReducer,d as searchReducer,e as selectedColectionsReducer};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:j,selectedCollectionsDispatch:f,setScreen:P,collections:S,onBackPress:I,hideVariantCheckbox:O,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:R,hideCollectionCheckbox:W,renderWithoutModal:B}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,j,V,"setProducts")}),[null==b?void 0:b.products]);const M=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{P("collections"),I()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==S?void 0:S[o],isDisabled:M&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==S?void 0:S[o],y,x),selectedCollectionsDispatch:f,setCollectionId:w,setSelectedCollectionId:R,setScreen:P,id:o,hideCollectionCheckbox:W||"-1"===o,selectedCollections:y,renderWithoutModal:B,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o],x),selectedData:y,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:O,hideProductVariants:x,pickerType:g},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
1
+ import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:j,selectedCollectionsDispatch:f,setScreen:P,collections:S,onBackPress:I,hideVariantCheckbox:O,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:R,hideCollectionCheckbox:W,renderWithoutModal:B}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,j,V,"setProducts")}),[null==b?void 0:b.products]);const M=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{P("collections"),I()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==S?void 0:S[o],isDisabled:M&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==S?void 0:S[o],y),selectedCollectionsDispatch:f,setCollectionId:w,setSelectedCollectionId:R,setScreen:P,id:o,hideCollectionCheckbox:W||"-1"===o,selectedCollections:y,renderWithoutModal:B,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o]),selectedData:y,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:O,hideProductVariants:x,pickerType:g},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
@@ -9,7 +9,6 @@ interface SelectedScreenInterface {
9
9
  collections: {
10
10
  [key: string]: Collection;
11
11
  };
12
- hideProductVariants?: boolean;
13
12
  outOfStockAction?: OUT_OF_STOCK_ACTION;
14
13
  storeId: string;
15
14
  fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as s,useEffect as l}from"react";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as n}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{AllProductHelper as u}from"./helpers/AllProductHelper.js";import{ProductGroup as a}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as m}from"./style.js";import{paginateSelectedItems as f,fetchFbStatusCollection as h,isProductPartiallyChecked as v}from"./utility.js";const j=j=>{const{selectedCollections:y,selectedCollectionsDispatch:b,setScreen:S,collections:g,hideProductVariants:O=!1,outOfStockAction:P,storeId:k,fbStatusFetcher:C}=j,I=c(0),A=c(null),[D,w]=s(p,{});l((()=>{I.current=0;const t=f(y,10,0);w({type:"paginate",data:t}),h(t,k,w,C,"set"),I.current+=1}),[]),l((()=>{w({type:"filter",data:y})}),[y]),l((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&I.current>0){const t=f(y,10,I.current);w({type:"paginate",data:t}),h(t,k,w,C,"update"),I.current+=1}}),{threshold:1});return A.current&&t.observe(A.current),()=>{A.current&&t.unobserve(A.current)}}),[A,y]);const x=O?u.removeDuplicatesForAllProducts(Object.assign({},y)):y;return console.log({curScreenData:D,selectedCollections:y}),t("div",{children:[t(m,{children:[e(i,{Icon:o,onClick:()=>{S("collections")}}),e(n,{children:"Selected Products"})]}),t("div",{children:[Object.keys(D).length>0?e(r,{children:Object.keys(D).map((t=>{var r;return Object.keys((null===(r=null==D?void 0:D[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==x?void 0:x.isCustom)&&(o=!0),e(a,{upliftAdditions:null,collectionId:t,productId:r,data:D[t].products[r],isProductPartiallyChecked:v(t,r,x,null==g?void 0:g[t],O),selectedData:x,selectedCollectionsDispatch:b,viewOnly:o,hideProductVariants:O,outOfStockAction:P},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:A})]})]})};export{j as SelectedScreen};
1
+ import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as n,useEffect as i}from"react";import{IconButton as s}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as a}from"./style.js";import{paginateSelectedItems as m,fetchFbStatusCollection as f,isProductPartiallyChecked as h}from"./utility.js";const v=v=>{const{selectedCollections:y,selectedCollectionsDispatch:j,setScreen:b,collections:S,outOfStockAction:k,storeId:I,fbStatusFetcher:O}=v,g=c(0),C=c(null),[w,P]=n(p,{});return i((()=>{g.current=0;const t=m(y,10,0);P({type:"paginate",data:t}),f(t,I,P,O,"set"),g.current+=1}),[]),i((()=>{P({type:"filter",data:y})}),[y]),i((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&g.current>0){const t=m(y,10,g.current);P({type:"paginate",data:t}),f(t,I,P,O,"update"),g.current+=1}}),{threshold:1});return C.current&&t.observe(C.current),()=>{C.current&&t.unobserve(C.current)}}),[C,y]),t("div",{children:[t(a,{children:[e(s,{Icon:o,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(w).length>0?e(r,{children:Object.keys(w).map((t=>{var r;return Object.keys((null===(r=null==w?void 0:w[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==y?void 0:y.isCustom)&&(o=!0),e(u,{upliftAdditions:null,collectionId:t,productId:r,data:w[t].products[r],isProductPartiallyChecked:h(t,r,y,null==S?void 0:S[t]),selectedData:y,selectedCollectionsDispatch:j,viewOnly:o,outOfStockAction:k},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:C})]})]})};export{v as SelectedScreen};
@@ -34,5 +34,5 @@ export declare const markVariantsAsApprovedProductsLevel: (products: {
34
34
  * Other cases returns true.
35
35
  */
36
36
  export declare const shouldShowVariant: (data: Product) => boolean;
37
- export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection, hideProductVariants?: boolean) => boolean;
38
- export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems, hideProductVariants?: boolean) => boolean;
37
+ export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection) => boolean;
38
+ export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems) => boolean;
@@ -1 +1 @@
1
- import{cloneDeep as o}from"lodash";const l=(l,t)=>{const n=o(t);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&t.products){const i=o(t.products[l.productId]);(null==i?void 0:i.variants)&&delete i.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:i})}return l};function t(o,l,t){var i;const d={};let v=0;for(const u in o)if(Object.prototype.hasOwnProperty.call(o,u)){const s=o[u],c=n(s.products,l,t-v);c&&Object.keys(c).length>0&&(d[u]=Object.assign(Object.assign({},s),{products:c})),v+=Object.keys(null!==(i=s.products)&&void 0!==i?i:{}).length}return d}function n(o,l,t){if(!o)return{};const n=Object.keys(o).slice(t,t+l),i={};return n.forEach((l=>{i[l]=o[l]})),i}const i=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,n;const i=null!==(n=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==n?n:{};Object.keys(i).forEach((t=>{var n,i,d,v;const u=null!==(v=null===(d=null===(i=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(u).forEach((n=>{var i,d,v,u;const s=null===(u=null===(v=null===(d=null===(i=o[l])||void 0===i?void 0:i.products)||void 0===d?void 0:d[t])||void 0===v?void 0:v.variants)||void 0===u?void 0:u[n];s&&!s.fbStatus&&(s.fbStatus="APPROVED")}))}))})),l({type:t,data:o})},d=function(o,l,t,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||i(o,t,d);const v=(o=>{const l=[];return Object.keys(o).forEach((t=>{var n,i;const d=null!==(i=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==i?i:{};Object.keys(d).forEach((n=>{var i,d,v,u;const s=null!==(u=null===(v=null===(d=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==u?u:{};Object.keys(s).forEach((i=>{var d,v,u,s;const c=null===(s=null===(u=null===(v=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===u?void 0:u.variants)||void 0===s?void 0:s[i];(null==c?void 0:c.fbStatus)||l.push(i)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var t,i;const d=null!==(i=null===(t=n[o])||void 0===t?void 0:t.products)&&void 0!==i?i:{};Object.keys(d).forEach((t=>{var i,d,v,u;const s=null!==(u=null===(v=null===(d=null===(i=n[o])||void 0===i?void 0:i.products)||void 0===d?void 0:d[t])||void 0===v?void 0:v.variants)&&void 0!==u?u:{};Object.keys(s).forEach((i=>{var d,v,u,s;const c=null===(s=null===(u=null===(v=null===(d=n[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[t])||void 0===u?void 0:u.variants)||void 0===s?void 0:s[i];c&&"REJECTED"===l[i]?c.fbStatus="REJECTED":c&&"APPROVED"===l[i]&&(c.fbStatus="APPROVED")}))}))})),t({type:d,data:n})})).catch((l=>{console.error("Error in fbStatusFetcher",l),i(o,t,d)}))},v=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((n=>{var i,d;const v=null!==(d=null===(i=null==o?void 0:o[n])||void 0===i?void 0:i.variants)&&void 0!==d?d:{};Object.keys(v).forEach((i=>{var d,v,u,s,c;let r;r=l?null===(u=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===u?void 0:u[i]:null===(c=null===(s=null==o?void 0:o[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[i],(null==r?void 0:r.fbStatus)||t.push(i)}))})),t},u=(o,l,t,n,i)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,n;Object.keys(null!==(n=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==n?n:{}).forEach((t=>{var n,i;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[t];v&&(v.fbStatus="APPROVED");const u=null===(i=null==d?void 0:d[l])||void 0===i?void 0:i.variants;u&&u[t]&&(u[t]=v)}))})),n&&i){const o=Object.assign({},n);o.products=d,i(o),l({type:"productsPaged",data:{collectionId:t,products:d}})}else l({type:"productsPaged",data:{collectionId:t,products:d}})},s=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var n,i;t=null!==(i=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==i&&i})),!t)},c=(o,l,t,n,i)=>{var d,v,u,s,c,r,a,e,f,p,b,O,h,j,y,E,k,g,P;let D=0,S=0;if(console.log({collectionId:o,productId:l,selectedData:t,currentCollection:n,hideProductVariants:i}),null===(v=null===(d=null==t?void 0:t[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[l]){if(i)return!1;const d=(null===(c=null===(s=null===(u=null==t?void 0:t[o])||void 0===u?void 0:u.products)||void 0===s?void 0:s[l])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const n in d){const i=null===(a=null===(r=null==t?void 0:t[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[l],d=null===(b=null===(p=null===(f=null===(e=null==t?void 0:t[o])||void 0===e?void 0:e.products)||void 0===f?void 0:f[l])||void 0===p?void 0:p.variants)||void 0===b?void 0:b[n];if(null===(O=null==d?void 0:d.name)||void 0===O?void 0:O.includes(null!==(h=null==i?void 0:i.name)&&void 0!==h?h:""))return!1}if(null===(E=Object.keys((null===(y=null===(j=null==n?void 0:n.products)||void 0===j?void 0:j[l])||void 0===y?void 0:y.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(g=null===(k=null==t?void 0:t[o])||void 0===k?void 0:k.products)||void 0===g?void 0:g[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},r=function(o,l,t){var n,i,d,v;let u=0,s=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};u=Object.keys(v).length;const c=null!==(d=null===(i=t[o])||void 0===i?void 0:i.products)&&void 0!==d?d:{};s=Object.keys(c).length}else if(t[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const t=null===(l=n[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>u+=1))}));const i=null===(v=t[o])||void 0===v?void 0:v.products;if(i&&Object.keys(i).forEach((o=>{var l;const t=null===(l=i[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>s+=1))})),u<=0&&s>0)return!1}return s>0&&u!==s};export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,u as markVariantsAsApprovedProductsLevel,t as paginateSelectedItems,s as shouldShowVariant};
1
+ import{cloneDeep as o}from"lodash";const l=(l,i)=>{const n=o(i);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&i.products){const t=o(i.products[l.productId]);(null==t?void 0:t.variants)&&delete t.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:t})}return l};function i(o,l,i){var t;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=n(u.products,l,i-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(t=u.products)&&void 0!==t?t:{}).length}return d}function n(o,l,i){if(!o)return{};const n=Object.keys(o).slice(i,i+l),t={};return n.forEach((l=>{t[l]=o[l]})),t}const t=(o,l,i)=>{Object.keys(o).forEach((l=>{var i,n;const t=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(t).forEach((i=>{var n,t,d,v;const s=null!==(v=null===(d=null===(t=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===t?void 0:t[i])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((n=>{var t,d,v,s;const u=null===(s=null===(v=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:i,data:o})},d=function(o,l,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||t(o,i,d);const v=(o=>{const l=[];return Object.keys(o).forEach((i=>{var n,t;const d=null!==(t=null===(n=o[i])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=o[i])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[i])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];(null==c?void 0:c.fbStatus)||l.push(t)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var i,t;const d=null!==(t=null===(i=n[o])||void 0===i?void 0:i.products)&&void 0!==t?t:{};Object.keys(d).forEach((i=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=n[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=n[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];c&&"REJECTED"===l[t]?c.fbStatus="REJECTED":c&&"APPROVED"===l[t]&&(c.fbStatus="APPROVED")}))}))})),i({type:d,data:n})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,i,d)}))},v=(o,l)=>{const i=[];return Object.keys(null!=o?o:{}).forEach((n=>{var t,d;const v=null!==(d=null===(t=null==o?void 0:o[n])||void 0===t?void 0:t.variants)&&void 0!==d?d:{};Object.keys(v).forEach((t=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t]:null===(c=null===(u=null==o?void 0:o[n])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[t],(null==r?void 0:r.fbStatus)||i.push(t)}))})),i},s=(o,l,i,n,t)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var i,n;Object.keys(null!==(n=null===(i=null==o?void 0:o[l])||void 0===i?void 0:i.variants)&&void 0!==n?n:{}).forEach((i=>{var n,t;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[i];v&&(v.fbStatus="APPROVED");const s=null===(t=null==d?void 0:d[l])||void 0===t?void 0:t.variants;s&&s[i]&&(s[i]=v)}))})),n&&t){const o=Object.assign({},n);o.products=d,t(o),l({type:"productsPaged",data:{collectionId:i,products:d}})}else l({type:"productsPaged",data:{collectionId:i,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let i=!1;return!(l.length<=1)||(l.forEach((l=>{var n,t;i=null!==(t=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==t&&t})),!i)},c=(o,l,i,n)=>{var t,d,v,s,u,c,r,a,e,f,p,b,O,h,j,y,E,k,g;let P=0,D=0;if(null===(d=null===(t=null==i?void 0:i[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[l]){const t=(null===(u=null===(s=null===(v=null==i?void 0:i[o])||void 0===v?void 0:v.products)||void 0===s?void 0:s[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(t).length)for(const n in t){const t=null===(r=null===(c=null==i?void 0:i[o])||void 0===c?void 0:c.products)||void 0===r?void 0:r[l],d=null===(p=null===(f=null===(e=null===(a=null==i?void 0:i[o])||void 0===a?void 0:a.products)||void 0===e?void 0:e[l])||void 0===f?void 0:f.variants)||void 0===p?void 0:p[n];if(null===(b=null==d?void 0:d.name)||void 0===b?void 0:b.includes(null!==(O=null==t?void 0:t.name)&&void 0!==O?O:""))return!1}if(null===(y=Object.keys((null===(j=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===j?void 0:j.variants)||[]))||void 0===y||y.forEach((()=>D++)),Object.keys((null===(g=null===(k=null===(E=null==i?void 0:i[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===g?void 0:g.variants)||[]).forEach((()=>P++)),P>0&&D!==P)return!0}return!1},r=(o,l,i)=>{var n;let t=0,d=0;if(i[o]){const v=null==l?void 0:l.products;v&&Object.keys(v).forEach((o=>{var l;const i=null===(l=v[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>t+=1))}));const s=null===(n=i[o])||void 0===n?void 0:n.products;return s&&Object.keys(s).forEach((o=>{var l;const i=null===(l=s[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>d+=1))})),!(t<=0&&d>0)&&(d>0&&t!==d)}return!1};export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,i as paginateSelectedItems,u as shouldShowVariant};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.461-4",
3
+ "version": "0.0.462",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +0,0 @@
1
- import { SelectedItems } from '../modal';
2
- export declare class AllProductHelper {
3
- static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.AllProductHelper=class{static removeDuplicatesForAllProducts(s){var e,t;const c=Object.assign({},s);if(!(null==c?void 0:c[-1])||!(null==c?void 0:c[-1].products))return c;let o=[];const r=Object.keys(null!==(t=null===(e=c[-1])||void 0===e?void 0:e.products)&&void 0!==t?t:{});for(const s in c)if("-1"!==s){const e=c[s].products;Object.keys(null!=e?e:{}).forEach((s=>{r.includes(s)&&o.push(s)}))}o=Array.from(new Set(o));const n=Object.assign({},c[-1]),l=Object.assign({},n.products);return o.forEach((s=>delete l[s])),Object.assign(Object.assign({},c),{"-1":Object.assign(Object.assign({},n),{products:Object.assign({},l)})})}};
@@ -1,4 +0,0 @@
1
- import { SelectedItems } from '../modal';
2
- export declare class AllProductHelper {
3
- static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
- }
@@ -1 +0,0 @@
1
- class s{static removeDuplicatesForAllProducts(s){var t,c;const e=Object.assign({},s);if(!(null==e?void 0:e[-1])||!(null==e?void 0:e[-1].products))return e;let n=[];const o=Object.keys(null!==(c=null===(t=e[-1])||void 0===t?void 0:t.products)&&void 0!==c?c:{});for(const s in e)if("-1"!==s){const t=e[s].products;Object.keys(null!=t?t:{}).forEach((s=>{o.includes(s)&&n.push(s)}))}n=Array.from(new Set(n));const r=Object.assign({},e[-1]),i=Object.assign({},r.products);return n.forEach((s=>delete i[s])),Object.assign(Object.assign({},e),{"-1":Object.assign(Object.assign({},r),{products:Object.assign({},i)})})}}export{s as AllProductHelper};