1 line
5.7 KiB
JavaScript
1 line
5.7 KiB
JavaScript
import{A as e,B as t,C as n,G as r,T as i,b as ee,c as a,i as te,j as o,l as s,lt as c,m as l,o as u,p as d,r as f,s as p,u as m,x as h}from"./runtime-core.esm-bundler-BD0e4RlP.js";import{t as g}from"./runtime-dom.esm-bundler-CcSFQHoC.js";import{t as _}from"./Icon-BCRRMV3J.js";import{t as v}from"./IconButton-Cxmf-7_q.js";import{t as y}from"./i18n-DrTQks20.js";import{t as ne}from"./Badge-DcvgVKep.js";import{t as b}from"./products-GEWPSJSp.js";import"./api-S-LVXOcC.js";import{t as x}from"./Button-DkdaDkuf.js";import{t as S}from"./QuantityStepper-Bjh3X3wE.js";var C=[`aria-label`],w={class:`shrink-0 flex items-center justify-between px-6 py-5 border-b border-line`,style:{"padding-top":`calc(env(safe-area-inset-top) + 1.25rem)`}},T={class:`flex items-center gap-3 min-w-0`},E={class:`font-display text-2xl font-normal text-brand leading-none truncate`},D={class:`flex-1 overflow-y-auto`},O={key:0,class:`h-full flex flex-col items-center justify-center gap-4 px-8 py-16 text-center`},k={class:`w-16 h-16 rounded-full bg-brand-wash flex items-center justify-center text-brand`},A={class:`font-display text-xl text-brand`},j={class:`text-sm text-muted max-w-xs`},M={key:1,class:`divide-y divide-line`},N=[`href`],P=[`src`,`alt`],F={class:`flex-1 min-w-0 flex flex-col gap-2`},I={class:`flex items-start justify-between gap-3`},L={class:`min-w-0`},re={class:`text-[15px] font-semibold text-ink leading-tight truncate`},R={key:0,class:`text-[13px] text-muted mt-0.5 truncate`},z={class:`flex items-center justify-between gap-3`},B={class:`font-display text-lg text-brand tabular-nums`},V={key:0,class:`shrink-0 border-t border-line px-6 py-5 flex flex-col gap-4`,style:{"padding-bottom":`calc(env(safe-area-inset-bottom) + 1.25rem)`}},H={class:`flex items-baseline justify-between`},U={class:`eyebrow`},W={class:`font-display text-2xl text-brand tabular-nums`},G={class:`flex items-center gap-3`},K={__name:`CartDrawer`,props:{modelValue:{type:Boolean,default:!1},items:{type:Array,default:()=>[]},subtotal:{type:Number,default:0},count:{type:Number,default:0}},emits:[`update:modelValue`,`update-quantity`,`remove`,`checkout`],setup(K,{emit:q}){let J=K,Y=q,{t:X}=y(),Z=t(null);function Q(){Y(`update:modelValue`,!1)}function ie(e){e.key===`Escape`&&(e.preventDefault(),Q())}e(()=>J.modelValue,e=>{typeof document>`u`||(document.documentElement.style.overflow=e?`hidden`:``,e&&ee(()=>Z.value?.focus()))}),h(()=>{typeof document<`u`&&(document.documentElement.style.overflow=``)});let $=u(()=>J.items.length>0);function ae(e,t){Y(`update-quantity`,{productId:e.productId,quantity:t})}function oe(e){Y(`remove`,e.productId)}return(e,t)=>(n(),a(te,{to:`body`},[l(g,{"enter-active-class":`transition duration-base ease-out`,"enter-from-class":`opacity-0`,"enter-to-class":`opacity-100`,"leave-active-class":`transition duration-base ease-out`,"leave-from-class":`opacity-100`,"leave-to-class":`opacity-0`},{default:o(()=>[K.modelValue?(n(),m(`div`,{key:0,class:`fixed inset-0 z-[55] bg-ink/40`,"aria-hidden":`true`,onClick:Q})):s(``,!0)]),_:1}),l(g,{"enter-active-class":`transition-transform duration-slow ease-out`,"enter-from-class":`translate-x-full`,"enter-to-class":`translate-x-0`,"leave-active-class":`transition-transform duration-base ease-out`,"leave-from-class":`translate-x-0`,"leave-to-class":`translate-x-full`},{default:o(()=>[K.modelValue?(n(),m(`aside`,{key:0,ref_key:`panelRef`,ref:Z,tabindex:`-1`,role:`dialog`,"aria-modal":`true`,"aria-label":r(X)(`cart.label`),class:`fixed inset-y-0 right-0 z-[60] w-full md:max-w-[440px] bg-cream text-ink flex flex-col shadow-lg md:border-l md:border-line font-sans outline-none`,onKeydown:ie},[p(`header`,w,[p(`div`,T,[l(_,{name:`cart`,size:22,class:`text-brand shrink-0`}),p(`h2`,E,c(r(X)(`cart.label`)),1),K.count>0?(n(),a(ne,{key:0,variant:`subtle`,class:`shrink-0`},{default:o(()=>[d(c(K.count),1)]),_:1})):s(``,!0)]),l(v,{icon:`close`,variant:`ghost`,size:`sm`,"icon-size":20,"aria-label":r(X)(`menu.close`),onClick:Q},null,8,[`aria-label`])]),p(`div`,D,[$.value?(n(),m(`ul`,M,[(n(!0),m(f,null,i(K.items,e=>(n(),m(`li`,{key:e.productId,class:`flex gap-4 px-6 py-5`},[p(`a`,{href:e.product?.href||`#`,class:`shrink-0 w-20 h-20 rounded-sm overflow-hidden bg-paper flex items-center justify-center`},[e.product?.image?(n(),m(`img`,{key:0,src:e.product.image,alt:e.product.title,loading:`lazy`,decoding:`async`,class:`w-full h-full object-contain p-2`},null,8,P)):s(``,!0)],8,N),p(`div`,F,[p(`div`,I,[p(`div`,L,[p(`p`,re,c(e.product?.title),1),e.product?.size?(n(),m(`p`,R,c(e.product.size),1)):s(``,!0)]),l(v,{icon:`trash`,variant:`ghost`,size:`xs`,"icon-size":18,"aria-label":r(X)(`cart.remove`),class:`shrink-0`,onClick:t=>oe(e)},null,8,[`aria-label`,`onClick`])]),p(`div`,z,[l(S,{"model-value":e.quantity,min:0,"decrease-label":r(X)(`cart.qty.decrease`),"increase-label":r(X)(`cart.qty.increase`),"onUpdate:modelValue":t=>ae(e,t)},null,8,[`model-value`,`decrease-label`,`increase-label`,`onUpdate:modelValue`]),p(`span`,B,c(r(b)(e.lineTotal)),1)])])]))),128))])):(n(),m(`div`,O,[p(`div`,k,[l(_,{name:`cart`,size:28})]),p(`p`,A,c(r(X)(`cart.empty.title`)),1),p(`p`,j,c(r(X)(`cart.empty.subtitle`)),1),l(x,{variant:`secondary`,size:`md`,class:`mt-2`,onClick:Q},{default:o(()=>[d(c(r(X)(`ds.buttons.continueShopping`)),1)]),_:1})]))]),$.value?(n(),m(`footer`,V,[p(`div`,H,[p(`span`,U,c(r(X)(`cart.subtotal`)),1),p(`span`,W,c(r(b)(K.subtotal)),1)]),p(`div`,G,[l(x,{variant:`primary`,size:`lg`,block:``,class:`flex-1`,onClick:t[0]||=t=>e.$emit(`checkout`)},{after:o(()=>[l(_,{name:`arrow-right`,size:18})]),default:o(()=>[d(` `+c(r(X)(`cart.checkout`)),1)]),_:1}),l(v,{icon:`close`,variant:`brand-wash`,size:`lg`,"icon-size":20,"aria-label":r(X)(`menu.close`),class:`shrink-0 md:hidden`,onClick:Q},null,8,[`aria-label`])])])):s(``,!0)],40,C)):s(``,!0)]),_:1})]))}};export{K as t}; |