@bikdotai/bik-component-library 0.0.384-beta.27 → 0.0.384-beta.28
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,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),c=require("react"),o=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),C=require("./selectedScreen.js"),g=require("./style.js"),x=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:j,selectedItems:m,onClose:v,visible:b,zIndex:y,limit:P,hideCollectionCheckbox:f,hideProductCheckbox:O,outOfStockAction:R=x.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:k,selectProductsFromCustomCollection:I,hideSelectionCount:q,title:F,width:T,startupScreen:E=exports.ScreenName.Collections,rearrangeEnabled:D}=e,[N,w]=c.useReducer(p.collectionsReducer,{}),[B,A]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(E)?E:exports.ScreenName.Collections),[L,_]=c.useState("grid"),[M,z]=c.useState(""),[G,H]=c.useState(0),[V,$]=c.useState(!1),[K,U]=c.useState(0),[Y,J]=c.useState(""),[Q,W]=c.useState(!1),[X,Z]=c.useState(!1),[ee,te]=c.useState(),[re,ce]=c.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{});c.useEffect((()=>{$(!0),Z(!0),e.collectionFetcher(G,j).then((e=>{w({type:"fetched",data:(null==e?void 0:e.collections)||{}}),$(!1),H((e=>e+1)),Z(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(re||[]).forEach((t=>{var r;Object.keys((null===(r=re[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var c,o;Object.keys((null===(o=null===(c=re[t].products)||void 0===c?void 0:c[r])||void 0===o?void 0:o.variants)||[]).forEach((()=>{e+=1}))}))})),U(e)})),c.useEffect((()=>{var t;M&&!(null===(t=null==N?void 0:N[M])||void 0===t?void 0:t.products)&&($(!0),e.productFetcher(M,j).then((e=>{Object.keys(e).length&&w({type:"productsFetched",data:{collectionId:M,products:e}}),$(!1)})).catch())}),[M]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),c=require("react"),o=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),C=require("./selectedScreen.js"),g=require("./style.js"),x=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:j,selectedItems:m,onClose:v,visible:b,zIndex:y,limit:P,hideCollectionCheckbox:f,hideProductCheckbox:O,outOfStockAction:R=x.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:k,selectProductsFromCustomCollection:I,hideSelectionCount:q,title:F,width:T,startupScreen:E=exports.ScreenName.Collections,rearrangeEnabled:D}=e,[N,w]=c.useReducer(p.collectionsReducer,{}),[B,A]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(E)?E:exports.ScreenName.Collections),[L,_]=c.useState("grid"),[M,z]=c.useState(""),[G,H]=c.useState(0),[V,$]=c.useState(!1),[K,U]=c.useState(0),[Y,J]=c.useState(""),[Q,W]=c.useState(!1),[X,Z]=c.useState(!1),[ee,te]=c.useState(),[re,ce]=c.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{});c.useEffect((()=>{$(!0),Z(!0),e.collectionFetcher(G,j).then((e=>{w({type:"fetched",data:(null==e?void 0:e.collections)||{}}),$(!1),H((e=>e+1)),Z(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(re||[]).forEach((t=>{var r;Object.keys((null===(r=re[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var c,o;Object.keys((null===(o=null===(c=re[t].products)||void 0===c?void 0:c[r])||void 0===o?void 0:o.variants)||[]).forEach((()=>{e+=1}))}))})),U(e)})),c.useEffect((()=>{var t;M&&!(null===(t=null==N?void 0:N[M])||void 0===t?void 0:t.products)&&($(!0),e.productFetcher(M,j).then((e=>{Object.keys(e).length&&w({type:"productsFetched",data:{collectionId:M,products:e}}),$(!1)})).catch())}),[M]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==B&&(Y.length?(W(!0),e.searchFetcher(j,Y).then((e=>{te(Object.assign({},e)),A("searchProducts"),$(!1),W(!1)}))):A("collections"))}),800);return()=>clearTimeout(t)}),[Y]);const oe=()=>{ce({type:"reset",data:{}})};return t.jsx(l.StyledModal,Object.assign({zIndex:y,open:b,onClose:()=>{v(),oe()},headingTitle:F||("collections"===B||"products"===B?"Select Products":"view"===B?"Selected Products":"searchProducts"===B?"Searched Products":"rearrange"===B?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:T||"480px"},headerRightCustomElement:"rearrange"===B?(console.log("ignore:",_),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:V?"Loading...":B===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:V||K<1||P&&K>P||!1,onClick:()=>{e.onAdd(re,K),oe()}},footerLeftCustomElement:q?t.jsx(t.Fragment,{}):P&&K>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):K>0?t.jsx(s.Button,{onClick:()=>{A(D?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:`${K} products selected`,buttonType:["rearrange","view"].includes(B)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(B)}):t.jsx(s.Button,{disabled:!0,buttonText:`${K} products selected`,buttonType:"tertiaryGray"})},{children:t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===B||"searchProducts"===B)&&t.jsx("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Q?t.jsx(i.Spinner,{size:"small",color:o.COLORS.content.primary}):t.jsx(r.default,{})},id:"listInput",height:"24px",type:"text",value:Y,onChangeText:e=>{e.length&&e.trim().length?J(e):J("")}})}))}),t.jsxs(g.ScrollContainerStyle,{children:["collections"===B&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:X,collections:N,selectedCollectionsDispatch:ce,setCollectionId:z,setScreen:A,selectedCollections:re,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:w,setSaveDisabled:$,pagingControls:{curPage:G,setCurPage:H},hideCollectionCheckbox:f}),"products"===B&&M&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:M},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:A,storeId:j,data:N[M],collectionsDispatch:w,selectedCollectionsDispatch:ce,selectedData:re,setSaveDisabled:$,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:R,hideVariantCheckbox:k,selectProductsFromCustomCollection:I})})),"view"===B&&t.jsx(C.SelectedScreen,{selectedCollections:re||{},selectedCollectionsDispatch:ce,setScreen:A,collections:N}),"rearrange"===B&&t.jsx(h.RearrangeScreen,{selectedCollections:re||{},selectedCollectionsDispatch:ce,setScreen:A,outOfStockAction:R,rearrangeViewType:"grid"===L?"list":"grid"}),"searchProducts"===B&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:re||{},searchedCollections:ee||{},selectedCollectionsDispatch:ce,setScreen:A,collections:N,onBackPress:()=>{J(""),te({})}})]})]})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as u}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as p}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{RearrangeScreen as g}from"./rearrangeScreen.js";import{collectionsReducer as C,selectedColectionsReducer as b,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as y,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";var x;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(x||(x={}));const k=k=>{const{storeId:I,selectedItems:O,onClose:R,visible:T,zIndex:D,limit:F,hideCollectionCheckbox:w,hideProductCheckbox:E,outOfStockAction:A=P.BLUR,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,hideSelectionCount:z,title:G,width:H,startupScreen:V=x.Collections,rearrangeEnabled:$}=k,[K,M]=r(C,{}),[U,Y]=s([x.Collections,x.RearrangeProducts].includes(V)?V:x.Collections),[q,J]=s("grid"),[N,Q]=s(""),[W,X]=s(0),[Z,_]=s(!1),[ee,te]=s(0),[oe,ce]=s(""),[re,se]=s(!1),[ie,ne]=s(!1),[le,de]=s(),[ae,ue]=r(b,Object.keys(O).length>0?O:{});i((()=>{_(!0),ne(!0),k.collectionFetcher(W,I).then((e=>{M({type:"fetched",data:(null==e?void 0:e.collections)||{}}),_(!1),X((e=>e+1)),ne(!1)})).catch()}),[]),i((()=>{let e=0;Object.keys(ae||[]).forEach((t=>{var o;Object.keys((null===(o=ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ae[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),te(e)})),i((()=>{var e;N&&!(null===(e=null==K?void 0:K[N])||void 0===e?void 0:e.products)&&(_(!0),k.productFetcher(N,I).then((e=>{Object.keys(e).length&&M({type:"productsFetched",data:{collectionId:N,products:e}}),_(!1)})).catch())}),[N]),i((()=>{const e=setTimeout((()=>{"rearrange"!==
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as u}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as p}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{RearrangeScreen as g}from"./rearrangeScreen.js";import{collectionsReducer as C,selectedColectionsReducer as b,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as y,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";var x;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(x||(x={}));const k=k=>{const{storeId:I,selectedItems:O,onClose:R,visible:T,zIndex:D,limit:F,hideCollectionCheckbox:w,hideProductCheckbox:E,outOfStockAction:A=P.BLUR,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,hideSelectionCount:z,title:G,width:H,startupScreen:V=x.Collections,rearrangeEnabled:$}=k,[K,M]=r(C,{}),[U,Y]=s([x.Collections,x.RearrangeProducts].includes(V)?V:x.Collections),[q,J]=s("grid"),[N,Q]=s(""),[W,X]=s(0),[Z,_]=s(!1),[ee,te]=s(0),[oe,ce]=s(""),[re,se]=s(!1),[ie,ne]=s(!1),[le,de]=s(),[ae,ue]=r(b,Object.keys(O).length>0?O:{});i((()=>{_(!0),ne(!0),k.collectionFetcher(W,I).then((e=>{M({type:"fetched",data:(null==e?void 0:e.collections)||{}}),_(!1),X((e=>e+1)),ne(!1)})).catch()}),[]),i((()=>{let e=0;Object.keys(ae||[]).forEach((t=>{var o;Object.keys((null===(o=ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ae[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),te(e)})),i((()=>{var e;N&&!(null===(e=null==K?void 0:K[N])||void 0===e?void 0:e.products)&&(_(!0),k.productFetcher(N,I).then((e=>{Object.keys(e).length&&M({type:"productsFetched",data:{collectionId:N,products:e}}),_(!1)})).catch())}),[N]),i((()=>{const e=setTimeout((()=>{"rearrange"!==U&&(oe.length?(se(!0),k.searchFetcher(I,oe).then((e=>{de(Object.assign({},e)),Y("searchProducts"),_(!1),se(!1)}))):Y("collections"))}),800);return()=>clearTimeout(e)}),[oe]);const he=()=>{ue({type:"reset",data:{}})};return e(a,Object.assign({zIndex:D,open:T,onClose:()=>{R(),he()},headingTitle:G||("collections"===U||"products"===U?"Select Products":"view"===U?"Selected Products":"searchProducts"===U?"Searched Products":"rearrange"===U?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"480px"},headerRightCustomElement:"rearrange"===U?(console.log("ignore:",J),e(t,{})):e(t,{}),primaryButton:{buttonText:Z?"Loading...":U===x.RearrangeProducts?"Done":"Add",disabled:Z||ee<1||F&&ee>F||!1,onClick:()=>{k.onAdd(ae,ee),he()}},footerLeftCustomElement:z?e(t,{}):F&&ee>F?e(h,{tagText:`You can only select ${F} products`,type:"negative"}):e(l,ee>0?{onClick:()=>{Y($?x.RearrangeProducts:x.SelectedProducts)},buttonText:`${ee} products selected`,buttonType:["rearrange","view"].includes(U)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(U)}:{disabled:!0,buttonText:`${ee} products selected`,buttonType:"tertiaryGray"})},{children:o(y,{children:[k.postHeader&&e("div",Object.assign({style:{padding:"0 24px"}},{children:k.postHeader})),!k.hideGlobalSearch&&e(t,{children:("collections"===U||"searchProducts"===U)&&e("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e(d,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>re?e(u,{size:"small",color:n.content.primary}):e(c,{})},id:"listInput",height:"24px",type:"text",value:oe,onChangeText:e=>{e.length&&e.trim().length?ce(e):ce("")}})}))}),o(j,{children:["collections"===U&&e(p,{customCollectionRestriction:k.customCollectionRestriction,dataLoading:ie,collections:K,selectedCollectionsDispatch:ue,setCollectionId:Q,setScreen:Y,selectedCollections:ae,collectionFetcher:k.collectionFetcher,storeId:I,collectionsDispatch:M,setSaveDisabled:_,pagingControls:{curPage:W,setCurPage:X},hideCollectionCheckbox:w}),"products"===U&&N&&e(v.Provider,Object.assign({value:N},{children:e(m,{hideInCollectionSearch:k.hideInCollectionSearch,customCollectionRestriction:k.customCollectionRestriction,productFetcher:k.productFetcher,setScreen:Y,storeId:I,data:K[N],collectionsDispatch:M,selectedCollectionsDispatch:ue,selectedData:ae,setSaveDisabled:_,searchInCollectionFetcher:k.searchInCollectionFetcher,hideProductCheckbox:E,outOfStockAction:A,hideVariantCheckbox:B,selectProductsFromCustomCollection:L})})),"view"===U&&e(f,{selectedCollections:ae||{},selectedCollectionsDispatch:ue,setScreen:Y,collections:K}),"rearrange"===U&&e(g,{selectedCollections:ae||{},selectedCollectionsDispatch:ue,setScreen:Y,outOfStockAction:A,rearrangeViewType:"grid"===q?"list":"grid"}),"searchProducts"===U&&e(S,{customCollectionRestriction:k.customCollectionRestriction,selectedCollections:ae||{},searchedCollections:le||{},selectedCollectionsDispatch:ue,setScreen:Y,collections:K,onBackPress:()=>{ce(""),de({})}})]})]})}))};export{k as ProductPickerModal,x as ScreenName};
|