@riverbankcms/sdk 0.174.0 → 0.175.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/dist/_dts/{BlocksIslandsHydrator-GqVX3I8E.d.ts → BlocksIslandsHydrator-hb2IWD8K.d.ts} +1 -1
- package/dist/_dts/{Page-BhUH31M-.d.ts → Page-BlY68ZF-.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-DBn2x0UL.d.ts → SdkPreviewMode-CA8hU7hW.d.ts} +2 -2
- package/dist/_dts/{client-Cr-sOeSl.d.ts → client-B6tCvmG4.d.ts} +487 -11
- package/dist/_dts/{content-types-DKw1yJdN.d.ts → content-types-B9qryk4R.d.ts} +2 -2
- package/dist/_dts/{contracts-CJ2O03nB.d.ts → contracts-DWoaRxj1.d.ts} +3 -3
- package/dist/_dts/{footerPageOutline-DoGHHKr_.d.ts → footerPageOutline-Djdrhp5s.d.ts} +6 -6
- package/dist/_dts/{generatePageMetadata-CJGu4hoa.d.ts → generatePageMetadata-CFi0vxov.d.ts} +2 -2
- package/dist/_dts/{index--39uLjrr.d.ts → index-Bl5_pjmq.d.ts} +1 -1
- package/dist/_dts/{index-DQZ5L0Gb.d.ts → index-Btp5nIoz.d.ts} +2 -2
- package/dist/_dts/{index-Bq-488M7.d.ts → index-CQUzwOxO.d.ts} +1 -1
- package/dist/_dts/{index-DYlfdT1O.d.ts → index-DmhFb6R1.d.ts} +1 -1
- package/dist/_dts/{index-3GzargmS.d.ts → index-OtazQE3U.d.ts} +2 -2
- package/dist/_dts/{index-DYsP4k6S.d.ts → index-YRQulWB4.d.ts} +3 -3
- package/dist/_dts/{index-DdEi2iXd.d.ts → index-_pXaCO12.d.ts} +4 -4
- package/dist/_dts/{loadContent-BVPagYmy.d.ts → loadContent-Hcuvs4pz.d.ts} +7 -7
- package/dist/_dts/{request-Be1E-H-V.d.ts → request-BT8i_vH-.d.ts} +2070 -503
- package/dist/_dts/{resolveBlockData-D1pL25bD.d.ts → resolveBlockData-B-dJrunl.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-B4sbTf96.d.ts → resolvePageContent-CVLYWcoI.d.ts} +2 -2
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +7 -7
- package/dist/_dts/sdk/src/config/index.d.ts +6 -6
- package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
- package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
- package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
- package/dist/_dts/sdk/src/data/types.d.ts +2 -2
- package/dist/_dts/sdk/src/gifting/client.d.ts +13 -1
- package/dist/_dts/sdk/src/index.d.ts +8 -8
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
- package/dist/_dts/sdk/src/next/index.d.ts +7 -7
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
- package/dist/_dts/sdk/src/portal/client.d.ts +3 -2
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
- package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
- package/dist/_dts/sdk/src/server.d.ts +5 -5
- package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
- package/dist/_dts/sdk/src/theme/index.d.ts +2 -1
- package/dist/_dts/{types-Bm5_3VEd.d.ts → types-C0XZnjXz.d.ts} +3 -3
- package/dist/_dts/{types-5MeDI1w8.d.ts → types-CXL1QJSY.d.ts} +7 -7
- package/dist/_dts/{types-CVoCc_Ia.d.ts → types-OKzbqRBx.d.ts} +2 -2
- package/dist/_dts/{validation-lEtYD-Rh.d.ts → validation-Bxi66FtQ.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-DkflFLGQ.mjs → BlocksIslandsHydrator-2xzlERTG.mjs} +17 -16
- package/dist/client/{BookingMailingListNote-CAyoiAGD.mjs → BookingMailingListNote-qsohSEdQ.mjs} +6 -6
- package/dist/client/{BookingPanelArrangement-C7yiJrxm.mjs → BookingPanelArrangement-DrdtON0q.mjs} +1 -1
- package/dist/client/{BookingQuestionFields-DZMrGvBh.mjs → BookingQuestionFields-CUFxBaTM.mjs} +3 -3
- package/dist/client/{CalendarNavigationChevron-BPQU5Snc.mjs → CalendarNavigationChevron-Ch0w0Utn.mjs} +34 -9
- package/dist/client/DemoBookingPortalAccess-DGgsjqXK.mjs +545 -0
- package/dist/client/{EventCalendar.client-BiWQc28-.mjs → EventCalendar.client-Dg4PHFJJ.mjs} +15 -25
- package/dist/client/{EventCombined.client-B_ytWQtn.mjs → EventCombined.client-tky8JcnQ.mjs} +25 -17
- package/dist/client/{EventItem-C-mxXpX_.mjs → EventItem-BybMSKNL.mjs} +4 -3
- package/dist/client/{EventListWeekNavigation-Bm3Ap1Rd.mjs → EventListWeekNavigation-uvWRE5wi.mjs} +1 -1
- package/dist/client/{EventListing.client-Bs_8im5_.mjs → EventListing.client-DQx9dohz.mjs} +3 -3
- package/dist/client/{EventListing.view-CN7BjGgC.mjs → EventListing.view-r31k8Icz.mjs} +8 -7
- package/dist/client/{EventRegistrationPayment-DPkRcSdw.mjs → EventRegistrationPayment-BMmPDmSf.mjs} +664 -362
- package/dist/client/{LocationMapActions-BJT7MqP2.mjs → LocationMapActions-BecH-qhI.mjs} +1 -1
- package/dist/client/{MapDrawingSvg-DCIwlON6.mjs → MapDrawingSvg-BJzmFdcn.mjs} +18 -3
- package/dist/client/{Page--xJ23nA5.mjs → Page-CWN_8cLZ.mjs} +736 -1667
- package/dist/client/{DemoBookingPortalAccess-BnEgvJas.mjs → SiteTermsAgreementField-Dr5lj4oY.mjs} +4 -301
- package/dist/client/{StepIndicator-D391QRNc.mjs → StepIndicator-C7RJBOW3.mjs} +37 -249
- package/dist/client/{accordion-BQtTkDN8.mjs → accordion-uUi_N6mZ.mjs} +1 -1
- package/dist/client/{booking-form.client-D9M7TKGV.mjs → booking-form.client-CKHgxvsh.mjs} +229 -42
- package/dist/client/{bookingForm-BsOS0sl9.mjs → bookingForm-Bi74dmiS.mjs} +4 -4
- package/dist/client/bookings.mjs +22 -15
- package/dist/client/{boxStyleClassNames-CNDLpT06.mjs → boxStyleClassNames-C-gFwhnO.mjs} +3 -29
- package/dist/client/{carousel-CPsW-FPh.mjs → carousel-C0_BqMA0.mjs} +1 -1
- package/dist/client/{cart-CwElmocm.mjs → cart-BOHuppVu.mjs} +3 -3
- package/dist/client/{cart.client-RpqI56w8.mjs → cart.client-IfJE1zAp.mjs} +1 -1
- package/dist/client/{checkout-CfMgqY8H.mjs → checkout-C3Aj-aNa.mjs} +3 -3
- package/dist/client/{checkout.client-BpuPyOuJ.mjs → checkout.client-Tg9lfeYf.mjs} +1 -1
- package/dist/client/{checkoutUrls-VeHY6WYj.mjs → checkoutUrls-OLqQdAXD.mjs} +1 -1
- package/dist/client/client.mjs +113 -21
- package/dist/client/{context-CNlesLfF.mjs → context-D8TpQXjX.mjs} +76 -58
- package/dist/client/{course-q1sA4Cj-.mjs → course-DHmeQAvq.mjs} +2 -2
- package/dist/client/{creditProducts-KYMVIH3J.mjs → creditProducts-BQ1t1erI.mjs} +14 -61
- package/dist/client/{dateFormatting-B73Ll0s4.mjs → dateFormatting-ABCZWkpT.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-BVbLD4pi.mjs → demoPortalMagicLink-BdcuW_pa.mjs} +1 -1
- package/dist/client/display-DMqotaGU.mjs +11797 -0
- package/dist/client/{enhanceHeaderSection-BzjY6AiY.mjs → enhanceHeaderSection-Ciuhsk0E.mjs} +3 -3
- package/dist/client/{event-details.client-CseTWUFC.mjs → event-details.client-CJapNbTv.mjs} +1 -1
- package/dist/client/{event-registration.client-b5TLxntR.mjs → event-registration.client-CAdcpnLc.mjs} +295 -188
- package/dist/client/{eventCalendar-C-kJNIc9.mjs → eventCalendar-BlsD5R8M.mjs} +4 -4
- package/dist/client/{eventCombined-BgHJGhwE.mjs → eventCombined-B9Ly3024.mjs} +4 -4
- package/dist/client/{eventDetails-CAwbreD0.mjs → eventDetails-CbEGI4jO.mjs} +2 -2
- package/dist/client/{eventListing-_14atrj8.mjs → eventListing-ZSmvhWII.mjs} +4 -4
- package/dist/client/{eventRegistration-BOqSdstJ.mjs → eventRegistration-D-yUcIyO.mjs} +4 -4
- package/dist/client/{form-DfAB-llc.mjs → form-DG_YZSNn.mjs} +3 -3
- package/dist/client/{form.client-DN-I9_qC.mjs → form.client-BU6dM0-C.mjs} +4 -4
- package/dist/client/{form.parts-t2Q1neM6.mjs → form.parts-Db0Iq7nx.mjs} +1 -1
- package/dist/client/{formatDate-Dp7POa9Y.mjs → formatDate-DFfWHpQB.mjs} +1 -1
- package/dist/client/gifting/client.mjs +5 -3
- package/dist/client/gifting-DMrsN4B4.mjs +28 -0
- package/dist/client/gifting.client-BVa2XYJB.mjs +404 -0
- package/dist/client/gifting.parts-C2u4Y-pf.mjs +86 -0
- package/dist/client/{headerSection-Dces54pb.mjs → headerSection-D91EzlOR.mjs} +2 -2
- package/dist/client/{display-D8MW2b0e.mjs → lookSurfaces-BDZLALxj.mjs} +3084 -12938
- package/dist/client/{newsletter-form.client-D_YFUlR2.mjs → newsletter-form.client-BMGRiRpo.mjs} +7 -5
- package/dist/client/{newsletter-form.parts-URO5Mn_I.mjs → newsletter-form.parts-D5UfUaD3.mjs} +3 -3
- package/dist/client/{newsletterForm-_c9fKIzS.mjs → newsletterForm-B_67sNwa.mjs} +3 -3
- package/dist/client/{noop-D5mFWXtN.mjs → noop-DF8_EiFt.mjs} +93 -28
- package/dist/client/portal/client.mjs +313 -148
- package/dist/client/{product-detail.client-CVW1UIxJ.mjs → product-detail.client-D-XNir0m.mjs} +1 -1
- package/dist/client/{product-list.client-CF9hO23G.mjs → product-list.client-BLfYQ-qi.mjs} +1 -1
- package/dist/client/{productDetail-C_qbmUuP.mjs → productDetail-W0_0lDGe.mjs} +3 -3
- package/dist/client/{productList-Df5qDD0z.mjs → productList-ayAtPJdb.mjs} +3 -3
- package/dist/client/{propsDecoder-BiEyK2ii.mjs → propsDecoder-ChYKWjLA.mjs} +4 -3
- package/dist/client/{registry.server-ClcfWpvM.mjs → registry.server-B1EEZkcr.mjs} +311 -262
- package/dist/client/rendering/client.mjs +25 -491
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +7 -7
- package/dist/client/{richText-coerce-C32cRQ03.mjs → richText-coerce-CDAfpMQU.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-DAypPzSo.mjs → routeIslandApiConfig-CcGWvyht.mjs} +1 -1
- package/dist/client/{shop-gteEpeO5.mjs → shop-DbUUoHFJ.mjs} +3 -3
- package/dist/client/{shop-discount-apply.state-DidgH7ow.mjs → shop-add-feedback-DvC2kP1K.mjs} +1 -78
- package/dist/client/{shop-commerce-Bw4_BXQg.mjs → shop-commerce-aQqcDmyZ.mjs} +64 -32
- package/dist/client/{shop-commerce-store-Da6Ah-_4.mjs → shop-commerce-store-Cd7USpuY.mjs} +1 -1
- package/dist/client/shop-discount-apply.state-DGvPBmVP.mjs +83 -0
- package/dist/client/{shop.client-CbbdjWWd.mjs → shop.client-BNZ9M8cG.mjs} +56 -19
- package/dist/client/{shop.interactive-CKFORzux.mjs → shop.interactive-CJAINJr3.mjs} +118 -39
- package/dist/client/{shopShared-C7QjoywZ.mjs → shopShared-DwVAuGsx.mjs} +2 -2
- package/dist/client/{timetableModel-CtZiIj9q.mjs → timetableModel-DBTIFWTb.mjs} +11 -148
- package/dist/client/{useAvailableSlots-CUVRD1nx.mjs → useAvailableSlots-BomyyKeo.mjs} +3 -3
- package/dist/client/{useDiscountCodeUi-BuLgof7O.mjs → useDiscountCodeUi-CCxHMWlU.mjs} +32 -17
- package/dist/client/{useEventPagination-B4VPtSEF.mjs → useEventPagination-Bjin_qaN.mjs} +7 -6
- package/dist/client/{view-CvlTplao.mjs → view-BTk470k0.mjs} +3 -2
- package/dist/client/{view-CxUpgcM6.mjs → view-Cw4EmEPv.mjs} +100 -32
- package/dist/preview-next/client/{PageSectionToolbar-BFbSrDbi.mjs → PageSectionToolbar-bq7gbKvn.mjs} +4 -4
- package/dist/preview-next/client/{PreviewEditorSidebar-BtpzqQ-i.mjs → PreviewEditorSidebar-DVsPNcos.mjs} +32 -29
- package/dist/preview-next/client/{PreviewEditorUI-z22h-CCY.mjs → PreviewEditorUI-B-pq3aZc.mjs} +4 -4
- package/dist/preview-next/client/{PreviewShell-BW3Qpoa_.mjs → PreviewShell-ChyjB96e.mjs} +5 -5
- package/dist/preview-next/client/{SdkPreviewModeRuntime-BvVeK1hR.mjs → SdkPreviewModeRuntime-D_czeC0l.mjs} +84 -101
- package/dist/preview-next/client/{previewAssistantSlot-BUqAh1FL.mjs → previewAssistantSlot-B61mZd81.mjs} +4981 -3275
- package/dist/preview-next/client/{previewChromeRoot-NCy5zHO8.mjs → previewChromeRoot-dwOn9XtM.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-CxmKDVGZ.mjs → sdk-runtime-DZDfOxoW.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-B_UaDyJO.mjs → siteStyleAccess-BZDIC-fA.mjs} +529 -238
- package/dist/preview-next/client/{useAutosaveStatus-BqmWvPLY.mjs → useAutosaveStatus-BbzLMf-l.mjs} +1 -1
- package/dist/preview-next/client/{useOpenBlockForSetup-LAllV0rU.mjs → useOpenBlockForSetup-BEXcWQeI.mjs} +25 -5
- package/dist/preview-next/container-responsive.css +51 -3
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-DV6SeCNv.mjs → route-contract-0gSlK9S0.mjs} +87 -12
- package/dist/server/{Block.shared-Ch2FKAvU.mjs → Block.shared-DeXXycg8.mjs} +4 -4
- package/dist/server/{ThemeScopeCore-DFvjDVzi.mjs → ThemeScopeCore-DFEM1a85.mjs} +16 -2
- package/dist/server/{bindings-CQg2lzZn.mjs → bindings-7L3pC5Os.mjs} +13 -34
- package/dist/server/{client-aYRTVneD.mjs → client-CgghATBm.mjs} +112 -20
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/{customCss-BGB8gMVb.mjs → customCss-BZ8YSrQg.mjs} +1 -0
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/index.mjs +2 -2
- package/dist/server/{loadContent-Cgpfr44e.mjs → loadContent-D7M5Vcug.mjs} +5 -5
- package/dist/server/{loadPage-RDk10NMP.mjs → loadPage-CiTId05y.mjs} +2 -2
- package/dist/server/{lookMediaFrame-CQtkvlDn.mjs → lookMediaFrame-CaH018pK.mjs} +129 -12
- package/dist/server/next.mjs +35 -9
- package/dist/server/{overrideResolution-VhhN94d8.mjs → overrideResolution-CJ3MRI5Q.mjs} +1 -1
- package/dist/server/page-converter.mjs +1 -1
- package/dist/server/{pageRenderPlan-CkFTsxkd.mjs → pageRenderPlan-Cuos4Xcd.mjs} +105 -357
- package/dist/server/{pageRuntimeSupport-CpAtzNxD.mjs → pageRuntimeSupport-CuVj3bkd.mjs} +4 -3
- package/dist/server/{pageShared-B8yLPjs0.mjs → pageShared-JxlV8_Bo.mjs} +1707 -1811
- package/dist/server/{parseThemeForPersistence-Cwqb5pZx.mjs → parseThemeForPersistence-DOsfofCy.mjs} +1 -1
- package/dist/server/{prebuild-DOu6QceG.mjs → prebuild-BDhlJbAx.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-CfOXFKYG.mjs → prefetchBlockData-kERh_c0v.mjs} +2 -2
- package/dist/server/{registry-34rkAfaU.mjs → registry-cQ9N5W-n.mjs} +21091 -20209
- package/dist/server/rendering/components/pageShared.mjs +1 -1
- package/dist/server/rendering/helpers/loadPage.mjs +1 -1
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
- package/dist/server/rendering/server.mjs +3 -3
- package/dist/server/rendering.mjs +7 -7
- package/dist/server/{resolveBlockData-D7VeoWgr.mjs → resolveBlockData-CN4UmmTK.mjs} +1 -1
- package/dist/server/{schema-CUDHMirj.mjs → schema-BpsqaSSU.mjs} +2 -2
- package/dist/server/server.mjs +3 -3
- package/dist/server/theme-bridge.mjs +1 -1
- package/dist/server/theme.mjs +2 -2
- package/dist/server/{validation-CLVKoJrX.mjs → validation-3puM5SM8.mjs} +3 -3
- package/dist/server/{version-HVfdvBJ0.mjs → version-B8g-Wx57.mjs} +1 -1
- package/dist/styles/index.css +361 -57
- package/package.json +1 -1
- package/dist/client/bookability-CE637yDE.mjs +0 -17
- package/dist/client/useDiscountApply-BZU5DWZQ.mjs +0 -199
package/dist/preview-next/client/{siteStyleAccess-B_UaDyJO.mjs → siteStyleAccess-BZDIC-fA.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { n as useOptionalPreviewLayout } from "./PreviewLayoutContext-Dy0LwcHc.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { Ac as createRovingFocusGroupScope, Al as rgbColorValue, Ao as applyCompiledRuntimeFieldsToContent, Ar as LocationMapView, As as isRecord$1, Bc as FocusScope, Bs as unwrapResponse, Co as DEFAULT_THEME_RESPONSIVE_MODE, Dc as hideOthers, Dl as surfaceForegroundInputFromResolved, Eo as heroPhotoPaintsGround, Fc as Content$1, Fn as renderSourceFor, Gc as createCollection, Go as headerStyleRecipeForTheme, Gs as Callout, Hc as DismissableLayer, Ho as componentRuntimeRulesForTheme, Ic as Root2$1, Ir as withValueAtPath, Jc as createContextScope, Ji as buildThemeDataAttrs, Jo as compiledRuntimeStyleFieldNames, K as siteChromeHeaderLogoMayBeHardToSee, Kc as useControllableState, Lc as createPopperScope, Ll as expandPalette, Ln as resolveRenderedValues, Mc as Portal, Ml as mapDrawingStyle, Nc as Anchor, Nl as parseSurfaceTree, No as restoreCompiledRuntimeFieldsFromContent, Oc as Item, Ol as surfaceForegroundStyle, Pc as Arrow, Pl as resolveSurfaceForeground, Pn as remoteDraftValues, Po as formatSiteChromeBackgroundTokenLabel, Qc as Button, Rc as useSize, Rs as ApiEnvelopeError, Uc as useCallbackRef, Uo as designRuntimeRulesForTheme, Vc as useFocusGuards, Wc as useDirection, Ws as VISUALLY_HIDDEN_STYLES, Xc as Primitive, Xi as themeRuntimeScopeProps, Yc as composeEventHandlers, Yo as surfaceResolutionContextFromTheme, Yu as unsafeAsEditorBlockId, _c as usePortalContainer, ac as DialogContent, al as useComposedRefs, ao as coerceInlineTextWithFallback, bo as buildThemeRuntime, c as usePreviewShownTheme, cc as DialogPortal, cd as unsafeAsPositiveSeconds, cs as resolveCompiledSectionContextFromContent, da as siteTopChromeMeasurementTargets$1, el as useControlReadiness, es as buildGoogleFontFamilyQuery, eu as getFontWidthRange, fr as planArrangementContent, h as composePreviewTheme, ia as SITE_CHROME_VISIBLE_HEADER_SELECTOR, ic as DialogClose, id as assertNever, jc as Presence, jo as compileEditorModelRuntime, kc as Root, la as measureSiteTopChromeBottomPx, lc as DialogTitle, mc as menuItemInteractionClassName, ni as getBlockDefinition, nl as createSlot, ns as getSiteFontsStorageUrl, ol as cn$1, oo as deriveInlineTextFieldChanges, ou as authoredValuesEqual, qc as useLayoutEffect2, rc as Dialog, ru as asDesignBlockId, s as usePreviewPageDesignRenderState, sd as unsafeAsPositiveByteCount, ts as generateFontFaceCss, u as useSiteChromeCustomizeOptional, uc as DialogTrigger, un as ApiRequestError, vc as ReactRemoveScroll, wo as getResponsiveScopeSpec, xn as useOptionalEditorUiStoreInstance, xo as escapeStyleContent, xr as resolveBlockVariantKey, y as applyBindingsToContent, zc as useId$1, zs as extractApiEnvelopeErrorDetails } from "./previewAssistantSlot-B61mZd81.mjs";
|
|
4
4
|
import { At as sameMeaningfulAddress, C as Move, Ct as LOCATION_MATCH_THRESHOLDS_METRES, D as MapPin, Dt as editLocationValue, Et as decideLocationSave, Ft as locationPinSchema, I as Info, Kt as err, Mt as decideLocationSourcePermission, Nt as formatLocationAddress, Ot as locationDistanceMetres, Pt as locationAddressSchema, Q as ExternalLink, Rt as parseLocationValue, Tt as decideLocationRelationship, V as House, at as Circle, c as Trash2, ct as CircleCheck, dt as ChevronRight, et as Crosshair, ft as ChevronLeft, g as RotateCcw, gt as Building2, h as Route, kt as sameLocationSpatialPair, l as Store, mt as Check, n as X, p as Search, pt as ChevronDown, qt as ok, r as WifiOff, s as TriangleAlert, ut as ChevronUp, v as Plus, w as Mountain, wt as confirmLocationPair, y as Pencil } from "./lucide-react-Dfgl3Vtq.mjs";
|
|
5
5
|
import { a as NO_EDIT_MAP_OVERLAY, i as useOptionalLocationPickerEnvironment, l as EMPTY_EDIT_MAP_VIEW, r as useLocationPickerWidgetContext, t as LocationDashboardLink } from "./LocationPickerEnvironment-8iKKoYZr.mjs";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -3949,10 +3949,10 @@ const BlockContext = createContext(null);
|
|
|
3949
3949
|
* Provides block information to child widgets.
|
|
3950
3950
|
* Typically used by FormRenderer when editing a block.
|
|
3951
3951
|
*/
|
|
3952
|
-
function BlockContextProvider({ blockKind,
|
|
3952
|
+
function BlockContextProvider({ blockKind, mediaLook, children }) {
|
|
3953
3953
|
const value = {
|
|
3954
3954
|
blockKind,
|
|
3955
|
-
|
|
3955
|
+
mediaLook
|
|
3956
3956
|
};
|
|
3957
3957
|
return /* @__PURE__ */ jsx(BlockContext.Provider, {
|
|
3958
3958
|
value,
|
|
@@ -4519,8 +4519,9 @@ function createLocationPickerState(location) {
|
|
|
4519
4519
|
responseOperation: null,
|
|
4520
4520
|
lastRequest: null,
|
|
4521
4521
|
retryAt: 0,
|
|
4522
|
-
|
|
4522
|
+
saveIntent: "idle",
|
|
4523
4523
|
suggestedName: null,
|
|
4524
|
+
chosenName: null,
|
|
4524
4525
|
adjustment: null,
|
|
4525
4526
|
undo: null,
|
|
4526
4527
|
history: []
|
|
@@ -4535,9 +4536,21 @@ function retainAddressEvidence(previous, next) {
|
|
|
4535
4536
|
...next.addressCheckSettled || previous.addressCheckSettled ? { addressCheckSettled: true } : {}
|
|
4536
4537
|
};
|
|
4537
4538
|
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
return location?.
|
|
4539
|
+
/** A check has already answered for this address, whatever it found. */
|
|
4540
|
+
function addressCheckDone(location) {
|
|
4541
|
+
return location?.addressMatch !== null && location?.addressMatch !== void 0 || location?.addressCheckSettled === true;
|
|
4542
|
+
}
|
|
4543
|
+
/** A pin and an address nothing has compared yet. Without a pin there's nothing to compare, so nothing is owed. */
|
|
4544
|
+
function addressCheckOwed(location) {
|
|
4545
|
+
return location !== null && location.address !== null && location.pin !== null && !addressCheckDone(location);
|
|
4546
|
+
}
|
|
4547
|
+
/** An address check or reverse lookup is on its way; a search never holds a save back. */
|
|
4548
|
+
function placeLookupRunning(state) {
|
|
4549
|
+
return state.request !== null && state.request.input.operation !== "autocomplete";
|
|
4550
|
+
}
|
|
4551
|
+
/** Pending saves resolve by themselves once a lookup replies; every other refusal needs the owner. */
|
|
4552
|
+
function isSavePending(save) {
|
|
4553
|
+
return save.kind === "blocked" && (save.reason === "pending_address_check" || save.reason === "pending_reverse");
|
|
4541
4554
|
}
|
|
4542
4555
|
function pickerCoordinateValue(coordinates) {
|
|
4543
4556
|
if (!coordinates.lat.trim() && !coordinates.lng.trim()) return {
|
|
@@ -4565,11 +4578,7 @@ function pickerSaveDecision(state) {
|
|
|
4565
4578
|
reason: "adjusting_pin"
|
|
4566
4579
|
};
|
|
4567
4580
|
if (state.request && state.request.input.operation !== "autocomplete") return decideLocationSave(state.location, state.request.input.operation);
|
|
4568
|
-
|
|
4569
|
-
kind: "blocked",
|
|
4570
|
-
reason: "unresolved_address"
|
|
4571
|
-
};
|
|
4572
|
-
return decideLocationSave(state.location, state.request?.input.operation ?? "idle");
|
|
4581
|
+
return decideLocationSave(state.location, addressCheckOwed(state.location) ? "address-check" : "idle");
|
|
4573
4582
|
}
|
|
4574
4583
|
function withLocation(state, location) {
|
|
4575
4584
|
return {
|
|
@@ -4597,7 +4606,6 @@ function editDetails(state, details) {
|
|
|
4597
4606
|
};
|
|
4598
4607
|
if (!sameMeaningfulAddress(state.location?.address ?? null, edited.value?.address ?? null)) return {
|
|
4599
4608
|
...next,
|
|
4600
|
-
check: edited.value?.address ? "unresolved" : "idle",
|
|
4601
4609
|
history: []
|
|
4602
4610
|
};
|
|
4603
4611
|
return sameLocationSpatialPair(state.location, edited.value) ? refineDetails(state, next) : rememberMove(state, next);
|
|
@@ -4621,7 +4629,6 @@ function rememberMove(state, next) {
|
|
|
4621
4629
|
...next,
|
|
4622
4630
|
undo: {
|
|
4623
4631
|
location: state.location,
|
|
4624
|
-
check: state.check,
|
|
4625
4632
|
expiresAt: Infinity
|
|
4626
4633
|
},
|
|
4627
4634
|
history: [state.undo, ...state.history].filter((entry) => entry !== null).slice(0, 4)
|
|
@@ -4632,17 +4639,61 @@ const detailsOf = (state) => ({
|
|
|
4632
4639
|
pin: state.location?.pin ?? null,
|
|
4633
4640
|
doorNote: state.location?.doorNote ?? null
|
|
4634
4641
|
});
|
|
4635
|
-
/** One exhaustive dispatch; helpers own edits, lookup lifecycle and draft history. */
|
|
4636
4642
|
function locationPickerReducer(state, action) {
|
|
4643
|
+
return settleSaveIntent(applyAction(state, action));
|
|
4644
|
+
}
|
|
4645
|
+
/** After every change: a waiting save is answered once nothing's pending, or interrupted if its lookup was cancelled. */
|
|
4646
|
+
function settleSaveIntent(state) {
|
|
4647
|
+
switch (state.saveIntent) {
|
|
4648
|
+
case "idle":
|
|
4649
|
+
case "settled": return state;
|
|
4650
|
+
case "waiting":
|
|
4651
|
+
if (!isSavePending(pickerSaveDecision(state))) return {
|
|
4652
|
+
...state,
|
|
4653
|
+
saveIntent: "settled"
|
|
4654
|
+
};
|
|
4655
|
+
return placeLookupRunning(state) ? state : {
|
|
4656
|
+
...state,
|
|
4657
|
+
saveIntent: "interrupted"
|
|
4658
|
+
};
|
|
4659
|
+
case "interrupted": return isSavePending(pickerSaveDecision(state)) ? state : {
|
|
4660
|
+
...state,
|
|
4661
|
+
saveIntent: "idle"
|
|
4662
|
+
};
|
|
4663
|
+
default: return assertNever(state.saveIntent);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
function requestSave(state, action) {
|
|
4667
|
+
if (!action.wait) return {
|
|
4668
|
+
...state,
|
|
4669
|
+
saveIntent: "settled"
|
|
4670
|
+
};
|
|
4671
|
+
const waiting = {
|
|
4672
|
+
...state,
|
|
4673
|
+
saveIntent: "waiting"
|
|
4674
|
+
};
|
|
4675
|
+
if (!action.check) return waiting;
|
|
4676
|
+
return startRequest(state.request?.input.operation === "reverse" ? {
|
|
4677
|
+
...waiting,
|
|
4678
|
+
request: null
|
|
4679
|
+
} : waiting, action.check, action.now);
|
|
4680
|
+
}
|
|
4681
|
+
/** One exhaustive dispatch; helpers own edits, lookup lifecycle and draft history. */
|
|
4682
|
+
function applyAction(state, action) {
|
|
4637
4683
|
switch (action.type) {
|
|
4638
4684
|
case "replace": return {
|
|
4639
4685
|
...createLocationPickerState(retainAddressEvidence(state.location, action.location)),
|
|
4686
|
+
chosenName: state.chosenName,
|
|
4640
4687
|
sequence: state.sequence + 1,
|
|
4641
4688
|
revision: state.revision + 1
|
|
4642
4689
|
};
|
|
4643
4690
|
case "address":
|
|
4644
4691
|
case "note":
|
|
4645
4692
|
case "pin": return editDraft(state, action);
|
|
4693
|
+
case "use-coordinates": return withQuery(editDetails(state, {
|
|
4694
|
+
...detailsOf(state),
|
|
4695
|
+
pin: action.pin
|
|
4696
|
+
}), "");
|
|
4646
4697
|
case "coordinate": return editCoordinate(state, action);
|
|
4647
4698
|
case "query":
|
|
4648
4699
|
case "request":
|
|
@@ -4651,6 +4702,8 @@ function locationPickerReducer(state, action) {
|
|
|
4651
4702
|
case "select":
|
|
4652
4703
|
case "confirm":
|
|
4653
4704
|
case "unconfirm": return choosePair(state, action);
|
|
4705
|
+
case "adopt-location": return adoptLocation(state, action.location);
|
|
4706
|
+
case "use-typed-address": return keepTypedAddress(state, action.text, action.now);
|
|
4654
4707
|
case "put-back":
|
|
4655
4708
|
case "commit-adjustment": return commitPin(state, action);
|
|
4656
4709
|
case "begin-adjustment":
|
|
@@ -4658,6 +4711,15 @@ function locationPickerReducer(state, action) {
|
|
|
4658
4711
|
case "cancel-adjustment": return adjustPin(state, action);
|
|
4659
4712
|
case "remove":
|
|
4660
4713
|
case "undo": return draftHistory(state, action);
|
|
4714
|
+
case "request-save": return requestSave(state, action);
|
|
4715
|
+
case "save-reported": return {
|
|
4716
|
+
...state,
|
|
4717
|
+
saveIntent: "idle"
|
|
4718
|
+
};
|
|
4719
|
+
case "suggestion-taken": return {
|
|
4720
|
+
...state,
|
|
4721
|
+
suggestedName: null
|
|
4722
|
+
};
|
|
4661
4723
|
default: return assertNever(action);
|
|
4662
4724
|
}
|
|
4663
4725
|
}
|
|
@@ -4677,20 +4739,21 @@ function editDraft(state, action) {
|
|
|
4677
4739
|
});
|
|
4678
4740
|
}
|
|
4679
4741
|
function lookupTransition(state, action) {
|
|
4680
|
-
if (action.type === "query") return
|
|
4742
|
+
if (action.type === "query") return withQuery(state, action.query, action.mode);
|
|
4743
|
+
if (action.type === "request") return startRequest(state, action.input, action.now);
|
|
4744
|
+
if (action.type === "reply") return acceptReply(state, action);
|
|
4745
|
+
return state.lastRequest ? startRequest(state, state.lastRequest, action.now) : state;
|
|
4746
|
+
}
|
|
4747
|
+
/** New search text starts over, and only a search is dropped with it. Finishing a choice clears the text this way too. */
|
|
4748
|
+
function withQuery(state, query, mode = state.mode) {
|
|
4749
|
+
return {
|
|
4681
4750
|
...state,
|
|
4682
|
-
query
|
|
4683
|
-
mode
|
|
4751
|
+
query,
|
|
4752
|
+
mode,
|
|
4684
4753
|
candidates: [],
|
|
4685
4754
|
response: null,
|
|
4686
4755
|
request: state.request?.input.operation === "autocomplete" ? null : state.request
|
|
4687
4756
|
};
|
|
4688
|
-
if (action.type === "request") return startRequest(state, action.input, action.now);
|
|
4689
|
-
if (action.type === "reply") return acceptReply(state, action);
|
|
4690
|
-
return state.lastRequest ? startRequest({
|
|
4691
|
-
...state,
|
|
4692
|
-
check: state.lastRequest.operation === "address-check" ? "idle" : state.check
|
|
4693
|
-
}, state.lastRequest, action.now) : state;
|
|
4694
4757
|
}
|
|
4695
4758
|
function choosePair(state, action) {
|
|
4696
4759
|
if (action.type === "select") return selectCandidate(state, action.candidate);
|
|
@@ -4706,14 +4769,10 @@ function choosePair(state, action) {
|
|
|
4706
4769
|
}
|
|
4707
4770
|
function commitPin(state, action) {
|
|
4708
4771
|
const pin = action.type === "put-back" ? state.location?.addressMatch?.point : state.adjustment?.candidate;
|
|
4709
|
-
|
|
4772
|
+
return pin ? editDetails(state, {
|
|
4710
4773
|
...detailsOf(state),
|
|
4711
4774
|
pin
|
|
4712
4775
|
}) : state;
|
|
4713
|
-
return action.type === "put-back" && pin ? {
|
|
4714
|
-
...next,
|
|
4715
|
-
check: "complete"
|
|
4716
|
-
} : next;
|
|
4717
4776
|
}
|
|
4718
4777
|
function adjustPin(state, action) {
|
|
4719
4778
|
if (action.type === "cancel-adjustment") return {
|
|
@@ -4737,11 +4796,10 @@ function beginAdjustment(state) {
|
|
|
4737
4796
|
function draftHistory(state, action) {
|
|
4738
4797
|
if (action.type === "remove") return {
|
|
4739
4798
|
...withLocation(state, null),
|
|
4740
|
-
check: "idle",
|
|
4741
4799
|
authored: true,
|
|
4800
|
+
chosenName: null,
|
|
4742
4801
|
undo: state.location ? {
|
|
4743
4802
|
location: state.location,
|
|
4744
|
-
check: state.check,
|
|
4745
4803
|
expiresAt: action.now + 5e3
|
|
4746
4804
|
} : null,
|
|
4747
4805
|
history: [state.undo, ...state.history].filter((entry) => entry !== null).slice(0, 4)
|
|
@@ -4753,7 +4811,6 @@ function draftHistory(state, action) {
|
|
|
4753
4811
|
};
|
|
4754
4812
|
return {
|
|
4755
4813
|
...withLocation(state, state.undo.location),
|
|
4756
|
-
check: state.undo.check,
|
|
4757
4814
|
authored: true,
|
|
4758
4815
|
undo: state.history[0] ?? null,
|
|
4759
4816
|
history: state.history.slice(1)
|
|
@@ -4778,11 +4835,10 @@ function editCoordinate(state, action) {
|
|
|
4778
4835
|
coordinates
|
|
4779
4836
|
};
|
|
4780
4837
|
}
|
|
4781
|
-
function startRequest(state, input, now) {
|
|
4782
|
-
if (now < state.retryAt) return state;
|
|
4838
|
+
function startRequest(state, input, now, onReply = { kind: "compare" }) {
|
|
4783
4839
|
if (state.request && !(input.operation === "address-check" && state.request.input.operation === "autocomplete")) return state;
|
|
4840
|
+
if (now < state.retryAt) return answerInsideThrottle(state, input, now);
|
|
4784
4841
|
if (input.operation === "autocomplete" && input.query.trim().length < 3) return state;
|
|
4785
|
-
if (input.operation === "address-check" && state.check === "complete") return state;
|
|
4786
4842
|
return {
|
|
4787
4843
|
...state,
|
|
4788
4844
|
sequence: state.sequence + 1,
|
|
@@ -4791,35 +4847,50 @@ function startRequest(state, input, now) {
|
|
|
4791
4847
|
request: {
|
|
4792
4848
|
id: state.sequence + 1,
|
|
4793
4849
|
revision: state.revision,
|
|
4794
|
-
input
|
|
4795
|
-
|
|
4796
|
-
|
|
4850
|
+
input,
|
|
4851
|
+
onReply
|
|
4852
|
+
}
|
|
4797
4853
|
};
|
|
4798
4854
|
}
|
|
4855
|
+
/** Asking inside a throttle window gets the answer a throttled reply would give, without the round trip. */
|
|
4856
|
+
function answerInsideThrottle(state, input, now) {
|
|
4857
|
+
switch (input.operation) {
|
|
4858
|
+
case "address-check": return settleAddressCheck(state);
|
|
4859
|
+
case "autocomplete": return {
|
|
4860
|
+
...state,
|
|
4861
|
+
lastRequest: input,
|
|
4862
|
+
responseOperation: input.operation,
|
|
4863
|
+
response: {
|
|
4864
|
+
kind: "throttled",
|
|
4865
|
+
retryAfterSeconds: Math.ceil((state.retryAt - now) / 1e3)
|
|
4866
|
+
}
|
|
4867
|
+
};
|
|
4868
|
+
case "reverse": return state;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4799
4871
|
/** Opening verification is incidental; an explicit check/reverse belongs to the owner's draft. */
|
|
4800
4872
|
function lookupAuthored(state, operation) {
|
|
4801
4873
|
switch (operation) {
|
|
4802
4874
|
case "autocomplete": return state.authored;
|
|
4803
4875
|
case "reverse": return true;
|
|
4804
|
-
case "address-check": return state.authored || state.
|
|
4876
|
+
case "address-check": return state.authored || !addressCheckOwed(state.location);
|
|
4805
4877
|
}
|
|
4806
4878
|
}
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
if (input.operation !== "address-check") return state.check;
|
|
4810
|
-
return state.check === "opening" ? "opening" : "unresolved";
|
|
4811
|
-
}
|
|
4879
|
+
const isCurrentReply = (state, request) => state.request?.id === request.id && state.revision === request.revision;
|
|
4880
|
+
const retryAtAfter = (response, now, current) => response.kind === "throttled" ? now + response.retryAfterSeconds * 1e3 : current;
|
|
4812
4881
|
function acceptReply(state, action) {
|
|
4813
|
-
if (state
|
|
4814
|
-
const response = action.response
|
|
4882
|
+
if (!isCurrentReply(state, action.request)) return state;
|
|
4883
|
+
const response = isFullSearch(action.request.input) && action.response.kind !== "found" ? { kind: "no-match" } : action.response;
|
|
4884
|
+
const settled = {
|
|
4815
4885
|
...state,
|
|
4816
4886
|
request: null,
|
|
4817
4887
|
response,
|
|
4818
4888
|
responseOperation: action.request.input.operation,
|
|
4819
4889
|
lastRequest: action.request.input,
|
|
4820
|
-
retryAt: response
|
|
4890
|
+
retryAt: retryAtAfter(action.response, action.now, state.retryAt)
|
|
4821
4891
|
};
|
|
4822
|
-
|
|
4892
|
+
if (action.request.onReply.kind === "start-pin") return startPinAtPostcode(settled, action.request.onReply.postcode);
|
|
4893
|
+
const completed = action.request.input.operation === "address-check" ? settleAddressCheck(settled) : settled;
|
|
4823
4894
|
if (response.kind !== "found") return completed;
|
|
4824
4895
|
if (action.request.input.operation === "autocomplete") return {
|
|
4825
4896
|
...settled,
|
|
@@ -4828,53 +4899,68 @@ function acceptReply(state, action) {
|
|
|
4828
4899
|
return applyMatchedAddress(completed, response.candidates[0], action.request.input.operation);
|
|
4829
4900
|
}
|
|
4830
4901
|
/** Completion is durable for the current meaningful address, including an unchecked result. */
|
|
4831
|
-
function
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
...state,
|
|
4836
|
-
|
|
4837
|
-
}
|
|
4838
|
-
|
|
4839
|
-
...state,
|
|
4840
|
-
check: "complete",
|
|
4841
|
-
location: state.location?.address ? {
|
|
4842
|
-
...state.location,
|
|
4843
|
-
addressCheckSettled: true
|
|
4844
|
-
} : state.location
|
|
4845
|
-
};
|
|
4846
|
-
}
|
|
4902
|
+
function settleAddressCheck(state) {
|
|
4903
|
+
return state.location?.address ? {
|
|
4904
|
+
...state,
|
|
4905
|
+
location: {
|
|
4906
|
+
...state.location,
|
|
4907
|
+
addressCheckSettled: true
|
|
4908
|
+
}
|
|
4909
|
+
} : state;
|
|
4847
4910
|
}
|
|
4848
4911
|
function applyMatchedAddress(state, candidate, operation) {
|
|
4849
4912
|
const address = operation === "reverse" ? candidate.address : state.location?.address ?? null;
|
|
4850
4913
|
if (!state.location || address === null) return state;
|
|
4914
|
+
const location = {
|
|
4915
|
+
...state.location,
|
|
4916
|
+
address,
|
|
4917
|
+
addressMatch: candidate.match,
|
|
4918
|
+
ownerConfirmedPinAndAddress: operation === "address-check" && state.location.ownerConfirmedPinAndAddress
|
|
4919
|
+
};
|
|
4920
|
+
const kept = operation === "address-check" ? {
|
|
4921
|
+
adjustment: state.adjustment,
|
|
4922
|
+
undo: state.undo,
|
|
4923
|
+
history: state.history,
|
|
4924
|
+
coordinates: state.coordinates
|
|
4925
|
+
} : {
|
|
4926
|
+
adjustment: null,
|
|
4927
|
+
undo: null,
|
|
4928
|
+
history: []
|
|
4929
|
+
};
|
|
4851
4930
|
return {
|
|
4852
|
-
...withLocation(state,
|
|
4853
|
-
...state.location,
|
|
4854
|
-
address,
|
|
4855
|
-
addressMatch: candidate.match,
|
|
4856
|
-
ownerConfirmedPinAndAddress: operation === "address-check" && state.location.ownerConfirmedPinAndAddress
|
|
4857
|
-
}),
|
|
4858
|
-
check: "complete",
|
|
4931
|
+
...withLocation(state, location),
|
|
4859
4932
|
response: state.response,
|
|
4860
|
-
|
|
4861
|
-
undo: operation === "address-check" ? state.undo : null,
|
|
4862
|
-
history: operation === "address-check" ? state.history : []
|
|
4933
|
+
...kept
|
|
4863
4934
|
};
|
|
4864
4935
|
}
|
|
4865
4936
|
function selectCandidate(state, candidate) {
|
|
4866
4937
|
if (!state.candidates.includes(candidate)) return state;
|
|
4867
4938
|
return {
|
|
4868
|
-
...withLocation(state, {
|
|
4939
|
+
...withQuery(withLocation(state, {
|
|
4869
4940
|
address: candidate.address,
|
|
4870
4941
|
pin: candidate.match.point,
|
|
4871
4942
|
addressMatch: candidate.match,
|
|
4872
4943
|
ownerConfirmedPinAndAddress: false,
|
|
4873
4944
|
doorNote: state.location?.doorNote ?? null
|
|
4874
|
-
}),
|
|
4875
|
-
|
|
4945
|
+
}), ""),
|
|
4946
|
+
authored: true,
|
|
4947
|
+
suggestedName: candidate.kind === "business" ? candidate.name : null,
|
|
4948
|
+
chosenName: candidate.name ? {
|
|
4949
|
+
name: candidate.name,
|
|
4950
|
+
address: candidate.address
|
|
4951
|
+
} : null
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
/** A place the site already holds comes with its own evidence, so it never needs a lookup. The door note stays the draft's. */
|
|
4955
|
+
function adoptLocation(state, place) {
|
|
4956
|
+
return {
|
|
4957
|
+
...withQuery(withLocation(state, {
|
|
4958
|
+
...place,
|
|
4959
|
+
doorNote: state.location?.doorNote ?? null,
|
|
4960
|
+
...place.address && !addressCheckDone(place) ? { addressCheckSettled: true } : {}
|
|
4961
|
+
}), ""),
|
|
4876
4962
|
authored: true,
|
|
4877
|
-
|
|
4963
|
+
chosenName: null
|
|
4878
4964
|
};
|
|
4879
4965
|
}
|
|
4880
4966
|
function confirmPair(state) {
|
|
@@ -4883,14 +4969,86 @@ function confirmPair(state) {
|
|
|
4883
4969
|
return confirmed.ok ? {
|
|
4884
4970
|
...state,
|
|
4885
4971
|
location: confirmed.value,
|
|
4886
|
-
check: "complete",
|
|
4887
4972
|
request: null,
|
|
4888
4973
|
authored: true
|
|
4889
4974
|
} : state;
|
|
4890
4975
|
}
|
|
4976
|
+
const UK_POSTCODE_AT_END = /(?:^|[\s,]+)([A-Z]{1,2}\d[A-Z\d]?)\s*(\d[A-Z]{2})\s*$/i;
|
|
4977
|
+
const samePostcode = (a, b) => a?.replace(/\s/g, "").toUpperCase() === b.replace(/\s/g, "").toUpperCase();
|
|
4978
|
+
/** Text after the last comma is the town, and everything else (or a line with no commas) is the street. */
|
|
4979
|
+
function typedStreetAndTown(text) {
|
|
4980
|
+
const parts = text.split(",").map((part) => part.trim().slice(0, 200)).filter(Boolean);
|
|
4981
|
+
if (parts.length < 2) return {
|
|
4982
|
+
street: parts[0] ?? null,
|
|
4983
|
+
locality: null
|
|
4984
|
+
};
|
|
4985
|
+
return {
|
|
4986
|
+
street: parts.slice(0, -1).join(", ").slice(0, 200),
|
|
4987
|
+
locality: parts.at(-1) ?? null
|
|
4988
|
+
};
|
|
4989
|
+
}
|
|
4990
|
+
/** Keeps what was typed for the owner to correct, with a UK postcode at the end taken off. */
|
|
4991
|
+
function addressFromTypedText(text, mode) {
|
|
4992
|
+
const postcode = UK_POSTCODE_AT_END.exec(text);
|
|
4993
|
+
const typed = typedStreetAndTown(postcode ? text.slice(0, postcode.index) : text);
|
|
4994
|
+
if (!postcode && !typed.street && !typed.locality) return null;
|
|
4995
|
+
const parsed = locationAddressSchema.safeParse({
|
|
4996
|
+
...typed,
|
|
4997
|
+
postalCode: postcode ? postcode.slice(1, 3).join(" ").toUpperCase() : null,
|
|
4998
|
+
country: postcode || mode === "uk" ? "GB" : null
|
|
4999
|
+
});
|
|
5000
|
+
return parsed.success ? parsed.data : null;
|
|
5001
|
+
}
|
|
5002
|
+
/** Saving never depends on a match: the draft is whole now, and a postcode lookup can only add a starting pin. */
|
|
5003
|
+
function keepTypedAddress(state, text, now) {
|
|
5004
|
+
const address = addressFromTypedText(text, state.mode);
|
|
5005
|
+
const edited = editLocationValue(null, {
|
|
5006
|
+
address,
|
|
5007
|
+
pin: null,
|
|
5008
|
+
doorNote: state.location?.doorNote ?? null
|
|
5009
|
+
});
|
|
5010
|
+
if (!edited.ok || edited.value === null) return state;
|
|
5011
|
+
const next = {
|
|
5012
|
+
...withQuery(withLocation(state, edited.value), ""),
|
|
5013
|
+
authored: true,
|
|
5014
|
+
chosenName: null
|
|
5015
|
+
};
|
|
5016
|
+
const postcode = address?.postalCode;
|
|
5017
|
+
return postcode ? startRequest(next, {
|
|
5018
|
+
operation: "address-check",
|
|
5019
|
+
query: postcode,
|
|
5020
|
+
mode: "uk"
|
|
5021
|
+
}, now, {
|
|
5022
|
+
kind: "start-pin",
|
|
5023
|
+
postcode
|
|
5024
|
+
}) : next;
|
|
5025
|
+
}
|
|
5026
|
+
/** A postcode is a neighbourhood, whatever the provider calls the result, so the status asks the owner to move the pin. */
|
|
5027
|
+
function startPinAtPostcode(state, postcode) {
|
|
5028
|
+
const found = state.response?.kind === "found" ? state.response.candidates.find((candidate) => samePostcode(candidate.address.postalCode, postcode)) : void 0;
|
|
5029
|
+
if (!found || !state.location) return settleAddressCheck(state);
|
|
5030
|
+
return {
|
|
5031
|
+
...withLocation(state, {
|
|
5032
|
+
...state.location,
|
|
5033
|
+
pin: found.match.point,
|
|
5034
|
+
addressMatch: {
|
|
5035
|
+
...found.match,
|
|
5036
|
+
precision: "area"
|
|
5037
|
+
}
|
|
5038
|
+
}),
|
|
5039
|
+
response: state.response
|
|
5040
|
+
};
|
|
5041
|
+
}
|
|
5042
|
+
const FULL_SEARCH_MIN_LENGTH = 8;
|
|
5043
|
+
const isFullSearch = (input) => input.operation === "autocomplete" && input.fullSearch === true;
|
|
5044
|
+
/** Autocomplete found nothing for this exact text, it's long enough to be an address, and the fuller search hasn't had a go. */
|
|
5045
|
+
function wantsFullSearch(state) {
|
|
5046
|
+
const last = state.lastRequest;
|
|
5047
|
+
return state.responseOperation === "autocomplete" && state.response?.kind === "no-match" && last?.operation === "autocomplete" && !last.fullSearch && last.query === state.query.trim() && last.query.length >= FULL_SEARCH_MIN_LENGTH;
|
|
5048
|
+
}
|
|
4891
5049
|
/** Completed legacy opening checks may be recorded without making the draft an owner edit. */
|
|
4892
5050
|
function openingCheckEvidence(previous, state) {
|
|
4893
|
-
if (
|
|
5051
|
+
if (!addressCheckOwed(previous) || state.authored || addressCheckOwed(state.location) || !state.location || !sameLocationSpatialPair(previous, state.location)) return null;
|
|
4894
5052
|
return state.location;
|
|
4895
5053
|
}
|
|
4896
5054
|
//#endregion
|
|
@@ -4901,9 +5059,13 @@ function openingCheckEvidence(previous, state) {
|
|
|
4901
5059
|
*/
|
|
4902
5060
|
/** Below this the pin is drawn on the address point, so the status says "on" rather than "moved". */
|
|
4903
5061
|
const SAME_SPOT_METRES = 3;
|
|
4904
|
-
/** The
|
|
5062
|
+
/** The most specific thing people typed or would recognise. Every name for a place starts here. */
|
|
5063
|
+
function placeName(address) {
|
|
5064
|
+
return address?.building ?? address?.street ?? address?.locality ?? address?.postalCode ?? null;
|
|
5065
|
+
}
|
|
5066
|
+
/** The words the status uses for "the address". */
|
|
4905
5067
|
function addressName(address) {
|
|
4906
|
-
return address
|
|
5068
|
+
return placeName(address) ?? "the address";
|
|
4907
5069
|
}
|
|
4908
5070
|
const roundedMetres = (a, b) => Math.round(locationDistanceMetres(a, b));
|
|
4909
5071
|
/** All placement instructions consume the primary-pointer decision made by the map area. */
|
|
@@ -4932,12 +5094,11 @@ function describePinStatus(state, addressEdited) {
|
|
|
4932
5094
|
canPlaceOnAddress: location.addressMatch !== null
|
|
4933
5095
|
};
|
|
4934
5096
|
if (location.address === null) return { kind: "pin-only" };
|
|
4935
|
-
if (state.
|
|
5097
|
+
if (addressCheckOwed(location)) return state.authored ? { kind: "address-edited" } : {
|
|
4936
5098
|
kind: "checking",
|
|
4937
5099
|
operation: "address-check",
|
|
4938
5100
|
hasPin: true
|
|
4939
5101
|
};
|
|
4940
|
-
if (state.check === "unresolved") return { kind: "address-edited" };
|
|
4941
5102
|
return comparedStatus(location, location.pin, state.undo !== null, addressEdited);
|
|
4942
5103
|
}
|
|
4943
5104
|
function comparedStatus(location, pin, movedThisSession, addressEdited) {
|
|
@@ -5006,7 +5167,7 @@ function countryName(country) {
|
|
|
5006
5167
|
*/
|
|
5007
5168
|
function resultLines(candidate, homeCountry) {
|
|
5008
5169
|
const address = candidate.address;
|
|
5009
|
-
const title = candidate.name ?? address
|
|
5170
|
+
const title = candidate.name ?? placeName(address) ?? candidate.label;
|
|
5010
5171
|
return {
|
|
5011
5172
|
title,
|
|
5012
5173
|
detail: [[address.street, [address.locality, address.postalCode].filter(Boolean).join(" ")].filter((part) => Boolean(part) && part !== title).join(", "), address.country !== null && address.country !== homeCountry ? countryName(address.country) : null].filter(Boolean).join(" · ")
|
|
@@ -5045,7 +5206,7 @@ function searchedCoordinates(query) {
|
|
|
5045
5206
|
}
|
|
5046
5207
|
/** What the chosen-place row shows: a remembered business name while the address is unchanged. */
|
|
5047
5208
|
function chosenPlaceLines(address, chosenName) {
|
|
5048
|
-
const title = (chosenName !== null && sameMeaningfulAddress(chosenName.address, address) ? chosenName.name : null) ?? address
|
|
5209
|
+
const title = (chosenName !== null && sameMeaningfulAddress(chosenName.address, address) ? chosenName.name : null) ?? placeName(address) ?? "Place";
|
|
5049
5210
|
return {
|
|
5050
5211
|
title,
|
|
5051
5212
|
detail: [
|
|
@@ -5057,6 +5218,14 @@ function chosenPlaceLines(address, chosenName) {
|
|
|
5057
5218
|
].filter((part) => Boolean(part) && part !== title).join(", ")
|
|
5058
5219
|
};
|
|
5059
5220
|
}
|
|
5221
|
+
/** The site's business address as a place to use. A saved pin with no address has nothing to offer. */
|
|
5222
|
+
function businessAddressOffer(location, siteCountry) {
|
|
5223
|
+
const line = formatLocationAddress(location?.address ?? null, siteCountry);
|
|
5224
|
+
return location && line ? {
|
|
5225
|
+
location,
|
|
5226
|
+
line
|
|
5227
|
+
} : null;
|
|
5228
|
+
}
|
|
5060
5229
|
function regionLabel(country) {
|
|
5061
5230
|
return country === "GB" ? "County" : country === "US" ? "State" : "Region";
|
|
5062
5231
|
}
|
|
@@ -5074,13 +5243,14 @@ const KIND_ICON = {
|
|
|
5074
5243
|
};
|
|
5075
5244
|
const MIN_QUERY = 3;
|
|
5076
5245
|
/** The search combobox and its result list. Choosing a row is the only thing that changes the draft. */
|
|
5077
|
-
function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurrent, onChosen,
|
|
5246
|
+
function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurrent, businessOffer, onBusinessAddress, onChosen, onTyped, onCoordinates, announce }) {
|
|
5078
5247
|
const { state, dispatch } = controller;
|
|
5079
5248
|
const [open, setOpen] = useState(false);
|
|
5080
5249
|
const [activeKey, setActiveKey] = useState(null);
|
|
5081
5250
|
const input = useRef(null);
|
|
5082
5251
|
const listId = `${idBase}-results`;
|
|
5083
|
-
const rows = searchRows(state);
|
|
5252
|
+
const rows = searchRows(state, businessOffer);
|
|
5253
|
+
const showList = open && (state.query !== "" || rows.length > 0);
|
|
5084
5254
|
const active = rows.findIndex((row) => rowKey(row) === activeKey);
|
|
5085
5255
|
const setActive = (index) => setActiveKey(rows[index] ? rowKey(rows[index]) : null);
|
|
5086
5256
|
const homeCountry = siteCountry ?? (state.mode === "uk" ? "GB" : null);
|
|
@@ -5088,9 +5258,10 @@ function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurr
|
|
|
5088
5258
|
const choose = (row) => {
|
|
5089
5259
|
setOpen(false);
|
|
5090
5260
|
setActive(-1);
|
|
5091
|
-
if (row.kind === "
|
|
5261
|
+
if (row.kind === "business") onBusinessAddress(row.offer);
|
|
5262
|
+
else if (row.kind === "candidate") onChosen(row.candidate);
|
|
5092
5263
|
else if (row.kind === "coordinates") onCoordinates(row.pin);
|
|
5093
|
-
else
|
|
5264
|
+
else onTyped(row.text);
|
|
5094
5265
|
};
|
|
5095
5266
|
const onKeyDown = (event) => {
|
|
5096
5267
|
const next = searchKey(event.key, {
|
|
@@ -5141,7 +5312,7 @@ function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurr
|
|
|
5141
5312
|
children: "Keep it"
|
|
5142
5313
|
})
|
|
5143
5314
|
]
|
|
5144
|
-
}) : null,
|
|
5315
|
+
}) : null, showList ? /* @__PURE__ */ jsx(ResultList, {
|
|
5145
5316
|
controller,
|
|
5146
5317
|
rows,
|
|
5147
5318
|
active,
|
|
@@ -5163,7 +5334,7 @@ function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurr
|
|
|
5163
5334
|
id,
|
|
5164
5335
|
role: "combobox",
|
|
5165
5336
|
"aria-autocomplete": "list",
|
|
5166
|
-
"aria-expanded":
|
|
5337
|
+
"aria-expanded": showList,
|
|
5167
5338
|
"aria-controls": listId,
|
|
5168
5339
|
"aria-activedescendant": open && active >= 0 ? `${idBase}-row-${active}` : void 0,
|
|
5169
5340
|
"aria-describedby": messageId,
|
|
@@ -5173,7 +5344,7 @@ function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurr
|
|
|
5173
5344
|
value: state.query,
|
|
5174
5345
|
onKeyDown,
|
|
5175
5346
|
onFocus: () => {
|
|
5176
|
-
if (state.query) setOpen(true);
|
|
5347
|
+
if (state.query || rows.length > 0) setOpen(true);
|
|
5177
5348
|
},
|
|
5178
5349
|
onChange: (event) => {
|
|
5179
5350
|
dispatch({
|
|
@@ -5208,7 +5379,7 @@ function PlaceSearch({ controller, idBase, siteCountry, changingFrom, onKeepCurr
|
|
|
5208
5379
|
const IGNORE = { kind: "ignore" };
|
|
5209
5380
|
/** Down/Up move through results, Enter chooses, the first Escape closes the list and the second clears the text. */
|
|
5210
5381
|
const SEARCH_KEYS = {
|
|
5211
|
-
ArrowDown: (list) => list.hasQuery ? {
|
|
5382
|
+
ArrowDown: (list) => list.hasQuery || list.count > 0 ? {
|
|
5212
5383
|
kind: "move",
|
|
5213
5384
|
active: list.open ? Math.min(list.count - 1, list.active + 1) : 0
|
|
5214
5385
|
} : IGNORE,
|
|
@@ -5222,11 +5393,19 @@ const SEARCH_KEYS = {
|
|
|
5222
5393
|
function searchKey(key, list) {
|
|
5223
5394
|
return SEARCH_KEYS[key]?.(list) ?? IGNORE;
|
|
5224
5395
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5396
|
+
/** Text long enough to mean something can be kept as typed, and any text can once search has failed, as long as it reads as an address. */
|
|
5397
|
+
function canKeepTypedText(state) {
|
|
5227
5398
|
const failed = state.responseOperation === "autocomplete" && (state.response?.kind === "unavailable" || state.response?.kind === "throttled");
|
|
5228
|
-
const
|
|
5399
|
+
const text = state.query.trim();
|
|
5400
|
+
return (text.length >= MIN_QUERY || failed) && coordinateSearch(state.query).kind === "place" && addressFromTypedText(text, state.mode) !== null;
|
|
5401
|
+
}
|
|
5402
|
+
function searchRows(state, businessOffer) {
|
|
5403
|
+
const coordinates = searchedCoordinates(state.query);
|
|
5229
5404
|
return [
|
|
5405
|
+
...businessOffer ? [{
|
|
5406
|
+
kind: "business",
|
|
5407
|
+
offer: businessOffer
|
|
5408
|
+
}] : [],
|
|
5230
5409
|
...coordinates ? [{
|
|
5231
5410
|
kind: "coordinates",
|
|
5232
5411
|
pin: coordinates
|
|
@@ -5235,7 +5414,10 @@ function searchRows(state) {
|
|
|
5235
5414
|
kind: "candidate",
|
|
5236
5415
|
candidate
|
|
5237
5416
|
})),
|
|
5238
|
-
...
|
|
5417
|
+
...canKeepTypedText(state) ? [{
|
|
5418
|
+
kind: "typed",
|
|
5419
|
+
text: state.query.trim()
|
|
5420
|
+
}] : []
|
|
5239
5421
|
];
|
|
5240
5422
|
}
|
|
5241
5423
|
/** Screen readers hear the count once results arrive, or that nothing matched. */
|
|
@@ -5251,7 +5433,7 @@ function ResultList({ controller, rows, active, listId, idBase, homeCountry, onC
|
|
|
5251
5433
|
const { state } = controller;
|
|
5252
5434
|
return /* @__PURE__ */ jsxs("div", {
|
|
5253
5435
|
className: "mt-1.5 overflow-hidden rounded-[var(--item-radius)] border border-border bg-background shadow-[0_8px_24px_rgba(60,50,45,0.12)]",
|
|
5254
|
-
children: [/* @__PURE__ */ jsx(ResultListHead, { controller }), /* @__PURE__ */ jsx("ul", {
|
|
5436
|
+
children: [state.query !== "" ? /* @__PURE__ */ jsx(ResultListHead, { controller }) : null, /* @__PURE__ */ jsx("ul", {
|
|
5255
5437
|
role: "listbox",
|
|
5256
5438
|
id: listId,
|
|
5257
5439
|
"aria-label": "Places",
|
|
@@ -5262,7 +5444,7 @@ function ResultList({ controller, rows, active, listId, idBase, homeCountry, onC
|
|
|
5262
5444
|
id: `${idBase}-row-${index}`,
|
|
5263
5445
|
selected: index === active,
|
|
5264
5446
|
query: state.query,
|
|
5265
|
-
separated: row.kind === "
|
|
5447
|
+
separated: row.kind === "typed" && index > 0,
|
|
5266
5448
|
onChoose: () => onChoose(row),
|
|
5267
5449
|
onHover: () => onHover(index)
|
|
5268
5450
|
}, rowKey(row)))
|
|
@@ -5347,7 +5529,7 @@ function NoMatch({ controller, query }) {
|
|
|
5347
5529
|
}),
|
|
5348
5530
|
/* @__PURE__ */ jsx("p", {
|
|
5349
5531
|
className: "m-0 mb-1.5 text-[13px] text-muted-foreground",
|
|
5350
|
-
children: "Check the spelling, or try just the postcode, or the street and town. If your place isn't listed,
|
|
5532
|
+
children: "Check the spelling, or try just the postcode, or the street and town. If your place isn't listed, choose Use this address as typed below and you can correct it."
|
|
5351
5533
|
}),
|
|
5352
5534
|
/* @__PURE__ */ jsx("p", {
|
|
5353
5535
|
className: "m-0 text-[13px]",
|
|
@@ -5373,7 +5555,7 @@ function SearchDown({ controller, retryAfter }) {
|
|
|
5373
5555
|
children: [
|
|
5374
5556
|
"Whatever you've typed is kept. ",
|
|
5375
5557
|
retryAfter === null ? "You can try again" : `You can try again in ${retryAfter} seconds`,
|
|
5376
|
-
", or
|
|
5558
|
+
", or choose Use this address as typed below."
|
|
5377
5559
|
]
|
|
5378
5560
|
}),
|
|
5379
5561
|
retryAfter === null ? /* @__PURE__ */ jsx("p", {
|
|
@@ -5414,7 +5596,7 @@ function SearchRowItem({ row, homeCountry, id, selected, query, separated, onCho
|
|
|
5414
5596
|
className: cn$1("flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2", selected && "bg-accent", "hover:bg-accent", separated && "mt-1 rounded-t-none border-t border-border"),
|
|
5415
5597
|
children: [
|
|
5416
5598
|
/* @__PURE__ */ jsx("span", {
|
|
5417
|
-
className: cn$1("grid size-7 flex-none place-items-center rounded-lg text-[color:var(--primary-ink,var(--primary))]", row.kind === "
|
|
5599
|
+
className: cn$1("grid size-7 flex-none place-items-center rounded-lg text-[color:var(--primary-ink,var(--primary))]", row.kind === "typed" ? "border border-dashed border-[color:var(--field-border-strong)]" : "bg-[var(--surface,var(--muted))]"),
|
|
5418
5600
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
5419
5601
|
className: "size-4",
|
|
5420
5602
|
"aria-hidden": "true"
|
|
@@ -5444,10 +5626,16 @@ function SearchRowItem({ row, homeCountry, id, selected, query, separated, onCho
|
|
|
5444
5626
|
});
|
|
5445
5627
|
}
|
|
5446
5628
|
function rowContent(row, homeCountry) {
|
|
5447
|
-
if (row.kind === "
|
|
5448
|
-
icon:
|
|
5449
|
-
title: "
|
|
5450
|
-
detail:
|
|
5629
|
+
if (row.kind === "business") return {
|
|
5630
|
+
icon: House,
|
|
5631
|
+
title: "Use your business address",
|
|
5632
|
+
detail: row.offer.line,
|
|
5633
|
+
kind: null
|
|
5634
|
+
};
|
|
5635
|
+
if (row.kind === "typed") return {
|
|
5636
|
+
icon: Pencil,
|
|
5637
|
+
title: "Use this address as typed",
|
|
5638
|
+
detail: row.text,
|
|
5451
5639
|
kind: null
|
|
5452
5640
|
};
|
|
5453
5641
|
if (row.kind === "coordinates") return {
|
|
@@ -5505,18 +5693,18 @@ function ChosenPlace({ address, chosenName, siteCountry, fieldsOpen, onToggleFie
|
|
|
5505
5693
|
className: "rb-chosen-actions flex flex-none gap-0.5",
|
|
5506
5694
|
children: [/* @__PURE__ */ jsxs(Button, {
|
|
5507
5695
|
type: "button",
|
|
5508
|
-
variant: "
|
|
5696
|
+
variant: "link",
|
|
5509
5697
|
size: "sm",
|
|
5510
|
-
className: "h-7 px-2.5 text-[13px]
|
|
5698
|
+
className: "h-7 px-2.5 text-[13px]",
|
|
5511
5699
|
"aria-expanded": fieldsOpen,
|
|
5512
5700
|
"aria-controls": `${idBase}-fields`,
|
|
5513
5701
|
onClick: onToggleFields,
|
|
5514
5702
|
children: [/* @__PURE__ */ jsx(Pencil, { "aria-hidden": "true" }), fieldsOpen ? "Hide address" : "Edit address"]
|
|
5515
5703
|
}), /* @__PURE__ */ jsx(Button, {
|
|
5516
5704
|
type: "button",
|
|
5517
|
-
variant: "
|
|
5705
|
+
variant: "link",
|
|
5518
5706
|
size: "sm",
|
|
5519
|
-
className: "h-7 px-2.5 text-[13px]
|
|
5707
|
+
className: "h-7 px-2.5 text-[13px]",
|
|
5520
5708
|
onClick: onChange,
|
|
5521
5709
|
children: "Change"
|
|
5522
5710
|
})]
|
|
@@ -6212,27 +6400,22 @@ const PREVIEW_CAPTION = {
|
|
|
6212
6400
|
drawing: "Drawing the map for this spot. It'll appear here when it's ready.",
|
|
6213
6401
|
"details-only": null
|
|
6214
6402
|
};
|
|
6215
|
-
function PinTab(
|
|
6403
|
+
function PinTab(props) {
|
|
6216
6404
|
const [coordsOpen, setCoordsOpen] = useState(false);
|
|
6217
6405
|
const [availability, setAvailability] = useState("loading");
|
|
6218
6406
|
const unavailable = availability === "unavailable";
|
|
6219
6407
|
const showCoords = coordsOpen || unavailable || props.coordinatesError !== null;
|
|
6220
6408
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6221
|
-
/* @__PURE__ */ jsxs("div", {
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
...props,
|
|
6232
|
-
onAvailabilityChange: setAvailability
|
|
6233
|
-
})
|
|
6234
|
-
})]
|
|
6235
|
-
}),
|
|
6409
|
+
/* @__PURE__ */ jsxs("div", { children: [unavailable ? /* @__PURE__ */ jsx("p", {
|
|
6410
|
+
className: "m-0 mb-2 rounded-[var(--item-radius)] bg-accent px-3 py-2.5 text-[13.5px]",
|
|
6411
|
+
children: "The map couldn't load just now. You can still type the pin's coordinates below."
|
|
6412
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
6413
|
+
hidden: unavailable,
|
|
6414
|
+
children: /* @__PURE__ */ jsx(PinMap, {
|
|
6415
|
+
...props,
|
|
6416
|
+
onAvailabilityChange: setAvailability
|
|
6417
|
+
})
|
|
6418
|
+
})] }),
|
|
6236
6419
|
!props.touch ? /* @__PURE__ */ jsx("p", {
|
|
6237
6420
|
className: "sr-only",
|
|
6238
6421
|
id: `${props.idBase}-pinhelp`,
|
|
@@ -6243,9 +6426,9 @@ function PinTab({ mapRef, ...props }) {
|
|
|
6243
6426
|
className: "flex flex-wrap items-center justify-between gap-2",
|
|
6244
6427
|
children: /* @__PURE__ */ jsx(Button, {
|
|
6245
6428
|
type: "button",
|
|
6246
|
-
variant: "
|
|
6429
|
+
variant: "link",
|
|
6247
6430
|
size: "sm",
|
|
6248
|
-
className: "h-7 px-2.5 text-[13px]
|
|
6431
|
+
className: "h-7 px-2.5 text-[13px]",
|
|
6249
6432
|
"aria-expanded": showCoords,
|
|
6250
6433
|
"aria-controls": `${props.idBase}-coordinates`,
|
|
6251
6434
|
onClick: () => setCoordsOpen((open) => !open),
|
|
@@ -6611,11 +6794,11 @@ function statusContent(view, actions, touch) {
|
|
|
6611
6794
|
};
|
|
6612
6795
|
case "address-edited": return {
|
|
6613
6796
|
tone: "info",
|
|
6614
|
-
body: "You've changed the address. We'll check it against the pin when you leave
|
|
6797
|
+
body: "You've changed the address. We'll check it against the pin when you leave this field, or when you save."
|
|
6615
6798
|
};
|
|
6616
6799
|
case "unchecked": return {
|
|
6617
6800
|
tone: "info",
|
|
6618
|
-
body: "We couldn't
|
|
6801
|
+
body: "We couldn't check this address on the map, so we can't compare it with the pin. Make sure the pin's in the right place."
|
|
6619
6802
|
};
|
|
6620
6803
|
case "on": return {
|
|
6621
6804
|
tone: "ok",
|
|
@@ -6630,11 +6813,16 @@ function statusContent(view, actions, touch) {
|
|
|
6630
6813
|
case "approximate": return {
|
|
6631
6814
|
tone: "warn",
|
|
6632
6815
|
body: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6633
|
-
"
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6816
|
+
view.precision === "street" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6817
|
+
"“",
|
|
6818
|
+
view.name,
|
|
6819
|
+
"” is a whole street, not a single building, so the pin's somewhere in the middle."
|
|
6820
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6821
|
+
"We only know roughly where “",
|
|
6822
|
+
view.name,
|
|
6823
|
+
"” is, so the pin's somewhere nearby."
|
|
6824
|
+
] }),
|
|
6825
|
+
" Move it to where people should arrive.",
|
|
6638
6826
|
/* @__PURE__ */ jsx(UndoLink, { undo: actions.undo })
|
|
6639
6827
|
] })
|
|
6640
6828
|
};
|
|
@@ -6723,11 +6911,17 @@ function farBody(view, actions) {
|
|
|
6723
6911
|
}
|
|
6724
6912
|
//#endregion
|
|
6725
6913
|
//#region ../editor-blocks/src/widgets/location/useSiteCountry.ts
|
|
6914
|
+
const NO_FACTS = {
|
|
6915
|
+
country: null,
|
|
6916
|
+
businessLocation: null
|
|
6917
|
+
};
|
|
6726
6918
|
/**
|
|
6727
|
-
*
|
|
6728
|
-
*
|
|
6919
|
+
* What the picker needs to know about the site, from one read.
|
|
6920
|
+
* The country lets "On your site this reads…" leave it out the way the site does, from the same source as the
|
|
6921
|
+
* server's getSiteLocationCountry: the saved business address country, falling back to its configured locale/currency.
|
|
6922
|
+
* The business location is what "Use your business address" offers.
|
|
6729
6923
|
*/
|
|
6730
|
-
function
|
|
6924
|
+
function useSiteAddressFacts(siteId) {
|
|
6731
6925
|
const apiClient = useOptionalLocationPickerEnvironment()?.apiClient;
|
|
6732
6926
|
const [loaded, setLoaded] = useState(null);
|
|
6733
6927
|
useEffect(() => {
|
|
@@ -6739,21 +6933,26 @@ function useSiteCountry(siteId) {
|
|
|
6739
6933
|
}).then(unwrapResponse).then((response) => {
|
|
6740
6934
|
if (!lifetime.signal.aborted) setLoaded({
|
|
6741
6935
|
siteId,
|
|
6742
|
-
|
|
6936
|
+
facts: {
|
|
6937
|
+
country: response.siteCountry ?? null,
|
|
6938
|
+
businessLocation: response.locationValue ?? null
|
|
6939
|
+
}
|
|
6743
6940
|
});
|
|
6744
6941
|
}).catch(() => {});
|
|
6745
6942
|
return () => lifetime.abort();
|
|
6746
6943
|
}, [siteId, apiClient]);
|
|
6747
|
-
return loaded?.siteId === siteId ? loaded.
|
|
6944
|
+
return loaded?.siteId === siteId ? loaded.facts : NO_FACTS;
|
|
6748
6945
|
}
|
|
6749
6946
|
//#endregion
|
|
6750
6947
|
//#region ../editor-blocks/src/widgets/location/LocationPicker.tsx
|
|
6751
|
-
const
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6948
|
+
const SAVE_REFUSAL = {
|
|
6949
|
+
invalid_coordinates: "Enter both valid coordinates, or clear both.",
|
|
6950
|
+
adjusting_pin: "Finish adjusting the pin first: choose Use this spot or Cancel.",
|
|
6951
|
+
unconfirmed_mismatch: "The pin and the address look like different places. Choose which is right before saving.",
|
|
6952
|
+
pending_address_check: "We're still checking the address against the pin. Try saving again in a moment.",
|
|
6953
|
+
pending_reverse: "We're still finding the address at the pin. Try saving again in a moment."
|
|
6756
6954
|
};
|
|
6955
|
+
const pickerSaveMessage = (save) => save.kind === "ready" ? null : SAVE_REFUSAL[save.reason];
|
|
6757
6956
|
const REMOVAL = {
|
|
6758
6957
|
venue: {
|
|
6759
6958
|
title: "Remove this venue's location?",
|
|
@@ -6781,7 +6980,8 @@ function LocationPicker(props) {
|
|
|
6781
6980
|
const { controller, context } = props;
|
|
6782
6981
|
const idBase = `location-${useId().replace(/[^a-zA-Z0-9-]/g, "")}`;
|
|
6783
6982
|
const ui = usePickerUi(controller, idBase);
|
|
6784
|
-
const siteCountry =
|
|
6983
|
+
const { country: siteCountry, businessLocation } = useSiteAddressFacts(controller.siteId);
|
|
6984
|
+
const businessOffer = props.offerBusinessAddress ? businessAddressOffer(businessLocation, siteCountry) : null;
|
|
6785
6985
|
useReportDecision(props);
|
|
6786
6986
|
const ownRemoval = useLocationRemoval();
|
|
6787
6987
|
const removal = props.removal ?? ownRemoval;
|
|
@@ -6796,11 +6996,7 @@ function LocationPicker(props) {
|
|
|
6796
6996
|
"aria-live": "polite",
|
|
6797
6997
|
children: ui.announcement
|
|
6798
6998
|
}),
|
|
6799
|
-
/* @__PURE__ */ jsx(
|
|
6800
|
-
context,
|
|
6801
|
-
canRemove: context === "venue" && location !== null,
|
|
6802
|
-
onRemove: removal.ask
|
|
6803
|
-
}),
|
|
6999
|
+
context === "venue" && location !== null ? /* @__PURE__ */ jsx(RemoveLocationButton, { onRemove: removal.ask }) : null,
|
|
6804
7000
|
removal.confirming && location ? /* @__PURE__ */ jsx(RemoveConfirmation, {
|
|
6805
7001
|
context,
|
|
6806
7002
|
onKeep: removal.keep,
|
|
@@ -6816,26 +7012,46 @@ function LocationPicker(props) {
|
|
|
6816
7012
|
controller,
|
|
6817
7013
|
ui,
|
|
6818
7014
|
idBase,
|
|
6819
|
-
siteCountry
|
|
7015
|
+
siteCountry,
|
|
7016
|
+
businessOffer
|
|
6820
7017
|
}),
|
|
6821
|
-
|
|
7018
|
+
/* @__PURE__ */ jsx(PickerDraftFields, {
|
|
6822
7019
|
controller,
|
|
7020
|
+
ui,
|
|
6823
7021
|
idBase,
|
|
6824
7022
|
siteCountry,
|
|
6825
|
-
streetRef: ui.streetRef,
|
|
6826
|
-
onAddressEdit: ui.setEditedAddress
|
|
6827
|
-
}) : null,
|
|
6828
|
-
location && !ui.changing ? /* @__PURE__ */ jsx(PickerDoorNote, {
|
|
6829
|
-
controller,
|
|
6830
7023
|
context,
|
|
6831
|
-
|
|
6832
|
-
})
|
|
7024
|
+
doorNoteHint: props.doorNoteHint
|
|
7025
|
+
}),
|
|
6833
7026
|
/* @__PURE__ */ jsx(PickerMapArea, { ...mapAreaProps(props, ui, idBase) })
|
|
6834
7027
|
]
|
|
6835
7028
|
})
|
|
6836
7029
|
]
|
|
6837
7030
|
});
|
|
6838
7031
|
}
|
|
7032
|
+
/** The address fields and door note, for a place that's in use and not being changed. */
|
|
7033
|
+
function PickerDraftFields({ controller, ui, idBase, siteCountry, context, doorNoteHint }) {
|
|
7034
|
+
if (!controller.state.location || ui.changing) return null;
|
|
7035
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
7036
|
+
controller.saveInterrupted ? /* @__PURE__ */ jsx("p", {
|
|
7037
|
+
role: "status",
|
|
7038
|
+
className: "m-0 text-sm text-muted-foreground",
|
|
7039
|
+
children: "You changed this while we were checking the address, so it hasn't saved yet. Save again when you're ready."
|
|
7040
|
+
}) : null,
|
|
7041
|
+
ui.fieldsOpen ? /* @__PURE__ */ jsx(PickerAddressFields, {
|
|
7042
|
+
controller,
|
|
7043
|
+
idBase,
|
|
7044
|
+
siteCountry,
|
|
7045
|
+
streetRef: ui.streetRef,
|
|
7046
|
+
onAddressEdit: ui.setEditedAddress
|
|
7047
|
+
}) : null,
|
|
7048
|
+
/* @__PURE__ */ jsx(PickerDoorNote, {
|
|
7049
|
+
controller,
|
|
7050
|
+
context,
|
|
7051
|
+
hint: doorNoteHint
|
|
7052
|
+
})
|
|
7053
|
+
] });
|
|
7054
|
+
}
|
|
6839
7055
|
/** Reveal happens during render; focus waits until the pin tab and coordinate fields exist. */
|
|
6840
7056
|
function useSaveRefusalFocus(props) {
|
|
6841
7057
|
const root = useRef(null);
|
|
@@ -6852,41 +7068,40 @@ function useSaveRefusalFocus(props) {
|
|
|
6852
7068
|
}, [errors.status, errors.coordinates]);
|
|
6853
7069
|
return root;
|
|
6854
7070
|
}
|
|
6855
|
-
/** Parents receive the decided save value, and an offered business name
|
|
7071
|
+
/** Parents receive the decided save value whenever the draft changes, and an offered business name once. */
|
|
6856
7072
|
function useReportDecision({ controller, onDecision, onSuggestedName }) {
|
|
6857
|
-
const { state, save } = controller;
|
|
6858
|
-
const decided = useEffectEvent(() =>
|
|
6859
|
-
onDecision?.(save);
|
|
6860
|
-
if (state.suggestedName) onSuggestedName?.(state.suggestedName);
|
|
6861
|
-
});
|
|
7073
|
+
const { state, save, dispatch } = controller;
|
|
7074
|
+
const decided = useEffectEvent(() => onDecision?.(save));
|
|
6862
7075
|
useLayoutEffect(() => {
|
|
6863
7076
|
decided();
|
|
6864
7077
|
}, [state]);
|
|
7078
|
+
const offered = state.suggestedName;
|
|
7079
|
+
const offer = useEffectEvent((name) => onSuggestedName?.(name));
|
|
7080
|
+
useLayoutEffect(() => {
|
|
7081
|
+
if (!offered) return;
|
|
7082
|
+
offer(offered);
|
|
7083
|
+
dispatch({ type: "suggestion-taken" });
|
|
7084
|
+
}, [offered, dispatch]);
|
|
6865
7085
|
}
|
|
6866
|
-
function
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
className: "-mb-0.5 flex flex-wrap items-center justify-between gap-2",
|
|
6871
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
6872
|
-
className: "text-sm font-semibold leading-6",
|
|
6873
|
-
children: legend
|
|
6874
|
-
}), canRemove ? /* @__PURE__ */ jsxs(Button, {
|
|
7086
|
+
function RemoveLocationButton({ onRemove }) {
|
|
7087
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7088
|
+
className: "-mb-0.5 flex justify-end",
|
|
7089
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
6875
7090
|
type: "button",
|
|
6876
|
-
variant: "
|
|
7091
|
+
variant: "link",
|
|
6877
7092
|
size: "sm",
|
|
6878
|
-
className: "h-7 px-2.5 text-[13px]
|
|
7093
|
+
className: "h-7 px-2.5 text-[13px]",
|
|
6879
7094
|
onClick: onRemove,
|
|
6880
7095
|
children: [/* @__PURE__ */ jsx(Trash2, { "aria-hidden": "true" }), "Remove location"]
|
|
6881
|
-
})
|
|
7096
|
+
})
|
|
6882
7097
|
});
|
|
6883
7098
|
}
|
|
6884
7099
|
/** The place in use, or the search while there isn't one (or while "Change" is open). */
|
|
6885
|
-
function PlaceRow({ controller, ui, idBase, siteCountry }) {
|
|
7100
|
+
function PlaceRow({ controller, ui, idBase, siteCountry, businessOffer }) {
|
|
6886
7101
|
const address = controller.state.location?.address ?? null;
|
|
6887
7102
|
if (address && !ui.changing) return /* @__PURE__ */ jsx(ChosenPlace, {
|
|
6888
7103
|
address,
|
|
6889
|
-
chosenName:
|
|
7104
|
+
chosenName: controller.state.chosenName,
|
|
6890
7105
|
siteCountry,
|
|
6891
7106
|
fieldsOpen: ui.fieldsOpen,
|
|
6892
7107
|
idBase,
|
|
@@ -6901,14 +7116,16 @@ function PlaceRow({ controller, ui, idBase, siteCountry }) {
|
|
|
6901
7116
|
announce: ui.setAnnouncement,
|
|
6902
7117
|
changingFrom: address ? addressName(address) : null,
|
|
6903
7118
|
onKeepCurrent: ui.keepCurrent,
|
|
7119
|
+
businessOffer,
|
|
7120
|
+
onBusinessAddress: ui.adoptBusinessAddress,
|
|
6904
7121
|
onChosen: ui.choose,
|
|
6905
|
-
|
|
7122
|
+
onTyped: ui.keepTyped,
|
|
6906
7123
|
onCoordinates: ui.placeAt
|
|
6907
7124
|
});
|
|
6908
7125
|
}
|
|
6909
|
-
/** A refused Save points at what still needs answering
|
|
7126
|
+
/** A refused Save points at what still needs answering. A lookup still running isn't a question for the owner, so nothing's marked. */
|
|
6910
7127
|
function saveErrorTargets(save, saveError) {
|
|
6911
|
-
if (save.kind === "ready" || !saveError) return {
|
|
7128
|
+
if (save.kind === "ready" || isSavePending(save) || !saveError) return {
|
|
6912
7129
|
status: null,
|
|
6913
7130
|
coordinates: null
|
|
6914
7131
|
};
|
|
@@ -6931,7 +7148,6 @@ function mapAreaProps(props, ui, idBase) {
|
|
|
6931
7148
|
MapComponent: props.MapComponent,
|
|
6932
7149
|
active: props.active ?? true,
|
|
6933
7150
|
pinOptional: context === "business",
|
|
6934
|
-
mapRef: ui.mapRef,
|
|
6935
7151
|
forcePinTab: errors.status !== null || errors.coordinates !== null,
|
|
6936
7152
|
coordinatesError: errors.coordinates,
|
|
6937
7153
|
previewAppearance: props.previewAppearance,
|
|
@@ -6991,12 +7207,15 @@ function usePickerUi(controller, idBase) {
|
|
|
6991
7207
|
const { state, dispatch } = controller;
|
|
6992
7208
|
const [fieldsOpen, setFieldsOpen] = useState(false);
|
|
6993
7209
|
const [changing, setChanging] = useState(false);
|
|
6994
|
-
const [chosenName, setChosenName] = useState(null);
|
|
6995
7210
|
const [editedAddress, setEditedAddress] = useState(null);
|
|
6996
7211
|
const [announcement, setAnnouncement] = useState("");
|
|
6997
|
-
const chosenRef = useRef(null),
|
|
7212
|
+
const chosenRef = useRef(null), streetRef = useRef(null);
|
|
6998
7213
|
const address = state.location?.address ?? null;
|
|
6999
7214
|
const searchInput = () => document.getElementById(`${idBase}-search`);
|
|
7215
|
+
const closeChange = () => {
|
|
7216
|
+
setChanging(false);
|
|
7217
|
+
setEditedAddress(null);
|
|
7218
|
+
};
|
|
7000
7219
|
const statusActions = {
|
|
7001
7220
|
undo: state.undo && state.location ? () => dispatch({
|
|
7002
7221
|
type: "undo",
|
|
@@ -7015,13 +7234,11 @@ function usePickerUi(controller, idBase) {
|
|
|
7015
7234
|
fieldsOpen,
|
|
7016
7235
|
setFieldsOpen,
|
|
7017
7236
|
changing,
|
|
7018
|
-
chosenName,
|
|
7019
7237
|
setEditedAddress,
|
|
7020
7238
|
announcement,
|
|
7021
7239
|
setAnnouncement,
|
|
7022
7240
|
addressEdited: editedAddress !== null && address !== null && sameMeaningfulAddress(editedAddress, address),
|
|
7023
7241
|
chosenRef,
|
|
7024
|
-
mapRef,
|
|
7025
7242
|
streetRef,
|
|
7026
7243
|
statusActions,
|
|
7027
7244
|
choose: (candidate) => {
|
|
@@ -7029,33 +7246,35 @@ function usePickerUi(controller, idBase) {
|
|
|
7029
7246
|
type: "select",
|
|
7030
7247
|
candidate
|
|
7031
7248
|
});
|
|
7249
|
+
closeChange();
|
|
7250
|
+
setAnnouncement(`Chose ${candidate.name ?? addressName(candidate.address)}. ${candidate.match.precision === "street" || candidate.match.precision === "area" ? "This is an area, so move the pin to where people arrive." : `The pin is on ${addressName(candidate.address)}.`}`);
|
|
7251
|
+
focusSoon(() => chosenRef.current);
|
|
7252
|
+
},
|
|
7253
|
+
adoptBusinessAddress: (offer) => {
|
|
7032
7254
|
dispatch({
|
|
7033
|
-
type: "
|
|
7034
|
-
|
|
7255
|
+
type: "adopt-location",
|
|
7256
|
+
location: offer.location
|
|
7035
7257
|
});
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
address: candidate.address
|
|
7039
|
-
} : null);
|
|
7040
|
-
setChanging(false);
|
|
7041
|
-
setEditedAddress(null);
|
|
7042
|
-
setAnnouncement(`Chose ${candidate.name ?? addressName(candidate.address)}. ${candidate.match.precision === "street" || candidate.match.precision === "area" ? "This is an area, so move the pin to where people arrive." : `The pin is on ${addressName(candidate.address)}.`}`);
|
|
7258
|
+
closeChange();
|
|
7259
|
+
setAnnouncement(`Using your business address, ${offer.line}.`);
|
|
7043
7260
|
focusSoon(() => chosenRef.current);
|
|
7044
7261
|
},
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7262
|
+
keepTyped: (text) => {
|
|
7263
|
+
dispatch({
|
|
7264
|
+
type: "use-typed-address",
|
|
7265
|
+
text,
|
|
7266
|
+
now: Date.now()
|
|
7267
|
+
});
|
|
7268
|
+
closeChange();
|
|
7269
|
+
setFieldsOpen(true);
|
|
7270
|
+
setAnnouncement("Using the address as you typed it. Check the address fields, then place the pin.");
|
|
7271
|
+
focusSoon(() => streetRef.current);
|
|
7049
7272
|
},
|
|
7050
7273
|
placeAt: (pin) => {
|
|
7051
7274
|
dispatch({
|
|
7052
|
-
type: "
|
|
7275
|
+
type: "use-coordinates",
|
|
7053
7276
|
pin
|
|
7054
7277
|
});
|
|
7055
|
-
dispatch({
|
|
7056
|
-
type: "query",
|
|
7057
|
-
query: ""
|
|
7058
|
-
});
|
|
7059
7278
|
setAnnouncement("Pin placed at those coordinates.");
|
|
7060
7279
|
},
|
|
7061
7280
|
startChange: () => {
|
|
@@ -7082,7 +7301,6 @@ function usePickerUi(controller, idBase) {
|
|
|
7082
7301
|
});
|
|
7083
7302
|
setFieldsOpen(false);
|
|
7084
7303
|
setChanging(false);
|
|
7085
|
-
setChosenName(null);
|
|
7086
7304
|
toast("Location removed.", {
|
|
7087
7305
|
duration: 5e3,
|
|
7088
7306
|
action: {
|
|
@@ -7099,6 +7317,11 @@ function usePickerUi(controller, idBase) {
|
|
|
7099
7317
|
}
|
|
7100
7318
|
//#endregion
|
|
7101
7319
|
//#region ../editor-blocks/src/widgets/location/useLocationPicker.ts
|
|
7320
|
+
/** Geoapify's own limit is 5 seconds; past this a lookup counts as failed, so a save can never wait on it for long. */
|
|
7321
|
+
const LOOKUP_TIMEOUT_MS = 8e3;
|
|
7322
|
+
/** Waits out the shared 2-a-second budget, and leaves the extra lookup to text the owner has stopped typing. */
|
|
7323
|
+
const FULL_SEARCH_PAUSE_MS = 1200;
|
|
7324
|
+
const LOOKUP_TIMED_OUT = { kind: "unavailable" };
|
|
7102
7325
|
async function geocode(client, siteId, body) {
|
|
7103
7326
|
return client ? unwrapResponse(await client({
|
|
7104
7327
|
endpoint: "geocodeLocation",
|
|
@@ -7112,23 +7335,32 @@ function useLocationPicker(input) {
|
|
|
7112
7335
|
const client = input.apiClient ?? environment?.apiClient;
|
|
7113
7336
|
const [state, dispatch] = useReducer(locationPickerReducer, input.initialLocation, createLocationPickerState);
|
|
7114
7337
|
useOpeningCheckPersistence(input, state);
|
|
7338
|
+
const save = pickerSaveDecision(state);
|
|
7339
|
+
const reportSave = useEffectEvent(() => input.onSaveSettled?.(save));
|
|
7115
7340
|
const run = useEffectEvent((request) => input.geocode ? input.geocode(input.siteId, request) : geocode(client, input.siteId, request));
|
|
7116
7341
|
const context = useEffectEvent(() => input.proximity ?? state.location?.pin ?? void 0);
|
|
7117
|
-
|
|
7118
|
-
|
|
7342
|
+
const opening = !state.authored && addressCheckOwed(state.location);
|
|
7343
|
+
const addressCheck = () => {
|
|
7119
7344
|
const query = formatLocationAddress(state.location?.address ?? null);
|
|
7120
|
-
|
|
7345
|
+
return query && !addressCheckDone(state.location) ? {
|
|
7346
|
+
operation: "address-check",
|
|
7347
|
+
query,
|
|
7348
|
+
mode: state.mode,
|
|
7349
|
+
proximity: context()
|
|
7350
|
+
} : null;
|
|
7351
|
+
};
|
|
7352
|
+
const startOpeningCheck = useEffectEvent(() => {
|
|
7353
|
+
const input = addressCheck();
|
|
7354
|
+
if (input) dispatch({
|
|
7121
7355
|
type: "request",
|
|
7122
7356
|
now: Date.now(),
|
|
7123
|
-
input
|
|
7124
|
-
operation: "address-check",
|
|
7125
|
-
query,
|
|
7126
|
-
mode: state.mode,
|
|
7127
|
-
proximity: context()
|
|
7128
|
-
}
|
|
7357
|
+
input
|
|
7129
7358
|
});
|
|
7359
|
+
});
|
|
7360
|
+
useEffect(() => {
|
|
7361
|
+
if (opening) startOpeningCheck();
|
|
7130
7362
|
}, [
|
|
7131
|
-
|
|
7363
|
+
opening,
|
|
7132
7364
|
state.revision,
|
|
7133
7365
|
state.mode
|
|
7134
7366
|
]);
|
|
@@ -7146,11 +7378,38 @@ function useLocationPicker(input) {
|
|
|
7146
7378
|
}), 350);
|
|
7147
7379
|
return () => clearTimeout(timer);
|
|
7148
7380
|
}, [state.query, state.mode]);
|
|
7381
|
+
const fullSearchDue = wantsFullSearch(state);
|
|
7382
|
+
useEffect(() => {
|
|
7383
|
+
if (!fullSearchDue) return;
|
|
7384
|
+
const timer = setTimeout(() => dispatch({
|
|
7385
|
+
type: "request",
|
|
7386
|
+
now: Date.now(),
|
|
7387
|
+
input: {
|
|
7388
|
+
operation: "autocomplete",
|
|
7389
|
+
fullSearch: true,
|
|
7390
|
+
query: state.query.trim(),
|
|
7391
|
+
mode: state.mode,
|
|
7392
|
+
proximity: context()
|
|
7393
|
+
}
|
|
7394
|
+
}), FULL_SEARCH_PAUSE_MS);
|
|
7395
|
+
return () => clearTimeout(timer);
|
|
7396
|
+
}, [
|
|
7397
|
+
fullSearchDue,
|
|
7398
|
+
state.query,
|
|
7399
|
+
state.mode
|
|
7400
|
+
]);
|
|
7149
7401
|
useEffect(() => {
|
|
7150
7402
|
const request = state.request;
|
|
7151
7403
|
if (!request) return;
|
|
7152
7404
|
const cancellation = new AbortController();
|
|
7405
|
+
const deadline = setTimeout(() => dispatch({
|
|
7406
|
+
type: "reply",
|
|
7407
|
+
request,
|
|
7408
|
+
response: LOOKUP_TIMED_OUT,
|
|
7409
|
+
now: Date.now()
|
|
7410
|
+
}), LOOKUP_TIMEOUT_MS);
|
|
7153
7411
|
run(request.input).catch(() => ({ kind: "unavailable" })).then((response) => {
|
|
7412
|
+
clearTimeout(deadline);
|
|
7154
7413
|
if (!cancellation.signal.aborted) dispatch({
|
|
7155
7414
|
type: "reply",
|
|
7156
7415
|
request,
|
|
@@ -7158,27 +7417,47 @@ function useLocationPicker(input) {
|
|
|
7158
7417
|
now: Date.now()
|
|
7159
7418
|
});
|
|
7160
7419
|
});
|
|
7161
|
-
return () =>
|
|
7420
|
+
return () => {
|
|
7421
|
+
clearTimeout(deadline);
|
|
7422
|
+
cancellation.abort();
|
|
7423
|
+
};
|
|
7162
7424
|
}, [state.request]);
|
|
7163
|
-
const
|
|
7164
|
-
|
|
7165
|
-
if (
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7425
|
+
const saveSettled = state.saveIntent === "settled";
|
|
7426
|
+
useEffect(() => {
|
|
7427
|
+
if (!saveSettled) return;
|
|
7428
|
+
dispatch({ type: "save-reported" });
|
|
7429
|
+
reportSave();
|
|
7430
|
+
}, [saveSettled]);
|
|
7431
|
+
/**
|
|
7432
|
+
* The one way to save: one click runs whatever check is outstanding, then answers through onSaveSettled.
|
|
7433
|
+
* A form that saves something other than the draft passes what it would save, so it only waits if that's pending.
|
|
7434
|
+
* onSaveSettled still reports the draft's decision, so that form reads its own when it's called.
|
|
7435
|
+
*/
|
|
7436
|
+
const requestSave = (savingNow = save) => {
|
|
7437
|
+
const wait = isSavePending(savingNow);
|
|
7438
|
+
dispatch({
|
|
7439
|
+
type: "request-save",
|
|
7440
|
+
wait,
|
|
7441
|
+
check: wait ? addressCheck() : null,
|
|
7442
|
+
now: Date.now()
|
|
7443
|
+
});
|
|
7444
|
+
};
|
|
7445
|
+
const checkAddress = () => {
|
|
7446
|
+
const check = addressCheck();
|
|
7447
|
+
if (check) dispatch({
|
|
7448
|
+
type: "request",
|
|
7449
|
+
now: Date.now(),
|
|
7450
|
+
input: check
|
|
7451
|
+
});
|
|
7452
|
+
};
|
|
7453
|
+
const findAddressAtPin = () => {
|
|
7454
|
+
const point = state.location?.pin;
|
|
7455
|
+
if (point) dispatch({
|
|
7175
7456
|
type: "request",
|
|
7176
7457
|
now: Date.now(),
|
|
7177
7458
|
input: {
|
|
7178
|
-
operation,
|
|
7179
|
-
|
|
7180
|
-
mode: state.mode,
|
|
7181
|
-
proximity: context()
|
|
7459
|
+
operation: "reverse",
|
|
7460
|
+
point
|
|
7182
7461
|
}
|
|
7183
7462
|
});
|
|
7184
7463
|
};
|
|
@@ -7186,9 +7465,12 @@ function useLocationPicker(input) {
|
|
|
7186
7465
|
siteId: input.siteId,
|
|
7187
7466
|
state,
|
|
7188
7467
|
dispatch,
|
|
7189
|
-
save
|
|
7190
|
-
|
|
7191
|
-
|
|
7468
|
+
save,
|
|
7469
|
+
saveRequested: state.saveIntent === "waiting",
|
|
7470
|
+
saveInterrupted: state.saveIntent === "interrupted",
|
|
7471
|
+
requestSave,
|
|
7472
|
+
checkAddress,
|
|
7473
|
+
useAddressAtPin: findAddressAtPin,
|
|
7192
7474
|
retryLookup: () => dispatch({
|
|
7193
7475
|
type: "retry",
|
|
7194
7476
|
now: Date.now()
|
|
@@ -7215,6 +7497,8 @@ function useOpeningCheckPersistence(input, state) {
|
|
|
7215
7497
|
}
|
|
7216
7498
|
//#endregion
|
|
7217
7499
|
//#region ../editor-blocks/src/widgets/location/LocationPickerField.tsx
|
|
7500
|
+
/** Block forms have no Save button to run the check from, so it runs once the owner pauses. */
|
|
7501
|
+
const AUTO_CHECK_MS = 1500;
|
|
7218
7502
|
function LocationPickerField({ path, backend }) {
|
|
7219
7503
|
const { siteId } = useLocationPickerWidgetContext();
|
|
7220
7504
|
const { value, setValue } = useField(path, backend);
|
|
@@ -7258,6 +7542,13 @@ function CanonicalLocationField({ siteId, path, backend, value, setValue, needsP
|
|
|
7258
7542
|
backend.form,
|
|
7259
7543
|
path
|
|
7260
7544
|
]);
|
|
7545
|
+
const checkAddress = useEffectEvent(() => picker.checkAddress());
|
|
7546
|
+
const checkWaiting = addressCheckOwed(picker.state.location) && !placeLookupRunning(picker.state);
|
|
7547
|
+
useEffect(() => {
|
|
7548
|
+
if (!checkWaiting) return;
|
|
7549
|
+
const timer = setTimeout(checkAddress, AUTO_CHECK_MS);
|
|
7550
|
+
return () => clearTimeout(timer);
|
|
7551
|
+
}, [checkWaiting, picker.state.revision]);
|
|
7261
7552
|
const decided = (decision) => {
|
|
7262
7553
|
if (needsPlace && decision.kind === "ready" && decision.location === null) {
|
|
7263
7554
|
backend.setError(path, { message: "Choose this place again." });
|