@riverbankcms/sdk 0.164.0 → 0.166.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-CubPwupc.d.ts → BlocksIslandsHydrator-CPvN6RBW.d.ts} +1 -1
- package/dist/_dts/{Page-CDzsagB2.d.ts → Page-rW0xgQCA.d.ts} +18 -256
- package/dist/_dts/{SdkPreviewMode-CPRQbRCI.d.ts → SdkPreviewMode-BWZh2WCk.d.ts} +107 -72
- package/dist/_dts/{client-CbeYTSry.d.ts → client-D4BXQEZc.d.ts} +5 -1
- package/dist/_dts/{content-types--uYRIcIF.d.ts → content-types-MUzta0l9.d.ts} +3 -3
- package/dist/_dts/{contracts-DJQYAOsv.d.ts → contracts-Cl9Xh1DO.d.ts} +4 -4
- package/dist/_dts/{footerPageOutline-CKkhBwgJ.d.ts → footerPageOutline-4BgLKehl.d.ts} +6 -6
- package/dist/_dts/{generatePageMetadata--qd7NCIA.d.ts → generatePageMetadata-BsmJ0qKh.d.ts} +2 -2
- package/dist/_dts/{index-wegfy7lf.d.ts → index--qflsCiy.d.ts} +4 -3
- package/dist/_dts/{index-CjdIn9-_.d.ts → index-BgJ2aU5c.d.ts} +2 -2
- package/dist/_dts/{index-BZE-1azr.d.ts → index-Bmboeb49.d.ts} +2 -2
- package/dist/_dts/{index-BpEbwDM7.d.ts → index-DdcwPqQN.d.ts} +4 -4
- package/dist/_dts/{index-DriYVLfT.d.ts → index-ahxQCUc7.d.ts} +2 -2
- package/dist/_dts/{index-DYQFmf--.d.ts → index-kQ5xkM6X.d.ts} +1 -1
- package/dist/_dts/{index-JS8WYgD3.d.ts → index-mMMvLLAJ.d.ts} +2996 -3079
- package/dist/_dts/{index-D_pQO-AS.d.ts → index-wbBZ0awa.d.ts} +49398 -48202
- package/dist/_dts/{loadContent-DUi94Qfk.d.ts → loadContent-BG5IAV-V.d.ts} +9 -6
- package/dist/_dts/resolveBlockData-Cmcle_zV.d.ts +136 -0
- package/dist/_dts/{resolvePageContent-JDE0ry6T.d.ts → resolvePageContent-BRJUTFoH.d.ts} +3 -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 +9 -6
- 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 +20 -0
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +2 -0
- package/dist/_dts/sdk/src/data/types.d.ts +54 -0
- 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 +2 -2
- package/dist/_dts/sdk/src/next/index.d.ts +9 -8
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +36 -48
- package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
- 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 +2 -0
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +3 -0
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +257 -0
- package/dist/_dts/sdk/src/rendering/index.d.ts +8 -7
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
- package/dist/_dts/{themeAdmission-D_qtGYAT.d.ts → sdk/src/rendering/themeAdmission.d.ts} +3 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
- package/dist/_dts/sdk/src/server.d.ts +7 -5
- package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
- package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
- package/dist/_dts/{types-DiciZDrk.d.ts → types-BX3Y-EW3.d.ts} +3 -3
- package/dist/_dts/{types-DubJnBnI.d.ts → types-DF54stxv.d.ts} +8 -7
- package/dist/_dts/{types-W40f2olO.d.ts → types-DuiHLiPo.d.ts} +2 -2
- package/dist/_dts/{validation-BF4_zNkR.d.ts → validation-Bxi0f81D.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-64hFxF02.mjs → BlocksIslandsHydrator-DwiRGtgh.mjs} +31 -24
- package/dist/client/{BookingMailingListNote-CSQyFm9J.mjs → BookingMailingListNote-DOWOZYlK.mjs} +2 -2
- package/dist/client/{CalendarNavigationChevron-Bvkx8Z7Y.mjs → CalendarNavigationChevron-5a0x0vcC.mjs} +7 -7
- package/dist/client/{CheckboxChoice-3PhxDxgR.mjs → CheckboxChoice-CZ-anOqV.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-pt2xXBQp.mjs → DemoBookingPortalAccess-B2qLkPRB.mjs} +6 -6
- package/dist/client/{DemoPortalSignInLink-Qw780EfW.mjs → DemoPortalSignInLink-B9YrzZt2.mjs} +1 -1
- package/dist/client/{EventCalendar.client-DWoboRW5.mjs → EventCalendar.client-BhADnDCg.mjs} +17 -10
- package/dist/client/{EventCombined.client-C98ucpcP.mjs → EventCombined.client-jik34zTb.mjs} +8 -8
- package/dist/client/{EventEmbeddedCheckoutStep-DHRlFfkp.mjs → EventEmbeddedCheckoutStep-D_14yqAU.mjs} +27 -2
- package/dist/client/{EventItem-hrSyTApW.mjs → EventItem-CMKrtkT7.mjs} +33 -12
- package/dist/client/{EventListWeekNavigation-C3t7H13W.mjs → EventListWeekNavigation-AGHjxy6C.mjs} +1 -1
- package/dist/client/{EventListing.client-Cp11sBX_.mjs → EventListing.client-DZeDM0Qt.mjs} +3 -3
- package/dist/client/{EventListing.view-Dd5QHIAf.mjs → EventListing.view-3BBRdNVa.mjs} +70 -15
- package/dist/client/{EventRegistrationPayment-ByT88VHR.mjs → EventRegistrationPayment-CpNcpga4.mjs} +108 -11
- package/dist/client/{LocationMapActions-BsepG5Vv.mjs → LocationMapActions-D5-H9ooQ.mjs} +2 -2
- package/dist/client/{MapDrawingSvg-R4JMT4yd.mjs → MapDrawingSvg-C30geMl-.mjs} +1 -1
- package/dist/client/{Page-Dub71o3c.mjs → Page-DNDZLRlB.mjs} +3388 -11530
- package/dist/client/{ProtectedSubmitButton-DGbgGvdh.mjs → ProtectedSubmitButton-8DuDw2ag.mjs} +1 -1
- package/dist/client/{SpamProtectionWidget-CRsKTQV-.mjs → SpamProtectionWidget-CCF6YLUX.mjs} +5 -3
- package/dist/client/{StepIndicator-Bp7MyutT.mjs → StepIndicator-Bin7YR0A.mjs} +3 -3
- package/dist/client/{TabBarFragment-C4WJyybx.mjs → TabBarFragment-_IAthZVM.mjs} +1 -1
- package/dist/client/{ThemedButton-BGVwNwE-.mjs → ThemedButton-8jUc02mZ.mjs} +64 -2
- package/dist/client/{accordion-vCG_JC5t.mjs → accordion-uVqNowRX.mjs} +1 -1
- package/dist/client/{altchaProtection-BWchRM3v.mjs → altchaProtection-DjIV9A5n.mjs} +1 -1
- package/dist/client/{booking-form.client-CHTbcZJM.mjs → booking-form.client-w-PvyWBv.mjs} +19 -14
- package/dist/client/{bookingForm-BxbUbzUr.mjs → bookingForm-DNMojb6A.mjs} +4 -4
- package/dist/client/bookings.mjs +6 -6
- package/dist/client/{carousel-FM1mkkL0.mjs → carousel-C8kxI3Dm.mjs} +2 -2
- package/dist/client/{carousel.client-ChoLiWwD.mjs → carousel.client-BO7sCEpH.mjs} +1 -1
- package/dist/client/{cart-BDFhbh9j.mjs → cart-DCxjE3Is.mjs} +3 -3
- package/dist/client/{cart.client-x3HOke6T.mjs → cart.client-Ceeng8fB.mjs} +1 -1
- package/dist/client/{checkout-BibhwnTd.mjs → checkout-B0EKbeVv.mjs} +3 -3
- package/dist/client/{checkout.client-CE4jUi0G.mjs → checkout.client-DtPj3fYk.mjs} +1 -1
- package/dist/client/client.mjs +9465 -15
- package/dist/client/{context-BNAM7NsW.mjs → context-n6IZigd3.mjs} +8 -6
- package/dist/client/cta-CDeAwYoN.mjs +121 -0
- package/dist/client/{dateFormatting-QwBSo0hK.mjs → dateFormatting-BWPzdeZE.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-NwKJk6gn.mjs → demoPortalMagicLink-BdXu0fj-.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-D4zqEBDl.mjs → enhanceHeaderSection-VHfv8M6-.mjs} +3 -3
- package/dist/client/{event-details.client-jFyFjOIC.mjs → event-details.client-Cfr1_Cj4.mjs} +2 -2
- package/dist/client/{event-registration.client-BK_jVv3R.mjs → event-registration.client-BhygihpQ.mjs} +43 -17
- package/dist/client/{eventCalendar-DSkzejQh.mjs → eventCalendar-B4XCL9u6.mjs} +4 -4
- package/dist/client/{eventCombined-BG-BEaYh.mjs → eventCombined-DVjz4wdf.mjs} +4 -4
- package/dist/client/{eventDetails-BhIwXAKe.mjs → eventDetails-B0DA1Nw1.mjs} +2 -2
- package/dist/client/{eventListing-DQtyO1Xj.mjs → eventListing-2-xjn2nz.mjs} +4 -4
- package/dist/client/{eventRegistration-DRTz8X0M.mjs → eventRegistration-ng4iGo9O.mjs} +4 -4
- package/dist/client/{form-GXqjObPC.mjs → form-BeNQiZ2V.mjs} +3 -3
- package/dist/client/{form.client-CoKNba2e.mjs → form.client-BFdCKlp7.mjs} +7 -7
- package/dist/client/{form.parts-magB_epJ.mjs → form.parts-C7gLK3jh.mjs} +3 -3
- package/dist/client/{formatDate-BiloOyjS.mjs → formatDate-CWfelfMt.mjs} +1 -1
- package/dist/client/gifting/client.mjs +4 -5
- package/dist/client/{headerSection-BMQCPHT3.mjs → headerSection-CalNAShx.mjs} +2 -2
- package/dist/client/{mediaAssets-BX-vWwQc.mjs → mediaAssets-DpPauppt.mjs} +1 -1
- package/dist/client/{mediaContext-CdqGYlWl.mjs → mediaContext-BLo4NtjP.mjs} +25 -19
- package/dist/client/{newsletter-form.client-8orCez1z.mjs → newsletter-form.client-Dq7GHGXU.mjs} +9 -9
- package/dist/client/{newsletter-form.parts-D8NgHY_F.mjs → newsletter-form.parts-BSMDYQiS.mjs} +2 -2
- package/dist/client/{newsletterForm-BhBNsS3n.mjs → newsletterForm-snzZ4L6i.mjs} +3 -3
- package/dist/client/{noop-C2vZse15.mjs → noop-D-RG9eR3.mjs} +399 -169
- package/dist/client/portal/client.mjs +13 -14
- package/dist/client/{product-detail.client-CQ0k0fbH.mjs → product-detail.client-Gu0INDb7.mjs} +1 -1
- package/dist/client/{product-list.client-Xlr1P0x9.mjs → product-list.client-BmH40fNf.mjs} +1 -1
- package/dist/client/{productDetail-BsCao6X4.mjs → productDetail-DsPUmJ0z.mjs} +3 -3
- package/dist/client/{productList-Cc-PmbEe.mjs → productList-DjGrjOwD.mjs} +3 -3
- package/dist/client/{propsDecoder-DikkDJ9x.mjs → propsDecoder-kTVPMnfD.mjs} +4 -4
- package/dist/client/{registry.server-BpLZo3bC.mjs → registry.server-CKK_RXZo.mjs} +350 -424
- package/dist/client/rendering/client.mjs +29 -28
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +70 -8
- package/dist/client/{richText-coerce-WuMYrBm3.mjs → richText-coerce-BcjTX-7h.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-DNx6b07x.mjs → routeIslandApiConfig-CaXesATK.mjs} +1 -1
- package/dist/client/{shop-DyXtB5TD.mjs → shop-DLufMauE.mjs} +3 -3
- package/dist/client/{shop-commerce-xjWH7-Ym.mjs → shop-commerce-BxYYXLNK.mjs} +12 -12
- package/dist/client/{shop-commerce-store-CbBsS1kD.mjs → shop-commerce-store-Dp3Nl5YK.mjs} +1 -1
- package/dist/client/{shop.client-QOKqQPgK.mjs → shop.client-CBy9_alG.mjs} +13 -13
- package/dist/client/{shop.interactive-BQdm441g.mjs → shop.interactive-BM0NRsFQ.mjs} +265 -24
- package/dist/client/{shopShared-CyW6MU48.mjs → shopShared-lS23OQE-.mjs} +2 -2
- package/dist/client/site-styles-D8jEPGxA.mjs +3 -0
- package/dist/{preview-next/client/ThemedButton-g7NPrsGp.mjs → client/site-styles-DELkUk9s.mjs} +25654 -17259
- package/dist/client/spam-protection.mjs +2 -2
- package/dist/client/src-DjnxOjXG.mjs +217 -0
- package/dist/client/surfaceTransportMarker-BXepAVF6.mjs +152 -0
- package/dist/client/{timetableModel-BgdkhRuA.mjs → timetableModel-DzRWikCU.mjs} +157 -139
- package/dist/client/types-sF-IrGQr.mjs +633 -0
- package/dist/client/{useAvailableSlots-wmdo6uZ8.mjs → useAvailableSlots-C3LphWDX.mjs} +8 -5
- package/dist/client/{useBookingNowIso-CUExAee1.mjs → useBookingNowIso-Da-f9iHw.mjs} +1 -1
- package/dist/client/{useDiscountApply-BRM-OoTN.mjs → useDiscountApply-SLoWhcen.mjs} +3 -3
- package/dist/client/{useDiscountCodeUi-BEIvL31G.mjs → useDiscountCodeUi-D6a2BJij.mjs} +1 -1
- package/dist/client/{useEventPagination-Dk3g64we.mjs → useEventPagination-Ccr4TZlm.mjs} +12 -159
- package/dist/client/{view-BnaOmrap.mjs → view-8w4GA8rf.mjs} +4 -4
- package/dist/client/{view-vhKGFfC3.mjs → view-DAVEoe8A.mjs} +310 -247
- package/dist/client/{wizardSteps-xqU4q63H.mjs → wizardSteps-DNpajrAH.mjs} +495 -173
- package/dist/preview-next/before-render.mjs +4 -141
- package/dist/preview-next/client/ArrangementLookControls-DY5TzhEa.mjs +31197 -0
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-43wIAWr4.mjs → EventEmbeddedCheckoutStep-C_h1cMYm.mjs} +33 -4
- package/dist/preview-next/client/{LocationPickerEnvironment-QtSG2Bl-.mjs → LocationPickerEnvironment-D56RD3e_.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-B-rohNcG.mjs → MapLibreEditMap-DFnyCckr.mjs} +2 -2
- package/dist/preview-next/client/PreviewEditorSidebar-DdnhmdFO.mjs +37049 -0
- package/dist/preview-next/client/PreviewEditorUI-C7ZmYE33.mjs +1189 -0
- package/dist/preview-next/client/PreviewShell-DnO38NaL.mjs +4707 -0
- package/dist/preview-next/client/SdkPreviewModeRuntime-D2OtoRMB.mjs +4258 -0
- package/dist/preview-next/client/SiteChromeCustomizeButton-eIu2RejJ.mjs +71144 -0
- package/dist/preview-next/client/ThemedButton-C0dgGJ5k.mjs +2006 -0
- package/dist/preview-next/client/{lucide-react-CA9cpo0P.mjs → lucide-react-CPBCf6QT.mjs} +15 -2
- package/dist/preview-next/client/previewAssistantSlot-Bp1AlAxx.mjs +110560 -0
- package/dist/preview-next/client/previewChromeSurface-D2cREDJ5.mjs +190 -0
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/sdk-runtime-DK0PUhLL.mjs +5 -0
- package/dist/preview-next/client/useAutosaveStatus--Pw8vnef.mjs +138 -0
- package/dist/preview-next/client/useBlockCustomizeControls-C1Rl73N4.mjs +2724 -0
- package/dist/preview-next/client/useOpenBlockForSetup-CL3842FM.mjs +28 -0
- package/dist/preview-next/keepAlive.mjs +27 -4
- package/dist/preview-next/middleware.mjs +2 -2
- package/dist/preview-next/{route-contract-D5tHZEz5.mjs → route-contract-Bq7SUX3K.mjs} +143 -126
- package/dist/preview-next/{session-P1R_ajT7.mjs → session-DU6zpYUQ.mjs} +1 -1
- package/dist/preview-next/session.mjs +1 -1
- package/dist/server/{Block.shared-Iy7g11iP.mjs → Block.shared-wXr7Iwhs.mjs} +7 -4
- package/dist/server/{src-cbbK3Bho.mjs → ThemeScopeCore-BI2mld9R.mjs} +1153 -2523
- package/dist/server/accessibleSurfaces-CuN8U_iU.mjs +2102 -0
- package/dist/server/{bindings-BVJGgUT0.mjs → bindings-DjdUq9FR.mjs} +2 -3
- package/dist/server/{publicProducts-D3Fc5TKk.mjs → client-07UeMDzA.mjs} +2492 -357
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +33 -2
- package/dist/server/data/dataLoaderContext.mjs +2 -0
- package/dist/server/data/resolveBlockData.mjs +2 -0
- package/dist/server/data/types.mjs +1 -0
- package/dist/server/dataLoaderContext-B3fXA54R.mjs +47 -0
- package/dist/server/identity-Bn9OQiT1.mjs +6 -0
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-BuintpdO.mjs → loadContent-ClpaSlBb.mjs} +6 -5
- package/dist/server/{loadPage-Dk4wea8M.mjs → loadPage-BwtVqpaA.mjs} +4 -2
- package/dist/server/manifest.mjs +1 -1
- package/dist/server/media-DnlczCMA.mjs +231 -0
- package/dist/server/mode-Cv_TG9gP.mjs +63 -0
- package/dist/server/next/middleware.mjs +1 -1
- package/dist/server/next/revalidate.mjs +1 -1
- package/dist/server/next.mjs +13 -13
- package/dist/server/opaqueSurface-3YSDPtDe.mjs +54 -0
- package/dist/server/{overrideResolution-BDiQWM7D.mjs → overrideResolution-Du_w3LY4.mjs} +2 -1
- package/dist/server/overrides-CD4d-1w7.mjs +177 -0
- package/dist/server/page-converter.mjs +243 -91
- package/dist/server/pageRenderPlan-BShULdc2.mjs +4055 -0
- package/dist/server/{themeAdmission-BdY8lP-K.mjs → pageRuntimeSupport-C4Dh5-mB.mjs} +13 -28
- package/dist/server/{overrides-DVemf-GV.mjs → pageShared-HdKFBpaX.mjs} +3594 -1726
- package/dist/server/parseThemeForPersistence-CJMrEkze.mjs +52 -0
- package/dist/server/{prebuild-DubLNgRH.mjs → prebuild-Cl-bkaMA.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/prefetchBlockData-C4yUmz-r.mjs +786 -0
- package/dist/server/publicProducts-W9hDRwjz.mjs +64 -0
- package/dist/server/{registry-zjd1P2Dl.mjs → registry-TFPJdGQi.mjs} +20901 -792
- package/dist/server/rendering/components/pageShared.mjs +2 -0
- package/dist/server/rendering/helpers/loadPage.mjs +2 -0
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +2 -0
- package/dist/server/rendering/server.mjs +5 -4
- package/dist/server/rendering/themeAdmission.mjs +2 -0
- package/dist/server/rendering.mjs +11 -10
- package/dist/server/repeaterFields-MIz7r1ez.mjs +9 -0
- package/dist/server/{resolveBlockData-CZJ--nH6.mjs → resolveBlockData-OHlOXlOE.mjs} +6 -48
- package/dist/server/resolveButtonColourStates-lry2ORwX.mjs +2672 -0
- package/dist/server/{richTextSchema-YYc85FX4.mjs → richTextSchema-Euhuj-7V.mjs} +26 -1
- package/dist/server/routing.mjs +1 -1
- package/dist/server/schema-C2PqHrMo.mjs +2523 -0
- package/dist/server/server.mjs +3 -3
- package/dist/server/theme-bridge.mjs +1031 -1
- package/dist/server/theme.mjs +2 -1
- package/dist/server/themeAdmission-DGSAlFUK.mjs +18 -0
- package/dist/server/{three-pass-converter-Chnb1XD-.mjs → three-pass-converter-_j2UE2tR.mjs} +1 -1
- package/dist/server/validation-CDd6m8Ry.mjs +140 -0
- package/dist/server/{validation-CGH-Xs4E.mjs → validation-DIBFZeMB.mjs} +419 -3
- package/dist/server/{version-DoOG6F13.mjs → version-DZWZM1H6.mjs} +1 -1
- package/dist/styles/index.css +924 -10
- package/package.json +39 -1
- package/dist/_dts/previewCompiler-BVVgDSdq.d.ts +0 -1
- package/dist/client/cta-ChiN1Vgg.mjs +0 -80
- package/dist/client/purchase-BMsWpx8y.mjs +0 -894
- package/dist/client/schema-DMUkBtIO.mjs +0 -15915
- package/dist/client/site-styles-BLHYJ8S7.mjs +0 -12339
- package/dist/client/src-VIsPY-kw.mjs +0 -62
- package/dist/preview-next/client/PreviewEditorSidebar-C3AQVxQt.mjs +0 -5441
- package/dist/preview-next/client/PreviewEditorUI-C-1zDCR_.mjs +0 -756
- package/dist/preview-next/client/SdkPreviewModeRuntime-B47yHFL0.mjs +0 -9130
- package/dist/preview-next/client/SdkPreviewModeRuntime-C6Rhm2NQ.mjs +0 -3
- package/dist/preview-next/client/previewAuthStore-By_zfrS5.mjs +0 -212195
- package/dist/preview-next/client/previewChromeSurface-Cjwxv90x.mjs +0 -85
- package/dist/preview-next/client/result-BjJUoxUF.mjs +0 -16
- package/dist/preview-next/client/sdk-runtime-BG2HYvQj.mjs +0 -4
- package/dist/preview-next/client/siteStyleAccess-BiSyYyyr.mjs +0 -14178
- package/dist/preview-next/client/spinner-DnWpeDp2.mjs +0 -67
- package/dist/preview-next/refresh-contract-uQ6BXgLJ.mjs +0 -25
- package/dist/server/bindings-Dgt_0goJ.mjs +0 -17
- package/dist/server/client-CiKaE8ms.mjs +0 -2330
- package/dist/server/effectiveNavLinkStyle-EDSdd_oK.mjs +0 -11574
- package/dist/server/loadPage-BwjncpJf.mjs +0 -2
- package/dist/server/prefetchBlockData-Bnbwoe5n.mjs +0 -4156
- package/dist/server/schema-BlTWmTSl.mjs +0 -16142
- package/dist/server/site-styles-yHytcXIB.mjs +0 -768
- package/dist/server/siteChromeOverlayClearance-D0uCNZ7E.mjs +0 -802
|
@@ -0,0 +1,2724 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { $p as Root2$1, A as usePreviewRenderReadiness, An as manifestFieldSectionOptions, Fp as ReactRemoveScroll, Gp as Item, Hn as parseBackgroundColorToken, I_ as syncStateOf, Jn as createCustomBlockRegistry, Jp as Presence, Kp as Root, Mf as augmentManifestWithStyleGroups, Np as menuItemInteractionClassName, On as createManifestFormAdapter, P as lookTilesFor, Pa as eventCalendarListGroupingDecision, Pp as menuTriggerInteractionClassName, Qp as Content, Sm as cn, Wn as parseCanonicalSectionBackground, Wp as hideOthers, Xm as isThemeV2NormalEditorRawStyleFieldName, Xn as fieldsNotShownIn, Xp as Anchor, Yn as mergeBlockDescriptorsWithRegistry, Yp as Portal$2, Zm as isThemeV2NormalEditorRawStylePath, Zp as Arrow, _r as getBlockDefinition, am as DismissableLayer, an as shouldRevealAllBlockFieldValidation, bm as composeRefs, cm as createCollection, cr as resolveFieldOwnership, dm as createContextScope, dr as systemCustomizeFacetAppliesToLayoutVariant, em as createPopperScope, fd as resolveVisiblePromotedFieldPathsForEditorBlock, ff as lookModes, fm as composeEventHandlers, fr as systemCustomizeFacetDefinitionForBlock, gr as resolveArrangementKnobs, gt as derivePromotedFieldPlan, hd as sectionPhotoPresence, hr as arrangementKnobChoices, im as useFocusGuards, ip as Root$1, kd as getCuratedSiteStyle, lm as useControllableState, md as decideSectionPhoto, mm as dispatchDiscreteCustomEvent, mr as systemCustomizeFacetStoredValue, nm as useId$1, o as usePreviewPageDesignEditorState, od as resolveEditorArrangementLook, om as useCallbackRef, pm as Primitive, pr as systemCustomizeFacetDefinitionsForBlock, qp as createRovingFocusGroupScope, rm as FocusScope, si as eventCalendarPagingFields, sm as useDirection, sr as fieldPathsOwnedBy, ur as isSystemCustomizeFacetId, vm as createSlot, xd as readStoredMode, xm as useComposedRefs, yd as lookDefinitionForId, ym as createSlottable, zg as asSiteStyleId } from "./previewAssistantSlot-Bp1AlAxx.mjs";
|
|
3
|
+
import { ft as ChevronRight, ht as Check, ot as Circle } from "./lucide-react-CPBCf6QT.mjs";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { createContext, useContext, useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import deepEqual from "fast-deep-equal";
|
|
8
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-menu@2.1.18_@types+react-dom@19.2.3_@types+react@19.2.17__@types+react@_476586c402937c39bc9e1e3c22b45af1/node_modules/@radix-ui/react-menu/dist/index.mjs
|
|
9
|
+
var SELECTION_KEYS = ["Enter", " "];
|
|
10
|
+
var FIRST_KEYS = [
|
|
11
|
+
"ArrowDown",
|
|
12
|
+
"PageUp",
|
|
13
|
+
"Home"
|
|
14
|
+
];
|
|
15
|
+
var LAST_KEYS = [
|
|
16
|
+
"ArrowUp",
|
|
17
|
+
"PageDown",
|
|
18
|
+
"End"
|
|
19
|
+
];
|
|
20
|
+
var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
21
|
+
var SUB_OPEN_KEYS = {
|
|
22
|
+
ltr: [...SELECTION_KEYS, "ArrowRight"],
|
|
23
|
+
rtl: [...SELECTION_KEYS, "ArrowLeft"]
|
|
24
|
+
};
|
|
25
|
+
var SUB_CLOSE_KEYS = {
|
|
26
|
+
ltr: ["ArrowLeft"],
|
|
27
|
+
rtl: ["ArrowRight"]
|
|
28
|
+
};
|
|
29
|
+
var MENU_NAME = "Menu";
|
|
30
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
|
|
31
|
+
var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
|
|
32
|
+
createCollectionScope,
|
|
33
|
+
createPopperScope,
|
|
34
|
+
createRovingFocusGroupScope
|
|
35
|
+
]);
|
|
36
|
+
var usePopperScope$1 = createPopperScope();
|
|
37
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
38
|
+
var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
|
|
39
|
+
var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
|
|
40
|
+
var Menu = (props) => {
|
|
41
|
+
const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
|
|
42
|
+
const popperScope = usePopperScope$1(__scopeMenu);
|
|
43
|
+
const [content, setContent] = React$1.useState(null);
|
|
44
|
+
const isUsingKeyboardRef = React$1.useRef(false);
|
|
45
|
+
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
46
|
+
const direction = useDirection(dir);
|
|
47
|
+
React$1.useEffect(() => {
|
|
48
|
+
const handleKeyDown = () => {
|
|
49
|
+
isUsingKeyboardRef.current = true;
|
|
50
|
+
document.addEventListener("pointerdown", handlePointer, {
|
|
51
|
+
capture: true,
|
|
52
|
+
once: true
|
|
53
|
+
});
|
|
54
|
+
document.addEventListener("pointermove", handlePointer, {
|
|
55
|
+
capture: true,
|
|
56
|
+
once: true
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const handlePointer = () => isUsingKeyboardRef.current = false;
|
|
60
|
+
document.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
61
|
+
return () => {
|
|
62
|
+
document.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
63
|
+
document.removeEventListener("pointerdown", handlePointer, { capture: true });
|
|
64
|
+
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
React$1.useEffect(() => {
|
|
68
|
+
if (!open) return;
|
|
69
|
+
const handleBlur = () => handleOpenChange(false);
|
|
70
|
+
window.addEventListener("blur", handleBlur);
|
|
71
|
+
return () => window.removeEventListener("blur", handleBlur);
|
|
72
|
+
}, [open, handleOpenChange]);
|
|
73
|
+
return /* @__PURE__ */ jsx(Root2$1, {
|
|
74
|
+
...popperScope,
|
|
75
|
+
children: /* @__PURE__ */ jsx(MenuProvider, {
|
|
76
|
+
scope: __scopeMenu,
|
|
77
|
+
open,
|
|
78
|
+
onOpenChange: handleOpenChange,
|
|
79
|
+
content,
|
|
80
|
+
onContentChange: setContent,
|
|
81
|
+
children: /* @__PURE__ */ jsx(MenuRootProvider, {
|
|
82
|
+
scope: __scopeMenu,
|
|
83
|
+
onClose: React$1.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
84
|
+
isUsingKeyboardRef,
|
|
85
|
+
dir: direction,
|
|
86
|
+
modal,
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
Menu.displayName = MENU_NAME;
|
|
93
|
+
var ANCHOR_NAME = "MenuAnchor";
|
|
94
|
+
var MenuAnchor = React$1.forwardRef((props, forwardedRef) => {
|
|
95
|
+
const { __scopeMenu, ...anchorProps } = props;
|
|
96
|
+
return /* @__PURE__ */ jsx(Anchor, {
|
|
97
|
+
...usePopperScope$1(__scopeMenu),
|
|
98
|
+
...anchorProps,
|
|
99
|
+
ref: forwardedRef
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
MenuAnchor.displayName = ANCHOR_NAME;
|
|
103
|
+
var PORTAL_NAME$2 = "MenuPortal";
|
|
104
|
+
var [PortalProvider$1, usePortalContext$1] = createMenuContext(PORTAL_NAME$2, { forceMount: void 0 });
|
|
105
|
+
var MenuPortal = (props) => {
|
|
106
|
+
const { __scopeMenu, forceMount, children, container } = props;
|
|
107
|
+
const context = useMenuContext(PORTAL_NAME$2, __scopeMenu);
|
|
108
|
+
return /* @__PURE__ */ jsx(PortalProvider$1, {
|
|
109
|
+
scope: __scopeMenu,
|
|
110
|
+
forceMount,
|
|
111
|
+
children: /* @__PURE__ */ jsx(Presence, {
|
|
112
|
+
present: forceMount || context.open,
|
|
113
|
+
children: /* @__PURE__ */ jsx(Portal$2, {
|
|
114
|
+
asChild: true,
|
|
115
|
+
container,
|
|
116
|
+
children
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
MenuPortal.displayName = PORTAL_NAME$2;
|
|
122
|
+
var CONTENT_NAME$2 = "MenuContent";
|
|
123
|
+
var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME$2);
|
|
124
|
+
var MenuContent = React$1.forwardRef((props, forwardedRef) => {
|
|
125
|
+
const portalContext = usePortalContext$1(CONTENT_NAME$2, props.__scopeMenu);
|
|
126
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
127
|
+
const context = useMenuContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
128
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
129
|
+
return /* @__PURE__ */ jsx(Collection.Provider, {
|
|
130
|
+
scope: props.__scopeMenu,
|
|
131
|
+
children: /* @__PURE__ */ jsx(Presence, {
|
|
132
|
+
present: forceMount || context.open,
|
|
133
|
+
children: /* @__PURE__ */ jsx(Collection.Slot, {
|
|
134
|
+
scope: props.__scopeMenu,
|
|
135
|
+
children: rootContext.modal ? /* @__PURE__ */ jsx(MenuRootContentModal, {
|
|
136
|
+
...contentProps,
|
|
137
|
+
ref: forwardedRef
|
|
138
|
+
}) : /* @__PURE__ */ jsx(MenuRootContentNonModal, {
|
|
139
|
+
...contentProps,
|
|
140
|
+
ref: forwardedRef
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
var MenuRootContentModal = React$1.forwardRef((props, forwardedRef) => {
|
|
147
|
+
const context = useMenuContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
148
|
+
const ref = React$1.useRef(null);
|
|
149
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
150
|
+
React$1.useEffect(() => {
|
|
151
|
+
const content = ref.current;
|
|
152
|
+
if (content) return hideOthers(content);
|
|
153
|
+
}, []);
|
|
154
|
+
return /* @__PURE__ */ jsx(MenuContentImpl, {
|
|
155
|
+
...props,
|
|
156
|
+
ref: composedRefs,
|
|
157
|
+
trapFocus: context.open,
|
|
158
|
+
disableOutsidePointerEvents: context.open,
|
|
159
|
+
disableOutsideScroll: true,
|
|
160
|
+
onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault(), { checkForDefaultPrevented: false }),
|
|
161
|
+
onDismiss: () => context.onOpenChange(false)
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
var MenuRootContentNonModal = React$1.forwardRef((props, forwardedRef) => {
|
|
165
|
+
const context = useMenuContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
166
|
+
return /* @__PURE__ */ jsx(MenuContentImpl, {
|
|
167
|
+
...props,
|
|
168
|
+
ref: forwardedRef,
|
|
169
|
+
trapFocus: false,
|
|
170
|
+
disableOutsidePointerEvents: false,
|
|
171
|
+
disableOutsideScroll: false,
|
|
172
|
+
onDismiss: () => context.onOpenChange(false)
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
var Slot = createSlot("MenuContent.ScrollLock");
|
|
176
|
+
var MenuContentImpl = React$1.forwardRef((props, forwardedRef) => {
|
|
177
|
+
const { __scopeMenu, loop = false, trapFocus, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEntryFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, disableOutsideScroll, ...contentProps } = props;
|
|
178
|
+
const context = useMenuContext(CONTENT_NAME$2, __scopeMenu);
|
|
179
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$2, __scopeMenu);
|
|
180
|
+
const popperScope = usePopperScope$1(__scopeMenu);
|
|
181
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
182
|
+
const getItems = useCollection(__scopeMenu);
|
|
183
|
+
const [currentItemId, setCurrentItemId] = React$1.useState(null);
|
|
184
|
+
const contentRef = React$1.useRef(null);
|
|
185
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
|
|
186
|
+
const timerRef = React$1.useRef(0);
|
|
187
|
+
const searchRef = React$1.useRef("");
|
|
188
|
+
const pointerGraceTimerRef = React$1.useRef(0);
|
|
189
|
+
const pointerGraceIntentRef = React$1.useRef(null);
|
|
190
|
+
const pointerDirRef = React$1.useRef("right");
|
|
191
|
+
const lastPointerXRef = React$1.useRef(0);
|
|
192
|
+
const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React$1.Fragment;
|
|
193
|
+
const scrollLockWrapperProps = disableOutsideScroll ? {
|
|
194
|
+
as: Slot,
|
|
195
|
+
allowPinchZoom: true
|
|
196
|
+
} : void 0;
|
|
197
|
+
const handleTypeaheadSearch = (key) => {
|
|
198
|
+
const search = searchRef.current + key;
|
|
199
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
200
|
+
const currentItem = document.activeElement;
|
|
201
|
+
const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
|
|
202
|
+
const nextMatch = getNextMatch(items.map((item) => item.textValue), search, currentMatch);
|
|
203
|
+
const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
|
|
204
|
+
(function updateSearch(value) {
|
|
205
|
+
searchRef.current = value;
|
|
206
|
+
window.clearTimeout(timerRef.current);
|
|
207
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
208
|
+
})(search);
|
|
209
|
+
if (newItem) setTimeout(() => newItem.focus());
|
|
210
|
+
};
|
|
211
|
+
React$1.useEffect(() => {
|
|
212
|
+
return () => window.clearTimeout(timerRef.current);
|
|
213
|
+
}, []);
|
|
214
|
+
useFocusGuards();
|
|
215
|
+
const isPointerMovingToSubmenu = React$1.useCallback((event) => {
|
|
216
|
+
return pointerDirRef.current === pointerGraceIntentRef.current?.side && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
|
|
217
|
+
}, []);
|
|
218
|
+
return /* @__PURE__ */ jsx(MenuContentProvider, {
|
|
219
|
+
scope: __scopeMenu,
|
|
220
|
+
searchRef,
|
|
221
|
+
onItemEnter: React$1.useCallback((event) => {
|
|
222
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
223
|
+
}, [isPointerMovingToSubmenu]),
|
|
224
|
+
onItemLeave: React$1.useCallback((event) => {
|
|
225
|
+
if (isPointerMovingToSubmenu(event)) return;
|
|
226
|
+
contentRef.current?.focus();
|
|
227
|
+
setCurrentItemId(null);
|
|
228
|
+
}, [isPointerMovingToSubmenu]),
|
|
229
|
+
onTriggerLeave: React$1.useCallback((event) => {
|
|
230
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
231
|
+
}, [isPointerMovingToSubmenu]),
|
|
232
|
+
pointerGraceTimerRef,
|
|
233
|
+
onPointerGraceIntentChange: React$1.useCallback((intent) => {
|
|
234
|
+
pointerGraceIntentRef.current = intent;
|
|
235
|
+
}, []),
|
|
236
|
+
children: /* @__PURE__ */ jsx(ScrollLockWrapper, {
|
|
237
|
+
...scrollLockWrapperProps,
|
|
238
|
+
children: /* @__PURE__ */ jsx(FocusScope, {
|
|
239
|
+
asChild: true,
|
|
240
|
+
trapped: trapFocus,
|
|
241
|
+
onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
contentRef.current?.focus({ preventScroll: true });
|
|
244
|
+
}),
|
|
245
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
246
|
+
children: /* @__PURE__ */ jsx(DismissableLayer, {
|
|
247
|
+
asChild: true,
|
|
248
|
+
disableOutsidePointerEvents,
|
|
249
|
+
onEscapeKeyDown,
|
|
250
|
+
onPointerDownOutside,
|
|
251
|
+
onFocusOutside,
|
|
252
|
+
onInteractOutside,
|
|
253
|
+
onDismiss,
|
|
254
|
+
children: /* @__PURE__ */ jsx(Root, {
|
|
255
|
+
asChild: true,
|
|
256
|
+
...rovingFocusGroupScope,
|
|
257
|
+
dir: rootContext.dir,
|
|
258
|
+
orientation: "vertical",
|
|
259
|
+
loop,
|
|
260
|
+
currentTabStopId: currentItemId,
|
|
261
|
+
onCurrentTabStopIdChange: setCurrentItemId,
|
|
262
|
+
onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
|
|
263
|
+
if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
|
|
264
|
+
}),
|
|
265
|
+
preventScrollOnEntryFocus: true,
|
|
266
|
+
children: /* @__PURE__ */ jsx(Content, {
|
|
267
|
+
role: "menu",
|
|
268
|
+
"aria-orientation": "vertical",
|
|
269
|
+
"data-state": getOpenState(context.open),
|
|
270
|
+
"data-radix-menu-content": "",
|
|
271
|
+
dir: rootContext.dir,
|
|
272
|
+
...popperScope,
|
|
273
|
+
...contentProps,
|
|
274
|
+
ref: composedRefs,
|
|
275
|
+
style: {
|
|
276
|
+
outline: "none",
|
|
277
|
+
...contentProps.style
|
|
278
|
+
},
|
|
279
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
280
|
+
const isKeyDownInside = event.target.closest("[data-radix-menu-content]") === event.currentTarget;
|
|
281
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
282
|
+
const isCharacterKey = event.key.length === 1;
|
|
283
|
+
if (isKeyDownInside) {
|
|
284
|
+
if (event.key === "Tab") event.preventDefault();
|
|
285
|
+
if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
|
|
286
|
+
}
|
|
287
|
+
const content = contentRef.current;
|
|
288
|
+
if (event.target !== content) return;
|
|
289
|
+
if (!FIRST_LAST_KEYS.includes(event.key)) return;
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
const candidateNodes = getItems().filter((item) => !item.disabled).map((item) => item.ref.current);
|
|
292
|
+
if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
|
|
293
|
+
focusFirst(candidateNodes);
|
|
294
|
+
}),
|
|
295
|
+
onBlur: composeEventHandlers(props.onBlur, (event) => {
|
|
296
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
297
|
+
window.clearTimeout(timerRef.current);
|
|
298
|
+
searchRef.current = "";
|
|
299
|
+
}
|
|
300
|
+
}),
|
|
301
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => {
|
|
302
|
+
const target = event.target;
|
|
303
|
+
const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
|
|
304
|
+
if (event.currentTarget.contains(target) && pointerXHasChanged) {
|
|
305
|
+
pointerDirRef.current = event.clientX > lastPointerXRef.current ? "right" : "left";
|
|
306
|
+
lastPointerXRef.current = event.clientX;
|
|
307
|
+
}
|
|
308
|
+
}))
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
})
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
MenuContent.displayName = CONTENT_NAME$2;
|
|
317
|
+
var GROUP_NAME$1 = "MenuGroup";
|
|
318
|
+
var MenuGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
319
|
+
const { __scopeMenu, ...groupProps } = props;
|
|
320
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
321
|
+
role: "group",
|
|
322
|
+
...groupProps,
|
|
323
|
+
ref: forwardedRef
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
MenuGroup.displayName = GROUP_NAME$1;
|
|
327
|
+
var LABEL_NAME$1 = "MenuLabel";
|
|
328
|
+
var MenuLabel = React$1.forwardRef((props, forwardedRef) => {
|
|
329
|
+
const { __scopeMenu, ...labelProps } = props;
|
|
330
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
331
|
+
...labelProps,
|
|
332
|
+
ref: forwardedRef
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
MenuLabel.displayName = LABEL_NAME$1;
|
|
336
|
+
var ITEM_NAME$1 = "MenuItem";
|
|
337
|
+
var ITEM_SELECT = "menu.itemSelect";
|
|
338
|
+
var MenuItem = React$1.forwardRef((props, forwardedRef) => {
|
|
339
|
+
const { disabled = false, onSelect, ...itemProps } = props;
|
|
340
|
+
const ref = React$1.useRef(null);
|
|
341
|
+
const rootContext = useMenuRootContext(ITEM_NAME$1, props.__scopeMenu);
|
|
342
|
+
const contentContext = useMenuContentContext(ITEM_NAME$1, props.__scopeMenu);
|
|
343
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
344
|
+
const isPointerDownRef = React$1.useRef(false);
|
|
345
|
+
const handleSelect = () => {
|
|
346
|
+
const menuItem = ref.current;
|
|
347
|
+
if (!disabled && menuItem) {
|
|
348
|
+
const itemSelectEvent = new CustomEvent(ITEM_SELECT, {
|
|
349
|
+
bubbles: true,
|
|
350
|
+
cancelable: true
|
|
351
|
+
});
|
|
352
|
+
menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
|
|
353
|
+
dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
|
|
354
|
+
if (itemSelectEvent.defaultPrevented) isPointerDownRef.current = false;
|
|
355
|
+
else rootContext.onClose();
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
return /* @__PURE__ */ jsx(MenuItemImpl, {
|
|
359
|
+
...itemProps,
|
|
360
|
+
ref: composedRefs,
|
|
361
|
+
disabled,
|
|
362
|
+
onClick: composeEventHandlers(props.onClick, handleSelect),
|
|
363
|
+
onPointerDown: (event) => {
|
|
364
|
+
props.onPointerDown?.(event);
|
|
365
|
+
isPointerDownRef.current = true;
|
|
366
|
+
},
|
|
367
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
368
|
+
if (!isPointerDownRef.current) event.currentTarget?.click();
|
|
369
|
+
}),
|
|
370
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
371
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
372
|
+
if (disabled || isTypingAhead && event.key === " ") return;
|
|
373
|
+
if (SELECTION_KEYS.includes(event.key)) {
|
|
374
|
+
event.currentTarget.click();
|
|
375
|
+
event.preventDefault();
|
|
376
|
+
}
|
|
377
|
+
})
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
MenuItem.displayName = ITEM_NAME$1;
|
|
381
|
+
var MenuItemImpl = React$1.forwardRef((props, forwardedRef) => {
|
|
382
|
+
const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
|
|
383
|
+
const contentContext = useMenuContentContext(ITEM_NAME$1, __scopeMenu);
|
|
384
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
385
|
+
const ref = React$1.useRef(null);
|
|
386
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
387
|
+
const [isFocused, setIsFocused] = React$1.useState(false);
|
|
388
|
+
const [textContent, setTextContent] = React$1.useState("");
|
|
389
|
+
React$1.useEffect(() => {
|
|
390
|
+
const menuItem = ref.current;
|
|
391
|
+
if (menuItem) setTextContent((menuItem.textContent ?? "").trim());
|
|
392
|
+
}, [itemProps.children]);
|
|
393
|
+
return /* @__PURE__ */ jsx(Collection.ItemSlot, {
|
|
394
|
+
scope: __scopeMenu,
|
|
395
|
+
disabled,
|
|
396
|
+
textValue: textValue ?? textContent,
|
|
397
|
+
children: /* @__PURE__ */ jsx(Item, {
|
|
398
|
+
asChild: true,
|
|
399
|
+
...rovingFocusGroupScope,
|
|
400
|
+
focusable: !disabled,
|
|
401
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
402
|
+
role: "menuitem",
|
|
403
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
404
|
+
"aria-disabled": disabled || void 0,
|
|
405
|
+
"data-disabled": disabled ? "" : void 0,
|
|
406
|
+
...itemProps,
|
|
407
|
+
ref: composedRefs,
|
|
408
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => {
|
|
409
|
+
if (disabled) contentContext.onItemLeave(event);
|
|
410
|
+
else {
|
|
411
|
+
contentContext.onItemEnter(event);
|
|
412
|
+
if (!event.defaultPrevented) event.currentTarget.focus({ preventScroll: true });
|
|
413
|
+
}
|
|
414
|
+
})),
|
|
415
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse((event) => contentContext.onItemLeave(event))),
|
|
416
|
+
onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
|
|
417
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
var CHECKBOX_ITEM_NAME$1 = "MenuCheckboxItem";
|
|
423
|
+
var MenuCheckboxItem = React$1.forwardRef((props, forwardedRef) => {
|
|
424
|
+
const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
|
|
425
|
+
return /* @__PURE__ */ jsx(ItemIndicatorProvider, {
|
|
426
|
+
scope: props.__scopeMenu,
|
|
427
|
+
checked,
|
|
428
|
+
children: /* @__PURE__ */ jsx(MenuItem, {
|
|
429
|
+
role: "menuitemcheckbox",
|
|
430
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
431
|
+
...checkboxItemProps,
|
|
432
|
+
ref: forwardedRef,
|
|
433
|
+
"data-state": getCheckedState(checked),
|
|
434
|
+
onSelect: composeEventHandlers(checkboxItemProps.onSelect, () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked), { checkForDefaultPrevented: false })
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME$1;
|
|
439
|
+
var RADIO_GROUP_NAME$1 = "MenuRadioGroup";
|
|
440
|
+
var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(RADIO_GROUP_NAME$1, {
|
|
441
|
+
value: void 0,
|
|
442
|
+
onValueChange: () => {}
|
|
443
|
+
});
|
|
444
|
+
var MenuRadioGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
445
|
+
const { value, onValueChange, ...groupProps } = props;
|
|
446
|
+
const handleValueChange = useCallbackRef(onValueChange);
|
|
447
|
+
return /* @__PURE__ */ jsx(RadioGroupProvider, {
|
|
448
|
+
scope: props.__scopeMenu,
|
|
449
|
+
value,
|
|
450
|
+
onValueChange: handleValueChange,
|
|
451
|
+
children: /* @__PURE__ */ jsx(MenuGroup, {
|
|
452
|
+
...groupProps,
|
|
453
|
+
ref: forwardedRef
|
|
454
|
+
})
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
MenuRadioGroup.displayName = RADIO_GROUP_NAME$1;
|
|
458
|
+
var RADIO_ITEM_NAME$1 = "MenuRadioItem";
|
|
459
|
+
var MenuRadioItem = React$1.forwardRef((props, forwardedRef) => {
|
|
460
|
+
const { value, ...radioItemProps } = props;
|
|
461
|
+
const context = useRadioGroupContext(RADIO_ITEM_NAME$1, props.__scopeMenu);
|
|
462
|
+
const checked = value === context.value;
|
|
463
|
+
return /* @__PURE__ */ jsx(ItemIndicatorProvider, {
|
|
464
|
+
scope: props.__scopeMenu,
|
|
465
|
+
checked,
|
|
466
|
+
children: /* @__PURE__ */ jsx(MenuItem, {
|
|
467
|
+
role: "menuitemradio",
|
|
468
|
+
"aria-checked": checked,
|
|
469
|
+
...radioItemProps,
|
|
470
|
+
ref: forwardedRef,
|
|
471
|
+
"data-state": getCheckedState(checked),
|
|
472
|
+
onSelect: composeEventHandlers(radioItemProps.onSelect, () => context.onValueChange?.(value), { checkForDefaultPrevented: false })
|
|
473
|
+
})
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
MenuRadioItem.displayName = RADIO_ITEM_NAME$1;
|
|
477
|
+
var ITEM_INDICATOR_NAME = "MenuItemIndicator";
|
|
478
|
+
var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(ITEM_INDICATOR_NAME, { checked: false });
|
|
479
|
+
var MenuItemIndicator = React$1.forwardRef((props, forwardedRef) => {
|
|
480
|
+
const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
|
|
481
|
+
const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
|
|
482
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
483
|
+
present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
|
|
484
|
+
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
485
|
+
...itemIndicatorProps,
|
|
486
|
+
ref: forwardedRef,
|
|
487
|
+
"data-state": getCheckedState(indicatorContext.checked)
|
|
488
|
+
})
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
492
|
+
var SEPARATOR_NAME$1 = "MenuSeparator";
|
|
493
|
+
var MenuSeparator = React$1.forwardRef((props, forwardedRef) => {
|
|
494
|
+
const { __scopeMenu, ...separatorProps } = props;
|
|
495
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
496
|
+
role: "separator",
|
|
497
|
+
"aria-orientation": "horizontal",
|
|
498
|
+
...separatorProps,
|
|
499
|
+
ref: forwardedRef
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
MenuSeparator.displayName = SEPARATOR_NAME$1;
|
|
503
|
+
var ARROW_NAME$2 = "MenuArrow";
|
|
504
|
+
var MenuArrow = React$1.forwardRef((props, forwardedRef) => {
|
|
505
|
+
const { __scopeMenu, ...arrowProps } = props;
|
|
506
|
+
return /* @__PURE__ */ jsx(Arrow, {
|
|
507
|
+
...usePopperScope$1(__scopeMenu),
|
|
508
|
+
...arrowProps,
|
|
509
|
+
ref: forwardedRef
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
MenuArrow.displayName = ARROW_NAME$2;
|
|
513
|
+
var SUB_NAME = "MenuSub";
|
|
514
|
+
var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
|
|
515
|
+
var MenuSub = (props) => {
|
|
516
|
+
const { __scopeMenu, children, open = false, onOpenChange } = props;
|
|
517
|
+
const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
|
|
518
|
+
const popperScope = usePopperScope$1(__scopeMenu);
|
|
519
|
+
const [trigger, setTrigger] = React$1.useState(null);
|
|
520
|
+
const [content, setContent] = React$1.useState(null);
|
|
521
|
+
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
522
|
+
React$1.useEffect(() => {
|
|
523
|
+
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
524
|
+
return () => handleOpenChange(false);
|
|
525
|
+
}, [parentMenuContext.open, handleOpenChange]);
|
|
526
|
+
return /* @__PURE__ */ jsx(Root2$1, {
|
|
527
|
+
...popperScope,
|
|
528
|
+
children: /* @__PURE__ */ jsx(MenuProvider, {
|
|
529
|
+
scope: __scopeMenu,
|
|
530
|
+
open,
|
|
531
|
+
onOpenChange: handleOpenChange,
|
|
532
|
+
content,
|
|
533
|
+
onContentChange: setContent,
|
|
534
|
+
children: /* @__PURE__ */ jsx(MenuSubProvider, {
|
|
535
|
+
scope: __scopeMenu,
|
|
536
|
+
contentId: useId$1(),
|
|
537
|
+
triggerId: useId$1(),
|
|
538
|
+
trigger,
|
|
539
|
+
onTriggerChange: setTrigger,
|
|
540
|
+
children
|
|
541
|
+
})
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
MenuSub.displayName = SUB_NAME;
|
|
546
|
+
var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
|
|
547
|
+
var MenuSubTrigger = React$1.forwardRef((props, forwardedRef) => {
|
|
548
|
+
const context = useMenuContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
549
|
+
const rootContext = useMenuRootContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
550
|
+
const subContext = useMenuSubContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
551
|
+
const contentContext = useMenuContentContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
552
|
+
const openTimerRef = React$1.useRef(null);
|
|
553
|
+
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
554
|
+
const scope = { __scopeMenu: props.__scopeMenu };
|
|
555
|
+
const clearOpenTimer = React$1.useCallback(() => {
|
|
556
|
+
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
557
|
+
openTimerRef.current = null;
|
|
558
|
+
}, []);
|
|
559
|
+
React$1.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
560
|
+
React$1.useEffect(() => {
|
|
561
|
+
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
562
|
+
return () => {
|
|
563
|
+
window.clearTimeout(pointerGraceTimer);
|
|
564
|
+
onPointerGraceIntentChange(null);
|
|
565
|
+
};
|
|
566
|
+
}, [pointerGraceTimerRef, onPointerGraceIntentChange]);
|
|
567
|
+
return /* @__PURE__ */ jsx(MenuAnchor, {
|
|
568
|
+
asChild: true,
|
|
569
|
+
...scope,
|
|
570
|
+
children: /* @__PURE__ */ jsx(MenuItemImpl, {
|
|
571
|
+
id: subContext.triggerId,
|
|
572
|
+
"aria-haspopup": "menu",
|
|
573
|
+
"aria-expanded": context.open,
|
|
574
|
+
"aria-controls": context.open ? subContext.contentId : void 0,
|
|
575
|
+
"data-state": getOpenState(context.open),
|
|
576
|
+
...props,
|
|
577
|
+
ref: composeRefs(forwardedRef, subContext.onTriggerChange),
|
|
578
|
+
onClick: (event) => {
|
|
579
|
+
props.onClick?.(event);
|
|
580
|
+
if (props.disabled || event.defaultPrevented) return;
|
|
581
|
+
event.currentTarget.focus();
|
|
582
|
+
if (!context.open) context.onOpenChange(true);
|
|
583
|
+
},
|
|
584
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse((event) => {
|
|
585
|
+
contentContext.onItemEnter(event);
|
|
586
|
+
if (event.defaultPrevented) return;
|
|
587
|
+
if (!props.disabled && !context.open && !openTimerRef.current) {
|
|
588
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
589
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
590
|
+
context.onOpenChange(true);
|
|
591
|
+
clearOpenTimer();
|
|
592
|
+
}, 100);
|
|
593
|
+
}
|
|
594
|
+
})),
|
|
595
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse((event) => {
|
|
596
|
+
clearOpenTimer();
|
|
597
|
+
const contentRect = context.content?.getBoundingClientRect();
|
|
598
|
+
if (contentRect) {
|
|
599
|
+
const side = context.content?.dataset.side;
|
|
600
|
+
const rightSide = side === "right";
|
|
601
|
+
const bleed = rightSide ? -5 : 5;
|
|
602
|
+
const contentNearEdge = contentRect[rightSide ? "left" : "right"];
|
|
603
|
+
const contentFarEdge = contentRect[rightSide ? "right" : "left"];
|
|
604
|
+
contentContext.onPointerGraceIntentChange({
|
|
605
|
+
area: [
|
|
606
|
+
{
|
|
607
|
+
x: event.clientX + bleed,
|
|
608
|
+
y: event.clientY
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
x: contentNearEdge,
|
|
612
|
+
y: contentRect.top
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
x: contentFarEdge,
|
|
616
|
+
y: contentRect.top
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
x: contentFarEdge,
|
|
620
|
+
y: contentRect.bottom
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
x: contentNearEdge,
|
|
624
|
+
y: contentRect.bottom
|
|
625
|
+
}
|
|
626
|
+
],
|
|
627
|
+
side
|
|
628
|
+
});
|
|
629
|
+
window.clearTimeout(pointerGraceTimerRef.current);
|
|
630
|
+
pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300);
|
|
631
|
+
} else {
|
|
632
|
+
contentContext.onTriggerLeave(event);
|
|
633
|
+
if (event.defaultPrevented) return;
|
|
634
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
635
|
+
}
|
|
636
|
+
})),
|
|
637
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
638
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
639
|
+
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
640
|
+
if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
|
|
641
|
+
context.onOpenChange(true);
|
|
642
|
+
context.content?.focus();
|
|
643
|
+
event.preventDefault();
|
|
644
|
+
}
|
|
645
|
+
})
|
|
646
|
+
})
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
MenuSubTrigger.displayName = SUB_TRIGGER_NAME$1;
|
|
650
|
+
var SUB_CONTENT_NAME$1 = "MenuSubContent";
|
|
651
|
+
var MenuSubContent = React$1.forwardRef((props, forwardedRef) => {
|
|
652
|
+
const portalContext = usePortalContext$1(CONTENT_NAME$2, props.__scopeMenu);
|
|
653
|
+
const { forceMount = portalContext.forceMount, align = "start", ...subContentProps } = props;
|
|
654
|
+
const context = useMenuContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
655
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$2, props.__scopeMenu);
|
|
656
|
+
const subContext = useMenuSubContext(SUB_CONTENT_NAME$1, props.__scopeMenu);
|
|
657
|
+
const ref = React$1.useRef(null);
|
|
658
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
659
|
+
return /* @__PURE__ */ jsx(Collection.Provider, {
|
|
660
|
+
scope: props.__scopeMenu,
|
|
661
|
+
children: /* @__PURE__ */ jsx(Presence, {
|
|
662
|
+
present: forceMount || context.open,
|
|
663
|
+
children: /* @__PURE__ */ jsx(Collection.Slot, {
|
|
664
|
+
scope: props.__scopeMenu,
|
|
665
|
+
children: /* @__PURE__ */ jsx(MenuContentImpl, {
|
|
666
|
+
id: subContext.contentId,
|
|
667
|
+
"aria-labelledby": subContext.triggerId,
|
|
668
|
+
...subContentProps,
|
|
669
|
+
ref: composedRefs,
|
|
670
|
+
align,
|
|
671
|
+
side: rootContext.dir === "rtl" ? "left" : "right",
|
|
672
|
+
disableOutsidePointerEvents: false,
|
|
673
|
+
disableOutsideScroll: false,
|
|
674
|
+
trapFocus: false,
|
|
675
|
+
onOpenAutoFocus: (event) => {
|
|
676
|
+
if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
|
|
677
|
+
event.preventDefault();
|
|
678
|
+
},
|
|
679
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
680
|
+
onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
|
|
681
|
+
if (event.target !== subContext.trigger) context.onOpenChange(false);
|
|
682
|
+
}),
|
|
683
|
+
onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
|
|
684
|
+
rootContext.onClose();
|
|
685
|
+
event.preventDefault();
|
|
686
|
+
}),
|
|
687
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
688
|
+
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
689
|
+
const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
|
|
690
|
+
if (isKeyDownInside && isCloseKey) {
|
|
691
|
+
context.onOpenChange(false);
|
|
692
|
+
subContext.trigger?.focus();
|
|
693
|
+
event.preventDefault();
|
|
694
|
+
}
|
|
695
|
+
})
|
|
696
|
+
})
|
|
697
|
+
})
|
|
698
|
+
})
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
MenuSubContent.displayName = SUB_CONTENT_NAME$1;
|
|
702
|
+
function getOpenState(open) {
|
|
703
|
+
return open ? "open" : "closed";
|
|
704
|
+
}
|
|
705
|
+
function isIndeterminate(checked) {
|
|
706
|
+
return checked === "indeterminate";
|
|
707
|
+
}
|
|
708
|
+
function getCheckedState(checked) {
|
|
709
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
710
|
+
}
|
|
711
|
+
function focusFirst(candidates) {
|
|
712
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
713
|
+
for (const candidate of candidates) {
|
|
714
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
715
|
+
candidate.focus();
|
|
716
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function wrapArray(array, startIndex) {
|
|
720
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
721
|
+
}
|
|
722
|
+
function getNextMatch(values, search, currentMatch) {
|
|
723
|
+
const normalizedSearch = search.length > 1 && Array.from(search).every((char) => char === search[0]) ? search[0] : search;
|
|
724
|
+
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
725
|
+
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
726
|
+
if (normalizedSearch.length === 1) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
727
|
+
const nextMatch = wrappedValues.find((value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase()));
|
|
728
|
+
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
729
|
+
}
|
|
730
|
+
function isPointInPolygon$1(point, polygon) {
|
|
731
|
+
const { x, y } = point;
|
|
732
|
+
let inside = false;
|
|
733
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
734
|
+
const ii = polygon[i];
|
|
735
|
+
const jj = polygon[j];
|
|
736
|
+
const xi = ii.x;
|
|
737
|
+
const yi = ii.y;
|
|
738
|
+
const xj = jj.x;
|
|
739
|
+
const yj = jj.y;
|
|
740
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) inside = !inside;
|
|
741
|
+
}
|
|
742
|
+
return inside;
|
|
743
|
+
}
|
|
744
|
+
function isPointerInGraceArea(event, area) {
|
|
745
|
+
if (!area) return false;
|
|
746
|
+
return isPointInPolygon$1({
|
|
747
|
+
x: event.clientX,
|
|
748
|
+
y: event.clientY
|
|
749
|
+
}, area);
|
|
750
|
+
}
|
|
751
|
+
function whenMouse(handler) {
|
|
752
|
+
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
753
|
+
}
|
|
754
|
+
var Root3$1 = Menu;
|
|
755
|
+
var Anchor2 = MenuAnchor;
|
|
756
|
+
var Portal$1 = MenuPortal;
|
|
757
|
+
var Content2$2 = MenuContent;
|
|
758
|
+
var Group = MenuGroup;
|
|
759
|
+
var Label = MenuLabel;
|
|
760
|
+
var Item2$1 = MenuItem;
|
|
761
|
+
var CheckboxItem = MenuCheckboxItem;
|
|
762
|
+
var RadioGroup = MenuRadioGroup;
|
|
763
|
+
var RadioItem = MenuRadioItem;
|
|
764
|
+
var ItemIndicator = MenuItemIndicator;
|
|
765
|
+
var Separator = MenuSeparator;
|
|
766
|
+
var Arrow2$1 = MenuArrow;
|
|
767
|
+
var SubTrigger = MenuSubTrigger;
|
|
768
|
+
var SubContent = MenuSubContent;
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-dropdown-menu@2.1.18_@types+react-dom@19.2.3_@types+react@19.2.17__@typ_7af4ef59106aedc167d77b05d7699524/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs
|
|
771
|
+
var DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
772
|
+
var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(DROPDOWN_MENU_NAME, [createMenuScope]);
|
|
773
|
+
var useMenuScope = createMenuScope();
|
|
774
|
+
var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
|
|
775
|
+
var DropdownMenu$1 = (props) => {
|
|
776
|
+
const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
|
|
777
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
778
|
+
const triggerRef = React$1.useRef(null);
|
|
779
|
+
const [open, setOpen] = useControllableState({
|
|
780
|
+
prop: openProp,
|
|
781
|
+
defaultProp: defaultOpen ?? false,
|
|
782
|
+
onChange: onOpenChange,
|
|
783
|
+
caller: DROPDOWN_MENU_NAME
|
|
784
|
+
});
|
|
785
|
+
return /* @__PURE__ */ jsx(DropdownMenuProvider, {
|
|
786
|
+
scope: __scopeDropdownMenu,
|
|
787
|
+
triggerId: useId$1(),
|
|
788
|
+
triggerRef,
|
|
789
|
+
contentId: useId$1(),
|
|
790
|
+
open,
|
|
791
|
+
onOpenChange: setOpen,
|
|
792
|
+
onOpenToggle: React$1.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
793
|
+
modal,
|
|
794
|
+
children: /* @__PURE__ */ jsx(Root3$1, {
|
|
795
|
+
...menuScope,
|
|
796
|
+
open,
|
|
797
|
+
onOpenChange: setOpen,
|
|
798
|
+
dir,
|
|
799
|
+
modal,
|
|
800
|
+
children
|
|
801
|
+
})
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
DropdownMenu$1.displayName = DROPDOWN_MENU_NAME;
|
|
805
|
+
var TRIGGER_NAME$1 = "DropdownMenuTrigger";
|
|
806
|
+
var DropdownMenuTrigger$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
807
|
+
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
808
|
+
const context = useDropdownMenuContext(TRIGGER_NAME$1, __scopeDropdownMenu);
|
|
809
|
+
return /* @__PURE__ */ jsx(Anchor2, {
|
|
810
|
+
asChild: true,
|
|
811
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
812
|
+
children: /* @__PURE__ */ jsx(Primitive.button, {
|
|
813
|
+
type: "button",
|
|
814
|
+
id: context.triggerId,
|
|
815
|
+
"aria-haspopup": "menu",
|
|
816
|
+
"aria-expanded": context.open,
|
|
817
|
+
"aria-controls": context.open ? context.contentId : void 0,
|
|
818
|
+
"data-state": context.open ? "open" : "closed",
|
|
819
|
+
"data-disabled": disabled ? "" : void 0,
|
|
820
|
+
disabled,
|
|
821
|
+
...triggerProps,
|
|
822
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
823
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
824
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
825
|
+
context.onOpenToggle();
|
|
826
|
+
if (!context.open) event.preventDefault();
|
|
827
|
+
}
|
|
828
|
+
}),
|
|
829
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
830
|
+
if (disabled) return;
|
|
831
|
+
if (["Enter", " "].includes(event.key)) context.onOpenToggle();
|
|
832
|
+
if (event.key === "ArrowDown") context.onOpenChange(true);
|
|
833
|
+
if ([
|
|
834
|
+
"Enter",
|
|
835
|
+
" ",
|
|
836
|
+
"ArrowDown"
|
|
837
|
+
].includes(event.key)) event.preventDefault();
|
|
838
|
+
})
|
|
839
|
+
})
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
DropdownMenuTrigger$1.displayName = TRIGGER_NAME$1;
|
|
843
|
+
var PORTAL_NAME$1 = "DropdownMenuPortal";
|
|
844
|
+
var DropdownMenuPortal = (props) => {
|
|
845
|
+
const { __scopeDropdownMenu, ...portalProps } = props;
|
|
846
|
+
return /* @__PURE__ */ jsx(Portal$1, {
|
|
847
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
848
|
+
...portalProps
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
DropdownMenuPortal.displayName = PORTAL_NAME$1;
|
|
852
|
+
var CONTENT_NAME$1 = "DropdownMenuContent";
|
|
853
|
+
var DropdownMenuContent$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
854
|
+
const { __scopeDropdownMenu, ...contentProps } = props;
|
|
855
|
+
const context = useDropdownMenuContext(CONTENT_NAME$1, __scopeDropdownMenu);
|
|
856
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
857
|
+
const hasInteractedOutsideRef = React$1.useRef(false);
|
|
858
|
+
return /* @__PURE__ */ jsx(Content2$2, {
|
|
859
|
+
id: context.contentId,
|
|
860
|
+
"aria-labelledby": context.triggerId,
|
|
861
|
+
...menuScope,
|
|
862
|
+
...contentProps,
|
|
863
|
+
ref: forwardedRef,
|
|
864
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
865
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
866
|
+
hasInteractedOutsideRef.current = false;
|
|
867
|
+
event.preventDefault();
|
|
868
|
+
}),
|
|
869
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
|
|
870
|
+
const originalEvent = event.detail.originalEvent;
|
|
871
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
872
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
873
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
874
|
+
}),
|
|
875
|
+
style: {
|
|
876
|
+
...props.style,
|
|
877
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
878
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
879
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
880
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
881
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
DropdownMenuContent$1.displayName = CONTENT_NAME$1;
|
|
886
|
+
var GROUP_NAME = "DropdownMenuGroup";
|
|
887
|
+
var DropdownMenuGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
888
|
+
const { __scopeDropdownMenu, ...groupProps } = props;
|
|
889
|
+
return /* @__PURE__ */ jsx(Group, {
|
|
890
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
891
|
+
...groupProps,
|
|
892
|
+
ref: forwardedRef
|
|
893
|
+
});
|
|
894
|
+
});
|
|
895
|
+
DropdownMenuGroup.displayName = GROUP_NAME;
|
|
896
|
+
var LABEL_NAME = "DropdownMenuLabel";
|
|
897
|
+
var DropdownMenuLabel$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
898
|
+
const { __scopeDropdownMenu, ...labelProps } = props;
|
|
899
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
900
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
901
|
+
...labelProps,
|
|
902
|
+
ref: forwardedRef
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
DropdownMenuLabel$1.displayName = LABEL_NAME;
|
|
906
|
+
var ITEM_NAME = "DropdownMenuItem";
|
|
907
|
+
var DropdownMenuItem$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
908
|
+
const { __scopeDropdownMenu, ...itemProps } = props;
|
|
909
|
+
return /* @__PURE__ */ jsx(Item2$1, {
|
|
910
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
911
|
+
...itemProps,
|
|
912
|
+
ref: forwardedRef
|
|
913
|
+
});
|
|
914
|
+
});
|
|
915
|
+
DropdownMenuItem$1.displayName = ITEM_NAME;
|
|
916
|
+
var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
|
|
917
|
+
var DropdownMenuCheckboxItem$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
918
|
+
const { __scopeDropdownMenu, ...checkboxItemProps } = props;
|
|
919
|
+
return /* @__PURE__ */ jsx(CheckboxItem, {
|
|
920
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
921
|
+
...checkboxItemProps,
|
|
922
|
+
ref: forwardedRef
|
|
923
|
+
});
|
|
924
|
+
});
|
|
925
|
+
DropdownMenuCheckboxItem$1.displayName = CHECKBOX_ITEM_NAME;
|
|
926
|
+
var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
|
|
927
|
+
var DropdownMenuRadioGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
928
|
+
const { __scopeDropdownMenu, ...radioGroupProps } = props;
|
|
929
|
+
return /* @__PURE__ */ jsx(RadioGroup, {
|
|
930
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
931
|
+
...radioGroupProps,
|
|
932
|
+
ref: forwardedRef
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
936
|
+
var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
|
|
937
|
+
var DropdownMenuRadioItem$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
938
|
+
const { __scopeDropdownMenu, ...radioItemProps } = props;
|
|
939
|
+
return /* @__PURE__ */ jsx(RadioItem, {
|
|
940
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
941
|
+
...radioItemProps,
|
|
942
|
+
ref: forwardedRef
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
DropdownMenuRadioItem$1.displayName = RADIO_ITEM_NAME;
|
|
946
|
+
var INDICATOR_NAME = "DropdownMenuItemIndicator";
|
|
947
|
+
var DropdownMenuItemIndicator = React$1.forwardRef((props, forwardedRef) => {
|
|
948
|
+
const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
|
|
949
|
+
return /* @__PURE__ */ jsx(ItemIndicator, {
|
|
950
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
951
|
+
...itemIndicatorProps,
|
|
952
|
+
ref: forwardedRef
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
956
|
+
var SEPARATOR_NAME = "DropdownMenuSeparator";
|
|
957
|
+
var DropdownMenuSeparator$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
958
|
+
const { __scopeDropdownMenu, ...separatorProps } = props;
|
|
959
|
+
return /* @__PURE__ */ jsx(Separator, {
|
|
960
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
961
|
+
...separatorProps,
|
|
962
|
+
ref: forwardedRef
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
DropdownMenuSeparator$1.displayName = SEPARATOR_NAME;
|
|
966
|
+
var ARROW_NAME$1 = "DropdownMenuArrow";
|
|
967
|
+
var DropdownMenuArrow = React$1.forwardRef((props, forwardedRef) => {
|
|
968
|
+
const { __scopeDropdownMenu, ...arrowProps } = props;
|
|
969
|
+
return /* @__PURE__ */ jsx(Arrow2$1, {
|
|
970
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
971
|
+
...arrowProps,
|
|
972
|
+
ref: forwardedRef
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
DropdownMenuArrow.displayName = ARROW_NAME$1;
|
|
976
|
+
var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
|
|
977
|
+
var DropdownMenuSubTrigger$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
978
|
+
const { __scopeDropdownMenu, ...subTriggerProps } = props;
|
|
979
|
+
return /* @__PURE__ */ jsx(SubTrigger, {
|
|
980
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
981
|
+
...subTriggerProps,
|
|
982
|
+
ref: forwardedRef
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
DropdownMenuSubTrigger$1.displayName = SUB_TRIGGER_NAME;
|
|
986
|
+
var SUB_CONTENT_NAME = "DropdownMenuSubContent";
|
|
987
|
+
var DropdownMenuSubContent$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
988
|
+
const { __scopeDropdownMenu, ...subContentProps } = props;
|
|
989
|
+
return /* @__PURE__ */ jsx(SubContent, {
|
|
990
|
+
...useMenuScope(__scopeDropdownMenu),
|
|
991
|
+
...subContentProps,
|
|
992
|
+
ref: forwardedRef,
|
|
993
|
+
style: {
|
|
994
|
+
...props.style,
|
|
995
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
996
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
997
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
998
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
999
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
});
|
|
1003
|
+
DropdownMenuSubContent$1.displayName = SUB_CONTENT_NAME;
|
|
1004
|
+
var Root2 = DropdownMenu$1;
|
|
1005
|
+
var Trigger$1 = DropdownMenuTrigger$1;
|
|
1006
|
+
var Portal2 = DropdownMenuPortal;
|
|
1007
|
+
var Content2$1 = DropdownMenuContent$1;
|
|
1008
|
+
var Label2 = DropdownMenuLabel$1;
|
|
1009
|
+
var Item2 = DropdownMenuItem$1;
|
|
1010
|
+
var CheckboxItem2 = DropdownMenuCheckboxItem$1;
|
|
1011
|
+
var RadioItem2 = DropdownMenuRadioItem$1;
|
|
1012
|
+
var ItemIndicator2 = DropdownMenuItemIndicator;
|
|
1013
|
+
var Separator2 = DropdownMenuSeparator$1;
|
|
1014
|
+
var SubTrigger2 = DropdownMenuSubTrigger$1;
|
|
1015
|
+
var SubContent2 = DropdownMenuSubContent$1;
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region ../ui/src/dropdown-menu.tsx
|
|
1018
|
+
const DropdownMenu = Root2;
|
|
1019
|
+
const DropdownMenuTrigger = Trigger$1;
|
|
1020
|
+
const DropdownMenuSubTrigger = React$1.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(SubTrigger2, {
|
|
1021
|
+
ref,
|
|
1022
|
+
className: cn(`flex select-none items-center gap-2 rounded-[var(--item-radius)] px-2 py-1.5 text-sm outline-none ${menuItemInteractionClassName} ${menuTriggerInteractionClassName} [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`, inset && "pl-8", className),
|
|
1023
|
+
...props,
|
|
1024
|
+
children: [children, /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })]
|
|
1025
|
+
}));
|
|
1026
|
+
DropdownMenuSubTrigger.displayName = SubTrigger2.displayName;
|
|
1027
|
+
const DropdownMenuSubContent = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SubContent2, {
|
|
1028
|
+
ref,
|
|
1029
|
+
className: cn("z-50 min-w-[8rem] overflow-hidden rounded-[var(--item-radius)] border border-border/60 bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", className),
|
|
1030
|
+
...props
|
|
1031
|
+
}));
|
|
1032
|
+
DropdownMenuSubContent.displayName = SubContent2.displayName;
|
|
1033
|
+
const DropdownMenuContent = React$1.forwardRef(({ className, sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsx(Portal2, {
|
|
1034
|
+
...container ? { container } : {},
|
|
1035
|
+
children: /* @__PURE__ */ jsx(Content2$1, {
|
|
1036
|
+
ref,
|
|
1037
|
+
sideOffset,
|
|
1038
|
+
className: cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-[var(--item-radius)] border border-border/60 bg-popover p-1 text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", className),
|
|
1039
|
+
...props
|
|
1040
|
+
})
|
|
1041
|
+
}));
|
|
1042
|
+
DropdownMenuContent.displayName = Content2$1.displayName;
|
|
1043
|
+
const DropdownMenuItem = React$1.forwardRef(({ className, inset, tone = "default", ...props }, ref) => /* @__PURE__ */ jsx(Item2, {
|
|
1044
|
+
ref,
|
|
1045
|
+
className: cn("relative flex select-none items-center gap-2 rounded-[var(--item-radius)] px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", tone === "destructive" ? "cursor-pointer text-destructive focus:bg-destructive focus:text-destructive-foreground data-[highlighted]:bg-destructive data-[highlighted]:text-destructive-foreground" : menuItemInteractionClassName, className),
|
|
1046
|
+
...props
|
|
1047
|
+
}));
|
|
1048
|
+
DropdownMenuItem.displayName = Item2.displayName;
|
|
1049
|
+
const DropdownMenuCheckboxItem = React$1.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(CheckboxItem2, {
|
|
1050
|
+
ref,
|
|
1051
|
+
className: cn(`relative flex select-none items-center rounded-[var(--item-radius)] py-1.5 pl-8 pr-2 text-sm outline-none transition-colors ${menuItemInteractionClassName} data-[disabled]:pointer-events-none data-[disabled]:opacity-50`, className),
|
|
1052
|
+
checked,
|
|
1053
|
+
...props,
|
|
1054
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1055
|
+
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
1056
|
+
children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) })
|
|
1057
|
+
}), children]
|
|
1058
|
+
}));
|
|
1059
|
+
DropdownMenuCheckboxItem.displayName = CheckboxItem2.displayName;
|
|
1060
|
+
const DropdownMenuRadioItem = React$1.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(RadioItem2, {
|
|
1061
|
+
ref,
|
|
1062
|
+
className: cn(`relative flex select-none items-center rounded-[var(--item-radius)] py-1.5 pl-8 pr-2 text-sm outline-none transition-colors ${menuItemInteractionClassName} data-[disabled]:pointer-events-none data-[disabled]:opacity-50`, className),
|
|
1063
|
+
...props,
|
|
1064
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1065
|
+
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
1066
|
+
children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) })
|
|
1067
|
+
}), children]
|
|
1068
|
+
}));
|
|
1069
|
+
DropdownMenuRadioItem.displayName = RadioItem2.displayName;
|
|
1070
|
+
const DropdownMenuLabel = React$1.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(Label2, {
|
|
1071
|
+
ref,
|
|
1072
|
+
className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
|
|
1073
|
+
...props
|
|
1074
|
+
}));
|
|
1075
|
+
DropdownMenuLabel.displayName = Label2.displayName;
|
|
1076
|
+
const DropdownMenuSeparator = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Separator2, {
|
|
1077
|
+
ref,
|
|
1078
|
+
className: cn("-mx-1 my-1 h-px bg-muted", className),
|
|
1079
|
+
...props
|
|
1080
|
+
}));
|
|
1081
|
+
DropdownMenuSeparator.displayName = Separator2.displayName;
|
|
1082
|
+
const DropdownMenuShortcut = ({ className, ...props }) => {
|
|
1083
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1084
|
+
className: cn("ml-auto text-xs tracking-widest opacity-60", className),
|
|
1085
|
+
...props
|
|
1086
|
+
});
|
|
1087
|
+
};
|
|
1088
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.10_@types+react-dom@19.2.3_@types+react@19.2.17__@types+rea_888699add025be5d8185ea2863550208/node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
1091
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [createPopperScope]);
|
|
1092
|
+
var usePopperScope = createPopperScope();
|
|
1093
|
+
var PROVIDER_NAME = "TooltipProvider";
|
|
1094
|
+
var DEFAULT_DELAY_DURATION = 700;
|
|
1095
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
|
1096
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
|
1097
|
+
var TooltipProvider$1 = (props) => {
|
|
1098
|
+
const { __scopeTooltip, delayDuration = DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
|
|
1099
|
+
const isOpenDelayedRef = React$1.useRef(true);
|
|
1100
|
+
const isPointerInTransitRef = React$1.useRef(false);
|
|
1101
|
+
const skipDelayTimerRef = React$1.useRef(0);
|
|
1102
|
+
React$1.useEffect(() => {
|
|
1103
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
1104
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
1105
|
+
}, []);
|
|
1106
|
+
return /* @__PURE__ */ jsx(TooltipProviderContextProvider, {
|
|
1107
|
+
scope: __scopeTooltip,
|
|
1108
|
+
isOpenDelayedRef,
|
|
1109
|
+
delayDuration,
|
|
1110
|
+
onOpen: React$1.useCallback(() => {
|
|
1111
|
+
if (skipDelayDuration <= 0) return;
|
|
1112
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
1113
|
+
isOpenDelayedRef.current = false;
|
|
1114
|
+
}, [skipDelayDuration]),
|
|
1115
|
+
onClose: React$1.useCallback(() => {
|
|
1116
|
+
if (skipDelayDuration <= 0) return;
|
|
1117
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
1118
|
+
skipDelayTimerRef.current = window.setTimeout(() => isOpenDelayedRef.current = true, skipDelayDuration);
|
|
1119
|
+
}, [skipDelayDuration]),
|
|
1120
|
+
isPointerInTransitRef,
|
|
1121
|
+
onPointerInTransitChange: React$1.useCallback((inTransit) => {
|
|
1122
|
+
isPointerInTransitRef.current = inTransit;
|
|
1123
|
+
}, []),
|
|
1124
|
+
disableHoverableContent,
|
|
1125
|
+
children
|
|
1126
|
+
});
|
|
1127
|
+
};
|
|
1128
|
+
TooltipProvider$1.displayName = PROVIDER_NAME;
|
|
1129
|
+
var TOOLTIP_NAME = "Tooltip";
|
|
1130
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
|
1131
|
+
var Tooltip$1 = (props) => {
|
|
1132
|
+
const { __scopeTooltip, children, open: openProp, defaultOpen, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
|
|
1133
|
+
const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
|
|
1134
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1135
|
+
const [trigger, setTrigger] = React$1.useState(null);
|
|
1136
|
+
const contentId = useId$1();
|
|
1137
|
+
const openTimerRef = React$1.useRef(0);
|
|
1138
|
+
const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
|
|
1139
|
+
const delayDuration = delayDurationProp ?? providerContext.delayDuration;
|
|
1140
|
+
const wasOpenDelayedRef = React$1.useRef(false);
|
|
1141
|
+
const [open, setOpen] = useControllableState({
|
|
1142
|
+
prop: openProp,
|
|
1143
|
+
defaultProp: defaultOpen ?? false,
|
|
1144
|
+
onChange: (open2) => {
|
|
1145
|
+
if (open2) {
|
|
1146
|
+
providerContext.onOpen();
|
|
1147
|
+
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
1148
|
+
} else providerContext.onClose();
|
|
1149
|
+
onOpenChange?.(open2);
|
|
1150
|
+
},
|
|
1151
|
+
caller: TOOLTIP_NAME
|
|
1152
|
+
});
|
|
1153
|
+
const stateAttribute = React$1.useMemo(() => {
|
|
1154
|
+
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
1155
|
+
}, [open]);
|
|
1156
|
+
const handleOpen = React$1.useCallback(() => {
|
|
1157
|
+
window.clearTimeout(openTimerRef.current);
|
|
1158
|
+
openTimerRef.current = 0;
|
|
1159
|
+
wasOpenDelayedRef.current = false;
|
|
1160
|
+
setOpen(true);
|
|
1161
|
+
}, [setOpen]);
|
|
1162
|
+
const handleClose = React$1.useCallback(() => {
|
|
1163
|
+
window.clearTimeout(openTimerRef.current);
|
|
1164
|
+
openTimerRef.current = 0;
|
|
1165
|
+
setOpen(false);
|
|
1166
|
+
}, [setOpen]);
|
|
1167
|
+
const handleDelayedOpen = React$1.useCallback(() => {
|
|
1168
|
+
window.clearTimeout(openTimerRef.current);
|
|
1169
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
1170
|
+
wasOpenDelayedRef.current = true;
|
|
1171
|
+
setOpen(true);
|
|
1172
|
+
openTimerRef.current = 0;
|
|
1173
|
+
}, delayDuration);
|
|
1174
|
+
}, [delayDuration, setOpen]);
|
|
1175
|
+
React$1.useEffect(() => {
|
|
1176
|
+
return () => {
|
|
1177
|
+
if (openTimerRef.current) {
|
|
1178
|
+
window.clearTimeout(openTimerRef.current);
|
|
1179
|
+
openTimerRef.current = 0;
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}, []);
|
|
1183
|
+
return /* @__PURE__ */ jsx(Root2$1, {
|
|
1184
|
+
...popperScope,
|
|
1185
|
+
children: /* @__PURE__ */ jsx(TooltipContextProvider, {
|
|
1186
|
+
scope: __scopeTooltip,
|
|
1187
|
+
contentId,
|
|
1188
|
+
open,
|
|
1189
|
+
stateAttribute,
|
|
1190
|
+
trigger,
|
|
1191
|
+
onTriggerChange: setTrigger,
|
|
1192
|
+
onTriggerEnter: React$1.useCallback(() => {
|
|
1193
|
+
if (providerContext.isOpenDelayedRef.current) handleDelayedOpen();
|
|
1194
|
+
else handleOpen();
|
|
1195
|
+
}, [
|
|
1196
|
+
providerContext.isOpenDelayedRef,
|
|
1197
|
+
handleDelayedOpen,
|
|
1198
|
+
handleOpen
|
|
1199
|
+
]),
|
|
1200
|
+
onTriggerLeave: React$1.useCallback(() => {
|
|
1201
|
+
if (disableHoverableContent) handleClose();
|
|
1202
|
+
else {
|
|
1203
|
+
window.clearTimeout(openTimerRef.current);
|
|
1204
|
+
openTimerRef.current = 0;
|
|
1205
|
+
}
|
|
1206
|
+
}, [handleClose, disableHoverableContent]),
|
|
1207
|
+
onOpen: handleOpen,
|
|
1208
|
+
onClose: handleClose,
|
|
1209
|
+
disableHoverableContent,
|
|
1210
|
+
children
|
|
1211
|
+
})
|
|
1212
|
+
});
|
|
1213
|
+
};
|
|
1214
|
+
Tooltip$1.displayName = TOOLTIP_NAME;
|
|
1215
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
|
1216
|
+
var TooltipTrigger$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
1217
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
1218
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
|
1219
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
|
1220
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1221
|
+
const composedRefs = useComposedRefs(forwardedRef, React$1.useRef(null), context.onTriggerChange);
|
|
1222
|
+
const isPointerDownRef = React$1.useRef(false);
|
|
1223
|
+
const hasPointerMoveOpenedRef = React$1.useRef(false);
|
|
1224
|
+
const handlePointerUp = React$1.useCallback(() => isPointerDownRef.current = false, []);
|
|
1225
|
+
React$1.useEffect(() => {
|
|
1226
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
1227
|
+
}, [handlePointerUp]);
|
|
1228
|
+
return /* @__PURE__ */ jsx(Anchor, {
|
|
1229
|
+
asChild: true,
|
|
1230
|
+
...popperScope,
|
|
1231
|
+
children: /* @__PURE__ */ jsx(Primitive.button, {
|
|
1232
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
1233
|
+
"data-state": context.stateAttribute,
|
|
1234
|
+
...triggerProps,
|
|
1235
|
+
ref: composedRefs,
|
|
1236
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
1237
|
+
if (event.pointerType === "touch") return;
|
|
1238
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
1239
|
+
context.onTriggerEnter();
|
|
1240
|
+
hasPointerMoveOpenedRef.current = true;
|
|
1241
|
+
}
|
|
1242
|
+
}),
|
|
1243
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
1244
|
+
context.onTriggerLeave();
|
|
1245
|
+
hasPointerMoveOpenedRef.current = false;
|
|
1246
|
+
}),
|
|
1247
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
1248
|
+
if (context.open) context.onClose();
|
|
1249
|
+
isPointerDownRef.current = true;
|
|
1250
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
|
1251
|
+
}),
|
|
1252
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
1253
|
+
if (!isPointerDownRef.current) context.onOpen();
|
|
1254
|
+
}),
|
|
1255
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
1256
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
1257
|
+
})
|
|
1258
|
+
});
|
|
1259
|
+
});
|
|
1260
|
+
TooltipTrigger$1.displayName = TRIGGER_NAME;
|
|
1261
|
+
var PORTAL_NAME = "TooltipPortal";
|
|
1262
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, { forceMount: void 0 });
|
|
1263
|
+
var TooltipPortal = (props) => {
|
|
1264
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
1265
|
+
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
|
|
1266
|
+
return /* @__PURE__ */ jsx(PortalProvider, {
|
|
1267
|
+
scope: __scopeTooltip,
|
|
1268
|
+
forceMount,
|
|
1269
|
+
children: /* @__PURE__ */ jsx(Presence, {
|
|
1270
|
+
present: forceMount || context.open,
|
|
1271
|
+
children: /* @__PURE__ */ jsx(Portal$2, {
|
|
1272
|
+
asChild: true,
|
|
1273
|
+
container,
|
|
1274
|
+
children
|
|
1275
|
+
})
|
|
1276
|
+
})
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
TooltipPortal.displayName = PORTAL_NAME;
|
|
1280
|
+
var CONTENT_NAME = "TooltipContent";
|
|
1281
|
+
var TooltipContent$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
1282
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1283
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
1284
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1285
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
1286
|
+
present: forceMount || context.open,
|
|
1287
|
+
children: context.disableHoverableContent ? /* @__PURE__ */ jsx(TooltipContentImpl, {
|
|
1288
|
+
side,
|
|
1289
|
+
...contentProps,
|
|
1290
|
+
ref: forwardedRef
|
|
1291
|
+
}) : /* @__PURE__ */ jsx(TooltipContentHoverable, {
|
|
1292
|
+
side,
|
|
1293
|
+
...contentProps,
|
|
1294
|
+
ref: forwardedRef
|
|
1295
|
+
})
|
|
1296
|
+
});
|
|
1297
|
+
});
|
|
1298
|
+
var TooltipContentHoverable = React$1.forwardRef((props, forwardedRef) => {
|
|
1299
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1300
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1301
|
+
const ref = React$1.useRef(null);
|
|
1302
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1303
|
+
const [pointerGraceArea, setPointerGraceArea] = React$1.useState(null);
|
|
1304
|
+
const { trigger, onClose } = context;
|
|
1305
|
+
const content = ref.current;
|
|
1306
|
+
const { onPointerInTransitChange } = providerContext;
|
|
1307
|
+
const handleRemoveGraceArea = React$1.useCallback(() => {
|
|
1308
|
+
setPointerGraceArea(null);
|
|
1309
|
+
onPointerInTransitChange(false);
|
|
1310
|
+
}, [onPointerInTransitChange]);
|
|
1311
|
+
const handleCreateGraceArea = React$1.useCallback((event, hoverTarget) => {
|
|
1312
|
+
const currentTarget = event.currentTarget;
|
|
1313
|
+
const exitPoint = {
|
|
1314
|
+
x: event.clientX,
|
|
1315
|
+
y: event.clientY
|
|
1316
|
+
};
|
|
1317
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect()));
|
|
1318
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
1319
|
+
setPointerGraceArea(getHull([...paddedExitPoints, ...hoverTargetPoints]));
|
|
1320
|
+
onPointerInTransitChange(true);
|
|
1321
|
+
}, [onPointerInTransitChange]);
|
|
1322
|
+
React$1.useEffect(() => {
|
|
1323
|
+
return () => handleRemoveGraceArea();
|
|
1324
|
+
}, [handleRemoveGraceArea]);
|
|
1325
|
+
React$1.useEffect(() => {
|
|
1326
|
+
if (trigger && content) {
|
|
1327
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
1328
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
1329
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
1330
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
1331
|
+
return () => {
|
|
1332
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
1333
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
}, [
|
|
1337
|
+
trigger,
|
|
1338
|
+
content,
|
|
1339
|
+
handleCreateGraceArea,
|
|
1340
|
+
handleRemoveGraceArea
|
|
1341
|
+
]);
|
|
1342
|
+
React$1.useEffect(() => {
|
|
1343
|
+
if (pointerGraceArea) {
|
|
1344
|
+
const handleTrackPointerGrace = (event) => {
|
|
1345
|
+
const target = event.target;
|
|
1346
|
+
const pointerPosition = {
|
|
1347
|
+
x: event.clientX,
|
|
1348
|
+
y: event.clientY
|
|
1349
|
+
};
|
|
1350
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
1351
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
1352
|
+
if (hasEnteredTarget) handleRemoveGraceArea();
|
|
1353
|
+
else if (isPointerOutsideGraceArea) {
|
|
1354
|
+
handleRemoveGraceArea();
|
|
1355
|
+
onClose();
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
1359
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
1360
|
+
}
|
|
1361
|
+
}, [
|
|
1362
|
+
trigger,
|
|
1363
|
+
content,
|
|
1364
|
+
pointerGraceArea,
|
|
1365
|
+
onClose,
|
|
1366
|
+
handleRemoveGraceArea
|
|
1367
|
+
]);
|
|
1368
|
+
return /* @__PURE__ */ jsx(TooltipContentImpl, {
|
|
1369
|
+
...props,
|
|
1370
|
+
ref: composedRefs
|
|
1371
|
+
});
|
|
1372
|
+
});
|
|
1373
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
|
1374
|
+
var Slottable = createSlottable("TooltipContent");
|
|
1375
|
+
var TooltipContentImpl = React$1.forwardRef((props, forwardedRef) => {
|
|
1376
|
+
const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
|
|
1377
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
|
1378
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1379
|
+
const { onClose } = context;
|
|
1380
|
+
React$1.useEffect(() => {
|
|
1381
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
1382
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
1383
|
+
}, [onClose]);
|
|
1384
|
+
React$1.useEffect(() => {
|
|
1385
|
+
if (context.trigger) {
|
|
1386
|
+
const handleScroll = (event) => {
|
|
1387
|
+
if (event.target instanceof Node && event.target.contains(context.trigger)) onClose();
|
|
1388
|
+
};
|
|
1389
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
1390
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
1391
|
+
}
|
|
1392
|
+
}, [context.trigger, onClose]);
|
|
1393
|
+
return /* @__PURE__ */ jsx(DismissableLayer, {
|
|
1394
|
+
asChild: true,
|
|
1395
|
+
disableOutsidePointerEvents: false,
|
|
1396
|
+
onEscapeKeyDown,
|
|
1397
|
+
onPointerDownOutside,
|
|
1398
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
1399
|
+
onDismiss: onClose,
|
|
1400
|
+
children: /* @__PURE__ */ jsxs(Content, {
|
|
1401
|
+
"data-state": context.stateAttribute,
|
|
1402
|
+
...popperScope,
|
|
1403
|
+
...contentProps,
|
|
1404
|
+
ref: forwardedRef,
|
|
1405
|
+
style: {
|
|
1406
|
+
...contentProps.style,
|
|
1407
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1408
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
1409
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
1410
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1411
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1412
|
+
},
|
|
1413
|
+
children: [/* @__PURE__ */ jsx(Slottable, { children }), /* @__PURE__ */ jsx(VisuallyHiddenContentContextProvider, {
|
|
1414
|
+
scope: __scopeTooltip,
|
|
1415
|
+
isInside: true,
|
|
1416
|
+
children: /* @__PURE__ */ jsx(Root$1, {
|
|
1417
|
+
id: context.contentId,
|
|
1418
|
+
role: "tooltip",
|
|
1419
|
+
children: ariaLabel || children
|
|
1420
|
+
})
|
|
1421
|
+
})]
|
|
1422
|
+
})
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
TooltipContent$1.displayName = CONTENT_NAME;
|
|
1426
|
+
var ARROW_NAME = "TooltipArrow";
|
|
1427
|
+
var TooltipArrow = React$1.forwardRef((props, forwardedRef) => {
|
|
1428
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
1429
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1430
|
+
return useVisuallyHiddenContentContext(ARROW_NAME, __scopeTooltip).isInside ? null : /* @__PURE__ */ jsx(Arrow, {
|
|
1431
|
+
...popperScope,
|
|
1432
|
+
...arrowProps,
|
|
1433
|
+
ref: forwardedRef
|
|
1434
|
+
});
|
|
1435
|
+
});
|
|
1436
|
+
TooltipArrow.displayName = ARROW_NAME;
|
|
1437
|
+
function getExitSideFromRect(point, rect) {
|
|
1438
|
+
const top = Math.abs(rect.top - point.y);
|
|
1439
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
1440
|
+
const right = Math.abs(rect.right - point.x);
|
|
1441
|
+
const left = Math.abs(rect.left - point.x);
|
|
1442
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
1443
|
+
case left: return "left";
|
|
1444
|
+
case right: return "right";
|
|
1445
|
+
case top: return "top";
|
|
1446
|
+
case bottom: return "bottom";
|
|
1447
|
+
default: throw new Error("unreachable");
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
1451
|
+
const paddedExitPoints = [];
|
|
1452
|
+
switch (exitSide) {
|
|
1453
|
+
case "top":
|
|
1454
|
+
paddedExitPoints.push({
|
|
1455
|
+
x: exitPoint.x - padding,
|
|
1456
|
+
y: exitPoint.y + padding
|
|
1457
|
+
}, {
|
|
1458
|
+
x: exitPoint.x + padding,
|
|
1459
|
+
y: exitPoint.y + padding
|
|
1460
|
+
});
|
|
1461
|
+
break;
|
|
1462
|
+
case "bottom":
|
|
1463
|
+
paddedExitPoints.push({
|
|
1464
|
+
x: exitPoint.x - padding,
|
|
1465
|
+
y: exitPoint.y - padding
|
|
1466
|
+
}, {
|
|
1467
|
+
x: exitPoint.x + padding,
|
|
1468
|
+
y: exitPoint.y - padding
|
|
1469
|
+
});
|
|
1470
|
+
break;
|
|
1471
|
+
case "left":
|
|
1472
|
+
paddedExitPoints.push({
|
|
1473
|
+
x: exitPoint.x + padding,
|
|
1474
|
+
y: exitPoint.y - padding
|
|
1475
|
+
}, {
|
|
1476
|
+
x: exitPoint.x + padding,
|
|
1477
|
+
y: exitPoint.y + padding
|
|
1478
|
+
});
|
|
1479
|
+
break;
|
|
1480
|
+
case "right":
|
|
1481
|
+
paddedExitPoints.push({
|
|
1482
|
+
x: exitPoint.x - padding,
|
|
1483
|
+
y: exitPoint.y - padding
|
|
1484
|
+
}, {
|
|
1485
|
+
x: exitPoint.x - padding,
|
|
1486
|
+
y: exitPoint.y + padding
|
|
1487
|
+
});
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
return paddedExitPoints;
|
|
1491
|
+
}
|
|
1492
|
+
function getPointsFromRect(rect) {
|
|
1493
|
+
const { top, right, bottom, left } = rect;
|
|
1494
|
+
return [
|
|
1495
|
+
{
|
|
1496
|
+
x: left,
|
|
1497
|
+
y: top
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
x: right,
|
|
1501
|
+
y: top
|
|
1502
|
+
},
|
|
1503
|
+
{
|
|
1504
|
+
x: right,
|
|
1505
|
+
y: bottom
|
|
1506
|
+
},
|
|
1507
|
+
{
|
|
1508
|
+
x: left,
|
|
1509
|
+
y: bottom
|
|
1510
|
+
}
|
|
1511
|
+
];
|
|
1512
|
+
}
|
|
1513
|
+
function isPointInPolygon(point, polygon) {
|
|
1514
|
+
const { x, y } = point;
|
|
1515
|
+
let inside = false;
|
|
1516
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1517
|
+
const ii = polygon[i];
|
|
1518
|
+
const jj = polygon[j];
|
|
1519
|
+
const xi = ii.x;
|
|
1520
|
+
const yi = ii.y;
|
|
1521
|
+
const xj = jj.x;
|
|
1522
|
+
const yj = jj.y;
|
|
1523
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) inside = !inside;
|
|
1524
|
+
}
|
|
1525
|
+
return inside;
|
|
1526
|
+
}
|
|
1527
|
+
function getHull(points) {
|
|
1528
|
+
const newPoints = points.slice();
|
|
1529
|
+
newPoints.sort((a, b) => {
|
|
1530
|
+
if (a.x < b.x) return -1;
|
|
1531
|
+
else if (a.x > b.x) return 1;
|
|
1532
|
+
else if (a.y < b.y) return -1;
|
|
1533
|
+
else if (a.y > b.y) return 1;
|
|
1534
|
+
else return 0;
|
|
1535
|
+
});
|
|
1536
|
+
return getHullPresorted(newPoints);
|
|
1537
|
+
}
|
|
1538
|
+
function getHullPresorted(points) {
|
|
1539
|
+
if (points.length <= 1) return points.slice();
|
|
1540
|
+
const upperHull = [];
|
|
1541
|
+
for (let i = 0; i < points.length; i++) {
|
|
1542
|
+
const p = points[i];
|
|
1543
|
+
while (upperHull.length >= 2) {
|
|
1544
|
+
const q = upperHull[upperHull.length - 1];
|
|
1545
|
+
const r = upperHull[upperHull.length - 2];
|
|
1546
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
1547
|
+
else break;
|
|
1548
|
+
}
|
|
1549
|
+
upperHull.push(p);
|
|
1550
|
+
}
|
|
1551
|
+
upperHull.pop();
|
|
1552
|
+
const lowerHull = [];
|
|
1553
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
1554
|
+
const p = points[i];
|
|
1555
|
+
while (lowerHull.length >= 2) {
|
|
1556
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
1557
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
1558
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
|
|
1559
|
+
else break;
|
|
1560
|
+
}
|
|
1561
|
+
lowerHull.push(p);
|
|
1562
|
+
}
|
|
1563
|
+
lowerHull.pop();
|
|
1564
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
|
|
1565
|
+
else return upperHull.concat(lowerHull);
|
|
1566
|
+
}
|
|
1567
|
+
var Provider = TooltipProvider$1;
|
|
1568
|
+
var Root3 = Tooltip$1;
|
|
1569
|
+
var Trigger = TooltipTrigger$1;
|
|
1570
|
+
var Portal = TooltipPortal;
|
|
1571
|
+
var Content2 = TooltipContent$1;
|
|
1572
|
+
var Arrow2 = TooltipArrow;
|
|
1573
|
+
//#endregion
|
|
1574
|
+
//#region ../ui/src/tooltip.tsx
|
|
1575
|
+
function TooltipProvider({ delayDuration = 0, ...props }) {
|
|
1576
|
+
return /* @__PURE__ */ jsx(Provider, {
|
|
1577
|
+
"data-slot": "tooltip-provider",
|
|
1578
|
+
delayDuration,
|
|
1579
|
+
...props
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
function Tooltip({ ...props }) {
|
|
1583
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(Root3, {
|
|
1584
|
+
"data-slot": "tooltip",
|
|
1585
|
+
...props
|
|
1586
|
+
}) });
|
|
1587
|
+
}
|
|
1588
|
+
function TooltipTrigger({ ...props }) {
|
|
1589
|
+
return /* @__PURE__ */ jsx(Trigger, {
|
|
1590
|
+
"data-slot": "tooltip-trigger",
|
|
1591
|
+
...props
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
function getSafePortalContainer(container) {
|
|
1595
|
+
if (typeof document === "undefined") return void 0;
|
|
1596
|
+
if (!container) return void 0;
|
|
1597
|
+
const ATTR = "data-portal-root";
|
|
1598
|
+
let target = container.querySelector(`[${ATTR}]`);
|
|
1599
|
+
if (!target) {
|
|
1600
|
+
target = document.createElement("div");
|
|
1601
|
+
target.setAttribute(ATTR, "");
|
|
1602
|
+
container.appendChild(target);
|
|
1603
|
+
}
|
|
1604
|
+
return target;
|
|
1605
|
+
}
|
|
1606
|
+
function TooltipContent({ className, sideOffset = 0, children, container, ...props }) {
|
|
1607
|
+
return /* @__PURE__ */ jsx(Portal, {
|
|
1608
|
+
...container ? { container: getSafePortalContainer(container) } : {},
|
|
1609
|
+
children: /* @__PURE__ */ jsxs(Content2, {
|
|
1610
|
+
"data-slot": "tooltip-content",
|
|
1611
|
+
sideOffset,
|
|
1612
|
+
className: cn("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className),
|
|
1613
|
+
...props,
|
|
1614
|
+
children: [children, /* @__PURE__ */ jsx(Arrow2, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })]
|
|
1615
|
+
})
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region ../blocks/src/system/data/readinessPresentation.ts
|
|
1620
|
+
/** Presentation-only wording; domain assessments and tests use closed reason codes. */
|
|
1621
|
+
const READINESS_REASON_COPY = {
|
|
1622
|
+
mailing_destination: "Pick where sign-ups go. Until you do, this signup stays hidden from visitors.",
|
|
1623
|
+
mailing_setup: "Pick where sign-ups go. Until you do, this signup stays hidden from visitors.",
|
|
1624
|
+
form_not_chosen: "Choose a form. Until you do, this block stays hidden from visitors.",
|
|
1625
|
+
form_deleted: "The form this block used has been deleted. Choose another one. Until you do, this block stays hidden from visitors.",
|
|
1626
|
+
testimonials_none: "Add a testimonial to show here. Until you do, this block stays hidden from visitors.",
|
|
1627
|
+
testimonials_unpublished: "Publish a testimonial to show it here. Until you do, this block stays hidden from visitors.",
|
|
1628
|
+
testimonials_empty: "There are no testimonials to show here yet. Until there are, this block stays hidden from visitors.",
|
|
1629
|
+
team_empty: "Add people to your team to show them here. Until you do, this block stays hidden from visitors.",
|
|
1630
|
+
members_empty: "Add someone to show here. Until you do, this block stays hidden from visitors.",
|
|
1631
|
+
product_not_chosen: "Choose a product. Until you do, this block stays hidden from visitors.",
|
|
1632
|
+
product_gone: "The product this block showed is no longer available. Choose another one. Until you do, this block stays hidden from visitors.",
|
|
1633
|
+
gallery_empty: "Add a photo. Until you do, this gallery stays hidden from visitors."
|
|
1634
|
+
};
|
|
1635
|
+
//#endregion
|
|
1636
|
+
//#region ../editor-blocks/src/block-form/debug.ts
|
|
1637
|
+
const noop = () => {};
|
|
1638
|
+
function bindConsoleMethod(method) {
|
|
1639
|
+
if (typeof console === "undefined") return noop;
|
|
1640
|
+
const candidate = console[method];
|
|
1641
|
+
if (candidate instanceof Function) return (...args) => {
|
|
1642
|
+
Reflect.apply(candidate, console, args);
|
|
1643
|
+
};
|
|
1644
|
+
const fallback = console.log;
|
|
1645
|
+
return typeof fallback === "function" ? (...args) => {
|
|
1646
|
+
Reflect.apply(fallback, console, args);
|
|
1647
|
+
} : noop;
|
|
1648
|
+
}
|
|
1649
|
+
function createBlockFormLogger(scope) {
|
|
1650
|
+
const prefix = `[block-form:${scope}]`;
|
|
1651
|
+
const debugFn = bindConsoleMethod("debug");
|
|
1652
|
+
const warnFn = bindConsoleMethod("warn");
|
|
1653
|
+
const errorFn = bindConsoleMethod("error");
|
|
1654
|
+
const infoFn = bindConsoleMethod("info");
|
|
1655
|
+
const wrap = (fn) => (...args) => fn(prefix, ...args);
|
|
1656
|
+
return {
|
|
1657
|
+
debug: wrap(debugFn),
|
|
1658
|
+
warn: wrap(warnFn),
|
|
1659
|
+
error: wrap(errorFn),
|
|
1660
|
+
info: wrap(infoFn)
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
//#endregion
|
|
1664
|
+
//#region ../editor-blocks/src/block-editor/sdkBlockMerger.ts
|
|
1665
|
+
const logger = createBlockFormLogger("customBlockRegistry");
|
|
1666
|
+
function mergeBlockDescriptors(systemBlocks, sdkConfig, dbCustomBlocks) {
|
|
1667
|
+
return mergeBlockDescriptorsWithRegistry(systemBlocks, createCustomBlockRegistry({
|
|
1668
|
+
sdkConfig,
|
|
1669
|
+
customBlocks: normalizeCustomBlockEntries(dbCustomBlocks),
|
|
1670
|
+
onConflict: (message) => logger.warn(message)
|
|
1671
|
+
}), (message) => logger.warn(message));
|
|
1672
|
+
}
|
|
1673
|
+
function getBlockManifestFromSdkConfig(blockKind, sdkConfig, dbCustomBlocks) {
|
|
1674
|
+
return createCustomBlockRegistry({
|
|
1675
|
+
sdkConfig,
|
|
1676
|
+
customBlocks: normalizeCustomBlockEntries(dbCustomBlocks),
|
|
1677
|
+
onConflict: (message) => logger.warn(message)
|
|
1678
|
+
}).findManifest(blockKind)?.manifest;
|
|
1679
|
+
}
|
|
1680
|
+
function normalizeCustomBlockEntries(customBlocks) {
|
|
1681
|
+
if (!customBlocks) return [];
|
|
1682
|
+
return customBlocks.map((entry) => {
|
|
1683
|
+
if ("manifest" in entry && "source" in entry) return entry;
|
|
1684
|
+
return {
|
|
1685
|
+
manifest: entry,
|
|
1686
|
+
source: { kind: "managed-database" }
|
|
1687
|
+
};
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
//#endregion
|
|
1691
|
+
//#region ../editor-blocks/src/block-editor/colourFieldVisibility.ts
|
|
1692
|
+
/** Only changes form presentation; the validation manifest and saved data stay intact. */
|
|
1693
|
+
function hideUnavailableColourFields(manifest, options) {
|
|
1694
|
+
if (options.colour && options.gradient) return manifest;
|
|
1695
|
+
const hiddenPaths = [];
|
|
1696
|
+
const visit = (fields, parent) => fields.flatMap((field) => {
|
|
1697
|
+
const path = parent ? `${parent}.${field.id}` : field.id;
|
|
1698
|
+
const widget = field.ui?.widget;
|
|
1699
|
+
if (widget === "backgroundColor" && !options.colour || widget === "backgroundGradient" && !options.gradient) {
|
|
1700
|
+
hiddenPaths.push(path);
|
|
1701
|
+
return [];
|
|
1702
|
+
}
|
|
1703
|
+
if (field.type === "group" || field.type === "modal") {
|
|
1704
|
+
const children = visit(field.schema.fields, path);
|
|
1705
|
+
if (!children.length) {
|
|
1706
|
+
hiddenPaths.push(path);
|
|
1707
|
+
return [];
|
|
1708
|
+
}
|
|
1709
|
+
return [{
|
|
1710
|
+
...field,
|
|
1711
|
+
schema: {
|
|
1712
|
+
...field.schema,
|
|
1713
|
+
fields: children
|
|
1714
|
+
}
|
|
1715
|
+
}];
|
|
1716
|
+
}
|
|
1717
|
+
if (field.type === "repeater") return [{
|
|
1718
|
+
...field,
|
|
1719
|
+
...field.schema ? { schema: {
|
|
1720
|
+
...field.schema,
|
|
1721
|
+
fields: visit(field.schema.fields, path)
|
|
1722
|
+
} } : {},
|
|
1723
|
+
...field.itemTypes ? { itemTypes: Object.fromEntries(Object.entries(field.itemTypes).map(([id, item]) => [id, {
|
|
1724
|
+
...item,
|
|
1725
|
+
fields: visit(item.fields, path)
|
|
1726
|
+
}])) } : {}
|
|
1727
|
+
}];
|
|
1728
|
+
if (field.type === "tabGroup") {
|
|
1729
|
+
const tabs = field.tabs.flatMap((tab) => {
|
|
1730
|
+
const children = visit(tab.fields, path);
|
|
1731
|
+
const unavailableTab = tab.sdkSectionOption === "backgroundColor" && !options.colour || tab.sdkSectionOption === "backgroundGradient" && !options.gradient;
|
|
1732
|
+
return children.length && !unavailableTab ? [{
|
|
1733
|
+
...tab,
|
|
1734
|
+
fields: children
|
|
1735
|
+
}] : [];
|
|
1736
|
+
});
|
|
1737
|
+
if (!tabs.length) {
|
|
1738
|
+
hiddenPaths.push(path);
|
|
1739
|
+
return [];
|
|
1740
|
+
}
|
|
1741
|
+
return [{
|
|
1742
|
+
...field,
|
|
1743
|
+
tabs
|
|
1744
|
+
}];
|
|
1745
|
+
}
|
|
1746
|
+
return [field];
|
|
1747
|
+
});
|
|
1748
|
+
const fields = visit(manifest.fields, "");
|
|
1749
|
+
return {
|
|
1750
|
+
...manifest,
|
|
1751
|
+
fields,
|
|
1752
|
+
promotedFields: manifest.promotedFields?.filter((path) => !hiddenPaths.some((hidden) => path === hidden || path.startsWith(`${hidden}.`)))
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
//#endregion
|
|
1756
|
+
//#region ../block-form/src/manifest/mergeManifestWithSdkOptions.ts
|
|
1757
|
+
/**
|
|
1758
|
+
* Merges SDK-provided field options AND field extensions into a block manifest.
|
|
1759
|
+
*
|
|
1760
|
+
* This creates a single source of truth for validation and rendering:
|
|
1761
|
+
* 1. Field options: Replaces select options for fields with `ui.widget: 'sdkSelect'`
|
|
1762
|
+
* 2. Field extensions: Appends additional fields to the end of the manifest
|
|
1763
|
+
*
|
|
1764
|
+
* Without this merge, the Zod validation schema is built from manifest's
|
|
1765
|
+
* hardcoded options, but SdkSelectField renders SDK options - causing
|
|
1766
|
+
* validation errors when users select SDK-provided values.
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* // Field options: Embed block manifest has options [list, grid, carousel]
|
|
1770
|
+
* // SDK config provides options [showcase, list]
|
|
1771
|
+
* // After merge, manifest.fields[layoutField].options = [showcase, list]
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* // Field extensions: Body text block has [body] field
|
|
1775
|
+
* // SDK config extends with [layout] field
|
|
1776
|
+
* // After merge, manifest.fields = [body, layout]
|
|
1777
|
+
*/
|
|
1778
|
+
function mergeManifestWithSdkOptions(manifest, blockKind, sdkBlockFieldOptions, sdkBlockFieldExtensions) {
|
|
1779
|
+
const blockOptions = sdkBlockFieldOptions?.[blockKind];
|
|
1780
|
+
return mergeFieldExtension(blockOptions ? {
|
|
1781
|
+
...manifest,
|
|
1782
|
+
fields: manifest.fields.map((field) => mergeFieldWithSdkOptions(field, blockOptions))
|
|
1783
|
+
} : manifest, sdkBlockFieldExtensions?.[blockKind]);
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Recursively merges SDK options into a single field.
|
|
1787
|
+
* Handles nested fields in groups, repeaters, modals, and tab groups.
|
|
1788
|
+
*/
|
|
1789
|
+
function mergeFieldWithSdkOptions(field, blockOptions) {
|
|
1790
|
+
if (field.type === "select") return mergeSelectField(field, blockOptions);
|
|
1791
|
+
if (field.type === "group" && field.schema?.fields) return {
|
|
1792
|
+
...field,
|
|
1793
|
+
schema: { fields: field.schema.fields.map((f) => mergeFieldWithSdkOptions(f, blockOptions)) }
|
|
1794
|
+
};
|
|
1795
|
+
if (field.type === "modal" && field.schema?.fields) return {
|
|
1796
|
+
...field,
|
|
1797
|
+
schema: { fields: field.schema.fields.map((f) => mergeFieldWithSdkOptions(f, blockOptions)) }
|
|
1798
|
+
};
|
|
1799
|
+
if (field.type === "repeater") {
|
|
1800
|
+
if (field.schema?.fields) return {
|
|
1801
|
+
...field,
|
|
1802
|
+
schema: { fields: field.schema.fields.map((f) => mergeFieldWithSdkOptions(f, blockOptions)) }
|
|
1803
|
+
};
|
|
1804
|
+
if (field.itemTypes) {
|
|
1805
|
+
const mergedItemTypes = Object.fromEntries(Object.entries(field.itemTypes).map(([key, itemType]) => [key, {
|
|
1806
|
+
...itemType,
|
|
1807
|
+
fields: itemType.fields.map((f) => mergeFieldWithSdkOptions(f, blockOptions))
|
|
1808
|
+
}]));
|
|
1809
|
+
return {
|
|
1810
|
+
...field,
|
|
1811
|
+
itemTypes: mergedItemTypes
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
if (field.type === "tabGroup" && field.tabs) return {
|
|
1816
|
+
...field,
|
|
1817
|
+
tabs: field.tabs.map((tab) => ({
|
|
1818
|
+
...tab,
|
|
1819
|
+
fields: tab.fields.map((f) => mergeFieldWithSdkOptions(f, blockOptions))
|
|
1820
|
+
}))
|
|
1821
|
+
};
|
|
1822
|
+
return field;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Merges SDK options into a select field if it uses the sdkSelect widget.
|
|
1826
|
+
* Returns the original field unchanged if it doesn't use sdkSelect or has no SDK options.
|
|
1827
|
+
*/
|
|
1828
|
+
function mergeSelectField(field, blockOptions) {
|
|
1829
|
+
if (field.ui?.widget !== "sdkSelect") return field;
|
|
1830
|
+
const sdkFieldConfig = blockOptions[field.id];
|
|
1831
|
+
if (!sdkFieldConfig?.options?.length) return field;
|
|
1832
|
+
return {
|
|
1833
|
+
...field,
|
|
1834
|
+
options: sdkFieldConfig.options
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
function mergeFieldExtension(manifest, extension) {
|
|
1838
|
+
if (!extension || !extension.fields.length && !extension.lookField && !extension.promotedFields?.length) return manifest;
|
|
1839
|
+
return {
|
|
1840
|
+
...manifest,
|
|
1841
|
+
fields: [...manifest.fields, ...extension.fields],
|
|
1842
|
+
lookField: extension.lookField ?? manifest.lookField,
|
|
1843
|
+
promotedFields: [...manifest.promotedFields ?? [], ...extension.promotedFields ?? []]
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
//#endregion
|
|
1847
|
+
//#region ../editor-blocks/src/block-editor/settingsIntent.ts
|
|
1848
|
+
function isThemeV2NormalEditorRawStyleField(field) {
|
|
1849
|
+
return isThemeV2NormalEditorRawStyleFieldName(field.id);
|
|
1850
|
+
}
|
|
1851
|
+
function filterThemeV2NormalEditorRawPromotedFields(promotedFields, allowedFieldPaths = void 0) {
|
|
1852
|
+
if (!promotedFields) return void 0;
|
|
1853
|
+
const allowedFieldPathSet = new Set(allowedFieldPaths ?? []);
|
|
1854
|
+
const filtered = promotedFields.filter((fieldPath) => !isThemeV2NormalEditorRawStylePath(fieldPath) || allowedFieldPathSet.has(fieldPath));
|
|
1855
|
+
return filtered.length > 0 ? filtered : void 0;
|
|
1856
|
+
}
|
|
1857
|
+
function hideThemeV2NormalEditorRawStyleFieldsInRenderFields(fields) {
|
|
1858
|
+
return fields.map((field) => {
|
|
1859
|
+
if (!isThemeV2NormalEditorRawStyleField(field)) return field;
|
|
1860
|
+
return {
|
|
1861
|
+
...field,
|
|
1862
|
+
ui: {
|
|
1863
|
+
...field.ui ?? {},
|
|
1864
|
+
hidden: true
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
//#endregion
|
|
1870
|
+
//#region ../editor-blocks/src/block-editor/preparedManifest.ts
|
|
1871
|
+
const showRawStyleFields = { kind: "show-raw-style-fields" };
|
|
1872
|
+
const hideThemeV2RawStyleFields = { kind: "hide-theme-v2-raw-style-fields" };
|
|
1873
|
+
const EDITOR_OWNED_FEATURE_CARD_FIELD_IDS = /* @__PURE__ */ new Set(["_generatedIconSizePx"]);
|
|
1874
|
+
function hideEditorOwnedFields(manifest, blockKind) {
|
|
1875
|
+
if (blockKind !== "block.feature-cards") return manifest;
|
|
1876
|
+
return {
|
|
1877
|
+
...manifest,
|
|
1878
|
+
fields: manifest.fields?.map((field) => EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(field.id) ? {
|
|
1879
|
+
...field,
|
|
1880
|
+
ui: {
|
|
1881
|
+
...field.ui ?? {},
|
|
1882
|
+
hidden: true
|
|
1883
|
+
}
|
|
1884
|
+
} : field),
|
|
1885
|
+
promotedFields: manifest.promotedFields?.filter((fieldPath) => !EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(fieldPath))
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
function prepareBlockEditorManifest(input) {
|
|
1889
|
+
const mergedManifest = mergeManifestWithSdkOptions(input.manifest, input.blockKind, input.blockFieldOptions, input.blockFieldExtensions);
|
|
1890
|
+
const validationManifest = augmentManifestWithStyleGroups(mergedManifest, input.theme?.styleGroups, input.blockKind);
|
|
1891
|
+
const renderManifest = editorRenderManifest(input, mergedManifest, validationManifest);
|
|
1892
|
+
return {
|
|
1893
|
+
validationManifest,
|
|
1894
|
+
renderManifest: noteFieldsNotShown(hideCalendarGroupingField(hideEditorOwnedFields(input.colourFieldOptions ? hideUnavailableColourFields(renderManifest, input.colourFieldOptions) : renderManifest, input.blockKind), input.theme?.siteStyleId), input.notShownFieldIds ?? [])
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
const lookNotShownNote = "Not shown in this Look.";
|
|
1898
|
+
/** Content the Look leaves out stays editable, with the note in place of its description. */
|
|
1899
|
+
function noteFieldsNotShown(manifest, fieldIds) {
|
|
1900
|
+
if (fieldIds.length === 0) return manifest;
|
|
1901
|
+
return {
|
|
1902
|
+
...manifest,
|
|
1903
|
+
fields: manifest.fields.map((field) => fieldIds.includes(field.id) ? {
|
|
1904
|
+
...field,
|
|
1905
|
+
description: lookNotShownNote
|
|
1906
|
+
} : field)
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
/** Preserve validation/stored intent while limiting weekly presentation, and its unpaged list, to arrangement styles. */
|
|
1910
|
+
function hideCalendarGroupingField(manifest, siteStyleId) {
|
|
1911
|
+
if (manifest.name !== "block.event-calendar") return manifest;
|
|
1912
|
+
if (eventCalendarListGroupingDecision({
|
|
1913
|
+
arrangementLooks: (siteStyleId ? getCuratedSiteStyle(asSiteStyleId(siteStyleId)) : void 0)?.looks.kind === "offers",
|
|
1914
|
+
variant: "list"
|
|
1915
|
+
}).available) return manifest;
|
|
1916
|
+
const upcomingPaging = new Map(eventCalendarPagingFields(false).map((field) => [field.id, field]));
|
|
1917
|
+
return {
|
|
1918
|
+
...manifest,
|
|
1919
|
+
fields: manifest.fields.map((field) => field.id === "listBy" ? {
|
|
1920
|
+
...field,
|
|
1921
|
+
ui: {
|
|
1922
|
+
...field.ui,
|
|
1923
|
+
hidden: true
|
|
1924
|
+
}
|
|
1925
|
+
} : upcomingPaging.get(field.id) ?? field),
|
|
1926
|
+
promotedFields: manifest.promotedFields?.filter((path) => path !== "listBy")
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
/** Form presentation uses the merged manifest; synthetic style groups remain validation-only. */
|
|
1930
|
+
function editorRenderManifest(input, merged, validation) {
|
|
1931
|
+
if (input.visibilityPolicy.kind !== "hide-theme-v2-raw-style-fields") return validation;
|
|
1932
|
+
return {
|
|
1933
|
+
...merged,
|
|
1934
|
+
fields: hideThemeV2NormalEditorRawStyleFieldsInRenderFields(merged.fields),
|
|
1935
|
+
promotedFields: filterThemeV2NormalEditorRawPromotedFields(merged.promotedFields, input.allowedPromotedFieldPaths)
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
//#endregion
|
|
1939
|
+
//#region ../editor-blocks/src/block-editor/blockFieldSectionContext.ts
|
|
1940
|
+
/**
|
|
1941
|
+
* Fields kept out of the block form on a newer style: the arrangement and its
|
|
1942
|
+
* knobs, which the Look section edits, and, once a Look resolves, the
|
|
1943
|
+
* presentation it owns. The field ownership decision says which those are.
|
|
1944
|
+
*/
|
|
1945
|
+
function arrangementOwnedFieldIds(block) {
|
|
1946
|
+
if (!block?.arrangementLookSelection) return [];
|
|
1947
|
+
const manifest = getBlockDefinition(block.blockKind)?.manifest;
|
|
1948
|
+
if (!manifest) return [];
|
|
1949
|
+
const ownership = resolveFieldOwnership({
|
|
1950
|
+
blockKind: block.blockKind,
|
|
1951
|
+
manifest,
|
|
1952
|
+
arrangementLook: true
|
|
1953
|
+
});
|
|
1954
|
+
const owners = arrangementVisibilityValues(block) ? [
|
|
1955
|
+
"knob",
|
|
1956
|
+
"arrangement",
|
|
1957
|
+
"look"
|
|
1958
|
+
] : ["knob", "arrangement"];
|
|
1959
|
+
const modeField = manifest.variantMeaning?.kind === "mode" ? ["variant"] : [];
|
|
1960
|
+
return [...fieldPathsOwnedBy(ownership, owners), ...modeField];
|
|
1961
|
+
}
|
|
1962
|
+
/** Content fields the block's current Look leaves out; the form keeps them, with a note. */
|
|
1963
|
+
function lookNotShownFieldIds(block) {
|
|
1964
|
+
const arrangement = arrangementVisibilityValues(block)?.arrangement ?? null;
|
|
1965
|
+
return block ? fieldsNotShownIn(block.blockKind, arrangement) : [];
|
|
1966
|
+
}
|
|
1967
|
+
function arrangementLookResolution(block) {
|
|
1968
|
+
const selection = block.arrangementLookSelection;
|
|
1969
|
+
return selection ? resolveEditorArrangementLook(selection, arrangementBlockMode(block), block.look.kind === "user-pinned" ? block.look.value : null) : null;
|
|
1970
|
+
}
|
|
1971
|
+
function arrangementBlockMode(block) {
|
|
1972
|
+
const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
|
|
1973
|
+
return meaning?.kind === "mode" ? readStoredMode({
|
|
1974
|
+
keys: [],
|
|
1975
|
+
defaultKey: null,
|
|
1976
|
+
variantMeaning: meaning
|
|
1977
|
+
}, { variant: block.layoutChoice.effectiveValue }) : null;
|
|
1978
|
+
}
|
|
1979
|
+
function arrangementVisibilityValues(block) {
|
|
1980
|
+
if (!block) return null;
|
|
1981
|
+
const resolved = arrangementLookResolution(block);
|
|
1982
|
+
if (!resolved || resolved.kind === "none" || resolved.kind === "recipe") return null;
|
|
1983
|
+
const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
|
|
1984
|
+
const arrangementField = meaning?.kind === "mode" ? meaning.arrangementField : "variant";
|
|
1985
|
+
const arrangement = resolved.look.structure.byMode[arrangementBlockMode(block) ?? "default"];
|
|
1986
|
+
return arrangement ? {
|
|
1987
|
+
lookId: resolved.look.id,
|
|
1988
|
+
arrangementField,
|
|
1989
|
+
arrangement
|
|
1990
|
+
} : null;
|
|
1991
|
+
}
|
|
1992
|
+
/** Legacy Look knobs keep their ordinary manifest fields in Look, without a second widget inventory. */
|
|
1993
|
+
function blockLookOwnedFieldPaths(block) {
|
|
1994
|
+
if (!block || block.arrangementLookSelection) return [];
|
|
1995
|
+
return systemCustomizeFacetDefinitionsForBlock(block.blockKind).filter((facet) => systemCustomizeFacetAppliesToLayoutVariant(facet, block.layoutChoice.effectiveValue ?? null)).map((facet) => facet.target.kind === "content-field" ? facet.target.field : "listLayout");
|
|
1996
|
+
}
|
|
1997
|
+
//#endregion
|
|
1998
|
+
//#region ../block-form/src/sdk-config/SdkConfigContext.tsx
|
|
1999
|
+
const SdkConfigContext = createContext(null);
|
|
2000
|
+
function SdkConfigProvider({ sdkConfig, children }) {
|
|
2001
|
+
const value = useMemo(() => {
|
|
2002
|
+
const config = sdkConfig ?? null;
|
|
2003
|
+
return {
|
|
2004
|
+
sdkConfig: config,
|
|
2005
|
+
sectionBackgrounds: config?.styles?.sectionBackgrounds ?? null,
|
|
2006
|
+
sectionOptions: config?.styles?.sectionOptions ?? null,
|
|
2007
|
+
themePalette: config?.theme?.palette ?? null,
|
|
2008
|
+
customBlocks: config?.customBlocks ?? null,
|
|
2009
|
+
blockFieldOptions: config?.blockFieldOptions ?? null,
|
|
2010
|
+
blockFieldExtensions: config?.blockFieldExtensions ?? null,
|
|
2011
|
+
isSdkSite: Boolean(config?.styles || config?.customBlocks || config?.blockFieldOptions || config?.blockFieldExtensions)
|
|
2012
|
+
};
|
|
2013
|
+
}, [sdkConfig]);
|
|
2014
|
+
return /* @__PURE__ */ jsx(SdkConfigContext.Provider, {
|
|
2015
|
+
value,
|
|
2016
|
+
children
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
function useSdkConfig() {
|
|
2020
|
+
const ctx = useContext(SdkConfigContext);
|
|
2021
|
+
if (!ctx) return {
|
|
2022
|
+
sdkConfig: null,
|
|
2023
|
+
sectionBackgrounds: null,
|
|
2024
|
+
sectionOptions: null,
|
|
2025
|
+
themePalette: null,
|
|
2026
|
+
customBlocks: null,
|
|
2027
|
+
blockFieldOptions: null,
|
|
2028
|
+
blockFieldExtensions: null,
|
|
2029
|
+
isSdkSite: false
|
|
2030
|
+
};
|
|
2031
|
+
return ctx;
|
|
2032
|
+
}
|
|
2033
|
+
//#endregion
|
|
2034
|
+
//#region ../block-form/src/backend/fieldObservation.ts
|
|
2035
|
+
function sameFieldError(left, right) {
|
|
2036
|
+
return left?.message === right?.message && left?.type === right?.type;
|
|
2037
|
+
}
|
|
2038
|
+
function sameFieldState(left, right) {
|
|
2039
|
+
return sameFieldError(left.error, right.error) && left.isDirty === right.isDirty && left.isTouched === right.isTouched && left.invalid === right.invalid;
|
|
2040
|
+
}
|
|
2041
|
+
/** A backend owns stable field snapshots; hooks only subscribe to the field they consume. */
|
|
2042
|
+
function createFieldObservation(read, subscribe, captureValue) {
|
|
2043
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
2044
|
+
const getFieldSnapshot = (path) => {
|
|
2045
|
+
const previous = snapshots.get(path);
|
|
2046
|
+
const readSnapshot = read(path);
|
|
2047
|
+
const value = captureValue(readSnapshot.value, previous?.value);
|
|
2048
|
+
if (previous && Object.is(previous.value, value) && sameFieldState(previous, readSnapshot)) return previous;
|
|
2049
|
+
const next = {
|
|
2050
|
+
...readSnapshot,
|
|
2051
|
+
value,
|
|
2052
|
+
error: sameFieldError(previous?.error, readSnapshot.error) ? previous?.error : readSnapshot.error
|
|
2053
|
+
};
|
|
2054
|
+
snapshots.set(path, next);
|
|
2055
|
+
return next;
|
|
2056
|
+
};
|
|
2057
|
+
return {
|
|
2058
|
+
getFieldSnapshot,
|
|
2059
|
+
subscribe: (callback, path) => {
|
|
2060
|
+
if (path === void 0) return subscribe(callback);
|
|
2061
|
+
const current = { snapshot: getFieldSnapshot(path) };
|
|
2062
|
+
return subscribe(() => {
|
|
2063
|
+
const next = getFieldSnapshot(path);
|
|
2064
|
+
if (next === current.snapshot) return;
|
|
2065
|
+
current.snapshot = next;
|
|
2066
|
+
callback();
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region ../block-form/src/utils/typeGuards.ts
|
|
2073
|
+
function isRecord(value) {
|
|
2074
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2075
|
+
}
|
|
2076
|
+
function isObjectRecord(value) {
|
|
2077
|
+
return typeof value === "object" && value !== null;
|
|
2078
|
+
}
|
|
2079
|
+
//#endregion
|
|
2080
|
+
//#region ../block-form/src/backend/store-backend.ts
|
|
2081
|
+
/**
|
|
2082
|
+
* Zustand Store backend implementation
|
|
2083
|
+
*
|
|
2084
|
+
* Integrates with EditorUiStore for autosave-enabled form management.
|
|
2085
|
+
* Supports blocks (per-block data), metadata, content, and linkedContent (embedded entry data).
|
|
2086
|
+
*/
|
|
2087
|
+
const EMPTY_SCOPE_VALUES = Object.freeze({});
|
|
2088
|
+
function isSnapshotDirty(snapshot) {
|
|
2089
|
+
return snapshot ? syncStateOf(snapshot.sync).kind === "pending" : false;
|
|
2090
|
+
}
|
|
2091
|
+
function isUnknownArray(value) {
|
|
2092
|
+
return Array.isArray(value);
|
|
2093
|
+
}
|
|
2094
|
+
function toUnknownArray(value) {
|
|
2095
|
+
return isUnknownArray(value) ? [...value] : [];
|
|
2096
|
+
}
|
|
2097
|
+
function requireBlockId(scope, blockId) {
|
|
2098
|
+
if (scope !== "blocks") throw new Error("[createStoreBackend] blockId requested for non-block scope");
|
|
2099
|
+
if (!blockId) throw new Error("[createStoreBackend] blockId required for scope=\"blocks\"");
|
|
2100
|
+
return blockId;
|
|
2101
|
+
}
|
|
2102
|
+
function filterVisibleBlockIssues(validation, blockId, issues) {
|
|
2103
|
+
if (!validation || shouldRevealAllBlockFieldValidation(validation.getBlockSaveability(blockId))) return issues;
|
|
2104
|
+
return issues.filter((issue) => validation.isPathEdited(blockId, issue.path.join(".")));
|
|
2105
|
+
}
|
|
2106
|
+
/** A read falls back to the read-only context for a top-level key the values don't hold. */
|
|
2107
|
+
function readsContext(context, values, path) {
|
|
2108
|
+
return context !== void 0 && path in context && !(values && path in values);
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Generate a unique ID that works in all environments.
|
|
2112
|
+
* Falls back to timestamp-based UUID if crypto.randomUUID is unavailable.
|
|
2113
|
+
*/
|
|
2114
|
+
function generateId() {
|
|
2115
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) return crypto.randomUUID();
|
|
2116
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Create Store backend from Zustand store
|
|
2120
|
+
*
|
|
2121
|
+
* Integrates with editorUiStore for autosave and validation
|
|
2122
|
+
*/
|
|
2123
|
+
function createStoreBackend(options) {
|
|
2124
|
+
const { scope, store, blockId, validateFn, context } = options;
|
|
2125
|
+
const getStoreState = () => store.getState();
|
|
2126
|
+
const getBlocksSlice = () => {
|
|
2127
|
+
if (!blockId) throw new Error("[createStoreBackend] blockId required for scope=\"blocks\"");
|
|
2128
|
+
const drafts = getStoreState().drafts;
|
|
2129
|
+
if (!drafts) throw new Error("[createStoreBackend] store state missing drafts slice");
|
|
2130
|
+
return drafts;
|
|
2131
|
+
};
|
|
2132
|
+
const getRootSlice = () => {
|
|
2133
|
+
const state = getStoreState();
|
|
2134
|
+
if (scope === "metadata") {
|
|
2135
|
+
if (!state.metadata) throw new Error("[createStoreBackend] store state missing metadata slice");
|
|
2136
|
+
return state.metadata;
|
|
2137
|
+
}
|
|
2138
|
+
if (scope === "content") {
|
|
2139
|
+
if (!state.content) throw new Error("[createStoreBackend] store state missing content slice");
|
|
2140
|
+
return state.content;
|
|
2141
|
+
}
|
|
2142
|
+
if (scope === "linkedContent") {
|
|
2143
|
+
if (!state.linkedEntries) throw new Error("[createStoreBackend] store state missing linkedEntries slice");
|
|
2144
|
+
return state.linkedEntries;
|
|
2145
|
+
}
|
|
2146
|
+
throw new Error("[createStoreBackend] root slice requested for scope=\"blocks\"");
|
|
2147
|
+
};
|
|
2148
|
+
const getScopeKey = () => {
|
|
2149
|
+
if (scope === "blocks") {
|
|
2150
|
+
if (!blockId) throw new Error("[createStoreBackend] blockId required for scope=\"blocks\"");
|
|
2151
|
+
return `block-${blockId}`;
|
|
2152
|
+
}
|
|
2153
|
+
if (scope === "linkedContent") {
|
|
2154
|
+
const entryId = getStoreState().linkedEntries?.getSelectedEntryId?.();
|
|
2155
|
+
return entryId ? `linked-content-${entryId}` : "linked-content";
|
|
2156
|
+
}
|
|
2157
|
+
return scope;
|
|
2158
|
+
};
|
|
2159
|
+
const getBlockId = () => requireBlockId(scope, blockId);
|
|
2160
|
+
const getBlockValidation = () => getStoreState().blockValidation;
|
|
2161
|
+
const getCurrentScopeValues = () => {
|
|
2162
|
+
if (scope === "blocks") return getBlocksSlice().getCurrentValues(getBlockId()) ?? EMPTY_SCOPE_VALUES;
|
|
2163
|
+
return getRootSlice().getCurrentValues() ?? EMPTY_SCOPE_VALUES;
|
|
2164
|
+
};
|
|
2165
|
+
const validationCache = { current: null };
|
|
2166
|
+
const getValidationIssues = () => {
|
|
2167
|
+
if (scope === "blocks") return getBlockValidation()?.getBlockSaveability(getBlockId()).issues ?? [];
|
|
2168
|
+
const values = getCurrentScopeValues();
|
|
2169
|
+
if (validationCache.current?.values === values) return validationCache.current.issues;
|
|
2170
|
+
const issues = validateFn ? validateFn(values) : [];
|
|
2171
|
+
validationCache.current = {
|
|
2172
|
+
values,
|
|
2173
|
+
issues
|
|
2174
|
+
};
|
|
2175
|
+
return issues;
|
|
2176
|
+
};
|
|
2177
|
+
const issueIndexes = /* @__PURE__ */ new WeakMap();
|
|
2178
|
+
const fieldIssueAt = (path) => {
|
|
2179
|
+
const issues = getValidationIssues();
|
|
2180
|
+
const index = issueIndexes.get(issues) ?? new Map([...issues].reverse().map((issue) => [issue.path.join("."), issue]));
|
|
2181
|
+
issueIndexes.set(issues, index);
|
|
2182
|
+
return index.get(path);
|
|
2183
|
+
};
|
|
2184
|
+
const getVisibleValidationIssues = () => {
|
|
2185
|
+
const issues = getValidationIssues();
|
|
2186
|
+
if (scope !== "blocks") return issues;
|
|
2187
|
+
const currentBlockId = getBlockId();
|
|
2188
|
+
return filterVisibleBlockIssues(getBlockValidation(), currentBlockId, issues);
|
|
2189
|
+
};
|
|
2190
|
+
const backend = {
|
|
2191
|
+
type: "store",
|
|
2192
|
+
store,
|
|
2193
|
+
scope,
|
|
2194
|
+
blockId,
|
|
2195
|
+
getValue: (path) => {
|
|
2196
|
+
if (scope === "blocks") return getBlocksSlice().getAtPath(getBlockId(), path);
|
|
2197
|
+
return readsContext(context, getRootSlice().getCurrentValues(), path) ? context[path] : getRootSlice().getAtPath(path);
|
|
2198
|
+
},
|
|
2199
|
+
deriveValue: (input) => {
|
|
2200
|
+
if (scope === "blocks") return getBlocksSlice().setDerivedAtPath(getBlockId(), input);
|
|
2201
|
+
getRootSlice().setDerivedAtPath(input);
|
|
2202
|
+
},
|
|
2203
|
+
setValue: (path, value, options) => {
|
|
2204
|
+
const previousValue = scope === "blocks" ? getBlocksSlice().getAtPath(getBlockId(), path) : getRootSlice().getAtPath(path);
|
|
2205
|
+
if (scope === "blocks") {
|
|
2206
|
+
getBlocksSlice().setAtPath(getBlockId(), path, value);
|
|
2207
|
+
if (!deepEqual(previousValue, value)) {
|
|
2208
|
+
getBlockValidation()?.markPathEdited(getBlockId(), path);
|
|
2209
|
+
if (options?.editedPath && options.editedPath !== path) getBlockValidation()?.markPathEdited(getBlockId(), options.editedPath);
|
|
2210
|
+
}
|
|
2211
|
+
} else getRootSlice().setAtPath(path, value);
|
|
2212
|
+
},
|
|
2213
|
+
setValues: (values, options) => {
|
|
2214
|
+
if (scope === "blocks") {
|
|
2215
|
+
const edit = getBlocksSlice().edit;
|
|
2216
|
+
if (!edit) throw new Error("Block backend requires structured user edits");
|
|
2217
|
+
edit(getBlockId(), values);
|
|
2218
|
+
if (options?.editedPath) getBlockValidation()?.markPathEdited(getBlockId(), options.editedPath);
|
|
2219
|
+
} else {
|
|
2220
|
+
const edit = getRootSlice().setCurrentValues;
|
|
2221
|
+
if (!edit) throw new Error("Content backend requires structured user edits");
|
|
2222
|
+
edit(values);
|
|
2223
|
+
}
|
|
2224
|
+
},
|
|
2225
|
+
getValues: getCurrentScopeValues,
|
|
2226
|
+
getFieldState: (path) => {
|
|
2227
|
+
const snapshot = scope === "blocks" ? getBlocksSlice().getBlockSnapshot?.(getBlockId()) : getRootSlice().getSnapshot?.();
|
|
2228
|
+
const issue = fieldIssueAt(path);
|
|
2229
|
+
const visible = scope === "blocks" ? filterVisibleBlockIssues(getBlockValidation(), getBlockId(), issue ? [issue] : []) : issue ? [issue] : [];
|
|
2230
|
+
const fieldError = visible[0] ? { message: visible[0].message } : void 0;
|
|
2231
|
+
return {
|
|
2232
|
+
error: fieldError,
|
|
2233
|
+
isDirty: isSnapshotDirty(snapshot),
|
|
2234
|
+
isTouched: scope === "blocks" ? Boolean(getBlockValidation()?.isPathEdited(getBlockId(), path)) : false,
|
|
2235
|
+
invalid: !!fieldError
|
|
2236
|
+
};
|
|
2237
|
+
},
|
|
2238
|
+
setError: (path, error) => {
|
|
2239
|
+
if (scope === "blocks") getBlockValidation()?.setFieldIssue?.(getBlockId(), path, error.message);
|
|
2240
|
+
},
|
|
2241
|
+
clearErrors: (path) => {
|
|
2242
|
+
if (scope === "blocks") getBlockValidation()?.clearFieldIssues?.(getBlockId(), path);
|
|
2243
|
+
},
|
|
2244
|
+
getErrors: () => {
|
|
2245
|
+
const issues = getVisibleValidationIssues();
|
|
2246
|
+
const errors = {};
|
|
2247
|
+
issues.forEach((issue) => {
|
|
2248
|
+
const path = issue.path.join(".");
|
|
2249
|
+
errors[path] = { message: issue.message };
|
|
2250
|
+
});
|
|
2251
|
+
return errors;
|
|
2252
|
+
},
|
|
2253
|
+
setDirty: (_path, _isDirty) => {},
|
|
2254
|
+
setTouched: (_path, _isTouched) => {},
|
|
2255
|
+
resetField: (path) => {
|
|
2256
|
+
const baseline = (scope === "blocks" ? getBlocksSlice().getBlockSnapshot?.(getBlockId()) : getRootSlice().getSnapshot?.())?.sync.baseline.values;
|
|
2257
|
+
if (baseline) {
|
|
2258
|
+
const baselineValue = baseline[path];
|
|
2259
|
+
if (scope === "blocks") getBlocksSlice().setAtPath(getBlockId(), path, baselineValue);
|
|
2260
|
+
else getRootSlice().setAtPath(path, baselineValue);
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
setFocus: (path) => {
|
|
2264
|
+
if (scope !== "blocks") return;
|
|
2265
|
+
getStoreState().requestFocus?.({
|
|
2266
|
+
kind: "main-field",
|
|
2267
|
+
blockId: getBlockId(),
|
|
2268
|
+
fieldPath: path
|
|
2269
|
+
});
|
|
2270
|
+
},
|
|
2271
|
+
arrayField: {
|
|
2272
|
+
append: (path, value) => {
|
|
2273
|
+
const newArray = [...toUnknownArray(scope === "blocks" ? getBlocksSlice().getAtPath(getBlockId(), path) : getRootSlice().getAtPath(path)), value];
|
|
2274
|
+
if (scope === "blocks") getBlocksSlice().setAtPath(getBlockId(), path, newArray);
|
|
2275
|
+
else getRootSlice().setAtPath(path, newArray);
|
|
2276
|
+
getStoreState().arrayKeys.append(getScopeKey(), path, generateId());
|
|
2277
|
+
},
|
|
2278
|
+
remove: (path, index) => {
|
|
2279
|
+
const newArray = toUnknownArray(scope === "blocks" ? getBlocksSlice().getAtPath(getBlockId(), path) : getRootSlice().getAtPath(path)).filter((_, i) => i !== index);
|
|
2280
|
+
if (scope === "blocks") getBlocksSlice().setAtPath(getBlockId(), path, newArray);
|
|
2281
|
+
else getRootSlice().setAtPath(path, newArray);
|
|
2282
|
+
getStoreState().arrayKeys.remove(getScopeKey(), path, index);
|
|
2283
|
+
},
|
|
2284
|
+
move: (path, from, to) => {
|
|
2285
|
+
const newArray = [...toUnknownArray(scope === "blocks" ? getBlocksSlice().getAtPath(getBlockId(), path) : getRootSlice().getAtPath(path))];
|
|
2286
|
+
const [removed] = newArray.splice(from, 1);
|
|
2287
|
+
if (removed !== void 0) newArray.splice(to, 0, removed);
|
|
2288
|
+
if (scope === "blocks") getBlocksSlice().setAtPath(getBlockId(), path, newArray);
|
|
2289
|
+
else getRootSlice().setAtPath(path, newArray);
|
|
2290
|
+
getStoreState().arrayKeys.move(getScopeKey(), path, from, to);
|
|
2291
|
+
},
|
|
2292
|
+
insert: (path, index, value) => {
|
|
2293
|
+
const newArray = [...toUnknownArray(scope === "blocks" ? getBlocksSlice().getAtPath(getBlockId(), path) : getRootSlice().getAtPath(path))];
|
|
2294
|
+
newArray.splice(index, 0, value);
|
|
2295
|
+
if (scope === "blocks") getBlocksSlice().setAtPath(getBlockId(), path, newArray);
|
|
2296
|
+
else getRootSlice().setAtPath(path, newArray);
|
|
2297
|
+
getStoreState().arrayKeys.insert(getScopeKey(), path, index, generateId());
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
get formState() {
|
|
2301
|
+
const snapshot = scope === "blocks" ? getBlocksSlice().getBlockSnapshot?.(getBlockId()) : getRootSlice().getSnapshot?.();
|
|
2302
|
+
getCurrentScopeValues();
|
|
2303
|
+
const issues = getValidationIssues();
|
|
2304
|
+
const visibleIssues = getVisibleValidationIssues();
|
|
2305
|
+
const errors = {};
|
|
2306
|
+
visibleIssues.forEach((issue) => {
|
|
2307
|
+
const path = issue.path.join(".");
|
|
2308
|
+
errors[path] = { message: issue.message };
|
|
2309
|
+
});
|
|
2310
|
+
return {
|
|
2311
|
+
isDirty: isSnapshotDirty(snapshot),
|
|
2312
|
+
isValid: issues.length === 0,
|
|
2313
|
+
errors
|
|
2314
|
+
};
|
|
2315
|
+
},
|
|
2316
|
+
reset: (values) => {
|
|
2317
|
+
if (scope === "blocks") getBlocksSlice().updateBlockBaseline?.(getBlockId(), isRecord(values) ? values : null);
|
|
2318
|
+
else getRootSlice().refresh?.({ values: isRecord(values) ? values : null }, "replace");
|
|
2319
|
+
},
|
|
2320
|
+
validate: async () => {
|
|
2321
|
+
getCurrentScopeValues();
|
|
2322
|
+
return getValidationIssues().length === 0;
|
|
2323
|
+
},
|
|
2324
|
+
subscribe: (callback) => {
|
|
2325
|
+
return store.subscribe(callback);
|
|
2326
|
+
}
|
|
2327
|
+
};
|
|
2328
|
+
return Object.assign(backend, createFieldObservation((path) => ({
|
|
2329
|
+
value: backend.getValue(path),
|
|
2330
|
+
...backend.getFieldState(path)
|
|
2331
|
+
}), backend.subscribe, (value) => value));
|
|
2332
|
+
}
|
|
2333
|
+
//#endregion
|
|
2334
|
+
//#region ../preview-next/src/client/blocks/arrangementControlsModel.ts
|
|
2335
|
+
/**
|
|
2336
|
+
* Decides the arrangement-Look controls for one block from the editor read
|
|
2337
|
+
* model and the content the editor holds. Null means the block's style uses
|
|
2338
|
+
* the legacy catalogue, so the legacy controls apply unchanged.
|
|
2339
|
+
*/
|
|
2340
|
+
function arrangementBlockControlsFor(input) {
|
|
2341
|
+
const selection = input.block.arrangementLookSelection;
|
|
2342
|
+
if (!selection) return null;
|
|
2343
|
+
const mode = arrangementBlockMode(input.block);
|
|
2344
|
+
const pin = pinnedLookId(input.block);
|
|
2345
|
+
const offered = offeredLooksForMode(selection, mode);
|
|
2346
|
+
const resolved = resolveEditorArrangementLook(selection, mode, pin);
|
|
2347
|
+
const effective = resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look;
|
|
2348
|
+
const knobState = effective ? resolveArrangementKnobs({
|
|
2349
|
+
blockKind: input.block.blockKind,
|
|
2350
|
+
look: compiledKnobLook(selection.style.offers, effective),
|
|
2351
|
+
content: input.content
|
|
2352
|
+
}) : null;
|
|
2353
|
+
return {
|
|
2354
|
+
look: lookPosition(resolved, input.block),
|
|
2355
|
+
tiles: lookTilesFor({
|
|
2356
|
+
looks: offered,
|
|
2357
|
+
defaultLookId: resolvedLookId(resolveEditorArrangementLook(selection, mode, null)),
|
|
2358
|
+
shownLookId: effective?.id ?? null
|
|
2359
|
+
}),
|
|
2360
|
+
mode: modeSwitch(input.block, selection.available, mode),
|
|
2361
|
+
knobs: knobState ? knobControls(input.block.blockKind, knobState.exposure, knobState.knobs, input.content, effective?.structure.knobDescriptions) : [],
|
|
2362
|
+
headlineHint: knobState ? headlineHint(knobState.knobs, knobState.length) : null
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
/** The name of the Look a block shows, for the page outline. Null on a legacy style. */
|
|
2366
|
+
function arrangementLookNameFor(block) {
|
|
2367
|
+
const selection = block.arrangementLookSelection;
|
|
2368
|
+
if (!selection) return null;
|
|
2369
|
+
return lookPosition(resolveEditorArrangementLook(selection, arrangementBlockMode(block), pinnedLookId(block)), block)?.lookName ?? null;
|
|
2370
|
+
}
|
|
2371
|
+
/** The Look a resolution renders; unpinned, that's the style's own pick. */
|
|
2372
|
+
function resolvedLookId(resolved) {
|
|
2373
|
+
return resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look.id;
|
|
2374
|
+
}
|
|
2375
|
+
function pinnedLookId(block) {
|
|
2376
|
+
return block.look.kind === "user-pinned" ? block.look.value : null;
|
|
2377
|
+
}
|
|
2378
|
+
/** Offer order, as the resolver uses it, for the Looks that support the mode. */
|
|
2379
|
+
function offeredLooksForMode(selection, mode) {
|
|
2380
|
+
return selection.style.offers.flatMap((offer) => {
|
|
2381
|
+
const look = selection.available.find((candidate) => candidate.id === offer.id);
|
|
2382
|
+
return look && lookModes(look).includes(mode) ? [look] : [];
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
function compiledKnobLook(offers, look) {
|
|
2386
|
+
const offer = offers.find((candidate) => candidate.id === look.id);
|
|
2387
|
+
return {
|
|
2388
|
+
look,
|
|
2389
|
+
addKnobs: offer?.addKnobs ?? [],
|
|
2390
|
+
removeKnobs: offer?.removeKnobs ?? [],
|
|
2391
|
+
knobValues: offer?.knobValues ?? {}
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
function lookPosition(resolved, block) {
|
|
2395
|
+
switch (resolved.kind) {
|
|
2396
|
+
case "offered": return resolved.source === "auto" ? {
|
|
2397
|
+
kind: "automatic",
|
|
2398
|
+
lookName: resolved.look.label
|
|
2399
|
+
} : {
|
|
2400
|
+
kind: "pinned",
|
|
2401
|
+
lookName: resolved.look.label
|
|
2402
|
+
};
|
|
2403
|
+
case "style-fallback": return {
|
|
2404
|
+
kind: "style-fallback",
|
|
2405
|
+
requestedName: lookName(resolved.requested),
|
|
2406
|
+
lookName: resolved.look.label
|
|
2407
|
+
};
|
|
2408
|
+
case "mode-mismatch": return {
|
|
2409
|
+
kind: "mode-mismatch",
|
|
2410
|
+
requestedName: lookName(resolved.requested),
|
|
2411
|
+
requestedModeLabel: requestedModeLabel(block, resolved.requested),
|
|
2412
|
+
lookName: resolved.look.label
|
|
2413
|
+
};
|
|
2414
|
+
case "recipe":
|
|
2415
|
+
case "none": return null;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
/** The requested Look may be one this style doesn't offer, so read the shared catalogue. */
|
|
2419
|
+
function lookName(id) {
|
|
2420
|
+
return lookDefinitionForId(id)?.label ?? "your chosen Look";
|
|
2421
|
+
}
|
|
2422
|
+
function requestedModeLabel(block, id) {
|
|
2423
|
+
const look = lookDefinitionForId(id);
|
|
2424
|
+
const mode = look ? lookModes(look).find((candidate) => candidate !== null) : void 0;
|
|
2425
|
+
return mode ? modeLabel(block, mode) : "another";
|
|
2426
|
+
}
|
|
2427
|
+
function modeSwitch(block, available, current) {
|
|
2428
|
+
if (current === null) return null;
|
|
2429
|
+
const modesWithLooks = available.flatMap((look) => lookModes(look)).filter((mode) => mode !== null);
|
|
2430
|
+
const modes = [...new Set(modesWithLooks)];
|
|
2431
|
+
return modes.length > 1 ? {
|
|
2432
|
+
current,
|
|
2433
|
+
options: modes.map((mode) => ({
|
|
2434
|
+
mode,
|
|
2435
|
+
label: modeLabel(block, mode)
|
|
2436
|
+
}))
|
|
2437
|
+
} : null;
|
|
2438
|
+
}
|
|
2439
|
+
function modeLabel(block, mode) {
|
|
2440
|
+
const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
|
|
2441
|
+
return (meaning?.kind === "mode" ? meaning.modeLabels?.[mode] : void 0) ?? block.availableLayouts.find((layout) => layout.id === mode)?.label ?? mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
2442
|
+
}
|
|
2443
|
+
function knobControls(blockKind, exposure, knobs, content, descriptions = {}) {
|
|
2444
|
+
return exposure.flatMap((entry) => {
|
|
2445
|
+
const knob = knobs[entry.definition.id];
|
|
2446
|
+
const facet = shownKnobFacet(blockKind, entry, knob);
|
|
2447
|
+
if (!facet || !knob || knob.kind === "kept") return [];
|
|
2448
|
+
const control = knobControl(entry, knob, facet, systemCustomizeFacetStoredValue(facet, { ...content }));
|
|
2449
|
+
const description = descriptions[entry.definition.id] ?? facet.description;
|
|
2450
|
+
return [control.kind === "choice" && description !== void 0 ? {
|
|
2451
|
+
...control,
|
|
2452
|
+
description
|
|
2453
|
+
} : control];
|
|
2454
|
+
});
|
|
2455
|
+
}
|
|
2456
|
+
/** Only knobs the current Look exposes and doesn't force get a control. */
|
|
2457
|
+
function shownKnobFacet(blockKind, entry, knob) {
|
|
2458
|
+
const id = entry.definition.id;
|
|
2459
|
+
if (entry.definition.textMaxLength === void 0 && arrangementKnobChoices(entry).length <= 1 || !entry.exposed || entry.forced !== void 0 || !knob || knob.kind === "kept" || !isSystemCustomizeFacetId(id)) return null;
|
|
2460
|
+
return systemCustomizeFacetDefinitionForBlock(blockKind, id);
|
|
2461
|
+
}
|
|
2462
|
+
function knobControl(entry, knob, facet, stored) {
|
|
2463
|
+
if (entry.definition.textMaxLength !== void 0) return {
|
|
2464
|
+
kind: "text",
|
|
2465
|
+
facetId: facet.id,
|
|
2466
|
+
label: facet.label,
|
|
2467
|
+
value: knob.value,
|
|
2468
|
+
stored,
|
|
2469
|
+
maxLength: entry.definition.textMaxLength
|
|
2470
|
+
};
|
|
2471
|
+
const choices = arrangementKnobChoices(entry);
|
|
2472
|
+
const preference = knob.kind === "clamped" && knob.reason === "length" && choices.includes(knob.stored) ? knob.stored : knob.value;
|
|
2473
|
+
const labelOf = (value) => facet.values.find((option) => option.value === value)?.label ?? value;
|
|
2474
|
+
return {
|
|
2475
|
+
kind: "choice",
|
|
2476
|
+
presentation: knobPresentation(facet, choices),
|
|
2477
|
+
facetId: facet.id,
|
|
2478
|
+
label: facet.label,
|
|
2479
|
+
value: preference,
|
|
2480
|
+
stored,
|
|
2481
|
+
notOffered: knob.kind === "clamped" && knob.reason !== "length" ? {
|
|
2482
|
+
by: knob.reason,
|
|
2483
|
+
choice: labelOf(knob.stored),
|
|
2484
|
+
shows: labelOf(knob.value)
|
|
2485
|
+
} : null,
|
|
2486
|
+
options: choices.map((value) => ({
|
|
2487
|
+
value,
|
|
2488
|
+
label: labelOf(value)
|
|
2489
|
+
}))
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
/** On/off knobs store `'true'` and `'false'`; the switch is on for `'true'`. */
|
|
2493
|
+
function knobPresentation(facet, choices) {
|
|
2494
|
+
if (facet.target.kind === "content-field" && facet.target.boolean === true && choices.length === 2 && choices.includes("true") && choices.includes("false")) return "switch";
|
|
2495
|
+
return choices.length <= 3 ? "segments" : "menu";
|
|
2496
|
+
}
|
|
2497
|
+
function headlineHint(knobs, length) {
|
|
2498
|
+
const headline = knobs.titleSize;
|
|
2499
|
+
return headline?.kind === "clamped" && headline.reason === "length" && length !== null && length !== "short" ? { length } : null;
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Section backgrounds for an arrangement-Look style: the style's own surfaces
|
|
2503
|
+
* by plain name, plus the page rhythm. A background is never a Look. A Look
|
|
2504
|
+
* that paints its photo behind the text has no Background row, because the
|
|
2505
|
+
* photo is the background. Any other Look offers the surfaces until the
|
|
2506
|
+
* section has a photo, which replaces the colour choice.
|
|
2507
|
+
*/
|
|
2508
|
+
function arrangementBackgroundControlFor(input) {
|
|
2509
|
+
const selection = input.block.arrangementLookSelection;
|
|
2510
|
+
if (!selection || input.block.backgroundSupport.kind === "unsupported") return null;
|
|
2511
|
+
const photo = decideSectionPhoto({
|
|
2512
|
+
block: input.block,
|
|
2513
|
+
promotedFieldPaths: getBlockDefinition(input.block.blockKind)?.manifest.promotedFields,
|
|
2514
|
+
draftPhoto: sectionPhotoPresence(input.content)
|
|
2515
|
+
});
|
|
2516
|
+
if (photo.kind === "arrangement" && photo.use === "behind") return null;
|
|
2517
|
+
if (photo.kind === "arrangement" && photo.photo === "present") return {
|
|
2518
|
+
kind: "held-by-photo",
|
|
2519
|
+
photo: "section-photo"
|
|
2520
|
+
};
|
|
2521
|
+
const options = arrangementSurfaceOptions(selection.style);
|
|
2522
|
+
const stored = storedSurfaceChoice(parseCanonicalSectionBackground({ ...input.content }), options);
|
|
2523
|
+
return stored.kind === "held-by-photo" ? stored : {
|
|
2524
|
+
kind: "surfaces",
|
|
2525
|
+
selected: stored.selected,
|
|
2526
|
+
options,
|
|
2527
|
+
rhythm: options.find((option) => option.token === input.decidedBackground) ?? null
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
function arrangementSurfaceOptions(style) {
|
|
2531
|
+
return Object.entries(style.surfaces).flatMap(([name, spec]) => {
|
|
2532
|
+
const token = spec.kind === "token" && !spec.roleOnly ? parseBackgroundColorToken(spec.token) : null;
|
|
2533
|
+
return token ? [{
|
|
2534
|
+
name,
|
|
2535
|
+
label: arrangementSurfaceLabel(name),
|
|
2536
|
+
token
|
|
2537
|
+
}] : [];
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
/** Which surface the stored background shows as chosen, once the section has no photo of its own. */
|
|
2541
|
+
function storedSurfaceChoice(stored, options) {
|
|
2542
|
+
switch (stored.kind) {
|
|
2543
|
+
case "none": return {
|
|
2544
|
+
kind: "surface",
|
|
2545
|
+
selected: null
|
|
2546
|
+
};
|
|
2547
|
+
case "block-authored":
|
|
2548
|
+
if (stored.background.type === "image" || stored.background.type === "video") return {
|
|
2549
|
+
kind: "held-by-photo",
|
|
2550
|
+
photo: "older-style-photo"
|
|
2551
|
+
};
|
|
2552
|
+
return {
|
|
2553
|
+
kind: "surface",
|
|
2554
|
+
selected: stored.background.type === "color" ? surfaceForToken(options, stored.background.color) : null
|
|
2555
|
+
};
|
|
2556
|
+
case "page-design-override": {
|
|
2557
|
+
const override = stored.parsed.kind === "supported" ? stored.parsed.override : null;
|
|
2558
|
+
return {
|
|
2559
|
+
kind: "surface",
|
|
2560
|
+
selected: override?.kind === "color" ? surfaceForToken(options, override.token) : null
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
const arrangementSurfaceLabels = {
|
|
2566
|
+
base: "Page ground",
|
|
2567
|
+
band: "Quiet band",
|
|
2568
|
+
brand: "Brand colour",
|
|
2569
|
+
deep: "Deepest tone",
|
|
2570
|
+
inverse: "Opposite ground",
|
|
2571
|
+
pop: "Pop colour"
|
|
2572
|
+
};
|
|
2573
|
+
function arrangementSurfaceLabel(name) {
|
|
2574
|
+
return arrangementSurfaceLabels[name] ?? name.charAt(0).toUpperCase() + name.slice(1).replace(/[-_]+/g, " ");
|
|
2575
|
+
}
|
|
2576
|
+
function surfaceForToken(options, token) {
|
|
2577
|
+
return options.find((option) => option.token === token)?.name ?? null;
|
|
2578
|
+
}
|
|
2579
|
+
//#endregion
|
|
2580
|
+
//#region ../preview-next/src/client/blocks/blockNeedsSetup.ts
|
|
2581
|
+
/** The short label every editing surface uses for a block that isn't set up. */
|
|
2582
|
+
const NEEDS_SETUP_LABEL = "Needs setting up";
|
|
2583
|
+
/**
|
|
2584
|
+
* Whether the draft as rendered needs setting up. This reads the preview's own
|
|
2585
|
+
* render, so it's for editing surfaces; publishing checks published facts on the server.
|
|
2586
|
+
*/
|
|
2587
|
+
function needsSetupOf(readiness, blockId) {
|
|
2588
|
+
const found = blockId ? readiness.get(blockId) : void 0;
|
|
2589
|
+
return found?.kind === "NeedsSetup" ? found : null;
|
|
2590
|
+
}
|
|
2591
|
+
function useBlockNeedsSetup(blockId) {
|
|
2592
|
+
return needsSetupOf(usePreviewRenderReadiness(), blockId);
|
|
2593
|
+
}
|
|
2594
|
+
/** What's missing and what happens until it's fixed, e.g. "Pick where sign-ups go. Until you do, …". */
|
|
2595
|
+
function needsSetupMessage(needs) {
|
|
2596
|
+
return READINESS_REASON_COPY[needs.reason];
|
|
2597
|
+
}
|
|
2598
|
+
/** The first part of the message, without what happens meanwhile, e.g. "Pick where sign-ups go." */
|
|
2599
|
+
function needsSetupAsk(needs) {
|
|
2600
|
+
return READINESS_REASON_COPY[needs.reason].split(" Until ")[0] ?? READINESS_REASON_COPY[needs.reason];
|
|
2601
|
+
}
|
|
2602
|
+
//#endregion
|
|
2603
|
+
//#region ../preview-next/src/client/blocks/sectionPhotoField.ts
|
|
2604
|
+
/**
|
|
2605
|
+
* Arrangement Looks call the section photo's field Photo. Looks that show it
|
|
2606
|
+
* say what the section shows until one is added; a Look that doesn't show it
|
|
2607
|
+
* only lists the field while a photo is stored, so the owner can remove it.
|
|
2608
|
+
* Older recipe Looks keep the field as it is.
|
|
2609
|
+
*/
|
|
2610
|
+
function sectionPhotoFieldCopy(photo) {
|
|
2611
|
+
if (photo.kind !== "arrangement") return null;
|
|
2612
|
+
if (photo.use === "none") return photo.photo === "present" ? {
|
|
2613
|
+
label: "Photo",
|
|
2614
|
+
hint: "This Look doesn’t show the photo. Remove it to choose a background colour."
|
|
2615
|
+
} : null;
|
|
2616
|
+
if (photo.photo === "present") return {
|
|
2617
|
+
label: "Photo",
|
|
2618
|
+
hint: null
|
|
2619
|
+
};
|
|
2620
|
+
return {
|
|
2621
|
+
label: "Photo",
|
|
2622
|
+
hint: photo.withoutPhoto === "shows-another-look" ? "Add a photo. Until you do, this section shows the title on its own." : "Add a photo. This Look is built around one, so it can look a little bare without it."
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
/** Applies the Photo copy to the promoted photo field in the Look section. */
|
|
2626
|
+
function withSectionPhotoField(plan, photo) {
|
|
2627
|
+
const copy = sectionPhotoFieldCopy(photo);
|
|
2628
|
+
if (copy === null) return plan;
|
|
2629
|
+
const look = plan.sections.look.map((item) => item.path === "_sectionStyles.background.image" ? {
|
|
2630
|
+
...item,
|
|
2631
|
+
field: {
|
|
2632
|
+
...item.field,
|
|
2633
|
+
label: copy.label,
|
|
2634
|
+
description: copy.hint ?? void 0
|
|
2635
|
+
}
|
|
2636
|
+
} : item);
|
|
2637
|
+
return {
|
|
2638
|
+
...plan,
|
|
2639
|
+
sections: {
|
|
2640
|
+
...plan.sections,
|
|
2641
|
+
look
|
|
2642
|
+
}
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
//#endregion
|
|
2646
|
+
//#region ../preview-next/src/client/blocks/useBlockCustomizeControls.ts
|
|
2647
|
+
function useBlockCustomizeControls({ blockId, blockKind, content, uiStore, theme, sdkConfig }) {
|
|
2648
|
+
const { blockFieldOptions, blockFieldExtensions, sdkConfig: contextSdkConfig } = useSdkConfig();
|
|
2649
|
+
const effectiveSdkConfig = sdkConfig ?? contextSdkConfig;
|
|
2650
|
+
const manifest = useMemo(() => resolveBlockManifest(blockKind, effectiveSdkConfig ?? null), [blockKind, effectiveSdkConfig]);
|
|
2651
|
+
const { state: pageDesignState } = usePreviewPageDesignEditorState();
|
|
2652
|
+
const designBlock = useMemo(() => pageDesignState.kind === "loaded" ? pageDesignState.editorModel.blocks.find((block) => String(block.blockId) === String(blockId)) ?? null : null, [blockId, pageDesignState]);
|
|
2653
|
+
const draftPhoto = sectionPhotoPresence(content);
|
|
2654
|
+
const preparedManifest = useMemo(() => {
|
|
2655
|
+
if (!manifest) return null;
|
|
2656
|
+
return prepareBlockEditorManifest({
|
|
2657
|
+
manifest,
|
|
2658
|
+
blockKind,
|
|
2659
|
+
theme,
|
|
2660
|
+
blockFieldOptions,
|
|
2661
|
+
blockFieldExtensions,
|
|
2662
|
+
visibilityPolicy: hideThemeV2RawStyleFields,
|
|
2663
|
+
allowedPromotedFieldPaths: designBlock ? resolveVisiblePromotedFieldPathsForEditorBlock({
|
|
2664
|
+
block: designBlock,
|
|
2665
|
+
promotedFieldPaths: manifest.promotedFields,
|
|
2666
|
+
draftPhoto
|
|
2667
|
+
}) : void 0
|
|
2668
|
+
});
|
|
2669
|
+
}, [
|
|
2670
|
+
designBlock,
|
|
2671
|
+
draftPhoto,
|
|
2672
|
+
blockFieldExtensions,
|
|
2673
|
+
blockFieldOptions,
|
|
2674
|
+
blockKind,
|
|
2675
|
+
manifest,
|
|
2676
|
+
theme
|
|
2677
|
+
]);
|
|
2678
|
+
const ownedFieldIds = useMemo(() => arrangementOwnedFieldIds(designBlock), [designBlock]);
|
|
2679
|
+
const visibilityValues = useMemo(() => arrangementVisibilityValues(designBlock), [designBlock]);
|
|
2680
|
+
const fields = useMemo(() => {
|
|
2681
|
+
if (!preparedManifest) return [];
|
|
2682
|
+
return createManifestFormAdapter(preparedManifest.renderManifest).fields.filter((field) => !ownedFieldIds.includes(field.id));
|
|
2683
|
+
}, [ownedFieldIds, preparedManifest]);
|
|
2684
|
+
const backend = useMemo(() => {
|
|
2685
|
+
if (!preparedManifest) return null;
|
|
2686
|
+
return createStoreBackend({
|
|
2687
|
+
scope: "blocks",
|
|
2688
|
+
store: uiStore,
|
|
2689
|
+
blockId
|
|
2690
|
+
});
|
|
2691
|
+
}, [
|
|
2692
|
+
blockId,
|
|
2693
|
+
preparedManifest,
|
|
2694
|
+
uiStore
|
|
2695
|
+
]);
|
|
2696
|
+
const getValue = (path) => visibilityValues && path === "blockLook" ? visibilityValues.lookId : visibilityValues && path === visibilityValues.arrangementField ? visibilityValues.arrangement : backend?.getValue(path) ?? content[path] ?? fields.find((field) => field.id === path)?.defaultValue;
|
|
2697
|
+
const sectionOptions = preparedManifest ? manifestFieldSectionOptions(preparedManifest.renderManifest, { lookOwnedPaths: blockLookOwnedFieldPaths(designBlock) }) : {};
|
|
2698
|
+
const plan = derivePromotedFieldPlan(fields, preparedManifest?.renderManifest.promotedFields, getValue, sectionOptions);
|
|
2699
|
+
const sectionPlan = designBlock && manifest ? withSectionPhotoField(plan, decideSectionPhoto({
|
|
2700
|
+
block: designBlock,
|
|
2701
|
+
promotedFieldPaths: manifest.promotedFields,
|
|
2702
|
+
draftPhoto
|
|
2703
|
+
})) : plan;
|
|
2704
|
+
const renderManifest = preparedManifest?.renderManifest ?? null;
|
|
2705
|
+
return {
|
|
2706
|
+
manifest: renderManifest,
|
|
2707
|
+
fields,
|
|
2708
|
+
sectionPlan,
|
|
2709
|
+
backend,
|
|
2710
|
+
designBlock,
|
|
2711
|
+
lookSource: resolveBlockLookSource(renderManifest, sectionPlan)
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
function resolveBlockManifest(blockKind, sdkConfig) {
|
|
2715
|
+
return getBlockManifestFromSdkConfig(blockKind, sdkConfig) ?? getBlockDefinition(blockKind)?.manifest ?? null;
|
|
2716
|
+
}
|
|
2717
|
+
function resolveBlockLookSource(manifest, plan) {
|
|
2718
|
+
return manifest?.lookField ? {
|
|
2719
|
+
kind: "sdk",
|
|
2720
|
+
item: plan.sections.look.find((item) => item.path === manifest.lookField) ?? null
|
|
2721
|
+
} : { kind: "built-in" };
|
|
2722
|
+
}
|
|
2723
|
+
//#endregion
|
|
2724
|
+
export { TooltipTrigger as A, prepareBlockEditorManifest as C, Tooltip as D, mergeBlockDescriptors as E, DropdownMenuTrigger as F, DropdownMenuContent as M, DropdownMenuItem as N, TooltipContent as O, DropdownMenuSeparator as P, hideThemeV2RawStyleFields as S, getBlockManifestFromSdkConfig as T, arrangementLookResolution as _, needsSetupMessage as a, blockLookOwnedFieldPaths as b, arrangementBackgroundControlFor as c, createStoreBackend as d, isObjectRecord as f, useSdkConfig as g, SdkConfigProvider as h, needsSetupAsk as i, DropdownMenu as j, TooltipProvider as k, arrangementBlockControlsFor as l, createFieldObservation as m, useBlockCustomizeControls as n, needsSetupOf as o, isRecord as p, NEEDS_SETUP_LABEL as r, useBlockNeedsSetup as s, resolveBlockManifest as t, arrangementLookNameFor as u, arrangementOwnedFieldIds as v, showRawStyleFields as w, lookNotShownFieldIds as x, arrangementVisibilityValues as y };
|