@riverbankcms/sdk 0.179.0 → 0.181.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/README.md +2 -2
- package/dist/_dts/{BlocksIslandsHydrator-DKwgs95u.d.ts → BlocksIslandsHydrator-CVCasDPz.d.ts} +1 -1
- package/dist/_dts/{Page-lWenra5i.d.ts → Page-Dtj2Ui3S.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-BRxhRw4I.d.ts → SdkPreviewMode-D1f_60WW.d.ts} +3 -2
- package/dist/_dts/{client-qWn7xAwJ.d.ts → client-Chr9pNVW.d.ts} +288 -121
- package/dist/_dts/{content-types-DL6GIvTm.d.ts → content-types-kjccgopX.d.ts} +2 -2
- package/dist/_dts/{contracts-CzWyAiJj.d.ts → contracts-BodaiS00.d.ts} +3 -3
- package/dist/_dts/{generatePageMetadata-CBKd0cJ4.d.ts → generatePageMetadata-BS6kaJFp.d.ts} +2 -2
- package/dist/_dts/{index-DCiSHd-C.d.ts → index-Brl6_I2j.d.ts} +5 -4
- package/dist/_dts/{index-CaCum9mM.d.ts → index-CJkefwYh.d.ts} +2 -2
- package/dist/_dts/{index-7CDBZGb-.d.ts → index-D1WpKwQe.d.ts} +1 -1
- package/dist/_dts/{index-BU9uAkHB.d.ts → index-DG0OvBs0.d.ts} +8 -8
- package/dist/_dts/{index-BYnG_vF5.d.ts → index-Diqt0PvG.d.ts} +1 -1
- package/dist/_dts/{index-CZgJrhzT.d.ts → index-Dy50xUMK.d.ts} +2 -2
- package/dist/_dts/{loadContent-CPKbFQyq.d.ts → loadContent-BgxshKrA.d.ts} +7 -7
- package/dist/_dts/{request-BjKBCS7t.d.ts → request-CA0izds5.d.ts} +4561 -1390
- package/dist/_dts/{resolveBlockData-DupbMCup.d.ts → resolveBlockData-ChQmwEd3.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-BqNyCHi8.d.ts → resolvePageContent-BvGyvblj.d.ts} +1 -1
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +7 -7
- package/dist/_dts/sdk/src/config/index.d.ts +6 -6
- package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
- package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
- package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
- package/dist/_dts/sdk/src/data/types.d.ts +2 -2
- package/dist/_dts/sdk/src/gifting/client.d.ts +1 -2
- package/dist/_dts/sdk/src/index.d.ts +104 -8
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
- package/dist/_dts/sdk/src/next/index.d.ts +84 -53
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
- package/dist/_dts/sdk/src/portal/client.d.ts +43 -56
- package/dist/_dts/sdk/src/portal/index.d.ts +3 -18
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
- package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
- package/dist/_dts/sdk/src/server.d.ts +5 -5
- package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
- package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
- package/dist/_dts/{serviceBookingOutline-YcsIjvn1.d.ts → serviceBookingOutline-BgFbJQhU.d.ts} +8 -7
- package/dist/_dts/{types-B7e6Lmo5.d.ts → types-CQrsP1x_.d.ts} +3 -3
- package/dist/_dts/{types-CT-KOxl_.d.ts → types-CgS3xLk8.d.ts} +7 -2
- package/dist/_dts/{types-BOxSq-Bq.d.ts → types-R65DKjPn.d.ts} +9 -8
- package/dist/_dts/{validation-Dz6qccue.d.ts → validation-6LTIbuBA.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-1XifJg6V.mjs → BlocksIslandsHydrator-DqZPz6oW.mjs} +19 -19
- package/dist/client/{BookingMailingListNote-BsbEgagJ.mjs → BookingMailingListNote-uWfR2kaG.mjs} +177 -70
- package/dist/client/{BookingQuestionFields-C8IbeLHj.mjs → BookingQuestionFields-CyNIKw6k.mjs} +23 -82
- package/dist/client/CalendarAction-D_Glwvz2.mjs +105 -0
- package/dist/client/{CalendarNavigationChevron-Bbqij1XQ.mjs → CalendarNavigationChevron-BGCX3zwG.mjs} +6 -6
- package/dist/client/{CheckboxChoice-BZPLCgTU.mjs → CheckboxChoice-C8i4NraK.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-uA9H8LIL.mjs → DemoBookingPortalAccess-DFLPyuqe.mjs} +18 -10
- package/dist/client/{EventCalendar.client-yoSI77ov.mjs → EventCalendar.client-zDL4-t-B.mjs} +10 -10
- package/dist/client/{EventCombined.client-HeCNlliq.mjs → EventCombined.client-uciDKLID.mjs} +60 -10
- package/dist/client/{EventEmbeddedCheckoutStep-BDnicDM6.mjs → EventEmbeddedCheckoutStep-BGkbUhuw.mjs} +1 -1
- package/dist/client/{EventItem-Duhk1vnF.mjs → EventItem-CwzrjcRw.mjs} +8 -7
- package/dist/client/{EventListWeekNavigation-BiutEqPK.mjs → EventListWeekNavigation-ChvcnPma.mjs} +1 -1
- package/dist/client/{EventListing.client-B5ln77jG.mjs → EventListing.client-DA57Qoyx.mjs} +3 -3
- package/dist/client/{EventListing.view-hUDhNtMv.mjs → EventListing.view-DZ0qMFF4.mjs} +8 -211
- package/dist/client/{EventRegistrationPayment-DqtX1vB2.mjs → EventRegistrationPayment-DSqCJL8E.mjs} +1657 -403
- package/dist/client/{Page-ChJ2TGVk.mjs → Page-C7mygH_f.mjs} +536 -287
- package/dist/client/{ProtectedSubmitButton-De6AzhE6.mjs → ProtectedSubmitButton-BNnKuir8.mjs} +1 -1
- package/dist/client/{SiteTermsAgreementField-CDBU31xW.mjs → SiteTermsAgreementField-B4z-e4Wq.mjs} +27 -24
- package/dist/client/{StepIndicator-JQA-VuEH.mjs → StepIndicator-Dn_DY4oY.mjs} +1 -1
- package/dist/client/{StepIndicator-2Dl9zon2.mjs → StepIndicator-atfDU82W.mjs} +21 -13
- package/dist/client/{ThemedButton-CnSa7o-I.mjs → ThemedButton-PFOhXktM.mjs} +1 -33
- package/dist/client/{accessibleSurfaces-Wl8-_OVJ.mjs → accessibleSurfaces-n6kS6Hct.mjs} +77 -1
- package/dist/client/{accordion-B6SqU49k.mjs → accordion-CsW8U3ff.mjs} +1 -1
- package/dist/client/{booking-form.client-DrEOjQ3N.mjs → booking-form.client-cBWM392H.mjs} +442 -86
- package/dist/client/bookingCalendar--aWnqFDn.mjs +180 -0
- package/dist/client/{bookingForm-drZBwEZW.mjs → bookingForm-DgySpp6C.mjs} +4 -4
- package/dist/client/bookings.mjs +51 -15
- package/dist/client/{boxStyleClassNames-DEh45w16.mjs → boxStyleClassNames-BpGVdLFD.mjs} +2 -2
- package/dist/client/{carousel-C-YJliD-.mjs → carousel-DJoleFV3.mjs} +2 -2
- package/dist/client/{carousel.client-DMtGYTTM.mjs → carousel.client-BtLwHefX.mjs} +1 -1
- package/dist/client/{cart-acGFWK9R.mjs → cart-EO5o6uPH.mjs} +3 -3
- package/dist/client/{cart.client-BzlOGP2j.mjs → cart.client-D_gPw45z.mjs} +1 -1
- package/dist/client/{checkout-SEontwhy.mjs → checkout-NVfZW0kR.mjs} +3 -3
- package/dist/client/{checkout.client-C0Qvh-d4.mjs → checkout.client-DD3JuqOy.mjs} +1 -1
- package/dist/client/{checkoutUrls-yUKeq1N9.mjs → checkoutUrls-z2gXvlGw.mjs} +1 -1
- package/dist/client/client.mjs +306 -196
- package/dist/client/constants-CoOkvw__.mjs +100 -0
- package/dist/client/{context-DTrwaQtg.mjs → context-CRhn9qzS.mjs} +922 -388
- package/dist/client/{dateFormatting-Cg8E1r9l.mjs → dateFormatting-BnWB4L1s.mjs} +15 -25
- package/dist/client/{demoPortalMagicLink-D0kOJYOX.mjs → demoPortalMagicLink-CWDGSTBu.mjs} +2 -3
- package/dist/client/{enhanceHeaderSection-DyrpZ7ks.mjs → enhanceHeaderSection-tdP_-Z9o.mjs} +4 -5
- package/dist/client/{event-registration.client-RLZQWi2V.mjs → event-registration.client-D7YYKySQ.mjs} +2084 -1640
- package/dist/client/{eventCalendar-CphYnImh.mjs → eventCalendar-CsAfu5d0.mjs} +4 -4
- package/dist/client/{eventCombined-BvqjASB_.mjs → eventCombined-VXJB5CoS.mjs} +4 -4
- package/dist/client/{eventListing-BaNAoC_M.mjs → eventListing-B3KIZNfY.mjs} +4 -4
- package/dist/client/{eventRegistration-COMHoRl6.mjs → eventRegistration-BP-dEk1c.mjs} +4 -4
- package/dist/client/{form-DyH2juYT.mjs → form-DM8Zbxbv.mjs} +3 -3
- package/dist/client/{form.client-DBwzkB0M.mjs → form.client-e2z_Tlgk.mjs} +5 -5
- package/dist/client/{form.parts-CY4kX3mh.mjs → form.parts-Ctljy1a3.mjs} +3 -3
- package/dist/client/gifting/client.mjs +32 -29
- package/dist/client/{gifting-CIx4V378.mjs → gifting-DWIsqQru.mjs} +4 -4
- package/dist/client/{gifting.client-BEVPpzJM.mjs → gifting.client-QsSWF0uA.mjs} +5 -5
- package/dist/client/{gifting.parts-VnORjnZK.mjs → gifting.parts-CedLgwa_.mjs} +2 -2
- package/dist/client/{headerSection-DGcJfRS8.mjs → headerSection-DAkRkwb-.mjs} +2 -2
- package/dist/client/{mediaAssets-B99AP7ai.mjs → mediaAssets-COfQolI3.mjs} +1 -1
- package/dist/client/{mediaContext-Fusweriw.mjs → mediaContext-DzvnjYXm.mjs} +1 -1
- package/dist/client/{newsletter-form.client-BvEDkjiD.mjs → newsletter-form.client-WYja9-WN.mjs} +7 -7
- package/dist/client/{newsletter-form.interactive-DCO1lErD.mjs → newsletter-form.interactive-RuM86VAv.mjs} +37 -44
- package/dist/client/{newsletter-form.parts-BIy4IUT3.mjs → newsletter-form.parts-2petDnWv.mjs} +2 -2
- package/dist/client/{newsletterForm-CoTXDNFS.mjs → newsletterForm-BUbXdA_e.mjs} +3 -3
- package/dist/client/{lookSurfaces-IqT_SVnX.mjs → noop-Dl4mZ-rr.mjs} +257 -49
- package/dist/client/portal/client.mjs +11779 -6745
- package/dist/client/portalOrders-COGn4BKG.mjs +596 -0
- package/dist/client/portalRoutes-D72yvtDh.mjs +862 -0
- package/dist/client/{product-detail.client-YHQ2aKX1.mjs → product-detail.client-pOAryevt.mjs} +1 -1
- package/dist/client/{product-list.client-DxoZw1vF.mjs → product-list.client-CcUpUiud.mjs} +1 -1
- package/dist/client/{productDetail-DjuFvkey.mjs → productDetail-BZJCfqat.mjs} +3 -3
- package/dist/client/{productList-DE9GEFoZ.mjs → productList-CiRs3mNb.mjs} +3 -3
- package/dist/client/{propsDecoder-Cyag_HOs.mjs → propsDecoder--uHW4tFM.mjs} +2 -2
- package/dist/client/{registry.server-BPwV-0Pp.mjs → registry.server-CDNNd8wC.mjs} +318 -235
- package/dist/client/{renderableMediaAssetAdmission-BlfqYLJW.mjs → renderableMediaAssetAdmission-BsOWd9lf.mjs} +1 -1
- package/dist/client/rendering/client.mjs +26 -26
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +16 -8
- package/dist/client/{richText-coerce-NrRqDeOg.mjs → richText-coerce-CQGE_wHV.mjs} +2 -1
- package/dist/client/{routeIslandApiConfig-BWq5gKFK.mjs → routeIslandApiConfig-BtCg87-N.mjs} +1 -1
- package/dist/client/{runtimeResponse-D2j2-mOk.mjs → runtimeResponse-DL_ARBpa.mjs} +1 -1
- package/dist/client/{runtimeResponse-DtWSfWSZ.mjs → runtimeResponse-Ds9cmBUf.mjs} +1 -1
- package/dist/client/{shop-C3wM0Hr4.mjs → shop-Rx_gEMK8.mjs} +3 -3
- package/dist/client/{shop-commerce-34YvcpbX.mjs → shop-commerce-D8evQnMT.mjs} +53 -16
- package/dist/client/{shop-commerce-store-B7xHksOs.mjs → shop-commerce-store-C9PcsSTj.mjs} +22 -5
- package/dist/client/{shop-discount-apply.state-BiBnozfO.mjs → shop-discount-apply.state-D5CtGfJI.mjs} +2 -2
- package/dist/client/{shop.client-C0v88nLd.mjs → shop.client-D4lzQ9oY.mjs} +17 -39
- package/dist/client/{shopShared-Ct-BRNez.mjs → shopShared-BVbq7Nm-.mjs} +2 -2
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/src-Al4ooTl_.mjs +164 -0
- package/dist/client/{src-CCtanNlD.mjs → src-ZSqRK3dD.mjs} +345 -92
- package/dist/client/{timetableModel-lhE29TNT.mjs → timetableModel-BQJrSK0K.mjs} +205 -80
- package/dist/client/{shop-add-feedback-DvC2kP1K.mjs → urlParams-C2QHo1Pa.mjs} +1 -42
- package/dist/client/{useAvailableSlots-BelJviOT.mjs → useAvailableSlots-Dm3lKJKR.mjs} +3 -24
- package/dist/client/{useDiscountCodeUi-rQRE1-Ho.mjs → useDiscountCodeUi-klgfGn7f.mjs} +1 -1
- package/dist/client/{useEventPagination-C4rS2Xxl.mjs → useEventPagination-Jnjt7_ly.mjs} +8 -8
- package/dist/client/{view-LJVHVqsy.mjs → view-CC_yQLSA.mjs} +4 -4
- package/dist/client/{wizardSteps-CNDsxeJH.mjs → wizardSteps-BliJOzEX.mjs} +2512 -675
- package/dist/preview-next/before-render.mjs +1 -0
- package/dist/preview-next/client/{LocationPickerEnvironment-BHAT81Wx.mjs → LocationPickerEnvironment-BW3dRFIv.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-B52hkdIZ.mjs → MapLibreEditMap-Db9BHyXh.mjs} +2 -2
- package/dist/preview-next/client/{PageSectionToolbar-C4TtBPN-.mjs → PageSectionToolbar-BhL0uADo.mjs} +4 -4
- package/dist/preview-next/client/{PreviewEditorSidebar-D6fkE59-.mjs → PreviewEditorSidebar-Ct8eIm0i.mjs} +8 -7
- package/dist/preview-next/client/{PreviewEditorUI-amcDlj0O.mjs → PreviewEditorUI-BS32G4V9.mjs} +5 -5
- package/dist/preview-next/client/{PreviewShell-DeQjx4zk.mjs → PreviewShell-RL0WfZXD.mjs} +7 -7
- package/dist/preview-next/client/{SdkPreviewModeRuntime-Cx0SXnoX.mjs → SdkPreviewModeRuntime-MK_gHeGy.mjs} +39 -7
- package/dist/preview-next/client/{lucide-react-McYZeSMb.mjs → lucide-react-00FF_oar.mjs} +13 -1
- package/dist/preview-next/client/{previewAssistantSlot-aqpU34WI.mjs → previewAssistantSlot-CQyS8pcq.mjs} +10318 -3719
- package/dist/preview-next/client/{previewChromeRoot-D3Gy_Rs0.mjs → previewChromeRoot-BSxp3Mfu.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-Dzx_RrN7.mjs → sdk-runtime-DKnTzy74.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-LHedw83e.mjs → siteStyleAccess-BlmbvbLN.mjs} +37 -25
- package/dist/preview-next/client/{useAutosaveStatus-DpSd9aVk.mjs → useAutosaveStatus-D-7GwZOQ.mjs} +1 -1
- package/dist/preview-next/client/{useOpenBlockForSetup-BGZn5AT1.mjs → useOpenBlockForSetup-BNZtGM5g.mjs} +2 -2
- package/dist/preview-next/container-responsive.css +292 -170
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-DnL-FgSV.mjs → route-contract-R3PcMmax.mjs} +114 -37
- package/dist/server/{Block.shared-BEbq6EwO.mjs → Block.shared-CniF9tSu.mjs} +5 -5
- package/dist/server/{ThemeScopeCore-DFEM1a85.mjs → ThemeScopeCore-BQWsnGT6.mjs} +133 -120
- package/dist/server/{accessibleSurfaces-CM3QANtw.mjs → accessibleSurfaces-WPzUAHp4.mjs} +33 -2
- package/dist/server/accordions-By_0Ykks.mjs +111 -0
- package/dist/server/{bindings-Bly0dRs7.mjs → bindings-DxojjtK3.mjs} +7 -7
- package/dist/server/{client-CGJ2ztYp.mjs → client-CDndhbYO.mjs} +1412 -1307
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/constants-VyF5nEhL.mjs +1474 -0
- package/dist/server/{customCss-BZ8YSrQg.mjs → customCss-C9kgPHvr.mjs} +41 -5
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-BkK1w3QQ.mjs → loadContent-BKstMBmX.mjs} +7 -4
- package/dist/server/{loadPage-DTLe0FEs.mjs → loadPage-IgNnZaqr.mjs} +3 -3
- package/dist/server/{lookMediaFrame-CaH018pK.mjs → lookMediaFrame-TFjgNG61.mjs} +74 -18
- package/dist/server/manifest.mjs +36 -25
- package/dist/server/{mapLocation-BM5WX7FY.mjs → mapLocation-MDDSubTp.mjs} +1 -1
- package/dist/server/media-BRmYrnzb.mjs +31 -0
- package/dist/server/{media-luf7RF22.mjs → media-gvfIw3z8.mjs} +2 -31
- package/dist/server/{navigation-BcNfYYuu.mjs → navigation-quBYlSKD.mjs} +2 -2
- package/dist/server/navigation.mjs +1 -1
- package/dist/server/next.mjs +170 -104
- package/dist/server/{overrideResolution-Uy9Zp2Ks.mjs → overrideResolution-CCaAPpIa.mjs} +1 -1
- package/dist/server/page-converter.mjs +3 -3
- package/dist/server/{pageRenderPlan-JzxBnqfV.mjs → pageRenderPlan-B7iULvKe.mjs} +15 -12
- package/dist/server/{pageRuntimeSupport-DyNSd2Yj.mjs → pageRuntimeSupport-BytMroxn.mjs} +9 -5
- package/dist/server/{pageShared-DU4ETFPS.mjs → pageShared-Dcs_XTIO.mjs} +836 -624
- package/dist/server/{parseThemeForPersistence-DOsfofCy.mjs → parseThemeForPersistence-Bihl4W5K.mjs} +3 -2
- package/dist/server/{portal-B4JVkdjc.mjs → portal-CMW_b9mG.mjs} +62 -46
- package/dist/server/portal.mjs +3 -3
- package/dist/server/portalQuestions-oUyohgL9.mjs +225 -0
- package/dist/server/{prebuild-8jNtDXmS.mjs → prebuild-agaH-vZV.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-xeMG42aw.mjs → prefetchBlockData-DwpRjqw4.mjs} +5 -3
- package/dist/server/{registry-DH1VrsCl.mjs → registry-DM9dHfDC.mjs} +582 -526
- package/dist/server/rendering/components/pageShared.mjs +1 -1
- package/dist/server/rendering/helpers/loadPage.mjs +1 -1
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
- package/dist/server/rendering/server.mjs +4 -4
- package/dist/server/rendering.mjs +10 -9
- package/dist/server/{resolveBlockData-BN8tweTx.mjs → resolveBlockData-CinHGf8l.mjs} +39 -31
- package/dist/server/{resolveButtonColourStates--6yJp9Tq.mjs → resolveButtonColourStates-B0O1IM16.mjs} +2 -1028
- package/dist/server/{resolvePageContent-DnM16_f9.mjs → resolvePageContent-BWKUZUIn.mjs} +1 -1
- package/dist/server/{responseMedia-F-ElH2Rd.mjs → responseMedia-IfH65QAH.mjs} +57 -2
- package/dist/server/routing.mjs +1 -1
- package/dist/server/{schema-BpsqaSSU.mjs → schema-CwfxQjc4.mjs} +10 -113
- package/dist/server/server.mjs +3 -3
- package/dist/server/{servicePageContent-B-FezJmH.mjs → servicePageContent-BBBhOtdE.mjs} +31 -26
- package/dist/server/theme-bridge.mjs +3 -2
- package/dist/server/theme.mjs +2 -2
- package/dist/server/{three-pass-converter-39SXCCnh.mjs → three-pass-converter-DPaUPTfl.mjs} +34 -16
- package/dist/server/titleSourceSchema-NhK6azFS.mjs +2018 -0
- package/dist/server/typeGuards-CTW_9AXq.mjs +413 -0
- package/dist/server/types-BKaBZFjD.mjs +1085 -0
- package/dist/server/{validation-3jOzYdPL.mjs → validation-DG5jX3jH.mjs} +70 -17
- package/dist/server/{version-8t0o6_jd.mjs → version-CipbxPHL.mjs} +1 -1
- package/dist/server/video-Cdr3wh-q.mjs +272 -0
- package/dist/styles/index.css +3446 -3796
- package/package.json +2 -1
- package/dist/_dts/index-DVSipdrT.d.ts +0 -101
- package/dist/client/TabBarFragment-DlKQRhP4.mjs +0 -56
- package/dist/client/checkoutRoute-DKlZRNZD.mjs +0 -22
- package/dist/client/constants-4o4_hl34.mjs +0 -6
- package/dist/client/creditProducts-BQ1t1erI.mjs +0 -266
- package/dist/client/formatDate-CTEN7gxW.mjs +0 -26
- package/dist/server/constants-Cj7hfbrA.mjs +0 -41
- package/dist/server/richTextSchema-QLaQrbII.mjs +0 -212
- package/dist/server/titleSourceSchema-Cu-3PRvv.mjs +0 -122
|
@@ -0,0 +1,2018 @@
|
|
|
1
|
+
import { I as CSS_LOADING_FUNCTIONS, L as callsCssLoadingFunction, R as staysInsideDeclaration, g as VARIANT_ROLES, t as DEFAULT_VARIANT_ALIAS_ID } from "./types-BKaBZFjD.mjs";
|
|
2
|
+
import { t as accordionIconSchema } from "./accordions-By_0Ykks.mjs";
|
|
3
|
+
import { n as isRecord, p as isSafeRichTextHref, s as customLayoutSizeProblem } from "./typeGuards-CTW_9AXq.mjs";
|
|
4
|
+
import { a as hasOwn, n as getVideoEmbed, o as nodePropEntries, t as VIDEO_ASPECT_RATIO_PATTERN } from "./video-Cdr3wh-q.mjs";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region ../blocks/src/system/node/validation-constants.ts
|
|
7
|
+
/**
|
|
8
|
+
* Constants for validating declarative node layouts.
|
|
9
|
+
*
|
|
10
|
+
* These whitelists define which node types and transform IDs
|
|
11
|
+
* are allowed in custom block layouts.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Valid node types for declarative layouts.
|
|
15
|
+
*
|
|
16
|
+
* This whitelist defines which component types can be used in
|
|
17
|
+
* SdkCustomBlock.layout definitions. Node types not in this list
|
|
18
|
+
* will be rejected during validation.
|
|
19
|
+
*/
|
|
20
|
+
const ALLOWED_NODE_TYPES = [
|
|
21
|
+
"div",
|
|
22
|
+
"figure",
|
|
23
|
+
"section",
|
|
24
|
+
"headerSection",
|
|
25
|
+
"stack",
|
|
26
|
+
"inline",
|
|
27
|
+
"grid",
|
|
28
|
+
"text",
|
|
29
|
+
"richText",
|
|
30
|
+
"media",
|
|
31
|
+
"videoEmbed",
|
|
32
|
+
"icon",
|
|
33
|
+
"feature-card-icon",
|
|
34
|
+
"svg",
|
|
35
|
+
"button",
|
|
36
|
+
"link",
|
|
37
|
+
"carousel",
|
|
38
|
+
"accordion",
|
|
39
|
+
"accordionItem",
|
|
40
|
+
"form",
|
|
41
|
+
"booking-form",
|
|
42
|
+
"weekly-slot-availability",
|
|
43
|
+
"event-registration",
|
|
44
|
+
"event-spotlight",
|
|
45
|
+
"event-listing",
|
|
46
|
+
"event-calendar",
|
|
47
|
+
"offerings-preview",
|
|
48
|
+
"event-combined",
|
|
49
|
+
"shop",
|
|
50
|
+
"product-list",
|
|
51
|
+
"product-detail",
|
|
52
|
+
"cart",
|
|
53
|
+
"checkout",
|
|
54
|
+
"gifting"
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Valid transform IDs for declarative layouts.
|
|
58
|
+
*
|
|
59
|
+
* This whitelist defines which transforms can be referenced in
|
|
60
|
+
* $bind.transforms within custom block layouts. Transform IDs
|
|
61
|
+
* not in this list will be rejected during validation.
|
|
62
|
+
*/
|
|
63
|
+
const ALLOWED_TRANSFORM_IDS = [
|
|
64
|
+
"string.uppercase",
|
|
65
|
+
"value.fallback",
|
|
66
|
+
"date.formatShort",
|
|
67
|
+
"array.length",
|
|
68
|
+
"value.jsonArray",
|
|
69
|
+
"value.csv",
|
|
70
|
+
"array.marqueeLoop",
|
|
71
|
+
"value.mapToken",
|
|
72
|
+
"layout.maxWidthClass",
|
|
73
|
+
"layout.headerRootClass",
|
|
74
|
+
"layout.headerRootStyle",
|
|
75
|
+
"layout.headerSectionBackground",
|
|
76
|
+
"layout.footerRootStyle",
|
|
77
|
+
"ui.headerNavLinkClass",
|
|
78
|
+
"ui.headingClassFromAlignment",
|
|
79
|
+
"ui.bodyClassFromAlignment",
|
|
80
|
+
"ui.stackAlignFromAlignment",
|
|
81
|
+
"ui.sectionStateTone",
|
|
82
|
+
"ui.heroContentWrapperClass",
|
|
83
|
+
"ui.heroCtaJustify",
|
|
84
|
+
"ui.heroStackJustifyFromVerticalAlignment",
|
|
85
|
+
"ui.heroGridClassFromVerticalAlignment",
|
|
86
|
+
"ui.conditionalClass",
|
|
87
|
+
"ui.twoColumnContainerClass",
|
|
88
|
+
"ui.twoColumnFlexBasis",
|
|
89
|
+
"ui.imageGalleryFilterClass",
|
|
90
|
+
"ui.imageGalleryTileClass",
|
|
91
|
+
"ui.imageGalleryTileStyle",
|
|
92
|
+
"ui.imageGalleryMarqueeTileStyle",
|
|
93
|
+
"ui.imageGalleryMarqueeDuration",
|
|
94
|
+
"ui.imageGalleryMarqueeDirection",
|
|
95
|
+
"ui.imageFragmentClass",
|
|
96
|
+
"ui.imageFragmentSize",
|
|
97
|
+
"media.fromUrl",
|
|
98
|
+
"background.resolveStyle",
|
|
99
|
+
"background.resolveColorsStyle",
|
|
100
|
+
"background.resolveFrameClassName",
|
|
101
|
+
"background.resolveImageStyle",
|
|
102
|
+
"background.resolveImageClassName",
|
|
103
|
+
"background.resolveOverlayStyle",
|
|
104
|
+
"links.resolve",
|
|
105
|
+
"links.label",
|
|
106
|
+
"content.interpolateRichTextTokens",
|
|
107
|
+
"boxStyles.spacing",
|
|
108
|
+
"boxStyles.semanticGap",
|
|
109
|
+
"boxStyles.semanticGapValue",
|
|
110
|
+
"containerStyles.resolveBoxClassName"
|
|
111
|
+
];
|
|
112
|
+
/**
|
|
113
|
+
* Set for O(1) lookup of allowed node types.
|
|
114
|
+
*/
|
|
115
|
+
const ALLOWED_NODE_TYPES_SET = new Set(ALLOWED_NODE_TYPES);
|
|
116
|
+
/**
|
|
117
|
+
* Set for O(1) lookup of allowed transform IDs.
|
|
118
|
+
*/
|
|
119
|
+
const ALLOWED_TRANSFORM_IDS_SET = new Set(ALLOWED_TRANSFORM_IDS);
|
|
120
|
+
/** The z-index rule in words, for the generator prompt and validation hints. */
|
|
121
|
+
const LAYOUT_Z_INDEX_RULE = `z-index from -10 to 10`;
|
|
122
|
+
const MAX_CSS_VALUE_LENGTH = 300;
|
|
123
|
+
/**
|
|
124
|
+
* Inline style properties a custom-block layout may set: layout, spacing, type,
|
|
125
|
+
* colour, border and simple effects. Left out on purpose: `content`,
|
|
126
|
+
* `animation`, masks, border images, `list-style-image` and anything else
|
|
127
|
+
* whose job is to load a resource or add text.
|
|
128
|
+
*/
|
|
129
|
+
const STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
130
|
+
"display",
|
|
131
|
+
"position",
|
|
132
|
+
"top",
|
|
133
|
+
"right",
|
|
134
|
+
"bottom",
|
|
135
|
+
"left",
|
|
136
|
+
"inset",
|
|
137
|
+
"insetBlock",
|
|
138
|
+
"insetInline",
|
|
139
|
+
"zIndex",
|
|
140
|
+
"isolation",
|
|
141
|
+
"overflow",
|
|
142
|
+
"overflowX",
|
|
143
|
+
"overflowY",
|
|
144
|
+
"overflowWrap",
|
|
145
|
+
"visibility",
|
|
146
|
+
"boxSizing",
|
|
147
|
+
"aspectRatio",
|
|
148
|
+
"objectFit",
|
|
149
|
+
"objectPosition",
|
|
150
|
+
"verticalAlign",
|
|
151
|
+
"cursor",
|
|
152
|
+
"float",
|
|
153
|
+
"clear",
|
|
154
|
+
"pointerEvents",
|
|
155
|
+
"userSelect",
|
|
156
|
+
"clipPath",
|
|
157
|
+
"flex",
|
|
158
|
+
"flexBasis",
|
|
159
|
+
"flexDirection",
|
|
160
|
+
"flexFlow",
|
|
161
|
+
"flexGrow",
|
|
162
|
+
"flexShrink",
|
|
163
|
+
"flexWrap",
|
|
164
|
+
"order",
|
|
165
|
+
"alignContent",
|
|
166
|
+
"alignItems",
|
|
167
|
+
"alignSelf",
|
|
168
|
+
"justifyContent",
|
|
169
|
+
"justifyItems",
|
|
170
|
+
"justifySelf",
|
|
171
|
+
"placeContent",
|
|
172
|
+
"placeItems",
|
|
173
|
+
"placeSelf",
|
|
174
|
+
"gap",
|
|
175
|
+
"rowGap",
|
|
176
|
+
"columnGap",
|
|
177
|
+
"gridArea",
|
|
178
|
+
"gridAutoColumns",
|
|
179
|
+
"gridAutoFlow",
|
|
180
|
+
"gridAutoRows",
|
|
181
|
+
"gridColumn",
|
|
182
|
+
"gridColumnEnd",
|
|
183
|
+
"gridColumnStart",
|
|
184
|
+
"gridRow",
|
|
185
|
+
"gridRowEnd",
|
|
186
|
+
"gridRowStart",
|
|
187
|
+
"gridTemplateAreas",
|
|
188
|
+
"gridTemplateColumns",
|
|
189
|
+
"gridTemplateRows",
|
|
190
|
+
"columns",
|
|
191
|
+
"columnCount",
|
|
192
|
+
"columnWidth",
|
|
193
|
+
"width",
|
|
194
|
+
"height",
|
|
195
|
+
"minWidth",
|
|
196
|
+
"minHeight",
|
|
197
|
+
"maxWidth",
|
|
198
|
+
"maxHeight",
|
|
199
|
+
"margin",
|
|
200
|
+
"marginTop",
|
|
201
|
+
"marginRight",
|
|
202
|
+
"marginBottom",
|
|
203
|
+
"marginLeft",
|
|
204
|
+
"marginBlock",
|
|
205
|
+
"marginInline",
|
|
206
|
+
"padding",
|
|
207
|
+
"paddingTop",
|
|
208
|
+
"paddingRight",
|
|
209
|
+
"paddingBottom",
|
|
210
|
+
"paddingLeft",
|
|
211
|
+
"paddingBlock",
|
|
212
|
+
"paddingInline",
|
|
213
|
+
"color",
|
|
214
|
+
"fontFamily",
|
|
215
|
+
"fontSize",
|
|
216
|
+
"fontStyle",
|
|
217
|
+
"fontWeight",
|
|
218
|
+
"fontVariant",
|
|
219
|
+
"fontVariantNumeric",
|
|
220
|
+
"fontFeatureSettings",
|
|
221
|
+
"letterSpacing",
|
|
222
|
+
"lineHeight",
|
|
223
|
+
"textAlign",
|
|
224
|
+
"textDecoration",
|
|
225
|
+
"textDecorationColor",
|
|
226
|
+
"textDecorationLine",
|
|
227
|
+
"textDecorationStyle",
|
|
228
|
+
"textDecorationThickness",
|
|
229
|
+
"textUnderlineOffset",
|
|
230
|
+
"textTransform",
|
|
231
|
+
"textIndent",
|
|
232
|
+
"textOverflow",
|
|
233
|
+
"textShadow",
|
|
234
|
+
"textWrap",
|
|
235
|
+
"whiteSpace",
|
|
236
|
+
"wordBreak",
|
|
237
|
+
"wordSpacing",
|
|
238
|
+
"hyphens",
|
|
239
|
+
"listStyle",
|
|
240
|
+
"listStyleType",
|
|
241
|
+
"listStylePosition",
|
|
242
|
+
"WebkitTextFillColor",
|
|
243
|
+
"borderCollapse",
|
|
244
|
+
"background",
|
|
245
|
+
"backgroundColor",
|
|
246
|
+
"backgroundImage",
|
|
247
|
+
"backgroundSize",
|
|
248
|
+
"backgroundPosition",
|
|
249
|
+
"backgroundRepeat",
|
|
250
|
+
"backgroundClip",
|
|
251
|
+
"WebkitBackgroundClip",
|
|
252
|
+
"backgroundAttachment",
|
|
253
|
+
"backgroundBlendMode",
|
|
254
|
+
"opacity",
|
|
255
|
+
"mixBlendMode",
|
|
256
|
+
"border",
|
|
257
|
+
"borderTop",
|
|
258
|
+
"borderRight",
|
|
259
|
+
"borderBottom",
|
|
260
|
+
"borderLeft",
|
|
261
|
+
"borderColor",
|
|
262
|
+
"borderStyle",
|
|
263
|
+
"borderWidth",
|
|
264
|
+
"borderTopColor",
|
|
265
|
+
"borderRightColor",
|
|
266
|
+
"borderBottomColor",
|
|
267
|
+
"borderLeftColor",
|
|
268
|
+
"borderTopWidth",
|
|
269
|
+
"borderRightWidth",
|
|
270
|
+
"borderBottomWidth",
|
|
271
|
+
"borderLeftWidth",
|
|
272
|
+
"borderRadius",
|
|
273
|
+
"borderTopLeftRadius",
|
|
274
|
+
"borderTopRightRadius",
|
|
275
|
+
"borderBottomLeftRadius",
|
|
276
|
+
"borderBottomRightRadius",
|
|
277
|
+
"outline",
|
|
278
|
+
"outlineColor",
|
|
279
|
+
"outlineOffset",
|
|
280
|
+
"outlineStyle",
|
|
281
|
+
"outlineWidth",
|
|
282
|
+
"boxShadow",
|
|
283
|
+
"transform",
|
|
284
|
+
"transformOrigin",
|
|
285
|
+
"translate",
|
|
286
|
+
"rotate",
|
|
287
|
+
"scale",
|
|
288
|
+
"filter",
|
|
289
|
+
"backdropFilter",
|
|
290
|
+
"transition",
|
|
291
|
+
"transitionProperty",
|
|
292
|
+
"transitionDuration",
|
|
293
|
+
"transitionTimingFunction",
|
|
294
|
+
"transitionDelay",
|
|
295
|
+
"fill",
|
|
296
|
+
"stroke",
|
|
297
|
+
"strokeWidth",
|
|
298
|
+
"fillOpacity",
|
|
299
|
+
"strokeOpacity",
|
|
300
|
+
"strokeLinecap",
|
|
301
|
+
"strokeLinejoin",
|
|
302
|
+
"strokeDasharray"
|
|
303
|
+
]);
|
|
304
|
+
/** Properties whose value is a colour, which `value.mapToken` can produce. */
|
|
305
|
+
const COLOR_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
306
|
+
"color",
|
|
307
|
+
"backgroundColor",
|
|
308
|
+
"borderColor",
|
|
309
|
+
"borderTopColor",
|
|
310
|
+
"borderRightColor",
|
|
311
|
+
"borderBottomColor",
|
|
312
|
+
"borderLeftColor",
|
|
313
|
+
"outlineColor",
|
|
314
|
+
"textDecorationColor",
|
|
315
|
+
"fill",
|
|
316
|
+
"stroke",
|
|
317
|
+
"WebkitTextFillColor"
|
|
318
|
+
]);
|
|
319
|
+
/** CSS functions a value may call. None of them fetches anything. */
|
|
320
|
+
const CSS_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
321
|
+
"var",
|
|
322
|
+
"calc",
|
|
323
|
+
"min",
|
|
324
|
+
"max",
|
|
325
|
+
"clamp",
|
|
326
|
+
"minmax",
|
|
327
|
+
"repeat",
|
|
328
|
+
"fit-content",
|
|
329
|
+
"rgb",
|
|
330
|
+
"rgba",
|
|
331
|
+
"hsl",
|
|
332
|
+
"hsla",
|
|
333
|
+
"hwb",
|
|
334
|
+
"lab",
|
|
335
|
+
"lch",
|
|
336
|
+
"oklab",
|
|
337
|
+
"oklch",
|
|
338
|
+
"color",
|
|
339
|
+
"color-mix",
|
|
340
|
+
"linear-gradient",
|
|
341
|
+
"radial-gradient",
|
|
342
|
+
"conic-gradient",
|
|
343
|
+
"repeating-linear-gradient",
|
|
344
|
+
"repeating-radial-gradient",
|
|
345
|
+
"repeating-conic-gradient",
|
|
346
|
+
"translate",
|
|
347
|
+
"translatex",
|
|
348
|
+
"translatey",
|
|
349
|
+
"translatez",
|
|
350
|
+
"translate3d",
|
|
351
|
+
"rotate",
|
|
352
|
+
"rotatex",
|
|
353
|
+
"rotatey",
|
|
354
|
+
"rotatez",
|
|
355
|
+
"rotate3d",
|
|
356
|
+
"scale",
|
|
357
|
+
"scalex",
|
|
358
|
+
"scaley",
|
|
359
|
+
"scale3d",
|
|
360
|
+
"skew",
|
|
361
|
+
"skewx",
|
|
362
|
+
"skewy",
|
|
363
|
+
"matrix",
|
|
364
|
+
"perspective",
|
|
365
|
+
"blur",
|
|
366
|
+
"brightness",
|
|
367
|
+
"contrast",
|
|
368
|
+
"drop-shadow",
|
|
369
|
+
"grayscale",
|
|
370
|
+
"hue-rotate",
|
|
371
|
+
"invert",
|
|
372
|
+
"opacity",
|
|
373
|
+
"saturate",
|
|
374
|
+
"sepia",
|
|
375
|
+
"cubic-bezier",
|
|
376
|
+
"steps",
|
|
377
|
+
"inset",
|
|
378
|
+
"circle",
|
|
379
|
+
"ellipse",
|
|
380
|
+
"polygon"
|
|
381
|
+
]);
|
|
382
|
+
/** Values that keep an element inside its block. `fixed` and `sticky` leave it. */
|
|
383
|
+
const POSITIONS = /* @__PURE__ */ new Set([
|
|
384
|
+
"static",
|
|
385
|
+
"relative",
|
|
386
|
+
"absolute"
|
|
387
|
+
]);
|
|
388
|
+
const CUSTOM_PROPERTY = /^--[A-Za-z][A-Za-z0-9_-]*$/;
|
|
389
|
+
/**
|
|
390
|
+
* On top of the shared rule that a value stays inside its declaration
|
|
391
|
+
* (`staysInsideDeclaration` in theme-core, which the renderer applies too), a
|
|
392
|
+
* layout value may not hold `@`, `!` (so no `!important`), a backtick or a
|
|
393
|
+
* comment, and its quotes have to pair up even where a string would close
|
|
394
|
+
* later. Quotes themselves are fine: font names need them.
|
|
395
|
+
*/
|
|
396
|
+
const LAYOUT_ONLY_STRUCTURE = /[@!`]|\/\*/;
|
|
397
|
+
const unpairedQuote = (value) => (value.match(/"/g) ?? []).length % 2 === 1 || (value.match(/'/g) ?? []).length % 2 === 1;
|
|
398
|
+
/** A semicolon inside a quoted string stays in its declaration, but nothing a layout writes needs one. */
|
|
399
|
+
const addsCssStructure = (value) => !staysInsideDeclaration(value) || value.includes(";") || LAYOUT_ONLY_STRUCTURE.test(value);
|
|
400
|
+
/** Turn `background-image` into `backgroundImage`. Custom properties keep their name. */
|
|
401
|
+
const toCamelCase = (property) => property.startsWith("--") ? property : property.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
402
|
+
const isAllowedStyleProperty = (property) => {
|
|
403
|
+
const name = toCamelCase(property);
|
|
404
|
+
return CUSTOM_PROPERTY.test(name) || STYLE_PROPERTIES.has(name);
|
|
405
|
+
};
|
|
406
|
+
/** Checks on the text of a value, in order, each with the reason it fails. */
|
|
407
|
+
const TEXT_PROBLEMS = [
|
|
408
|
+
[(value) => value.length > MAX_CSS_VALUE_LENGTH, `the value is longer than ${MAX_CSS_VALUE_LENGTH} characters`],
|
|
409
|
+
[(value) => /[^\x20-\x7e]/.test(value), "the value contains characters outside plain ASCII"],
|
|
410
|
+
[unpairedQuote, "the value has a quote that is not closed"],
|
|
411
|
+
[addsCssStructure, "the value contains CSS syntax (; { } < > \\ @ ! or a comment) that could add other declarations"]
|
|
412
|
+
];
|
|
413
|
+
/** Why a value is unsafe on any property, or null when it is fine. */
|
|
414
|
+
function cssValueProblem(value) {
|
|
415
|
+
if (typeof value === "number") return Number.isFinite(value) ? null : "the number is not finite";
|
|
416
|
+
if (typeof value !== "string") return "a style value must be a string or a number";
|
|
417
|
+
const textProblem = TEXT_PROBLEMS.find(([fails]) => fails(value));
|
|
418
|
+
if (textProblem) return textProblem[1];
|
|
419
|
+
return functionProblem(value);
|
|
420
|
+
}
|
|
421
|
+
function functionProblem(value) {
|
|
422
|
+
const unknown = Array.from(value.matchAll(/([A-Za-z0-9-]*)\s*\(/g)).map((match) => (match[1] ?? "").toLowerCase()).find((name) => name !== "" && !CSS_FUNCTIONS.has(name));
|
|
423
|
+
if (unknown === void 0) return null;
|
|
424
|
+
return CSS_LOADING_FUNCTIONS.has(unknown) ? `${unknown}() is not allowed in a layout. Use a media field with a media node or a background.* transform so the platform serves the file` : `the CSS function ${unknown}() is not allowed`;
|
|
425
|
+
}
|
|
426
|
+
function zIndexProblem(value) {
|
|
427
|
+
const layer = typeof value === "number" ? value : typeof value === "string" && /^-?\d+$/.test(value.trim()) ? Number(value) : NaN;
|
|
428
|
+
return Number.isInteger(layer) && Math.abs(layer) <= 10 || value === "auto" ? null : `zIndex must be a whole number from -10 to 10, so the block cannot sit above the site header or other blocks' overlays`;
|
|
429
|
+
}
|
|
430
|
+
function positionProblem(value) {
|
|
431
|
+
return typeof value === "string" && POSITIONS.has(value.trim().toLowerCase()) ? null : "position must be static, relative or absolute. fixed and sticky would take the element out of its block";
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Why a declaration is unsafe, or null. `property` is camelCase or kebab-case.
|
|
435
|
+
* The same rule applies to a literal and to every string a binding can
|
|
436
|
+
* resolve to.
|
|
437
|
+
*/
|
|
438
|
+
function declarationProblem(property, value) {
|
|
439
|
+
if (!isAllowedStyleProperty(property)) return `the CSS property "${property}" is not on the allowlist for custom-block layouts`;
|
|
440
|
+
const name = toCamelCase(property);
|
|
441
|
+
if (name === "position") return positionProblem(value);
|
|
442
|
+
if (name === "zIndex") return zIndexProblem(value);
|
|
443
|
+
return cssValueProblem(value);
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region ../blocks/src/system/node/layoutGate/classes.ts
|
|
447
|
+
/**
|
|
448
|
+
* Class names a custom-block layout may use (issue 1185).
|
|
449
|
+
*
|
|
450
|
+
* Classes are allowed by what they do, not refused by name. On hosted sites the
|
|
451
|
+
* compiled Tailwind CSS holds every utility the platform's own source uses, and
|
|
452
|
+
* theme-core ships platform classes (`rb-*`, `nav-mobile-overlay`, ...) on
|
|
453
|
+
* every site, so any name a layout writes may match a rule somewhere. A token is
|
|
454
|
+
* therefore allowed only when it is:
|
|
455
|
+
*
|
|
456
|
+
* - a Tailwind utility from a family below, with plain variants, or
|
|
457
|
+
* - the `rb-` spelling of one of those utilities (`rb-md-grid-cols-2`), or one
|
|
458
|
+
* of the platform's text styles (`rb-eyebrow`), or
|
|
459
|
+
* - a block's own class, prefixed `cb-`, which no shipped stylesheet uses, for
|
|
460
|
+
* the block's custom CSS rules to target.
|
|
461
|
+
*
|
|
462
|
+
* Positioning (`fixed`, `sticky`), stacking above the z-index cap, generated
|
|
463
|
+
* content and arbitrary properties have no family here. A test scans the shipped
|
|
464
|
+
* stylesheets for every class that sets `position: fixed/sticky` or a high
|
|
465
|
+
* z-index and checks this rule refuses each one.
|
|
466
|
+
*/
|
|
467
|
+
const MAX_CLASS_NAME_LENGTH = 1e3;
|
|
468
|
+
const CUSTOM_CLASS = /^cb-[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
469
|
+
/** A class a custom block names for its own CSS: `cb-` then kebab-case, e.g. `cb-hero-title`. */
|
|
470
|
+
const isCustomBlockClassName = (name) => CUSTOM_CLASS.test(name);
|
|
471
|
+
/** Platform type styles that only set font, size, spacing and colour, so a custom block can match the theme. */
|
|
472
|
+
const PLATFORM_TEXT_CLASSES = /* @__PURE__ */ new Set([
|
|
473
|
+
"rb-eyebrow",
|
|
474
|
+
"rb-label",
|
|
475
|
+
"rb-caption"
|
|
476
|
+
]);
|
|
477
|
+
/** Responsive, state and structural variants. Nothing that reaches outside the element. */
|
|
478
|
+
const VARIANTS = /* @__PURE__ */ new Set([
|
|
479
|
+
"sm",
|
|
480
|
+
"md",
|
|
481
|
+
"lg",
|
|
482
|
+
"xl",
|
|
483
|
+
"2xl",
|
|
484
|
+
"max-sm",
|
|
485
|
+
"max-md",
|
|
486
|
+
"max-lg",
|
|
487
|
+
"max-xl",
|
|
488
|
+
"hover",
|
|
489
|
+
"focus",
|
|
490
|
+
"focus-visible",
|
|
491
|
+
"focus-within",
|
|
492
|
+
"active",
|
|
493
|
+
"visited",
|
|
494
|
+
"disabled",
|
|
495
|
+
"group-hover",
|
|
496
|
+
"group-focus",
|
|
497
|
+
"group-focus-within",
|
|
498
|
+
"peer-hover",
|
|
499
|
+
"peer-focus",
|
|
500
|
+
"peer-checked",
|
|
501
|
+
"first",
|
|
502
|
+
"last",
|
|
503
|
+
"odd",
|
|
504
|
+
"even",
|
|
505
|
+
"only",
|
|
506
|
+
"empty",
|
|
507
|
+
"first-of-type",
|
|
508
|
+
"last-of-type",
|
|
509
|
+
"motion-safe",
|
|
510
|
+
"motion-reduce",
|
|
511
|
+
"dark",
|
|
512
|
+
"print",
|
|
513
|
+
"placeholder",
|
|
514
|
+
"marker",
|
|
515
|
+
"selection",
|
|
516
|
+
"before",
|
|
517
|
+
"after",
|
|
518
|
+
"open"
|
|
519
|
+
]);
|
|
520
|
+
/** `[&>*]` and `[&_p]`: the element's own children and descendants, never its siblings. */
|
|
521
|
+
const ARBITRARY_VARIANT = /^\[&(?:>|_)[a-z0-9*_.>:-]*\]$/;
|
|
522
|
+
/** `aria-expanded:` and `data-[state=open]:` read the element's own attributes. */
|
|
523
|
+
const OWN_ATTRIBUTE_VARIANT = /^(?:aria-(?:busy|checked|disabled|expanded|hidden|pressed|readonly|required|selected)|data-\[[a-z][a-z0-9-]*(?:=[a-z0-9-]+)?\])$/;
|
|
524
|
+
const isAllowedVariant = (variant) => VARIANTS.has(variant) || ARBITRARY_VARIANT.test(variant) || OWN_ATTRIBUTE_VARIANT.test(variant);
|
|
525
|
+
const SCALE = String.raw`(?:\d+(?:\.\d+)?|\d+\/\d+|px|full|screen|svh|lvh|dvh|svw|lvw|dvw|auto|min|max|fit|none|prose|xs|sm|md|lg|xl|[2-9]xl)`;
|
|
526
|
+
const ARBITRARY = String.raw`\[[^\]\s]+\]`;
|
|
527
|
+
const VALUE = `(?:${SCALE}|${ARBITRARY})`;
|
|
528
|
+
const COLOR = String.raw`(?:inherit|current|transparent|black|white|[a-z]+(?:-\d{2,3})?|[a-z]+[A-Z][A-Za-z]*)(?:\/\d{1,3})?|${ARBITRARY}`;
|
|
529
|
+
/** Utility families, without variants, `-` or `!`. Each one stays inside its element. */
|
|
530
|
+
const UTILITY_FAMILIES = [
|
|
531
|
+
/^(?:block|inline-block|inline|flex|inline-flex|grid|inline-grid|hidden|contents|flow-root|list-item|table|table-row|table-cell|table-caption|visible|invisible|collapse|sr-only|not-sr-only)$/,
|
|
532
|
+
/^(?:static|relative|absolute|isolate|isolation-auto)$/,
|
|
533
|
+
/^(?:group|peer)$/,
|
|
534
|
+
new RegExp(`^(?:inset|inset-x|inset-y|top|right|bottom|left|start|end)-${VALUE}$`),
|
|
535
|
+
/^(?:box-border|box-content|container|float-(?:left|right|start|end|none)|clear-(?:left|right|both|none|start|end))$/,
|
|
536
|
+
/^overflow(?:-[xy])?-(?:auto|hidden|clip|visible|scroll)$/,
|
|
537
|
+
/^overscroll(?:-[xy])?-(?:auto|contain|none)$/,
|
|
538
|
+
/^flex-(?:row|row-reverse|col|col-reverse|wrap|wrap-reverse|nowrap|1|auto|initial|none)$/,
|
|
539
|
+
new RegExp(`^(?:grow|shrink|flex-grow|flex-shrink)(?:-0)?$|^(?:basis|order)-${VALUE}$`),
|
|
540
|
+
/^order-(?:first|last|none)$/,
|
|
541
|
+
new RegExp(`^(?:grid-cols|grid-rows|col-span|row-span|col-start|col-end|row-start|row-end|auto-cols|auto-rows|columns)-${VALUE}$`),
|
|
542
|
+
/^(?:col|row)-(?:auto|span-full)$/,
|
|
543
|
+
/^grid-flow-(?:row|col|dense|row-dense|col-dense)$/,
|
|
544
|
+
new RegExp(`^(?:gap|gap-x|gap-y|space-x|space-y)-${VALUE}$`),
|
|
545
|
+
/^(?:space-[xy]-reverse)$/,
|
|
546
|
+
/^(?:justify|justify-items|justify-self|items|content|self|place-content|place-items|place-self)-(?:start|end|center|between|around|evenly|stretch|baseline|normal|auto|left|right|flex-start|flex-end)$/,
|
|
547
|
+
new RegExp(`^(?:p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me)-${VALUE}$`),
|
|
548
|
+
new RegExp(`^(?:w|h|min-w|min-h|max-w|max-h|size)-${VALUE}$`),
|
|
549
|
+
/^max-w-screen-(?:sm|md|lg|xl|2xl)$/,
|
|
550
|
+
/^text-(?:xs|sm|base|lg|xl|[2-9]xl|left|center|right|justify|start|end|ellipsis|clip|wrap|nowrap|balance|pretty)$/,
|
|
551
|
+
/^font-(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|sans|serif|mono|body|heading|display)$/,
|
|
552
|
+
new RegExp(`^font-${ARBITRARY}$`),
|
|
553
|
+
/^(?:italic|not-italic|uppercase|lowercase|capitalize|normal-case|underline|overline|line-through|no-underline|truncate|antialiased|subpixel-antialiased|ordinal|tabular-nums|lining-nums|oldstyle-nums|proportional-nums|slashed-zero|diagonal-fractions|stacked-fractions)$/,
|
|
554
|
+
new RegExp(`^(?:tracking|leading|indent|underline-offset|decoration|line-clamp)-${VALUE}$`),
|
|
555
|
+
/^(?:tracking|leading)-(?:tighter|tight|snug|normal|relaxed|loose|wide|wider|widest|none)$/,
|
|
556
|
+
/^(?:decoration)-(?:solid|double|dotted|dashed|wavy|auto|from-font)$/,
|
|
557
|
+
/^whitespace-(?:normal|nowrap|pre|pre-line|pre-wrap|break-spaces)$/,
|
|
558
|
+
/^break-(?:normal|words|all|keep|before-\w+|after-\w+|inside-\w+)$/,
|
|
559
|
+
/^hyphens-(?:none|manual|auto)$/,
|
|
560
|
+
/^align-(?:baseline|top|middle|bottom|text-top|text-bottom|sub|super)$/,
|
|
561
|
+
/^list-(?:none|disc|decimal|inside|outside)$/,
|
|
562
|
+
/^(?:prose|prose-(?:sm|base|lg|xl|2xl|neutral|invert|slate|gray|zinc|stone)|max-w-prose)$/,
|
|
563
|
+
new RegExp(`^(?:bg|text|border|border-[trblxyse]|ring|ring-offset|from|via|to|fill|stroke|outline|decoration|divide|placeholder|accent|caret|shadow)-(?:${COLOR})$`),
|
|
564
|
+
/^stroke-[012]$/,
|
|
565
|
+
/^bg-gradient-to-(?:t|tr|r|br|b|bl|l|tl)$/,
|
|
566
|
+
/^bg-(?:cover|contain|auto|center|top|bottom|left|right|left-top|left-bottom|right-top|right-bottom|no-repeat|repeat|repeat-x|repeat-y|repeat-round|repeat-space|fixed|local|scroll|clip-border|clip-padding|clip-content|clip-text|origin-border|origin-padding|origin-content|none)$/,
|
|
567
|
+
/^border(?:-[trblxyse])?(?:-(?:0|2|4|8))?$/,
|
|
568
|
+
/^border-(?:solid|dashed|dotted|double|hidden|none|collapse|separate)$/,
|
|
569
|
+
new RegExp(`^rounded(?:-(?:t|r|b|l|tl|tr|br|bl|s|e|ss|se|es|ee))?(?:-(?:none|sm|md|lg|xl|2xl|3xl|full|${ARBITRARY}))?$`),
|
|
570
|
+
/^divide-[xy](?:-(?:0|2|4|8|reverse))?$|^divide-(?:solid|dashed|dotted|double|none)$/,
|
|
571
|
+
new RegExp(`^(?:ring|ring-offset|outline|outline-offset)(?:-${VALUE})?$`),
|
|
572
|
+
/^(?:ring-inset|outline-none|outline-dashed|outline-dotted|outline-double)$/,
|
|
573
|
+
new RegExp(`^(?:shadow|drop-shadow|blur|backdrop-blur)(?:-(?:sm|md|lg|xl|2xl|3xl|none|inner|${ARBITRARY}))?$`),
|
|
574
|
+
new RegExp(`^(?:opacity|brightness|contrast|saturate|hue-rotate|backdrop-brightness|backdrop-contrast|backdrop-saturate|backdrop-opacity)-${VALUE}$`),
|
|
575
|
+
/^(?:grayscale|invert|sepia|backdrop-grayscale|backdrop-invert|backdrop-sepia)(?:-0)?$/,
|
|
576
|
+
/^(?:mix-blend|bg-blend)-(?:normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity|plus-lighter)$/,
|
|
577
|
+
/^(?:transform|transform-gpu|transform-none|transform-cpu)$/,
|
|
578
|
+
new RegExp(`^(?:scale|scale-x|scale-y|rotate|translate-x|translate-y|skew-x|skew-y|duration|delay)-${VALUE}$`),
|
|
579
|
+
/^origin-(?:center|top|top-right|right|bottom-right|bottom|bottom-left|left|top-left)$/,
|
|
580
|
+
/^transition(?:-(?:all|colors|opacity|shadow|transform|none))?$/,
|
|
581
|
+
/^ease-(?:linear|in|out|in-out)$/,
|
|
582
|
+
/^animate-(?:none|spin|pulse)$/,
|
|
583
|
+
/^object-(?:cover|contain|fill|none|scale-down|center|top|bottom|left|right|left-top|left-bottom|right-top|right-bottom)$/,
|
|
584
|
+
new RegExp(`^aspect-(?:auto|square|video|${ARBITRARY})$`),
|
|
585
|
+
/^cursor-(?:auto|default|pointer|wait|text|move|help|not-allowed|none|grab|grabbing|zoom-in|zoom-out)$/,
|
|
586
|
+
/^(?:select|pointer-events)-(?:none|auto|text|all)$/,
|
|
587
|
+
/^(?:appearance-none|will-change-(?:auto|scroll|contents|transform)|snap-(?:start|end|center|x|y|mandatory|proximity|none|align-none)|scroll-smooth|scroll-auto|touch-(?:auto|none|manipulation))$/,
|
|
588
|
+
/^table-(?:auto|fixed)$/
|
|
589
|
+
];
|
|
590
|
+
/** `z-0` to `z-10`, `-z-10`, `z-auto` and `z-[5]`. */
|
|
591
|
+
function zUtilityProblem(utility, token) {
|
|
592
|
+
const layer = utility.slice(2).replace(/^\[(-?\d+)\]$/, "$1");
|
|
593
|
+
if (layer === "auto") return null;
|
|
594
|
+
const value = Number(layer);
|
|
595
|
+
return /^-?\d+$/.test(layer) && Math.abs(value) <= 10 ? null : `"${token}" layers the element above the rest of the page. Use z-0 to z-10`;
|
|
596
|
+
}
|
|
597
|
+
/** An arbitrary value holds CSS once its underscores are spaces, so it gets the CSS value rule. */
|
|
598
|
+
function arbitraryValueProblem(utility) {
|
|
599
|
+
const match = /\[([^\]]*)\]/.exec(utility);
|
|
600
|
+
if (!match) return null;
|
|
601
|
+
const problem = cssValueProblem((match[1] ?? "").replace(/_/g, " "));
|
|
602
|
+
return problem === null ? null : `"${utility}": ${problem}`;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* `text-muted-foreground`, `bg-primary-foreground`, `bg-surface-alt`: colour
|
|
606
|
+
* names from other design systems. A visitor's page defines none of them (the
|
|
607
|
+
* theme's colours are the `--tb-*` variables), so the class would do nothing.
|
|
608
|
+
*/
|
|
609
|
+
const HYPHENATED_COLOR_NAME = /^(?:bg|text|border|ring|fill|stroke|outline|decoration|divide|from|via|to)-[a-z]+(?:-[a-z]+)+$/;
|
|
610
|
+
function utilityProblem(utility, token) {
|
|
611
|
+
if (/^z-/.test(utility)) return zUtilityProblem(utility, token);
|
|
612
|
+
if (!UTILITY_FAMILIES.some((family) => family.test(utility))) {
|
|
613
|
+
if (HYPHENATED_COLOR_NAME.test(utility)) return `"${token}" names a colour this site's theme does not define, so it would do nothing. Use a theme colour in style, such as style: { color: "rgb(var(--tb-mutedText))" }`;
|
|
614
|
+
return `"${token}" is not a utility class a custom block may use. Use Tailwind layout, spacing, type, colour and border utilities, or a class starting "cb-" for your own CSS`;
|
|
615
|
+
}
|
|
616
|
+
return arbitraryValueProblem(utility);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* The `rb-` utilities mirror Tailwind's: `rb-md-grid-cols-2` is `md:grid-cols-2`
|
|
620
|
+
* and `rb-z-neg-10` is `-z-10`. Read one back into Tailwind's spelling.
|
|
621
|
+
*/
|
|
622
|
+
function fromRbSpelling(name) {
|
|
623
|
+
const body = name.slice(3);
|
|
624
|
+
const variant = /^(sm|md|lg|xl|2xl|hover)-/.exec(body)?.[1] ?? null;
|
|
625
|
+
return (variant ? body.slice(variant.length + 1) : body).replace(/(^|-)neg-/, "$1");
|
|
626
|
+
}
|
|
627
|
+
/** Why one class token is not allowed, or null. */
|
|
628
|
+
function classTokenProblem(token) {
|
|
629
|
+
if (!/^[A-Za-z0-9_\-:./[\]%(),#&>*!=]+$/.test(token)) return `"${token.slice(0, 60)}" contains characters a class name cannot use`;
|
|
630
|
+
const parts = token.split(/:(?![^[]*\])/);
|
|
631
|
+
const last = parts.pop() ?? "";
|
|
632
|
+
const badVariant = parts.find((variant) => !isAllowedVariant(variant));
|
|
633
|
+
if (badVariant !== void 0) return `"${token}" uses the variant "${badVariant}:", which a custom block cannot use`;
|
|
634
|
+
const bare = last.replace(/^!/, "").replace(/!$/, "");
|
|
635
|
+
if (CUSTOM_CLASS.test(bare) || PLATFORM_TEXT_CLASSES.has(bare)) return null;
|
|
636
|
+
if (bare.startsWith("rb-")) return utilityProblem(fromRbSpelling(bare), token);
|
|
637
|
+
return utilityProblem(bare.replace(/^-/, ""), token);
|
|
638
|
+
}
|
|
639
|
+
/** Why a static class string is not allowed, or null. */
|
|
640
|
+
function classNameProblem(value) {
|
|
641
|
+
if (typeof value !== "string") return "className must be a string";
|
|
642
|
+
if (value.length > MAX_CLASS_NAME_LENGTH) return `className is longer than ${MAX_CLASS_NAME_LENGTH} characters`;
|
|
643
|
+
if (/[^\x20-\x7e]/.test(value)) return "className contains characters outside plain ASCII";
|
|
644
|
+
return value.split(/\s+/).filter(Boolean).map(classTokenProblem).find((problem) => problem !== null) ?? null;
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region ../blocks/src/system/node/layoutGate/transforms.ts
|
|
648
|
+
/**
|
|
649
|
+
* What each layout transform produces, and which of its options end up in
|
|
650
|
+
* that output (issue 1185).
|
|
651
|
+
*
|
|
652
|
+
* A binding in a custom-block layout is judged by its last transform: a
|
|
653
|
+
* `className` takes a binding that ends in a transform producing classes, a
|
|
654
|
+
* `style` one producing a style object, and so on. Options that are copied into
|
|
655
|
+
* the output (`ui.conditionalClass`'s `whenTrue`, `value.mapToken`'s roles) get
|
|
656
|
+
* the same rule as a literal in that slot.
|
|
657
|
+
*
|
|
658
|
+
* The table is keyed by every allowed transform id, so a transform added to the
|
|
659
|
+
* allowlist without a decision here does not compile.
|
|
660
|
+
*/
|
|
661
|
+
const contract = (output, options = "none") => ({
|
|
662
|
+
output,
|
|
663
|
+
options
|
|
664
|
+
});
|
|
665
|
+
const LAYOUT_TRANSFORM_CONTRACTS = {
|
|
666
|
+
"string.uppercase": contract("text"),
|
|
667
|
+
"value.fallback": contract("raw", "fallback"),
|
|
668
|
+
"date.formatShort": contract("text"),
|
|
669
|
+
"array.length": contract("number"),
|
|
670
|
+
"value.jsonArray": contract("text"),
|
|
671
|
+
"value.csv": contract("text"),
|
|
672
|
+
"array.marqueeLoop": contract("array", "plain"),
|
|
673
|
+
"value.mapToken": contract("color", "roles"),
|
|
674
|
+
"layout.maxWidthClass": contract("class", "classes"),
|
|
675
|
+
"layout.headerRootClass": contract("chrome"),
|
|
676
|
+
"layout.headerRootStyle": contract("chrome"),
|
|
677
|
+
"layout.headerSectionBackground": contract("chrome"),
|
|
678
|
+
"layout.footerRootStyle": contract("chrome"),
|
|
679
|
+
"ui.headerNavLinkClass": contract("chrome"),
|
|
680
|
+
"ui.headingClassFromAlignment": contract("class", "classes"),
|
|
681
|
+
"ui.bodyClassFromAlignment": contract("class", "classes"),
|
|
682
|
+
"ui.stackAlignFromAlignment": contract("stackAlign"),
|
|
683
|
+
"ui.sectionStateTone": contract("text"),
|
|
684
|
+
"ui.heroContentWrapperClass": contract("class", "classes"),
|
|
685
|
+
"ui.heroCtaJustify": contract("justify"),
|
|
686
|
+
"ui.heroStackJustifyFromVerticalAlignment": contract("justify"),
|
|
687
|
+
"ui.heroGridClassFromVerticalAlignment": contract("class", "classes"),
|
|
688
|
+
"ui.conditionalClass": contract("class", "classes"),
|
|
689
|
+
"ui.twoColumnContainerClass": contract("class", "classes"),
|
|
690
|
+
"ui.twoColumnFlexBasis": contract("flexBasis", "plain"),
|
|
691
|
+
"ui.imageGalleryFilterClass": contract("class"),
|
|
692
|
+
"ui.imageGalleryTileClass": contract("class"),
|
|
693
|
+
"ui.imageGalleryTileStyle": contract("style"),
|
|
694
|
+
"ui.imageGalleryMarqueeTileStyle": contract("style"),
|
|
695
|
+
"ui.imageGalleryMarqueeDuration": contract("chrome"),
|
|
696
|
+
"ui.imageGalleryMarqueeDirection": contract("chrome"),
|
|
697
|
+
"ui.imageFragmentClass": contract("class", "classes"),
|
|
698
|
+
"ui.imageFragmentSize": contract("mediaSize", "plain"),
|
|
699
|
+
"media.fromUrl": contract("media", "plain"),
|
|
700
|
+
"background.resolveStyle": contract("style", "plain"),
|
|
701
|
+
"background.resolveColorsStyle": contract("style", "plain"),
|
|
702
|
+
"background.resolveFrameClassName": contract("class", "classes"),
|
|
703
|
+
"background.resolveImageStyle": contract("style", "plain"),
|
|
704
|
+
"background.resolveImageClassName": contract("chrome"),
|
|
705
|
+
"background.resolveOverlayStyle": contract("style", "plain"),
|
|
706
|
+
"links.resolve": contract("href"),
|
|
707
|
+
"links.label": contract("text"),
|
|
708
|
+
"content.interpolateRichTextTokens": contract("richText", "plain"),
|
|
709
|
+
"boxStyles.spacing": contract("class", "classes"),
|
|
710
|
+
"boxStyles.semanticGap": contract("class", "classes"),
|
|
711
|
+
"boxStyles.semanticGapValue": contract("gap"),
|
|
712
|
+
"containerStyles.resolveBoxClassName": contract("class", "classes")
|
|
713
|
+
};
|
|
714
|
+
function transformContract(id) {
|
|
715
|
+
return typeof id === "string" && hasOwn(LAYOUT_TRANSFORM_CONTRACTS, id) ? LAYOUT_TRANSFORM_CONTRACTS[id] : null;
|
|
716
|
+
}
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region ../blocks/src/system/node/layoutGate/slots.ts
|
|
719
|
+
/**
|
|
720
|
+
* Slots: the rule for one prop of one node type in a custom-block layout
|
|
721
|
+
* (issue 1185).
|
|
722
|
+
*
|
|
723
|
+
* Every prop a custom layout may set has a slot, and the slot decides both
|
|
724
|
+
* what a literal may be and what a binding may resolve to. A binding is judged
|
|
725
|
+
* by everything it can produce: the bound value (raw, or through its last
|
|
726
|
+
* transform), its fallback, the options its transforms copy into the output,
|
|
727
|
+
* and any `$prepend`/`$append`. A prop without a slot is refused.
|
|
728
|
+
*/
|
|
729
|
+
const isBinding = (value) => isRecord(value) && hasOwn(value, "$bind");
|
|
730
|
+
const own = (record, key) => hasOwn(record, key) ? record[key] : void 0;
|
|
731
|
+
const issue = (path, property, value, reason) => ({
|
|
732
|
+
path,
|
|
733
|
+
property,
|
|
734
|
+
value,
|
|
735
|
+
reason
|
|
736
|
+
});
|
|
737
|
+
/**
|
|
738
|
+
* Tags `as` may name. The text, stack, inline, grid and section primitives
|
|
739
|
+
* render `as` as the element itself, so anything outside text and sectioning
|
|
740
|
+
* content is out: `script` and `style` would run their text, and `link`,
|
|
741
|
+
* `base`, `meta`, `iframe`, `object` and `embed` load or redirect.
|
|
742
|
+
*/
|
|
743
|
+
const ELEMENT_NAMES = /* @__PURE__ */ new Set([
|
|
744
|
+
"div",
|
|
745
|
+
"span",
|
|
746
|
+
"p",
|
|
747
|
+
"h1",
|
|
748
|
+
"h2",
|
|
749
|
+
"h3",
|
|
750
|
+
"h4",
|
|
751
|
+
"h5",
|
|
752
|
+
"h6",
|
|
753
|
+
"section",
|
|
754
|
+
"article",
|
|
755
|
+
"aside",
|
|
756
|
+
"header",
|
|
757
|
+
"footer",
|
|
758
|
+
"main",
|
|
759
|
+
"nav",
|
|
760
|
+
"ul",
|
|
761
|
+
"ol",
|
|
762
|
+
"li",
|
|
763
|
+
"dl",
|
|
764
|
+
"dt",
|
|
765
|
+
"dd",
|
|
766
|
+
"figure",
|
|
767
|
+
"figcaption",
|
|
768
|
+
"blockquote",
|
|
769
|
+
"strong",
|
|
770
|
+
"em",
|
|
771
|
+
"b",
|
|
772
|
+
"i",
|
|
773
|
+
"u",
|
|
774
|
+
"s",
|
|
775
|
+
"small",
|
|
776
|
+
"mark",
|
|
777
|
+
"cite",
|
|
778
|
+
"q",
|
|
779
|
+
"abbr",
|
|
780
|
+
"time",
|
|
781
|
+
"address",
|
|
782
|
+
"pre",
|
|
783
|
+
"code",
|
|
784
|
+
"sub",
|
|
785
|
+
"sup",
|
|
786
|
+
"label"
|
|
787
|
+
]);
|
|
788
|
+
const COLOR_TOKEN = /^[A-Za-z][A-Za-z0-9-]*(?:\/\d{1,3})?$/;
|
|
789
|
+
function describe(slot) {
|
|
790
|
+
switch (slot.kind) {
|
|
791
|
+
case "enum": return `one of ${slot.values.map((value) => JSON.stringify(value)).join(", ")}`;
|
|
792
|
+
case "number": return `a ${slot.integer ? "whole " : ""}number from ${slot.min} to ${slot.max}`;
|
|
793
|
+
case "boolean": return "true or false";
|
|
794
|
+
case "text": return slot.hint ?? `plain text up to ${slot.max} characters`;
|
|
795
|
+
case "style":
|
|
796
|
+
case "className":
|
|
797
|
+
case "element":
|
|
798
|
+
case "href":
|
|
799
|
+
case "colorToken":
|
|
800
|
+
case "cssValue":
|
|
801
|
+
case "platform":
|
|
802
|
+
case "data":
|
|
803
|
+
case "bound":
|
|
804
|
+
case "videoUrl":
|
|
805
|
+
case "object":
|
|
806
|
+
case "list":
|
|
807
|
+
case "tagged":
|
|
808
|
+
case "either": return "a value this prop accepts";
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
/** Looks up the rule for `slot.kind` in a table with one entry per kind. */
|
|
812
|
+
const dispatch = (table, slot, value) => table[slot.kind](slot, value);
|
|
813
|
+
const CONTROL_CHARACTERS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
814
|
+
function textProblem(slot, value) {
|
|
815
|
+
const text = typeof value === "number" && Number.isFinite(value) ? String(value) : value;
|
|
816
|
+
if (typeof text !== "string") return `this prop takes ${describe(slot)}`;
|
|
817
|
+
if (text.length > slot.max) return `the text is longer than ${slot.max} characters`;
|
|
818
|
+
if (CONTROL_CHARACTERS.test(text)) return "the text contains control characters";
|
|
819
|
+
return slot.pattern && !slot.pattern.test(text) ? `this prop takes ${describe(slot)}` : null;
|
|
820
|
+
}
|
|
821
|
+
const inNumberRange = (slot, value) => typeof value === "number" && Number.isFinite(value) && value >= slot.min && value <= slot.max && (!slot.integer || Number.isInteger(value));
|
|
822
|
+
const isLayoutHref = (value) => typeof value === "string" && (value === "" || isSafeRichTextHref(value) && !/^https?:(?!\/\/)/i.test(value));
|
|
823
|
+
const unless = (ok, problem) => ok ? null : problem;
|
|
824
|
+
const LITERAL_PROBLEMS = {
|
|
825
|
+
className: (_slot, value) => classNameProblem(value),
|
|
826
|
+
element: (_slot, value) => unless(typeof value === "string" && ELEMENT_NAMES.has(value), "as must be a text or sectioning element such as div, span, p, h1 to h6, section, ul or li"),
|
|
827
|
+
text: textProblem,
|
|
828
|
+
enum: (slot, value) => unless(slot.values.includes(value), `this prop takes ${describe(slot)}`),
|
|
829
|
+
boolean: (_slot, value) => unless(typeof value === "boolean", "this prop takes true or false"),
|
|
830
|
+
number: (slot, value) => unless(inNumberRange(slot, value), `this prop takes ${describe(slot)}`),
|
|
831
|
+
href: (_slot, value) => unless(isLayoutHref(value), LAYOUT_HREF_RULE),
|
|
832
|
+
colorToken: (_slot, value) => unless(typeof value === "string" && COLOR_TOKEN.test(value), "this prop takes a theme colour name such as surface, primary or primary/80"),
|
|
833
|
+
cssValue: (slot, value) => declarationProblem(slot.property, value),
|
|
834
|
+
videoUrl: (_slot, value) => unless(typeof value === "string" && getVideoEmbed(value) !== null, "this prop takes a video page address from a supported provider (YouTube, Vimeo...)"),
|
|
835
|
+
platform: (slot) => `this prop is set by the platform. Leave it out, or bind it with { $bind: { from: "${slot.from}" } }`,
|
|
836
|
+
data: () => "this prop is filled by a data loader. Bind it to the loader with { $bind: { from: \"data.<loader>\" } }",
|
|
837
|
+
bound: () => "this prop takes content. Bind it to a field instead of writing a value in the layout",
|
|
838
|
+
style: () => null,
|
|
839
|
+
object: () => null,
|
|
840
|
+
list: () => null,
|
|
841
|
+
tagged: () => null,
|
|
842
|
+
either: () => null
|
|
843
|
+
};
|
|
844
|
+
const LAYOUT_HREF_RULE = "a link must be a path on this site (/contact, #section) or an http, https, mailto or tel address, written without backslashes";
|
|
845
|
+
const literalProblem = (slot, value) => dispatch(LITERAL_PROBLEMS, slot, value);
|
|
846
|
+
function styleIssues(value, { path, property, scope }) {
|
|
847
|
+
if (!isRecord(value)) return [issue(path, property, value, "style must be an object of CSS properties")];
|
|
848
|
+
return Object.entries(value).flatMap(([name, declaration]) => slotIssues({
|
|
849
|
+
kind: "cssValue",
|
|
850
|
+
property: name
|
|
851
|
+
}, declaration, `${path}.${name}`, name, scope));
|
|
852
|
+
}
|
|
853
|
+
function objectIssues(fields, value, { path, property, scope }) {
|
|
854
|
+
if (!isRecord(value)) return [issue(path, property, value, "this prop takes an object")];
|
|
855
|
+
return Object.entries(value).flatMap(([key, item]) => {
|
|
856
|
+
const field = own(fields, key);
|
|
857
|
+
return field ? slotIssues(field, item, `${path}.${key}`, key, scope) : [issue(`${path}.${key}`, key, item, `"${key}" is not a field of ${property}`)];
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
function listIssues(slot, value, { path, property, scope }) {
|
|
861
|
+
if (!Array.isArray(value)) return [issue(path, property, value, "this prop takes a list")];
|
|
862
|
+
if (value.length > slot.max) return [issue(path, property, value, `this list takes at most ${slot.max} items`)];
|
|
863
|
+
return value.flatMap((item, index) => slotIssues(slot.item, item, `${path}[${index}]`, property, scope));
|
|
864
|
+
}
|
|
865
|
+
function taggedIssues(slot, value, at) {
|
|
866
|
+
const tag = isRecord(value) ? value[slot.key] : void 0;
|
|
867
|
+
const fields = typeof tag === "string" ? own(slot.variants, tag) : void 0;
|
|
868
|
+
if (typeof tag !== "string" || !fields) return [issue(at.path, at.property, value, `this prop takes an object whose ${slot.key} is one of ${Object.keys(slot.variants).join(", ")}`)];
|
|
869
|
+
return objectIssues({
|
|
870
|
+
...fields,
|
|
871
|
+
[slot.key]: {
|
|
872
|
+
kind: "enum",
|
|
873
|
+
values: [tag],
|
|
874
|
+
bindable: false,
|
|
875
|
+
outputs: []
|
|
876
|
+
}
|
|
877
|
+
}, value, at);
|
|
878
|
+
}
|
|
879
|
+
function eitherIssues(slot, value, { path, property, scope }) {
|
|
880
|
+
return slot.options.some((option) => slotIssues(option, value, path, property, scope).length === 0) ? [] : slotIssues(slot.options[0] ?? { kind: "boolean" }, value, path, property, scope);
|
|
881
|
+
}
|
|
882
|
+
function literalIssues(slot, value, path, property, scope) {
|
|
883
|
+
const at = {
|
|
884
|
+
path,
|
|
885
|
+
property,
|
|
886
|
+
scope
|
|
887
|
+
};
|
|
888
|
+
switch (slot.kind) {
|
|
889
|
+
case "style": return styleIssues(value, at);
|
|
890
|
+
case "object": return objectIssues(slot.fields, value, at);
|
|
891
|
+
case "list": return listIssues(slot, value, at);
|
|
892
|
+
case "tagged": return taggedIssues(slot, value, at);
|
|
893
|
+
case "either": return eitherIssues(slot, value, at);
|
|
894
|
+
case "className":
|
|
895
|
+
case "element":
|
|
896
|
+
case "text":
|
|
897
|
+
case "enum":
|
|
898
|
+
case "boolean":
|
|
899
|
+
case "number":
|
|
900
|
+
case "href":
|
|
901
|
+
case "colorToken":
|
|
902
|
+
case "cssValue":
|
|
903
|
+
case "videoUrl":
|
|
904
|
+
case "platform":
|
|
905
|
+
case "data":
|
|
906
|
+
case "bound": {
|
|
907
|
+
const problem = literalProblem(slot, value);
|
|
908
|
+
return problem ? [issue(path, property, value, problem)] : [];
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
/** A field path: `content.title`, `card.image`. No `$root`, no other directive. */
|
|
913
|
+
const CONTENT_PATH = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
914
|
+
const BINDING_KEYS = /* @__PURE__ */ new Set([
|
|
915
|
+
"$bind",
|
|
916
|
+
"$prepend",
|
|
917
|
+
"$append"
|
|
918
|
+
]);
|
|
919
|
+
const BIND_KEYS = /* @__PURE__ */ new Set([
|
|
920
|
+
"from",
|
|
921
|
+
"fallback",
|
|
922
|
+
"transforms",
|
|
923
|
+
"pick"
|
|
924
|
+
]);
|
|
925
|
+
const IDENTIFIER = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
926
|
+
const GAP_PROPERTIES = /* @__PURE__ */ new Set([
|
|
927
|
+
"gap",
|
|
928
|
+
"rowGap",
|
|
929
|
+
"columnGap"
|
|
930
|
+
]);
|
|
931
|
+
function cssValueAccepts(property, output) {
|
|
932
|
+
const name = toCamelCase(property);
|
|
933
|
+
return output === "color" && COLOR_STYLE_PROPERTIES.has(name) || output === "flexBasis" && name === "flexBasis" || output === "gap" && GAP_PROPERTIES.has(name);
|
|
934
|
+
}
|
|
935
|
+
const never = () => false;
|
|
936
|
+
/** What a slot takes from a binding with this output, when the slot is a literal-only rule otherwise. */
|
|
937
|
+
const ACCEPTS_OUTPUT = {
|
|
938
|
+
style: (_slot, { output }) => output === "style",
|
|
939
|
+
className: (_slot, { output }) => output === "class",
|
|
940
|
+
text: (slot, { output }) => slot.bindable && (output === "raw" || output === "text" || output === "number"),
|
|
941
|
+
enum: (slot, { output }) => slot.bindable && output === "raw" || slot.outputs.includes(output),
|
|
942
|
+
boolean: (_slot, { output }) => output === "raw",
|
|
943
|
+
number: (slot, { output }) => output === "number" || slot.bindable === true && output === "raw",
|
|
944
|
+
href: (_slot, { output }) => output === "raw" || output === "href",
|
|
945
|
+
cssValue: (slot, { output }) => cssValueAccepts(slot.property, output),
|
|
946
|
+
data: (_slot, { output, from, scope }) => output === "raw" && from.startsWith("data.") && !scope.insideScope,
|
|
947
|
+
bound: (slot, { output, from }) => output === "raw" ? !from.startsWith("data.") : slot.outputs.includes(output),
|
|
948
|
+
videoUrl: (_slot, { output }) => output === "raw",
|
|
949
|
+
object: (slot, { output }) => slot.outputs?.includes(output) ?? false,
|
|
950
|
+
either: (slot, produced) => slot.options.some((option) => acceptsOutput(option, produced)),
|
|
951
|
+
element: never,
|
|
952
|
+
colorToken: never,
|
|
953
|
+
platform: never,
|
|
954
|
+
list: never,
|
|
955
|
+
tagged: never
|
|
956
|
+
};
|
|
957
|
+
function acceptsOutput(slot, produced) {
|
|
958
|
+
return ACCEPTS_OUTPUT[slot.kind](slot, produced);
|
|
959
|
+
}
|
|
960
|
+
/** What a binding's fallback has to be: a literal the slot takes, or nothing where only content fits. */
|
|
961
|
+
function fallbackIssues(slot, fallback, path, property, scope) {
|
|
962
|
+
if (fallback === void 0 || fallback === null) return [];
|
|
963
|
+
if (slot.kind === "bound" || slot.kind === "data") return [issue(path, property, fallback, "a fallback here would be written into the page as it is. Leave it out")];
|
|
964
|
+
if (isBinding(fallback)) return [issue(path, property, fallback, "a fallback cannot be another binding")];
|
|
965
|
+
return literalIssues(slot, fallback, path, property, scope);
|
|
966
|
+
}
|
|
967
|
+
/** Options nest a level or two (`cases: { a: 'accent' }`). Anything deeper is not an option a transform reads. */
|
|
968
|
+
const MAX_OPTION_DEPTH = 4;
|
|
969
|
+
/** Every string in a transform's options with its path, or null when they nest deeper than any transform reads. */
|
|
970
|
+
function optionStrings(value, at, depth = 0) {
|
|
971
|
+
if (typeof value === "string") return [[value, at]];
|
|
972
|
+
const children = Array.isArray(value) ? value.map((item, index) => [item, `${at}[${index}]`]) : isRecord(value) ? Object.entries(value).map(([key, item]) => [item, `${at}.${key}`]) : [];
|
|
973
|
+
if (children.length > 0 && depth >= MAX_OPTION_DEPTH) return null;
|
|
974
|
+
const nested = children.map(([item, path]) => optionStrings(item, path, depth + 1));
|
|
975
|
+
return nested.some((strings) => strings === null) ? null : nested.flatMap((strings) => strings ?? []);
|
|
976
|
+
}
|
|
977
|
+
const OPTION_STRING_PROBLEMS = {
|
|
978
|
+
classes: classNameProblem,
|
|
979
|
+
roles: plainOptionProblem,
|
|
980
|
+
plain: plainOptionProblem
|
|
981
|
+
};
|
|
982
|
+
function plainOptionProblem(text) {
|
|
983
|
+
return text === "" || IDENTIFIER.test(text) ? null : "this option takes a short name (letters, numbers, - and _), which the transform builds its output from";
|
|
984
|
+
}
|
|
985
|
+
/** Options a transform copies into its output or builds it from, judged by what they become. */
|
|
986
|
+
function copiedOptionIssues(kind, options, path, property) {
|
|
987
|
+
if (kind === "none") return Object.keys(options).length === 0 ? [] : [issue(path, property, options, "this transform takes no options")];
|
|
988
|
+
const strings = optionStrings(options, path);
|
|
989
|
+
if (strings === null) return [issue(path, property, options, "transform options are nested too deeply")];
|
|
990
|
+
const problemOf = OPTION_STRING_PROBLEMS[kind];
|
|
991
|
+
return strings.flatMap(([text, at]) => {
|
|
992
|
+
const problem = problemOf(text);
|
|
993
|
+
return problem ? [issue(at, property, text, problem)] : [];
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
function optionIssues(options, kind, slot, path, property, scope) {
|
|
997
|
+
if (options === void 0 || options === null || kind === null) return [];
|
|
998
|
+
if (!isRecord(options)) return [issue(path, property, options, "transform options must be an object")];
|
|
999
|
+
return kind.options === "fallback" ? fallbackIssues(slot, options.fallback, `${path}.fallback`, property, scope) : copiedOptionIssues(kind.options, options, path, property);
|
|
1000
|
+
}
|
|
1001
|
+
/** The binding's own shape: only known keys, a $bind object, a list of transforms. */
|
|
1002
|
+
function bindingShape(value, path, property) {
|
|
1003
|
+
const extra = Object.keys(value).find((key) => !BINDING_KEYS.has(key));
|
|
1004
|
+
if (extra !== void 0) return issue(`${path}.${extra}`, property, value, `"${extra}" is not part of a binding`);
|
|
1005
|
+
const bind = value.$bind;
|
|
1006
|
+
if (!isRecord(bind)) return issue(path, property, value, "$bind must be an object with a from path");
|
|
1007
|
+
const extraBind = Object.keys(bind).find((key) => !BIND_KEYS.has(key));
|
|
1008
|
+
if (extraBind !== void 0) return issue(`${path}.$bind.${extraBind}`, property, value, `"${extraBind}" is not allowed in a layout binding`);
|
|
1009
|
+
if (bind.pick != null && bind.pick !== "value") return issue(`${path}.$bind.pick`, property, value, "pick must be \"value\" in a layout prop");
|
|
1010
|
+
if (bind.transforms != null && !Array.isArray(bind.transforms)) return issue(`${path}.$bind.transforms`, property, value, "transforms must be a list");
|
|
1011
|
+
return {
|
|
1012
|
+
bind,
|
|
1013
|
+
from: bind.from,
|
|
1014
|
+
transforms: Array.isArray(bind.transforms) ? bind.transforms : []
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
const isSlotIssue = (value) => "reason" in value;
|
|
1018
|
+
function platformIssues(slot, value, { bind, from, transforms }, path, property) {
|
|
1019
|
+
return from === slot.from && transforms.length === 0 && bind.fallback == null && value.$prepend == null && value.$append == null ? [] : [issue(path, property, value, literalProblem(slot, value) ?? "")];
|
|
1020
|
+
}
|
|
1021
|
+
function affixIssues(slot, value, path, property) {
|
|
1022
|
+
return ["$prepend", "$append"].flatMap((key) => {
|
|
1023
|
+
const affix = value[key];
|
|
1024
|
+
if (affix == null) return [];
|
|
1025
|
+
return slot.kind === "text" && typeof affix === "string" && literalProblem(slot, affix) === null ? [] : [issue(`${path}.${key}`, property, affix, `${key} joins text onto the bound value, which only works for plain text props. Write the whole value in a transform option or a literal`)];
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
function outputProblem(property, output, lastStep) {
|
|
1029
|
+
return output === "raw" ? `content cannot be bound straight into ${property}. Use a literal value, or a binding through a transform that produces this kind of value` : `a binding that ends in ${String(isRecord(lastStep) ? lastStep.id : "")} produces ${output}, which ${property} does not take`;
|
|
1030
|
+
}
|
|
1031
|
+
function contentBindingIssues(slot, value, parsed, from, at) {
|
|
1032
|
+
const { path, property, scope } = at;
|
|
1033
|
+
const steps = parsed.transforms.map((step, index) => ({
|
|
1034
|
+
step,
|
|
1035
|
+
index,
|
|
1036
|
+
kind: isRecord(step) ? transformContract(step.id) : null
|
|
1037
|
+
}));
|
|
1038
|
+
const unknownStep = steps.find(({ kind }) => kind === null);
|
|
1039
|
+
if (unknownStep) return [issue(`${path}.$bind.transforms[${unknownStep.index}]`, property, value, "this transform is not available in a custom-block layout")];
|
|
1040
|
+
const output = steps.at(-1)?.kind?.output ?? "raw";
|
|
1041
|
+
return [
|
|
1042
|
+
...acceptsOutput(slot, {
|
|
1043
|
+
output,
|
|
1044
|
+
from,
|
|
1045
|
+
scope
|
|
1046
|
+
}) ? [] : [issue(path, property, value, outputProblem(property, output, parsed.transforms.at(-1)))],
|
|
1047
|
+
...steps.flatMap(({ step, index, kind }) => optionIssues(isRecord(step) ? step.options : void 0, kind, slot, `${path}.$bind.transforms[${index}].options`, property, scope)),
|
|
1048
|
+
...fallbackIssues(slot, parsed.bind.fallback, `${path}.$bind.fallback`, property, scope),
|
|
1049
|
+
...affixIssues(slot, value, path, property)
|
|
1050
|
+
];
|
|
1051
|
+
}
|
|
1052
|
+
function bindingIssues(slot, value, path, property, scope) {
|
|
1053
|
+
const parsed = bindingShape(value, path, property);
|
|
1054
|
+
if (isSlotIssue(parsed)) return [parsed];
|
|
1055
|
+
if (slot.kind === "platform") return platformIssues(slot, value, parsed, path, property);
|
|
1056
|
+
const { from } = parsed;
|
|
1057
|
+
if (typeof from !== "string" || !CONTENT_PATH.test(from)) return [issue(`${path}.$bind.from`, property, value, "a binding reads a field path such as content.title. Platform values ($root) only go into the props that take them")];
|
|
1058
|
+
return contentBindingIssues(slot, value, parsed, from, {
|
|
1059
|
+
path,
|
|
1060
|
+
property,
|
|
1061
|
+
scope
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
/** Every issue with `value` in `slot`. Null and undefined mean the prop is absent. */
|
|
1065
|
+
function slotIssues(slot, value, path, property, scope) {
|
|
1066
|
+
if (value === void 0 || value === null) return [];
|
|
1067
|
+
if (slot.kind === "cssValue" && !isAllowedStyleProperty(slot.property)) return [issue(path, property, value, `the CSS property "${slot.property}" is not on the allowlist for custom-block layouts`)];
|
|
1068
|
+
if (isBinding(value)) return bindingIssues(slot, value, path, property, scope);
|
|
1069
|
+
return literalIssues(slot, value, path, property, scope);
|
|
1070
|
+
}
|
|
1071
|
+
const isPrimitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
1072
|
+
const NOT_AVAILABLE = "this transform is not available in a custom-block layout";
|
|
1073
|
+
/** `$when`: any layout transform, with a plain fallback and plain options. */
|
|
1074
|
+
function decidingStepIssues(step, at, property) {
|
|
1075
|
+
if (!isRecord(step) || transformContract(step.id) === null) return [issue(at, property, step, NOT_AVAILABLE)];
|
|
1076
|
+
const options = step.options;
|
|
1077
|
+
if (options === void 0 || options === null) return [];
|
|
1078
|
+
return isRecord(options) && Object.values(options).every((option) => isPrimitive(option) || Array.isArray(option) && option.every(isPrimitive) || isRecord(option) && Object.values(option).every(isPrimitive)) ? [] : [issue(`${at}.options`, property, options, "transform options here must be plain values")];
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* `$scopes` and `$repeat`: only transforms that work on the bound content.
|
|
1082
|
+
* One that copies an option into its output (`value.fallback`, a class or role
|
|
1083
|
+
* transform) would let the layout write the value a media node or a link then
|
|
1084
|
+
* reads as content.
|
|
1085
|
+
*/
|
|
1086
|
+
function holdingStepIssues(step, at, property) {
|
|
1087
|
+
const kind = isRecord(step) ? transformContract(step.id) : null;
|
|
1088
|
+
if (!isRecord(step) || kind === null) return [issue(at, property, step, NOT_AVAILABLE)];
|
|
1089
|
+
if (kind.options !== "none" && kind.options !== "plain") return [issue(at, property, step, `${String(step.id)} copies its options into the value, and a scope or repeater is read like content. Use the transform on the prop that needs it instead`)];
|
|
1090
|
+
const options = step.options;
|
|
1091
|
+
if (options === void 0 || options === null) return [];
|
|
1092
|
+
return isRecord(options) ? copiedOptionIssues(kind.options, options, `${at}.options`, property) : [issue(`${at}.options`, property, options, "transform options must be an object")];
|
|
1093
|
+
}
|
|
1094
|
+
function directiveFallbackIssues(fallback, role, path, property) {
|
|
1095
|
+
if (fallback === void 0 || fallback === null) return [];
|
|
1096
|
+
if (role === "holds") return [issue(path, property, fallback, "a scope or repeater is read like content, so the layout cannot write its value. Leave the fallback out, and use $when for a missing field")];
|
|
1097
|
+
return isPrimitive(fallback) ? [] : [issue(path, property, fallback, "a fallback here must be text, a number or true/false")];
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* A `$when`, `$repeat` or `$scopes` binding reads field paths only. What else
|
|
1101
|
+
* it may carry depends on its role: a `$when` value only decides rendering, so
|
|
1102
|
+
* it takes a plain fallback and any layout transform; a scope or repeater value
|
|
1103
|
+
* is read like content by the slots below it, so nothing written in the layout
|
|
1104
|
+
* (a fallback, an option a transform copies out) may end up in it.
|
|
1105
|
+
*/
|
|
1106
|
+
function directiveBindingIssues(binding, role, path, property) {
|
|
1107
|
+
if (binding === void 0 || binding === null) return [];
|
|
1108
|
+
if (!isRecord(binding)) return [issue(path, property, binding, "a binding must be an object with a from path")];
|
|
1109
|
+
const from = binding.from;
|
|
1110
|
+
if (typeof from !== "string" || !CONTENT_PATH.test(from)) return [issue(`${path}.from`, property, binding, "a binding reads a field path such as content.items. Platform values ($root) are not available here")];
|
|
1111
|
+
const transforms = Array.isArray(binding.transforms) ? binding.transforms : [];
|
|
1112
|
+
const stepIssues = role === "holds" ? holdingStepIssues : decidingStepIssues;
|
|
1113
|
+
return [...directiveFallbackIssues(binding.fallback, role, `${path}.fallback`, property), ...transforms.flatMap((step, index) => stepIssues(step, `${path}.transforms[${index}]`, property))];
|
|
1114
|
+
}
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region ../blocks/src/system/node/layoutGate/fieldDefaults.ts
|
|
1117
|
+
/**
|
|
1118
|
+
* What a custom block's field defaults may hold (issue 1185).
|
|
1119
|
+
*
|
|
1120
|
+
* A layout binds content into slots that trust it: a media node renders the
|
|
1121
|
+
* `src` it is given, a link its `href`, a background transform its gradient.
|
|
1122
|
+
* Editors write content, but a field's `defaultValue` is written by the
|
|
1123
|
+
* manifest's author, the same author as the layout. So a default is held to
|
|
1124
|
+
* the rules a layout literal would be, wherever the value sits in it:
|
|
1125
|
+
*
|
|
1126
|
+
* - `src` is a path on this site, so the platform serves the file;
|
|
1127
|
+
* - `href` and `url` pass the layout link rule;
|
|
1128
|
+
* - no string calls `url()` or `image-set()`.
|
|
1129
|
+
*/
|
|
1130
|
+
/** Defaults nest a few levels (a repeater of cards, each with a link). Deeper than this is not content a field holds. */
|
|
1131
|
+
const MAX_DEFAULT_DEPTH = 12;
|
|
1132
|
+
const SITE_PATH = /^\/(?![/\\])[^\\]*$/;
|
|
1133
|
+
const ADDRESS_KEY_PROBLEMS = {
|
|
1134
|
+
src: (value) => SITE_PATH.test(value) ? null : "a default src must be a path on this site, such as /images/hero.jpg. For a file in the media library, give its identifier instead",
|
|
1135
|
+
href: (value) => isLayoutHref(value) ? null : LAYOUT_HREF_RULE,
|
|
1136
|
+
url: (value) => isLayoutHref(value) ? null : LAYOUT_HREF_RULE
|
|
1137
|
+
};
|
|
1138
|
+
function stringProblem(key, value) {
|
|
1139
|
+
return (Object.prototype.hasOwnProperty.call(ADDRESS_KEY_PROBLEMS, key) ? ADDRESS_KEY_PROBLEMS[key] : void 0)?.(value) ?? (callsCssLoadingFunction(value) ? "a default cannot call url() or image-set(). Use a media field so the platform serves the file" : null);
|
|
1140
|
+
}
|
|
1141
|
+
function valueIssues(value, key, path, depth) {
|
|
1142
|
+
if (typeof value === "string") {
|
|
1143
|
+
const problem = stringProblem(key, value);
|
|
1144
|
+
return problem ? [{
|
|
1145
|
+
path,
|
|
1146
|
+
property: key,
|
|
1147
|
+
value,
|
|
1148
|
+
reason: problem
|
|
1149
|
+
}] : [];
|
|
1150
|
+
}
|
|
1151
|
+
const children = Array.isArray(value) ? value.map((item, index) => [
|
|
1152
|
+
item,
|
|
1153
|
+
key,
|
|
1154
|
+
`${path}[${index}]`
|
|
1155
|
+
]) : isRecord(value) ? Object.entries(value).map(([name, item]) => [
|
|
1156
|
+
item,
|
|
1157
|
+
name,
|
|
1158
|
+
`${path}.${name}`
|
|
1159
|
+
]) : [];
|
|
1160
|
+
if (children.length > 0 && depth >= MAX_DEFAULT_DEPTH) return [{
|
|
1161
|
+
path,
|
|
1162
|
+
property: key,
|
|
1163
|
+
value: "",
|
|
1164
|
+
reason: "the default value is nested too deeply"
|
|
1165
|
+
}];
|
|
1166
|
+
return children.flatMap(([item, name, at]) => valueIssues(item, name, at, depth + 1));
|
|
1167
|
+
}
|
|
1168
|
+
/** A `url` or `link` field's default written as a bare string is an address too. */
|
|
1169
|
+
const ADDRESS_FIELD_TYPES = /* @__PURE__ */ new Set(["url", "link"]);
|
|
1170
|
+
function nestedFieldLists(field, path) {
|
|
1171
|
+
const schema = isRecord(field.schema) ? field.schema : {};
|
|
1172
|
+
const tabs = Array.isArray(field.tabs) ? field.tabs : [];
|
|
1173
|
+
const itemTypes = isRecord(field.itemTypes) ? field.itemTypes : {};
|
|
1174
|
+
return [
|
|
1175
|
+
[field.fields, `${path}.fields`],
|
|
1176
|
+
[schema.fields, `${path}.schema.fields`],
|
|
1177
|
+
...tabs.map((tab, index) => [isRecord(tab) ? tab.fields : void 0, `${path}.tabs[${index}].fields`]),
|
|
1178
|
+
...Object.entries(itemTypes).map(([name, itemType]) => [isRecord(itemType) ? itemType.fields : void 0, `${path}.itemTypes.${name}.fields`])
|
|
1179
|
+
];
|
|
1180
|
+
}
|
|
1181
|
+
function fieldIssues(field, path, depth) {
|
|
1182
|
+
if (!isRecord(field)) return [];
|
|
1183
|
+
const key = ADDRESS_FIELD_TYPES.has(field.type) ? "href" : "defaultValue";
|
|
1184
|
+
return [...valueIssues(field.defaultValue, key, `${path}.defaultValue`, 0), ...nestedFieldLists(field, path).flatMap(([fields, at]) => fieldListIssues(fields, at, depth + 1))];
|
|
1185
|
+
}
|
|
1186
|
+
function fieldListIssues(fields, path, depth) {
|
|
1187
|
+
if (!Array.isArray(fields) || depth > MAX_DEFAULT_DEPTH) return [];
|
|
1188
|
+
return fields.flatMap((field, index) => fieldIssues(field, `${path}[${index}]`, depth));
|
|
1189
|
+
}
|
|
1190
|
+
/** Every issue with the defaults of a custom block's fields, nested fields included. */
|
|
1191
|
+
function fieldDefaultIssues(fields, path) {
|
|
1192
|
+
return fieldListIssues(fields, path, 0);
|
|
1193
|
+
}
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region ../blocks/src/system/node/layoutGate/nodeSchemas.ts
|
|
1196
|
+
/**
|
|
1197
|
+
* Ties a schema to its renderer: a key that is not a prop of `P` does not
|
|
1198
|
+
* compile, including keys that arrive through a spread (which `satisfies`
|
|
1199
|
+
* alone lets through). Renaming a renderer prop therefore breaks the build
|
|
1200
|
+
* here instead of leaving a rule for a prop nothing reads.
|
|
1201
|
+
*/
|
|
1202
|
+
const forRenderer = () => (schema) => schema;
|
|
1203
|
+
const text = (max = 500) => ({
|
|
1204
|
+
kind: "text",
|
|
1205
|
+
bindable: true,
|
|
1206
|
+
max
|
|
1207
|
+
});
|
|
1208
|
+
const literalText = (max, pattern, hint, bindable = false) => ({
|
|
1209
|
+
kind: "text",
|
|
1210
|
+
bindable,
|
|
1211
|
+
max,
|
|
1212
|
+
pattern,
|
|
1213
|
+
hint
|
|
1214
|
+
});
|
|
1215
|
+
const oneOf = (values, options = {}) => ({
|
|
1216
|
+
kind: "enum",
|
|
1217
|
+
values,
|
|
1218
|
+
bindable: options.bindable ?? false,
|
|
1219
|
+
outputs: options.outputs ?? []
|
|
1220
|
+
});
|
|
1221
|
+
const flag = { kind: "boolean" };
|
|
1222
|
+
const whole = (min, max, bindable = false) => ({
|
|
1223
|
+
kind: "number",
|
|
1224
|
+
min,
|
|
1225
|
+
max,
|
|
1226
|
+
integer: true,
|
|
1227
|
+
bindable
|
|
1228
|
+
});
|
|
1229
|
+
const platform = (path) => ({
|
|
1230
|
+
kind: "platform",
|
|
1231
|
+
from: `$root.${path}`
|
|
1232
|
+
});
|
|
1233
|
+
const data = { kind: "data" };
|
|
1234
|
+
const href = { kind: "href" };
|
|
1235
|
+
const style = { kind: "style" };
|
|
1236
|
+
const className = { kind: "className" };
|
|
1237
|
+
const element = { kind: "element" };
|
|
1238
|
+
const colorToken = { kind: "colorToken" };
|
|
1239
|
+
/** A hook for the theme's CSS, such as `card` or `media`. */
|
|
1240
|
+
const dataSlot = literalText(40, /^[a-z][a-z0-9-]*$/, "a short lowercase name such as card or media");
|
|
1241
|
+
/** A block's own element id. The `cb-` prefix keeps it clear of the platform's ids. */
|
|
1242
|
+
const elementId = literalText(64, /^cb-[a-z0-9]+(?:-[a-z0-9]+)*$/, "an id starting \"cb-\", such as cb-pricing");
|
|
1243
|
+
const ROLES = [
|
|
1244
|
+
"region",
|
|
1245
|
+
"group",
|
|
1246
|
+
"list",
|
|
1247
|
+
"listitem",
|
|
1248
|
+
"img",
|
|
1249
|
+
"presentation",
|
|
1250
|
+
"none",
|
|
1251
|
+
"note",
|
|
1252
|
+
"status",
|
|
1253
|
+
"figure",
|
|
1254
|
+
"article",
|
|
1255
|
+
"complementary",
|
|
1256
|
+
"separator"
|
|
1257
|
+
];
|
|
1258
|
+
/** Button styles every theme has. A theme's own extra styles are not open to custom layouts. */
|
|
1259
|
+
const buttonVariant = oneOf([...VARIANT_ROLES, DEFAULT_VARIANT_ALIAS_ID]);
|
|
1260
|
+
/** Sizes become a `btn-<size>` class, so only the theme's sizes. */
|
|
1261
|
+
const buttonSize = oneOf([
|
|
1262
|
+
"sm",
|
|
1263
|
+
"md",
|
|
1264
|
+
"lg",
|
|
1265
|
+
"xl"
|
|
1266
|
+
]);
|
|
1267
|
+
const linkTarget = oneOf(["_self", "_blank"]);
|
|
1268
|
+
const linkRel = literalText(60, /^(?:noopener|noreferrer|nofollow|external|ugc|sponsored)(?: (?:noopener|noreferrer|nofollow|external|ugc|sponsored))*$/, "rel words such as noopener noreferrer");
|
|
1269
|
+
/** Attributes the plain containers pass straight to their element. */
|
|
1270
|
+
const ATTRIBUTES = {
|
|
1271
|
+
id: elementId,
|
|
1272
|
+
role: oneOf(ROLES),
|
|
1273
|
+
title: text(200),
|
|
1274
|
+
"aria-label": text(200),
|
|
1275
|
+
"aria-hidden": oneOf([
|
|
1276
|
+
"true",
|
|
1277
|
+
"false",
|
|
1278
|
+
true,
|
|
1279
|
+
false
|
|
1280
|
+
]),
|
|
1281
|
+
"aria-labelledby": elementId,
|
|
1282
|
+
"aria-describedby": elementId,
|
|
1283
|
+
tabIndex: oneOf([-1, 0])
|
|
1284
|
+
};
|
|
1285
|
+
const BOX = {
|
|
1286
|
+
className,
|
|
1287
|
+
style,
|
|
1288
|
+
"data-slot": dataSlot
|
|
1289
|
+
};
|
|
1290
|
+
const STACK_GAP = oneOf([
|
|
1291
|
+
"none",
|
|
1292
|
+
"xs",
|
|
1293
|
+
"sm",
|
|
1294
|
+
"md",
|
|
1295
|
+
"lg"
|
|
1296
|
+
], { bindable: true });
|
|
1297
|
+
const JUSTIFY = oneOf([
|
|
1298
|
+
"start",
|
|
1299
|
+
"center",
|
|
1300
|
+
"end",
|
|
1301
|
+
"between"
|
|
1302
|
+
], {
|
|
1303
|
+
bindable: true,
|
|
1304
|
+
outputs: ["justify"]
|
|
1305
|
+
});
|
|
1306
|
+
/** A grid column count, or a column template such as `1fr 2fr`. */
|
|
1307
|
+
const gridColumn = {
|
|
1308
|
+
kind: "either",
|
|
1309
|
+
options: [whole(1, 12), {
|
|
1310
|
+
kind: "cssValue",
|
|
1311
|
+
property: "gridTemplateColumns"
|
|
1312
|
+
}]
|
|
1313
|
+
};
|
|
1314
|
+
const div = {
|
|
1315
|
+
...BOX,
|
|
1316
|
+
...ATTRIBUTES
|
|
1317
|
+
};
|
|
1318
|
+
const section = {
|
|
1319
|
+
...BOX,
|
|
1320
|
+
as: element,
|
|
1321
|
+
background: colorToken
|
|
1322
|
+
};
|
|
1323
|
+
const stack = {
|
|
1324
|
+
...BOX,
|
|
1325
|
+
...ATTRIBUTES,
|
|
1326
|
+
as: element,
|
|
1327
|
+
gap: STACK_GAP,
|
|
1328
|
+
align: oneOf([
|
|
1329
|
+
"start",
|
|
1330
|
+
"center",
|
|
1331
|
+
"end",
|
|
1332
|
+
"stretch"
|
|
1333
|
+
], {
|
|
1334
|
+
bindable: true,
|
|
1335
|
+
outputs: ["stackAlign"]
|
|
1336
|
+
}),
|
|
1337
|
+
justify: JUSTIFY
|
|
1338
|
+
};
|
|
1339
|
+
const inline = {
|
|
1340
|
+
...stack,
|
|
1341
|
+
align: oneOf([
|
|
1342
|
+
"start",
|
|
1343
|
+
"center",
|
|
1344
|
+
"end",
|
|
1345
|
+
"stretch",
|
|
1346
|
+
"baseline"
|
|
1347
|
+
], {
|
|
1348
|
+
bindable: true,
|
|
1349
|
+
outputs: ["stackAlign"]
|
|
1350
|
+
}),
|
|
1351
|
+
wrap: flag
|
|
1352
|
+
};
|
|
1353
|
+
const grid = {
|
|
1354
|
+
...BOX,
|
|
1355
|
+
...ATTRIBUTES,
|
|
1356
|
+
as: element,
|
|
1357
|
+
gap: oneOf([
|
|
1358
|
+
"none",
|
|
1359
|
+
"xs",
|
|
1360
|
+
"sm",
|
|
1361
|
+
"md",
|
|
1362
|
+
"lg",
|
|
1363
|
+
"compact",
|
|
1364
|
+
"cozy",
|
|
1365
|
+
"medium",
|
|
1366
|
+
"comfortable",
|
|
1367
|
+
"spacious"
|
|
1368
|
+
], { bindable: true }),
|
|
1369
|
+
cols: {
|
|
1370
|
+
kind: "either",
|
|
1371
|
+
options: [gridColumn, {
|
|
1372
|
+
kind: "object",
|
|
1373
|
+
fields: {
|
|
1374
|
+
base: gridColumn,
|
|
1375
|
+
sm: gridColumn,
|
|
1376
|
+
md: gridColumn,
|
|
1377
|
+
lg: gridColumn,
|
|
1378
|
+
xl: gridColumn
|
|
1379
|
+
}
|
|
1380
|
+
}]
|
|
1381
|
+
},
|
|
1382
|
+
userColumns: whole(1, 4, true)
|
|
1383
|
+
};
|
|
1384
|
+
const textNode = {
|
|
1385
|
+
...BOX,
|
|
1386
|
+
as: element,
|
|
1387
|
+
value: text(5e3),
|
|
1388
|
+
maxLength: whole(1, 1e4)
|
|
1389
|
+
};
|
|
1390
|
+
const richText = {
|
|
1391
|
+
...BOX,
|
|
1392
|
+
as: element,
|
|
1393
|
+
value: {
|
|
1394
|
+
kind: "bound",
|
|
1395
|
+
outputs: ["richText"]
|
|
1396
|
+
},
|
|
1397
|
+
leadParagraphSlot: oneOf(["lede"])
|
|
1398
|
+
};
|
|
1399
|
+
const media = {
|
|
1400
|
+
...BOX,
|
|
1401
|
+
value: {
|
|
1402
|
+
kind: "bound",
|
|
1403
|
+
outputs: ["media"]
|
|
1404
|
+
},
|
|
1405
|
+
size: {
|
|
1406
|
+
kind: "object",
|
|
1407
|
+
fields: {
|
|
1408
|
+
width: whole(16, 4e3),
|
|
1409
|
+
height: whole(16, 4e3),
|
|
1410
|
+
quality: whole(1, 100),
|
|
1411
|
+
resize: oneOf([
|
|
1412
|
+
"cover",
|
|
1413
|
+
"contain",
|
|
1414
|
+
"fill"
|
|
1415
|
+
])
|
|
1416
|
+
},
|
|
1417
|
+
outputs: ["mediaSize"]
|
|
1418
|
+
},
|
|
1419
|
+
loading: oneOf(["lazy", "eager"]),
|
|
1420
|
+
fetchPriority: oneOf([
|
|
1421
|
+
"high",
|
|
1422
|
+
"low",
|
|
1423
|
+
"auto"
|
|
1424
|
+
]),
|
|
1425
|
+
videoPlayback: oneOf(["inline", "background"])
|
|
1426
|
+
};
|
|
1427
|
+
const videoEmbed = {
|
|
1428
|
+
...BOX,
|
|
1429
|
+
value: { kind: "videoUrl" },
|
|
1430
|
+
aspectRatio: literalText(20, VIDEO_ASPECT_RATIO_PATTERN, "a ratio such as 16/9 or 1.5, or auto")
|
|
1431
|
+
};
|
|
1432
|
+
/** Icon names are looked up in the icon registry, so an unknown one renders nothing. */
|
|
1433
|
+
const ICON_NAME = /^[A-Za-z0-9:_-]+$/;
|
|
1434
|
+
const ICON_HINT = "an icon name such as MapPin";
|
|
1435
|
+
const icon = {
|
|
1436
|
+
className,
|
|
1437
|
+
value: literalText(64, ICON_NAME, ICON_HINT, true),
|
|
1438
|
+
title: text(200),
|
|
1439
|
+
"aria-label": text(200)
|
|
1440
|
+
};
|
|
1441
|
+
const featureCardIcon = forRenderer()({
|
|
1442
|
+
className,
|
|
1443
|
+
"data-slot": dataSlot,
|
|
1444
|
+
value: literalText(200, ICON_NAME, ICON_HINT, true),
|
|
1445
|
+
treatment: oneOf([
|
|
1446
|
+
"plain",
|
|
1447
|
+
"soft-badge",
|
|
1448
|
+
"utility-badge"
|
|
1449
|
+
], { bindable: true }),
|
|
1450
|
+
generatedIconSizePx: whole(16, 256),
|
|
1451
|
+
generatedAssets: data
|
|
1452
|
+
});
|
|
1453
|
+
const svgNumber = {
|
|
1454
|
+
kind: "either",
|
|
1455
|
+
options: [{
|
|
1456
|
+
kind: "number",
|
|
1457
|
+
min: -1e5,
|
|
1458
|
+
max: 1e5,
|
|
1459
|
+
integer: false
|
|
1460
|
+
}, literalText(12, /^-?\d{1,6}(?:\.\d{1,4})?%?$/, "a number")]
|
|
1461
|
+
};
|
|
1462
|
+
const svgPaint = (property) => ({
|
|
1463
|
+
kind: "cssValue",
|
|
1464
|
+
property
|
|
1465
|
+
});
|
|
1466
|
+
const SHAPE_PAINT = {
|
|
1467
|
+
className,
|
|
1468
|
+
fillRule: oneOf(["evenodd", "nonzero"]),
|
|
1469
|
+
fill: svgPaint("fill"),
|
|
1470
|
+
stroke: svgPaint("stroke"),
|
|
1471
|
+
strokeWidth: svgPaint("strokeWidth"),
|
|
1472
|
+
fillOpacity: svgPaint("fillOpacity"),
|
|
1473
|
+
strokeOpacity: svgPaint("strokeOpacity"),
|
|
1474
|
+
strokeLinecap: oneOf([
|
|
1475
|
+
"butt",
|
|
1476
|
+
"round",
|
|
1477
|
+
"square"
|
|
1478
|
+
]),
|
|
1479
|
+
strokeLinejoin: oneOf([
|
|
1480
|
+
"miter",
|
|
1481
|
+
"round",
|
|
1482
|
+
"bevel"
|
|
1483
|
+
]),
|
|
1484
|
+
strokeDasharray: svgPaint("strokeDasharray"),
|
|
1485
|
+
transform: literalText(200, /^[a-zA-Z0-9().,\s-]*$/, "an SVG transform such as rotate(45)")
|
|
1486
|
+
};
|
|
1487
|
+
const svg = {
|
|
1488
|
+
className,
|
|
1489
|
+
style,
|
|
1490
|
+
viewBox: literalText(60, /^-?[\d.]+(?:[ ,]+-?[\d.]+){3}$/, "four numbers such as 0 0 24 24"),
|
|
1491
|
+
width: svgNumber,
|
|
1492
|
+
height: svgNumber,
|
|
1493
|
+
ariaHidden: flag,
|
|
1494
|
+
ariaLabel: text(200),
|
|
1495
|
+
shapes: {
|
|
1496
|
+
kind: "list",
|
|
1497
|
+
max: 200,
|
|
1498
|
+
item: {
|
|
1499
|
+
kind: "tagged",
|
|
1500
|
+
key: "kind",
|
|
1501
|
+
variants: {
|
|
1502
|
+
text: {
|
|
1503
|
+
...SHAPE_PAINT,
|
|
1504
|
+
x: svgNumber,
|
|
1505
|
+
y: svgNumber,
|
|
1506
|
+
text: text(500)
|
|
1507
|
+
},
|
|
1508
|
+
path: {
|
|
1509
|
+
...SHAPE_PAINT,
|
|
1510
|
+
d: literalText(5e3, /^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]*$/, "SVG path data")
|
|
1511
|
+
},
|
|
1512
|
+
ellipse: {
|
|
1513
|
+
...SHAPE_PAINT,
|
|
1514
|
+
cx: svgNumber,
|
|
1515
|
+
cy: svgNumber,
|
|
1516
|
+
rx: svgNumber,
|
|
1517
|
+
ry: svgNumber
|
|
1518
|
+
},
|
|
1519
|
+
circle: {
|
|
1520
|
+
...SHAPE_PAINT,
|
|
1521
|
+
cx: svgNumber,
|
|
1522
|
+
cy: svgNumber,
|
|
1523
|
+
r: svgNumber
|
|
1524
|
+
},
|
|
1525
|
+
rect: {
|
|
1526
|
+
...SHAPE_PAINT,
|
|
1527
|
+
x: svgNumber,
|
|
1528
|
+
y: svgNumber,
|
|
1529
|
+
width: svgNumber,
|
|
1530
|
+
height: svgNumber,
|
|
1531
|
+
rx: svgNumber,
|
|
1532
|
+
ry: svgNumber
|
|
1533
|
+
},
|
|
1534
|
+
line: {
|
|
1535
|
+
...SHAPE_PAINT,
|
|
1536
|
+
x1: svgNumber,
|
|
1537
|
+
y1: svgNumber,
|
|
1538
|
+
x2: svgNumber,
|
|
1539
|
+
y2: svgNumber
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
const button = {
|
|
1546
|
+
className,
|
|
1547
|
+
value: text(200),
|
|
1548
|
+
href,
|
|
1549
|
+
target: linkTarget,
|
|
1550
|
+
rel: linkRel,
|
|
1551
|
+
"aria-label": text(200),
|
|
1552
|
+
variantId: buttonVariant,
|
|
1553
|
+
size: buttonSize,
|
|
1554
|
+
actionStyle: oneOf(["button", "link"], { bindable: true }),
|
|
1555
|
+
linkRequired: flag,
|
|
1556
|
+
disabled: flag,
|
|
1557
|
+
type: oneOf([
|
|
1558
|
+
"button",
|
|
1559
|
+
"submit",
|
|
1560
|
+
"reset"
|
|
1561
|
+
])
|
|
1562
|
+
};
|
|
1563
|
+
const link = {
|
|
1564
|
+
...BOX,
|
|
1565
|
+
href,
|
|
1566
|
+
target: linkTarget,
|
|
1567
|
+
rel: linkRel,
|
|
1568
|
+
linkRequired: flag,
|
|
1569
|
+
title: text(200),
|
|
1570
|
+
"aria-label": text(200),
|
|
1571
|
+
value: text(200)
|
|
1572
|
+
};
|
|
1573
|
+
const slideCount = whole(1, 6);
|
|
1574
|
+
const carousel = {
|
|
1575
|
+
className,
|
|
1576
|
+
slidesToShow: {
|
|
1577
|
+
kind: "either",
|
|
1578
|
+
options: [slideCount, {
|
|
1579
|
+
kind: "object",
|
|
1580
|
+
fields: {
|
|
1581
|
+
mobile: slideCount,
|
|
1582
|
+
tablet: slideCount,
|
|
1583
|
+
desktop: slideCount
|
|
1584
|
+
}
|
|
1585
|
+
}]
|
|
1586
|
+
},
|
|
1587
|
+
transition: oneOf(["slide", "fade"], { bindable: true }),
|
|
1588
|
+
showControls: flag,
|
|
1589
|
+
showDots: flag,
|
|
1590
|
+
arrowVisibility: oneOf([
|
|
1591
|
+
"always",
|
|
1592
|
+
"hover",
|
|
1593
|
+
"never"
|
|
1594
|
+
], { bindable: true }),
|
|
1595
|
+
autoplay: flag,
|
|
1596
|
+
autoplayDelay: whole(1e3, 6e4),
|
|
1597
|
+
loop: flag
|
|
1598
|
+
};
|
|
1599
|
+
const accordion = forRenderer()({
|
|
1600
|
+
className,
|
|
1601
|
+
type: oneOf(["single", "multiple"]),
|
|
1602
|
+
collapsible: flag,
|
|
1603
|
+
defaultValue: text(100)
|
|
1604
|
+
});
|
|
1605
|
+
const accordionText = {
|
|
1606
|
+
kind: "either",
|
|
1607
|
+
options: [text(2e3), {
|
|
1608
|
+
kind: "bound",
|
|
1609
|
+
outputs: ["richText"]
|
|
1610
|
+
}]
|
|
1611
|
+
};
|
|
1612
|
+
const accordionItem = forRenderer()({
|
|
1613
|
+
className,
|
|
1614
|
+
value: text(100),
|
|
1615
|
+
trigger: accordionText,
|
|
1616
|
+
content: accordionText,
|
|
1617
|
+
question: accordionText,
|
|
1618
|
+
answer: accordionText,
|
|
1619
|
+
iconStyle: oneOf(accordionIconSchema.options)
|
|
1620
|
+
});
|
|
1621
|
+
const PLATFORM_API = {
|
|
1622
|
+
apiBaseUrl: platform("apiBaseUrl"),
|
|
1623
|
+
siteId: platform("siteId"),
|
|
1624
|
+
now: platform("now")
|
|
1625
|
+
};
|
|
1626
|
+
const READ_AUTHORITY = { readAuthority: platform("readAuthority") };
|
|
1627
|
+
const form = {
|
|
1628
|
+
className,
|
|
1629
|
+
...PLATFORM_API,
|
|
1630
|
+
spamProtectionEnabled: platform("spamProtectionEnabled"),
|
|
1631
|
+
value: data,
|
|
1632
|
+
submitLabel: text(100),
|
|
1633
|
+
successMessage: text(1e3)
|
|
1634
|
+
};
|
|
1635
|
+
const bookingForm = forRenderer()({
|
|
1636
|
+
className,
|
|
1637
|
+
...PLATFORM_API,
|
|
1638
|
+
businessPerson: platform("businessPerson"),
|
|
1639
|
+
dateContext: platform("dateContext"),
|
|
1640
|
+
demoEmailSuppressed: platform("demoEmailSuppressed"),
|
|
1641
|
+
mailingList: platform("mailingList"),
|
|
1642
|
+
pageNavigation: platform("pageNavigation"),
|
|
1643
|
+
portalToken: platform("portalToken"),
|
|
1644
|
+
siteName: platform("siteName"),
|
|
1645
|
+
siteTerms: platform("siteTerms"),
|
|
1646
|
+
form: data,
|
|
1647
|
+
initialData: data,
|
|
1648
|
+
noticeMessage: data,
|
|
1649
|
+
rebookContext: data,
|
|
1650
|
+
requiresResourceSelection: data,
|
|
1651
|
+
requiresServiceSelection: data,
|
|
1652
|
+
resourceId: data,
|
|
1653
|
+
services: data,
|
|
1654
|
+
shouldAutoSelectSingleResource: data,
|
|
1655
|
+
formId: text(64),
|
|
1656
|
+
serviceId: text(64)
|
|
1657
|
+
});
|
|
1658
|
+
const weeklySlotAvailability = {
|
|
1659
|
+
className,
|
|
1660
|
+
...PLATFORM_API,
|
|
1661
|
+
availability: data,
|
|
1662
|
+
ctaText: text(100),
|
|
1663
|
+
ctaUrl: href,
|
|
1664
|
+
emptyMessage: text(500),
|
|
1665
|
+
horizonWeeks: whole(1, 12),
|
|
1666
|
+
resourceId: text(64),
|
|
1667
|
+
serviceId: text(64)
|
|
1668
|
+
};
|
|
1669
|
+
const EVENT_DISPLAY = {
|
|
1670
|
+
buttonText: text(100),
|
|
1671
|
+
buttonVariant,
|
|
1672
|
+
emptyMessage: text(500),
|
|
1673
|
+
showCapacity: flag,
|
|
1674
|
+
showVenue: flag,
|
|
1675
|
+
showMap: flag
|
|
1676
|
+
};
|
|
1677
|
+
const eventRegistration = forRenderer()({
|
|
1678
|
+
className,
|
|
1679
|
+
...PLATFORM_API,
|
|
1680
|
+
...READ_AUTHORITY,
|
|
1681
|
+
bookingOfferingPresets: platform("bookingOfferingPresets"),
|
|
1682
|
+
demoEmailSuppressed: platform("demoEmailSuppressed"),
|
|
1683
|
+
loaderFailures: platform("loaderFailures"),
|
|
1684
|
+
mailingList: platform("mailingList"),
|
|
1685
|
+
occurrenceContext: platform("occurrenceContext"),
|
|
1686
|
+
pageNavigation: platform("pageNavigation"),
|
|
1687
|
+
portalToken: platform("portalToken"),
|
|
1688
|
+
siteName: platform("siteName"),
|
|
1689
|
+
siteTerms: platform("siteTerms"),
|
|
1690
|
+
stage: platform("previewStage"),
|
|
1691
|
+
subject: platform("subject"),
|
|
1692
|
+
events: data,
|
|
1693
|
+
wholeSeriesRunEvents: data,
|
|
1694
|
+
buttonText: text(100),
|
|
1695
|
+
buttonVariant,
|
|
1696
|
+
successMessage: text(1e3),
|
|
1697
|
+
maxTickets: whole(1, 50),
|
|
1698
|
+
showCapacity: flag,
|
|
1699
|
+
showVenue: flag
|
|
1700
|
+
});
|
|
1701
|
+
const eventSpotlight = forRenderer()({
|
|
1702
|
+
className,
|
|
1703
|
+
...EVENT_DISPLAY,
|
|
1704
|
+
events: data,
|
|
1705
|
+
columns: whole(1, 4),
|
|
1706
|
+
ctaLabel: text(100),
|
|
1707
|
+
ctaUrl: href
|
|
1708
|
+
});
|
|
1709
|
+
const EVENT_COLLECTION = {
|
|
1710
|
+
className,
|
|
1711
|
+
...PLATFORM_API,
|
|
1712
|
+
...READ_AUTHORITY,
|
|
1713
|
+
...EVENT_DISPLAY,
|
|
1714
|
+
stage: platform("previewStage"),
|
|
1715
|
+
events: data,
|
|
1716
|
+
columns: whole(1, 4),
|
|
1717
|
+
eventsPerPage: whole(1, 100),
|
|
1718
|
+
loadMoreText: text(100),
|
|
1719
|
+
seeAllUrl: href
|
|
1720
|
+
};
|
|
1721
|
+
const eventCalendar = forRenderer()({
|
|
1722
|
+
...EVENT_COLLECTION,
|
|
1723
|
+
dateContext: platform("dateContext"),
|
|
1724
|
+
bookingTimeZone: platform("dateContext.timeZone"),
|
|
1725
|
+
calendarWindow: data,
|
|
1726
|
+
schedule: data,
|
|
1727
|
+
boardTitle: text(200),
|
|
1728
|
+
panelHeading: text(200),
|
|
1729
|
+
footerNote: text(500),
|
|
1730
|
+
showFilters: flag,
|
|
1731
|
+
showCategoryFilter: flag,
|
|
1732
|
+
showStaffFilter: flag,
|
|
1733
|
+
showVenueFilter: flag
|
|
1734
|
+
});
|
|
1735
|
+
const offeringsPreview = {
|
|
1736
|
+
className,
|
|
1737
|
+
siteId: platform("siteId"),
|
|
1738
|
+
now: platform("now"),
|
|
1739
|
+
pathname: platform("pathname"),
|
|
1740
|
+
previewStage: platform("previewStage"),
|
|
1741
|
+
bookingOfferingPresets: platform("bookingOfferingPresets"),
|
|
1742
|
+
catalogueEvents: data,
|
|
1743
|
+
classEvents: data,
|
|
1744
|
+
performanceEvents: data,
|
|
1745
|
+
quickDateEvents: data,
|
|
1746
|
+
retreatEvents: data,
|
|
1747
|
+
routeCandidates: data,
|
|
1748
|
+
wholeSeriesRunEvents: data,
|
|
1749
|
+
workshopEvents: data,
|
|
1750
|
+
buttonText: text(100),
|
|
1751
|
+
buttonVariant,
|
|
1752
|
+
emptyMessage: text(500),
|
|
1753
|
+
itemLimit: whole(1, 50),
|
|
1754
|
+
showPhotos: flag
|
|
1755
|
+
};
|
|
1756
|
+
const COMMERCE = {
|
|
1757
|
+
className,
|
|
1758
|
+
...PLATFORM_API,
|
|
1759
|
+
...READ_AUTHORITY
|
|
1760
|
+
};
|
|
1761
|
+
/** Every node type a custom layout may use, with the props it takes. */
|
|
1762
|
+
const LAYOUT_NODE_SCHEMAS = {
|
|
1763
|
+
div,
|
|
1764
|
+
figure: div,
|
|
1765
|
+
section,
|
|
1766
|
+
headerSection: section,
|
|
1767
|
+
stack,
|
|
1768
|
+
inline,
|
|
1769
|
+
grid,
|
|
1770
|
+
text: textNode,
|
|
1771
|
+
richText,
|
|
1772
|
+
media,
|
|
1773
|
+
videoEmbed,
|
|
1774
|
+
icon,
|
|
1775
|
+
"feature-card-icon": featureCardIcon,
|
|
1776
|
+
svg,
|
|
1777
|
+
button,
|
|
1778
|
+
link,
|
|
1779
|
+
carousel,
|
|
1780
|
+
accordion,
|
|
1781
|
+
accordionItem,
|
|
1782
|
+
form,
|
|
1783
|
+
"booking-form": bookingForm,
|
|
1784
|
+
"weekly-slot-availability": weeklySlotAvailability,
|
|
1785
|
+
"event-registration": eventRegistration,
|
|
1786
|
+
"event-spotlight": eventSpotlight,
|
|
1787
|
+
"event-listing": EVENT_COLLECTION,
|
|
1788
|
+
"event-calendar": eventCalendar,
|
|
1789
|
+
"offerings-preview": offeringsPreview,
|
|
1790
|
+
"event-combined": EVENT_COLLECTION,
|
|
1791
|
+
shop: {
|
|
1792
|
+
...COMMERCE,
|
|
1793
|
+
dateContext: platform("dateContext"),
|
|
1794
|
+
demoEmailSuppressed: platform("demoEmailSuppressed"),
|
|
1795
|
+
siteTerms: platform("siteTerms"),
|
|
1796
|
+
mode: oneOf(["passes-memberships"]),
|
|
1797
|
+
memberships: data,
|
|
1798
|
+
passes: data,
|
|
1799
|
+
buyButtonText: text(100),
|
|
1800
|
+
emptyStateText: text(500),
|
|
1801
|
+
membershipsHeading: text(200),
|
|
1802
|
+
passesHeading: text(200),
|
|
1803
|
+
subscribeButtonText: text(100),
|
|
1804
|
+
buttonVariant,
|
|
1805
|
+
columns: whole(1, 4),
|
|
1806
|
+
showDescriptions: flag,
|
|
1807
|
+
showMemberships: flag,
|
|
1808
|
+
showPasses: flag,
|
|
1809
|
+
showPhotos: flag,
|
|
1810
|
+
showPricePerCredit: flag,
|
|
1811
|
+
showValidityPeriod: flag
|
|
1812
|
+
},
|
|
1813
|
+
"product-list": {
|
|
1814
|
+
...COMMERCE,
|
|
1815
|
+
mode: oneOf(["product-list"]),
|
|
1816
|
+
products: data,
|
|
1817
|
+
addButtonText: text(100),
|
|
1818
|
+
emptyStateText: text(500),
|
|
1819
|
+
heading: text(200),
|
|
1820
|
+
columns: whole(1, 4),
|
|
1821
|
+
showPrices: flag,
|
|
1822
|
+
showSummary: flag
|
|
1823
|
+
},
|
|
1824
|
+
"product-detail": {
|
|
1825
|
+
...COMMERCE,
|
|
1826
|
+
contentEntry: platform("contentEntry"),
|
|
1827
|
+
template: platform("template"),
|
|
1828
|
+
mode: oneOf(["product-detail"]),
|
|
1829
|
+
products: data,
|
|
1830
|
+
productSlug: text(200),
|
|
1831
|
+
addButtonText: text(100),
|
|
1832
|
+
emptyStateText: text(500),
|
|
1833
|
+
heading: text(200),
|
|
1834
|
+
showBody: flag,
|
|
1835
|
+
showSummary: flag
|
|
1836
|
+
},
|
|
1837
|
+
cart: {
|
|
1838
|
+
...COMMERCE,
|
|
1839
|
+
mode: oneOf(["cart"]),
|
|
1840
|
+
checkoutButtonText: text(100),
|
|
1841
|
+
clearButtonText: text(100),
|
|
1842
|
+
emptyStateText: text(500),
|
|
1843
|
+
heading: text(200)
|
|
1844
|
+
},
|
|
1845
|
+
checkout: {
|
|
1846
|
+
...COMMERCE,
|
|
1847
|
+
demoEmailSuppressed: platform("demoEmailSuppressed"),
|
|
1848
|
+
mode: oneOf(["checkout"]),
|
|
1849
|
+
emptyStateText: text(500),
|
|
1850
|
+
heading: text(200),
|
|
1851
|
+
submitButtonText: text(100)
|
|
1852
|
+
},
|
|
1853
|
+
gifting: {
|
|
1854
|
+
className,
|
|
1855
|
+
...PLATFORM_API,
|
|
1856
|
+
siteTerms: platform("siteTerms"),
|
|
1857
|
+
offers: data,
|
|
1858
|
+
checkoutButtonText: text(100),
|
|
1859
|
+
emptyStateText: text(500),
|
|
1860
|
+
giftCardsHeading: text(200),
|
|
1861
|
+
heading: text(200),
|
|
1862
|
+
intro: text(1e3),
|
|
1863
|
+
successMessage: text(1e3),
|
|
1864
|
+
vouchersHeading: text(200)
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
function layoutNodeSchema(type) {
|
|
1868
|
+
return typeof type === "string" && hasOwn(LAYOUT_NODE_SCHEMAS, type) ? LAYOUT_NODE_SCHEMAS[type] : null;
|
|
1869
|
+
}
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region ../blocks/src/system/node/safeLayoutProps.ts
|
|
1872
|
+
/**
|
|
1873
|
+
* What a custom-block layout may put on the page (issue 1185).
|
|
1874
|
+
*
|
|
1875
|
+
* Custom-block layouts are data: they arrive from SDK config, the management
|
|
1876
|
+
* API and LLM authors, get stored, and are then rendered by the node
|
|
1877
|
+
* primitives. Everything such a layout can put on the DOM is allowed by an
|
|
1878
|
+
* explicit rule for that slot, and anything without a rule is refused:
|
|
1879
|
+
*
|
|
1880
|
+
* - each node type has a prop schema (`layoutGate/nodeSchemas`), so an unknown
|
|
1881
|
+
* prop, or a known one with the wrong shape, is refused;
|
|
1882
|
+
* - each slot decides what a literal may be and what a binding may resolve to,
|
|
1883
|
+
* counting fallbacks, transform options and `$prepend`/`$append`
|
|
1884
|
+
* (`layoutGate/slots`);
|
|
1885
|
+
* - styles, classes and links have their own allowlists (`layoutGate/css`,
|
|
1886
|
+
* `layoutGate/classes`, and the rich-text link policy in core);
|
|
1887
|
+
* - platform values (API origin, site id, tokens) are only ever passed through
|
|
1888
|
+
* from `$root`, and nothing else in a layout can read `$root`.
|
|
1889
|
+
*
|
|
1890
|
+
* First-party block definitions are trusted code and do not pass through here.
|
|
1891
|
+
*/
|
|
1892
|
+
const NODE_KEYS = /* @__PURE__ */ new Set([
|
|
1893
|
+
"$bind",
|
|
1894
|
+
"$repeat",
|
|
1895
|
+
"$when",
|
|
1896
|
+
"$scopes"
|
|
1897
|
+
]);
|
|
1898
|
+
const NAME = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
1899
|
+
const stringify = (value) => {
|
|
1900
|
+
try {
|
|
1901
|
+
return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
1902
|
+
} catch {
|
|
1903
|
+
return Object.prototype.toString.call(value);
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
const preview = (value) => {
|
|
1907
|
+
const text = stringify(value);
|
|
1908
|
+
return text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
1909
|
+
};
|
|
1910
|
+
const toIssue = ({ path, property, value, reason }) => ({
|
|
1911
|
+
path,
|
|
1912
|
+
property,
|
|
1913
|
+
value: preview(value),
|
|
1914
|
+
message: `Unsafe value at ${path}: ${reason}.`
|
|
1915
|
+
});
|
|
1916
|
+
const plain = (path, property, value, reason) => ({
|
|
1917
|
+
path,
|
|
1918
|
+
property,
|
|
1919
|
+
value,
|
|
1920
|
+
reason
|
|
1921
|
+
});
|
|
1922
|
+
function propIssues(schema, type, node, path, scope) {
|
|
1923
|
+
const props = nodePropEntries(node).flatMap(([name, value, where]) => {
|
|
1924
|
+
const propPath = where === "props" ? `${path}.props.${name}` : `${path}.${name}`;
|
|
1925
|
+
const slot = hasOwn(schema, name) ? schema[name] : void 0;
|
|
1926
|
+
if (value === null || value === void 0) return [];
|
|
1927
|
+
return slot ? slotIssues(slot, value, propPath, name, scope) : [plain(propPath, name, value, `"${name}" is not a prop a ${type} node takes in a custom-block layout`)];
|
|
1928
|
+
});
|
|
1929
|
+
const bind = node.$bind;
|
|
1930
|
+
const valueSlot = hasOwn(schema, "value") ? schema.value : void 0;
|
|
1931
|
+
const bound = bind === void 0 || bind === null ? [] : valueSlot ? slotIssues(valueSlot, { $bind: bind }, path, "value", scope) : [plain(`${path}.$bind`, "$bind", bind, `a ${type} node does not take a bound value`)];
|
|
1932
|
+
return [...props, ...bound].map(toIssue);
|
|
1933
|
+
}
|
|
1934
|
+
function whenIssues(when, path) {
|
|
1935
|
+
if (when === void 0 || when === null) return [];
|
|
1936
|
+
if (!isRecord(when)) return [plain(`${path}.$when`, "$when", when, "$when must be an object")];
|
|
1937
|
+
return directiveBindingIssues(when.when, "decides", `${path}.$when.when`, "$when");
|
|
1938
|
+
}
|
|
1939
|
+
function repeatNameIssues(repeat, path) {
|
|
1940
|
+
return ["itemName", "indexName"].flatMap((name) => {
|
|
1941
|
+
const value = repeat[name];
|
|
1942
|
+
return value != null && (typeof value !== "string" || !NAME.test(value)) ? [plain(`${path}.$repeat.${name}`, "$repeat", value, `${name} must be a short name such as item`)] : [];
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
function repeatIssues(repeat, path) {
|
|
1946
|
+
if (repeat === void 0 || repeat === null) return [];
|
|
1947
|
+
if (!isRecord(repeat)) return [plain(`${path}.$repeat`, "$repeat", repeat, "$repeat must be an object")];
|
|
1948
|
+
const sortPath = isRecord(repeat.sortBy) ? repeat.sortBy.path : void 0;
|
|
1949
|
+
const sortIssues = sortPath != null && (typeof sortPath !== "string" || !CONTENT_PATH.test(sortPath)) ? [plain(`${path}.$repeat.sortBy.path`, "$repeat", sortPath, "sortBy.path must be a field path")] : [];
|
|
1950
|
+
return [
|
|
1951
|
+
...directiveBindingIssues(repeat.collection, "holds", `${path}.$repeat.collection`, "$repeat"),
|
|
1952
|
+
...repeatNameIssues(repeat, path),
|
|
1953
|
+
...sortIssues
|
|
1954
|
+
];
|
|
1955
|
+
}
|
|
1956
|
+
function scopesIssues(scopes, path) {
|
|
1957
|
+
if (scopes === void 0 || scopes === null) return [];
|
|
1958
|
+
if (!Array.isArray(scopes)) return [plain(`${path}.$scopes`, "$scopes", scopes, "$scopes must be a list")];
|
|
1959
|
+
return scopes.flatMap((entry, index) => {
|
|
1960
|
+
const at = `${path}.$scopes[${index}]`;
|
|
1961
|
+
return isRecord(entry) && typeof entry.name === "string" && NAME.test(entry.name) ? directiveBindingIssues(entry.from, "holds", `${at}.from`, "$scopes") : [plain(at, "$scopes", entry, "each scope needs a short name such as item")];
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
function directiveIssues(node, path) {
|
|
1965
|
+
return [
|
|
1966
|
+
...Object.keys(node).filter((key) => key.startsWith("$") && !NODE_KEYS.has(key)).map((key) => plain(`${path}.${key}`, key, node[key], `"${key}" is not a node directive`)),
|
|
1967
|
+
...whenIssues(node.$when, path),
|
|
1968
|
+
...repeatIssues(node.$repeat, path),
|
|
1969
|
+
...scopesIssues(node.$scopes, path)
|
|
1970
|
+
].map(toIssue);
|
|
1971
|
+
}
|
|
1972
|
+
const childNodes = (node) => isRecord(node) && Array.isArray(node.children) ? node.children : [];
|
|
1973
|
+
/**
|
|
1974
|
+
* The issue with a layout's size, checked before anything walks the whole
|
|
1975
|
+
* tree: a layout nested thousands deep would otherwise run the walk out of
|
|
1976
|
+
* stack and fail the request rather than be refused.
|
|
1977
|
+
*/
|
|
1978
|
+
function customBlockLayoutSizeIssues(layout, path = "layout") {
|
|
1979
|
+
const problem = customLayoutSizeProblem(layout);
|
|
1980
|
+
return problem === null ? [] : [{
|
|
1981
|
+
path,
|
|
1982
|
+
property: "children",
|
|
1983
|
+
value: "",
|
|
1984
|
+
message: problem
|
|
1985
|
+
}];
|
|
1986
|
+
}
|
|
1987
|
+
function nodeIssues(node, path, scope) {
|
|
1988
|
+
if (!isRecord(node)) return [];
|
|
1989
|
+
const ownScope = { insideScope: scope.insideScope || node.$repeat != null || node.$scopes != null };
|
|
1990
|
+
const schema = layoutNodeSchema(node.type);
|
|
1991
|
+
const childrenIssues = node.children != null && !Array.isArray(node.children) ? [toIssue(plain(`${path}.children`, "children", node.children, "children must be a list of nodes"))] : [];
|
|
1992
|
+
return [
|
|
1993
|
+
...schema && typeof node.type === "string" ? propIssues(schema, node.type, node, path, ownScope) : [],
|
|
1994
|
+
...directiveIssues(node, path),
|
|
1995
|
+
...childrenIssues,
|
|
1996
|
+
...childNodes(node).flatMap((child, index) => nodeIssues(child, `${path}.children[${index}]`, ownScope))
|
|
1997
|
+
];
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Every issue in a custom-block layout tree. Empty means it is safe to store
|
|
2001
|
+
* and render. A layout that is too large gets that one issue and is not walked.
|
|
2002
|
+
*/
|
|
2003
|
+
function customBlockLayoutPropIssues(layout, path = "layout") {
|
|
2004
|
+
const sizeIssues = customBlockLayoutSizeIssues(layout, path);
|
|
2005
|
+
return sizeIssues.length > 0 ? sizeIssues : nodeIssues(layout, path, { insideScope: false });
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Every issue with the field defaults of a custom block that has a layout.
|
|
2009
|
+
* The layout's author writes them too, so they are not content to trust.
|
|
2010
|
+
*/
|
|
2011
|
+
function customBlockFieldDefaultIssues(fields, path = "fields") {
|
|
2012
|
+
return fieldDefaultIssues(fields, path).map(toIssue);
|
|
2013
|
+
}
|
|
2014
|
+
//#endregion
|
|
2015
|
+
//#region src/zod/titleSourceSchema.ts
|
|
2016
|
+
const titleSourceValueSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
2017
|
+
//#endregion
|
|
2018
|
+
export { isCustomBlockClassName as a, ALLOWED_NODE_TYPES_SET as c, customBlockLayoutSizeIssues as i, ALLOWED_TRANSFORM_IDS as l, customBlockFieldDefaultIssues as n, LAYOUT_Z_INDEX_RULE as o, customBlockLayoutPropIssues as r, ALLOWED_NODE_TYPES as s, titleSourceValueSchema as t, ALLOWED_TRANSFORM_IDS_SET as u };
|