efficient-storefront-blocks 0.97.0 → 0.99.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.
- package/CHANGELOG.md +61 -0
- package/dist/chunks/EditorPreviewCheckout-J76THKIJ.js +4 -0
- package/dist/chunks/{SiteEditorProvider-VZUU5OPZ.js → SiteEditorProvider-YAIB64UV.js} +1 -1
- package/dist/chunks/chunk-B2IYTOE3.js +1 -0
- package/dist/chunks/chunk-EIBYUCDE.js +1 -0
- package/dist/chunks/chunk-GOVYQQA4.js +1 -0
- package/dist/chunks/chunk-KRMWJLBM.js +412 -0
- package/dist/chunks/{fitment-data-MCGKHSA4.js → fitment-data-OUHMES66.js} +1 -1
- package/dist/consent.js +1 -1
- package/dist/contract.js +11 -3
- package/dist/editor/components/EditorPreviewCheckout.js +1 -1
- package/dist/editor/components/GalleryShowcaseSource.js +1 -1
- package/dist/editor/components/HeaderSettingsPanel.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/Collections/fields.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/SearchBlock/fields.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/SpecTable/fields.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/WheelDiagram/fields.d.ts +2 -0
- package/dist/editor/lib/document/blocks/commerce/WheelDiagram/fields.js +1 -0
- package/dist/editor/lib/document/blocks/commerce/index.d.ts +1 -1
- package/dist/editor/lib/document/blocks/commerce/index.js +1 -1
- package/dist/editor/lib/document/blocks/service/BookingBox/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/ContactCards/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/SiteHeader/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/SubmitBox/fields.js +1 -1
- package/dist/editor/lib/document/box-header-for-site.d.ts +5 -0
- package/dist/editor/lib/document/box-header-for-site.js +1 -1
- package/dist/editor/lib/document/box-header.d.ts +2 -0
- package/dist/editor/lib/document/box-header.js +1 -1
- package/dist/editor/lib/document/config.d.ts +1 -0
- package/dist/editor/lib/document/config.js +1 -1
- package/dist/editor/lib/document/popup-look-fields.d.ts +1 -0
- package/dist/editor/lib/document/popup-look-fields.js +1 -1
- package/dist/editor/lib/document/text-kind-style-rows.d.ts +5 -0
- package/dist/editor/lib/document/text-kind-style-rows.js +1 -0
- package/dist/editor/lib/efficient-block-sources.js +1 -1
- package/dist/editor/lib/header-settings-source.js +1 -1
- package/dist/editor/lib/storefront-editor-words.d.ts +6 -3
- package/dist/editor/lib/storefront-editor-words.js +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +212 -44
- package/dist/links.js +1 -1
- package/dist/render/app/globals.css +136 -12
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/BundleCard.js +1 -1
- package/dist/render/components/CatalogFilterBarSection.js +1 -1
- package/dist/render/components/ChatWidget.js +1 -1
- package/dist/render/components/CollectionCard.d.ts +3 -0
- package/dist/render/components/CollectionCard.js +1 -1
- package/dist/render/components/Collections.d.ts +2 -1
- package/dist/render/components/Collections.js +1 -1
- package/dist/render/components/CompatibleTyres.js +1 -1
- package/dist/render/components/CountrySelect.js +1 -1
- package/dist/render/components/CurrencyContext.d.ts +3 -0
- package/dist/render/components/CurrencyContext.js +1 -1
- package/dist/render/components/FooterGroup.js +1 -1
- package/dist/render/components/FooterLogo.js +1 -1
- package/dist/render/components/FooterMenu.d.ts +5 -3
- package/dist/render/components/FooterMenu.js +1 -1
- package/dist/render/components/FooterPayment.js +1 -1
- package/dist/render/components/FooterSection.js +1 -1
- package/dist/render/components/FooterSocial.js +1 -1
- package/dist/render/components/FooterText.js +1 -1
- package/dist/render/components/FormBlock.d.ts +4 -1
- package/dist/render/components/FormBlock.js +1 -1
- package/dist/render/components/Header.js +1 -1
- package/dist/render/components/HeaderToolBlocks.d.ts +4 -2
- package/dist/render/components/HeaderToolBlocks.js +1 -1
- package/dist/render/components/HeaderTools.d.ts +7 -2
- package/dist/render/components/HeaderTools.js +1 -1
- package/dist/render/components/PhoneSheet.d.ts +16 -0
- package/dist/render/components/PhoneSheet.js +1 -0
- package/dist/render/components/PreOrderPanel.js +1 -1
- package/dist/render/components/ProductGridSection.js +1 -1
- package/dist/render/components/ProductRef.js +1 -1
- package/dist/render/components/SectionGroupBody.d.ts +2 -1
- package/dist/render/components/SectionGroupBody.js +1 -1
- package/dist/render/components/SpecTable.d.ts +2 -1
- package/dist/render/components/SpecTable.js +1 -1
- package/dist/render/components/Subscribe.d.ts +1 -0
- package/dist/render/components/Subscribe.js +1 -1
- package/dist/render/components/WheelCardFrame.js +1 -1
- package/dist/render/components/WheelDiagram.d.ts +16 -0
- package/dist/render/components/WheelDiagram.js +1 -0
- package/dist/render/components/card-pieces/CardName.js +1 -1
- package/dist/render/components/card-pieces/CardPrice.js +1 -1
- package/dist/render/components/card-pieces/CardSurfaceFrame.d.ts +1 -1
- package/dist/render/components/card-pieces/ProductCardState.d.ts +1 -0
- package/dist/render/components/card-pieces/ProductCardState.js +1 -1
- package/dist/render/components/catalog/CatalogFilterBar.d.ts +5 -1
- package/dist/render/components/catalog/CatalogFilterBar.js +1 -1
- package/dist/render/components/catalog/CatalogFilterContext.d.ts +2 -0
- package/dist/render/components/catalog/CatalogFilterContext.js +1 -1
- package/dist/render/components/catalog/FilterPill.js +1 -1
- package/dist/render/components/catalog/PriceRange.d.ts +6 -1
- package/dist/render/components/catalog/PriceRange.js +1 -1
- package/dist/render/components/catalog/ShopperFilters.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +5 -0
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/components/fitment/PickerField.js +1 -1
- package/dist/render/components/formSubmission.d.ts +4 -2
- package/dist/render/components/formSubmission.js +1 -1
- package/dist/render/components/pdp-dynamic/DynamicSpecTable.js +1 -1
- package/dist/render/components/pdp-dynamic/DynamicWheelDiagram.d.ts +6 -0
- package/dist/render/components/pdp-dynamic/DynamicWheelDiagram.js +1 -0
- package/dist/render/components/pdp-dynamic/KindGate.d.ts +2 -1
- package/dist/render/components/pdp-dynamic/KindGate.js +1 -1
- package/dist/render/components/submit/SubmitRegions.js +1 -1
- package/dist/render/components/wheels-plp/AlloyWheelsListing.js +1 -1
- package/dist/render/components/wheels-plp/PlpActiveChips.d.ts +2 -1
- package/dist/render/components/wheels-plp/PlpActiveChips.js +1 -1
- package/dist/render/components/wheels-plp/PlpSidebar.d.ts +15 -7
- package/dist/render/components/wheels-plp/PlpSidebar.js +1 -1
- package/dist/render/components/wheels-plp/useVehicleCatalog.d.ts +6 -1
- package/dist/render/components/wheels-plp/useVehicleCatalog.js +1 -1
- package/dist/render/lib/api/index.d.ts +4 -1
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/booking/text-kinds.js +1 -1
- package/dist/render/lib/checkout/pay-first.d.ts +1 -0
- package/dist/render/lib/checkout/pay-first.js +1 -1
- package/dist/render/lib/consent/rules.js +1 -1
- package/dist/render/lib/content/article-page-seed.js +1 -1
- package/dist/render/lib/content/collection-card-look.d.ts +13 -0
- package/dist/render/lib/content/collection-card-look.js +1 -0
- package/dist/render/lib/content/menu-row.d.ts +16 -0
- package/dist/render/lib/content/menu-row.js +1 -1
- package/dist/render/lib/content/text-kind-vars.d.ts +4 -0
- package/dist/render/lib/content/text-kind-vars.js +1 -0
- package/dist/render/lib/countries.js +1 -1
- package/dist/render/lib/document/blocks/commerce/Collections/meta.d.ts +4 -0
- package/dist/render/lib/document/blocks/commerce/Collections/meta.js +1 -1
- package/dist/render/lib/document/blocks/commerce/Collections/render.js +1 -1
- package/dist/render/lib/document/blocks/commerce/SearchBlock/render.js +1 -1
- package/dist/render/lib/document/blocks/commerce/WheelDiagram/meta.d.ts +2 -0
- package/dist/render/lib/document/blocks/commerce/WheelDiagram/meta.js +1 -0
- package/dist/render/lib/document/blocks/commerce/WheelDiagram/render.d.ts +2 -0
- package/dist/render/lib/document/blocks/commerce/WheelDiagram/render.js +1 -0
- package/dist/render/lib/document/blocks/commerce/metas.d.ts +1 -0
- package/dist/render/lib/document/blocks/commerce/metas.js +1 -1
- package/dist/render/lib/document/blocks/commerce/renders.d.ts +1 -0
- package/dist/render/lib/document/blocks/commerce/renders.js +1 -1
- package/dist/render/lib/document/blocks/service/SiteHeader/render.js +1 -1
- package/dist/render/lib/document/card-templates.d.ts +2 -0
- package/dist/render/lib/document/card-templates.js +1 -1
- package/dist/render/lib/document/current-record.js +1 -1
- package/dist/render/lib/document/footer-page-blocks.js +1 -1
- package/dist/render/lib/document/lazy-draws.js +1 -1
- package/dist/render/lib/document/render-config.d.ts +4 -0
- package/dist/render/lib/document/render-config.js +1 -1
- package/dist/render/lib/document/section-to-box-rows-collections.d.ts +1 -0
- package/dist/render/lib/document/section-to-box-rows-collections.js +1 -0
- package/dist/render/lib/document/section-to-box-rows-service.js +1 -1
- package/dist/render/lib/document/section-to-box-rows-spec.js +1 -1
- package/dist/render/lib/document/template-product-kind.d.ts +1 -0
- package/dist/render/lib/document/template-product-kind.js +1 -1
- package/dist/render/lib/next-fonts.js +1 -1
- package/dist/render/lib/popup/text-kind-style.js +1 -1
- package/dist/render/lib/sections/gallery-toolbar.js +1 -1
- package/dist/render/lib/storefront-page-groups.js +1 -1
- package/dist/render/lib/submit/text-kinds.js +1 -1
- package/dist/render/lib/wheels/catalog-filters-to-listing.d.ts +1 -1
- package/dist/render/lib/wheels/catalog-filters-to-listing.js +1 -1
- package/dist/render/lib/wheels/fitments.js +1 -1
- package/dist/render/lib/wheels/plp-filters.d.ts +5 -0
- package/dist/render/lib/wheels/plp-filters.js +1 -1
- package/dist/render/lib/wheels/price-display.d.ts +5 -1
- package/dist/render/lib/wheels/price-display.js +1 -1
- package/dist/render/lib/wheels/wheel-sheet.d.ts +3 -0
- package/dist/render/lib/wheels/wheel-sheet.js +1 -0
- package/dist/render/lib/wheels/wheel-specs.js +1 -1
- package/dist/words.d.ts +13 -3
- package/dist/words.js +4 -4
- package/package.json +5 -4
- package/dist/chunks/EditorPreviewCheckout-O7F36ZXB.js +0 -4
- package/dist/chunks/chunk-AOZEO73W.js +0 -401
- package/dist/chunks/chunk-MXWQOFM6.js +0 -1
- package/dist/chunks/chunk-NYEB6V2R.js +0 -1
- package/dist/chunks/chunk-SQ62RGWV.js +0 -1
- /package/dist/chunks/{chunk-AOZEO73W.js.LEGAL.txt → chunk-KRMWJLBM.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-UFEEFZ5M.js → chunk-QP2F42DV.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as l}from"react/jsx-runtime";import{createContext as O,useCallback as z,useContext as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{createContext as O,useCallback as z,useContext as P,useMemo as A,useState as y}from"react";import{useCurrency as S}from"../CurrencyContext.js";import{useTyreDetail as B}from"../useTyreDetail.js";import{usePlpCardSelection as L}from"../wheels-plp/usePlpCardSelection.js";import{tyrePagePath as N}from"../../lib/tyres/tyre-page-path.js";import{canOrderTyreVariant as W}from"../../lib/tyres/tyre-purchase.js";import{resolveSelectionPrice as D}from"../../lib/wheels/price-display.js";import{setBuildLabel as T,setIsWide as j,summarySetBuild as E}from"../../lib/wheels/set-mode.js";function J(e,r=null){return{brand:e.brand,brandLogo:e.brandLogo,name:e.name,treadPattern:e.treadPattern,slug:e.slug,sizes:e.sizes,fitSize:r,rimDiameters:e.rimDiameters,prices:e.prices,image:e.coverImage}}const n=O(null);function K(){const e=P(n);return e?.kind==="hero"?e:null}function Q({value:e,children:r}){return l(n.Provider,{value:e,children:r})}function H(){const e=P(n);if(!e||e.kind==="hero")throw new Error("A product card piece was drawn outside a product card (no ProductCardState).");return e}function X(){const e=P(n);return e?.kind==="hero"?null:e}function Y(){const e=H();if(e.kind!=="wheel")throw new Error(`A wheel card piece was drawn on a ${e.kind} card.`);return e}const I=[];function Z({wheel:e,colours:r=I,defaultFinish:o,editing:a=!1,children:s}){const{currency:t}=S(),c=L(e,r,o),[p,f]=y(!1),d=E(e),u={kind:"wheel",wheel:e,sel:c,currency:t,price:D(e,c.selectedVariant,t,1),isSet:j(d),setWords:T(d),editing:a,notifyOpen:p,setNotifyOpen:f};return l(n.Provider,{value:u,children:s})}function ee({bundle:e,children:r}){const{currency:o}=S(),a={kind:"bundle",bundle:e,currency:o};return l(n.Provider,{value:a,children:r})}function re({tyre:e,currency:r,editing:o=!1,children:a}){const{currency:s}=S(),{slug:t}=e,c=N(t),[p,f]=y(!1),d=z(()=>{t&&f(!0)},[t]),{state:u,tyre:m}=B(t??null,p),i=A(()=>m?.variants??[],[m]),[x,g]=y(null),k=i.length===1?i[0].size:null,C=x??k,v=i.find(w=>w.size===C),h=u==="ready",b={kind:"tyre",tyre:e,currency:r??s,activeCurrency:s,pagePath:c,arm:d,detailState:u,detail:m,variants:i,chosen:C,setSize:g,variant:v,canAdd:v!=null&&W(v,s),detailReady:h,unsellable:!c||u==="error"||h&&i.length===0,editing:o};return l(n.Provider,{value:b,children:a})}export{ee as BundleCardStateProvider,Q as HeroStateProvider,re as TyreCardStateProvider,Z as WheelCardStateProvider,J as tyreCardProduct,K as useHeroStateOrNull,H as useProductCardState,X as useProductCardStateOrNull,Y as useWheelCardState};
|
|
@@ -27,6 +27,10 @@ export interface CatalogFilterBarProps {
|
|
|
27
27
|
lugOptions?: readonly number[];
|
|
28
28
|
sizeOptions?: readonly number[];
|
|
29
29
|
finishOptions?: readonly string[];
|
|
30
|
+
priceBounds?: {
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
} | null;
|
|
30
34
|
scrollProcess: string | null;
|
|
31
35
|
show?: FilterBarVisibility;
|
|
32
36
|
picker?: CatalogVehicleControl;
|
|
@@ -52,4 +56,4 @@ export declare function filterBarFacetsWithChoice({ processCount, sizeCount, lug
|
|
|
52
56
|
lugs: boolean;
|
|
53
57
|
finish: boolean;
|
|
54
58
|
};
|
|
55
|
-
export default function CatalogFilterBar({ filters, setProcess, setSize, setLugs, setFinish, setPriceMin, setPriceMax, setSort, clearAll, total, scrollProcess, show, picker, lugOptions, sizeOptions, finishOptions, layout, processOptions, resultsLink, optionsReported, fieldUsage, }: CatalogFilterBarProps): import("react").JSX.Element;
|
|
59
|
+
export default function CatalogFilterBar({ filters, setProcess, setSize, setLugs, setFinish, setPriceMin, setPriceMax, setSort, clearAll, total, scrollProcess, show, picker, lugOptions, sizeOptions, finishOptions, priceBounds, layout, processOptions, resultsLink, optionsReported, fieldUsage, }: CatalogFilterBarProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as i,Fragment as he}from"react/jsx-runtime";import{useState as Q}from"react";import{withRMark as W}from"efficient-web-builder/render/components/RMark";import{FilterPill as L,OptButton as X,PanelTitle as R,PillButton as fe}from"./FilterPill.js";import{useCatalogFilterLabels as ge}from"./CatalogFilterLabels.js";import{CatalogVehicleNextRow as xe,CatalogVehicleFieldRow as be,CatalogVehicleRow as ee,CatalogVehicleSheet as ve}from"./CatalogVehiclePicker.js";import{facetFieldKey as le,keepForFilter as Ce,orderByAnswers as Ne}from"../../lib/content/field-usage.js";import{PLP_ONE_VALUE_MAX as re}from"../../lib/wheels/plp-filters.js";import{DEFAULT_FILTER_BAR_LAYOUT as ke}from"../../lib/sections/catalog-filter-layout.js";import{SORT_LABELS as G}from"../../lib/wheels/catalog-filters.js";import{FINISH_FAMILY_SWATCHES as ie}from"../../lib/wheels/finish-defaults.js";import{VEHICLE_FIELD_ORDER as ye}from"../../lib/wheels/vehicle-field-focus.js";import{CONTENT_CAP_GUTTER as ne}from"../../lib/sections/content-cap-gutter.js";import{CATALOG_TEXT_SIZE as _e}from"../../lib/sections/catalog-text-size.js";import{lugFilterLabel as ae}from"../../lib/wheels/lug-count.js";import Fe from"./PriceRange.js";import oe from"./SortSelect.js";const f=_e,te=Object.keys(G),H={size:le("diameters","alloy-wheel"),finish:le("finishes","alloy-wheel")};function ce(t,o){return Ne(t,c=>H[String(c.key)],o??[],"filterOrder")}function Te({processCount:t,sizeCount:o,lugCount:c,finishCount:d,optionsReported:g,fieldUsage:w}){const x=$=>!g||$>re,y=Ce(w??[]);return{process:t>re,size:y(H.size)&&x(o),lugs:x(c),finish:y(H.finish)&&x(d)}}function N(t,o){return t===o?null:o}function se({href:t,label:o}){return e("a",{href:t,"data-results-link":!0,className:`inline-block self-start border-0 border-b border-line bg-transparent pb-2 font-mono ${f.labelLarge} uppercase tracking-[0.2em] text-fg transition-colors hover:text-fg-dim`,children:o})}function Ae({filters:t,setProcess:o,setSize:c,setLugs:d,setFinish:g,setPriceMin:w,setPriceMax:x,setSort:y,clearAll:$,total:b,scrollProcess:Y,show:u,picker:s,lugOptions:B=[],sizeOptions:M=[],finishOptions:q,layout:de=ke,processOptions:I=[],resultsLink:v,optionsReported:ue=!1,fieldUsage:j}){const[m,h]=Q(null),[K,P]=Q(null),p=ge(),{process:_,size:F,lugs:T,finish:O,priceMin:V,priceMax:D,sort:Z}=t,U=q?ie.filter(r=>q.includes(r.f)):ie,S=Te({processCount:I.length,sizeCount:M.length,lugCount:B.length,finishCount:U.length,optionsReported:ue,fieldUsage:j}),n={process:(u?.process??!0)&&S.process,size:(u?.size??!0)&&S.size,lugs:(u?.lugs??!0)&&S.lugs,finish:(u?.finish??!0)&&S.finish,price:u?.price??!0,vehicle:(u?.vehicle??!0)&&!!s,count:u?.count??!0,sort:u?.sort??!0},C={process:_?1:0,size:F?1:0,lugs:T?1:0,finish:O?1:0,price:V!=null||D!=null?1:0,vehicle:s?.appliedName?1:0},J=()=>{$(),s?.clear(),h(null),P(null)};if(de==="columns"){const r=l=>P(K===l?null:l),a=[];n.vehicle&&s&&a.push(i(k,{name:"vehicle",label:p.vehicle,children:[ye.map(l=>e(be,{field:l,picker:s,open:K===l,onOpenRequest:r,onClose:()=>P(null)},l)),e(xe,{picker:s,onOpenRequest:r})]},"vehicle"));const E=[];return n.process&&E.push(e(k,{name:"process",label:p.process,rowsAreOptions:!0,children:I.map(l=>e(z,{active:_===l,onClick:()=>o(N(_,l)),children:W(l)},l))},"process")),n.size&&E.push(e(k,{name:"size",label:p.size,rowsAreOptions:!0,children:M.map(l=>i(z,{active:F===l,onClick:()=>c(N(F,l)),children:[l,'"']},l))},"size")),n.lugs&&E.push(e(k,{name:"lugs",label:p.lugs,rowsAreOptions:!0,children:B.map(l=>e(z,{active:T===l,onClick:()=>d(N(T,l)),children:ae(l)},l))},"lugs")),n.finish&&E.push(e(k,{name:"finish",label:p.finish,rowsAreOptions:!0,children:U.map(l=>e(z,{active:O===l.f,onClick:()=>g(O===l.f?null:l.f),children:l.label},l.f))},"finish")),a.push(...ce(E,j)),n.price&&a.push(i(k,{name:"price",label:p.price,children:[e(pe,{label:"Min",value:V,onChange:w,ariaLabel:"Minimum price per wheel"}),e(pe,{label:"Max",value:D,onChange:x,ariaLabel:"Maximum price per wheel"})]},"price")),i("div",{className:"@container",children:[i("div",{className:`border-t border-line ${ne} pb-12 pt-10 @max-[720px]:px-4 @max-[720px]:pb-10 @max-[720px]:pt-8`,children:[(n.count||n.sort)&&i("div",{className:"mb-10 flex flex-wrap items-center gap-x-6 gap-y-3 @max-[720px]:mb-8",children:[n.count&&i("span",{className:`font-mono ${f.labelLarge} uppercase tracking-[0.2em] text-fg-dim`,children:[b," ",b===1?"result":"results"]}),n.sort&&i("div",{className:"ml-auto flex items-center gap-5",children:[e("button",{type:"button",onClick:J,className:`font-mono ${f.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-fg`,children:"Clear All"}),e(oe,{look:"line",value:Z,keys:te,labels:G,onChange:y})]})]}),e("div",{"data-filter-columns":!0,className:`grid grid-cols-1 gap-x-[72px] gap-y-10 ${Ee[a.length]??""}`,children:a}),v&&e("div",{className:"mt-10 flex",children:e(se,{href:v.href,label:v.label})})]}),n.vehicle&&s&&e(ee,{picker:s,total:b})]})}const A=[];return n.process&&A.push(i(L,{name:"process",label:Y?i(he,{children:[e("span",{className:"text-accent @min-[720px]:hidden",children:W(Y)}),e("span",{className:"hidden @min-[720px]:inline",children:p.process})]}):p.process,badge:C.process,open:m==="process",onToggle:()=>h(m==="process"?null:"process"),children:[e(R,{children:"Series · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Process series",children:I.map(r=>{const a=_===r;return e(X,{active:a,role:"radio",ariaChecked:a,onClick:()=>o(N(_,r)),children:W(r)},r)})})]},"process")),n.size&&A.push(i(L,{name:"size",label:p.size,badge:C.size,open:m==="size",onToggle:()=>h(m==="size"?null:"size"),children:[e(R,{children:"Diameter · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Wheel diameter",children:M.map(r=>{const a=F===r;return i(X,{active:a,role:"radio",ariaChecked:a,onClick:()=>c(N(F,r)),children:[r,'"']},r)})})]},"size")),n.lugs&&A.push(i(L,{name:"lugs",label:p.lugs,badge:C.lugs,open:m==="lugs",onToggle:()=>h(m==="lugs"?null:"lugs"),children:[e(R,{children:"Lug count · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Lug count",children:B.map(r=>{const a=T===r;return e(X,{active:a,role:"radio",ariaChecked:a,onClick:()=>d(N(T,r)),children:ae(r)},r)})})]},"lugs")),n.finish&&A.push(i(L,{name:"finish",label:p.finish,badge:C.finish,open:m==="finish",onToggle:()=>h(m==="finish"?null:"finish"),children:[e(R,{children:"Color family · single-select"}),e("div",{className:"flex flex-col gap-2",role:"radiogroup","aria-label":"Finish color family",children:U.map(r=>{const a=O===r.f;return i("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>g(a?null:r.f),className:["flex items-center gap-3 border px-3 py-2 text-left transition-colors",a?"border-accent text-fg":"border-line hover:border-fg-dim"].join(" "),children:[e("span",{className:"block h-3.5 w-3.5 shrink-0 rounded-full border border-line",style:{background:r.hex}}),e("span",{className:`font-mono ${f.labelSmall} uppercase tracking-[0.18em]`,style:a?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"},children:r.label}),a&&e("span",{"aria-hidden":!0,className:"ml-auto text-accent",children:"●"})]},r.f)})})]},"finish")),i("div",{className:"@container sticky top-[67px] z-40 border-b border-line backdrop-blur",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[i("div",{className:`flex items-center gap-6 ${ne} py-4 @max-[720px]:flex-wrap @max-[720px]:items-stretch @max-[720px]:gap-2 @max-[720px]:px-4 @max-[720px]:py-3`,children:[i("div",{className:"flex flex-wrap items-center gap-1 @max-[720px]:basis-full @max-[720px]:gap-2",children:[n.count&&i("span",{className:`mr-3 border-r border-line pr-4 font-mono ${f.labelLarge} uppercase tracking-[0.2em] text-fg-dim @max-[720px]:hidden`,children:[b," ",b===1?"result":"results"]}),ce(A,j),n.price&&i(L,{name:"price",label:p.price,badge:C.price,open:m==="price",onToggle:()=>h(m==="price"?null:"price"),children:[e(R,{children:"Price range (per wheel)"}),e(Fe,{min:V,max:D,onMin:w,onMax:x})]}),n.vehicle&&s&&e(fe,{label:p.vehicle,badge:C.vehicle,open:m==="vehicle",onToggle:()=>h(m==="vehicle"?null:"vehicle")})]}),v&&e("div",{className:`flex items-center ${n.sort?"":"ml-auto"}`,children:e(se,{href:v.href,label:v.label})}),n.sort&&i("div",{className:"ml-auto flex items-center gap-3",children:[e("button",{type:"button",onClick:J,className:`font-mono ${f.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-accent`,children:"Clear All"}),e(oe,{look:"box",value:Z,keys:te,labels:G,onChange:y})]})]}),n.vehicle&&s&&m==="vehicle"&&e(ve,{picker:s,onClose:()=>h(null)}),n.vehicle&&s&&e(ee,{picker:s,total:b})]})}const Ee={1:"@min-[720px]:grid-cols-1",2:"@min-[720px]:grid-cols-2",3:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3",4:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-4",5:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3 @min-[1400px]:grid-cols-5",6:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3 @min-[1400px]:grid-cols-6"},me=`flex w-full items-center justify-between gap-4 border-b py-3 text-left ${f.body}`;function k({name:t,label:o,rowsAreOptions:c,children:d}){return i("div",{"data-filter-column":t,className:"flex flex-col gap-6",children:[e("div",{className:`font-mono ${f.labelXs} uppercase tracking-[0.34em] text-fg-dim`,children:o}),e("div",{role:c?"radiogroup":void 0,"aria-label":c?o:void 0,children:d})]})}function z({active:t,onClick:o,children:c}){return e("button",{type:"button",role:"radio","aria-checked":t,onClick:o,className:[me,"transition-colors",t?"border-fg text-fg":"border-line text-fg-dim hover:text-fg"].join(" "),children:e("span",{children:c})})}function pe({label:t,value:o,onChange:c,ariaLabel:d}){return i("label",{className:`${me} border-line`,children:[e("span",{className:"text-fg-dim",children:t}),e("input",{type:"number",inputMode:"numeric","aria-label":d,placeholder:"Any",value:o??"",onChange:g=>c(g.target.value?Number(g.target.value):null),className:"w-24 bg-transparent text-right text-fg outline-none placeholder:text-fg-dim"})]})}export{Ae as default,Te as filterBarFacetsWithChoice};
|
|
1
|
+
"use client";import{jsx as e,jsxs as n,Fragment as he}from"react/jsx-runtime";import{useState as ee}from"react";import{withRMark as X}from"efficient-web-builder/render/components/RMark";import{FilterPill as R,OptButton as G,PanelTitle as L,PillButton as fe}from"./FilterPill.js";import{useCatalogFilterLabels as ge}from"./CatalogFilterLabels.js";import{CatalogVehicleNextRow as xe,CatalogVehicleFieldRow as be,CatalogVehicleRow as le,CatalogVehicleSheet as ve}from"./CatalogVehiclePicker.js";import{facetFieldKey as ie,keepForFilter as Ce,orderByAnswers as Ne}from"../../lib/content/field-usage.js";import{PLP_ONE_VALUE_MAX as re}from"../../lib/wheels/plp-filters.js";import{DEFAULT_FILTER_BAR_LAYOUT as ke}from"../../lib/sections/catalog-filter-layout.js";import{SORT_LABELS as H}from"../../lib/wheels/catalog-filters.js";import{FINISH_FAMILY_SWATCHES as ne}from"../../lib/wheels/finish-defaults.js";import{VEHICLE_FIELD_ORDER as ye}from"../../lib/wheels/vehicle-field-focus.js";import{CONTENT_CAP_GUTTER as ae}from"../../lib/sections/content-cap-gutter.js";import{CATALOG_TEXT_SIZE as _e}from"../../lib/sections/catalog-text-size.js";import{lugFilterLabel as oe}from"../../lib/wheels/lug-count.js";import se from"./PriceRange.js";import ce from"./SortSelect.js";const h=_e,te=Object.keys(H),z={size:ie("diameters","alloy-wheel"),finish:ie("finishes","alloy-wheel")};function pe(s,o){return Ne(s,d=>Object.hasOwn(z,String(d.key))?z[String(d.key)]:void 0,o??[],"filterOrder")}function Fe({processCount:s,sizeCount:o,lugCount:d,finishCount:f,optionsReported:g,fieldUsage:O}){const x=B=>!g||B>re,y=Ce(O??[]);return{process:s>re,size:y(z.size)&&x(o),lugs:x(d),finish:y(z.finish)&&x(f)}}function N(s,o){return s===o?null:o}function de({href:s,label:o}){return e("a",{href:s,"data-results-link":!0,className:`inline-block self-start border-0 border-b border-line bg-transparent pb-2 font-mono ${h.labelLarge} uppercase tracking-[0.2em] text-fg transition-colors hover:text-fg-dim`,children:o})}function Te({filters:s,setProcess:o,setSize:d,setLugs:f,setFinish:g,setPriceMin:O,setPriceMax:x,setSort:y,clearAll:B,total:b,scrollProcess:Y,show:m,picker:c,lugOptions:I=[],sizeOptions:j=[],finishOptions:q,priceBounds:K=null,layout:me=ke,processOptions:M=[],resultsLink:v,optionsReported:ue=!1,fieldUsage:P}){const[t,u]=ee(null),[Z,V]=ee(null),p=ge(),{process:_,size:F,lugs:T,finish:w,priceMin:D,priceMax:U,sort:J}=s,W=q?ne.filter(i=>q.includes(i.f)):ne,S=Fe({processCount:M.length,sizeCount:j.length,lugCount:I.length,finishCount:W.length,optionsReported:ue,fieldUsage:P}),r={process:(m?.process??!0)&&S.process,size:(m?.size??!0)&&S.size,lugs:(m?.lugs??!0)&&S.lugs,finish:(m?.finish??!0)&&S.finish,price:m?.price??!0,vehicle:(m?.vehicle??!0)&&!!c,count:m?.count??!0,sort:m?.sort??!0},C={process:_?1:0,size:F?1:0,lugs:T?1:0,finish:w?1:0,price:D!=null||U!=null?1:0,vehicle:c?.appliedName?1:0},Q=()=>{B(),c?.clear(),u(null),V(null)};if(me==="columns"){const i=l=>V(Z===l?null:l),a=[];r.vehicle&&c&&a.push(n(k,{name:"vehicle",label:p.vehicle,children:[ye.map(l=>e(be,{field:l,picker:c,open:Z===l,onOpenRequest:i,onClose:()=>V(null)},l)),e(xe,{picker:c,onOpenRequest:i})]},"vehicle"));const E=[];return r.process&&E.push(e(k,{name:"process",label:p.process,rowsAreOptions:!0,children:M.map(l=>e($,{active:_===l,onClick:()=>o(N(_,l)),children:X(l)},l))},"process")),r.size&&E.push(e(k,{name:"size",label:p.size,rowsAreOptions:!0,children:j.map(l=>n($,{active:F===l,onClick:()=>d(N(F,l)),children:[l,'"']},l))},"size")),r.lugs&&E.push(e(k,{name:"lugs",label:p.lugs,rowsAreOptions:!0,children:I.map(l=>e($,{active:T===l,onClick:()=>f(N(T,l)),children:oe(l)},l))},"lugs")),r.finish&&E.push(e(k,{name:"finish",label:p.finish,rowsAreOptions:!0,children:W.map(l=>e($,{active:w===l.f,onClick:()=>g(w===l.f?null:l.f),children:l.label},l.f))},"finish")),a.push(...pe(E,P)),r.price&&a.push(e(k,{name:"price",label:p.price,tight:!0,children:e(se,{bounds:K,boxes:"line",min:D,max:U,onMin:O,onMax:x})},"price")),n("div",{className:"@container",children:[n("div",{className:`border-t border-line ${ae} pb-12 pt-10 @max-[720px]:px-4 @max-[720px]:pb-10 @max-[720px]:pt-8`,children:[(r.count||r.sort)&&n("div",{className:"mb-10 flex flex-wrap items-center gap-x-6 gap-y-3 @max-[720px]:mb-8",children:[r.count&&n("span",{className:`font-mono ${h.labelLarge} uppercase tracking-[0.2em] text-fg-dim`,children:[b," ",b===1?"result":"results"]}),r.sort&&n("div",{className:"ml-auto flex items-center gap-5",children:[e("button",{type:"button",onClick:Q,className:`font-mono ${h.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-fg`,children:"Clear All"}),e(ce,{look:"line",value:J,keys:te,labels:H,onChange:y})]})]}),e("div",{"data-filter-columns":!0,className:`grid grid-cols-1 gap-x-[72px] gap-y-10 ${Ae[a.length]??""}`,children:a}),v&&e("div",{className:"mt-10 flex",children:e(de,{href:v.href,label:v.label})})]}),r.vehicle&&c&&e(le,{picker:c,total:b})]})}const A=[];return r.process&&A.push(n(R,{name:"process",label:Y?n(he,{children:[e("span",{className:"text-accent @min-[720px]:hidden",children:X(Y)}),e("span",{className:"hidden @min-[720px]:inline",children:p.process})]}):p.process,badge:C.process,open:t==="process",onToggle:()=>u(t==="process"?null:"process"),children:[e(L,{children:"Series · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Process series",children:M.map(i=>{const a=_===i;return e(G,{active:a,role:"radio",ariaChecked:a,onClick:()=>o(N(_,i)),children:X(i)},i)})})]},"process")),r.size&&A.push(n(R,{name:"size",label:p.size,badge:C.size,open:t==="size",onToggle:()=>u(t==="size"?null:"size"),children:[e(L,{children:"Diameter · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Wheel diameter",children:j.map(i=>{const a=F===i;return n(G,{active:a,role:"radio",ariaChecked:a,onClick:()=>d(N(F,i)),children:[i,'"']},i)})})]},"size")),r.lugs&&A.push(n(R,{name:"lugs",label:p.lugs,badge:C.lugs,open:t==="lugs",onToggle:()=>u(t==="lugs"?null:"lugs"),children:[e(L,{children:"Lug count · single-select"}),e("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Lug count",children:I.map(i=>{const a=T===i;return e(G,{active:a,role:"radio",ariaChecked:a,onClick:()=>f(N(T,i)),children:oe(i)},i)})})]},"lugs")),r.finish&&A.push(n(R,{name:"finish",label:p.finish,badge:C.finish,open:t==="finish",onToggle:()=>u(t==="finish"?null:"finish"),children:[e(L,{children:"Color family · single-select"}),e("div",{className:"flex flex-col gap-2",role:"radiogroup","aria-label":"Finish color family",children:W.map(i=>{const a=w===i.f;return n("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>g(a?null:i.f),className:["flex items-center gap-3 border px-3 py-2 text-left transition-colors",a?"border-accent text-fg":"border-line hover:border-fg-dim"].join(" "),children:[e("span",{className:"block h-3.5 w-3.5 shrink-0 rounded-full border border-line",style:{background:i.hex}}),e("span",{className:`font-mono ${h.labelSmall} uppercase tracking-[0.18em]`,style:a?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"},children:i.label}),a&&e("span",{"aria-hidden":!0,className:"ml-auto text-accent",children:"●"})]},i.f)})})]},"finish")),n("div",{className:"@container sticky top-[67px] z-40 border-b border-line backdrop-blur",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[n("div",{className:`flex items-center gap-6 ${ae} py-4 @max-[720px]:flex-wrap @max-[720px]:items-stretch @max-[720px]:gap-2 @max-[720px]:px-4 @max-[720px]:py-3`,children:[n("div",{className:"relative flex flex-wrap items-center gap-1 @max-[720px]:basis-full @max-[720px]:gap-2",children:[r.count&&n("span",{className:`mr-3 border-r border-line pr-4 font-mono ${h.labelLarge} uppercase tracking-[0.2em] text-fg-dim @max-[720px]:hidden`,children:[b," ",b===1?"result":"results"]}),pe(A,P),r.price&&n(R,{name:"price",label:p.price,badge:C.price,open:t==="price",onToggle:()=>u(t==="price"?null:"price"),children:[e(L,{children:"Price range (per wheel)"}),e(se,{bounds:K,min:D,max:U,onMin:O,onMax:x})]}),r.vehicle&&c&&e(fe,{label:p.vehicle,badge:C.vehicle,open:t==="vehicle",onToggle:()=>u(t==="vehicle"?null:"vehicle")})]}),v&&e("div",{className:`flex items-center ${r.sort?"":"ml-auto"}`,children:e(de,{href:v.href,label:v.label})}),r.sort&&n("div",{className:"ml-auto flex items-center gap-3",children:[e("button",{type:"button",onClick:Q,className:`font-mono ${h.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-accent`,children:"Clear All"}),e(ce,{look:"box",value:J,keys:te,labels:H,onChange:y})]})]}),r.vehicle&&c&&t==="vehicle"&&e(ve,{picker:c,onClose:()=>u(null)}),r.vehicle&&c&&e(le,{picker:c,total:b})]})}const Ae={1:"@min-[720px]:grid-cols-1",2:"@min-[720px]:grid-cols-2",3:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3",4:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-4",5:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3 @min-[1400px]:grid-cols-5",6:"@min-[720px]:grid-cols-2 @min-[1100px]:grid-cols-3 @min-[1400px]:grid-cols-6"},Ee=`flex w-full items-center justify-between gap-4 border-b py-3 text-left ${h.body}`;function k({name:s,label:o,rowsAreOptions:d,tight:f,children:g}){return n("div",{"data-filter-column":s,className:`flex flex-col ${f?"gap-3":"gap-6"}`,children:[e("div",{className:`font-mono ${h.labelXs} uppercase tracking-[0.34em] text-fg-dim`,children:o}),e("div",{role:d?"radiogroup":void 0,"aria-label":d?o:void 0,children:g})]})}function $({active:s,onClick:o,children:d}){return e("button",{type:"button",role:"radio","aria-checked":s,onClick:o,className:[Ee,"transition-colors",s?"border-fg text-fg":"border-line text-fg-dim hover:text-fg"].join(" "),children:e("span",{children:d})})}export{Te as default,Fe as filterBarFacetsWithChoice};
|
|
@@ -29,6 +29,8 @@ interface CatalogFilterContextValue {
|
|
|
29
29
|
finishOptions: string[];
|
|
30
30
|
reportCategories: (id: string, names: readonly string[]) => void;
|
|
31
31
|
categoryOptions: string[];
|
|
32
|
+
reportPrices: (id: string, prices: readonly number[]) => void;
|
|
33
|
+
priceOptions: number[];
|
|
32
34
|
optionsReported: boolean;
|
|
33
35
|
scrollProcess: string | null;
|
|
34
36
|
vehicle: CatalogVehicleState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as $}from"react/jsx-runtime";import{createContext as re,useCallback as n,useContext as ne,useEffect as ie,useMemo as ce,useRef as J,useState as u}from"react";import{EMPTY_FILTERS as P}from"../../lib/wheels/catalog-filters.js";import{compareFinishFamily as le}from"../../lib/wheels/finish-defaults.js";import{ShopperScopeProvider as pe}from"./ShopperScope.js";const K={fit:null,name:"",resolving:!1,unresolved:!1};function ue(r,o){return r.fit===o.fit&&r.name===o.name&&r.resolving===o.resolving&&r.unresolved===o.unresolved}const s=()=>{},Q=re({filters:P,setProcess:s,setSize:s,setLugs:s,setFinish:s,setPriceMin:s,setPriceMax:s,setSort:s,clearAll:s,reportCount:s,total:0,reportLugs:s,lugOptions:[],reportSizes:s,sizeOptions:[],reportFinishes:s,finishOptions:[],reportCategories:s,categoryOptions:[],reportPrices:s,priceOptions:[],optionsReported:!1,scrollProcess:null,vehicle:K,publishVehicle:s}),W="data-catalog-collection",F=(r,o)=>r-o,ae=()=>0;function X(r,o){return r.length===o.length&&r.every((a,p)=>a===o[p])}function h(r){const o=J(new Map),[a,p]=u([]),i=n((f,d)=>{const g=o.current.get(f);if(g&&X(g,d))return;o.current.set(f,d);const m=new Set;for(const c of o.current.values())for(const R of c)m.add(R);const v=[...m].sort(r);p(c=>X(c,v)?c:v)},[r]);return[a,i]}function he({children:r,address:o=null,editing:a=!1}){const[p,i]=u(P),f=n(t=>i(e=>({...e,process:t})),[]),d=n(t=>i(e=>({...e,size:t})),[]),g=n(t=>i(e=>({...e,lugs:t})),[]),m=n(t=>i(e=>({...e,finish:t})),[]),v=n(t=>i(e=>({...e,priceMin:t})),[]),c=n(t=>i(e=>({...e,priceMax:t})),[]),R=n(t=>i(e=>({...e,sort:t})),[]),L=n(()=>i(t=>({...P,sort:t.sort})),[]),[x,Z]=u(K),w=n(t=>{Z(e=>ue(e,t)?e:t)},[]),S=J(new Map),[z,ee]=u(0),M=n((t,e)=>{if(S.current.get(t)===e)return;S.current.set(t,e);let l=0;for(const O of S.current.values())l+=O;ee(l)},[]),[T,_]=h(F),[A,G]=h(F),[I,y]=h(le),[N,V]=h(ae),[U,Y]=h(F),[b,C]=u(!1),j=n((t,e)=>{C(!0),_(t,e)},[_]),k=n((t,e)=>{C(!0),G(t,e)},[G]),q=n((t,e)=>{C(!0),y(t,e)},[y]),[D,te]=u(null);ie(()=>{let e=0;const E=()=>{e=0;let O=null;const se=document.querySelectorAll(`[${W}]`);for(const B of se){const H=B.getBoundingClientRect();if(H.top<=140&&H.bottom>140){O=B.getAttribute(W)??null;break}}te(O)},l=()=>{e||(e=requestAnimationFrame(E))};return E(),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),e&&cancelAnimationFrame(e)}},[]);const oe=ce(()=>({filters:p,setProcess:f,setSize:d,setLugs:g,setFinish:m,setPriceMin:v,setPriceMax:c,setSort:R,clearAll:L,reportCount:M,total:z,reportLugs:j,lugOptions:T,reportSizes:k,sizeOptions:A,reportFinishes:q,finishOptions:I,reportCategories:V,categoryOptions:N,reportPrices:Y,priceOptions:U,optionsReported:b,scrollProcess:D,vehicle:x,publishVehicle:w}),[p,f,d,g,m,v,c,R,L,M,z,j,T,k,A,q,I,V,N,Y,U,b,D,x,w]);return $(Q.Provider,{value:oe,children:$(pe,{address:o,editing:a,children:r})})}function Re(){return ne(Q)}export{W as COLLECTION_ATTR,he as CatalogFilterProvider,K as NO_VEHICLE,Re as useCatalogFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as
|
|
1
|
+
"use client";import{jsx as i,jsxs as h}from"react/jsx-runtime";import{useEffect as v,useId as k,useRef as f,useState as y}from"react";import{CATALOG_TEXT_SIZE as d}from"../../lib/sections/catalog-text-size.js";import{useIsoLayoutEffect as _}from"./ShopperScope.js";function C({labelSize:n=d.labelLarge,label:c,badge:o,open:e,onToggle:r,controls:m,buttonRef:p}){const a=o>0;return h("button",{ref:p,type:"button","aria-haspopup":"dialog","aria-expanded":e,"aria-controls":m,onClick:r,className:[`inline-flex items-center gap-2 whitespace-nowrap border px-4 py-3 font-mono ${n} uppercase tracking-[0.2em] transition-colors`,a?"border-accent text-accent":"border-line hover:border-fg-dim"].join(" "),style:a?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"},children:[c,o>0&&i("span",{className:`px-2 ${d.badge} tracking-[0.1em] text-bg`,style:{background:"var(--accent)"},children:o}),i("span",{className:`${d.badge} opacity-65 transition-transform ${e?"rotate-180":""}`,children:"▾"})]})}function R({labelSize:n,label:c,badge:o,open:e,onToggle:r,children:m}){const p=k(),a=f(null),x=f(null),b=f(null),[E,g]=y(!1);return _(()=>{if(!e){g(!1);return}const t=b.current,s=a.current,l=t?.ownerDocument.defaultView;if(!t||!s||!l||l.getComputedStyle(s).position==="static")return;const u=t.ownerDocument.documentElement.clientWidth,w=t.getBoundingClientRect();w.width>0&&w.right>u-L&&g(!0)},[e]),v(()=>{if(!e)return;const t=a.current?.ownerDocument??document,s=u=>{u.key==="Escape"&&(r(),x.current?.focus())},l=u=>{a.current?.contains(u.target)||r()};return t.addEventListener("keydown",s),t.addEventListener("pointerdown",l),()=>{t.removeEventListener("keydown",s),t.removeEventListener("pointerdown",l)}},[e,r]),h("div",{ref:a,className:e?"relative @max-[720px]:static":"relative",children:[i(C,{labelSize:n,label:c,badge:o,open:e,onToggle:r,controls:e?p:void 0,buttonRef:x}),e&&i("div",{ref:b,id:p,className:`absolute ${E?"right-0":"left-0"} top-[calc(100%+6px)] z-[60] min-w-[280px] max-w-[calc(100vw-32px)] border border-line bg-surface p-5 shadow-[0_24px_60px_rgba(0,0,0,0.4)] @max-[720px]:inset-x-0 @max-[720px]:top-auto @max-[720px]:mt-2 @max-[720px]:min-w-0`,onClick:t=>t.stopPropagation(),children:m})]})}const L=16;function S({children:n}){return i("div",{className:`mb-3 font-mono ${d.labelSmall} uppercase tracking-[0.32em] text-fg-dim`,children:n})}function I({active:n,onClick:c,children:o,role:e,ariaChecked:r}){return i("button",{type:"button",role:e,"aria-checked":e==="radio"?r:void 0,onClick:c,className:[`border px-3 py-2 font-mono ${d.labelLarge} uppercase tracking-[0.18em] transition-colors`,n?"border-accent bg-accent text-bg":"border-line hover:border-fg-dim"].join(" "),style:n?void 0:{color:"color-mix(in oklab, currentColor 75%, transparent)"},children:o})}export{R as FilterPill,I as OptButton,S as PanelTitle,C as PillButton};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export default function PriceRange({ min, max, onMin, onMax, }: {
|
|
1
|
+
export default function PriceRange({ min, max, onMin, onMax, bounds, boxes, }: {
|
|
2
2
|
min: number | null | undefined;
|
|
3
3
|
max: number | null | undefined;
|
|
4
4
|
onMin: (value: number | null) => void;
|
|
5
5
|
onMax: (value: number | null) => void;
|
|
6
|
+
bounds?: {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
} | null;
|
|
10
|
+
boxes?: "framed" | "line";
|
|
6
11
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n,jsxs as g}from"react/jsx-runtime";import{useState as C}from"react";import{useCurrency as T}from"../CurrencyContext.js";import{CATALOG_TEXT_SIZE as v}from"../../lib/sections/catalog-text-size.js";function S({min:l,max:a,onMin:e,onMax:u,bounds:i=null,boxes:p="framed"}){const f=T({optional:!0}),s=f?.currencies.find(m=>m.code===f.currency)?.symbol??"",r=p==="line"?"flex w-full items-center gap-1 border-b border-line py-3 pr-3":"flex w-full items-center gap-1 bg-bg border border-line px-3 py-3",o=`w-full min-w-0 bg-transparent font-mono ${v.labelXl} text-fg outline-none`;return g("div",{children:[i?n($,{min:l,max:a,bounds:i,onMin:e,onMax:u}):p==="line"&&n("div",{"aria-hidden":"true",className:"h-4"}),g("div",{className:`${i||p==="line"?"mt-3 ":""}flex items-center gap-2`,children:[g("label",{className:r,children:[s&&n("span",{"aria-hidden":"true",className:`font-mono ${v.labelXl} text-fg-dim`,children:s}),n("input",{type:"number",placeholder:i?String(i.min):"Min","aria-label":"Minimum price value",value:l??"",onChange:m=>e(M(m.target.value)),onBlur:()=>{l!=null&&a!=null&&l>a&&e(a)},className:o})]}),n("span",{className:`font-mono ${v.labelSmall} text-fg-dim`,children:"—"}),g("label",{className:r,children:[s&&n("span",{"aria-hidden":"true",className:`font-mono ${v.labelXl} text-fg-dim`,children:s}),n("input",{type:"number",placeholder:i?String(i.max):"Max","aria-label":"Maximum price value",value:a??"",onChange:m=>u(M(m.target.value)),onBlur:()=>{l!=null&&a!=null&&a<l&&u(l)},className:o})]})]})]})}function M(l){const a=Number(l);return l!==""&&Number.isFinite(a)&&a>=0?a:null}const c=5;function $({min:l,max:a,bounds:e,onMin:u,onMax:i}){const p=t=>Math.min(e.max,Math.max(e.min,t)),f=e.min+Math.floor((e.max-e.min)/c)*c,s=t=>Math.min(f,e.min+Math.round((p(t)-e.min)/c)*c),r=s(l??e.min),o=Math.max(r,s(a??e.max)),[m,d]=C(null),N=e.max-e.min,x=t=>N>0?(t-e.min)/N:0,w=t=>`calc(8px + (100% - 16px) * ${x(t)})`,y=m?m==="min":x(r)>.5,b={"--price-thumb":"var(--accent)","--price-thumb-ring":"var(--bg)"};return g("div",{className:"relative h-4",children:[n("div",{className:"absolute inset-x-0 top-1/2 h-1 -translate-y-1/2",style:{background:"var(--site-line)"}}),n("div",{className:"absolute top-1/2 h-1 -translate-y-1/2",style:{left:w(r),width:`calc((100% - 16px) * ${x(o)-x(r)})`,background:"var(--accent)"}}),n("input",{type:"range","aria-label":"Minimum price",min:e.min,max:e.max,step:c,value:r,onChange:t=>{const h=Math.min(Number(t.target.value),o);d("min"),u(h<e.min+c?null:h)},className:"price-range-thumbs absolute inset-0 h-4 w-full",style:{...b,zIndex:y?2:1}}),n("input",{type:"range","aria-label":"Maximum price",min:e.min,max:e.max,step:c,value:o,onChange:t=>{const h=Math.max(Number(t.target.value),r);d("max"),i(h>e.max-c?null:h)},className:"price-range-thumbs absolute inset-0 h-4 w-full",style:{...b,zIndex:y?1:2}})]})}export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n,Fragment as Y,jsxs as S}from"react/jsx-runtime";import{useCallback as H,useMemo as F,useState as U}from"react";import{CardTemplateRows as re}from"efficient-web-builder/render/components/CardRowContext";import{cardRow as le}from"efficient-web-builder/format/lib/content/card-template";import{useCurrency as oe}from"../CurrencyContext.js";import{useEnglish as se}from"../EnglishVariant.js";import X from"./PriceRange.js";import ie from"./SortSelect.js";import{DEFAULT_CATALOG_FILTER_LABELS as I}from"../../lib/content/catalog-filter-labels.js";import{itemKind as D,plpKindNoun as ce}from"../../lib/catalog/plp-item.js";import{itemLugs as ae,lugFilterLabel as pe}from"../../lib/wheels/lug-count.js";import{CATALOG_TEXT_SIZE as O}from"../../lib/sections/catalog-text-size.js";import{buildPlpFacets as ue,itemMatchesPlp as me,plpInStockCount as de,plpPriceBounds as fe,plpSortKeysFor as ge,PLP_ONE_VALUE_MAX as he,PLP_SORT_LABELS as Se}from"../../lib/wheels/plp-filters.js";import{FILTER_IN_STOCK_KEY as be,FILTER_PRICE_KEY as A,filterGroupItems as xe}from"../../lib/sections/filter-option-rows.js";import we from"../wheels-plp/PlpSidebar.js";import{FILTER_BLOCK_TYPE as V}from"../../lib/document/document-nodes.js";import{FilterPill as ye,PillButton as Me}from"./FilterPill.js";import{useShopperFilter as ke}from"./ShopperScope.js";import{HideTaker as Te}from"efficient-web-builder/render/components/ViewHideRoot";const Z="lugs";function _e({owner:r,look:e,lookPhone:s,shown:l,showSort:a,openingSort:c,filtersBelow:t,fieldUsage:p,firstRows:L,editing:u}){const{currency:h}=oe(),w=se(),{ref:E,scope:f}=ke({filtersBelow:t,openingSort:c}),{state:m}=f,g=f.live?f.rows:L??f.rows,b=F(()=>[...new Set(g.map(D))],[g]),N=F(()=>{const o=ue(g,m,h,b,p??[],"pass").filter(i=>i.key!=="collections"||l.includes("category"));if(l.includes("lugs")){const i=Le(g,m,h);i&&o.push(i)}return o.map(i=>({...i,label:w(i.label)}))},[g,m,h,b,p,l,w]),y=l.includes("price")?fe(g,h):null,P=l.includes("inStock")&&g.length>0?de(g,m,h):null,J=ge(b.length?b:["alloy-wheel"]),k=f.update,x=H(o=>k({...o,page:1}),[k]),v=H((o,i)=>k(d=>{if(o===Z){const M=Number(i),te=(d.lugs??[]).includes(M);return{...d,page:1,lugs:te?(d.lugs??[]).filter(ne=>ne!==M):[...d.lugs??[],M]}}const C=d[o].map(String),z=C.includes(i)?C.filter(M=>M!==i):[...C,i];return{...d,page:1,[o]:o==="diameters"?z.map(Number):z}}),[k]),B=a&&!f.sortInChips,Q=F(()=>{const o=xe(N,m,P).map(i=>({...i,options:i.options.map(d=>({...d,press:i.key===be?()=>x({inStockOnly:!m.inStockOnly}):()=>v(i.key,d.value)}))}));return y?[...o,{key:A,label:I.price,options:[]}]:o},[N,m,P,y,x,v]),T={owner:r,items:Q,state:m,sorts:J,showSort:B,set:x,bounds:y},W=o=>x({priceMin:o}),ee=o=>x({priceMax:o}),G=n(we,{facets:N,filters:m,noun:ce(b.length?b:["alloy-wheel"]),inStockCount:P,onToggle:v,onInStockOnly:o=>x({inStockOnly:o}),onClearAll:f.clear,price:y?{label:I.price,control:n(X,{bounds:y,min:m.priceMin,max:m.priceMax,onMin:W,onMax:ee})}:void 0,foot:B?n(_,{...T}):void 0,owner:{id:r.id,facetTemplate:r.facetTemplate,type:V},editing:u}),K=e==="rail"?G:n(R,{...T,columns:e==="bar-columns"}),j=(s==="rail"?e==="rail":s==="bar"&&e!=="rail")?null:s==="button"?n(Ee,{...T}):s==="rail"?G:n(R,{...T,columns:!1});return S(Te,{as:"div",ref:E,"data-shopper-filters":"",className:"w-full",children:[j?S(Y,{children:[n("div",{className:"max-view-wide:hidden",children:K}),n("div",{className:"view-wide:hidden",children:j})]}):K,u&&f.grids===0&&n("p",{className:`mt-2 font-mono ${O.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:"Filters a Product Grid in this Box"})]})}function Le(r,e,s){const l=new Map,a=new Set;for(const t of r){const p=D(t)==="alloy-wheel"?ae(t):null;p!==null&&(a.add(p),me(t,e,s,"lugs","pass")&&l.set(p,(l.get(p)??0)+1))}if(a.size<=he)return null;const c=e.lugs??[];return{key:Z,label:I.lugs,options:[...a].sort((t,p)=>t-p).map(t=>({value:String(t),label:pe(t),count:l.get(t)??0,checked:c.includes(t),swatch:null}))}}function _({state:r,sorts:e,set:s}){return n(ie,{value:r.sort,keys:e,labels:Se,onChange:l=>s({sort:l})})}function $(r,e){return r.key===A?(e.priceMin!=null?1:0)+(e.priceMax!=null?1:0):r.options.filter(s=>s.state.selected).length}function q({owner:r,items:e,state:s,set:l,bounds:a,wrap:c}){const t=u=>l({priceMin:u}),p=u=>l({priceMax:u}),L=(u,h)=>{const w=e[h.index],E=w.key===A?S(Y,{children:[u,n(X,{bounds:a,min:s.priceMin,max:s.priceMax,onMin:t,onMax:p})]}):u;return c(E,w)};return n(re,{ownerId:r.id,ownerType:V,Template:r.template,rows:e.map(le),items:e,fallback:null,wrapCopy:L,children:u=>u})}function R({columns:r,...e}){const[s,l]=U(null),a=c=>()=>l(t=>t===c?null:c);return r?S("div",{className:"flex flex-col gap-4",children:[n("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-6 border-y border-line py-4",children:n(q,{...e,wrap:(c,t)=>n("div",{children:c},t.key)})}),e.showSort&&n("div",{className:"flex flex-wrap items-center justify-end gap-4",children:n(_,{...e})})]}):S("div",{className:"relative flex flex-wrap items-center gap-2 @container",children:[n(q,{...e,wrap:(c,t)=>n(ye,{labelSize:O.labelSmall,name:t.key,label:t.label,badge:$(t,e.state),open:s===t.key,onToggle:a(t.key),children:c},t.key)}),e.showSort&&n("div",{className:"ml-auto",children:n(_,{...e})})]})}function Ee(r){const[e,s]=U(!1),l=r.items.reduce((a,c)=>a+$(c,r.state),0);return S("div",{className:"flex flex-col gap-4",children:[S("div",{className:"flex items-center justify-between gap-4",children:[n(Me,{labelSize:O.labelSmall,label:"Filters",badge:l,open:e,onToggle:()=>s(a=>!a)}),r.showSort&&n(_,{...r})]}),e&&n(R,{...r,columns:!0,showSort:!1})]})}export{_e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import j from"next/link";import{useEffect as Y,useMemo as O,useRef as E,useState as v}from"react";import{stripeAppearance as V}from"../../lib/checkout/stripe-appearance.js";import{Elements as Z,PaymentElement as J,useElements as X,useStripe as ee}from"@stripe/react-stripe-js";import{loadStripe as te}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as q}from"../Notice.js";import{resolveCopyright as re}from"../../lib/content/site.js";import{ApiError as B,products as I}from"../../lib/api/index.js";import ne from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as ae}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ie,useCheckout as oe}from"./checkout-state.js";import{CheckoutContact as ce,CheckoutOrderSummary as se,CheckoutPayment as le,CheckoutShippingAddress as de,CheckoutShippingMethod as me}from"./checkout-parts.js";function pe(t){return e(ie,{...t,children:e(xe,{})})}function ue({order:t,paid:n}){const{formatMoney:i}=R();if(!t.grandTotal||!t.currency)return null;const u=o=>i(Number(o),t.currency),h=Number(t.freightCharge??0),s=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||h>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:u(t.freightCharge??"0")})]}),s>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",u(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:u(t.grandTotal)})]})}function fe({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(j,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function xe(){const{site:t,logo:n,items:i,placing:u,email:h,me:s,addressSaveNote:o,lostChangeNote:f,idemKey:p,confirmation:d,setConfirmation:c,payment:k,paypalStep:g,squareStep:b,pendingConf:m,paid:y,setPaid:N,payNote:C,afterpayConfirming:l,gocardlessConfirming:a,zipConfirming:w,klarnaConfirming:P,cardConfirming:K,checkoutResult:D,confirmCardPayment:z,cardStillProcessing:F,renewCardPayment:H,holdRenewed:G,leaveCardPayment:U,checkoutRootRef:W,setCheckoutHeaderEl:Q}=oe();return d?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:y?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[y?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(j,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ue,{order:d,paid:y}),f&&e("p",{className:"text-sm text-fg-dim",children:f}),C&&e("p",{className:"text-sm text-fg-dim",children:C}),o&&e("p",{className:"text-sm text-fg-dim",children:o}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(j,{href:`/track?order=${encodeURIComponent(d.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(j,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):D?e(fe,{result:D,lostChangeNote:f}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):l?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):k&&m?e(ge,{payment:k,checkout:m,holdRenewed:G,onPaid:z,onProcessing:F,onRenew:H,onBack:U}):g&&m?e(Ne,{confirmation:m,clientId:t.paypalClientId??"",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):b&&m?e(we,{confirmation:m,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):r("div",{ref:W,className:"bg-bg text-fg",children:[r("header",{ref:Q,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(j,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(j,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(ne,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,siteName:t.name})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[e(ce,{}),e(de,{}),e(me,{}),e(le,{})]}),e(se,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:re({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ge({payment:t,checkout:n,holdRenewed:i,onPaid:u,onProcessing:h,onRenew:s,onBack:o}){const{formatMoney:f}=R(),p=e("span",{className:"text-fg",children:f(Number(t.amount),t.currency)}),d=O(()=>te(t.publishableKey),[t.publishableKey]),c=O(()=>V(),[]);return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:ae(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",p," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Enter your card again, then pay ",p,"."]}):r(x,{children:["Your items are held",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Pay ",p," by card to place your order."]})}),e(Z,{stripe:d,options:{clientSecret:t.clientSecret,appearance:c},children:e(ye,{payment:t,checkout:n,onPaid:u,onProcessing:h,onRenew:s,onBack:o})},t.clientSecret)]})]})})}function M(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const he=5;function ye({payment:t,checkout:n,onPaid:i,onProcessing:u,onRenew:h,onBack:s}){const{formatMoney:o}=R(),f=ee(),p=X(),[d,c]=v(!1),[k,g]=v(null),b=E(!1);async function m(){try{return(await f.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function y(l){let a=l;for(let w=0;a==="processing"&&w<he;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await m()??a;if(a==="succeeded"){i();return}if(a==="processing"){u();return}g("Payment did not complete. Please try again."),c(!1)}async function N(){if(!f||!p||d)return;c(!0),g(null),b.current=!0;const l=await f.confirmPayment({elements:p,redirect:"if_required"}).catch(()=>null);if(!l){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}g(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(l.error){if(!n.orderNumber&&l.error.code==="payment_intent_unexpected_state"){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}if(a===void 0){g(T),c(!1);return}await h(a==="canceled"),c(!1);return}g(l.error.message??"Payment failed. Please try again."),c(!1);return}await y(l.paymentIntent?.status)}async function C(){if(d)return;if(!b.current){s();return}c(!0),g(null);const l=await m();if(l==="succeeded"||l==="processing"){await y(l);return}if(c(!1),l===void 0){g(T);return}s()}return r("div",{className:"flex flex-col gap-4",children:[e(J,{}),k&&e(q,{role:"alert",children:k}),e("button",{type:"button",onClick:N,disabled:!f||!p||d,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||!p||d?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:d?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",o(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!d&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const $="paypal-sdk-js";let _=null;function be(t,n){const i=`${t}|${n}`;if(_?.key===i)return _.promise;const u=new Promise((h,s)=>{document.getElementById($)?.remove();const o=document.createElement("script");o.id=$;const f=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});o.src=`https://www.paypal.com/sdk/js?${f}`,o.onload=()=>{const p=window.paypal;p?h(p):s(new Error("PayPal SDK loaded without its namespace"))},o.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(o)});return _={key:i,promise:u},u}function Ne({confirmation:t,clientId:n,idemKey:i,onPaid:u,onSkip:h}){const{formatMoney:s}=R(),o=E(null),[f,p]=v(!1),[d,c]=v(null),k=E(u);return k.current=u,Y(()=>{let g=!1,b=null;return be(n,t.currency).then(m=>{if(!(g||!o.current))return b=m.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async y=>{try{if((await I.capturePaypalOrder({idempotencyKey:i,paypalOrderId:y.orderID})).status==="paid"){k.current();return}c("PayPal did not complete the payment. Please try again.")}catch(N){c(N instanceof B?N.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),b.render(o.current).then(()=>{g||p(!0)})}).catch(()=>{g||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,b?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!f&&!d&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:o}),d&&e(q,{role:"alert",children:d}),e("button",{type:"button",onClick:h,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const L="square-web-sdk";let A=null;function ke(t){const n=t==="sandbox"?"sandbox":"production";if(A?.key===n)return A.promise;const i=new Promise((u,h)=>{document.getElementById(L)?.remove();const s=document.createElement("script");s.id=L,s.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{const o=window.Square;o?u(o):h(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(s)});return A={key:n,promise:i},i}function we({confirmation:t,applicationId:n,locationId:i,environment:u,idemKey:h,onPaid:s,onSkip:o}){const{formatMoney:f}=R(),p=E(null),d=E(null),c=E(null),[k,g]=v(!1),[b,m]=v(!1),[y,N]=v(null);Y(()=>{let l=!1,a=null;return ke(u).then(async w=>{if(l||!p.current)return;const P=w.payments(n,i);c.current=P,a=await P.card(),await a.attach(p.current),d.current=a,l||g(!0)}).catch(()=>{l||N("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{l=!0,a?.destroy?.()}},[n,i,u]);async function C(){const l=d.current;if(!(!l||b)){m(!0),N(null);try{const a=await l.tokenize();if(a.status!=="OK"||!a.token){N(a.errors?.[0]?.message??"Please check the card details and try again."),m(!1);return}let w;try{w=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:h,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){s();return}N("Square did not complete the payment. Please try again.")}catch(a){N(a instanceof B?a.message:"Square payment failed. Please try again.")}m(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:f(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!k&&!y&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:p}),y&&e(q,{role:"alert",children:y}),e("button",{type:"button",onClick:C,disabled:!k||b,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!k||b?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:b?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",f(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:o,disabled:b,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{fe as PayFirstResultView,pe as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import j from"next/link";import{useEffect as Y,useMemo as O,useRef as E,useState as v}from"react";import{stripeAppearance as V}from"../../lib/checkout/stripe-appearance.js";import{Elements as Z,PaymentElement as J,useElements as X,useStripe as ee}from"@stripe/react-stripe-js";import{loadStripe as te}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as q}from"../Notice.js";import{resolveCopyright as re}from"../../lib/content/site.js";import{ApiError as B,products as I}from"../../lib/api/index.js";import ne from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as ae}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ie,useCheckout as oe}from"./checkout-state.js";import{CheckoutContact as ce,CheckoutOrderSummary as se,CheckoutPayment as le,CheckoutShippingAddress as de,CheckoutShippingMethod as me}from"./checkout-parts.js";function pe(t){return e(ie,{...t,children:e(xe,{})})}function ue({order:t,paid:n}){const{formatMoney:i}=R();if(!t.grandTotal||!t.currency)return null;const u=o=>i(Number(o),t.currency),h=Number(t.freightCharge??0),s=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||h>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:u(t.freightCharge??"0")})]}),s>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",u(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:u(t.grandTotal)})]})}function fe({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(j,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function xe(){const{site:t,logo:n,items:i,placing:u,email:h,me:s,addressSaveNote:o,lostChangeNote:f,idemKey:p,confirmation:d,setConfirmation:c,payment:k,paypalStep:g,squareStep:b,pendingConf:m,paid:y,setPaid:N,payNote:C,afterpayConfirming:l,gocardlessConfirming:a,zipConfirming:w,klarnaConfirming:P,cardConfirming:K,checkoutResult:D,confirmCardPayment:L,cardStillProcessing:F,renewCardPayment:U,holdRenewed:H,leaveCardPayment:G,checkoutRootRef:W,setCheckoutHeaderEl:Q}=oe();return d?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:y?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[y?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(j,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ue,{order:d,paid:y}),f&&e("p",{className:"text-sm text-fg-dim",children:f}),C&&e("p",{className:"text-sm text-fg-dim",children:C}),o&&e("p",{className:"text-sm text-fg-dim",children:o}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(j,{href:`/track?order=${encodeURIComponent(d.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(j,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):D?e(fe,{result:D,lostChangeNote:f}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):l?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):k&&m?e(ge,{payment:k,checkout:m,holdRenewed:H,onPaid:L,onProcessing:F,onRenew:U,onBack:G}):g&&m?e(Ne,{confirmation:m,clientId:t.paypalClientId??"",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):b&&m?e(we,{confirmation:m,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):r("div",{ref:W,className:"bg-bg text-fg",children:[r("header",{ref:Q,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(j,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(j,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(ne,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[e(ce,{}),e(de,{}),e(me,{}),e(le,{})]}),e(se,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:re({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ge({payment:t,checkout:n,holdRenewed:i,onPaid:u,onProcessing:h,onRenew:s,onBack:o}){const{formatMoney:f}=R(),p=e("span",{className:"text-fg",children:f(Number(t.amount),t.currency)}),d=O(()=>te(t.publishableKey),[t.publishableKey]),c=O(()=>V(),[]);return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:ae(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",p," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Enter your card again, then pay ",p,"."]}):r(x,{children:["Your items are held",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Pay ",p," by card to place your order."]})}),e(Z,{stripe:d,options:{clientSecret:t.clientSecret,appearance:c},children:e(ye,{payment:t,checkout:n,onPaid:u,onProcessing:h,onRenew:s,onBack:o})},t.clientSecret)]})]})})}function M(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const he=5;function ye({payment:t,checkout:n,onPaid:i,onProcessing:u,onRenew:h,onBack:s}){const{formatMoney:o}=R(),f=ee(),p=X(),[d,c]=v(!1),[k,g]=v(null),b=E(!1);async function m(){try{return(await f.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function y(l){let a=l;for(let w=0;a==="processing"&&w<he;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await m()??a;if(a==="succeeded"){i();return}if(a==="processing"){u();return}g("Payment did not complete. Please try again."),c(!1)}async function N(){if(!f||!p||d)return;c(!0),g(null),b.current=!0;const l=await f.confirmPayment({elements:p,redirect:"if_required"}).catch(()=>null);if(!l){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}g(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(l.error){if(!n.orderNumber&&l.error.code==="payment_intent_unexpected_state"){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}if(a===void 0){g(T),c(!1);return}await h(a==="canceled"),c(!1);return}g(l.error.message??"Payment failed. Please try again."),c(!1);return}await y(l.paymentIntent?.status)}async function C(){if(d)return;if(!b.current){s();return}c(!0),g(null);const l=await m();if(l==="succeeded"||l==="processing"){await y(l);return}if(c(!1),l===void 0){g(T);return}s()}return r("div",{className:"flex flex-col gap-4",children:[e(J,{}),k&&e(q,{role:"alert",children:k}),e("button",{type:"button",onClick:N,disabled:!f||!p||d,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||!p||d?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:d?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",o(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!d&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const z="paypal-sdk-js";let _=null;function be(t,n){const i=`${t}|${n}`;if(_?.key===i)return _.promise;const u=new Promise((h,s)=>{document.getElementById(z)?.remove();const o=document.createElement("script");o.id=z;const f=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});o.src=`https://www.paypal.com/sdk/js?${f}`,o.onload=()=>{const p=window.paypal;p?h(p):s(new Error("PayPal SDK loaded without its namespace"))},o.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(o)});return _={key:i,promise:u},u}function Ne({confirmation:t,clientId:n,idemKey:i,onPaid:u,onSkip:h}){const{formatMoney:s}=R(),o=E(null),[f,p]=v(!1),[d,c]=v(null),k=E(u);return k.current=u,Y(()=>{let g=!1,b=null;return be(n,t.currency).then(m=>{if(!(g||!o.current))return b=m.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async y=>{try{if((await I.capturePaypalOrder({idempotencyKey:i,paypalOrderId:y.orderID})).status==="paid"){k.current();return}c("PayPal did not complete the payment. Please try again.")}catch(N){c(N instanceof B?N.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),b.render(o.current).then(()=>{g||p(!0)})}).catch(()=>{g||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,b?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!f&&!d&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:o}),d&&e(q,{role:"alert",children:d}),e("button",{type:"button",onClick:h,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const $="square-web-sdk";let A=null;function ke(t){const n=t==="sandbox"?"sandbox":"production";if(A?.key===n)return A.promise;const i=new Promise((u,h)=>{document.getElementById($)?.remove();const s=document.createElement("script");s.id=$,s.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{const o=window.Square;o?u(o):h(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(s)});return A={key:n,promise:i},i}function we({confirmation:t,applicationId:n,locationId:i,environment:u,idemKey:h,onPaid:s,onSkip:o}){const{formatMoney:f}=R(),p=E(null),d=E(null),c=E(null),[k,g]=v(!1),[b,m]=v(!1),[y,N]=v(null);Y(()=>{let l=!1,a=null;return ke(u).then(async w=>{if(l||!p.current)return;const P=w.payments(n,i);c.current=P,a=await P.card(),await a.attach(p.current),d.current=a,l||g(!0)}).catch(()=>{l||N("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{l=!0,a?.destroy?.()}},[n,i,u]);async function C(){const l=d.current;if(!(!l||b)){m(!0),N(null);try{const a=await l.tokenize();if(a.status!=="OK"||!a.token){N(a.errors?.[0]?.message??"Please check the card details and try again."),m(!1);return}let w;try{w=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:h,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){s();return}N("Square did not complete the payment. Please try again.")}catch(a){N(a instanceof B?a.message:"Square payment failed. Please try again.")}m(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:f(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!k&&!y&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:p}),y&&e(q,{role:"alert",children:y}),e("button",{type:"button",onClick:C,disabled:!k||b,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!k||b?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:b?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",f(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:o,disabled:b,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{fe as PayFirstResultView,pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as E}from"react";import W from"next/image";import T from"next/link";import{lineTotal as K,useCart as X}from"../CartContext.js";import{useCurrency as Z}from"../CurrencyContext.js";import{Notice as R}from"../Notice.js";import{FREE_PRICE as F}from"../../lib/wheels/price-display.js";import J from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as Q}from"../../lib/cart/coupon-preview.js";import{orderReference as V}from"../../lib/checkout/pay-first.js";import{shippingWords as ee,TAX_PENDING as te}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ne}from"../../lib/wheels/finish-defaults.js";import $ from"../ThemedSelect.js";import f from"../WebFormField.js";import ae from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as re,SHIPPING_RETRY_NOTE as ie,useCheckout as k}from"./checkout-state.js";import{FIELD_INPUT_CLASS as g}from"../../lib/field-input.js";function Ee(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:u,me:o,checkoutSignOut:y}=k(),x=E();return a(w,{num:"N° 01",title:"Contact",children:[e(f,{label:"Email",htmlFor:x,hint:o?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:y,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:x,type:"email",value:t,onChange:d=>i(d.target.value),placeholder:"you@example.com",readOnly:o!==null,className:g+(o?" opacity-70":"")})}),a(M,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:d=>l(d.target.value),className:g})}),e(f,{label:"Last name",children:e("input",{type:"text",value:c,onChange:d=>u(d.target.value),className:g})})]})]})}function Fe(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:u,city:o,setCity:y,postcode:x,setPostcode:d,phone:b,setPhone:s,country:p,setCountry:m,subdivision:C,setSubdivision:h,subdivisions:A,destination:ce,postcodeLabel:U,subdivisionLabel:z,me:I,savedAddresses:L,selectedAddressId:_,setSelectedAddressId:P,saveAddress:O,setSaveAddress:D,saveLabel:H,setSaveLabel:q,fillFromAddress:G}=k(),B=E(),j=E();return a(w,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[I!==null&&L.length>0&&a("div",{className:"grid gap-3",children:[L.map(r=>e(S,{active:_===r.id,onClick:()=>{P(r.id),G(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(S,{active:_==="new",onClick:()=>P("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:g})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>u(r.target.value),placeholder:"Apartment, unit, garage bay…",className:g})}),a(M,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:o,onChange:r=>y(r.target.value),className:g})}),e(f,{label:U,children:e("input",{type:"text",value:x,onChange:r=>d(r.target.value),className:g})}),e(f,{label:"Country",separate:!0,htmlFor:B,children:e($,{id:B,value:p,onChange:r=>m(r.target.value),className:g+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:z,separate:!0,htmlFor:j,children:A.length>0?a($,{id:j,value:C,onChange:r=>h(r.target.value),className:g+" pr-10",style:Y,children:[e("option",{value:"",children:"Select…"}),A.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:C,onChange:r=>h(r.target.value),className:g})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>s(r.target.value),className:g})}),!t&&I!==null&&_==="new"&&a(N,{children:[e(le,{checked:O,onChange:D,label:"Save this address to my account"}),O&&e(f,{label:"Address label",children:e("input",{type:"text",value:H,onChange:r=>q(r.target.value),placeholder:"Home",className:g})})]})]})}function Ae(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:u,formatMoney:o,city:y,destination:x,courierUnavailable:d,retryCourier:b}=k();return e(w,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(s=>{const p=s.pickupLocation,m=p?[p.address,p.city,p.state,p.zipCode].filter(Boolean).join(", "):null;return e(S,{active:l===s.id,onClick:()=>c(s.id),title:p?`${s.name} — ${p.name}`:s.name,body:p?[m,p.openingHours,p.instructions,s.description].filter(Boolean).join(" · "):s.description||null,price:t.freeShipping||s.amount===0?F:o(s.amount,t.currency),tag:s.tag||void 0},s.id)}),d?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ie," ",e("button",{type:"button",onClick:b,className:"underline transition-colors hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ie(){const{payChoice:t,setPayChoice:i,placing:n,payment:l,payOptions:c,noPaymentMethod:u}=k();return a(w,{num:"N° 04",title:"Payment",children:[u&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:re}),e("div",{className:"grid gap-3",children:c.map(o=>e(S,{active:t===o.key,onClick:()=>i(o.key),title:o.title,body:o.body,price:o.price,tag:o.tag},o.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Le(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:u,placing:o,email:y,orderError:x,payment:d,noPaymentMethod:b,unpaidOrder:s,placeOrder:p}=k();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(T,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(T,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(m=>e(oe,{slug:m.slug,name:m.name,qty:m.qty,config:m.config,configSummary:se(m.config),price:K(m,n.currency)??0,currency:n.currency},m.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(J,{customerEmail:y})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(v,{label:"Subtotal",value:c(n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(v,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),l?.deferred&&e(v,{label:`Coupon · ${l.code}`,value:Q}),l?.valid&&l.effects?.gift&&e(v,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:F})}),e(v,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:F}):ee(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(v,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(v,{label:n.tax.name,value:te}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[x&&e(R,{role:"alert",children:x}),n.hasUnpricedLine&&a(R,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:p,disabled:o||!s&&(b||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",o||!s&&(i.length===0||b||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:o?a(N,{children:["Building order… ",e("span",{children:"·"})]}):b?a(N,{children:["No online payment ",e("span",{children:"·"})]}):s?a(N,{children:["Try payment again · ",V(s),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(N,{children:["Updating total… ",e("span",{children:"·"})]}):a(N,{children:[u==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const Y={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function w({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function M({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function S({active:t,onClick:i,title:n,body:l,price:c,tag:u}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,u&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:u})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function le({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function oe({slug:t,name:i,qty:n,config:l,configSummary:c,price:u,currency:o}){const{catalog:y}=X(),{formatMoney:x}=Z(),d=y.find(h=>h.slug===t),b=d?.spokes??5,s=d?.mesh??!1,p=l.find(h=>h.gold)?.label,m=d?.finishes.find(h=>h.name===p&&h.src)??d?.finishes.find(h=>h.src),C=d?.finishes[0]?.color??ne;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:m?.src?e(W,{src:m.src,alt:`${i.lead}${i.accent} — ${m.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(ae,{spokes:b,mesh:s,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:x(u,o)})]})}function v({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function se(t){return t.map(i=>i.label).join(" · ")}export{Ee as CheckoutContact,Le as CheckoutOrderSummary,Ie as CheckoutPayment,Fe as CheckoutShippingAddress,Ae as CheckoutShippingMethod};
|
|
1
|
+
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as E}from"react";import W from"next/image";import T from"next/link";import{lineTotal as K,useCart as X}from"../CartContext.js";import{useCurrency as Z}from"../CurrencyContext.js";import{Notice as R}from"../Notice.js";import{FREE_PRICE as F}from"../../lib/wheels/price-display.js";import J from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as Q}from"../../lib/cart/coupon-preview.js";import{orderReference as V}from"../../lib/checkout/pay-first.js";import{shippingWords as ee,TAX_PENDING as te}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ne}from"../../lib/wheels/finish-defaults.js";import $ from"../ThemedSelect.js";import f from"../WebFormField.js";import ae from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as re,SHIPPING_RETRY_NOTE as ie,useCheckout as k}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";function Ee(){const{email:t,setEmail:i,firstName:n,setFirstName:o,lastName:c,setLastName:m,company:s,setCompany:y,me:x,checkoutSignOut:g}=k(),h=E();return a(w,{num:"N° 01",title:"Contact",children:[e(f,{label:"Email",htmlFor:h,hint:x?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:g,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:h,type:"email",value:t,onChange:l=>i(l.target.value),placeholder:"you@example.com",readOnly:x!==null,className:u+(x?" opacity-70":"")})}),a(M,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:l=>o(l.target.value),className:u})}),e(f,{label:"Last name",children:e("input",{type:"text",value:c,onChange:l=>m(l.target.value),className:u})})]}),e(f,{label:"Company (optional)",children:e("input",{type:"text",value:s,onChange:l=>y(l.target.value),autoComplete:"organization",className:u})})]})}function Fe(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:o,address2:c,setAddress2:m,city:s,setCity:y,postcode:x,setPostcode:g,phone:h,setPhone:l,country:d,setCountry:p,subdivision:C,setSubdivision:b,subdivisions:A,destination:ce,postcodeLabel:z,subdivisionLabel:U,me:I,savedAddresses:L,selectedAddressId:_,setSelectedAddressId:P,saveAddress:O,setSaveAddress:D,saveLabel:H,setSaveLabel:q,fillFromAddress:G}=k(),B=E(),j=E();return a(w,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[I!==null&&L.length>0&&a("div",{className:"grid gap-3",children:[L.map(r=>e(S,{active:_===r.id,onClick:()=>{P(r.id),G(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(S,{active:_==="new",onClick:()=>P("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>o(r.target.value),className:u})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>m(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(M,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:s,onChange:r=>y(r.target.value),className:u})}),e(f,{label:z,children:e("input",{type:"text",value:x,onChange:r=>g(r.target.value),className:u})}),e(f,{label:"Country",separate:!0,htmlFor:B,children:e($,{id:B,value:d,onChange:r=>p(r.target.value),className:u+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:U,separate:!0,htmlFor:j,children:A.length>0?a($,{id:j,value:C,onChange:r=>b(r.target.value),className:u+" pr-10",style:Y,children:[e("option",{value:"",children:"Select…"}),A.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:C,onChange:r=>b(r.target.value),className:u})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:h,onChange:r=>l(r.target.value),className:u})}),!t&&I!==null&&_==="new"&&a(N,{children:[e(le,{checked:O,onChange:D,label:"Save this address to my account"}),O&&e(f,{label:"Address label",children:e("input",{type:"text",value:H,onChange:r=>q(r.target.value),placeholder:"Home",className:u})})]})]})}function Ae(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:o,setShippingMethodId:c,pickupLocation:m,formatMoney:s,city:y,destination:x,courierUnavailable:g,retryCourier:h}=k();return e(w,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(l=>{const d=l.pickupLocation,p=d?[d.address,d.city,d.state,d.zipCode].filter(Boolean).join(", "):null;return e(S,{active:o===l.id,onClick:()=>c(l.id),title:d?`${l.name} — ${d.name}`:l.name,body:d?[p,d.openingHours,d.instructions,l.description].filter(Boolean).join(" · "):l.description||null,price:t.freeShipping||l.amount===0?F:s(l.amount,t.currency),tag:l.tag||void 0},l.id)}),g?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ie," ",e("button",{type:"button",onClick:h,className:"underline transition-colors hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ie(){const{payChoice:t,setPayChoice:i,placing:n,payment:o,payOptions:c,noPaymentMethod:m}=k();return a(w,{num:"N° 04",title:"Payment",children:[m&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:re}),e("div",{className:"grid gap-3",children:c.map(s=>e(S,{active:t===s.key,onClick:()=>i(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Le(){const{site:t,items:i,totals:n,coupon:o,formatMoney:c,payChoice:m,placing:s,email:y,orderError:x,payment:g,noPaymentMethod:h,unpaidOrder:l,placeOrder:d}=k();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(T,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(T,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(p=>e(oe,{slug:p.slug,name:p.name,qty:p.qty,config:p.config,configSummary:se(p.config),price:K(p,n.currency)??0,currency:n.currency},p.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(J,{customerEmail:y})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(v,{label:"Subtotal",value:c(n.subtotal,n.currency)}),n.discount>0&&o?.valid&&e(v,{label:`Coupon · ${o.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),o?.deferred&&e(v,{label:`Coupon · ${o.code}`,value:Q}),o?.valid&&o.effects?.gift&&e(v,{label:`Free gift · ${o.effects.gift.partNumber}${o.effects.gift.quantity>1?` ×${o.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:F})}),e(v,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:F}):ee(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(v,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(v,{label:n.tax.name,value:te}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[x&&e(R,{role:"alert",children:x}),n.hasUnpricedLine&&a(R,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:d,disabled:s||!l&&(h||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",s||!l&&(i.length===0||h||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:s?a(N,{children:["Building order… ",e("span",{children:"·"})]}):h?a(N,{children:["No online payment ",e("span",{children:"·"})]}):l?a(N,{children:["Try payment again · ",V(l),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(N,{children:["Updating total… ",e("span",{children:"·"})]}):a(N,{children:[m==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const Y={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function w({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function M({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function S({active:t,onClick:i,title:n,body:o,price:c,tag:m}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,m&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:m})]}),o&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:o})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function le({checked:t,onChange:i,label:n,sub:o}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,o&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:o})]})]})}function oe({slug:t,name:i,qty:n,config:o,configSummary:c,price:m,currency:s}){const{catalog:y}=X(),{formatMoney:x}=Z(),g=y.find(b=>b.slug===t),h=g?.spokes??5,l=g?.mesh??!1,d=o.find(b=>b.gold)?.label,p=g?.finishes.find(b=>b.name===d&&b.src)??g?.finishes.find(b=>b.src),C=g?.finishes[0]?.color??ne;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:p?.src?e(W,{src:p.src,alt:`${i.lead}${i.accent} — ${p.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(ae,{spokes:h,mesh:l,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:x(m,s)})]})}function v({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function se(t){return t.map(i=>i.label).join(" · ")}export{Ee as CheckoutContact,Le as CheckoutOrderSummary,Ie as CheckoutPayment,Fe as CheckoutShippingAddress,Ae as CheckoutShippingMethod};
|
|
@@ -2,6 +2,7 @@ import { type SiteIdentity } from "../../lib/content/site.js";
|
|
|
2
2
|
import type { OrderConfirmation, ShopAddress, ShopMe } from "../../lib/api/index.js";
|
|
3
3
|
import { type LandingOrder } from "../../lib/checkout/wallet-return.js";
|
|
4
4
|
import { type PayFirstResult } from "../../lib/checkout/pay-first.js";
|
|
5
|
+
import type { LengthUnit } from "efficient-easel/screen/lib/content/length-units";
|
|
5
6
|
type PayKey = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "bank";
|
|
6
7
|
interface PayOption {
|
|
7
8
|
key: PayKey;
|
|
@@ -25,6 +26,7 @@ export interface CheckoutProps {
|
|
|
25
26
|
reverse: boolean;
|
|
26
27
|
size: "small" | "medium" | "large";
|
|
27
28
|
sizePx: number | null;
|
|
29
|
+
sizeUnit?: LengthUnit | null;
|
|
28
30
|
} | null;
|
|
29
31
|
preview?: boolean;
|
|
30
32
|
}
|
|
@@ -37,6 +39,7 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
37
39
|
reverse: boolean;
|
|
38
40
|
size: "small" | "medium" | "large";
|
|
39
41
|
sizePx: number | null;
|
|
42
|
+
sizeUnit?: LengthUnit | null;
|
|
40
43
|
} | null | undefined;
|
|
41
44
|
items: import("../CartContext.js").CartLine[];
|
|
42
45
|
totals: {
|
|
@@ -98,6 +101,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
98
101
|
setFirstName: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
99
102
|
lastName: string;
|
|
100
103
|
setLastName: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
104
|
+
company: string;
|
|
105
|
+
setCompany: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
101
106
|
address1: string;
|
|
102
107
|
setAddress1: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
103
108
|
address2: string;
|