UNPKG

@lanaco/lnc-react-ui

Version:

React component library

89 lines (75 loc) 5.29 kB
"use strict";const t=require("react/jsx-runtime"),l=require("react"),K=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),p=require("./breakpoints-CcVm-gVm.cjs"),Q=require("./IconButton.cjs"),G=require("./Button.cjs"),s=require("./utils-BK6B_Y9X.cjs"),H=require("./useDetectMobile-DYV6V1yw.cjs"),g=require("./index-BLapl_Sv.cjs"),J=require("./index-RrqW9QBJ.cjs"),W=require("./index-D8dqelzt.cjs"),X=K.styled.div` display: flex; flex-direction: column; gap: 1.5rem; & .section__heading { display: flex; justify-content: space-between; } & .section__title { color: var(--gray-950, #14161a); font-weight: 600; font-size: 1.5rem; line-height: 2rem; letter-spacing: -0.0294rem; & i { font-size: 1.5rem; color: var(--primary-500, #f59e0b); } } & .section__options { & button { &:focus { outline: none; outline-offset: 0; } } } & .section__items { display: grid; grid-template-columns: ${r=>`repeat(${r.limit}, minmax(0, 1fr))`}; gap: 2rem; } @media ${p.down("M")} { & .section__items { grid-template-columns: repeat(6, minmax(0, 1fr)); } } & .section__show-more { color: var(--neutral-600, #0f2a46); font-size: 0.875rem; font-style: normal; font-weight: 500; line-height: 1.25rem; letter-spacing: -0.0056rem; width: 100%; max-width: 100%; align-self: center; &:focus { outline: none; } } & .section__view-all { white-space: nowrap; } @media ${p.down("S")} { gap: 1.25rem; & .section__items { display: flex; gap: 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; ::-webkit-scrollbar { -webkit-appearance: none; } -ms-overflow-style: none; /* Internet Explorer 10+ */ scrollbar-width: none; /* Firefox */ &::-webkit-scrollbar { display: none; /* Safari and Chrome */ } } } `,Y=l.memo(g.DetailedProductCard),Z=l.forwardRef((r,f)=>{const{title:c,icon:d,items:i,limit:b=4,isLoading:a=!1,onSelectCard:h=()=>{},onLoadMore:_=()=>{},onButtonAction:y=()=>{},getImage:S=()=>{},viewAllbuttonLink:u,viewAllButonText:m="View all",negotiableText:w,freeText:v,loadMoreButtonIcon:k="angle-down",sponsoredText:N,onBookmark:C=()=>{},actionComponent:j,componentName:q,hasNextPage:P=!1,LinkComponent:L,urgentText:B,options:o=[],isLoadingOptions:D=!1,selectedOption:M,onSelectOption:O=()=>{},onRemoveOption:T=()=>{},allOptionsEnabled:R=!1,allOptionsLabel:A="All",onSelectAllOptions:E=()=>{},optionLabel:I="label",optionValue:$="value",optionCode:z="code"}=r,F=H.useDetectMobile(),U=l.useMemo(()=>i==null?void 0:i.map((e,n)=>t.jsx(Y,{name:e==null?void 0:e.name,price:e==null?void 0:e.price,sellingPrice:e==null?void 0:e.sellingPrice,currency:e==null?void 0:e.currency,image:e==null?void 0:e.image,sellerUuid:e==null?void 0:e.sellerUuid,uuid:e==null?void 0:e.uuid,sponsored:e==null?void 0:e.sponsored,imageComponent:e==null?void 0:e.imageComponent,onSelectCard:(x,V)=>h({uuid:e==null?void 0:e.uuid,nameSlug:e==null?void 0:e.nameSlug,cardRef:V}),nameSlug:e==null?void 0:e.nameSlug,imageUrl:S(e==null?void 0:e.image,e==null?void 0:e.uuid,e==null?void 0:e.sellerUuid)||null,isFree:e==null?void 0:e.isFree,isNegotiable:e==null?void 0:e.isNegotiable,negotiableText:w,freeText:v,tags:e==null?void 0:e.tags,categoryCode:e==null?void 0:e.categoryCode,condition:e==null?void 0:e.condition,quantity:e==null?void 0:e.quantity,hasQuantities:e==null?void 0:e.hasQuantities,status:e==null?void 0:e.status,trade:e==null?void 0:e.trade,sponsoredText:N,onBookmark:C,actionComponent:j,bookmarked:e==null?void 0:e.bookmarked,bookmarkLists:e==null?void 0:e.bookmarkLists,metadata:{accessor:e==null?void 0:e.accessor,name:q},sellerName:e==null?void 0:e.sellerName,forCart:e==null?void 0:e.forCart,forOrder:e==null?void 0:e.forOrder,contactSeller:e==null?void 0:e.contactSeller,hasVariants:e==null?void 0:e.hasVariants,LinkComponent:L,activeSalesPackages:e==null?void 0:e.activeSalesPackages,urgentText:B,hasFreeShipping:e==null?void 0:e.hasFreeShipping},n)),[i]);return t.jsxs(X,{ref:f,limit:b,className:"lp-section lp-detailed-products-infinitive-section",children:[t.jsxs("div",{className:"section__heading",children:[s.isDefinedNotEmptyString(c)&&t.jsxs("div",{className:"section__title",children:[s.isDefinedNotEmptyString(d)&&t.jsx("i",{className:d})," ",c]}),s.isDefinedNotEmptyString(u)&&s.isDefinedNotEmptyString(m)&&!a&&t.jsx(G,{type:"button",btnType:"tinted",color:"neutral",onClick:e=>{var n;(n=e==null?void 0:e.target)==null||n.blur(),y(u)},borderRadius:"curved",className:"section__view-all",children:m})]}),t.jsx(W.SuspenseSelectBar,{isLoading:D,children:o&&(o==null?void 0:o.length)>0&&t.jsx(J.SelectBar,{items:o,selectedIds:M,onRemove:T,onSelect:O,allButton:R,onSelectAll:E,labelKey:I,valueKey:$,codeKey:z,noMargin:!0,productsToolbarName:A,noGradient:!0,className:"section__options"})}),t.jsx(g.SuspenseDetailedProductCard,{isLoading:a,keyPrefix:"detailed-product-card-skeleton",children:t.jsx("div",{className:"section__items",children:U})}),!F&&!a&&P&&t.jsx(Q,{icon:k,borderRadius:"curved",btnType:"basic",color:"neutral",className:"section__show-more",onClick:_})]})});module.exports=Z;