@riverbankcms/sdk 0.181.0 → 0.183.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/README.md +49 -3
- package/dist/_dts/{BlocksIslandsHydrator-CVCasDPz.d.ts → BlocksIslandsHydrator-X1_G96iN.d.ts} +1 -1
- package/dist/_dts/{Page-Dtj2Ui3S.d.ts → Page-CEqZJZEE.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-D1f_60WW.d.ts → SdkPreviewMode-DQejfbXL.d.ts} +2 -2
- package/dist/_dts/{client-Chr9pNVW.d.ts → client-B_B_amKD.d.ts} +2 -3
- package/dist/_dts/{content-types-kjccgopX.d.ts → content-types-Dhx5Ocvx.d.ts} +9 -16
- package/dist/_dts/{contracts-BodaiS00.d.ts → contracts-FeOnfoa1.d.ts} +3 -3
- package/dist/_dts/{generatePageMetadata-BS6kaJFp.d.ts → generatePageMetadata-m70J6tit.d.ts} +2 -2
- package/dist/_dts/{index-Brl6_I2j.d.ts → index-BOpUh8kO.d.ts} +1 -1
- package/dist/_dts/{index-CJkefwYh.d.ts → index-Bizdaxji.d.ts} +2 -2
- package/dist/_dts/{index-Diqt0PvG.d.ts → index-BxCmCit0.d.ts} +1 -1
- package/dist/_dts/{index-DG0OvBs0.d.ts → index-CjAkEWAp.d.ts} +4 -4
- package/dist/_dts/{index-D1WpKwQe.d.ts → index-iuFrbIjt.d.ts} +1 -1
- package/dist/_dts/{index-Dy50xUMK.d.ts → index-liuhlOX7.d.ts} +2 -2
- package/dist/_dts/{loadContent-BgxshKrA.d.ts → loadContent-D4wrTIIw.d.ts} +7 -7
- package/dist/_dts/{request-CA0izds5.d.ts → request-Gn0O1blj.d.ts} +25042 -23761
- package/dist/_dts/{resolveBlockData-ChQmwEd3.d.ts → resolveBlockData-D5duwuqS.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-BvGyvblj.d.ts → resolvePageContent-xzJ3c9Na.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 +7 -7
- 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 -1
- package/dist/_dts/sdk/src/index.d.ts +8 -8
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
- package/dist/_dts/sdk/src/next/index.d.ts +7 -7
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
- package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
- package/dist/_dts/sdk/src/portal/index.d.ts +1 -1
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +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 +91 -2
- package/dist/_dts/{serviceBookingOutline-BgFbJQhU.d.ts → serviceBookingOutline-B1gyJon_.d.ts} +7 -7
- package/dist/_dts/{types-CgS3xLk8.d.ts → types-BoITy0rA.d.ts} +41 -4
- package/dist/_dts/{types-CQrsP1x_.d.ts → types-DBNuMtSk.d.ts} +16 -5
- package/dist/_dts/{types-R65DKjPn.d.ts → types-DHMcuoeQ.d.ts} +7 -7
- package/dist/_dts/{validation-6LTIbuBA.d.ts → validation-BIPO-XlE.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-DqZPz6oW.mjs → BlocksIslandsHydrator-Ct8slgRk.mjs} +22 -18
- package/dist/client/{BookingMailingListNote-uWfR2kaG.mjs → BookingMailingListNote-qqTxGGS4.mjs} +7 -7
- package/dist/client/{BookingQuestionFields-CyNIKw6k.mjs → BookingQuestionFields-DCh9MUIF.mjs} +2 -2
- package/dist/client/{CalendarAction-D_Glwvz2.mjs → CalendarAction-RcdaStG7.mjs} +1 -1
- package/dist/client/{CalendarNavigationChevron-BGCX3zwG.mjs → CalendarNavigationChevron-D7Wt-Oaa.mjs} +27 -10
- package/dist/client/{CheckboxChoice-C8i4NraK.mjs → CheckboxChoice-BdGxZWeg.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-DFLPyuqe.mjs → DemoBookingPortalAccess-HFVkoOac.mjs} +5 -5
- package/dist/client/{EventCalendar.client-zDL4-t-B.mjs → EventCalendar.client-BtkJW8bA.mjs} +10 -10
- package/dist/client/{EventCombined.client-uciDKLID.mjs → EventCombined.client-DxaGjFFS.mjs} +9 -9
- package/dist/client/{EventEmbeddedCheckoutStep-BGkbUhuw.mjs → EventEmbeddedCheckoutStep-B2c5dR49.mjs} +1 -1
- package/dist/client/{EventItem-CwzrjcRw.mjs → EventItem-Fr2qi2C2.mjs} +33 -186
- package/dist/client/{EventListWeekNavigation-ChvcnPma.mjs → EventListWeekNavigation-BRMaq0ky.mjs} +1 -1
- package/dist/client/{EventListing.client-DA57Qoyx.mjs → EventListing.client-BhGxfbjt.mjs} +3 -3
- package/dist/client/{EventListing.view-DZ0qMFF4.mjs → EventListing.view-COuEJzbO.mjs} +8 -8
- package/dist/client/{EventRegistrationPayment-DSqCJL8E.mjs → EventRegistrationPayment-BTLYhVxD.mjs} +41 -195
- package/dist/client/{Page-C7mygH_f.mjs → Page-CgbQZP5g.mjs} +2947 -1018
- package/dist/client/{ProtectedSubmitButton-BNnKuir8.mjs → ProtectedSubmitButton-BG7my0Qf.mjs} +1 -1
- package/dist/client/{SiteTermsAgreementField-B4z-e4Wq.mjs → SiteTermsAgreementField-DQNkfNLA.mjs} +3 -3
- package/dist/client/{StepIndicator-Dn_DY4oY.mjs → StepIndicator-DvPekKeM.mjs} +1 -1
- package/dist/client/{StepIndicator-atfDU82W.mjs → StepIndicator-DyXoI3ob.mjs} +221 -20
- package/dist/client/{ThemedButton-PFOhXktM.mjs → ThemedButton-Bc9DBbVp.mjs} +42 -9
- package/dist/client/{accessibleSurfaces-n6kS6Hct.mjs → accessibleSurfaces-wj4Rloo5.mjs} +1214 -724
- package/dist/client/{accordion-CsW8U3ff.mjs → accordion-BVXfjnh-.mjs} +1 -1
- package/dist/client/{booking-form.client-cBWM392H.mjs → booking-form.client-DycPGtke.mjs} +191 -71
- package/dist/client/{bookingForm-DgySpp6C.mjs → bookingForm-DrWSUqL3.mjs} +4 -4
- package/dist/client/bookings.mjs +5 -5
- package/dist/client/{boxStyleClassNames-BpGVdLFD.mjs → boxStyleClassNames-CduDRcIk.mjs} +2 -2
- package/dist/client/buttonParts-CJEtVOUy.mjs +1511 -0
- package/dist/client/{carousel-DJoleFV3.mjs → carousel-DyCLMP8s.mjs} +2 -2
- package/dist/client/{carousel.client-BtLwHefX.mjs → carousel.client-DffP_Nv0.mjs} +1 -1
- package/dist/client/{cart-EO5o6uPH.mjs → cart-BuEp_cj4.mjs} +3 -3
- package/dist/client/{cart.client-D_gPw45z.mjs → cart.client-CAO39uDG.mjs} +1 -1
- package/dist/client/{checkout-NVfZW0kR.mjs → checkout-BoxzT64s.mjs} +3 -3
- package/dist/client/{checkout.client-DD3JuqOy.mjs → checkout.client-IGUy7XOx.mjs} +1 -1
- package/dist/client/{checkoutUrls-z2gXvlGw.mjs → checkoutUrls-D0UsiFmm.mjs} +1 -1
- package/dist/client/client.mjs +466 -94
- package/dist/client/{constants-CoOkvw__.mjs → constants-C_8AxMdm.mjs} +1 -1
- package/dist/client/{context-CRhn9qzS.mjs → context-D1L0pe__.mjs} +23 -5
- package/dist/client/{dateFormatting-BnWB4L1s.mjs → dateFormatting-HvfmS_cH.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-CWDGSTBu.mjs → demoPortalMagicLink-BunFTnIq.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-tdP_-Z9o.mjs → enhanceHeaderSection-CtLAG651.mjs} +4 -4
- package/dist/client/{event-registration.client-D7YYKySQ.mjs → event-registration.client-DiSxkBUP.mjs} +15 -15
- package/dist/client/{eventCalendar-CsAfu5d0.mjs → eventCalendar-DUnhwZ1o.mjs} +4 -4
- package/dist/client/{eventCombined-VXJB5CoS.mjs → eventCombined-BvBQo0nF.mjs} +4 -4
- package/dist/client/{eventListing-B3KIZNfY.mjs → eventListing-aTLifOX7.mjs} +4 -4
- package/dist/client/{eventRegistration-BP-dEk1c.mjs → eventRegistration-DFd7pr09.mjs} +4 -4
- package/dist/client/{form-DM8Zbxbv.mjs → form-Dikmc2AO.mjs} +3 -3
- package/dist/client/{form.client-e2z_Tlgk.mjs → form.client-zHaQK5I9.mjs} +5 -5
- package/dist/client/{form.parts-Ctljy1a3.mjs → form.parts-BLl9n8TH.mjs} +3 -3
- package/dist/client/gifting/client.mjs +16 -9
- package/dist/client/{gifting-DWIsqQru.mjs → gifting-CufPM38H.mjs} +4 -4
- package/dist/client/{gifting.client-QsSWF0uA.mjs → gifting.client--N1GaSY8.mjs} +155 -84
- package/dist/client/gifting.interactive-D9MK4HkV.mjs +157 -0
- package/dist/client/gifting.parts-CRtiRzo-.mjs +119 -0
- package/dist/client/{headerSection-DAkRkwb-.mjs → headerSection-BIaBpmk3.mjs} +2 -2
- package/dist/client/{noop-Dl4mZ-rr.mjs → islands-DJDLGQEm.mjs} +16008 -8676
- package/dist/client/{newsletter-form.client-WYja9-WN.mjs → newsletter-form.client-wg_JHTxm.mjs} +6 -6
- package/dist/client/{newsletter-form.interactive-RuM86VAv.mjs → newsletter-form.interactive-hzpkW9NQ.mjs} +384 -326
- package/dist/client/{newsletter-form.parts-2petDnWv.mjs → newsletter-form.parts-CgzpSv9p.mjs} +2 -2
- package/dist/client/{newsletterForm-BUbXdA_e.mjs → newsletterForm-CvxLiEBT.mjs} +3 -3
- package/dist/client/portal/client.mjs +291 -101
- package/dist/client/{portalOrders-COGn4BKG.mjs → portalOrders-tCxS04g0.mjs} +3 -2
- package/dist/client/{portalRoutes-D72yvtDh.mjs → portalRoutes-DTHlWg_F.mjs} +33 -7
- package/dist/client/{product-detail.client-pOAryevt.mjs → product-detail.client-22Q7zgjN.mjs} +1 -1
- package/dist/client/{product-list.client-CcUpUiud.mjs → product-list.client-DFWYvK8z.mjs} +1 -1
- package/dist/client/{productDetail-BZJCfqat.mjs → productDetail-DhZAwo60.mjs} +3 -3
- package/dist/client/{productList-CiRs3mNb.mjs → productList-BiVpbZK2.mjs} +3 -3
- package/dist/client/{propsDecoder--uHW4tFM.mjs → propsDecoder-DFYqKnLy.mjs} +4 -2
- package/dist/client/{registry.server-CDNNd8wC.mjs → registry.server-C3OBRg7x.mjs} +2305 -873
- package/dist/client/rendering/client.mjs +29 -26
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +5 -5
- package/dist/client/{richText-coerce-CQGE_wHV.mjs → richText-coerce-ms477Z08.mjs} +2 -2
- package/dist/client/{routeIslandApiConfig-BtCg87-N.mjs → routeIslandApiConfig-B6nQeqvH.mjs} +1 -1
- package/dist/client/{runtimeResponse-Ds9cmBUf.mjs → runtimeResponse-BYqsV1Kb.mjs} +1 -1
- package/dist/client/runtimeResponse-CUX_lldL.mjs +3 -0
- package/dist/client/{shop-commerce-D8evQnMT.mjs → shop-commerce-DVsIcPaI.mjs} +16 -15
- package/dist/client/{shop-commerce-store-C9PcsSTj.mjs → shop-commerce-store-7mO6KY7_.mjs} +1 -1
- package/dist/client/{shop-discount-apply.state-D5CtGfJI.mjs → shop-discount-apply.state-L1Vge8tG.mjs} +2 -2
- package/dist/client/{shop-Rx_gEMK8.mjs → shop-xt4dQ3HH.mjs} +3 -3
- package/dist/client/{shop.client-D4lzQ9oY.mjs → shop.client-DNJfD3VQ.mjs} +28 -17
- package/dist/client/{shopShared-BVbq7Nm-.mjs → shopShared-DS8t6749.mjs} +2 -2
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/{src-ZSqRK3dD.mjs → src-Do_s2lqH.mjs} +16 -19
- package/dist/client/{timetableModel-BQJrSK0K.mjs → timetableModel-Dy3nNfTG.mjs} +13 -17
- package/dist/client/{useAvailableSlots-Dm3lKJKR.mjs → useAvailableSlots-DcjtDpUu.mjs} +2 -2
- package/dist/client/{useDiscountCodeUi-klgfGn7f.mjs → useDiscountCodeUi-DvdFFWOT.mjs} +1 -1
- package/dist/client/{useEventPagination-Jnjt7_ly.mjs → useEventPagination-Cq-7sU5_.mjs} +8 -8
- package/dist/client/{view-CC_yQLSA.mjs → view-4gnPcpWJ.mjs} +24 -9
- package/dist/client/{wizardSteps-BliJOzEX.mjs → wizardSteps-DDvL3iza.mjs} +375 -186
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-aRJjq4x8.mjs → EventEmbeddedCheckoutStep-CLqSRUpt.mjs} +1 -1
- package/dist/preview-next/client/{LocationPickerEnvironment-BW3dRFIv.mjs → LocationPickerEnvironment-CIdAg-Tm.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-Db9BHyXh.mjs → MapLibreEditMap-Bm85jX35.mjs} +2 -2
- package/dist/preview-next/client/{PageSectionToolbar-BhL0uADo.mjs → PageSectionToolbar-D8srnz9R.mjs} +445 -18
- package/dist/preview-next/client/{PreviewEditorSidebar-Ct8eIm0i.mjs → PreviewEditorSidebar-DVpk5cqp.mjs} +3871 -1947
- package/dist/preview-next/client/{PreviewEditorUI-BS32G4V9.mjs → PreviewEditorUI-XoTtHSFH.mjs} +11 -36
- package/dist/preview-next/client/{PreviewShell-RL0WfZXD.mjs → PreviewShell-VQHsRg2u.mjs} +40 -35
- package/dist/preview-next/client/{SdkPreviewModeRuntime-MK_gHeGy.mjs → SdkPreviewModeRuntime-CLdF9f6o.mjs} +51 -20
- package/dist/preview-next/client/{ThemedButton-CVYz7h68.mjs → ThemedButton-ORNN4x-3.mjs} +782 -16
- package/dist/preview-next/client/{lucide-react-00FF_oar.mjs → lucide-react-eAi3tDAr.mjs} +11 -1
- package/dist/preview-next/client/{previewAssistantSlot-CQyS8pcq.mjs → previewAssistantSlot-CqH91EwA.mjs} +20687 -8562
- package/dist/preview-next/client/{previewChromeRoot-BSxp3Mfu.mjs → previewChromeRoot-B3ySEu6p.mjs} +3 -90
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-DKnTzy74.mjs → sdk-runtime-CdpSupcr.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-BlmbvbLN.mjs → siteStyleAccess-C6eOP6QW.mjs} +35 -6
- package/dist/preview-next/client/{useAutosaveStatus-D-7GwZOQ.mjs → useAutosaveStatus-BhPg4e-r.mjs} +49 -3
- package/dist/preview-next/client/{useOpenBlockForSetup-BNZtGM5g.mjs → useOpenBlockForSetup-BaWUF9D7.mjs} +2007 -448
- package/dist/preview-next/container-responsive.css +320 -0
- package/dist/preview-next/editor-chrome.css +23 -2
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-R3PcMmax.mjs → route-contract-Ch0X99vE.mjs} +183 -18
- package/dist/server/{Block.shared-CniF9tSu.mjs → Block.shared-B2FmczLO.mjs} +5 -5
- package/dist/server/{ThemeScopeCore-BQWsnGT6.mjs → ThemeScopeCore-DtAyv9qA.mjs} +51 -29
- package/dist/server/{accessibleSurfaces-WPzUAHp4.mjs → accessibleSurfaces-BtPqb76u.mjs} +509 -389
- package/dist/server/{accordions-By_0Ykks.mjs → accordions-vzdZ2Wt1.mjs} +1 -1
- package/dist/server/{bindings-DxojjtK3.mjs → bindings-B_9JuU66.mjs} +7 -7
- package/dist/server/{client-CDndhbYO.mjs → client-DC7cjiSw.mjs} +489 -93
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/{constants-VyF5nEhL.mjs → constants-d6nPNJpe.mjs} +33 -6
- package/dist/server/{customCss-C9kgPHvr.mjs → customCss-rtIfEYwQ.mjs} +1 -18
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/{resolveButtonColourStates-B0O1IM16.mjs → expandPalette-DxPrNOAB.mjs} +950 -316
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-BKstMBmX.mjs → loadContent-hb27HYic.mjs} +11 -10
- package/dist/server/{loadPage-IgNnZaqr.mjs → loadPage-JToD8wDD.mjs} +3 -3
- package/dist/server/{lookMediaFrame-TFjgNG61.mjs → lookMediaFrame-CTsycLLK.mjs} +94 -39
- package/dist/server/manifest.mjs +2 -2
- package/dist/server/{navigation-quBYlSKD.mjs → navigation-B2WhGofA.mjs} +1 -1
- package/dist/server/navigation.mjs +1 -1
- package/dist/server/next.mjs +8 -8
- package/dist/server/{overrideResolution-CCaAPpIa.mjs → overrideResolution-vD5KTClL.mjs} +1 -1
- package/dist/server/page-converter.mjs +3 -3
- package/dist/server/{pageRenderPlan-B7iULvKe.mjs → pageRenderPlan-CdqJ1NQZ.mjs} +242 -336
- package/dist/server/{pageRuntimeSupport-BytMroxn.mjs → pageRuntimeSupport-CAhr4oOf.mjs} +3 -3
- package/dist/server/{pageShared-Dcs_XTIO.mjs → pageShared-m80Xu2pd.mjs} +1292 -877
- package/dist/server/{parseThemeForPersistence-Bihl4W5K.mjs → parseThemeForPersistence-CRwOZfpa.mjs} +3 -3
- package/dist/server/{portal-CMW_b9mG.mjs → portal-B2wCQno_.mjs} +1 -1
- package/dist/server/portal.mjs +2 -2
- package/dist/server/{prebuild-agaH-vZV.mjs → prebuild-BWIkFaXq.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-DwpRjqw4.mjs → prefetchBlockData-D1PHU-K9.mjs} +3 -3
- package/dist/server/{registry-DM9dHfDC.mjs → registry-KtsOsAzY.mjs} +21703 -10936
- 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 +9 -9
- package/dist/server/{resolveBlockData-CinHGf8l.mjs → resolveBlockData-sjIDJYl7.mjs} +1 -1
- package/dist/server/{schema-CwfxQjc4.mjs → schema-BBEqquBM.mjs} +44 -28
- package/dist/server/server.mjs +3 -3
- package/dist/server/{servicePageContent-BBBhOtdE.mjs → servicePageContent-ChEZDRwU.mjs} +38 -15
- package/dist/server/theme-bridge.mjs +34 -9
- package/dist/server/theme.mjs +2 -2
- package/dist/server/{three-pass-converter-DPaUPTfl.mjs → three-pass-converter-DKCIBeb1.mjs} +2 -2
- package/dist/server/{titleSourceSchema-NhK6azFS.mjs → titleSourceSchema-DybHErxH.mjs} +4 -4
- package/dist/server/{typeGuards-CTW_9AXq.mjs → typeGuards-DZOaGTEv.mjs} +126 -126
- package/dist/server/{types-BKaBZFjD.mjs → types-vyz09w64.mjs} +479 -8
- package/dist/server/{validation-DG5jX3jH.mjs → validation-Cvi-1TZZ.mjs} +13 -9
- package/dist/server/{version-CipbxPHL.mjs → version-B-icAIV1.mjs} +1 -1
- package/dist/server/{video-Cdr3wh-q.mjs → video-DBaeSawZ.mjs} +1 -1
- package/dist/styles/index.css +2568 -154
- package/package.json +1 -1
- package/dist/client/gifting.parts-CedLgwa_.mjs +0 -86
- package/dist/client/runtimeResponse-DL_ARBpa.mjs +0 -3
- package/dist/client/types-BEaKfam_.mjs +0 -778
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { c as buttonEffectApplicationSchema, m as parseOpaqueButtonColourToken,
|
|
1
|
+
import { G as hexColorSchema, K as isThemeColorToken, O as surfaceForegroundValue, Q as parseColorTokenParts, U as PALETTE_TOKEN_NAMES, Y as paletteColorsFromEntries, Z as paletteModeSchema, c as buttonEffectApplicationSchema, m as parseOpaqueButtonColourToken, q as normalizePaletteHex, s as unsafeAsOpaqueButtonColourToken } from "./types-vyz09w64.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
//#region ../theme-core/src/palette/utils/colorConversion.ts
|
|
3
4
|
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
4
5
|
const mod = (a, n) => (a % n + n) % n;
|
|
@@ -227,6 +228,10 @@ function solidPaint(hex, index) {
|
|
|
227
228
|
const y = hexLuminance(hex, index);
|
|
228
229
|
return new Interval(y, y);
|
|
229
230
|
}
|
|
231
|
+
/** The smallest paint covering every given paint: an ink that clears it clears each of them. */
|
|
232
|
+
function spanningPaint(first, ...rest) {
|
|
233
|
+
return rest.reduce((span, paint) => new Interval(paint.lo < span.lo ? paint.lo : span.lo, paint.hi > span.hi ? paint.hi : span.hi), first);
|
|
234
|
+
}
|
|
230
235
|
function luminanceRatio(a, b) {
|
|
231
236
|
return a >= b ? (a + .05) / (b + .05) : (b + .05) / (a + .05);
|
|
232
237
|
}
|
|
@@ -242,8 +247,8 @@ function assertContrastRatio(ratio) {
|
|
|
242
247
|
* The one black-or-white rule: literal black or white, whichever contrasts more
|
|
243
248
|
* with the whole paint (black on a tie). It always returns, even when neither
|
|
244
249
|
* reaches the ratio a caller wants; callers decide what a shortfall means.
|
|
245
|
-
* A style's preferred neutral
|
|
246
|
-
*
|
|
250
|
+
* A style's preferred neutral or the palette's own roles are separate inputs
|
|
251
|
+
* (`neutralInk`, `paletteInk`) that are tried before this rule, never part of it.
|
|
247
252
|
*/
|
|
248
253
|
function maxContrastBlackOrWhite(paint) {
|
|
249
254
|
const blackContrast = (paint.lo + .05) / .05;
|
|
@@ -256,6 +261,9 @@ function maxContrastBlackOrWhite(paint) {
|
|
|
256
261
|
ratio: whiteContrast
|
|
257
262
|
};
|
|
258
263
|
}
|
|
264
|
+
function literalInkHex(ink) {
|
|
265
|
+
return ink === "black" ? "#000000" : "#FFFFFF";
|
|
266
|
+
}
|
|
259
267
|
function contrastRatio(hex1, hex2, index) {
|
|
260
268
|
const L1 = indexedLuminance(hex1, index);
|
|
261
269
|
const L2 = indexedLuminance(hex2, index);
|
|
@@ -263,119 +271,116 @@ function contrastRatio(hex1, hex2, index) {
|
|
|
263
271
|
return (hi + .05) / (lo + .05);
|
|
264
272
|
}
|
|
265
273
|
//#endregion
|
|
266
|
-
//#region ../theme-core/src/palette/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
400,
|
|
274
|
-
500,
|
|
275
|
-
600,
|
|
276
|
-
700,
|
|
277
|
-
800,
|
|
278
|
-
900,
|
|
279
|
-
950
|
|
280
|
-
];
|
|
281
|
-
const base = featuresFromHex(hexColor);
|
|
282
|
-
const hue = base.okH;
|
|
283
|
-
const baseChroma = base.okC;
|
|
284
|
-
const toneMap = {
|
|
285
|
-
50: .975,
|
|
286
|
-
100: .945,
|
|
287
|
-
200: .89,
|
|
288
|
-
300: .82,
|
|
289
|
-
400: .74,
|
|
290
|
-
500: .66,
|
|
291
|
-
600: .58,
|
|
292
|
-
700: .49,
|
|
293
|
-
800: .4,
|
|
294
|
-
900: .28,
|
|
295
|
-
950: .16
|
|
296
|
-
};
|
|
297
|
-
const shadeDefs = shadeSteps.map((step, idx) => {
|
|
298
|
-
const t = idx / (shadeSteps.length - 1);
|
|
299
|
-
const L = toneMap[step];
|
|
300
|
-
const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
|
|
301
|
-
return {
|
|
302
|
-
name: `${name}-${step}`,
|
|
303
|
-
hex: oklchToHexGamut(L, C, hue)
|
|
304
|
-
};
|
|
305
|
-
});
|
|
306
|
-
shadeDefs.push({
|
|
307
|
-
name,
|
|
308
|
-
hex: hexColor
|
|
309
|
-
});
|
|
310
|
-
return shadeDefs;
|
|
274
|
+
//#region ../theme-core/src/palette/colors.ts
|
|
275
|
+
const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
|
|
276
|
+
z.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
|
|
277
|
+
function requirePaletteColorsFromEntries(entries) {
|
|
278
|
+
const result = paletteColorsFromEntries(entries);
|
|
279
|
+
if (result.ok) return result.colors;
|
|
280
|
+
throw new Error(`Invalid complete palette: ${result.error.kind}`);
|
|
311
281
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
|
|
316
|
-
* on every palette, light or dark. Readers that want "the ground" or "the
|
|
317
|
-
* text" ask the palette for those roles, not a fixed end of this scale.
|
|
318
|
-
*/
|
|
319
|
-
function generateNeutralScale({ steps = 11, warm = false } = {}) {
|
|
320
|
-
const shadeNames = [
|
|
321
|
-
50,
|
|
322
|
-
100,
|
|
323
|
-
200,
|
|
324
|
-
300,
|
|
325
|
-
400,
|
|
326
|
-
500,
|
|
327
|
-
600,
|
|
328
|
-
700,
|
|
329
|
-
800,
|
|
330
|
-
900,
|
|
331
|
-
950
|
|
332
|
-
];
|
|
333
|
-
const count = Math.min(steps, shadeNames.length);
|
|
334
|
-
return shadeNames.slice(0, count).map((shadeName, index) => ({
|
|
335
|
-
name: `neutral-${shadeName}`,
|
|
336
|
-
hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), .02, warm ? 85 : 250)
|
|
337
|
-
}));
|
|
282
|
+
function paletteColorFingerprint(colors) {
|
|
283
|
+
return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
|
|
338
284
|
}
|
|
339
|
-
function
|
|
340
|
-
return
|
|
285
|
+
function canonicalPaletteHashInput(colors, mode) {
|
|
286
|
+
return `${mode}|${paletteColorFingerprint(colors)}`;
|
|
341
287
|
}
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
344
288
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* `maxContrastBlackOrWhite` for a solid ground.
|
|
348
|
-
*
|
|
349
|
-
* @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
|
|
350
|
-
* @param _minContrast - Kept for callers. It cannot change the result: when
|
|
351
|
-
* only one of black or white reaches it, that one is also the better of the two.
|
|
352
|
-
* @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
|
|
289
|
+
* Stable curated-catalogue identity. Do not reorder roles: the order comes
|
|
290
|
+
* from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
|
|
353
291
|
*/
|
|
354
|
-
function
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
292
|
+
function paletteValueKey(colors, mode) {
|
|
293
|
+
return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
|
|
294
|
+
}
|
|
295
|
+
/** Parses only the exact v1 canonical form emitted by paletteValueKey. */
|
|
296
|
+
function parsePaletteValueKey(value) {
|
|
297
|
+
if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
|
|
298
|
+
const [rawMode, ...rawRoles] = value.slice(17).split("|");
|
|
299
|
+
const mode = paletteModeSchema.safeParse(rawMode);
|
|
300
|
+
if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
|
|
301
|
+
const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
|
|
302
|
+
const separator = roleValue.indexOf(":");
|
|
303
|
+
return separator === -1 ? {
|
|
304
|
+
name: "",
|
|
305
|
+
hex: ""
|
|
306
|
+
} : {
|
|
307
|
+
name: roleValue.slice(0, separator),
|
|
308
|
+
hex: roleValue.slice(separator + 1)
|
|
309
|
+
};
|
|
310
|
+
}));
|
|
311
|
+
if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
|
|
312
|
+
return value;
|
|
313
|
+
}
|
|
314
|
+
const paletteValueKeySchema = z.string().transform((value, ctx) => {
|
|
315
|
+
const parsed = parsePaletteValueKey(value);
|
|
316
|
+
if (parsed) return parsed;
|
|
317
|
+
ctx.addIssue({
|
|
318
|
+
code: "custom",
|
|
319
|
+
message: "Invalid canonical palette value key"
|
|
320
|
+
});
|
|
321
|
+
return z.NEVER;
|
|
322
|
+
});
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region ../theme-core/src/palette/utils/opaqueSurfaceColor.ts
|
|
325
|
+
/** Resolve an opaque colour, compositing alpha against an explicit underlay. */
|
|
326
|
+
function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
|
|
327
|
+
const opaque = resolveConcreteColorHex(reference, palette);
|
|
328
|
+
if (opaque) return opaque;
|
|
329
|
+
if (!underlayReference) return null;
|
|
330
|
+
const underlayHex = resolveConcreteColorHex(underlayReference, palette);
|
|
331
|
+
if (!underlayHex) return null;
|
|
332
|
+
const parts = parseColorTokenParts(reference);
|
|
333
|
+
if (parts.kind === "token" && parts.opacityPercent !== null) {
|
|
334
|
+
const foregroundHex = normalizePaletteHex(palette[parts.token] ?? "");
|
|
335
|
+
return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
|
|
336
|
+
}
|
|
337
|
+
const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
|
|
338
|
+
return rgba ? compositeHex$1(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
|
|
339
|
+
}
|
|
340
|
+
/** Resolve a colour reference only when it is already fully opaque. */
|
|
341
|
+
function resolveConcreteColorHex(reference, palette) {
|
|
342
|
+
const literalHex = normalizePaletteHex(reference);
|
|
343
|
+
if (literalHex) return literalHex;
|
|
344
|
+
const parts = parseColorTokenParts(reference);
|
|
345
|
+
if (parts.kind === "token") {
|
|
346
|
+
if (parts.opacityPercent !== null) return null;
|
|
347
|
+
return normalizePaletteHex(palette[parts.token] ?? "");
|
|
348
|
+
}
|
|
349
|
+
const literal = parts.kind === "raw" ? parts.value : reference;
|
|
350
|
+
if (literal.toLowerCase() === "black") return "#000000";
|
|
351
|
+
if (literal.toLowerCase() === "white") return "#ffffff";
|
|
352
|
+
return normalizePaletteHex(literal);
|
|
353
|
+
}
|
|
354
|
+
function compositeHex$1(foregroundHex, underlayHex, alpha) {
|
|
355
|
+
const foreground = hexToRgb(foregroundHex);
|
|
356
|
+
const underlay = hexToRgb(underlayHex);
|
|
357
|
+
const channel = (foregroundValue, underlayValue) => Math.round(foregroundValue * alpha + underlayValue * (1 - alpha));
|
|
358
|
+
return rgbToHex(channel(foreground.r, underlay.r), channel(foreground.g, underlay.g), channel(foreground.b, underlay.b));
|
|
359
|
+
}
|
|
360
|
+
function parseRgba(value) {
|
|
361
|
+
const match = value.trim().match(/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*(?:,|\/)\s*([\d.]+%?))?\s*\)$/i);
|
|
362
|
+
if (!match) return null;
|
|
363
|
+
const [, rSource, gSource, bSource] = match;
|
|
364
|
+
if (!rSource || !gSource || !bSource) return null;
|
|
365
|
+
const r = Number(rSource);
|
|
366
|
+
const g = Number(gSource);
|
|
367
|
+
const b = Number(bSource);
|
|
368
|
+
const alpha = parseAlpha(match[4]);
|
|
369
|
+
if (alpha === null || !isRgbChannel(r) || !isRgbChannel(g) || !isRgbChannel(b)) return null;
|
|
370
|
+
return {
|
|
371
|
+
r,
|
|
372
|
+
g,
|
|
373
|
+
b,
|
|
374
|
+
alpha
|
|
373
375
|
};
|
|
374
|
-
throw new Error("Unsupported color format");
|
|
375
376
|
}
|
|
376
|
-
function
|
|
377
|
-
if (
|
|
378
|
-
|
|
377
|
+
function parseAlpha(source) {
|
|
378
|
+
if (!source) return 1;
|
|
379
|
+
const value = source.endsWith("%") ? Number(source.slice(0, -1)) / 100 : Number(source);
|
|
380
|
+
return Number.isFinite(value) && value >= 0 && value <= 1 ? value : null;
|
|
381
|
+
}
|
|
382
|
+
function isRgbChannel(value) {
|
|
383
|
+
return Number.isFinite(value) && value >= 0 && value <= 255;
|
|
379
384
|
}
|
|
380
385
|
//#endregion
|
|
381
386
|
//#region ../theme-core/src/palette/utils/onColor.ts
|
|
@@ -401,117 +406,6 @@ function isOnColorBackgroundCandidateToken(token) {
|
|
|
401
406
|
return BACKGROUND_ROLE_NAMES.has(role);
|
|
402
407
|
}
|
|
403
408
|
//#endregion
|
|
404
|
-
//#region ../theme-core/src/palette/expandPalette.ts
|
|
405
|
-
function colorsToMap(palette) {
|
|
406
|
-
const map = {};
|
|
407
|
-
for (const c of palette.colors) map[c.name] = c.hex;
|
|
408
|
-
return map;
|
|
409
|
-
}
|
|
410
|
-
const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
|
|
411
|
-
"success",
|
|
412
|
-
"warning",
|
|
413
|
-
"destructive"
|
|
414
|
-
]);
|
|
415
|
-
/**
|
|
416
|
-
* Status role aliases the persisted palette does not carry itself.
|
|
417
|
-
*
|
|
418
|
-
* Generators reference `--tb-error` (the site-style-owned input error border)
|
|
419
|
-
* and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
|
|
420
|
-
* palette schema only defines `destructive` and has no `info` role at all.
|
|
421
|
-
* Without these aliases those declarations name variables that are never
|
|
422
|
-
* defined and browsers drop them. The SDK bridge resolves the same pair via
|
|
423
|
-
* TOKEN_ALIASES, so both runtimes agree on what a status token means.
|
|
424
|
-
*
|
|
425
|
-
* Runs after the danger → destructive promotion above, so `destructive` is
|
|
426
|
-
* already the single source of truth for the error colour.
|
|
427
|
-
*/
|
|
428
|
-
function statusAliasTokens(expanded) {
|
|
429
|
-
const aliases = {};
|
|
430
|
-
if (expanded.destructive) aliases.error = expanded.destructive;
|
|
431
|
-
if (expanded.accent) aliases.info = expanded.accent;
|
|
432
|
-
return aliases;
|
|
433
|
-
}
|
|
434
|
-
function expandPalette(palette, options = {}) {
|
|
435
|
-
return {
|
|
436
|
-
...expandBasePalette(palette),
|
|
437
|
-
...arrangementPaletteTokens(colorsToMap(palette), options)
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
function expandBasePalette(palette) {
|
|
441
|
-
const base = colorsToMap(palette);
|
|
442
|
-
const expanded = { ...base };
|
|
443
|
-
generateNeutralScale({
|
|
444
|
-
steps: 11,
|
|
445
|
-
warm: false
|
|
446
|
-
}).forEach((n) => {
|
|
447
|
-
expanded[n.name] = n.hex;
|
|
448
|
-
});
|
|
449
|
-
for (const [name, hex] of Object.entries(base)) {
|
|
450
|
-
if (nonShadeablePaletteRoleNames.has(name)) continue;
|
|
451
|
-
if (hex) generateShades(hex, name).forEach((shade) => {
|
|
452
|
-
expanded[shade.name] = shade.hex;
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
if (base.text) expanded.body = base.text;
|
|
456
|
-
if (base.danger && !base.destructive) expanded.destructive = base.danger;
|
|
457
|
-
Object.assign(expanded, statusAliasTokens(expanded));
|
|
458
|
-
expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base);
|
|
459
|
-
for (const [token, hex] of Object.entries({ ...expanded })) {
|
|
460
|
-
if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
|
|
461
|
-
const onToken = onColorTokenName(token);
|
|
462
|
-
if (expanded[onToken]) continue;
|
|
463
|
-
expanded[onToken] = getTextColorForBackground(hex);
|
|
464
|
-
}
|
|
465
|
-
return expanded;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* The neutral step stays when it reads on the ground. Otherwise (a dark palette
|
|
469
|
-
* on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
|
|
470
|
-
* with a 4.5:1 floor, heading for black or white when the text can't reach it.
|
|
471
|
-
*/
|
|
472
|
-
function readableMutedText(step, base) {
|
|
473
|
-
const ground = base.background || base.surface;
|
|
474
|
-
if (!ground || contrastRatio(step, ground) >= 4.5) return step;
|
|
475
|
-
return deriveSurfaceMutedColor(ground, base.text && contrastRatio(base.text, ground) >= 4.5 ? base.text : getTextColorForBackground(ground));
|
|
476
|
-
}
|
|
477
|
-
/** Derived decoration colours never become editable palette swatches. */
|
|
478
|
-
function deriveSurfaceDecorationColors(ground, text, accent) {
|
|
479
|
-
const ink = getTextColorForBackground(ground);
|
|
480
|
-
return {
|
|
481
|
-
line: firstContrastBlend(ground, text, ground, 1.5),
|
|
482
|
-
mark: firstContrastBlend(accent, ink, ground, 3)
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
/** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
|
|
486
|
-
function deriveSurfaceMutedColor(ground, text) {
|
|
487
|
-
const start = hexToRgb(ground);
|
|
488
|
-
const end = hexToRgb(text);
|
|
489
|
-
const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
|
|
490
|
-
return firstSafeMutedSample(sample, ground, 0, 100);
|
|
491
|
-
}
|
|
492
|
-
/** The blend moves monotonically from the ground toward its validated ink. */
|
|
493
|
-
function firstSafeMutedSample(sample, ground, low, high) {
|
|
494
|
-
if (low === high) return sample(high);
|
|
495
|
-
const middle = Math.floor((low + high) / 2);
|
|
496
|
-
return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
|
|
497
|
-
}
|
|
498
|
-
function firstContrastBlend(from, to, ground, threshold) {
|
|
499
|
-
const start = hexToRgb(from);
|
|
500
|
-
const end = hexToRgb(to);
|
|
501
|
-
return Array.from({ length: 101 }, (_, index) => {
|
|
502
|
-
const amount = index / 100;
|
|
503
|
-
return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
|
|
504
|
-
}).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
|
|
505
|
-
}
|
|
506
|
-
/** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
|
|
507
|
-
function arrangementPaletteTokens(base, options) {
|
|
508
|
-
if (options.arrangement !== true || !base.text) return {};
|
|
509
|
-
return {
|
|
510
|
-
onText: getTextColorForBackground(base.text),
|
|
511
|
-
...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
//#endregion
|
|
515
409
|
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
|
|
516
410
|
function _assertClassBrand(e, t, n) {
|
|
517
411
|
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
@@ -609,6 +503,250 @@ function member(hex, sample) {
|
|
|
609
503
|
};
|
|
610
504
|
}
|
|
611
505
|
//#endregion
|
|
506
|
+
//#region ../theme-core/src/palette/utils/inkSolver.ts
|
|
507
|
+
/**
|
|
508
|
+
* How far (OKLab ΔE) a brand colour drawn as ink may be nudged along its own
|
|
509
|
+
* family before it stops reading as that colour. Past this the caller uses
|
|
510
|
+
* neutral or palette text instead (Will, 2026-10-14).
|
|
511
|
+
*/
|
|
512
|
+
const BRAND_INK_MAX_DELTA_E = .08;
|
|
513
|
+
/**
|
|
514
|
+
* The seed itself when it clears `paint`, otherwise the family member nearest
|
|
515
|
+
* the seed (OKLab ΔE) that clears. On a light ground that is darker, on a dark
|
|
516
|
+
* one lighter. A passing member further than `maxDistance` from the seed is
|
|
517
|
+
* refused as `too-far`, which is distinct from `unpaintable`: the family runs
|
|
518
|
+
* from black to white, so if no member clears, neither does black or white.
|
|
519
|
+
*/
|
|
520
|
+
function inkFrom(family, paint, ratio, maxDistance = BRAND_INK_MAX_DELTA_E) {
|
|
521
|
+
assertContrastRatio(ratio);
|
|
522
|
+
if (!Number.isFinite(maxDistance) || maxDistance < 0) throw new RangeError(`Maximum ink distance must be finite and not negative: ${maxDistance}`);
|
|
523
|
+
const seedRatio = worstContrast(family.seed.y, paint);
|
|
524
|
+
if (seedRatio >= ratio) return {
|
|
525
|
+
kind: "ink",
|
|
526
|
+
hex: family.seed.hex,
|
|
527
|
+
ratio: seedRatio,
|
|
528
|
+
source: "exact"
|
|
529
|
+
};
|
|
530
|
+
const nearest = family.members.reduce((best, member) => {
|
|
531
|
+
const achieved = worstContrast(member.y, paint);
|
|
532
|
+
if (achieved < ratio) return best;
|
|
533
|
+
const distance = oklabDistance(member.oklab, family.seed.oklab);
|
|
534
|
+
return best === null || distance < best.distance ? {
|
|
535
|
+
hex: member.hex,
|
|
536
|
+
distance,
|
|
537
|
+
ratio: achieved
|
|
538
|
+
} : best;
|
|
539
|
+
}, null);
|
|
540
|
+
if (nearest === null) return {
|
|
541
|
+
kind: "unpaintable",
|
|
542
|
+
interval: paint,
|
|
543
|
+
ratio
|
|
544
|
+
};
|
|
545
|
+
if (nearest.distance > maxDistance) return {
|
|
546
|
+
kind: "too-far",
|
|
547
|
+
nearest: {
|
|
548
|
+
hex: nearest.hex,
|
|
549
|
+
distance: nearest.distance
|
|
550
|
+
},
|
|
551
|
+
maxDistance
|
|
552
|
+
};
|
|
553
|
+
return {
|
|
554
|
+
kind: "ink",
|
|
555
|
+
hex: nearest.hex,
|
|
556
|
+
ratio: nearest.ratio,
|
|
557
|
+
source: "family"
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* The one "preferred ink, else black or white" comparison. Of the candidates,
|
|
562
|
+
* the one with the most contrast against the whole paint wins if it reaches
|
|
563
|
+
* `ratio` (the earlier one on a tie); otherwise literal black or white by
|
|
564
|
+
* `maxContrastBlackOrWhite`; otherwise `unpaintable`. It's direction-neutral:
|
|
565
|
+
* a candidate pair of one dark and one light ink needs no light/dark branch.
|
|
566
|
+
*/
|
|
567
|
+
function preferredOrLiteralInk(paint, ratio, candidates) {
|
|
568
|
+
assertContrastRatio(ratio);
|
|
569
|
+
const best = candidates.map((candidate) => ({
|
|
570
|
+
...candidate,
|
|
571
|
+
ratio: worstContrast(hexLuminance(candidate.hex), paint)
|
|
572
|
+
})).reduce((winner, candidate) => winner === null || candidate.ratio > winner.ratio ? candidate : winner, null);
|
|
573
|
+
if (best !== null && best.ratio >= ratio) return {
|
|
574
|
+
kind: "candidate",
|
|
575
|
+
value: best.value,
|
|
576
|
+
ratio: best.ratio
|
|
577
|
+
};
|
|
578
|
+
const literal = maxContrastBlackOrWhite(paint);
|
|
579
|
+
return literal.ratio >= ratio ? {
|
|
580
|
+
kind: "literal",
|
|
581
|
+
ink: literal.ink,
|
|
582
|
+
ratio: literal.ratio
|
|
583
|
+
} : {
|
|
584
|
+
kind: "unpaintable",
|
|
585
|
+
interval: paint,
|
|
586
|
+
ratio
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Neutral text for a paint. The style's preferred neutral wins when one of its
|
|
591
|
+
* pair clears (the higher-contrast one, dark on a tie); otherwise literal black
|
|
592
|
+
* or white by `maxContrastBlackOrWhite`; otherwise `unpaintable`.
|
|
593
|
+
*/
|
|
594
|
+
function neutralInk(paint, ratio, preferred) {
|
|
595
|
+
const picked = preferredOrLiteralInk(paint, ratio, preferred ? [{
|
|
596
|
+
value: preferred.dark,
|
|
597
|
+
hex: preferred.dark
|
|
598
|
+
}, {
|
|
599
|
+
value: preferred.light,
|
|
600
|
+
hex: preferred.light
|
|
601
|
+
}] : []);
|
|
602
|
+
switch (picked.kind) {
|
|
603
|
+
case "candidate": return {
|
|
604
|
+
kind: "ink",
|
|
605
|
+
hex: picked.value,
|
|
606
|
+
ratio: picked.ratio,
|
|
607
|
+
source: "neutral"
|
|
608
|
+
};
|
|
609
|
+
case "literal": return {
|
|
610
|
+
kind: "ink",
|
|
611
|
+
hex: picked.ink === "black" ? "#000000" : "#ffffff",
|
|
612
|
+
ratio: picked.ratio,
|
|
613
|
+
source: "neutral"
|
|
614
|
+
};
|
|
615
|
+
case "unpaintable": return picked;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
/** The palette's `background` and `text` as an ink pair, or null when either is missing or not a hex colour. */
|
|
619
|
+
function paletteInkRoles(palette) {
|
|
620
|
+
const background = hexColorSchema.safeParse(palette.background?.toLowerCase());
|
|
621
|
+
const text = hexColorSchema.safeParse(palette.text?.toLowerCase());
|
|
622
|
+
return background.success && text.success ? {
|
|
623
|
+
background: background.data,
|
|
624
|
+
text: text.data
|
|
625
|
+
} : null;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Palette text for a paint: of the palette's background and text, the one with
|
|
629
|
+
* more contrast against the whole paint when it reaches `ratio`; otherwise
|
|
630
|
+
* literal black or white; otherwise `unpaintable`. On a dark palette the
|
|
631
|
+
* background is the dark one, so the same rule mirrors with no mode branch.
|
|
632
|
+
*/
|
|
633
|
+
function paletteInk(paint, roles, ratio = ORDINARY_TEXT_MIN_CONTRAST_RATIO) {
|
|
634
|
+
const picked = preferredOrLiteralInk(paint, ratio, roles ? ["text", "background"].map((role) => ({
|
|
635
|
+
value: {
|
|
636
|
+
role,
|
|
637
|
+
hex: roles[role]
|
|
638
|
+
},
|
|
639
|
+
hex: roles[role]
|
|
640
|
+
})) : []);
|
|
641
|
+
switch (picked.kind) {
|
|
642
|
+
case "candidate": return {
|
|
643
|
+
kind: "role",
|
|
644
|
+
...picked.value,
|
|
645
|
+
ratio: picked.ratio
|
|
646
|
+
};
|
|
647
|
+
case "literal": return {
|
|
648
|
+
kind: "literal",
|
|
649
|
+
hex: literalInkHex(picked.ink),
|
|
650
|
+
ratio: picked.ratio
|
|
651
|
+
};
|
|
652
|
+
case "unpaintable": return picked;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/** Ordinary-text palette ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
|
|
656
|
+
function paletteInkOnSolid(groundHex, roles) {
|
|
657
|
+
const paint = solidPaint(groundHex);
|
|
658
|
+
const ink = paletteInk(paint, roles);
|
|
659
|
+
if (ink.kind !== "unpaintable") return ink;
|
|
660
|
+
const literal = maxContrastBlackOrWhite(paint);
|
|
661
|
+
return {
|
|
662
|
+
kind: "literal",
|
|
663
|
+
hex: literalInkHex(literal.ink),
|
|
664
|
+
ratio: literal.ratio
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* The ink as token emitters write it: the role's theme token, so CSS follows
|
|
669
|
+
* the palette's variables, or the literal hex.
|
|
670
|
+
*/
|
|
671
|
+
function paletteInkToken(ink) {
|
|
672
|
+
if (ink.kind === "literal") return ink.hex;
|
|
673
|
+
if (!isThemeColorToken(ink.role)) throw new Error(`Palette ink role is not a theme token: ${ink.role}`);
|
|
674
|
+
return ink.role;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Secondary text that has to read on several grounds (a surface and the tinted
|
|
678
|
+
* cards laid on it). The full-strength ink is `preferred` when it reaches 4.5:1
|
|
679
|
+
* on every ground, otherwise the palette's ink over the same paint; the muted
|
|
680
|
+
* ink is then the faintest blend from the first ground toward it that still
|
|
681
|
+
* reaches 4.5:1 everywhere. When no ink reaches 4.5:1 on every ground (a light
|
|
682
|
+
* ground and a dark one together), it's `unpaintable` and the caller decides
|
|
683
|
+
* which grounds to give up, rather than receiving a colour that only claims to read.
|
|
684
|
+
*/
|
|
685
|
+
function paletteMutedInk(grounds, preferred, roles) {
|
|
686
|
+
const [first, ...rest] = grounds;
|
|
687
|
+
const paint = spanningPaint(solidPaint(first), ...rest.map((ground) => solidPaint(ground)));
|
|
688
|
+
const contrast = (hex) => worstContrast(hexLuminance(hex), paint);
|
|
689
|
+
const passes = (hex) => contrast(hex) >= ORDINARY_TEXT_MIN_CONTRAST_RATIO;
|
|
690
|
+
const endpoint = preferred !== null && passes(preferred) ? {
|
|
691
|
+
kind: "preferred",
|
|
692
|
+
hex: preferred
|
|
693
|
+
} : paletteInk(paint, roles);
|
|
694
|
+
if (endpoint.kind === "unpaintable") return endpoint;
|
|
695
|
+
const start = hexToRgb(first);
|
|
696
|
+
const end = hexToRgb(endpoint.hex);
|
|
697
|
+
const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
|
|
698
|
+
const firstPassing = (low, high) => {
|
|
699
|
+
if (low >= high) return high;
|
|
700
|
+
const middle = Math.floor((low + high) / 2);
|
|
701
|
+
return passes(sample(middle)) ? firstPassing(low, middle) : firstPassing(middle + 1, high);
|
|
702
|
+
};
|
|
703
|
+
const hex = sample(firstPassing(0, 100));
|
|
704
|
+
return {
|
|
705
|
+
kind: "muted",
|
|
706
|
+
hex,
|
|
707
|
+
ratio: contrast(hex)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
/** The muted ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
|
|
711
|
+
function paletteMutedInkOnSolid(ground, preferred, roles) {
|
|
712
|
+
const ink = paletteMutedInk([ground], preferred, roles);
|
|
713
|
+
if (ink.kind === "unpaintable") throw new Error(`No muted ink reads on the solid ground ${ground}`);
|
|
714
|
+
return ink.hex;
|
|
715
|
+
}
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
718
|
+
/**
|
|
719
|
+
* Pick the better of black/white text for a given background using actual
|
|
720
|
+
* contrast ratios, not a simple luminance cutoff. This is
|
|
721
|
+
* `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
|
|
722
|
+
* only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
|
|
723
|
+
* background and text colours first.
|
|
724
|
+
*
|
|
725
|
+
* @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
|
|
726
|
+
* @param _minContrast - Kept for callers. It cannot change the result: when
|
|
727
|
+
* only one of black or white reaches it, that one is also the better of the two.
|
|
728
|
+
* @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
|
|
729
|
+
*/
|
|
730
|
+
function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
|
|
731
|
+
const { r, g, b } = parseColorToRgb(background);
|
|
732
|
+
return literalInkHex(maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink);
|
|
733
|
+
}
|
|
734
|
+
function parseColorToRgb(input) {
|
|
735
|
+
const trimmed = input.trim();
|
|
736
|
+
if (trimmed.startsWith("#")) return hexToRgb(trimmed);
|
|
737
|
+
const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/i);
|
|
738
|
+
if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
|
|
739
|
+
r: clamp255(Number(rgbMatch[1])),
|
|
740
|
+
g: clamp255(Number(rgbMatch[2])),
|
|
741
|
+
b: clamp255(Number(rgbMatch[3]))
|
|
742
|
+
};
|
|
743
|
+
throw new Error("Unsupported color format");
|
|
744
|
+
}
|
|
745
|
+
function clamp255(value) {
|
|
746
|
+
if (Number.isNaN(value)) return 0;
|
|
747
|
+
return Math.max(0, Math.min(255, value));
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
612
750
|
//#region ../theme-core/src/buttons/constants.ts
|
|
613
751
|
/**
|
|
614
752
|
* Shared constants for button CSS generation
|
|
@@ -1084,15 +1222,42 @@ function unknownEffect(input, effect) {
|
|
|
1084
1222
|
}
|
|
1085
1223
|
//#endregion
|
|
1086
1224
|
//#region ../theme-core/src/buttons/contextualHover.ts
|
|
1225
|
+
/**
|
|
1226
|
+
* The smallest OKLab move that reads as a hover. Neighbouring steps of a
|
|
1227
|
+
* palette scale are about 0.06 to 0.08 apart.
|
|
1228
|
+
*/
|
|
1229
|
+
const MINIMUM_VISIBLE_STEP = .04;
|
|
1230
|
+
/**
|
|
1231
|
+
* The contrast at which a fill reads as a fill rather than a shadow on its
|
|
1232
|
+
* ground. It applies when the recipe names the ink to fill with
|
|
1233
|
+
* (`preferredToken`): those buttons rest as an outline and fill only on hover,
|
|
1234
|
+
* so the fill has to read against the ground on its own. A button edge can keep
|
|
1235
|
+
* a darker fill distinct, but it then looks like a hole in the panel.
|
|
1236
|
+
*/
|
|
1237
|
+
const FILL_CLEARS_GROUND = 1.5;
|
|
1238
|
+
/** Two label inks closer than this read as the same ink (a near-black for black); a light label against a dark one is far above it. */
|
|
1239
|
+
const SAME_LABEL_INK = 3;
|
|
1240
|
+
/** A step a filled button can change its label for: one or two neighbouring shades of its scale. */
|
|
1241
|
+
const NEAR_STEP = .2;
|
|
1242
|
+
/**
|
|
1243
|
+
* The ends of a scale are often close to neutral black or white. A shade below
|
|
1244
|
+
* the dark end or above the light end (OKLab lightness) that has under this
|
|
1245
|
+
* share of the seed's chroma reads as grey, black or white, not as the button.
|
|
1246
|
+
*/
|
|
1247
|
+
const HUELESS_DARK_END = .2;
|
|
1248
|
+
const HUELESS_LIGHT_END = .94;
|
|
1249
|
+
const HUE_KEPT_SHARE = .5;
|
|
1250
|
+
/** The recipe's own hover ink wins when it holds; otherwise the shade shift decides. */
|
|
1087
1251
|
function resolveContextualHoverPreference(input) {
|
|
1088
1252
|
const preferred = input.instruction.preferredToken;
|
|
1089
|
-
if (preferred &&
|
|
1253
|
+
if (preferred && preferredInkHolds(preferred, input)) return {
|
|
1090
1254
|
kind: "resolved",
|
|
1091
1255
|
token: preferred,
|
|
1092
1256
|
repair: null
|
|
1093
1257
|
};
|
|
1094
1258
|
const contextual = resolveContextualHover(input);
|
|
1095
|
-
|
|
1259
|
+
if (contextual.kind === "unavailable") return contextual;
|
|
1260
|
+
return {
|
|
1096
1261
|
kind: "resolved",
|
|
1097
1262
|
token: contextual.token,
|
|
1098
1263
|
repair: preferred ? {
|
|
@@ -1100,112 +1265,154 @@ function resolveContextualHoverPreference(input) {
|
|
|
1100
1265
|
preferredToken: preferred,
|
|
1101
1266
|
contextualToken: contextual.token
|
|
1102
1267
|
} : null
|
|
1103
|
-
}
|
|
1268
|
+
};
|
|
1104
1269
|
}
|
|
1105
1270
|
/**
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1271
|
+
* Chooses the hover fill from the seed's own shade family, so the hue stays.
|
|
1272
|
+
*
|
|
1273
|
+
* A hover should read as the same button, stronger. The choice is made on the
|
|
1274
|
+
* colours themselves, not on shade numbers (a brand colour is rarely the 500
|
|
1275
|
+
* step of its scale). Hard limits come first: the label stays readable, the
|
|
1276
|
+
* hover stands apart from a known surface, and a button that rests filled
|
|
1277
|
+
* stays recognisably itself. `HOVER_PREFERENCE` then ranks what's left.
|
|
1278
|
+
*
|
|
1279
|
+
* The ground is the proven surface, or the palette's page colour when the
|
|
1280
|
+
* surface is unknown. With neither, the instruction's fallback direction
|
|
1281
|
+
* stands in for "stronger".
|
|
1110
1282
|
*/
|
|
1111
1283
|
function resolveContextualHover(input) {
|
|
1112
|
-
const
|
|
1113
|
-
if (
|
|
1284
|
+
const shades = shadeCandidates(input);
|
|
1285
|
+
if (shades.length === 0) return {
|
|
1114
1286
|
kind: "unavailable",
|
|
1115
1287
|
reason: "no-distinct-shade"
|
|
1116
1288
|
};
|
|
1117
|
-
const
|
|
1118
|
-
if (
|
|
1289
|
+
const readable = shades.filter((shade) => labelReadable(shade.hex, shade.labelInk, input.colourIndex));
|
|
1290
|
+
if (readable.length === 0) return {
|
|
1119
1291
|
kind: "unavailable",
|
|
1120
1292
|
reason: "no-text-safe-candidate"
|
|
1121
1293
|
};
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
kind: "unavailable",
|
|
1131
|
-
reason: "no-text-safe-candidate"
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
const selected = selectSurfaceSafeHover(textSafe, {
|
|
1135
|
-
palette: input.palette,
|
|
1136
|
-
surface: input.surface,
|
|
1137
|
-
colourIndex: input.colourIndex,
|
|
1138
|
-
fallbackDirection: input.instruction.fallbackDirection,
|
|
1139
|
-
border: input.border
|
|
1140
|
-
});
|
|
1141
|
-
return selected ? {
|
|
1294
|
+
const restLabel = seedFilledRestLabel(input.rest, input.instruction.seedToken);
|
|
1295
|
+
const selected = pickHover(readable.filter((shade) => standsApartFromSurface(shade.hex, shade.labelInk, input) && (restLabel === void 0 || staysTheSameFilledButton(shade, restLabel))));
|
|
1296
|
+
const surfaceKnown = input.surface !== void 0;
|
|
1297
|
+
if (!selected) return {
|
|
1298
|
+
kind: "unavailable",
|
|
1299
|
+
reason: surfaceKnown ? "no-surface-safe-candidate" : "no-text-safe-candidate"
|
|
1300
|
+
};
|
|
1301
|
+
return {
|
|
1142
1302
|
kind: "resolved",
|
|
1143
1303
|
token: selected.token,
|
|
1144
1304
|
direction: selected.direction,
|
|
1145
|
-
evidence: "known-surface"
|
|
1146
|
-
} : {
|
|
1147
|
-
kind: "unavailable",
|
|
1148
|
-
reason: "no-surface-safe-candidate"
|
|
1305
|
+
evidence: surfaceKnown ? "known-surface" : "fallback-direction"
|
|
1149
1306
|
};
|
|
1150
1307
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1308
|
+
const visible = (shade) => shade.distance >= MINIMUM_VISIBLE_STEP;
|
|
1309
|
+
/**
|
|
1310
|
+
* Where the hover is looked for, in order. The first group with a shade wins,
|
|
1311
|
+
* and within it the nearest visible step (or, with none visible, the furthest).
|
|
1312
|
+
*
|
|
1313
|
+
* 1. Stronger, keeping the hue, and clearing the ground when the recipe names a fill ink.
|
|
1314
|
+
* 2. Stronger, keeping the hue.
|
|
1315
|
+
* 3. The other way, keeping the hue: a visible hover beats a hue-less or invisible one.
|
|
1316
|
+
* 4. Any stronger shade.
|
|
1317
|
+
* 5. Any shade the other way.
|
|
1318
|
+
*/
|
|
1319
|
+
const HOVER_PREFERENCE = [
|
|
1320
|
+
(shade) => shade.stronger && shade.keepsHue && visible(shade) && shade.fillClearsGround,
|
|
1321
|
+
(shade) => shade.stronger && shade.keepsHue && visible(shade),
|
|
1322
|
+
(shade) => !shade.stronger && shade.keepsHue && visible(shade),
|
|
1323
|
+
(shade) => shade.stronger,
|
|
1324
|
+
() => true
|
|
1325
|
+
];
|
|
1326
|
+
function pickHover(allowed) {
|
|
1327
|
+
for (const inGroup of HOVER_PREFERENCE) {
|
|
1328
|
+
const group = allowed.filter(inGroup);
|
|
1329
|
+
if (group.length > 0) return nearestVisibleStep(group);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function nearestVisibleStep(shades) {
|
|
1333
|
+
const byDistance = [...shades].sort((left, right) => left.distance - right.distance || left.token.localeCompare(right.token));
|
|
1334
|
+
return byDistance.find(visible) ?? byDistance[byDistance.length - 1];
|
|
1335
|
+
}
|
|
1336
|
+
/** The label ink of a button that rests filled with the seed; undefined when it rests some other way (it fills only on hover). */
|
|
1337
|
+
function seedFilledRestLabel(rest, seed) {
|
|
1338
|
+
return rest.kind === "solid" && rest.colorToken === seed ? rest.labelInk : void 0;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* A button that rests filled with the seed should still read as itself on
|
|
1342
|
+
* hover. A shade that needs the other label ink is only allowed a near step
|
|
1343
|
+
* away (a jump across the scale with the label flipped looks like another
|
|
1344
|
+
* button), and a shade the other way has to keep the hue. A button that fills
|
|
1345
|
+
* only on hover changes its label anyway, so this doesn't apply to it.
|
|
1346
|
+
*/
|
|
1347
|
+
function staysTheSameFilledButton(shade, restLabel) {
|
|
1348
|
+
return (contrastRatio(shade.labelInk, restLabel) < SAME_LABEL_INK || shade.distance <= NEAR_STEP) && (shade.stronger || shade.keepsHue);
|
|
1349
|
+
}
|
|
1350
|
+
function labelReadable(hex, labelInk, colourIndex) {
|
|
1351
|
+
return labelInk !== void 0 && contrastRatio(hex, labelInk, colourIndex) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
|
|
1352
|
+
}
|
|
1353
|
+
/** On a proven surface, the fill stands apart from it by colour or by a declared edge. */
|
|
1354
|
+
function standsApartFromSurface(hex, labelInk, input) {
|
|
1355
|
+
return input.surface === void 0 || buttonSurfaceSeparation(hex, input.surface, {
|
|
1356
|
+
border: input.border,
|
|
1357
|
+
palette: input.palette,
|
|
1358
|
+
labelInk
|
|
1359
|
+
}).distinct;
|
|
1360
|
+
}
|
|
1361
|
+
/** The recipe's own hover ink holds when its label reads and, on a proven surface, it stands apart and clears the surface as a fill. */
|
|
1362
|
+
function preferredInkHolds(token, input) {
|
|
1363
|
+
const hex = input.palette[token];
|
|
1364
|
+
const labelInk = input.palette[solidForegroundToken(token)];
|
|
1365
|
+
if (hex === void 0 || !labelReadable(hex, labelInk, input.colourIndex)) return false;
|
|
1366
|
+
return input.surface === void 0 || standsApartFromSurface(hex, labelInk, input) && contrastRatio(hex, input.surface.backgroundHex, input.colourIndex) >= FILL_CLEARS_GROUND;
|
|
1367
|
+
}
|
|
1368
|
+
/** The other steps of the seed's scale (`primary-100` … `primary-950`), measured against the seed and the ground. */
|
|
1369
|
+
function shadeCandidates(input) {
|
|
1370
|
+
const { instruction, palette, colourIndex } = input;
|
|
1371
|
+
const seedHex = palette[instruction.seedToken];
|
|
1372
|
+
if (seedHex === void 0) return [];
|
|
1373
|
+
const family = String(instruction.seedToken).match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? String(instruction.seedToken);
|
|
1374
|
+
const step = new RegExp(`^${escapeRegExp(family)}-\\d{2,3}$`);
|
|
1375
|
+
const ground = input.surface?.backgroundHex ?? palette.background;
|
|
1376
|
+
const seed = {
|
|
1377
|
+
hex: seedHex,
|
|
1378
|
+
lightness: contrastRatio(seedHex, "#000000"),
|
|
1379
|
+
chroma: oklab(seedHex).chroma,
|
|
1380
|
+
ground: ground === void 0 ? void 0 : {
|
|
1381
|
+
contrast: (hex) => contrastRatio(hex, ground, colourIndex),
|
|
1382
|
+
restContrast: contrastRatio(seedHex, ground, colourIndex)
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
return Object.keys(palette).flatMap((name) => {
|
|
1386
|
+
const token = step.test(name) ? parseOpaqueButtonColourToken(name) : null;
|
|
1387
|
+
const hex = token === null ? void 0 : palette[token];
|
|
1388
|
+
return token === null || hex === void 0 || hex === seedHex ? [] : [describeShade(token, hex, seed, input)];
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
function describeShade(token, hex, seed, input) {
|
|
1392
|
+
const { instruction, palette } = input;
|
|
1393
|
+
const direction = contrastRatio(hex, "#000000") > seed.lightness ? "lighter" : "darker";
|
|
1394
|
+
const groundContrast = seed.ground?.contrast(hex);
|
|
1190
1395
|
return {
|
|
1191
1396
|
token,
|
|
1397
|
+
hex,
|
|
1192
1398
|
direction,
|
|
1193
|
-
|
|
1194
|
-
|
|
1399
|
+
labelInk: palette[solidForegroundToken(token)],
|
|
1400
|
+
distance: hexOklabDistance(seed.hex, hex),
|
|
1401
|
+
stronger: seed.ground === void 0 ? direction === instruction.fallbackDirection : seed.ground.contrast(hex) >= seed.ground.restContrast,
|
|
1402
|
+
keepsHue: keepsHue(oklab(hex), seed.chroma),
|
|
1403
|
+
fillClearsGround: instruction.preferredToken !== void 0 && groundContrast !== void 0 && groundContrast >= FILL_CLEARS_GROUND
|
|
1195
1404
|
};
|
|
1196
1405
|
}
|
|
1197
|
-
function
|
|
1198
|
-
|
|
1199
|
-
const foreground = palette[solidForegroundToken(token)];
|
|
1200
|
-
return typeof background === "string" && typeof foreground === "string" && contrastRatio(background, foreground, colourIndex) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
|
|
1406
|
+
function keepsHue(shade, seedChroma) {
|
|
1407
|
+
return !(shade.lightness < HUELESS_DARK_END || shade.lightness > HUELESS_LIGHT_END) || shade.chroma >= seedChroma * HUE_KEPT_SHARE;
|
|
1201
1408
|
}
|
|
1202
|
-
function
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1409
|
+
function oklab(hex) {
|
|
1410
|
+
const { r, g, b } = hexToRgb(hex);
|
|
1411
|
+
const lab = srgbToOklab(r, g, b);
|
|
1412
|
+
return {
|
|
1413
|
+
lightness: lab.L,
|
|
1414
|
+
chroma: Math.hypot(lab.a, lab.b)
|
|
1415
|
+
};
|
|
1209
1416
|
}
|
|
1210
1417
|
function escapeRegExp(value) {
|
|
1211
1418
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1219,7 +1426,8 @@ function resolveButtonHoverTreatment(input) {
|
|
|
1219
1426
|
palette: input.palette,
|
|
1220
1427
|
colourIndex: input.colourIndex,
|
|
1221
1428
|
surface: input.surface,
|
|
1222
|
-
border: input.variant.border
|
|
1429
|
+
border: input.variant.border,
|
|
1430
|
+
rest: input.rest
|
|
1223
1431
|
});
|
|
1224
1432
|
if (contextual.kind === "resolved") return {
|
|
1225
1433
|
treatment: {
|
|
@@ -1269,6 +1477,11 @@ function compileButtonColourStates(input) {
|
|
|
1269
1477
|
variant: input.variant,
|
|
1270
1478
|
global: input.global,
|
|
1271
1479
|
fallback: base.treatment,
|
|
1480
|
+
rest: restingFill({
|
|
1481
|
+
...input,
|
|
1482
|
+
variantId: input.variant.id,
|
|
1483
|
+
state: "base"
|
|
1484
|
+
}, base.treatment),
|
|
1272
1485
|
palette: input.palette,
|
|
1273
1486
|
surface: input.surface,
|
|
1274
1487
|
colourIndex: input.colourIndex
|
|
@@ -1293,7 +1506,12 @@ function compileDeclaredVisualStates(input, states) {
|
|
|
1293
1506
|
hoverColor: "none",
|
|
1294
1507
|
hoverColorToken: void 0
|
|
1295
1508
|
},
|
|
1296
|
-
fallback: states.hover.background
|
|
1509
|
+
fallback: states.hover.background,
|
|
1510
|
+
rest: restingFill({
|
|
1511
|
+
...input,
|
|
1512
|
+
variantId: input.variant.id,
|
|
1513
|
+
state: "base"
|
|
1514
|
+
}, states.base.background)
|
|
1297
1515
|
});
|
|
1298
1516
|
const colours = collectStateColours(mapVisualStates((state) => compileDeclaredVisualState(input, states, state, state === "hover" ? hover.treatment : states[state].background)));
|
|
1299
1517
|
return colours.ok ? {
|
|
@@ -1454,13 +1672,25 @@ function resolveSolid(input, backgroundToken, preferredForeground) {
|
|
|
1454
1672
|
function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
|
|
1455
1673
|
return resolveSolid(input, backgroundToken, preferredForeground);
|
|
1456
1674
|
}
|
|
1457
|
-
/**
|
|
1675
|
+
/** A solid rest fill with the label ink resolveSolidInk gives it, so a contextual hover compares against the ink visitors see. */
|
|
1676
|
+
function restingFill(input, treatment) {
|
|
1677
|
+
if (treatment.type !== "solid") return { kind: "not-solid" };
|
|
1678
|
+
const hex = input.palette[treatment.colorToken];
|
|
1679
|
+
if (hex === void 0) return { kind: "not-solid" };
|
|
1680
|
+
const ink = resolveSolidInk(input, treatment.colorToken, hex, treatment.foregroundToken);
|
|
1681
|
+
return {
|
|
1682
|
+
kind: "solid",
|
|
1683
|
+
colorToken: treatment.colorToken,
|
|
1684
|
+
labelInk: ink.foregroundHex
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
/** Preserve checked on-colours (a requested label colour first); a solid state's last resort is the palette ink for its actual fill. */
|
|
1458
1688
|
function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForeground) {
|
|
1459
1689
|
if (preferredForeground !== void 0) {
|
|
1460
1690
|
const preferred = checkedSolidInk(input, backgroundToken, backgroundHex, preferredForeground);
|
|
1461
1691
|
if (preferred) return preferred;
|
|
1462
1692
|
}
|
|
1463
|
-
return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ??
|
|
1693
|
+
return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
|
|
1464
1694
|
}
|
|
1465
1695
|
function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
|
|
1466
1696
|
const candidate = input.palette[foregroundToken];
|
|
@@ -1482,14 +1712,18 @@ function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken)
|
|
|
1482
1712
|
};
|
|
1483
1713
|
return null;
|
|
1484
1714
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1715
|
+
/** The palette's own background or text as the label where it reads (as a checked token), else literal black or white. */
|
|
1716
|
+
function paletteSolidInk(input, backgroundToken, backgroundHex) {
|
|
1717
|
+
const ink = paletteInkOnSolid(backgroundHex, paletteInkRoles(input.palette));
|
|
1718
|
+
const role = ink.kind === "role" ? checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(ink.role)) : null;
|
|
1719
|
+
if (role) return role;
|
|
1720
|
+
const literal = pickBlackOrWhiteTextColor(backgroundHex);
|
|
1487
1721
|
return {
|
|
1488
|
-
foregroundHex,
|
|
1722
|
+
foregroundHex: literal,
|
|
1489
1723
|
colour: {
|
|
1490
1724
|
kind: "known-solid",
|
|
1491
1725
|
backgroundCss: tokenCss(backgroundToken),
|
|
1492
|
-
foregroundCss:
|
|
1726
|
+
foregroundCss: literal
|
|
1493
1727
|
}
|
|
1494
1728
|
};
|
|
1495
1729
|
}
|
|
@@ -1567,4 +1801,404 @@ function interpolateHex(startHex, endHex, position) {
|
|
|
1567
1801
|
return `#${channel(start.r, end.r)}${channel(start.g, end.g)}${channel(start.b, end.b)}`;
|
|
1568
1802
|
}
|
|
1569
1803
|
//#endregion
|
|
1570
|
-
|
|
1804
|
+
//#region ../theme-core/src/palette/generateShades.ts
|
|
1805
|
+
function generateShades(hexColor, name) {
|
|
1806
|
+
const shadeSteps = [
|
|
1807
|
+
50,
|
|
1808
|
+
100,
|
|
1809
|
+
200,
|
|
1810
|
+
300,
|
|
1811
|
+
400,
|
|
1812
|
+
500,
|
|
1813
|
+
600,
|
|
1814
|
+
700,
|
|
1815
|
+
800,
|
|
1816
|
+
900,
|
|
1817
|
+
950
|
|
1818
|
+
];
|
|
1819
|
+
const base = featuresFromHex(hexColor);
|
|
1820
|
+
const hue = base.okH;
|
|
1821
|
+
const baseChroma = base.okC;
|
|
1822
|
+
const toneMap = {
|
|
1823
|
+
50: .975,
|
|
1824
|
+
100: .945,
|
|
1825
|
+
200: .89,
|
|
1826
|
+
300: .82,
|
|
1827
|
+
400: .74,
|
|
1828
|
+
500: .66,
|
|
1829
|
+
600: .58,
|
|
1830
|
+
700: .49,
|
|
1831
|
+
800: .4,
|
|
1832
|
+
900: .28,
|
|
1833
|
+
950: .16
|
|
1834
|
+
};
|
|
1835
|
+
const shadeDefs = shadeSteps.map((step, idx) => {
|
|
1836
|
+
const t = idx / (shadeSteps.length - 1);
|
|
1837
|
+
const L = toneMap[step];
|
|
1838
|
+
const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
|
|
1839
|
+
return {
|
|
1840
|
+
name: `${name}-${step}`,
|
|
1841
|
+
hex: oklchToHexGamut(L, C, hue)
|
|
1842
|
+
};
|
|
1843
|
+
});
|
|
1844
|
+
shadeDefs.push({
|
|
1845
|
+
name,
|
|
1846
|
+
hex: hexColor
|
|
1847
|
+
});
|
|
1848
|
+
return shadeDefs;
|
|
1849
|
+
}
|
|
1850
|
+
//#endregion
|
|
1851
|
+
//#region ../theme-core/src/palette/neutralScale.ts
|
|
1852
|
+
/** The cool slate tint every scale had before #1863, kept for grounds with no hue to lend. */
|
|
1853
|
+
const SLATE_NEUTRAL_TINT = {
|
|
1854
|
+
hue: 250,
|
|
1855
|
+
chroma: .02
|
|
1856
|
+
};
|
|
1857
|
+
/** Below this OKLCH chroma a background reads as plain white, grey or black, so its hue is noise. */
|
|
1858
|
+
const ACHROMATIC_CHROMA = .005;
|
|
1859
|
+
/**
|
|
1860
|
+
* The tint a palette's greys take from its background: the background's own
|
|
1861
|
+
* hue at no more than the slate scale's chroma, so a cream site gets warm greys.
|
|
1862
|
+
* A background with no hue to lend (white, `#fafafa`, a missing or unreadable
|
|
1863
|
+
* value) keeps the slate tint, so those palettes keep their exact neutrals.
|
|
1864
|
+
*/
|
|
1865
|
+
function neutralTint(background) {
|
|
1866
|
+
const parsed = hexColorSchema.safeParse(background?.toLowerCase());
|
|
1867
|
+
if (!parsed.success) return SLATE_NEUTRAL_TINT;
|
|
1868
|
+
const { r, g, b } = hexToRgb(parsed.data);
|
|
1869
|
+
const { L, a, b: ob } = srgbToOklab(r, g, b);
|
|
1870
|
+
const { C, h } = oklabToOklch(L, a, ob);
|
|
1871
|
+
return C < ACHROMATIC_CHROMA ? SLATE_NEUTRAL_TINT : {
|
|
1872
|
+
hue: h,
|
|
1873
|
+
chroma: Math.min(C, SLATE_NEUTRAL_TINT.chroma)
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
|
|
1878
|
+
* on every palette, light or dark. Readers that want "the ground" or "the
|
|
1879
|
+
* text" ask the palette for those roles, not a fixed end of this scale.
|
|
1880
|
+
*/
|
|
1881
|
+
function generateNeutralScale({ steps = 11, tint = SLATE_NEUTRAL_TINT } = {}) {
|
|
1882
|
+
const shadeNames = [
|
|
1883
|
+
50,
|
|
1884
|
+
100,
|
|
1885
|
+
200,
|
|
1886
|
+
300,
|
|
1887
|
+
400,
|
|
1888
|
+
500,
|
|
1889
|
+
600,
|
|
1890
|
+
700,
|
|
1891
|
+
800,
|
|
1892
|
+
900,
|
|
1893
|
+
950
|
|
1894
|
+
];
|
|
1895
|
+
const count = Math.min(steps, shadeNames.length);
|
|
1896
|
+
return shadeNames.slice(0, count).map((shadeName, index) => ({
|
|
1897
|
+
name: `neutral-${shadeName}`,
|
|
1898
|
+
hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), tint.chroma, tint.hue)
|
|
1899
|
+
}));
|
|
1900
|
+
}
|
|
1901
|
+
function mix(a, b, t) {
|
|
1902
|
+
return a + (b - a) * Math.max(0, Math.min(1, t));
|
|
1903
|
+
}
|
|
1904
|
+
//#endregion
|
|
1905
|
+
//#region ../theme-core/src/palette/utils/scrimContrast.ts
|
|
1906
|
+
const WHITE = "#ffffff";
|
|
1907
|
+
const BLACK = "#000000";
|
|
1908
|
+
/** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
|
|
1909
|
+
function compositeHex(topHex, alpha, bottomHex) {
|
|
1910
|
+
const top = hexToRgb(topHex);
|
|
1911
|
+
const bottom = hexToRgb(bottomHex);
|
|
1912
|
+
const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
|
|
1913
|
+
return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
|
|
1917
|
+
* any pixel. A foreground whose luminance falls inside the range the
|
|
1918
|
+
* composites can take has a worst case of 1:1.
|
|
1919
|
+
*/
|
|
1920
|
+
function worstCaseScrimContrast(input) {
|
|
1921
|
+
const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
|
|
1922
|
+
const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
|
|
1923
|
+
const luminance = (hex) => {
|
|
1924
|
+
const { r, g, b } = hexToRgb(hex);
|
|
1925
|
+
return relativeLuminance(r, g, b);
|
|
1926
|
+
};
|
|
1927
|
+
const foreground = luminance(input.foregroundHex);
|
|
1928
|
+
const low = luminance(overBlack);
|
|
1929
|
+
const high = luminance(overWhite);
|
|
1930
|
+
if (foreground >= low && foreground <= high) return 1;
|
|
1931
|
+
return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* The smallest scrim opacity, in hundredths, at which every foreground keeps
|
|
1935
|
+
* `threshold` contrast over any pixel. `null` when even an opaque scrim fails,
|
|
1936
|
+
* which means the foreground was never legible on the scrim colour itself.
|
|
1937
|
+
*/
|
|
1938
|
+
function minimumScrimOpacity(input) {
|
|
1939
|
+
const passes = (alpha) => input.foregroundHexes.every((foregroundHex) => worstCaseScrimContrast({
|
|
1940
|
+
foregroundHex,
|
|
1941
|
+
scrimHex: input.scrimHex,
|
|
1942
|
+
alpha
|
|
1943
|
+
}) >= input.threshold);
|
|
1944
|
+
return Array.from({ length: 101 }, (_, hundredths) => hundredths / 100).find(passes) ?? null;
|
|
1945
|
+
}
|
|
1946
|
+
/** Shared samples for literal RGB washes and palette-token gradient veils. */
|
|
1947
|
+
function gradientScrimSamples(gradient, alpha, palette) {
|
|
1948
|
+
const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
|
|
1949
|
+
hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
|
|
1950
|
+
alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
|
|
1951
|
+
}));
|
|
1952
|
+
const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
|
|
1953
|
+
const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
|
|
1954
|
+
return hex ? [{
|
|
1955
|
+
hex,
|
|
1956
|
+
alpha
|
|
1957
|
+
}] : [];
|
|
1958
|
+
});
|
|
1959
|
+
return [...literal, ...tokens];
|
|
1960
|
+
}
|
|
1961
|
+
/** The ink with the stronger worst-pixel guarantee identifies the veil tone.
|
|
1962
|
+
* No readable samples (or a tie) leaves classification to the foreground owner.
|
|
1963
|
+
*/
|
|
1964
|
+
function scrimTone(samples) {
|
|
1965
|
+
if (samples.length === 0) return null;
|
|
1966
|
+
const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
|
|
1967
|
+
foregroundHex,
|
|
1968
|
+
scrimHex: sample.hex,
|
|
1969
|
+
alpha: sample.alpha
|
|
1970
|
+
})));
|
|
1971
|
+
const white = worst(WHITE);
|
|
1972
|
+
const black = worst(BLACK);
|
|
1973
|
+
return white === black ? null : white > black ? "dark" : "light";
|
|
1974
|
+
}
|
|
1975
|
+
//#endregion
|
|
1976
|
+
//#region ../theme-core/src/palette/expandPalette.ts
|
|
1977
|
+
function colorsToMap(palette) {
|
|
1978
|
+
const map = {};
|
|
1979
|
+
for (const c of palette.colors) map[c.name] = c.hex;
|
|
1980
|
+
return map;
|
|
1981
|
+
}
|
|
1982
|
+
const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
|
|
1983
|
+
"success",
|
|
1984
|
+
"warning",
|
|
1985
|
+
"destructive"
|
|
1986
|
+
]);
|
|
1987
|
+
/**
|
|
1988
|
+
* Status role aliases the persisted palette does not carry itself.
|
|
1989
|
+
*
|
|
1990
|
+
* Generators reference `--tb-error` (the site-style-owned input error border)
|
|
1991
|
+
* and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
|
|
1992
|
+
* palette schema only defines `destructive` and has no `info` role at all.
|
|
1993
|
+
* Without these aliases those declarations name variables that are never
|
|
1994
|
+
* defined and browsers drop them. The SDK bridge resolves the same pair via
|
|
1995
|
+
* TOKEN_ALIASES, so both runtimes agree on what a status token means.
|
|
1996
|
+
*
|
|
1997
|
+
* Runs after the danger → destructive promotion above, so `destructive` is
|
|
1998
|
+
* already the single source of truth for the error colour.
|
|
1999
|
+
*/
|
|
2000
|
+
function statusAliasTokens(expanded) {
|
|
2001
|
+
const aliases = {};
|
|
2002
|
+
if (expanded.destructive) aliases.error = expanded.destructive;
|
|
2003
|
+
if (expanded.accent) aliases.info = expanded.accent;
|
|
2004
|
+
return aliases;
|
|
2005
|
+
}
|
|
2006
|
+
function expandPalette(palette, options = {}) {
|
|
2007
|
+
return {
|
|
2008
|
+
...expandBasePalette(palette),
|
|
2009
|
+
...arrangementPaletteTokens(colorsToMap(palette), options)
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
function expandBasePalette(palette) {
|
|
2013
|
+
const base = colorsToMap(palette);
|
|
2014
|
+
const expanded = { ...base };
|
|
2015
|
+
const roles = paletteInkRoles(base);
|
|
2016
|
+
generateNeutralScale({
|
|
2017
|
+
steps: 11,
|
|
2018
|
+
tint: neutralTint(base.background)
|
|
2019
|
+
}).forEach((n) => {
|
|
2020
|
+
expanded[n.name] = n.hex;
|
|
2021
|
+
});
|
|
2022
|
+
for (const [name, hex] of Object.entries(base)) {
|
|
2023
|
+
if (nonShadeablePaletteRoleNames.has(name)) continue;
|
|
2024
|
+
if (hex) generateShades(hex, name).forEach((shade) => {
|
|
2025
|
+
expanded[shade.name] = shade.hex;
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
if (base.text) expanded.body = base.text;
|
|
2029
|
+
if (base.danger && !base.destructive) expanded.destructive = base.danger;
|
|
2030
|
+
Object.assign(expanded, statusAliasTokens(expanded));
|
|
2031
|
+
expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base, roles);
|
|
2032
|
+
for (const [token, hex] of Object.entries({ ...expanded })) {
|
|
2033
|
+
if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
|
|
2034
|
+
const onToken = onColorTokenName(token);
|
|
2035
|
+
if (expanded[onToken]) continue;
|
|
2036
|
+
expanded[onToken] = paletteInkOnSolid(hex, roles).hex;
|
|
2037
|
+
}
|
|
2038
|
+
Object.assign(expanded, groundMutedInkTokens(expanded));
|
|
2039
|
+
return expanded;
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* The strongest tints booking and registration screens lay over a ground
|
|
2043
|
+
* where secondary text sits: selected option cards, event tiles and summaries
|
|
2044
|
+
* tint `primary` at 5–10% (`blocks/vars/appointment-booking.ts`,
|
|
2045
|
+
* `blocks/vars/event-registration.ts`, `blocks-static/event-registration.css`),
|
|
2046
|
+
* the appointment summary and hover rows tint `text`/`onSurface` at 5%, and the
|
|
2047
|
+
* registration summary lays `muted` at 42%. A weaker tint of the same colour
|
|
2048
|
+
* sits between the ground and these, so solving against the strongest covers it.
|
|
2049
|
+
* A selected card lays its tint over its own ground, so the same list applies
|
|
2050
|
+
* over the surface and over the page background that event option cards paint.
|
|
2051
|
+
* A new tint under secondary text belongs here, and the CSS paints it with
|
|
2052
|
+
* the ground's faded tint token (`groundTintToken`) before the colour itself;
|
|
2053
|
+
* `secondaryTextTints.test.ts` fails if the CSS lays one that isn't covered or
|
|
2054
|
+
* doesn't read that token.
|
|
2055
|
+
*/
|
|
2056
|
+
const SURFACE_SECONDARY_TEXT_TINTS = [
|
|
2057
|
+
{
|
|
2058
|
+
token: "primary",
|
|
2059
|
+
alpha: .1
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
token: "text",
|
|
2063
|
+
alpha: .05
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
token: "onSurface",
|
|
2067
|
+
alpha: .05
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
token: "muted",
|
|
2071
|
+
alpha: .42
|
|
2072
|
+
}
|
|
2073
|
+
];
|
|
2074
|
+
/** The strongest tint alpha per colour, for the CSS that paints those tints. */
|
|
2075
|
+
const SURFACE_SECONDARY_TEXT_TINT_ALPHA = Object.fromEntries(SURFACE_SECONDARY_TEXT_TINTS.map(({ token, alpha }) => [token, alpha]));
|
|
2076
|
+
/**
|
|
2077
|
+
* The grounds booking and registration secondary text sits on, with the token
|
|
2078
|
+
* its solved muted ink is published as: the surface (panels, details) and the
|
|
2079
|
+
* page background (event registration's option, ticket and payment cards).
|
|
2080
|
+
*/
|
|
2081
|
+
const MUTED_INK_TOKENS = {
|
|
2082
|
+
surface: "onSurfaceMuted",
|
|
2083
|
+
background: "onBackgroundMuted"
|
|
2084
|
+
};
|
|
2085
|
+
/**
|
|
2086
|
+
* Secondary text on a ground, solved rather than faded from the ground's
|
|
2087
|
+
* on-colour in CSS, against the ground and every tint laid over it.
|
|
2088
|
+
*
|
|
2089
|
+
* Some palettes admit no single ink for all of them: a mid-tone surface with a
|
|
2090
|
+
* dark `primary` tint and a light `muted` one. The plain ground always has one
|
|
2091
|
+
* (black or white reads on any solid), so the ground is kept, each tint is kept
|
|
2092
|
+
* in list order while one ink still reads on everything kept so far, and the
|
|
2093
|
+
* tints that can't join are faded toward the ground until that ink reads on
|
|
2094
|
+
* them too. Fading the tint rather than giving it an ink of its own keeps every
|
|
2095
|
+
* line of text on it (titles and prices as well as secondary text) close to the
|
|
2096
|
+
* ground its colours were chosen for. Hosted palettes and the SDK bridge both
|
|
2097
|
+
* derive it here.
|
|
2098
|
+
*/
|
|
2099
|
+
function groundMutedInk(palette, ground) {
|
|
2100
|
+
const groundHex = palette[ground];
|
|
2101
|
+
if (!groundHex) return null;
|
|
2102
|
+
const preferred = palette[onColorTokenName(ground)] ?? null;
|
|
2103
|
+
const roles = paletteInkRoles(palette);
|
|
2104
|
+
const initial = {
|
|
2105
|
+
grounds: [groundHex],
|
|
2106
|
+
hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
|
|
2107
|
+
uncovered: []
|
|
2108
|
+
};
|
|
2109
|
+
const solved = SURFACE_SECONDARY_TEXT_TINTS.reduce((kept, { token, alpha }) => {
|
|
2110
|
+
const tintHex = palette[token];
|
|
2111
|
+
if (!tintHex) return kept;
|
|
2112
|
+
const grounds = [...kept.grounds, compositeHex(tintHex, alpha, groundHex)];
|
|
2113
|
+
const ink = paletteMutedInk(grounds, preferred, roles);
|
|
2114
|
+
return ink.kind === "unpaintable" ? {
|
|
2115
|
+
...kept,
|
|
2116
|
+
uncovered: [...kept.uncovered, {
|
|
2117
|
+
token,
|
|
2118
|
+
alpha,
|
|
2119
|
+
tintHex
|
|
2120
|
+
}]
|
|
2121
|
+
} : {
|
|
2122
|
+
...kept,
|
|
2123
|
+
grounds,
|
|
2124
|
+
hex: ink.hex
|
|
2125
|
+
};
|
|
2126
|
+
}, initial);
|
|
2127
|
+
return {
|
|
2128
|
+
hex: solved.hex,
|
|
2129
|
+
fadedTints: solved.uncovered.map(({ token, alpha, tintHex }) => ({
|
|
2130
|
+
token,
|
|
2131
|
+
hex: tintFadedUntilInkReads(tintHex, alpha, groundHex, solved.hex)
|
|
2132
|
+
}))
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
/** The tint colour a ground publishes in place of a tint its muted ink can't read on, e.g. `surfaceTintMuted`. */
|
|
2136
|
+
function groundTintToken(ground, tint) {
|
|
2137
|
+
return `${ground}Tint${tint.charAt(0).toUpperCase()}${tint.slice(1)}`;
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* The tint blended toward the ground in 1% steps, stopping at the first that
|
|
2141
|
+
* the ink reads on when laid at `alpha`. The ground itself always reads, since
|
|
2142
|
+
* the ink was solved on it.
|
|
2143
|
+
*/
|
|
2144
|
+
function tintFadedUntilInkReads(tintHex, alpha, groundHex, inkHex) {
|
|
2145
|
+
const tint = hexToRgb(tintHex);
|
|
2146
|
+
const ground = hexToRgb(groundHex);
|
|
2147
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
2148
|
+
const amount = index / 100;
|
|
2149
|
+
return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
|
|
2150
|
+
}).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* The muted ink tokens a palette doesn't store itself, and the faded tint
|
|
2154
|
+
* colours of each ground whose ink is solved here, as hex.
|
|
2155
|
+
*/
|
|
2156
|
+
function groundMutedInkTokens(palette) {
|
|
2157
|
+
return Object.fromEntries(Object.entries(MUTED_INK_TOKENS).flatMap(([ground, token]) => {
|
|
2158
|
+
if (palette[token]) return [];
|
|
2159
|
+
const ink = groundMutedInk(palette, ground);
|
|
2160
|
+
if (!ink) return [];
|
|
2161
|
+
const faded = ink.fadedTints.map(({ token: tint, hex }) => [groundTintToken(ground, tint), hex]);
|
|
2162
|
+
return [[token, ink.hex], ...faded.filter(([name]) => !palette[name])];
|
|
2163
|
+
}));
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* The neutral step stays when it reads on the ground. Otherwise (a dark palette
|
|
2167
|
+
* on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
|
|
2168
|
+
* with a 4.5:1 floor, heading for the palette's own ink on that ground.
|
|
2169
|
+
*/
|
|
2170
|
+
function readableMutedText(step, base, roles) {
|
|
2171
|
+
const ground = base.background || base.surface;
|
|
2172
|
+
if (!ground || contrastRatio(step, ground) >= 4.5) return step;
|
|
2173
|
+
return paletteMutedInkOnSolid(ground, null, roles);
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Derived decoration colours never become editable palette swatches. The mark
|
|
2177
|
+
* blends toward literal black or white: it's a graphic endpoint for a 3:1
|
|
2178
|
+
* search, not text, so it stays off the palette ink rule.
|
|
2179
|
+
*/
|
|
2180
|
+
function deriveSurfaceDecorationColors(ground, text, accent) {
|
|
2181
|
+
const ink = pickBlackOrWhiteTextColor(ground);
|
|
2182
|
+
return {
|
|
2183
|
+
line: firstContrastBlend(ground, text, ground, 1.5),
|
|
2184
|
+
mark: firstContrastBlend(accent, ink, ground, 3)
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
function firstContrastBlend(from, to, ground, threshold) {
|
|
2188
|
+
const start = hexToRgb(from);
|
|
2189
|
+
const end = hexToRgb(to);
|
|
2190
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
2191
|
+
const amount = index / 100;
|
|
2192
|
+
return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
|
|
2193
|
+
}).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
|
|
2194
|
+
}
|
|
2195
|
+
/** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
|
|
2196
|
+
function arrangementPaletteTokens(base, options) {
|
|
2197
|
+
if (options.arrangement !== true || !base.text) return {};
|
|
2198
|
+
return {
|
|
2199
|
+
onText: base.onText ?? paletteInkOnSolid(base.text, paletteInkRoles(base)).hex,
|
|
2200
|
+
...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
//#endregion
|
|
2204
|
+
export { onColorTokenName as A, preparePaletteColourIndex as B, paletteInk as C, paletteMutedInkOnSolid as D, paletteInkToken as E, requirePaletteColorsFromEntries as F, oklabToSrgb as G, featuresFromHex as H, ORDINARY_TEXT_MIN_CONTRAST_RATIO as I, rgbToHex as J, oklchToHexGamut as K, contrastRatio as L, resolveOpaqueSurfaceHex as M, paletteValueKey as N, colourFamily as O, paletteValueKeySchema as P, hexLuminance as R, neutralInk as S, paletteInkRoles as T, hexToRgb as U, solidPaint as V, oklabToOklch as W, srgbToOklab as Y, ELEVATION_OFFSET as _, compositeHex as a, pickBlackOrWhiteTextColor as b, scrimTone as c, resolveSolidButtonColour as d, BUTTON_CONTRAST_POLICY as f, DEFAULT_BUTTON_SIZES as g, BORDER_WIDTH_MAP as h, groundMutedInkTokens as i, resolveConcreteColorHex as j, isOnColorBackgroundCandidateToken as k, buttonStateBorder as l, BORDER_RADIUS_MAP as m, deriveSurfaceDecorationColors as n, gradientScrimSamples as o, formatButtonColourContractError as p, oklchToOklab as q, expandPalette as r, minimumScrimOpacity as s, SURFACE_SECONDARY_TEXT_TINT_ALPHA as t, compileButtonColourStates as u, FONT_SIZE_MAP as v, paletteInkOnSolid as w, inkFrom as x, generateShadowValue as y, luminanceInterval as z };
|