@bikdotai/bik-component-library 0.0.439-beta.2 → 0.0.439-beta.ppi-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cjs/components/add-variableV2/AddVariableV2.js +1 -1
  2. package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +8 -0
  3. package/dist/cjs/components/product-picker-v2/ProductPickerTag.js +1 -0
  4. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +1 -0
  5. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  6. package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.d.ts +2 -0
  7. package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.js +1 -1
  8. package/dist/cjs/components/product-picker-v2/modal.d.ts +12 -2
  9. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  10. package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +11 -0
  11. package/dist/cjs/components/product-picker-v2/productInfoOverlay.js +39 -0
  12. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +10 -3
  13. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  14. package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  15. package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
  16. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  17. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +4 -1
  18. package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
  19. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +5 -1
  20. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  21. package/dist/cjs/components/product-picker-v2/style.js +12 -7
  22. package/dist/cjs/components/product-picker-v2/useFetchFbStatus.d.ts +5 -0
  23. package/dist/cjs/components/product-picker-v2/useFetchFbStatus.js +1 -0
  24. package/dist/cjs/components/product-picker-v2/utility.d.ts +10 -0
  25. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  26. package/dist/cjs/components/product-picker-v2/variant.js +1 -1
  27. package/dist/esm/components/add-variableV2/AddVariableV2.js +1 -1
  28. package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +8 -0
  29. package/dist/esm/components/product-picker-v2/ProductPickerTag.js +1 -0
  30. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +1 -0
  31. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  32. package/dist/esm/components/product-picker-v2/helpers/ProductHelper.d.ts +2 -0
  33. package/dist/esm/components/product-picker-v2/helpers/ProductHelper.js +1 -1
  34. package/dist/esm/components/product-picker-v2/modal.d.ts +12 -2
  35. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  36. package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +11 -0
  37. package/dist/esm/components/product-picker-v2/productInfoOverlay.js +39 -0
  38. package/dist/esm/components/product-picker-v2/productScreen.d.ts +10 -3
  39. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  40. package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  41. package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
  42. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  43. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +4 -1
  44. package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
  45. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +5 -1
  46. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  47. package/dist/esm/components/product-picker-v2/style.js +14 -9
  48. package/dist/esm/components/product-picker-v2/useFetchFbStatus.d.ts +5 -0
  49. package/dist/esm/components/product-picker-v2/useFetchFbStatus.js +1 -0
  50. package/dist/esm/components/product-picker-v2/utility.d.ts +10 -0
  51. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  52. package/dist/esm/components/product-picker-v2/variant.js +1 -1
  53. package/package.json +1 -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=>M(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=>M(e))).filter((e=>null!==e));else{const e=S[w];s=m.data.filter((e=>e.displayName===w)).map((a=>M(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 M(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&&M(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 $=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($,{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("."),s=a[0]+`['${a[1]}']`;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($,{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($,{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;
@@ -0,0 +1,8 @@
1
+ import { Product, ProductVariant } from './modal';
2
+ import { OUT_OF_STOCK_ACTION } from './type';
3
+ export type ProductPickerTagType = {
4
+ isVariant: boolean;
5
+ data: Product | ProductVariant;
6
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
7
+ };
8
+ export declare const ProductPickerTag: (props: ProductPickerTagType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../tag/Tag.js"),i=require("./helpers/ProductHelper.js");exports.ProductPickerTag=s=>{var l,a;const{isVariant:n,data:o,outOfStockAction:u}=s;let d=o,c=n;1===Object.keys(null!==(l=null==o?void 0:o.variants)&&void 0!==l?l:{}).length&&(d=Object.values(null!==(a=null==o?void 0:o.variants)&&void 0!==a?a:{})[0],c=!0);const p=i.ProductHelper.getProductLabels(d,u),g=i.ProductHelper.getTagType(null!=p?p:"");return e.jsx("div",Object.assign({style:{display:"flex"}},{children:!(null==d?void 0:d.fbStatus)&&c?e.jsx(t.BikShimmer,{boxes:[{height:"24px",width:"100px",marginTop:"0px"}]}):p?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(r.Tag,{tagText:p,type:g,theme:"light"})})):e.jsx(e.Fragment,{})}))};
@@ -13,6 +13,7 @@ interface CollectionsScreenInterface {
13
13
  storeId: string;
14
14
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
15
15
  setCollectionId: React.Dispatch<React.SetStateAction<string>>;
16
+ setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
16
17
  setScreen: React.Dispatch<React.SetStateAction<string>>;
17
18
  collectionsDispatch: React.Dispatch<CollectionsActions>;
18
19
  setSaveDisabled: React.Dispatch<boolean>;
@@ -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"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:c,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:y,isDisabled:g,hideCollectionCheckbox:v,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:g,onClick:e=>{if(!g){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:c}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!v&&e.jsx(s.CheckBox,{isDisabled:g,isChecked:y,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:c}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(l.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:g,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:o,collections:l,selectedCollectionsDispatch:r,setCollectionId:n,selectedCollections:d,setScreen:u,collectionFetcher:p,collectionsDispatch:C,pagingControls:j,storeId:x,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:v,pickerType:m}=t,b=i.useRef(null),k=i.useRef(j.curPage),f=!!s&&(null==d?void 0:d.isCustom),[O,S]=i.useState(!1);i.useEffect((()=>{k.current=j.curPage}),[j.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&k.current>0&&(y(!0),S(!0),p(k.current,x).then((e=>{C({type:"paged",data:(null==e?void 0:e.collections)||{}}),j.setCurPage(k.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const E=e=>{var t,i;let s=0,o=0;if(d[e]){const c=null===(t=l[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const r=null===(i=d[e])||void 0===i?void 0:i.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[Object.keys(l).length?Object.keys(l).map((t=>e.jsx(h,{customCollectionRestriction:s,data:l[t],isDisabled:f&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:E(t),selectedCollectionsDispatch:r,setCollectionId:n,setScreen:u,id:t,hideCollectionCheckbox:g,selectedCollections:d,renderWithoutModal:v,pickerType:m},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:b}),O&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
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"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),d=require("./emptyState.js"),a=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:c,data:d,selectedCollectionsDispatch:h,setCollectionId:p,setSelectedCollectionId:C,isPartiallyChecked:j,setScreen:x,id:y,isChecked:g,isDisabled:v,hideCollectionCheckbox:b,pickerType:m,selectedCollections:k}=i;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:v,onClick:e=>{if(!v){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:y,val:d,isRestricted:c}}),void p(y);p(y),x("products")}},isActive:!!k[y]},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!b&&e.jsx(s.CheckBox,{isDisabled:v,isChecked:g,isPartiallyChecked:j,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:y,val:d,isRestricted:c}}:{type:"unselected",data:{id:y}}),C(e?y:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400},{children:e.jsxs(a.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:u(d.name,40,!0)}),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(l.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:v,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:o,collections:l,selectedCollectionsDispatch:r,setCollectionId:n,setSelectedCollectionId:a,selectedCollections:u,setScreen:p,collectionFetcher:C,collectionsDispatch:j,pagingControls:x,storeId:y,setSaveDisabled:g,hideCollectionCheckbox:v,renderWithoutModal:b,pickerType:m}=t,k=i.useRef(null),f=i.useRef(x.curPage),S=!!s&&(null==u?void 0:u.isCustom),[O,I]=i.useState(!1),E=i.useRef(!1);i.useEffect((()=>{f.current=x.curPage}),[x.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&!E.current&&(g(!0),I(!0),C(f.current,y).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(f.current+1),I(!1),g(!1),Object.keys(e).length||(E.current=!0)})).catch())}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const T=e=>{var t,i;let s=0,o=0;if(u[e]){const c=null===(t=l[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const r=null===(i=u[e])||void 0===i?void 0:i.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[Object.keys(l).length?Object.keys(l).map((t=>e.jsx(h,{customCollectionRestriction:s,data:l[t],isDisabled:S&&!(null==u?void 0:u[t]),isChecked:!!(null==u?void 0:u[t]),isPartiallyChecked:T(t),selectedCollectionsDispatch:r,setCollectionId:n,setSelectedCollectionId:a,setScreen:p,id:t,hideCollectionCheckbox:v||"-1"===t,selectedCollections:u,renderWithoutModal:b,pickerType:m},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(d.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:k}),O&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
@@ -1,3 +1,4 @@
1
+ import { TagType } from "../../tag/model";
1
2
  import { Product, ProductVariant, SelectedItems } from '../modal';
2
3
  import { OUT_OF_STOCK_ACTION } from '../type';
3
4
  import { ProductVariantForRearrange } from '../variant';
@@ -31,6 +32,7 @@ export declare class ProductHelper {
31
32
  * @param outOfStockAction
32
33
  */
33
34
  static getProductLabels(productVariant: Product | ProductVariant, outOfStockAction?: OUT_OF_STOCK_ACTION): string | null;
35
+ static getTagType: (tagText: string) => TagType;
34
36
  }
35
37
  /**
36
38
  * Loops through each collection, each product, each variant.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"};exports.ProductHelper=class{static getProductLabels(l){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.OUT_OF_STOCK_ACTION.NORMAL,u="NORMAL";if(l.variants)return n[u];const d=l;return i===t.OUT_OF_STOCK_ACTION.HIDE&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.BLUR&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="OUT_OF_STOCK"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.NORMAL&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NORMAL"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),n[u]}},exports.parseSelectedVariantsToArray=t=>{let n=[];Object.keys(t).forEach((l=>{var i;return Object.keys((null===(i=null==t?void 0:t[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,d;const a=null!==(u=t[l].products)&&void 0!==u?u:[],o=null!==(d=a[i].variants)&&void 0!==d?d:[];return Object.keys(o).map((t=>{const n=o[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(o)],n}))}));const l=n.sort(((t,n)=>null==t.displayOrder&&null==n.displayOrder?0:null==t.displayOrder?1:null==n.displayOrder?-1:t.displayOrder-n.displayOrder));return l.forEach(((t,n)=>{t.displayOrder=n})),l};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock",FB_REJECTED:"Rejected on FB catalog"};class l{static getProductLabels(l){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.OUT_OF_STOCK_ACTION.NORMAL,u="NORMAL";if(l.variants)return n[u];const e=l;return"REJECTED"===(null==e?void 0:e.fbStatus)?n.FB_REJECTED:(i===t.OUT_OF_STOCK_ACTION.HIDE&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.BLUR&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="OUT_OF_STOCK"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.NORMAL&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NORMAL"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),n[u])}}Object.defineProperty(l,"getTagType",{enumerable:!0,configurable:!0,writable:!0,value:t=>n.FB_REJECTED===t?"negative":"warning"});exports.ProductHelper=l,exports.parseSelectedVariantsToArray=t=>{let n=[];Object.keys(t).forEach((l=>{var i;return Object.keys((null===(i=null==t?void 0:t[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,e;const a=null!==(u=t[l].products)&&void 0!==u?u:[],d=null!==(e=a[i].variants)&&void 0!==e?e:[];return Object.keys(d).map((t=>{const n=d[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(d)],n}))}));const l=n.sort(((t,n)=>null==t.displayOrder&&null==n.displayOrder?0:null==t.displayOrder?1:null==n.displayOrder?-1:t.displayOrder-n.displayOrder));return l.forEach(((t,n)=>{t.displayOrder=n})),l};
@@ -7,10 +7,13 @@ export interface ProductVariant {
7
7
  quantity: number;
8
8
  skipSync?: boolean;
9
9
  displayOrder?: number | null;
10
+ fbStatus?: FbProductStatus;
11
+ description?: string;
10
12
  }
11
13
  export interface Product {
12
14
  name: string;
13
15
  image: string;
16
+ description?: string;
14
17
  variants?: {
15
18
  [key: string]: ProductVariant;
16
19
  };
@@ -38,6 +41,10 @@ export type CollectionFetcherReturn = Promise<{
38
41
  export type ProductFetcherReturn = Promise<{
39
42
  [key: string]: Product;
40
43
  }>;
44
+ export type FbStatusFetcherReturn = Promise<{
45
+ [key: string]: FbProductStatus;
46
+ }>;
47
+ export type FbProductStatus = 'APPROVED' | 'REJECTED';
41
48
  export declare enum ScreenName {
42
49
  Collections = "collections",
43
50
  RearrangeProducts = "rearrange",
@@ -49,10 +56,11 @@ export type ProductPickerInterface = {
49
56
  hideGlobalSearch?: boolean;
50
57
  hideInCollectionSearch?: boolean;
51
58
  customCollectionRestriction?: boolean;
52
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
59
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
53
60
  searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
54
61
  collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
55
- productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
62
+ productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
63
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
56
64
  storeId: string;
57
65
  selectedItems: SelectedItems;
58
66
  onAdd: (items: SelectedItems, total: number) => void;
@@ -60,6 +68,7 @@ export type ProductPickerInterface = {
60
68
  visible: boolean;
61
69
  zIndex?: number;
62
70
  limit?: number;
71
+ minlimit?: number;
63
72
  hideCollectionCheckbox?: boolean;
64
73
  hideProductCheckbox?: boolean;
65
74
  outOfStockAction?: OUT_OF_STOCK_ACTION;
@@ -74,6 +83,7 @@ export type ProductPickerInterface = {
74
83
  pickerType?: 'COLLECTION' | 'PRODUCT';
75
84
  hideProductVariants?: boolean;
76
85
  rearrangeEnabled?: boolean;
86
+ showProductDetailInfoIcon?: boolean;
77
87
  } & ({
78
88
  startupScreen: ScreenName.RearrangeProducts;
79
89
  rearrangeEnabled: true;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),C=require("./selectedScreen.js"),x=require("./style.js"),g=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:j,selectedItems:m,onClose:y,visible:b,zIndex:v,limit:P,hideCollectionCheckbox:f,hideProductCheckbox:k,outOfStockAction:O=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:F,title:I,width:q,renderWithoutModal:E,onClickSave:D,pickerType:N,hideProductVariants:w=!1,startupScreen:A=exports.ScreenName.Collections,rearrangeEnabled:B}=e,[M,V]=o.useReducer(p.collectionsReducer,{}),[L,_]=o.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(A)?A:exports.ScreenName.Collections),[z,G]=o.useState("grid"),[H,W]=o.useState(""),[$,K]=o.useState(0),[U,Y]=o.useState(!1),[J,Q]=o.useState(0),[X,Z]=o.useState(""),[ee,te]=o.useState(!1),[re,oe]=o.useState(!1),[ce,se]=o.useState(),[ne,ie]=o.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{}),le=o.useRef(null);o.useEffect((()=>{Y(!0),oe(!0),e.collectionFetcher($,j).then((e=>{V({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Y(!1),K((e=>e+1)),oe(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;Object.keys(ne||[]).forEach((t=>{var r;Object.keys((null===(r=ne[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var o,c;Object.keys((null===(c=null===(o=ne[t].products)||void 0===o?void 0:o[r])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Q(e)})),o.useEffect((()=>{var t;H&&!(null===(t=null==M?void 0:M[H])||void 0===t?void 0:t.products)&&(Y(!0),e.productFetcher(H,j).then((e=>{Object.keys(e).length&&V({type:"productsFetched",data:{collectionId:H,products:e}}),Y(!1)})).catch())}),[H]),o.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==L&&(X.length?(te(!0),e.searchFetcher(j,X).then((e=>{se(Object.assign({},e)),_("searchProducts"),Y(!1),te(!1)}))):_("collections"))}),800);return()=>clearTimeout(t)}),[X]),o.useEffect((()=>{D&&(e.onAdd(ne,J),ae())}),[D]);const ae=()=>{ie({type:"reset",data:{}})},de=t.jsxs(x.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===L||"searchProducts"===L)&&t.jsx("div",Object.assign({style:{padding:E?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ee?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(r.default,{})},id:"listInput",height:"24px",type:"text",value:X,onChangeText:e=>{e.length&&e.trim().length?Z(e):Z("")}})}))}),t.jsxs(x.ScrollContainerStyle,Object.assign({ref:le},{children:["collections"===L&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:re,collections:M,selectedCollectionsDispatch:ie,setCollectionId:W,setScreen:_,selectedCollections:ne,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:V,setSaveDisabled:Y,pagingControls:{curPage:$,setCurPage:K},hideCollectionCheckbox:f,renderWithoutModal:E,pickerType:N}),"products"===L&&H&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:H},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:_,storeId:j,data:M[H],collectionsDispatch:V,selectedCollectionsDispatch:ie,selectedData:ne,setSaveDisabled:Y,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:k,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:E,pickerType:N,hideProductVariants:w})})),"view"===L&&t.jsx(C.SelectedScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:ie,setScreen:_,collections:M}),"rearrange"===L&&t.jsx(h.RearrangeScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:ie,setScreen:_,outOfStockAction:O,rearrangeViewType:"grid"===z?"list":"grid",scrollContainerRef:le}),"searchProducts"===L&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:ne||{},searchedCollections:ce||{},selectedCollectionsDispatch:ie,setScreen:_,collections:M,onBackPress:()=>{Z(""),se({})},pickerType:N,hideProductCheckbox:k,hideProductVariants:w,hideVariantCheckbox:R})]}))]});return t.jsx(t.Fragment,{children:E?de:t.jsx(i.StyledModal,Object.assign({zIndex:v,open:b,onClose:()=>{null==y||y(),ae()},headingTitle:I||("collections"===L||"products"===L?"Select Products":"view"===L?"Selected Products":"searchProducts"===L?"Searched Products":"rearrange"===L?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:q||"480px"},headerRightCustomElement:"rearrange"===L?(console.log("ignore:",G),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:U?"Loading...":L===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:U||J<1||P&&J>P||!1,onClick:()=>{e.onAdd(ne,J),ae()}},footerLeftCustomElement:F?t.jsx(t.Fragment,{}):P&&J>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):J>0?t.jsx(s.Button,{onClick:()=>{_(B?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:`${J} products selected`,buttonType:["rearrange","view"].includes(L)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(L)}):t.jsx(s.Button,{disabled:!0,buttonText:`${J} products selected`,buttonType:"tertiaryGray"})},{children:de}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),S=require("./rearrangeScreen.js"),p=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js"),b=require("./useFetchFbStatus.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:m,selectedItems:f,onClose:y,visible:P,zIndex:F,minlimit:v,limit:I,hideCollectionCheckbox:k,hideProductCheckbox:O,outOfStockAction:T=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:q,hideSelectionCount:E,title:D,width:w,renderWithoutModal:N,onClickSave:A,pickerType:B,hideProductVariants:M=!1,startupScreen:V=exports.ScreenName.Collections,rearrangeEnabled:L,showProductDetailInfoIcon:_}=e,[$,z]=o.useReducer(p.collectionsReducer,{}),[G,H]=o.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(V)?V:exports.ScreenName.Collections),[W,K]=o.useState("grid"),[U,Y]=o.useState(""),[J,Q]=o.useState(""),[X,Z]=o.useState(0),[ee,te]=o.useState(!1),[re,oe]=o.useState(0),[ce,se]=o.useState(""),[ne,ie]=o.useState(!1),[le,ae]=o.useState(!1),[de,ue]=o.useState(),[he,Se]=o.useReducer(p.selectedColectionsReducer,Object.keys(f).length>0?f:{}),pe=o.useRef(null),[Ce,xe]=o.useState(!1),[ge,je]=o.useState(),{fetchFbStatus:be}=b.useFetchFbStatusForCollections(he,m,Se,e.fbStatusFetcher,!1);o.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,m).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var r;Object.keys((null===(r=he[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var o,c;Object.keys((null===(c=null===(o=he[t].products)||void 0===o?void 0:o[r])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),oe(e)})),o.useEffect((()=>{}),[U]),o.useEffect((()=>{J&&(te(!0),e.productFetcher(J,m).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),o.useEffect((()=>{be()}),[he]),o.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==G&&(ce.length?(ie(!0),e.searchFetcher(m,ce).then((e=>{ue(Object.assign({},e)),H("searchProducts"),te(!1),ie(!1)}))):H("collections"))}),800);return()=>clearTimeout(t)}),[ce]),o.useEffect((()=>{A&&(e.onAdd(he,re),me())}),[A]);const me=()=>{Se({type:"reset",data:{}})},fe=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"===G||"searchProducts"===G)&&t.jsx("div",Object.assign({style:{padding:N?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(r.default,{})},id:"listInput",height:"24px",type:"text",value:ce,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:pe},{children:["collections"===G&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:le,collections:$,selectedCollectionsDispatch:Se,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:H,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:m,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:k,renderWithoutModal:N,pickerType:B}),"products"===G&&U&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:H,storeId:m,data:$[U],collectionsDispatch:z,selectedCollectionsDispatch:Se,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:T,hideVariantCheckbox:R,selectProductsFromCustomCollection:q,renderWithoutModal:N,pickerType:B,hideProductVariants:M,fbStatusFetcher:e.fbStatusFetcher,onInfoIconClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:_})})),"view"===G&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:Se,setScreen:H,collections:$,outOfStockAction:T,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===G&&t.jsx(S.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:Se,setScreen:H,outOfStockAction:T,rearrangeViewType:"grid"===W?"list":"grid",scrollContainerRef:pe,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===G&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},setSearchedCollections:ue,selectedCollectionsDispatch:Se,setScreen:H,collections:$,onBackPress:()=>{se(""),ue({})},pickerType:B,hideProductCheckbox:O,hideProductVariants:M,hideVariantCheckbox:R,storeId:m,fbStatusFetcher:e.fbStatusFetcher})]}))]});return t.jsx(t.Fragment,{children:N?fe:t.jsxs(i.StyledModal,Object.assign({zIndex:F,open:P,onClose:()=>{null==y||y(),me()},headingTitle:D||("collections"===G||"products"===G?"Select Products":"view"===G?"Selected Products":"searchProducts"===G?"Searched Products":"rearrange"===G?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:w||"600px"},headerRightCustomElement:"rearrange"===G?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:ee?"Loading...":G===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||re<1||v&&re<v||I&&re>I||!1,onClick:()=>{e.onAdd(he,re),me()}},footerLeftCustomElement:E?t.jsx(t.Fragment,{}):v&&re<v?t.jsx(a.Tag,{tagText:`Minimum limit is ${v} products`,type:"negative"}):I&&re>I?t.jsx(a.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):re>0?t.jsx(s.Button,{onClick:()=>{H(L?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:`${re} products selected`,buttonType:["rearrange","view"].includes(G)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(G)}):t.jsx(s.Button,{disabled:!0,buttonText:`${re} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[fe,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:T,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -0,0 +1,11 @@
1
+ import { Product, ProductVariant } from './modal';
2
+ import { OUT_OF_STOCK_ACTION } from './type';
3
+ export declare const ProductInfoOverlay: (props: {
4
+ productData: Product | ProductVariant;
5
+ onClose: () => void;
6
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const ProductInfoCard: (props: {
9
+ productData: Product | ProductVariant;
10
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
11
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("styled-components"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),i=require("../icon-button/IconButton.js"),a=require("../shimmer-image/ShimmerImage.js"),s=require("../TypographyStyle.js"),d=require("./ProductPickerTag.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);const c=t=>{var o;console.log("vj: product data",t);const r=void 0===t.productData.variants;return e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(a.ShimmerImage,{imageUrl:t.productData.image,width:"200px",height:200,borderRadius:4})}),e.jsxs(h,{children:[e.jsx(s.TitleSmall,Object.assign({style:{display:"flex"}},{children:t.productData.name})),e.jsx(s.BodyCaption,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(o=t.productData.description)&&void 0!==o?o:""}}),e.jsx(d.ProductPickerTag,{isVariant:r,data:t.productData,outOfStockAction:t.outOfStockAction})]})]})},u=l.default.div`
2
+ display: flex;
3
+ flex: 1;
4
+ background: rgba(0, 0, 0, 0.5);
5
+ flex-direction: column;
6
+ width: 100%;
7
+ height: 100%;
8
+ position: absolute;
9
+ bottom: 0;
10
+ z-index: 10;
11
+ `,p=l.default.div`
12
+ display: flex;
13
+ flex: 1;
14
+ background: rgba(0, 0, 0, 0.5);
15
+ `,x=l.default.div`
16
+ position: relative;
17
+
18
+ .close-button {
19
+ position: absolute;
20
+ top: -50px;
21
+ right: 0px;
22
+ margin: 10px;
23
+ background: ${o.COLORS.surface.standard};
24
+ border-radius: 50%;
25
+ }
26
+ `,f=l.default.div`
27
+ display: flex;
28
+ background: white;
29
+ padding: 24px;
30
+ gap: 24px;
31
+ border-radius: 8px 8px 0px 0px;
32
+ `,g=l.default.div`
33
+ display: flex;
34
+ `,h=l.default.div`
35
+ display: flex;
36
+ flex: 1;
37
+ flex-direction: column;
38
+ gap: 10px;
39
+ `;exports.ProductInfoCard=c,exports.ProductInfoOverlay=t=>e.jsxs(u,{children:[e.jsx(p,{}),e.jsx(x,{children:e.jsx(i.IconButton,{className:"close-button",onClick:t.onClose,Icon:r.default,width:20,height:20})}),e.jsx(c,{productData:t.productData,outOfStockAction:t.outOfStockAction})]});
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
2
+ import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  import { OUT_OF_STOCK_ACTION } from './type';
5
5
  interface ProductsScreenInterface {
@@ -9,8 +9,8 @@ interface ProductsScreenInterface {
9
9
  collectionsDispatch: React.Dispatch<CollectionsActions>;
10
10
  selectedData: SelectedItems;
11
11
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
12
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
13
- productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
12
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
13
+ productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
14
14
  storeId: string;
15
15
  setScreen: React.Dispatch<React.SetStateAction<string>>;
16
16
  setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
@@ -21,6 +21,9 @@ interface ProductsScreenInterface {
21
21
  renderWithoutModal?: boolean;
22
22
  pickerType?: 'COLLECTION' | 'PRODUCT';
23
23
  hideProductVariants?: boolean;
24
+ showProductDetailInfoIcon?: boolean;
25
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
26
+ onInfoIconClick: (productData: Product | ProductVariant) => void;
24
27
  }
25
28
  export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
26
29
  interface ProductGroupInterface {
@@ -36,7 +39,9 @@ interface ProductGroupInterface {
36
39
  outOfStockAction?: OUT_OF_STOCK_ACTION;
37
40
  hideVariantCheckbox?: boolean;
38
41
  hideProductVariants?: boolean;
42
+ showProductDetailInfoIcon?: boolean;
39
43
  pickerType?: 'COLLECTION' | 'PRODUCT';
44
+ onInfoIconClick?: (productData: Product | ProductVariant) => void;
40
45
  }
41
46
  export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
42
47
  interface ProductCardInterface {
@@ -54,7 +59,9 @@ interface ProductCardInterface {
54
59
  outOfStockAction?: OUT_OF_STOCK_ACTION;
55
60
  hideVariantCheckbox?: boolean;
56
61
  hideProductVariants?: boolean;
62
+ showProductDetailInfoIcon?: boolean;
57
63
  pickerType?: 'COLLECTION' | 'PRODUCT';
64
+ onInfoIconClick?: (productData: Product | ProductVariant) => void;
58
65
  }
59
66
  export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
60
67
  export {};
@@ -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"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),r=require("react"),d=require("../tag/Tag.js"),s=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),n=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),x=require("./collectionScreen.js"),y=require("./emptyState.js"),g=require("./helpers/ProductHelper.js"),C=require("./reducers.js"),k=require("./style.js"),m=require("./type.js"),b=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:r,selectedCollectionsDispatch:d,viewOnly:s,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,d,s,l,n;if(!(null===(c=null===(t=null==r?void 0:r[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(n=null===(l=null===(s=null===(d=null==r?void 0:r[i])||void 0===d?void 0:d.products)||void 0===s?void 0:s[o])||void 0===l?void 0:l.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(y=null===(x=null==r?void 0:r[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:n,selectedCollectionsDispatch:d,upliftAdditions:l,viewOnly:s,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v},o),p?null:Object.keys(c.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:s,upliftAdditions:l,collectionId:i,isSelected:j(t),selectedCollectionsDispatch:d,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:r,variantId:s,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:m,hideVariantCheckbox:b,hideProductVariants:O,pickerType:I}=t,S=g.ProductHelper.getProductLabels(o,m);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{"PRODUCT"===I&&O&&(e.stopPropagation(),a({type:"reset",data:{}}),p("variantSelected",{productId:c,variantId:s||Object.keys(o.variants)[0],collectionId:r,variant:o}))},isActive:n},{children:[i&&!u&&!b||!i&&!u&&!C?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:y||!1,onValueChange:function(e){i?e?p("variantSelected",{productId:c,variantId:s,collectionId:r,variant:o}):a({type:"variantUnselected",data:{productId:c,variantId:s,collectionId:r}}):e?p("productSelected",{productId:c,collectionId:r,product:o}):a({type:"productUnselected",data:{productId:c,collectionId:r}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.Tooltip,Object.assign({body:o.name,placement:"bottom",delay:400},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(j.TitleRegular,{children:x.truncate(o.name,40,!0)}),S?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(d.Tag,{tagText:S,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=d=>{const h=r.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:S,storeId:f,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:T,customCollectionRestriction:V,hideProductCheckbox:E,outOfStockAction:D=m.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:A=!1,pickerType:B,hideProductVariants:R}=d,[F,U]=r.useState(""),[_,H]=r.useState(!1),[L,K]=r.useState(v);r.useEffect((()=>{const e=setTimeout((()=>{F.length?(H(!0),d.searchInCollectionFetcher(f,h,F).then((e=>{var t;const i=c.cloneDeep(v);i.products={};for(const o of e)(null===(t=null==v?void 0:v.products)||void 0===t?void 0:t[o])&&(i.products[o]=v.products[o]);K(i),q(!1),H(!1)}))):K(v)}),800);return()=>clearTimeout(e)}),[F]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,r,d,s,l;let n=0,a=0;return!!((null===(i=null===(t=null==g?void 0:g[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(r=Object.keys((null===(c=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===r||r.forEach((()=>a++)),Object.keys((null===(l=null===(s=null===(d=null==g?void 0:g[h])||void 0===d?void 0:d.products)||void 0===s?void 0:s[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};r.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),S(h,f).then((e=>{Object.keys(e).length&&(x({type:"productsFetched",data:{collectionId:h,products:e}}),K(Object.assign(Object.assign({},L),{products:e}))),q(!1),H(!1)})).catch()},G=(e,t)=>{const i=b.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},i),{isRestricted:V})})};return e.jsxs("div",{children:[e.jsxs(k.ProductScreenHeader,{children:[e.jsx(n.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:v.name}))]}),!T&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&F.length?e.jsx(p.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:F,onChangeText:e=>{e.length&&e.trim().length?U(e):U("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!F.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==g?void 0:g[h]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(g[e]){const c=null==v?void 0:v.products;c&&Object.keys(c).forEach((e=>{var t;const o=null===(t=c[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const r=null===(t=g[e])||void 0===t?void 0:t.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((()=>o+=1))})),o>0&&i!==o}return!1})(h),onValueChange:function(e){I(e?{type:"selected",data:{id:h,val:v}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==L?void 0:L.products)||[]).length?Object.keys(L.products||[]).map((t=>e.jsx(O,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:W(t),productId:t,data:L.products[t],selectedData:g,selectedCollectionsDispatch:I,viewOnly:!A&&!!N,upliftAdditions:G,hideProductCheckbox:E,hideVariantCheckbox:w,hideProductVariants:R,pickerType:B},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(y.EmptyState,{title:"No products to show",subtitle:F.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
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("../../assets/icons/box.svg.js"),i=require("../../assets/icons/search.svg.js"),n=require("lodash"),s=require("react"),c=require("../../constants/Theme.js"),l=require("../../assets/icons/info.svg.js"),r=require("../checkBox/CheckBox.js"),d=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),v=require("../shimmer-image/ShimmerImage.js"),h=require("../spinner/Spinner.js"),p=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),g=require("./emptyState.js"),b=require("./ProductPickerTag.js"),f=require("./reducers.js"),y=require("./style.js"),O=require("./type.js"),k=require("./utility.js");const x=t=>{const{collectionId:o,productId:i,data:n,selectedData:s,selectedCollectionsDispatch:c,viewOnly:l,upliftAdditions:r,isProductPartiallyChecked:d,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,onInfoIconClick:j,showProductDetailInfoIcon:g}=t,b=e=>{var t,n,c,l,r,d;if(!(null===(n=null===(t=null==s?void 0:s[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[i]))return!1;return!!(null===(d=null===(r=null===(l=null===(c=null==s?void 0:s[o])||void 0===c?void 0:c.products)||void 0===l?void 0:l[i])||void 0===r?void 0:r.variants)||void 0===d?void 0:d[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:n,productId:i,collectionId:o,isSelected:!!(null===(y=null===(f=null==s?void 0:s[o])||void 0===f?void 0:f.products)||void 0===y?void 0:y[i]),isPartiallyChecked:d,selectedCollectionsDispatch:c,upliftAdditions:r,viewOnly:l,hideProductCheckbox:a,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},i),h?null:Object.keys(n.variants||[]).length>1&&Object.keys(n.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:v,data:n.variants[t],variantId:t,productId:i,viewOnly:l,upliftAdditions:r,collectionId:o,isSelected:b(t),selectedCollectionsDispatch:c,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},t)))]});var f,y},I=t=>{const{isVariant:o,data:i,productId:n,collectionId:s,variantId:a,isSelected:u,selectedCollectionsDispatch:h,viewOnly:g,upliftAdditions:f,isPartiallyChecked:O,hideProductCheckbox:k,outOfStockAction:x,hideVariantCheckbox:I,hideProductVariants:C,pickerType:P,onInfoIconClick:m,showProductDetailInfoIcon:S}=t;return e.jsxs(y.ProductCardStyle,Object.assign({isVariant:o,onClick:e=>{"PRODUCT"===P&&C&&(e.stopPropagation(),h({type:"reset",data:{}}),f("variantSelected",{productId:n,variantId:a||Object.keys(i.variants)[0],collectionId:s,variant:i}))},isActive:u},{children:[o&&!g&&!I||!o&&!g&&!k?e.jsx(r.CheckBox,{isChecked:u,isPartiallyChecked:O||!1,onValueChange:function(e){o?e?f("variantSelected",{productId:n,variantId:a,collectionId:s,variant:i}):h({type:"variantUnselected",data:{productId:n,variantId:a,collectionId:s}}):e?f("productSelected",{productId:n,collectionId:s,product:i}):h({type:"productUnselected",data:{productId:n,collectionId:s}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(v.ShimmerImage,{width:40,height:40,imageUrl:i.image,alt:"Item",borderRadius:4})}),e.jsx(p.Tooltip,Object.assign({variant:"light",body:i.name,placement:"bottom",delay:400},{children: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(j.BodyPrimary,Object.assign({numberOfLines:1},{children:i.name})),S&&e.jsx(d.IconButton,{onClick:()=>{null==m||m(i)},Icon:()=>e.jsx(l.default,{width:20,height:20,color:c.COLORS.content.placeholder})})]})),e.jsx(b.ProductPickerTag,{isVariant:o,data:i,outOfStockAction:x})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=x,exports.ProductsScreen=l=>{const{data:v,collectionsDispatch:p,selectedData:b,selectedCollectionsDispatch:I,productFetcher:C,storeId:P,setScreen:m,setSaveDisabled:S,hideInCollectionSearch:E,customCollectionRestriction:D,hideProductCheckbox:T,outOfStockAction:A=O.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:V=!1,selectProductsFromCustomCollection:w=!1,pickerType:q,hideProductVariants:F,fbStatusFetcher:R,onInfoIconClick:B,showProductDetailInfoIcon:L}=l,U=s.useContext(f.CollectionIdContext),_=s.useRef(null),H=s.useRef(0),[J,K]=s.useState(!1),[M,N]=s.useState(""),[W,z]=s.useState(!1),[G,Q]=s.useState(v),X=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),l.searchInCollectionFetcher(P,U,M).then((e=>{const t=n.cloneDeep(v);t.products=e,Q(t);const o=$(null!=e?e:{},!0);ee(o,null!=e?e:{},!0),S(!1),z(!1)}))):Q(v)}),800);return()=>clearTimeout(e)}),[M]),s.useEffect((()=>{var e,t,o,i,n,s,c,l;console.log("vj: collectionId change before",v,v.products,null===(t=Object.keys(null!==(e=v.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length,X),X.current=!1,H.current=Math.floor((null===(i=Object.keys(null!==(o=v.products)&&void 0!==o?o:{}))||void 0===i?void 0:i.length)/10);const r=$(null!==(n=v.products)&&void 0!==n?n:{});ee(r,null!==(s=v.products)&&void 0!==s?s:{}),console.log("vj: collectionId change after",v,v.products,null===(l=Object.keys(null!==(c=v.products)&&void 0!==c?c:{}))||void 0===l?void 0:l.length,X)}),[U]);const Y=!!D&&v.isSmartCollection,Z=e=>{var t,o,i,n,s,c,l,r;let d=0,a=0;return!!((null===(o=null===(t=null==b?void 0:b[U])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e])&&(null===(s=Object.keys((null===(n=null===(i=null==v?void 0:v.products)||void 0===i?void 0:i[e])||void 0===n?void 0:n.variants)||[]))||void 0===s||s.forEach((()=>a++)),Object.keys((null===(r=null===(l=null===(c=null==b?void 0:b[U])||void 0===c?void 0:c.products)||void 0===l?void 0:l[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>d++)),d>0&&a!==d))};s.useEffect((()=>{(null==v?void 0:v.products)||te(10)}),[]);const $=(e,t)=>{const o=[];return console.log("vj: getVariantIdsForFbStatusFetch",e),Object.keys(null!=e?e:{}).forEach((i=>{var n,s;const c=null!==(s=null===(n=null==e?void 0:e[i])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(c).forEach((n=>{var s,c,l,r,d;let a;a=t?null===(c=null===(s=null==e?void 0:e[i])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n]:null===(d=null===(r=null===(l=null==v?void 0:v.products)||void 0===l?void 0:l[i])||void 0===r?void 0:r.variants)||void 0===d?void 0:d[n],console.log("vj: variant fb status",{data:v,variant:a}),(null==a?void 0:a.fbStatus)||o.push(n)}))})),console.log("vj: getVariantIdsForFbStatusFetch returning",o),o},ee=(e,t,o)=>{if(console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:e,fbStatusFetcher:R}),!R){const e=Object.assign({},t);if(Object.keys(t).forEach((o=>{var i,n,s;console.log("vj: response variants",null===(i=null==t?void 0:t[o])||void 0===i?void 0:i.variants),Object.keys(null!==(s=null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.variants)&&void 0!==s?s:{}).forEach((i=>{var n,s;const c=null===(n=null==t?void 0:t[o].variants)||void 0===n?void 0:n[i];c&&(c.fbStatus="APPROVED");const l=null===(s=null==e?void 0:e[o])||void 0===s?void 0:s.variants;l&&l[i]&&(l[i]=c)}))})),console.log("vj: fetchFbStatusAndDispatchProducts updated Products",e),o){const t=Object.assign({},G);t.products=e,Q(t)}else p({type:"productsPaged",data:{collectionId:U,products:e}})}e.length>0&&R&&R(P,e).then((e=>{console.log("vj: response",{response:e,products:t});const i=Object.assign({},t);if(Object.keys(t).forEach((o=>{var n,s,c;console.log("vj: response variants",null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.variants),Object.keys(null!==(c=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.variants)&&void 0!==c?c:{}).forEach((n=>{var s,c;const l=null===(s=null==t?void 0:t[o].variants)||void 0===s?void 0:s[n];console.log("vj: v",{v:l,vId:n,status:e[n],response:e}),l&&"REJECTED"===e[n]?l.fbStatus="REJECTED":l&&"APPROVED"===e[n]&&(l.fbStatus="APPROVED");const r=null===(c=null==i?void 0:i[o])||void 0===c?void 0:c.variants;r&&r[n]&&(r[n]=l)}))})),console.log("vj: updated Products",i),o){const e=Object.assign({},G);e.products=i,Q(e)}else p({type:"productsPaged",data:{collectionId:U,products:i}})})).catch((e=>{const i=Object.assign({},t);if(Object.keys(t).forEach((e=>{var o,n,s;console.log("vj: response variants",null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.variants),Object.keys(null!==(s=null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.variants)&&void 0!==s?s:{}).forEach((o=>{var n,s;const c=null===(n=null==t?void 0:t[e].variants)||void 0===n?void 0:n[o];c&&(c.fbStatus="APPROVED");const l=null===(s=null==i?void 0:i[e])||void 0===s?void 0:s.variants;l&&l[o]&&(l[o]=c)}))})),console.log("vj: fetchFbStatusAndDispatchProducts updated Products",i),o){const e=Object.assign({},G);e.products=i,Q(e)}else p({type:"productsPaged",data:{collectionId:U,products:i}})}))};s.useEffect((()=>{console.log("vj: observertarget",_.current);const e=new IntersectionObserver((e=>{console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",H.current,X),H.current>=0&&!X.current&&(S(!0),K(!0),C(U,P,10,H.current).then((e=>{if(console.log("vj: fetched products",e,X,Object.keys(e).length),Object.keys(e).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const o=$(e);ee(o,e),H.current+=1}K(!1),S(!1)})).catch()))}),{threshold:1});return _.current&&e.observe(_.current),()=>{_.current&&e.unobserve(_.current)}}),[_]);const te=e=>{console.log("vj: getProductsForCollection"),S(!0),z(!0),C(U,P,e,0).then((t=>{if(Object.keys(t).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t})),console.log("vj: next page when products loaded",H.current);const e=$(t);ee(e,t),H.current=1}console.log("vj: product data",{productData:t,limit:e,data:v}),e||I({type:"selected",data:{id:U,val:Object.assign(Object.assign({},v),{products:t})}}),S(!1),z(!1)})).catch()},oe=(e,t)=>{const o=k.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},o),{isRestricted:D})})};return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(d.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:v.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(h.Spinner,{size:"small",color:c.COLORS.content.primary}):e.jsx(i.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&&!T&&"-1"!==U&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(r.CheckBox,{isChecked:!!(null==b?void 0:b[U]),isPartiallyChecked:(e=>{var t;let o=0,i=0;if(b[e]){const n=null==v?void 0:v.products;n&&Object.keys(n).forEach((e=>{var t;const i=null===(t=n[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))}));const s=null===(t=b[e])||void 0===t?void 0:t.products;return s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((()=>i+=1))})),i>0&&o!==i}return!1})(U),onValueChange:function(e){e?te():I({type:"unselected",data:{id:U}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(o.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(x,{outOfStockAction:A,collectionId:U,isProductPartiallyChecked:Z(t),productId:t,data:G.products[t],selectedData:b,selectedCollectionsDispatch:I,viewOnly:!w&&!!Y,upliftAdditions:oe,hideProductCheckbox:T,hideVariantCheckbox:V,hideProductVariants:F,pickerType:q,onInfoIconClick:B,showProductDetailInfoIcon:L},t))):W?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e.jsx(g.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:_})]}),J&&[1,2,3,4,5].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { SelectedItems } from '.';
2
+ import { FbStatusFetcherReturn, SelectedItems } from '.';
3
3
  import { SelectedCollectionsActions } from './reducers';
4
4
  import { OUT_OF_STOCK_ACTION } from './type';
5
5
  interface RearrangeScreenInterface {
@@ -9,6 +9,8 @@ interface RearrangeScreenInterface {
9
9
  rearrangeViewType: 'grid' | 'list';
10
10
  outOfStockAction?: OUT_OF_STOCK_ACTION;
11
11
  scrollContainerRef: React.RefObject<HTMLDivElement>;
12
+ storeId: string;
13
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
12
14
  }
13
15
  /**
14
16
  * Screen will be opened on two conditions -
@@ -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"),s=require("react-beautiful-dnd"),n=require("../../constants/Theme.js"),c=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),i=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./variantComponents.js");exports.RearrangeScreen=u=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:S,rearrangeViewType:h,outOfStockAction:y,scrollContainerRef:x}=u,[f,q]=r.useState(a.parseSelectedVariantsToArray(p));r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),q(a.parseSelectedVariantsToArray(p))}),[p]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=f,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),q(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,width:16,height:16,color:n.COLORS.content.secondary,onClick:()=>{S("collections")}}),e.jsx(o.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(p).length>0?"list"===h?e.jsx(d.VariantsList,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j,outOfStockAction:y}):e.jsx(d.VariantsGrid,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j}):e.jsx(i.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
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"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),n=require("../TypographyStyle.js"),i=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),u=require("./useFetchFbStatus.js"),d=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:S,selectedCollectionsDispatch:j,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C}=p,[b,O]=r.useState(a.parseSelectedVariantsToArray(S)),{fetchFbStatus:g}=u.useFetchFbStatusForCollections(S,q,j,C,!1);r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),g(),O(a.parseSelectedVariantsToArray(S))}),[S]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=b,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),O(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(n.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(S).length>0?"list"===y?e.jsx(d.VariantsList,{selectedVariants:b,setSelectedVariants:O,selectedCollectionsDispatch:j,outOfStockAction:f}):e.jsx(d.VariantsGrid,{selectedVariants:b,setSelectedVariants:O,selectedCollectionsDispatch:j}):e.jsx(i.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
@@ -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;default:return{}}},exports.selectedColectionsReducer=function(e,a){var d,o,c,s,l,r;let n={},u="",i="",p="";switch(a.type){case"selected":return n=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(n={}),n.isCustom=!0),n[a.data.id]=a.data.val,n;case"unselected":return n=t.cloneDeep(e),(null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[a.data.id],n;case"productUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,delete n[i].products[u],Object.keys(n[i].products).length||((null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[i]),n;case"productSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={}),n[i].products[u]=a.data.product,n;case"variantSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={},n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),(null===(s=null===(c=null==n?void 0:n[i])||void 0===c?void 0:c.products)||void 0===s?void 0:s[u])||((null===(l=null==n?void 0:n[i])||void 0===l?void 0:l.products)||(n[i].products={}),n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),n[i].products[u].variants[p]=a.data.variant,n;case"variantUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,delete n[i].products[u].variants[p],Object.keys(n[i].products[u].variants).length||(delete n[i].products[u],Object.keys(n[i].products).length||((null===(r=n[i])||void 0===r?void 0:r.isSmartCollection)&&(n.isCustom=!1),delete n[i])),n;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 o={};switch(e.type){case"fetched":return o=Object.assign({},e.data),o;case"productsFetched":return console.log("vj: productsFetched",{collections:t,action:e}),o=Object.assign({},t),o[e.data.collectionId].products=e.data.products,console.log("vj: collectionsCopy",{collectionsCopy:o}),o;case"paged":return console.log("vj: paged",{collections:t,action:e}),o=Object.assign(Object.assign({},t),e.data),o;case"productsPaged":return console.log("vj: pagedProducts",{collections:t,action:e}),o=Object.assign({},t),e.data.collectionId,o[e.data.collectionId].products=Object.assign(Object.assign({},o[e.data.collectionId].products),e.data.products),o;default:return{}}},exports.selectedColectionsReducer=function(e,o){var a,c,d,l,s,n;let r={},i="",u="",p="";switch(console.log("vj: selected Items",e),o.type){case"selected":return console.log("vj: selectedColectionsReducer selected",o),r=t.cloneDeep(e),o.data.val.isSmartCollection&&(o.data.isRestricted&&(r={}),r.isCustom=!0),r[o.data.id]=o.data.val,r;case"unselected":return r=t.cloneDeep(e),(null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[o.data.id],r;case"productUnselected":return r=t.cloneDeep(e),i=o.data.productId,u=o.data.collectionId,delete r[u].products[i],Object.keys(r[u].products).length||((null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[u]),r;case"productSelected":return r=t.cloneDeep(e),i=o.data.productId,u=o.data.collectionId,(null===(a=o.data.catalogOnlyData)||void 0===a?void 0:a.isSmartCollection)&&(o.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=o.data.catalogOnlyData,r[u].products={}),r[u].products[i]=o.data.product,r;case"variantSelected":return r=t.cloneDeep(e),i=o.data.productId,u=o.data.collectionId,p=o.data.variantId,(null===(c=o.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(o.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=o.data.catalogOnlyData,r[u].products={},r[u].products[i]=o.data.productOnlyData,r[u].products[i].variants={}),(null===(l=null===(d=null==r?void 0:r[u])||void 0===d?void 0:d.products)||void 0===l?void 0:l[i])||((null===(s=null==r?void 0:r[u])||void 0===s?void 0:s.products)||(r[u].products={}),r[u].products[i]=o.data.productOnlyData,r[u].products[i].variants={}),r[u].products[i].variants[p]=o.data.variant,r;case"variantUnselected":return r=t.cloneDeep(e),i=o.data.productId,u=o.data.collectionId,p=o.data.variantId,delete r[u].products[i].variants[p],Object.keys(r[u].products[i].variants).length||(delete r[u].products[i],Object.keys(r[u].products).length||((null===(n=r[u])||void 0===n?void 0:n.isSmartCollection)&&(r.isCustom=!1),delete r[u])),r;case"reset":return{};default:return e}};
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
2
+ import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
3
3
  import { SelectedCollectionsActions } from './reducers';
4
4
  interface SearchScreenInterface {
5
5
  customCollectionRestriction?: boolean;
6
6
  selectedCollections: SelectedItems;
7
7
  searchedCollections: SelectedItems;
8
+ setSearchedCollections: React.Dispatch<React.SetStateAction<SelectedItems | undefined>>;
8
9
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
9
10
  setScreen: React.Dispatch<React.SetStateAction<string>>;
10
11
  collections: {
@@ -15,6 +16,8 @@ interface SearchScreenInterface {
15
16
  pickerType?: 'COLLECTION' | 'PRODUCT';
16
17
  hideProductVariants?: boolean;
17
18
  hideProductCheckbox?: boolean;
19
+ storeId: string;
20
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
18
21
  }
19
22
  export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
20
23
  export {};
@@ -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("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),r=require("./emptyState.js"),c=require("./productScreen.js"),s=require("./style.js"),l=require("./utility.js");exports.SearchScreen=d=>{const{customCollectionRestriction:n,selectedCollections:u,searchedCollections:a,selectedCollectionsDispatch:v,setScreen:h,collections:p,onBackPress:j,hideVariantCheckbox:y,pickerType:k,hideProductVariants:x,hideProductCheckbox:b}=d,C=(e,t)=>{var o,i,r,c,s,l,d,n,a;let v=0,h=0;return!!((null===(i=null===(o=null==u?void 0:u[e])||void 0===o?void 0:o.products)||void 0===i?void 0:i[t])&&(null===(l=Object.keys((null===(s=null===(c=null===(r=null==p?void 0:p[e])||void 0===r?void 0:r.products)||void 0===c?void 0:c[t])||void 0===s?void 0:s.variants)||[]))||void 0===l||l.forEach((()=>h++)),Object.keys((null===(a=null===(n=null===(d=null==u?void 0:u[e])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&h!==v))};return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{h("collections"),j()}}),e.jsx(i.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(a).length?e.jsx(e.Fragment,{children:Object.keys(a).map((t=>{var o;return Object.keys((null===(o=null==a?void 0:a[t])||void 0===o?void 0:o.products)||[]).map((o=>{let i=!1;return(null==a?void 0:a.isCustom)&&(i=!0),e.jsx(c.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const i=l.liftTheStateUp(o,a[e]);v({type:t,data:Object.assign(Object.assign({},i),{isRestricted:n})})})(t,e,o),productId:o,data:a[t].products[o],isProductPartiallyChecked:C(t,o),selectedData:u,selectedCollectionsDispatch:v,viewOnly:i,hideProductCheckbox:b,hideVariantCheckbox:y,hideProductVariants:x,pickerType:k},o)}))}))}):e.jsx(r.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("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),r=require("./emptyState.js"),s=require("./productScreen.js"),c=require("./style.js"),l=require("./useFetchFbStatus.js"),d=require("./utility.js");exports.SearchScreen=n=>{const{customCollectionRestriction:u,selectedCollections:a,searchedCollections:v,selectedCollectionsDispatch:h,setSearchedCollections:p,setScreen:j,collections:y,onBackPress:b,hideVariantCheckbox:k,pickerType:x,hideProductVariants:C,hideProductCheckbox:S,storeId:f,fbStatusFetcher:P}=n;l.useFetchFbStatusForCollections(v,f,h,P,!0,p);const q=(e,t)=>{var o,i,r,s,c,l,d,n,u;let v=0,h=0;return!!((null===(i=null===(o=null==a?void 0:a[e])||void 0===o?void 0:o.products)||void 0===i?void 0:i[t])&&(null===(l=Object.keys((null===(c=null===(s=null===(r=null==y?void 0:y[e])||void 0===r?void 0:r.products)||void 0===s?void 0:s[t])||void 0===c?void 0:c.variants)||[]))||void 0===l||l.forEach((()=>h++)),Object.keys((null===(u=null===(n=null===(d=null==a?void 0:a[e])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>v++)),v>0&&h!==v))};return e.jsxs("div",{children:[e.jsxs(c.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{j("collections"),b()}}),e.jsx(i.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(v).length?e.jsx(e.Fragment,{children:Object.keys(v).map((t=>{var o;return Object.keys((null===(o=null==v?void 0:v[t])||void 0===o?void 0:o.products)||[]).map((o=>{let i=!1;return(null==v?void 0:v.isCustom)&&(i=!0),e.jsx(s.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const i=d.liftTheStateUp(o,v[e]);h({type:t,data:Object.assign(Object.assign({},i),{isRestricted:u})})})(t,e,o),productId:o,data:v[t].products[o],isProductPartiallyChecked:q(t,o),selectedData:a,selectedCollectionsDispatch:h,viewOnly:i,hideProductCheckbox:S,hideVariantCheckbox:k,hideProductVariants:C,pickerType:x},o)}))}))}):e.jsx(r.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
2
+ import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
3
3
  import { SelectedCollectionsActions } from './reducers';
4
+ import { OUT_OF_STOCK_ACTION } from './type';
4
5
  interface SelectedScreenInterface {
5
6
  selectedCollections: SelectedItems;
6
7
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
@@ -8,6 +9,9 @@ interface SelectedScreenInterface {
8
9
  collections: {
9
10
  [key: string]: Collection;
10
11
  };
12
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
13
+ storeId: string;
14
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
11
15
  }
12
16
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
13
17
  export {};
@@ -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"),l=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),r=require("./emptyState.js"),i=require("./productScreen.js"),d=require("./style.js");exports.SelectedScreen=s=>{const{selectedCollections:c,selectedCollectionsDispatch:n,setScreen:u,collections:v}=s,a=(e,t)=>{var l,o,r,i,d,s,n,u,a;let p=0,j=0;return!!((null===(o=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===o?void 0:o[t])&&(null===(s=Object.keys((null===(d=null===(i=null===(r=null==v?void 0:v[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(n=null==c?void 0:c[e])||void 0===n?void 0:n.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(d.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{u("collections")}}),e.jsx(o.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(c).length>0?e.jsx(e.Fragment,{children:Object.keys(c).map((t=>{var l;return Object.keys((null===(l=null==c?void 0:c[t])||void 0===l?void 0:l.products)||[]).map((l=>{let o=!1;return(null==c?void 0:c.isCustom)&&(o=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:l,data:c[t].products[l],isProductPartiallyChecked:a(t,l),selectedData:c,selectedCollectionsDispatch:n,viewOnly:o},l)}))}))}):e.jsx(r.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};
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"),o=require("../icon-button/IconButton.js"),c=require("../TypographyStyle.js"),s=require("./emptyState.js"),n=require("./productScreen.js"),l=require("./style.js"),i=require("./utility.js");exports.SelectedScreen=u=>{const{selectedCollections:d,selectedCollectionsDispatch:a,setScreen:v,collections:p,outOfStockAction:j}=u,[g,f]=r.useState({}),S=r.useRef(0),h=r.useRef(null);r.useEffect((()=>{S.current=0;const e=i.paginateSelectedItems(d,10,S.current);console.log("paginated",{paginatedProducts:e,selectedCollections:d}),f(e),S.current+=1}),[]),r.useEffect((()=>{console.log("paginated curscreen data change",g)}),[g]),r.useEffect((()=>{console.log("vj: observertarget",h.current);const e=new IntersectionObserver((e=>{if(console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",S.current),S.current>0)){const e=i.paginateSelectedItems(d,10,S.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:d});const t=i.mergeProducts(g,e);f(t),S.current+=1}}),{threshold:1});return h.current&&e.observe(h.current),()=>{h.current&&e.unobserve(h.current)}}),[h]);const y=(e,t)=>{var r,o,c,s,n,l,i,u,a;let v=0,j=0;return!!((null===(o=null===(r=null==d?void 0:d[e])||void 0===r?void 0:r.products)||void 0===o?void 0:o[t])&&(null===(l=Object.keys((null===(n=null===(s=null===(c=null==p?void 0:p[e])||void 0===c?void 0:c.products)||void 0===s?void 0:s[t])||void 0===n?void 0:n.variants)||[]))||void 0===l||l.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(i=null==d?void 0:d[e])||void 0===i?void 0:i.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&j!==v))};return e.jsxs("div",{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{v("collections")}}),e.jsx(c.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(g).length>0?e.jsx(e.Fragment,{children:Object.keys(g).map((t=>{var r;return Object.keys((null===(r=null==g?void 0:g[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==g?void 0:g.isCustom)&&(o=!0),e.jsx(n.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:g[t].products[r],isProductPartiallyChecked:y(t,r),selectedData:g,selectedCollectionsDispatch:a,viewOnly:o,outOfStockAction:j},r)}))}))}):e.jsx(s.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:h})]})]})};
@@ -1,13 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);const r=o.default.div`
2
2
  display: flex;
3
3
  background-color: white;
4
- max-height: 600px;
5
- min-height: 600px;
4
+ height: 600px;
6
5
  flex-direction: column;
7
6
  `,l=o.default.div`
8
7
  overflow-y: scroll;
9
8
  overflow-x: hidden;
10
- `,d=o.default.div`
9
+ `,n=o.default.div`
11
10
  height: 64px;
12
11
  background-color: ${e=>e.isDisabled?"#F0F0F0":e.isActive?t.COLORS.background.positive.light:"white"};
13
12
  border-bottom: 1px solid #e0e0e0;
@@ -21,7 +20,7 @@
21
20
  cursor: pointer;
22
21
  background-color: ${t.COLORS.surface.hovered};
23
22
  }
24
- `,n=o.default.div`
23
+ `,d=o.default.div`
25
24
  display: flex;
26
25
  flex-direction: row;
27
26
  justify-content: center;
@@ -41,6 +40,9 @@
41
40
  align-items: center;
42
41
  padding: 8px 16px;
43
42
  margin-top: 16px;
43
+ position: sticky;
44
+ top: 0;
45
+ z-index: 10;
44
46
  `,c=o.default.div`
45
47
  display: flex;
46
48
  flex-direction: row;
@@ -49,7 +51,7 @@
49
51
  border-bottom: 1px solid #e0e0e0;
50
52
  align-items: center;
51
53
  `,x=o.default.div`
52
- height: 64px;
54
+ min-height: 64px;
53
55
  background-color: ${e=>e.isActive?t.COLORS.background.positive.light:"white"};
54
56
  border-bottom: 1px solid #e0e0e0;
55
57
  padding: 12px 16px;
@@ -72,11 +74,14 @@
72
74
  justify-content: flex-start;
73
75
  align-items: center;
74
76
  padding: 8px 16px;
77
+ position: sticky;
78
+ top: 0;
79
+ z-index: 10;
75
80
  `,f=o.default.div`
76
81
  display: flex;
77
82
  flex-direction: column;
78
83
  `,u=o.default.div`
79
- height: 72px;
84
+ min-height: 72px;
80
85
  background: white;
81
86
  padding: 12px 16px;
82
87
  display: flex;
@@ -107,4 +112,4 @@
107
112
  align-items: center;
108
113
  border: 1px solid ${t.COLORS.stroke.primary};
109
114
  border-radius: 4px;
110
- `,exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=n,exports.CollectionCardStyle=d,exports.CollectionNameHolder=f,exports.ContainerStyle=r,exports.ProductCardStyle=x,exports.ProductScreenCollectionCardStyle=c,exports.ProductScreenHeader=p,exports.ScrollContainerStyle=l,exports.SelectedScreenHeader=s,exports.VariantCardGridStyle=g,exports.VariantCardListStyle=u;
115
+ `,exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=d,exports.CollectionCardStyle=n,exports.CollectionNameHolder=f,exports.ContainerStyle=r,exports.ProductCardStyle=x,exports.ProductScreenCollectionCardStyle=c,exports.ProductScreenHeader=p,exports.ScrollContainerStyle=l,exports.SelectedScreenHeader=s,exports.VariantCardGridStyle=g,exports.VariantCardListStyle=u;
@@ -0,0 +1,5 @@
1
+ import { FbStatusFetcherReturn, SelectedItems } from './modal';
2
+ import { SelectedCollectionsActions } from './reducers';
3
+ export declare const useFetchFbStatusForCollections: (data: SelectedItems, storeId: string, selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, autoFetch?: boolean, setSearchedCollections?: React.Dispatch<React.SetStateAction<SelectedItems | undefined>>) => {
4
+ fetchFbStatus: () => void;
5
+ };