@bikdotai/bik-component-library 0.0.161 → 0.0.163

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,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js"),i=require("../dropdown/Dropdown.js");require("../dropdown/DropdownPopover/index.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),r=require("../../constants/Theme.js");require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../dropdown/OpenedDropdown/components/menu/SelectAllMenu.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),d=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/triangle_error.svg.js"),l=require("./DiscountModal.styled.js"),T=require("./DiscountUtils.js"),p=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P,_;const[y,O]=t.useState(),[D,b]=t.useState(null!==(C=S.data)&&void 0!==C?C:{}),[N,j]=t.useState(((null===(I=S.data)||void 0===I?void 0:I.isStaticCoupon)||S.allowStaticCoupon)&&!(null===(P=S.data)||void 0===P?void 0:P.targetSelection)),[v,U]=t.useState(!0),[g,m]=t.useState(),[q,h]=t.useState(o.MIN_PURCHASE_REQUIREMENT.NA),[A,x]=t.useState([]),[Y,L]=t.useState([]),[w,G]=t.useState(0);t.useEffect((()=>{S.hideProbability||M()}),[]),t.useEffect((()=>{S.hideProbability||M(),U(T.validateDiscountData(D,q,g,S.hideProbability||!1,w))}),[D,w,g,q]),t.useEffect((()=>{var e,t;if(S.products){if(null===(e=S.data)||void 0===e?void 0:e.entitledProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));L(e)}if(null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));x(e)}}}),[]),t.useEffect((()=>{const e=Y.map((e=>parseInt(e.id)));b(Object.assign(Object.assign({},D),{entitledProductIds:e}))}),[Y]),t.useEffect((()=>{const e=A.map((e=>parseInt(e.id)));b(Object.assign(Object.assign({},D),{prerequisiteProductIds:e}))}),[A]),t.useEffect((()=>{D.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?m(o.DISCOUNT_TYPES.FREE_SHIPPING):D.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?m(o.DISCOUNT_TYPES.BUY_X_GET_Y):D.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?m(o.DISCOUNT_TYPES.FIXED_AMOUNT):D.valueType===o.DISCOUNT_VALUE_TYPES.PERCENTAGE&&m(o.DISCOUNT_TYPES.PERCENTAGE)}),[]);const R=[{value:o.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:g===o.DISCOUNT_TYPES.FIXED_AMOUNT},{value:o.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:g===o.DISCOUNT_TYPES.PERCENTAGE},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:g===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:g===o.DISCOUNT_TYPES.FREE_SHIPPING}],M=()=>{if(!S.quadrant||!S.probability)return;const e=[...S.probability];let t=[];e.length>=S.quadrant&&e.splice(S.quadrant-1,1),t=e;const o=t.reduce(((e,t)=>e+t),0)+(D.probability||0);G(o)},f=e=>{const t=e.value;m(t),t===o.DISCOUNT_TYPES.FREE_SHIPPING?(x([]),L([]),b(Object.assign(Object.assign({},D),{value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.BUY_X_GET_Y?b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE})):t===o.DISCOUNT_TYPES.PERCENTAGE?(x([]),L([]),b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.FIXED_AMOUNT&&(x([]),L([]),b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return e.jsxs(s.StyledModal,Object.assign({open:S.isOpen,headingTitle:y?"Select Products":S.title,headingSubtitle:y?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e.jsx(e.Fragment,{}):w<=1?e.jsx(a.Tag,{theme:"light",tagText:`Current probability sum: ${w}`,type:"white"}):e.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(a.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${w}`,type:"negative",LeadingIcon:c.default})})})),headerRightCustomElement:S.allowStaticCoupon||y?void 0:e.jsx(i.Dropdown,{options:R,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{f(e)}}),onClose:S.onClose,footerShadow:!0,primaryButton:y?{buttonType:"primary",onClick:()=>{O(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:v,onClick:()=>{D.isStaticCoupon?S.onSaveClicked({quadrant:D.quadrant,couponCode:D.couponCode,description:D.description,isStaticCoupon:D.isStaticCoupon,probability:D.probability}):S.onSaveClicked(D),b({})}},secondaryButton:y?{buttonType:"tertiaryGray",onClick:()=>{O(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!y&&e.jsxs(l.StyledDiscountDialogueContainer,{children:[S.allowStaticCoupon&&!y&&e.jsxs(l.CouponTypeContainerStyled,Object.assign({selectedDiv:N?1:2},{children:[e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{j(!0),b({isStaticCoupon:!0,couponCode:D.couponCode,description:D.description,quadrant:D.quadrant})}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"Static code"})),e.jsx(n.BodyCaption,Object.assign({style:N?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{b(Object.assign(Object.assign({},D),{isStaticCoupon:!1})),j(!1)}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic code"})),e.jsx(n.BodyCaption,Object.assign({style:N?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),N&&!y&&e.jsx(E.default,{discountData:D,setDiscountData:b,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!N&&!y&&e.jsx(p.default,{entitledProducts:Y,prerequisiteProducts:A,setEntitledProducts:L,setPrerequisiteProducts:x,discountData:D,productPickerOpen:y,setIsProductPickerOpen:O,setDiscountData:b,selectedCouponType:g,setSelectedCouponType:m,selectedMinimumRequirement:q,setSelectedMinimumRequirement:h,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:f})]}),!!y&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{O(void 0)},selectedProducts:y===p.DISCOUNT_PRODUCTS.ENTITLED?Y:A,setSelectedProducts:y===p.DISCOUNT_PRODUCTS.ENTITLED?L:x,onSearchKeyChange:S.onProductSearch})}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js"),i=require("../dropdown/Dropdown.js");require("../dropdown/DropdownPopover/index.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),r=require("../../constants/Theme.js");require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../dropdown/OpenedDropdown/components/menu/SelectAllMenu.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),d=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/triangle_error.svg.js"),l=require("./DiscountModal.styled.js"),T=require("./DiscountUtils.js"),p=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P,_;const[y,O]=t.useState(),[D,b]=t.useState(null!==(C=S.data)&&void 0!==C?C:{}),[N,j]=t.useState(((null===(I=S.data)||void 0===I?void 0:I.isStaticCoupon)||S.allowStaticCoupon)&&!(null===(P=S.data)||void 0===P?void 0:P.targetSelection)),[v,U]=t.useState(!0),[g,m]=t.useState(),[q,h]=t.useState(o.MIN_PURCHASE_REQUIREMENT.NA),[A,x]=t.useState([]),[Y,L]=t.useState([]),[w,G]=t.useState(0);t.useEffect((()=>{S.hideProbability||M()}),[]),t.useEffect((()=>{S.hideProbability||M(),U(T.validateDiscountData(D,q,g,S.hideProbability||!1,w))}),[D,w,g,q]),t.useEffect((()=>{var e,t;if(S.products){if(null===(e=S.data)||void 0===e?void 0:e.entitledProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));L(e)}if(null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));x(e)}}}),[]),t.useEffect((()=>{const e=Y.map((e=>parseInt(e.id)));b(Object.assign(Object.assign({},D),{entitledProductIds:e}))}),[Y]),t.useEffect((()=>{const e=A.map((e=>parseInt(e.id)));b(Object.assign(Object.assign({},D),{prerequisiteProductIds:e}))}),[A]),t.useEffect((()=>{D.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?m(o.DISCOUNT_TYPES.FREE_SHIPPING):D.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?m(o.DISCOUNT_TYPES.BUY_X_GET_Y):D.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?m(o.DISCOUNT_TYPES.FIXED_AMOUNT):D.valueType===o.DISCOUNT_VALUE_TYPES.PERCENTAGE&&m(o.DISCOUNT_TYPES.PERCENTAGE)}),[]);const R=[{value:o.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:g===o.DISCOUNT_TYPES.FIXED_AMOUNT},{value:o.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:g===o.DISCOUNT_TYPES.PERCENTAGE},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:g===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:g===o.DISCOUNT_TYPES.FREE_SHIPPING}],M=()=>{if(!S.quadrant||!S.probability)return;const e=[...S.probability];let t=[];e.length>=S.quadrant&&e.splice(S.quadrant-1,1),t=e;const o=t.reduce(((e,t)=>e+t),0)+(D.probability||0);G(o)},f=e=>{const t=e.value;m(t),t===o.DISCOUNT_TYPES.FREE_SHIPPING?(x([]),L([]),b(Object.assign(Object.assign({},D),{value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.BUY_X_GET_Y?b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE})):t===o.DISCOUNT_TYPES.PERCENTAGE?(x([]),L([]),b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.FIXED_AMOUNT&&(x([]),L([]),b(Object.assign(Object.assign({},D),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return e.jsxs(s.StyledModal,Object.assign({open:S.isOpen,headingTitle:y?"Select Products":S.title,headingSubtitle:y?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e.jsx(e.Fragment,{}):w<=1?e.jsx(a.Tag,{theme:"light",tagText:`Current probability sum: ${w}`,type:"white"}):e.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(a.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${w}`,type:"negative",LeadingIcon:c.default})})})),headerRightCustomElement:S.allowStaticCoupon||y?void 0:e.jsx(i.Dropdown,{options:R,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{f(e)}}),onClose:S.onClose,footerShadow:!0,primaryButton:y?{buttonType:"primary",onClick:()=>{O(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:v,onClick:()=>{D.isStaticCoupon?S.onSaveClicked({quadrant:D.quadrant,couponCode:D.couponCode,description:D.description,isStaticCoupon:D.isStaticCoupon,probability:D.probability}):S.onSaveClicked(D),b({})}},secondaryButton:y?{buttonType:"tertiaryGray",onClick:()=>{O(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!y&&e.jsxs(l.StyledDiscountDialogueContainer,{children:[S.allowStaticCoupon&&!y&&e.jsxs(l.CouponTypeContainerStyled,Object.assign({selectedDiv:N?1:2},{children:[e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{j(!0),b({isStaticCoupon:!0,couponCode:D.couponCode,description:D.description,quadrant:D.quadrant})}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"Static code"})),e.jsx(n.BodyCaption,Object.assign({style:N?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{b(Object.assign(Object.assign({},D),{isStaticCoupon:!1})),j(!1)}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic code"})),e.jsx(n.BodyCaption,Object.assign({style:N?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),N&&!y&&e.jsx(E.default,{discountData:D,setDiscountData:b,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!N&&!y&&e.jsx(p.default,{currency:S.currency,entitledProducts:Y,prerequisiteProducts:A,setEntitledProducts:L,setPrerequisiteProducts:x,discountData:D,productPickerOpen:y,setIsProductPickerOpen:O,setDiscountData:b,selectedCouponType:g,setSelectedCouponType:m,selectedMinimumRequirement:q,setSelectedMinimumRequirement:h,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:f})]}),!!y&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{O(void 0)},selectedProducts:y===p.DISCOUNT_PRODUCTS.ENTITLED?Y:A,setSelectedProducts:y===p.DISCOUNT_PRODUCTS.ENTITLED?L:x,onSearchKeyChange:S.onProductSearch})}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../zeroState/ZeroState.js"),n=require("../../../../hooks/useOutside.js"),l=require("../utils/iterationOnOptions.js"),i=require("./description/Description.js"),o=require("./menu/FreeFormMenu.js"),r=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 f=304,h=290;exports.OpenedDropdown=j=>{let{options:b,isSearchable:S,isMultiSelect:O,width:x,allowFreeForm:g,height:v,onClose:m,onSelect:w}=j;const[y,q]=t.useState(null!=b?b:[]);t.useEffect((()=>{b&&q(b.sort((e=>e.selected?-1:1)))}),[b]);const[C,M]=t.useState(null!=x?x:h),[L,F]=t.useState(""),[D,A]=t.useState(null),B=t.useRef(null);n.useOutside(B,(()=>{A(null),null==m||m()}));const Z=null!=v?v:f,E="number"==typeof Z?S&&O?Z-96:S&&!O||!S&&O?Z-48:Z:Z;function k(e){if(O){const t=l.iterateOnOptions(y,{selected:e.selected},(t=>t.value===e.value));q([...t])}else null==w||w(e)}t.useEffect((()=>{const e=null!=x?x:h;if(null===D)M(e);else if("number"==typeof e)M(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));M(t)}}),[D]);const H=[],P=y.map((e=>{var t,s;if(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(L.toLowerCase()))&&(H.push(!L||e.label===L),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(L.toLowerCase()))||(null===(s=e.searchKey)||void 0===s?void 0:s.toLowerCase().includes(L.toLowerCase()))?(H.push(!L||e.label===L),e):null}return e})).filter((e=>null!==e)),_=!!S&&L&&0===P.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({ref:B,style:{width:C}},{children:[e.jsxs("div",Object.assign({style:{width:D?"50%":"100%",display:"flex",flexDirection:"column"}},{children:[!!S&&e.jsx(d.SearchBox,{onSearch:function(e){F(e)}}),P.length||L?e.jsxs(a.MenuListContainer,Object.assign({minHeight:Z,maxHeight:E},{children:[!!O&&!_&&e.jsx(u.SelectAllMenu,{options:y,onSelect:function(e){if("selectAll"===e){const e=l.iterateOnOptions(y,{selected:!0},(e=>{var t;return L?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(L.toLowerCase()))&&!e.disabled:!e.disabled}));q([...e])}else if("notSelected"===e){const e=l.iterateOnOptions(y,{selected:!1},(e=>!e.disabled));q([...e])}}}),!g&&_&&e.jsx(p.SearchZeroState,{searchedString:L}),g&&(_||!!H.length&&H.every((e=>!1===e)))&&e.jsx(o.FreeFormMenu,{isMultiSelect:O,onSelect:function(e){if(!O)return void k({label:L,value:L,isFreeForm:!0,selected:!0});const t=y.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===L&&t.value===L?e:t.selected})));e&&(t.some((e=>e.label===L&&e.value===L))||t.unshift({label:L,value:L,isFreeForm:!0,selected:!0})),q([...t])},searchedString:L}),e.jsx(r.MenuList,{onSelect:k,showDescription:function(e,t){A(e&&t?{title:e,description:t}:null)},isMultiSelect:O,options:P})]})):e.jsx("div",Object.assign({style:{height:Z,display:"flex"}},{children:e.jsx(s.ZeroState,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!O&&!(!P.length&&!L)&&e.jsx(c.default,{onClear:function(){const e=l.iterateOnOptions(y,{selected:!1});q([...e])},onApply:function(){const e=[];y.forEach((t=>{if(t.options){const s=t.options.filter((e=>!0===e.selected));e.push(Object.assign(Object.assign({},t),{options:[...s]}))}else t.selected&&e.push(Object.assign({},t))})),null==w||w([...e])},list:y})]})),!!D&&e.jsx(i.Description,{title:D.title,description:D.description})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../zeroState/ZeroState.js"),n=require("../../../../hooks/useOutside.js"),l=require("../utils/iterationOnOptions.js"),i=require("./description/Description.js"),o=require("./menu/FreeFormMenu.js"),r=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 f=304,h=290;exports.OpenedDropdown=j=>{let{options:b,isSearchable:S,isMultiSelect:O,width:x,allowFreeForm:g,height:v,onClose:m,onSelect:w}=j;const[y,q]=t.useState(null!=b?b:[]);t.useEffect((()=>{b&&q([...b.sort((e=>e.selected?-1:1))])}),[b]);const[C,M]=t.useState(null!=x?x:h),[L,F]=t.useState(""),[D,A]=t.useState(null),B=t.useRef(null);n.useOutside(B,(()=>{A(null),null==m||m()}));const Z=null!=v?v:f,E="number"==typeof Z?S&&O?Z-96:S&&!O||!S&&O?Z-48:Z:Z;function k(e){if(O){const t=l.iterateOnOptions(y,{selected:e.selected},(t=>t.value===e.value));q([...t])}else null==w||w(e)}t.useEffect((()=>{const e=null!=x?x:h;if(null===D)M(e);else if("number"==typeof e)M(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));M(t)}}),[D]);const H=[],P=y.map((e=>{var t,s;if(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(L.toLowerCase()))&&(H.push(!L||e.label===L),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(L.toLowerCase()))||(null===(s=e.searchKey)||void 0===s?void 0:s.toLowerCase().includes(L.toLowerCase()))?(H.push(!L||e.label===L),e):null}return e})).filter((e=>null!==e)),_=!!S&&L&&0===P.length;return e.jsxs(a.OpennedDropdownContainer,Object.assign({ref:B,style:{width:C}},{children:[e.jsxs("div",Object.assign({style:{width:D?"50%":"100%",display:"flex",flexDirection:"column"}},{children:[!!S&&e.jsx(d.SearchBox,{onSearch:function(e){F(e)}}),P.length||L?e.jsxs(a.MenuListContainer,Object.assign({minHeight:Z,maxHeight:E},{children:[!!O&&!_&&e.jsx(u.SelectAllMenu,{options:y,onSelect:function(e){if("selectAll"===e){const e=l.iterateOnOptions(y,{selected:!0},(e=>{var t;return L?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(L.toLowerCase()))&&!e.disabled:!e.disabled}));q([...e])}else if("notSelected"===e){const e=l.iterateOnOptions(y,{selected:!1},(e=>!e.disabled));q([...e])}}}),!g&&_&&e.jsx(p.SearchZeroState,{searchedString:L}),g&&(_||!!H.length&&H.every((e=>!1===e)))&&e.jsx(o.FreeFormMenu,{isMultiSelect:O,onSelect:function(e){if(!O)return void k({label:L,value:L,isFreeForm:!0,selected:!0});const t=y.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===L&&t.value===L?e:t.selected})));e&&(t.some((e=>e.label===L&&e.value===L))||t.unshift({label:L,value:L,isFreeForm:!0,selected:!0})),q([...t])},searchedString:L}),e.jsx(r.MenuList,{onSelect:k,showDescription:function(e,t){A(e&&t?{title:e,description:t}:null)},isMultiSelect:O,options:P})]})):e.jsx("div",Object.assign({style:{height:Z,display:"flex"}},{children:e.jsx(s.ZeroState,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!O&&!(!P.length&&!L)&&e.jsx(c.default,{onClear:function(){const e=l.iterateOnOptions(y,{selected:!1});q([...e])},onApply:function(){const e=[];y.forEach((t=>{if(t.options){const s=t.options.filter((e=>!0===e.selected));e.push(Object.assign(Object.assign({},t),{options:[...s]}))}else t.selected&&e.push(Object.assign({},t))})),null==w||w([...e])},list:y})]})),!!D&&e.jsx(i.Description,{title:D.title,description:D.description})]}))};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const WorkingStepper: () => JSX.Element;
2
3
  export declare enum STEPENUM {
3
4
  STEP1 = "STEP1",
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";import{MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_TARGET_TYPES as d,DISCOUNT_TYPES as s,DISCOUNT_TARGET_SELECTION as a,DISCOUNT_VALUE_TYPES as c}from"./type.js";import{Dropdown as l}from"../dropdown/Dropdown.js";import"../dropdown/DropdownPopover/index.js";import"../zeroState/ZeroState.js";import{TitleSmall as p,BodyCaption as u}from"../TypographyStyle.js";import{DEFAULT_THEME as m}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../dropdown/OpenedDropdown/components/menu/SelectAllMenu.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as b}from"../modals/styledModal.js";import{ProductPickerContent as y}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import T from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as P,CouponTypeContainerStyled as g}from"./DiscountModal.styled.js";import{validateDiscountData as I}from"./DiscountUtils.js";import j,{DISCOUNT_PRODUCTS as C}from"./DynamicCoupon/DynamicCoupon.js";import h from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,D,N,_;const[w,f]=i(),[A,q]=i(null!==(O=S.data)&&void 0!==O?O:{}),[G,M]=i(((null===(D=S.data)||void 0===D?void 0:D.isStaticCoupon)||S.allowStaticCoupon)&&!(null===(N=S.data)||void 0===N?void 0:N.targetSelection)),[L,x]=i(!0),[R,k]=i(),[F,B]=i(r.NA),[U,X]=i([]),[Y,H]=i([]),[Q,V]=i(0);n((()=>{S.hideProbability||$()}),[]),n((()=>{S.hideProbability||$(),x(I(A,F,R,S.hideProbability||!1,Q))}),[A,Q,R,F]),n((()=>{var t,e;if(S.products){if(null===(t=S.data)||void 0===t?void 0:t.entitledProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));H(t)}if(null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));X(t)}}}),[]),n((()=>{const t=Y.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{entitledProductIds:t}))}),[Y]),n((()=>{const t=U.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{prerequisiteProductIds:t}))}),[U]),n((()=>{A.targetType===d.SHIPPING_LINE?k(s.FREE_SHIPPING):A.targetSelection===a.ENTITLED?k(s.BUY_X_GET_Y):A.valueType===c.FIXED_AMOUNT?k(s.FIXED_AMOUNT):A.valueType===c.PERCENTAGE&&k(s.PERCENTAGE)}),[]);const z=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:R===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:R===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:R===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:R===s.FREE_SHIPPING}],$=()=>{if(!S.quadrant||!S.probability)return;const t=[...S.probability];let e=[];t.length>=S.quadrant&&t.splice(S.quadrant-1,1),e=t;const o=e.reduce(((t,e)=>t+e),0)+(A.probability||0);V(o)},K=t=>{const e=t.value;k(e),e===s.FREE_SHIPPING?(X([]),H([]),q(Object.assign(Object.assign({},A),{value:100,targetSelection:a.ALL,targetType:d.SHIPPING_LINE,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.BUY_X_GET_Y?q(Object.assign(Object.assign({},A),{targetSelection:a.ENTITLED,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE})):e===s.PERCENTAGE?(X([]),H([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.FIXED_AMOUNT&&(X([]),H([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return t(b,Object.assign({open:S.isOpen,headingTitle:w?"Select Products":S.title,headingSubtitle:w?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e(o,{}):Q<=1?e(E,{theme:"light",tagText:`Current probability sum: ${Q}`,type:"white"}):e(v,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Q}`,type:"negative",LeadingIcon:T})})})),headerRightCustomElement:S.allowStaticCoupon||w?void 0:e(l,{options:z,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{K(t)}}),onClose:S.onClose,footerShadow:!0,primaryButton:w?{buttonType:"primary",onClick:()=>{f(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:L,onClick:()=>{A.isStaticCoupon?S.onSaveClicked({quadrant:A.quadrant,couponCode:A.couponCode,description:A.description,isStaticCoupon:A.isStaticCoupon,probability:A.probability}):S.onSaveClicked(A),q({})}},secondaryButton:w?{buttonType:"tertiaryGray",onClick:()=>{f(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!w&&t(P,{children:[S.allowStaticCoupon&&!w&&t(g,Object.assign({selectedDiv:G?1:2},{children:[t("div",Object.assign({className:"coupon-type__container",onClick:()=>{M(!0),q({isStaticCoupon:!0,couponCode:A.couponCode,description:A.description,quadrant:A.quadrant})}},{children:[e(p,Object.assign({style:G?{color:m.colorsV2.content.brand}:{}},{children:"Static code"})),e(u,Object.assign({style:G?{color:m.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),t("div",Object.assign({className:"coupon-type__container",onClick:()=>{q(Object.assign(Object.assign({},A),{isStaticCoupon:!1})),M(!1)}},{children:[e(p,Object.assign({style:G?{}:{color:m.colorsV2.content.brand}},{children:"Dynamic code"})),e(u,Object.assign({style:G?{}:{color:m.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),G&&!w&&e(h,{discountData:A,setDiscountData:q,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!G&&!w&&e(j,{entitledProducts:Y,prerequisiteProducts:U,setEntitledProducts:H,setPrerequisiteProducts:X,discountData:A,productPickerOpen:w,setIsProductPickerOpen:f,setDiscountData:q,selectedCouponType:R,setSelectedCouponType:k,selectedMinimumRequirement:F,setSelectedMinimumRequirement:B,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:K})]}),!!w&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(y,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{f(void 0)},selectedProducts:w===C.ENTITLED?Y:U,setSelectedProducts:w===C.ENTITLED?H:X,onSearchKeyChange:S.onProductSearch})}))]}))};export{S as DiscountModal};
1
+ import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";import{MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_TARGET_TYPES as d,DISCOUNT_TYPES as s,DISCOUNT_TARGET_SELECTION as a,DISCOUNT_VALUE_TYPES as c}from"./type.js";import{Dropdown as l}from"../dropdown/Dropdown.js";import"../dropdown/DropdownPopover/index.js";import"../zeroState/ZeroState.js";import{TitleSmall as p,BodyCaption as u}from"../TypographyStyle.js";import{DEFAULT_THEME as m}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../dropdown/OpenedDropdown/components/menu/SelectAllMenu.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as y}from"../modals/styledModal.js";import{ProductPickerContent as b}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import T from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as P,CouponTypeContainerStyled as g}from"./DiscountModal.styled.js";import{validateDiscountData as I}from"./DiscountUtils.js";import j,{DISCOUNT_PRODUCTS as C}from"./DynamicCoupon/DynamicCoupon.js";import h from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,D,N,_;const[w,f]=i(),[A,q]=i(null!==(O=S.data)&&void 0!==O?O:{}),[G,M]=i(((null===(D=S.data)||void 0===D?void 0:D.isStaticCoupon)||S.allowStaticCoupon)&&!(null===(N=S.data)||void 0===N?void 0:N.targetSelection)),[L,x]=i(!0),[R,k]=i(),[F,B]=i(r.NA),[U,X]=i([]),[Y,H]=i([]),[Q,V]=i(0);n((()=>{S.hideProbability||$()}),[]),n((()=>{S.hideProbability||$(),x(I(A,F,R,S.hideProbability||!1,Q))}),[A,Q,R,F]),n((()=>{var t,e;if(S.products){if(null===(t=S.data)||void 0===t?void 0:t.entitledProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));H(t)}if(null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));X(t)}}}),[]),n((()=>{const t=Y.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{entitledProductIds:t}))}),[Y]),n((()=>{const t=U.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{prerequisiteProductIds:t}))}),[U]),n((()=>{A.targetType===d.SHIPPING_LINE?k(s.FREE_SHIPPING):A.targetSelection===a.ENTITLED?k(s.BUY_X_GET_Y):A.valueType===c.FIXED_AMOUNT?k(s.FIXED_AMOUNT):A.valueType===c.PERCENTAGE&&k(s.PERCENTAGE)}),[]);const z=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:R===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:R===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:R===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:R===s.FREE_SHIPPING}],$=()=>{if(!S.quadrant||!S.probability)return;const t=[...S.probability];let e=[];t.length>=S.quadrant&&t.splice(S.quadrant-1,1),e=t;const o=e.reduce(((t,e)=>t+e),0)+(A.probability||0);V(o)},K=t=>{const e=t.value;k(e),e===s.FREE_SHIPPING?(X([]),H([]),q(Object.assign(Object.assign({},A),{value:100,targetSelection:a.ALL,targetType:d.SHIPPING_LINE,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.BUY_X_GET_Y?q(Object.assign(Object.assign({},A),{targetSelection:a.ENTITLED,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE})):e===s.PERCENTAGE?(X([]),H([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.FIXED_AMOUNT&&(X([]),H([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return t(y,Object.assign({open:S.isOpen,headingTitle:w?"Select Products":S.title,headingSubtitle:w?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e(o,{}):Q<=1?e(E,{theme:"light",tagText:`Current probability sum: ${Q}`,type:"white"}):e(v,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Q}`,type:"negative",LeadingIcon:T})})})),headerRightCustomElement:S.allowStaticCoupon||w?void 0:e(l,{options:z,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{K(t)}}),onClose:S.onClose,footerShadow:!0,primaryButton:w?{buttonType:"primary",onClick:()=>{f(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:L,onClick:()=>{A.isStaticCoupon?S.onSaveClicked({quadrant:A.quadrant,couponCode:A.couponCode,description:A.description,isStaticCoupon:A.isStaticCoupon,probability:A.probability}):S.onSaveClicked(A),q({})}},secondaryButton:w?{buttonType:"tertiaryGray",onClick:()=>{f(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!w&&t(P,{children:[S.allowStaticCoupon&&!w&&t(g,Object.assign({selectedDiv:G?1:2},{children:[t("div",Object.assign({className:"coupon-type__container",onClick:()=>{M(!0),q({isStaticCoupon:!0,couponCode:A.couponCode,description:A.description,quadrant:A.quadrant})}},{children:[e(p,Object.assign({style:G?{color:m.colorsV2.content.brand}:{}},{children:"Static code"})),e(u,Object.assign({style:G?{color:m.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),t("div",Object.assign({className:"coupon-type__container",onClick:()=>{q(Object.assign(Object.assign({},A),{isStaticCoupon:!1})),M(!1)}},{children:[e(p,Object.assign({style:G?{}:{color:m.colorsV2.content.brand}},{children:"Dynamic code"})),e(u,Object.assign({style:G?{}:{color:m.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),G&&!w&&e(h,{discountData:A,setDiscountData:q,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!G&&!w&&e(j,{currency:S.currency,entitledProducts:Y,prerequisiteProducts:U,setEntitledProducts:H,setPrerequisiteProducts:X,discountData:A,productPickerOpen:w,setIsProductPickerOpen:f,setDiscountData:q,selectedCouponType:R,setSelectedCouponType:k,selectedMinimumRequirement:F,setSelectedMinimumRequirement:B,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:K})]}),!!w&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(b,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{f(void 0)},selectedProducts:w===C.ENTITLED?Y:U,setSelectedProducts:w===C.ENTITLED?H:X,onSearchKeyChange:S.onProductSearch})}))]}))};export{S as DiscountModal};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useEffect as l,useRef as s}from"react";import{ZeroState as i}from"../../../zeroState/ZeroState.js";import{useOutside as n}from"../../../../hooks/useOutside.js";import{iterateOnOptions as r}from"../utils/iterationOnOptions.js";import{Description as c}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as u}from"./menu/MenuList.js";import{SelectAllMenu as d}from"./menu/SelectAllMenu.js";import p from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as f,MenuListContainer as m}from"./OpennedDropdown.styled.js";import{SearchBox as h}from"./searchbox/SearchBox.js";import{SearchZeroState as b}from"./searchbox/SearchZeroState.js";const g=304,j=290,v=v=>{let{options:S,isSearchable:w,isMultiSelect:y,width:O,allowFreeForm:x,height:C,onClose:L,onSelect:F}=v;const[M,D]=o(null!=S?S:[]);l((()=>{S&&D(S.sort((e=>e.selected?-1:1)))}),[S]);const[A,B]=o(null!=O?O:j),[k,H]=o(""),[Z,q]=o(null),z=s(null);n(z,(()=>{q(null),null==L||L()}));const E=null!=C?C:g,I="number"==typeof E?w&&y?E-96:w&&!y||!w&&y?E-48:E:E;function K(e){if(y){const t=r(M,{selected:e.selected},(t=>t.value===e.value));D([...t])}else null==F||F(e)}l((()=>{const e=null!=O?O:j;if(null===Z)B(e);else if("number"==typeof e)B(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));B(t)}}),[Z]);const N=[],P=M.map((e=>{var t,o;if(k){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(k.toLowerCase()))&&(N.push(!k||e.label===k),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(k.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(k.toLowerCase()))?(N.push(!k||e.label===k),e):null}return e})).filter((e=>null!==e)),T=!!w&&k&&0===P.length;return e(f,Object.assign({ref:z,style:{width:A}},{children:[e("div",Object.assign({style:{width:Z?"50%":"100%",display:"flex",flexDirection:"column"}},{children:[!!w&&t(h,{onSearch:function(e){H(e)}}),P.length||k?e(m,Object.assign({minHeight:E,maxHeight:I},{children:[!!y&&!T&&t(d,{options:M,onSelect:function(e){if("selectAll"===e){const e=r(M,{selected:!0},(e=>{var t;return k?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(k.toLowerCase()))&&!e.disabled:!e.disabled}));D([...e])}else if("notSelected"===e){const e=r(M,{selected:!1},(e=>!e.disabled));D([...e])}}}),!x&&T&&t(b,{searchedString:k}),x&&(T||!!N.length&&N.every((e=>!1===e)))&&t(a,{isMultiSelect:y,onSelect:function(e){if(!y)return void K({label:k,value:k,isFreeForm:!0,selected:!0});const t=M.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===k&&t.value===k?e:t.selected})));e&&(t.some((e=>e.label===k&&e.value===k))||t.unshift({label:k,value:k,isFreeForm:!0,selected:!0})),D([...t])},searchedString:k}),t(u,{onSelect:K,showDescription:function(e,t){q(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:P})]})):t("div",Object.assign({style:{height:E,display:"flex"}},{children:t(i,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!y&&!(!P.length&&!k)&&t(p,{onClear:function(){const e=r(M,{selected:!1});D([...e])},onApply:function(){const e=[];M.forEach((t=>{if(t.options){const o=t.options.filter((e=>!0===e.selected));e.push(Object.assign(Object.assign({},t),{options:[...o]}))}else t.selected&&e.push(Object.assign({},t))})),null==F||F([...e])},list:M})]})),!!Z&&t(c,{title:Z.title,description:Z.description})]}))};export{v as OpenedDropdown};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useEffect as l,useRef as s}from"react";import{ZeroState as i}from"../../../zeroState/ZeroState.js";import{useOutside as n}from"../../../../hooks/useOutside.js";import{iterateOnOptions as r}from"../utils/iterationOnOptions.js";import{Description as c}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as u}from"./menu/MenuList.js";import{SelectAllMenu as d}from"./menu/SelectAllMenu.js";import p from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as f,MenuListContainer as m}from"./OpennedDropdown.styled.js";import{SearchBox as h}from"./searchbox/SearchBox.js";import{SearchZeroState as b}from"./searchbox/SearchZeroState.js";const g=304,j=290,v=v=>{let{options:S,isSearchable:w,isMultiSelect:y,width:O,allowFreeForm:x,height:C,onClose:L,onSelect:F}=v;const[M,D]=o(null!=S?S:[]);l((()=>{S&&D([...S.sort((e=>e.selected?-1:1))])}),[S]);const[A,B]=o(null!=O?O:j),[k,H]=o(""),[Z,q]=o(null),z=s(null);n(z,(()=>{q(null),null==L||L()}));const E=null!=C?C:g,I="number"==typeof E?w&&y?E-96:w&&!y||!w&&y?E-48:E:E;function K(e){if(y){const t=r(M,{selected:e.selected},(t=>t.value===e.value));D([...t])}else null==F||F(e)}l((()=>{const e=null!=O?O:j;if(null===Z)B(e);else if("number"==typeof e)B(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));B(t)}}),[Z]);const N=[],P=M.map((e=>{var t,o;if(k){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(k.toLowerCase()))&&(N.push(!k||e.label===k),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(k.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(k.toLowerCase()))?(N.push(!k||e.label===k),e):null}return e})).filter((e=>null!==e)),T=!!w&&k&&0===P.length;return e(f,Object.assign({ref:z,style:{width:A}},{children:[e("div",Object.assign({style:{width:Z?"50%":"100%",display:"flex",flexDirection:"column"}},{children:[!!w&&t(h,{onSearch:function(e){H(e)}}),P.length||k?e(m,Object.assign({minHeight:E,maxHeight:I},{children:[!!y&&!T&&t(d,{options:M,onSelect:function(e){if("selectAll"===e){const e=r(M,{selected:!0},(e=>{var t;return k?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(k.toLowerCase()))&&!e.disabled:!e.disabled}));D([...e])}else if("notSelected"===e){const e=r(M,{selected:!1},(e=>!e.disabled));D([...e])}}}),!x&&T&&t(b,{searchedString:k}),x&&(T||!!N.length&&N.every((e=>!1===e)))&&t(a,{isMultiSelect:y,onSelect:function(e){if(!y)return void K({label:k,value:k,isFreeForm:!0,selected:!0});const t=M.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===k&&t.value===k?e:t.selected})));e&&(t.some((e=>e.label===k&&e.value===k))||t.unshift({label:k,value:k,isFreeForm:!0,selected:!0})),D([...t])},searchedString:k}),t(u,{onSelect:K,showDescription:function(e,t){q(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:P})]})):t("div",Object.assign({style:{height:E,display:"flex"}},{children:t(i,{title:"No results found",subTitle:"Please try again later or contact us at support@bik.ai if you require further assistance."})})),!!y&&!(!P.length&&!k)&&t(p,{onClear:function(){const e=r(M,{selected:!1});D([...e])},onApply:function(){const e=[];M.forEach((t=>{if(t.options){const o=t.options.filter((e=>!0===e.selected));e.push(Object.assign(Object.assign({},t),{options:[...o]}))}else t.selected&&e.push(Object.assign({},t))})),null==F||F([...e])},list:M})]})),!!Z&&t(c,{title:Z.title,description:Z.description})]}))};export{v as OpenedDropdown};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const WorkingStepper: () => JSX.Element;
2
3
  export declare enum STEPENUM {
3
4
  STEP1 = "STEP1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.161",
3
+ "version": "0.0.163",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",