@bikdotai/bik-component-library 0.0.732-beta.6 → 0.0.733-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("react"),n=require("../../../zeroState/ZeroState.js"),s=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),r=require("./description/Description.js"),i=require("./menu/FreeFormMenu.js"),l=require("./menu/MenuList.js"),u=require("./menu/SelectAllMenu.js"),c=require("./multiSelect/MultiSelectDropdownBottomBar.js"),a=require("./OpennedDropdown.styled.js"),d=require("./searchbox/SearchBox.js"),p=require("./searchbox/SearchZeroState.js");const h=304,x=290;exports.OpenedDropdown=j=>{let{options:f,isSearchable:S,isMultiSelect:b,maxSelections:g,width:m,allowFreeForm:v,height:O,onClose:w,onSelect:y,onSearch:E,version:D,skipSorting:C,headerRef:R,hideSelectAll:q,primaryButtonText:M,onInfiniteScroll:k,onMultiSelectClear:L,onDropdownItemClick:A,buttonOptions:I,isSearchLoading:F,disableSearchOptions:T,disableSearchedOptionExcept:B,useDefaultCursor:H,containerStyle:Z={},zeroState:_}=j;const{dropdownOptions:z,search:P,searchedString:V,searchedOptions:W,onApplyHandler:$,selectAllHandler:K,onMultiSelectClear:N,onFreeFormSelect:U,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q,getCurrentSelectionCount:X}=o.useDropdown(D,f,y,C,b,E,T,B,g),[Y,ee]=t.useState(null!=m?m:x),[te,ne]=t.useState(null),[se,oe]=t.useState(-1),re=t.useRef(null),ie=t.useRef([]),le=t.useRef(null);s.useOutside(re,(()=>{if(ne(null),b&&"2.0"===D){const e=Q(J.current);null==w||w(e)}else null==w||w(z)}),[R,ie]),t.useEffect((()=>{re.current&&re.current.focus()}),[]);t.useEffect((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const n=e;n.disabled||t.push(n)}})),t})(V&&E?W:z);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),oe((e=>{const n=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("ArrowUp"===e.key)e.preventDefault(),oe((e=>{const n=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("Enter"===e.key&&se>=0){e.preventDefault();const n=t[se];n&&($(Object.assign(Object.assign({},n),{selected:!n.selected})),A&&A(n))}},t=re.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[se,V,W,z,E,$,A]);const ue=null!=O?O:h,ce="number"==typeof ue?S&&b?ue-96:S&&!b||!S&&b?ue-48:ue:ue;t.useEffect((()=>{const e=null!=m?m:x;if(null===te)ee(e);else if("number"==typeof e)ee(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ee(t)}}),[te]);const ae=[],de=(e=>{if(!b||!g&&0!==g)return e;const t=X(e)>=g;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const n=e;return Object.assign(Object.assign({},n),{disabled:n.disabled||!n.selected&&t})}})):e})((V&&E?W:z).map((e=>{var t,n;if(V&&!E){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))&&(ae.push(!V||e.label===V),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(V.toLowerCase()))?(ae.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),pe=!!S&&V&&0===de.length;return e.jsxRuntimeExports.jsxs(a.OpennedDropdownContainer,Object.assign({version:D,ref:re,tabIndex:-1,style:Object.assign(Object.assign({width:Y},Z),{outline:"none"})},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{width:te?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!S&&e.jsxRuntimeExports.jsx(d.SearchBox,{onSearch:P,version:D}),de.length||V?e.jsxRuntimeExports.jsxs(a.MenuListContainer,Object.assign({minHeight:ue,maxHeight:ce,ref:le},{children:[!!b&&!pe&&!q&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:D,options:V&&E?W:z,onSelect:K}),!v&&pe&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:F,height:ce,searchedString:V,containerWidth:m}),v&&(pe||!!ae.length&&ae.every((e=>!1===e)))&&e.jsxRuntimeExports.jsx(i.FreeFormMenu,{version:D,isMultiSelect:b,onSelect:U,searchedString:V}),e.jsxRuntimeExports.jsx(l.MenuList,{onInfiniteScroll:k,onDropdownItemClick:A,version:D,onSelect:$,showDescription:function(e,t){ne(e&&t?{title:e,description:t}:null)},isMultiSelect:b,options:de,useDefaultCursor:H,ref:ie,focusedIndex:se})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:ue,display:"flex"}},{children:e.jsxRuntimeExports.jsx(n.ZeroState,Object.assign({},_,{title:(null==_?void 0:_.title)||"No results found",subTitle:(null==_?void 0:_.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!b&&!(!de.length&&!V)&&"2.0"!==D&&e.jsxRuntimeExports.jsx(c.default,{onClear:()=>{N(),null==L||L()},onApply:G,list:V&&E?W:z,buttonText:M,buttonOptions:I})]})),!!te&&e.jsxRuntimeExports.jsx(r.Description,{title:te.title,description:te.description,version:D})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("react"),n=require("../../../zeroState/ZeroState.js"),s=require("../../../../hooks/useOutside.js"),o=require("../../hooks/useDropdown.js"),r=require("./description/Description.js"),i=require("./menu/FreeFormMenu.js"),l=require("./menu/MenuList.js"),u=require("./menu/SelectAllMenu.js"),c=require("./multiSelect/MultiSelectDropdownBottomBar.js"),a=require("./OpennedDropdown.styled.js"),d=require("./searchbox/SearchBox.js"),p=require("./searchbox/SearchZeroState.js");const h=304,x=290;exports.OpenedDropdown=j=>{let{options:f,isSearchable:S,isMultiSelect:b,maxSelections:m,width:g,allowFreeForm:v,height:O,onClose:w,onSelect:y,onSearch:E,version:D,skipSorting:C,headerRef:R,hideSelectAll:q,primaryButtonText:M,onInfiniteScroll:k,onMultiSelectClear:L,onDropdownItemClick:A,buttonOptions:I,isSearchLoading:F,disableSearchOptions:T,disableSearchedOptionExcept:B,useDefaultCursor:H,containerStyle:Z={},zeroState:_}=j;const{dropdownOptions:z,search:P,searchedString:V,searchedOptions:W,onApplyHandler:$,selectAllHandler:K,onMultiSelectClear:N,onFreeFormSelect:U,onMultiSelectApply:G,latestDropdownOptionsRef:J,getSelectedOptions:Q,getCurrentSelectionCount:X}=o.useDropdown(D,f,y,C,b,E,T,B,m),[Y,ee]=t.useState(null!=g?g:x),[te,ne]=t.useState(null),[se,oe]=t.useState(-1),re=t.useRef(null),ie=t.useRef([]),le=t.useRef(null);s.useOutside(re,(()=>{if(ne(null),b&&"2.0"===D){const e=Q(J.current);null==w||w(e)}else null==w||w(z)}),[R,ie]),t.useEffect((()=>{const e=setTimeout((()=>{re.current&&re.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);t.useEffect((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const n=e;n.disabled||t.push(n)}})),t})(V&&E?W:z);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),oe((e=>{const n=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("ArrowUp"===e.key)e.preventDefault(),oe((e=>{const n=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=le.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${n}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),n}));else if("Enter"===e.key&&se>=0){e.preventDefault();const n=t[se];n&&($(Object.assign(Object.assign({},n),{selected:!n.selected})),A&&A(n))}},t=re.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[se,V,W,z,E,$,A]);const ue=null!=O?O:h,ce="number"==typeof ue?S&&b?ue-96:S&&!b||!S&&b?ue-48:ue:ue;t.useEffect((()=>{const e=null!=g?g:x;if(null===te)ee(e);else if("number"==typeof e)ee(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ee(t)}}),[te]);const ae=[],de=(e=>{if(!b||!m&&0!==m)return e;const t=X(e)>=m;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const n=e;return Object.assign(Object.assign({},n),{disabled:n.disabled||!n.selected&&t})}})):e})((V&&E?W:z).map((e=>{var t,n;if(V&&!E){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))&&(ae.push(!V||e.label===V),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(V.toLowerCase()))||(null===(n=e.searchKey)||void 0===n?void 0:n.toLowerCase().includes(V.toLowerCase()))?(ae.push(!V||e.label===V),e):null}return e})).filter((e=>null!==e))),pe=!!S&&V&&0===de.length;return e.jsxRuntimeExports.jsxs(a.OpennedDropdownContainer,Object.assign({version:D,ref:re,tabIndex:-1,style:Object.assign(Object.assign({width:Y},Z),{outline:"none"})},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{width:te?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!S&&e.jsxRuntimeExports.jsx(d.SearchBox,{onSearch:P,version:D}),de.length||V?e.jsxRuntimeExports.jsxs(a.MenuListContainer,Object.assign({minHeight:ue,maxHeight:ce,ref:le},{children:[!!b&&!pe&&!q&&e.jsxRuntimeExports.jsx(u.SelectAllMenu,{version:D,options:V&&E?W:z,onSelect:K}),!v&&pe&&e.jsxRuntimeExports.jsx(p.SearchZeroState,{isLoading:F,height:ce,searchedString:V,containerWidth:g}),v&&(pe||!!ae.length&&ae.every((e=>!1===e)))&&e.jsxRuntimeExports.jsx(i.FreeFormMenu,{version:D,isMultiSelect:b,onSelect:U,searchedString:V}),e.jsxRuntimeExports.jsx(l.MenuList,{onInfiniteScroll:k,onDropdownItemClick:A,version:D,onSelect:$,showDescription:function(e,t){ne(e&&t?{title:e,description:t}:null)},isMultiSelect:b,options:de,useDefaultCursor:H,ref:ie,focusedIndex:se})]})):e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:ue,display:"flex"}},{children:e.jsxRuntimeExports.jsx(n.ZeroState,Object.assign({},_,{title:(null==_?void 0:_.title)||"No results found",subTitle:(null==_?void 0:_.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!b&&!(!de.length&&!V)&&"2.0"!==D&&e.jsxRuntimeExports.jsx(c.default,{onClear:()=>{N(),null==L||L()},onApply:G,list:V&&E?W:z,buttonText:M,buttonOptions:I})]})),!!te&&e.jsxRuntimeExports.jsx(r.Description,{title:te.title,description:te.description,version:D})]}))};
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ProductPickerProps } from "./type";
3
- export declare const ProductPickerContent: React.FC<ProductPickerProps & {
4
- resetSearchFlag?: number;
5
- }>;
3
+ export declare const ProductPickerContent: React.FC<ProductPickerProps>;
6
4
  export declare const PricePleaseProductPicker: React.FC<ProductPickerProps>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("../../node_modules/lodash.debounce/index.js"),s=require("react"),o=require("../bik-layout/PageLoader.js"),r=require("../checkBox/CheckBox.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),c=require("./ProductPicker.styled.js"),l=require("../TypographyStyle.js"),a=require("../../utils/DateUtils.js"),d=require("../../constants/Theme.js"),u=require("../../assets/icons/alert_triangle.svg.js"),x=require("../../assets/icons/search.svg.js");const p="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg",j=t=>{let{text:s,styleProps:o}=t;return e.jsxRuntimeExports.jsxs(c.StyledZeroState,{children:[e.jsxRuntimeExports.jsx("div",Object.assign({className:"icon__container",style:Object.assign({},o)},{children:e.jsxRuntimeExports.jsx(u.default,{width:24,height:24,color:d.DEFAULT_THEME.colorsV2.content.secondary})})),e.jsxRuntimeExports.jsx(l.TitleSmall,{children:"No results found"}),e.jsxRuntimeExports.jsx(l.BodySecondary,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.secondary,textAlign:"center"}},{children:`Sorry we could not find any results for "${s}"`}))]})},m=i=>{var u,m,h,E;const g=i.instaPost?a.default.dateFormat(new Date(i.instaPost.timestamp),"•",!0):"",[P,y]=s.useState(i.products),[v,_]=s.useState(!1),[b,f]=s.useState("");s.useEffect((()=>{f(""),y(i.products),_(!1)}),[i.show,i.resetSearchFlag]);const R=s.useCallback(t.default((e=>{e?(y([]),i.onSearchKeyChange(e).then((e=>{y(e),_(!1)}))):(y(i.products),_(!1))}),700),[]);return e.jsxRuntimeExports.jsxs(c.StyledProductPickerContainer,{children:[i.instaPost&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"post__wrapper"},{children:[e.jsxRuntimeExports.jsx("img",{alt:"Ig Media",onError:e=>{e.target.onerror=null,e.target.src=p},src:null===(u=i.instaPost)||void 0===u?void 0:u.media_url,className:"post__thumbnail"}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"post__info-wrapper"},{children:[e.jsxRuntimeExports.jsx(l.BodyPrimary,Object.assign({style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:i.instaPost.caption?d.DEFAULT_THEME.colorsV2.content.primary:d.DEFAULT_THEME.colorsV2.content.secondary}},{children:(null===(m=i.instaPost)||void 0===m?void 0:m.caption)?null===(h=i.instaPost)||void 0===h?void 0:h.caption:"No caption"})),e.jsxRuntimeExports.jsx(l.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.placeholder}},{children:g}))]}))]})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{borderTop:i.instaPost?`1px solid ${d.DEFAULT_THEME.colorsV2.stroke.primary}`:"none",borderBottom:`1px solid ${d.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:i.instaPost?"16px 24px":"0px 24px 16px 24px"}},{children:e.jsxRuntimeExports.jsx(n.Input,{value:b,placeholder:null!==(E=i.searchPlaceholder)&&void 0!==E?E:"Search products..",onChangeText:e=>{var t;f(e),(null===(t=e.trim())||void 0===t?void 0:t.length)>0?(_(!0),R(e)):(_(!1),y(i.products))},rightIcon:{icon:x.default}})})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{maxHeight:350,overflowY:"scroll"}},{children:[v&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"loader__wrapper"},{children:e.jsxRuntimeExports.jsx(o.PageLoader,{})})),0!==P.length||v?P.map((t=>{var s;const o=i.selectedProducts.find((e=>e.id===t.id));return e.jsxRuntimeExports.jsxs("div",Object.assign({className:"product__wrapper"},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"product__info-wrapper"},{children:[e.jsxRuntimeExports.jsx("img",{alt:"Product",onError:e=>{e.target.onerror=null,e.target.src=p},src:null!==(s=t.image)&&void 0!==s?s:p,className:"product__image"}),e.jsxRuntimeExports.jsx(l.TitleSmall,{children:t.name})]})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{order:1}},{children:e.jsxRuntimeExports.jsx(r.CheckBox,{isChecked:void 0!==o,onValueChange:e=>{((e,t)=>{const s=i.selectedProducts.find((e=>e.id===t.id));if(e&&!s){const e=[...i.selectedProducts,t];i.setSelectedProducts(e)}else if(s){const e=[...i.selectedProducts];let s=-1;i.selectedProducts.forEach(((e,o)=>{e.id===t.id&&(s=o)})),e.splice(s,1),i.setSelectedProducts(e)}})(e,t)}})}))]}),t.id)})):e.jsxRuntimeExports.jsx(j,{text:b})]}))]})};exports.PricePleaseProductPicker=t=>{var o;const[r,n]=s.useState([]),[c,a]=s.useState(0);s.useEffect((()=>{var e;n(null!==(e=t.selectedProducts)&&void 0!==e?e:[])}),[null===(o=t.selectedProducts)||void 0===o?void 0:o.length]);return e.jsxRuntimeExports.jsx(i.StyledModal,Object.assign({open:t.show,onClose:()=>{t.onClose()},footerLeftCustomElement:r.length>10?e.jsxRuntimeExports.jsx(l.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.negative}},{children:"Can't add more than 10 products"})):e.jsxRuntimeExports.jsx(l.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.placeholder}},{children:r?`${r.length} selected`:""})),headingTitle:t.title,primaryButton:{disabled:r.length>10||0===r.length,buttonType:"primary",buttonText:"Select",size:"small",onClick:()=>{t.setSelectedProducts(r),a((e=>e+1)),t.onClose()}},secondaryButton:t.secondaryButtonProps,footerShadow:!0},{children:e.jsxRuntimeExports.jsx(m,Object.assign({},t,{selectedProducts:r,setSelectedProducts:n,resetSearchFlag:c}))}))},exports.ProductPickerContent=m;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("../../node_modules/lodash.debounce/index.js"),s=require("react"),o=require("../bik-layout/PageLoader.js"),r=require("../checkBox/CheckBox.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("./ProductPicker.styled.js"),c=require("../TypographyStyle.js"),a=require("../../utils/DateUtils.js"),d=require("../../constants/Theme.js"),u=require("../../assets/icons/alert_triangle.svg.js"),x=require("../../assets/icons/search.svg.js");const p="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg",j=t=>{let{text:s,styleProps:o}=t;return e.jsxRuntimeExports.jsxs(l.StyledZeroState,{children:[e.jsxRuntimeExports.jsx("div",Object.assign({className:"icon__container",style:Object.assign({},o)},{children:e.jsxRuntimeExports.jsx(u.default,{width:24,height:24,color:d.DEFAULT_THEME.colorsV2.content.secondary})})),e.jsxRuntimeExports.jsx(c.TitleSmall,{children:"No results found"}),e.jsxRuntimeExports.jsx(c.BodySecondary,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.secondary,textAlign:"center"}},{children:`Sorry we could not find any results for "${s}"`}))]})},m=i=>{var u,m,h,E;const g=i.instaPost?a.default.dateFormat(new Date(i.instaPost.timestamp),"•",!0):"",[P,y]=s.useState(i.products),[v,_]=s.useState(!1),[b,R]=s.useState(""),T=s.useCallback(t.default((e=>{e?(y([]),i.onSearchKeyChange(e).then((e=>{y(e),_(!1)}))):(y(i.products),_(!1))}),700),[]);return e.jsxRuntimeExports.jsxs(l.StyledProductPickerContainer,{children:[i.instaPost&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"post__wrapper"},{children:[e.jsxRuntimeExports.jsx("img",{alt:"Ig Media",onError:e=>{e.target.onerror=null,e.target.src=p},src:null===(u=i.instaPost)||void 0===u?void 0:u.media_url,className:"post__thumbnail"}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"post__info-wrapper"},{children:[e.jsxRuntimeExports.jsx(c.BodyPrimary,Object.assign({style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:i.instaPost.caption?d.DEFAULT_THEME.colorsV2.content.primary:d.DEFAULT_THEME.colorsV2.content.secondary}},{children:(null===(m=i.instaPost)||void 0===m?void 0:m.caption)?null===(h=i.instaPost)||void 0===h?void 0:h.caption:"No caption"})),e.jsxRuntimeExports.jsx(c.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.placeholder}},{children:g}))]}))]})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{borderTop:i.instaPost?`1px solid ${d.DEFAULT_THEME.colorsV2.stroke.primary}`:"none",borderBottom:`1px solid ${d.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:i.instaPost?"16px 24px":"0px 24px 16px 24px"}},{children:e.jsxRuntimeExports.jsx(n.Input,{placeholder:null!==(E=i.searchPlaceholder)&&void 0!==E?E:"Search products..",onChangeText:e=>{var t;R(e),(null===(t=e.trim())||void 0===t?void 0:t.length)>0?(_(!0),T(e)):(_(!1),y(i.products))},rightIcon:{icon:x.default}})})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{maxHeight:350,overflowY:"scroll"}},{children:[v&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"loader__wrapper"},{children:e.jsxRuntimeExports.jsx(o.PageLoader,{})})),0!==P.length||v?P.map((t=>{var s;const o=i.selectedProducts.find((e=>e.id===t.id));return e.jsxRuntimeExports.jsxs("div",Object.assign({className:"product__wrapper"},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"product__info-wrapper"},{children:[e.jsxRuntimeExports.jsx("img",{alt:"Product",onError:e=>{e.target.onerror=null,e.target.src=p},src:null!==(s=t.image)&&void 0!==s?s:p,className:"product__image"}),e.jsxRuntimeExports.jsx(c.TitleSmall,{children:t.name})]})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{order:1}},{children:e.jsxRuntimeExports.jsx(r.CheckBox,{isChecked:void 0!==o,onValueChange:e=>{((e,t)=>{const s=i.selectedProducts.find((e=>e.id===t.id));if(e&&!s){const e=[...i.selectedProducts,t];i.setSelectedProducts(e)}else if(s){const e=[...i.selectedProducts];let s=-1;i.selectedProducts.forEach(((e,o)=>{e.id===t.id&&(s=o)})),e.splice(s,1),i.setSelectedProducts(e)}})(e,t)}})}))]}),t.id)})):e.jsxRuntimeExports.jsx(j,{text:b})]}))]})};exports.PricePleaseProductPicker=t=>{var o;const[r,n]=s.useState([]);return s.useEffect((()=>{var e;n(null!==(e=t.selectedProducts)&&void 0!==e?e:[])}),[null===(o=t.selectedProducts)||void 0===o?void 0:o.length]),e.jsxRuntimeExports.jsx(i.StyledModal,Object.assign({open:t.show,onClose:()=>{t.onClose()},footerLeftCustomElement:r.length>10?e.jsxRuntimeExports.jsx(c.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.negative}},{children:"Can't add more than 10 products"})):e.jsxRuntimeExports.jsx(c.Caption,Object.assign({style:{color:d.DEFAULT_THEME.colorsV2.content.placeholder}},{children:r?`${r.length} selected`:""})),headingTitle:t.title,primaryButton:{disabled:r.length>10||0===r.length,buttonType:"primary",buttonText:"Select",size:"small",onClick:()=>{t.setSelectedProducts(r),t.onClose()}},secondaryButton:t.secondaryButtonProps,footerShadow:!0},{children:e.jsxRuntimeExports.jsx(m,Object.assign({},t,{selectedProducts:r,setSelectedProducts:n}))}))},exports.ProductPickerContent=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),o=require("../../assets/icons/search.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),x=require("./productScreen.js"),h=require("./rearrangeScreen.js"),j=require("./reducers.js"),m=require("./searchScreen.js"),S=require("./selectedScreen.js"),C=require("./style.js"),g=require("./type.js"),y=require("./utility.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:L,width:A,left:B,renderWithoutModal:w,onClickSave:$,pickerType:M,hideProductVariants:V=!1,startupScreen:z=g.ScreenName.Collections,rearrangeEnabled:_,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||t.ApplicationType.BIK,[Z,ee]=s.useReducer(j.collectionsReducer,{}),[te,oe]=s.useState([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections),[se,re]=s.useState("grid"),[ce,ne]=s.useState(""),[ie,le]=s.useState(""),[ae,de]=s.useState(0),[ue,pe]=s.useState(!1),[xe,he]=s.useState(0),[je,me]=s.useState(""),[Se,Ce]=s.useState(!1),[ge,ye]=s.useState(!1),[Re,be]=s.useReducer(j.searchReducer,{collections:{},products:{}}),[fe,Ee]=s.useReducer(j.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=s.useRef(null),[ke,Ie]=s.useState(!1),[Oe,Fe]=s.useState();s.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),s.useEffect((()=>{let e=0;"COLLECTION"===M?e=Object.keys(fe||{}).filter((e=>"isCustom"!==e)).length:V?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,V,M]),s.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),s.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),s.useEffect((()=>{$&&(R.onAdd(fe,xe),Pe())}),[$]),s.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>{let t,o;return"COLLECTION"===M?(t="collection",o="collections"):V?(t="product",o="products"):(t="variant",o="variants"),I&&xe>I?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${I} ${1===I?t:o}`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${O} ${1===O?t:o}`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(n.Button,{onClick:()=>{oe(_?g.ScreenName.RearrangeProducts:g.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} ${1===xe?t:o} selected`:`${xe} ${1===xe?t:o} selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(n.Button,{disabled:!0,buttonText:I?`${xe}/${I} ${1===I?t:o} selected`:`${xe} ${1===xe?t:o} selected`,buttonType:"tertiaryGray"})},De=e=>ue?"Loading...":te===g.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(C.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(C.ScrollContainerStyle,Object.assign({ref:ve,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(u.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:w,pickerType:M,scrollContainerRef:ve,limit:O,exactLimit:I}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(j.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(x.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:w,pickerType:M,hideProductVariants:V,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ve})})),"view"===te&&e.jsxRuntimeExports.jsx(S.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:V,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(h.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ve,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(m.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:P,hideProductVariants:V,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:w,hideCollectionCheckbox:F,outOfStockAction:T,limit:O,exactLimit:I})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:w?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(C.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(n.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==E||E(),Pe()},headingTitle:L||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:B||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(c.default,{width:20,height:20,color:r.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=y.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ke||G},{children:[qe,ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),o=require("../../assets/icons/search.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),x=require("./productScreen.js"),h=require("./rearrangeScreen.js"),j=require("./reducers.js"),m=require("./searchScreen.js"),S=require("./selectedScreen.js"),C=require("./style.js"),g=require("./type.js"),y=require("./utility.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:L,width:A,left:B,renderWithoutModal:w,onClickSave:$,pickerType:M,hideProductVariants:V=!1,startupScreen:z=g.ScreenName.Collections,rearrangeEnabled:_,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||t.ApplicationType.BIK,[Z,ee]=s.useReducer(j.collectionsReducer,{}),[te,oe]=s.useState([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections),[se,re]=s.useState("grid"),[ce,ne]=s.useState(""),[ie,le]=s.useState(""),[ae,de]=s.useState(0),[ue,pe]=s.useState(!1),[xe,he]=s.useState(0),[je,me]=s.useState(""),[Se,Ce]=s.useState(!1),[ge,ye]=s.useState(!1),[Re,be]=s.useReducer(j.searchReducer,{collections:{},products:{}}),[fe,Ee]=s.useReducer(j.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=s.useRef(null),[ke,Ie]=s.useState(!1),[Oe,Fe]=s.useState();s.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),s.useEffect((()=>{let e=0;"COLLECTION"===M?e=Object.keys(fe||{}).filter((e=>"isCustom"!==e)).length:V?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,V,M]),s.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),s.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),s.useEffect((()=>{$&&(R.onAdd(fe,xe),Pe())}),[$]),s.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>{let t,o;return"COLLECTION"===M?(t="collection",o="collections"):V?(t="product",o="products"):(t="variant",o="variants"),I&&xe>I?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${I} ${1===I?t:o}`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${O} ${1===O?t:o}`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(n.Button,{onClick:()=>{oe(_?g.ScreenName.RearrangeProducts:g.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} ${1===xe?t:o} selected`:`${xe} ${1===xe?t:o} selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(n.Button,{disabled:!0,buttonText:I?`${xe}/${I} ${1===I?t:o} selected`:`${xe} ${1===xe?t:o} selected`,buttonType:"tertiaryGray"})},De=e=>ue?"Loading...":te===g.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(C.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(C.ScrollContainerStyle,Object.assign({ref:ve,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(u.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:w,pickerType:M,scrollContainerRef:ve,limit:O,exactLimit:I}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(j.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(x.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:w,pickerType:M,hideProductVariants:V,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ve})})),"view"===te&&e.jsxRuntimeExports.jsx(S.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:V,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(h.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ve,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(m.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:P,hideProductVariants:V,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:w,hideCollectionCheckbox:F,outOfStockAction:T,limit:O,exactLimit:I})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:w?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(C.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(n.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==E||E(),Pe()},headingTitle:L||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:B||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(c.default,{width:20,height:20,color:r.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),me(""),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes(z)?z:g.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe(),me("")}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=y.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ke||G},{children:[qe,ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
@@ -1 +1 @@
1
- import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as r}from"../../../../hooks/useOutside.js";import{useDropdown as i}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as c}from"./menu/FreeFormMenu.js";import{MenuList as a}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as p,MenuListContainer as h}from"./OpennedDropdown.styled.js";import{SearchBox as f}from"./searchbox/SearchBox.js";import{SearchZeroState as m}from"./searchbox/SearchZeroState.js";const b=304,j=290,g=g=>{let{options:S,isSearchable:v,isMultiSelect:x,maxSelections:w,width:O,allowFreeForm:y,height:C,onClose:D,onSelect:k,onSearch:L,version:M,skipSorting:I,headerRef:A,hideSelectAll:E,primaryButtonText:F,onInfiniteScroll:T,onMultiSelectClear:B,onDropdownItemClick:H,buttonOptions:q,isSearchLoading:z,disableSearchOptions:R,disableSearchedOptionExcept:V,useDefaultCursor:W,containerStyle:Z={},zeroState:$}=g;const{dropdownOptions:K,search:N,searchedString:P,searchedOptions:U,onApplyHandler:_,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:X,latestDropdownOptionsRef:Y,getSelectedOptions:ee,getCurrentSelectionCount:te}=i(M,S,k,I,x,L,R,V,w),[oe,ne]=t(null!=O?O:j),[se,re]=t(null),[ie,le]=t(-1),ce=o(null),ae=o([]),ue=o(null);r(ce,(()=>{if(re(null),x&&"2.0"===M){const e=ee(Y.current);null==D||D(e)}else null==D||D(K)}),[A,ae]),n((()=>{ce.current&&ce.current.focus()}),[]);n((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(P&&L?U:K);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),le((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),le((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("Enter"===e.key&&ie>=0){e.preventDefault();const o=t[ie];o&&(_(Object.assign(Object.assign({},o),{selected:!o.selected})),H&&H(o))}},t=ce.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ie,P,U,K,L,_,H]);const de=null!=C?C:b,pe="number"==typeof de?v&&x?de-96:v&&!x||!v&&x?de-48:de:de;n((()=>{const e=null!=O?O:j;if(null===se)ne(e);else if("number"==typeof e)ne(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ne(t)}}),[se]);const he=[],fe=(e=>{if(!x||!w&&0!==w)return e;const t=te(e)>=w;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((P&&L?U:K).map((e=>{var t,o;if(P&&!L){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))&&(he.push(!P||e.label===P),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(P.toLowerCase()))?(he.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e))),me=!!v&&P&&0===fe.length;return e.jsxs(p,Object.assign({version:M,ref:ce,tabIndex:-1,style:Object.assign(Object.assign({width:oe},Z),{outline:"none"})},{children:[e.jsxs("div",Object.assign({style:{width:se?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!v&&e.jsx(f,{onSearch:N,version:M}),fe.length||P?e.jsxs(h,Object.assign({minHeight:de,maxHeight:pe,ref:ue},{children:[!!x&&!me&&!E&&e.jsx(u,{version:M,options:P&&L?U:K,onSelect:G}),!y&&me&&e.jsx(m,{isLoading:z,height:pe,searchedString:P,containerWidth:O}),y&&(me||!!he.length&&he.every((e=>!1===e)))&&e.jsx(c,{version:M,isMultiSelect:x,onSelect:Q,searchedString:P}),e.jsx(a,{onInfiniteScroll:T,onDropdownItemClick:H,version:M,onSelect:_,showDescription:function(e,t){re(e&&t?{title:e,description:t}:null)},isMultiSelect:x,options:fe,useDefaultCursor:W,ref:ae,focusedIndex:ie})]})):e.jsx("div",Object.assign({style:{height:de,display:"flex"}},{children:e.jsx(s,Object.assign({},$,{title:(null==$?void 0:$.title)||"No results found",subTitle:(null==$?void 0:$.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!x&&!(!fe.length&&!P)&&"2.0"!==M&&e.jsx(d,{onClear:()=>{J(),null==B||B()},onApply:X,list:P&&L?U:K,buttonText:F,buttonOptions:q})]})),!!se&&e.jsx(l,{title:se.title,description:se.description,version:M})]}))};export{g as OpenedDropdown};
1
+ import{j as e}from"../../../../node_modules/react/jsx-runtime.js";import{useState as t,useRef as o,useEffect as n}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as r}from"../../../../hooks/useOutside.js";import{useDropdown as i}from"../../hooks/useDropdown.js";import{Description as l}from"./description/Description.js";import{FreeFormMenu as c}from"./menu/FreeFormMenu.js";import{MenuList as a}from"./menu/MenuList.js";import{SelectAllMenu as u}from"./menu/SelectAllMenu.js";import d from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as p,MenuListContainer as h}from"./OpennedDropdown.styled.js";import{SearchBox as f}from"./searchbox/SearchBox.js";import{SearchZeroState as m}from"./searchbox/SearchZeroState.js";const b=304,j=290,g=g=>{let{options:S,isSearchable:v,isMultiSelect:x,maxSelections:w,width:O,allowFreeForm:y,height:C,onClose:D,onSelect:k,onSearch:L,version:M,skipSorting:I,headerRef:A,hideSelectAll:T,primaryButtonText:E,onInfiniteScroll:F,onMultiSelectClear:B,onDropdownItemClick:H,buttonOptions:q,isSearchLoading:z,disableSearchOptions:R,disableSearchedOptionExcept:V,useDefaultCursor:W,containerStyle:Z={},zeroState:$}=g;const{dropdownOptions:K,search:N,searchedString:P,searchedOptions:U,onApplyHandler:_,selectAllHandler:G,onMultiSelectClear:J,onFreeFormSelect:Q,onMultiSelectApply:X,latestDropdownOptionsRef:Y,getSelectedOptions:ee,getCurrentSelectionCount:te}=i(M,S,k,I,x,L,R,V,w),[oe,ne]=t(null!=O?O:j),[se,re]=t(null),[ie,le]=t(-1),ce=o(null),ae=o([]),ue=o(null);r(ce,(()=>{if(re(null),x&&"2.0"===M){const e=ee(Y.current);null==D||D(e)}else null==D||D(K)}),[A,ae]),n((()=>{const e=setTimeout((()=>{ce.current&&ce.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);n((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(P&&L?U:K);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),le((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),le((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ue.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("Enter"===e.key&&ie>=0){e.preventDefault();const o=t[ie];o&&(_(Object.assign(Object.assign({},o),{selected:!o.selected})),H&&H(o))}},t=ce.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ie,P,U,K,L,_,H]);const de=null!=C?C:b,pe="number"==typeof de?v&&x?de-96:v&&!x||!v&&x?de-48:de:de;n((()=>{const e=null!=O?O:j;if(null===se)ne(e);else if("number"==typeof e)ne(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ne(t)}}),[se]);const he=[],fe=(e=>{if(!x||!w&&0!==w)return e;const t=te(e)>=w;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((P&&L?U:K).map((e=>{var t,o;if(P&&!L){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))&&(he.push(!P||e.label===P),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(P.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(P.toLowerCase()))?(he.push(!P||e.label===P),e):null}return e})).filter((e=>null!==e))),me=!!v&&P&&0===fe.length;return e.jsxs(p,Object.assign({version:M,ref:ce,tabIndex:-1,style:Object.assign(Object.assign({width:oe},Z),{outline:"none"})},{children:[e.jsxs("div",Object.assign({style:{width:se?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!v&&e.jsx(f,{onSearch:N,version:M}),fe.length||P?e.jsxs(h,Object.assign({minHeight:de,maxHeight:pe,ref:ue},{children:[!!x&&!me&&!T&&e.jsx(u,{version:M,options:P&&L?U:K,onSelect:G}),!y&&me&&e.jsx(m,{isLoading:z,height:pe,searchedString:P,containerWidth:O}),y&&(me||!!he.length&&he.every((e=>!1===e)))&&e.jsx(c,{version:M,isMultiSelect:x,onSelect:Q,searchedString:P}),e.jsx(a,{onInfiniteScroll:F,onDropdownItemClick:H,version:M,onSelect:_,showDescription:function(e,t){re(e&&t?{title:e,description:t}:null)},isMultiSelect:x,options:fe,useDefaultCursor:W,ref:ae,focusedIndex:ie})]})):e.jsx("div",Object.assign({style:{height:de,display:"flex"}},{children:e.jsx(s,Object.assign({},$,{title:(null==$?void 0:$.title)||"No results found",subTitle:(null==$?void 0:$.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!x&&!(!fe.length&&!P)&&"2.0"!==M&&e.jsx(d,{onClear:()=>{J(),null==B||B()},onApply:X,list:P&&L?U:K,buttonText:E,buttonOptions:q})]})),!!se&&e.jsx(l,{title:se.title,description:se.description,version:M})]}))};export{g as OpenedDropdown};
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ProductPickerProps } from "./type";
3
- export declare const ProductPickerContent: React.FC<ProductPickerProps & {
4
- resetSearchFlag?: number;
5
- }>;
3
+ export declare const ProductPickerContent: React.FC<ProductPickerProps>;
6
4
  export declare const PricePleaseProductPicker: React.FC<ProductPickerProps>;
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import s from"../../node_modules/lodash.debounce/index.js";import{useState as t,useEffect as o,useCallback as r}from"react";import{PageLoader as n}from"../bik-layout/PageLoader.js";import{CheckBox as c}from"../checkBox/CheckBox.js";import{Input as l}from"../input/Input.js";import{StyledModal as i}from"../modals/styledModal.js";import{StyledProductPickerContainer as a,StyledZeroState as d}from"./ProductPicker.styled.js";import{BodyPrimary as p,Caption as m,TitleSmall as h,BodySecondary as u}from"../TypographyStyle.js";import j from"../../utils/DateUtils.js";import{DEFAULT_THEME as g}from"../../constants/Theme.js";import x from"../../assets/icons/alert_triangle.svg.js";import v from"../../assets/icons/search.svg.js";const f="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg",y=s=>{let{text:t,styleProps:o}=s;return e.jsxs(d,{children:[e.jsx("div",Object.assign({className:"icon__container",style:Object.assign({},o)},{children:e.jsx(x,{width:24,height:24,color:g.colorsV2.content.secondary})})),e.jsx(h,{children:"No results found"}),e.jsx(u,Object.assign({style:{color:g.colorsV2.content.secondary,textAlign:"center"}},{children:`Sorry we could not find any results for "${t}"`}))]})},P=i=>{var d,u,x,P;const b=i.instaPost?j.dateFormat(new Date(i.instaPost.timestamp),"•",!0):"",[_,O]=t(i.products),[w,S]=t(!1),[C,N]=t("");o((()=>{N(""),O(i.products),S(!1)}),[i.show,i.resetSearchFlag]);const V=r(s((e=>{e?(O([]),i.onSearchKeyChange(e).then((e=>{O(e),S(!1)}))):(O(i.products),S(!1))}),700),[]);return e.jsxs(a,{children:[i.instaPost&&e.jsxs("div",Object.assign({className:"post__wrapper"},{children:[e.jsx("img",{alt:"Ig Media",onError:e=>{e.target.onerror=null,e.target.src=f},src:null===(d=i.instaPost)||void 0===d?void 0:d.media_url,className:"post__thumbnail"}),e.jsxs("div",Object.assign({className:"post__info-wrapper"},{children:[e.jsx(p,Object.assign({style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:i.instaPost.caption?g.colorsV2.content.primary:g.colorsV2.content.secondary}},{children:(null===(u=i.instaPost)||void 0===u?void 0:u.caption)?null===(x=i.instaPost)||void 0===x?void 0:x.caption:"No caption"})),e.jsx(m,Object.assign({style:{color:g.colorsV2.content.placeholder}},{children:b}))]}))]})),e.jsx("div",Object.assign({style:{borderTop:i.instaPost?`1px solid ${g.colorsV2.stroke.primary}`:"none",borderBottom:`1px solid ${g.colorsV2.stroke.primary}`,padding:i.instaPost?"16px 24px":"0px 24px 16px 24px"}},{children:e.jsx(l,{value:C,placeholder:null!==(P=i.searchPlaceholder)&&void 0!==P?P:"Search products..",onChangeText:e=>{var s;N(e),(null===(s=e.trim())||void 0===s?void 0:s.length)>0?(S(!0),V(e)):(S(!1),O(i.products))},rightIcon:{icon:v}})})),e.jsxs("div",Object.assign({style:{maxHeight:350,overflowY:"scroll"}},{children:[w&&e.jsx("div",Object.assign({className:"loader__wrapper"},{children:e.jsx(n,{})})),0!==_.length||w?_.map((s=>{var t;const o=i.selectedProducts.find((e=>e.id===s.id));return e.jsxs("div",Object.assign({className:"product__wrapper"},{children:[e.jsxs("div",Object.assign({className:"product__info-wrapper"},{children:[e.jsx("img",{alt:"Product",onError:e=>{e.target.onerror=null,e.target.src=f},src:null!==(t=s.image)&&void 0!==t?t:f,className:"product__image"}),e.jsx(h,{children:s.name})]})),e.jsx("div",Object.assign({style:{order:1}},{children:e.jsx(c,{isChecked:void 0!==o,onValueChange:e=>{((e,s)=>{const t=i.selectedProducts.find((e=>e.id===s.id));if(e&&!t){const e=[...i.selectedProducts,s];i.setSelectedProducts(e)}else if(t){const e=[...i.selectedProducts];let t=-1;i.selectedProducts.forEach(((e,o)=>{e.id===s.id&&(t=o)})),e.splice(t,1),i.setSelectedProducts(e)}})(e,s)}})}))]}),s.id)})):e.jsx(y,{text:C})]}))]})},b=s=>{var r;const[n,c]=t([]),[l,a]=t(0);o((()=>{var e;c(null!==(e=s.selectedProducts)&&void 0!==e?e:[])}),[null===(r=s.selectedProducts)||void 0===r?void 0:r.length]);return e.jsx(i,Object.assign({open:s.show,onClose:()=>{s.onClose()},footerLeftCustomElement:n.length>10?e.jsx(m,Object.assign({style:{color:g.colorsV2.content.negative}},{children:"Can't add more than 10 products"})):e.jsx(m,Object.assign({style:{color:g.colorsV2.content.placeholder}},{children:n?`${n.length} selected`:""})),headingTitle:s.title,primaryButton:{disabled:n.length>10||0===n.length,buttonType:"primary",buttonText:"Select",size:"small",onClick:()=>{s.setSelectedProducts(n),a((e=>e+1)),s.onClose()}},secondaryButton:s.secondaryButtonProps,footerShadow:!0},{children:e.jsx(P,Object.assign({},s,{selectedProducts:n,setSelectedProducts:c,resetSearchFlag:l}))}))};export{b as PricePleaseProductPicker,P as ProductPickerContent};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import s from"../../node_modules/lodash.debounce/index.js";import{useState as t,useCallback as o,useEffect as r}from"react";import{PageLoader as n}from"../bik-layout/PageLoader.js";import{CheckBox as c}from"../checkBox/CheckBox.js";import{Input as l}from"../input/Input.js";import{StyledModal as i}from"../modals/styledModal.js";import{StyledProductPickerContainer as d,StyledZeroState as a}from"./ProductPicker.styled.js";import{BodyPrimary as p,Caption as m,TitleSmall as j,BodySecondary as u}from"../TypographyStyle.js";import h from"../../utils/DateUtils.js";import{DEFAULT_THEME as g}from"../../constants/Theme.js";import x from"../../assets/icons/alert_triangle.svg.js";import v from"../../assets/icons/search.svg.js";const f="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg",y=s=>{let{text:t,styleProps:o}=s;return e.jsxs(a,{children:[e.jsx("div",Object.assign({className:"icon__container",style:Object.assign({},o)},{children:e.jsx(x,{width:24,height:24,color:g.colorsV2.content.secondary})})),e.jsx(j,{children:"No results found"}),e.jsx(u,Object.assign({style:{color:g.colorsV2.content.secondary,textAlign:"center"}},{children:`Sorry we could not find any results for "${t}"`}))]})},P=r=>{var i,a,u,x;const P=r.instaPost?h.dateFormat(new Date(r.instaPost.timestamp),"•",!0):"",[b,_]=t(r.products),[O,w]=t(!1),[C,S]=t(""),N=o(s((e=>{e?(_([]),r.onSearchKeyChange(e).then((e=>{_(e),w(!1)}))):(_(r.products),w(!1))}),700),[]);return e.jsxs(d,{children:[r.instaPost&&e.jsxs("div",Object.assign({className:"post__wrapper"},{children:[e.jsx("img",{alt:"Ig Media",onError:e=>{e.target.onerror=null,e.target.src=f},src:null===(i=r.instaPost)||void 0===i?void 0:i.media_url,className:"post__thumbnail"}),e.jsxs("div",Object.assign({className:"post__info-wrapper"},{children:[e.jsx(p,Object.assign({style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:r.instaPost.caption?g.colorsV2.content.primary:g.colorsV2.content.secondary}},{children:(null===(a=r.instaPost)||void 0===a?void 0:a.caption)?null===(u=r.instaPost)||void 0===u?void 0:u.caption:"No caption"})),e.jsx(m,Object.assign({style:{color:g.colorsV2.content.placeholder}},{children:P}))]}))]})),e.jsx("div",Object.assign({style:{borderTop:r.instaPost?`1px solid ${g.colorsV2.stroke.primary}`:"none",borderBottom:`1px solid ${g.colorsV2.stroke.primary}`,padding:r.instaPost?"16px 24px":"0px 24px 16px 24px"}},{children:e.jsx(l,{placeholder:null!==(x=r.searchPlaceholder)&&void 0!==x?x:"Search products..",onChangeText:e=>{var s;S(e),(null===(s=e.trim())||void 0===s?void 0:s.length)>0?(w(!0),N(e)):(w(!1),_(r.products))},rightIcon:{icon:v}})})),e.jsxs("div",Object.assign({style:{maxHeight:350,overflowY:"scroll"}},{children:[O&&e.jsx("div",Object.assign({className:"loader__wrapper"},{children:e.jsx(n,{})})),0!==b.length||O?b.map((s=>{var t;const o=r.selectedProducts.find((e=>e.id===s.id));return e.jsxs("div",Object.assign({className:"product__wrapper"},{children:[e.jsxs("div",Object.assign({className:"product__info-wrapper"},{children:[e.jsx("img",{alt:"Product",onError:e=>{e.target.onerror=null,e.target.src=f},src:null!==(t=s.image)&&void 0!==t?t:f,className:"product__image"}),e.jsx(j,{children:s.name})]})),e.jsx("div",Object.assign({style:{order:1}},{children:e.jsx(c,{isChecked:void 0!==o,onValueChange:e=>{((e,s)=>{const t=r.selectedProducts.find((e=>e.id===s.id));if(e&&!t){const e=[...r.selectedProducts,s];r.setSelectedProducts(e)}else if(t){const e=[...r.selectedProducts];let t=-1;r.selectedProducts.forEach(((e,o)=>{e.id===s.id&&(t=o)})),e.splice(t,1),r.setSelectedProducts(e)}})(e,s)}})}))]}),s.id)})):e.jsx(y,{text:C})]}))]})},b=s=>{var o;const[n,c]=t([]);return r((()=>{var e;c(null!==(e=s.selectedProducts)&&void 0!==e?e:[])}),[null===(o=s.selectedProducts)||void 0===o?void 0:o.length]),e.jsx(i,Object.assign({open:s.show,onClose:()=>{s.onClose()},footerLeftCustomElement:n.length>10?e.jsx(m,Object.assign({style:{color:g.colorsV2.content.negative}},{children:"Can't add more than 10 products"})):e.jsx(m,Object.assign({style:{color:g.colorsV2.content.placeholder}},{children:n?`${n.length} selected`:""})),headingTitle:s.title,primaryButton:{disabled:n.length>10||0===n.length,buttonType:"primary",buttonText:"Select",size:"small",onClick:()=>{s.setSelectedProducts(n),s.onClose()}},secondaryButton:s.secondaryButtonProps,footerShadow:!0},{children:e.jsx(P,Object.assign({},s,{selectedProducts:n,setSelectedProducts:c}))}))};export{b as PricePleaseProductPicker,P as ProductPickerContent};
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as O,ScreenName as P}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:L,visible:A,zIndex:E,exactLimit:$,limit:B,hideCollectionCheckbox:z,hideProductCheckbox:V,outOfStockAction:M=O.BLUR,hideVariantCheckbox:N,selectProductsFromCustomCollection:H,hideSelectionCount:W,title:G,width:K,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=P.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections),[he,pe]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Oe]=s(!1),[Pe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Le]=c(b,Object.keys(w).length>0?w:{}),Ae=r(null),[Ee,$e]=s(!1),[Be,ze]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;"COLLECTION"===q?e=Object.keys(we||{}).filter((e=>"isCustom"!==e)).length:J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J,q]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Oe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),Ve())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),Ve())}),[Z,we,Se]);const Ve=()=>{Le({type:"reset",data:{}})},Me=()=>{let t,o;return"COLLECTION"===q?(t="collection",o="collections"):J?(t="product",o="products"):(t="variant",o="variants"),$&&Se>$?e.jsx(p,{tagText:`You can only select ${$} ${1===$?t:o}`,type:"negative"}):B&&Se>B?e.jsx(p,{tagText:`You can only select ${B} ${1===B?t:o}`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?P.RearrangeProducts:P.SelectedProducts)},buttonText:$?`${Se}/${$} ${1===Se?t:o} selected`:`${Se} ${1===Se?t:o} selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:$?`${Se}/${$} ${1===$?t:o} selected`:`${Se} ${1===Se?t:o} selected`,buttonType:"tertiaryGray"})},Ne=e=>be?"Loading...":de===P.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(h,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Ae,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Pe,collections:le,selectedCollectionsDispatch:Le,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:z,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Ae,limit:B,exactLimit:$}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Le,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:V,outOfStockAction:M,hideVariantCheckbox:N,selectProductsFromCustomCollection:H,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{$e(!0),ze(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Ae})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Le,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Le,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Ae,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Le,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:V,hideProductVariants:J,hideVariantCheckbox:N,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:z,outOfStockAction:M,limit:B,exactLimit:$})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[He,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:Ne(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||$&&Se<$||!$&&B&&Se>B)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),Ve(),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&Be?e.jsx(g,{productData:Be,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{$e(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:A,onClose:()=>{null==L||L(),Ve()},headingTitle:G||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:K||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:L},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||$&&Se<$||!$&&B&&Se>B)||e.disabled,onClick:()=>{D.onAdd(we,Se),Ve(),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}}))(se):{buttonText:Ne(),disabled:be||Se<1||$&&Se<$||!$&&B&&Se>B||!1,onClick:()=>{D.onAdd(we,Se),Ve()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||$&&Se<$||!$&&B&&Se>B||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[He,Ee&&Be?e.jsx(g,{productData:Be,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{$e(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as O,ScreenName as P}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:L,visible:A,zIndex:E,exactLimit:$,limit:B,hideCollectionCheckbox:z,hideProductCheckbox:V,outOfStockAction:M=O.BLUR,hideVariantCheckbox:N,selectProductsFromCustomCollection:H,hideSelectionCount:W,title:G,width:K,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=P.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections),[he,pe]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Oe]=s(!1),[Pe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Le]=c(b,Object.keys(w).length>0?w:{}),Ae=r(null),[Ee,$e]=s(!1),[Be,ze]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;"COLLECTION"===q?e=Object.keys(we||{}).filter((e=>"isCustom"!==e)).length:J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J,q]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Oe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),Ve())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),Ve())}),[Z,we,Se]);const Ve=()=>{Le({type:"reset",data:{}})},Me=()=>{let t,o;return"COLLECTION"===q?(t="collection",o="collections"):J?(t="product",o="products"):(t="variant",o="variants"),$&&Se>$?e.jsx(p,{tagText:`You can only select ${$} ${1===$?t:o}`,type:"negative"}):B&&Se>B?e.jsx(p,{tagText:`You can only select ${B} ${1===B?t:o}`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?P.RearrangeProducts:P.SelectedProducts)},buttonText:$?`${Se}/${$} ${1===Se?t:o} selected`:`${Se} ${1===Se?t:o} selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:$?`${Se}/${$} ${1===$?t:o} selected`:`${Se} ${1===Se?t:o} selected`,buttonType:"tertiaryGray"})},Ne=e=>be?"Loading...":de===P.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(h,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Ae,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Pe,collections:le,selectedCollectionsDispatch:Le,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:z,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Ae,limit:B,exactLimit:$}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Le,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:V,outOfStockAction:M,hideVariantCheckbox:N,selectProductsFromCustomCollection:H,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{$e(!0),ze(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Ae})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Le,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Le,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Ae,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Le,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:V,hideProductVariants:J,hideVariantCheckbox:N,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:z,outOfStockAction:M,limit:B,exactLimit:$})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[He,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:Ne(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||$&&Se<$||!$&&B&&Se>B)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),Ve(),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&Be?e.jsx(g,{productData:Be,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{$e(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:A,onClose:()=>{null==L||L(),Ve()},headingTitle:G||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:K||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:L},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||$&&Se<$||!$&&B&&Se>B)||e.disabled,onClick:()=>{D.onAdd(we,Se),Ve(),Ie(""),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}}))(se):{buttonText:Ne(),disabled:be||Se<1||$&&Se<$||!$&&B&&Se>B||!1,onClick:()=>{D.onAdd(we,Se),Ve(),Ie("")}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||$&&Se<$||!$&&B&&Se>B||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[He,Ee&&Be?e.jsx(g,{productData:Be,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{$e(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.732-beta.6",
3
+ "version": "0.0.733-beta.0",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",