@riverbankcms/sdk 0.183.0 → 0.184.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 +34 -1
- package/dist/_dts/{BlocksIslandsHydrator-X1_G96iN.d.ts → BlocksIslandsHydrator-DjBTJYiF.d.ts} +1 -1
- package/dist/_dts/{Page-CEqZJZEE.d.ts → Page-BpXEM2ET.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-DQejfbXL.d.ts → SdkPreviewMode-Bb3h7KRE.d.ts} +2 -2
- package/dist/_dts/{client-B_B_amKD.d.ts → client-DgTRRtl_.d.ts} +13 -1
- package/dist/_dts/{content-types-Dhx5Ocvx.d.ts → content-types-DZQJp_ak.d.ts} +2 -2
- package/dist/_dts/{contracts-FeOnfoa1.d.ts → contracts-Ww1fmd-c.d.ts} +3 -3
- package/dist/_dts/{generatePageMetadata-m70J6tit.d.ts → generatePageMetadata-BGc7dju6.d.ts} +2 -2
- package/dist/_dts/{index-liuhlOX7.d.ts → index-BECaUNYs.d.ts} +2 -2
- package/dist/_dts/{index-BOpUh8kO.d.ts → index-Cc85KVLW.d.ts} +3 -3
- package/dist/_dts/{index-CjAkEWAp.d.ts → index-Cni4jykw.d.ts} +4 -4
- package/dist/_dts/{index-Bizdaxji.d.ts → index-DxxTQ_0V.d.ts} +2 -2
- package/dist/_dts/{index-BxCmCit0.d.ts → index-W9-7djG3.d.ts} +1 -1
- package/dist/_dts/{index-iuFrbIjt.d.ts → index-ukS-Ffem.d.ts} +1 -1
- package/dist/_dts/{loadContent-D4wrTIIw.d.ts → loadContent-BlSWTlbD.d.ts} +7 -7
- package/dist/_dts/{request-Gn0O1blj.d.ts → request-CZz2BoXJ.d.ts} +74180 -73974
- package/dist/_dts/{resolveBlockData-D5duwuqS.d.ts → resolveBlockData-D12HXnS3.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-xzJ3c9Na.d.ts → resolvePageContent-BteMsSGP.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 -1
- package/dist/_dts/sdk/src/index.d.ts +7 -7
- 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 +10 -2
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
- package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +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 +36 -1
- package/dist/_dts/{serviceBookingOutline-B1gyJon_.d.ts → serviceBookingOutline-aTlOvO3U.d.ts} +15 -7
- package/dist/_dts/{types-BoITy0rA.d.ts → types-Bi7R07RX.d.ts} +6 -2
- package/dist/_dts/{types-DBNuMtSk.d.ts → types-CCcQlRBi.d.ts} +9 -10
- package/dist/_dts/{types-DHMcuoeQ.d.ts → types-Du4aMnWC.d.ts} +13 -15
- package/dist/_dts/{validation-BIPO-XlE.d.ts → validation-CjCWVmwe.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-Ct8slgRk.mjs → BlocksIslandsHydrator-CFLWxjxR.mjs} +17 -17
- package/dist/client/{BookingMailingListNote-qqTxGGS4.mjs → BookingMailingListNote-C4LcfwyA.mjs} +7 -7
- package/dist/client/{BookingQuestionFields-DCh9MUIF.mjs → BookingQuestionFields-DdcmoHqQ.mjs} +1 -1
- package/dist/client/{CalendarAction-RcdaStG7.mjs → CalendarAction-DYGewmvh.mjs} +1 -1
- package/dist/client/{CalendarNavigationChevron-D7Wt-Oaa.mjs → CalendarNavigationChevron-ZfrUiiiI.mjs} +5 -5
- package/dist/client/{CheckboxChoice-BdGxZWeg.mjs → CheckboxChoice-CTMIII37.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-HFVkoOac.mjs → DemoBookingPortalAccess-pzkGVkgG.mjs} +7 -5
- package/dist/client/{EventCalendar.client-BtkJW8bA.mjs → EventCalendar.client-Ct1B3xI4.mjs} +9 -9
- package/dist/client/{EventCombined.client-DxaGjFFS.mjs → EventCombined.client-DgfNtcgW.mjs} +8 -8
- package/dist/client/{EventEmbeddedCheckoutStep-B2c5dR49.mjs → EventEmbeddedCheckoutStep-CjoaG1zy.mjs} +1 -1
- package/dist/client/{EventItem-Fr2qi2C2.mjs → EventItem-KGKkK19N.mjs} +5 -5
- package/dist/client/{EventListWeekNavigation-BRMaq0ky.mjs → EventListWeekNavigation-Ba9ezxuC.mjs} +1 -1
- package/dist/client/{EventListing.client-BhGxfbjt.mjs → EventListing.client-xFKRDLwC.mjs} +3 -3
- package/dist/client/{EventListing.view-COuEJzbO.mjs → EventListing.view-Dy36vWHi.mjs} +84 -7
- package/dist/client/{EventRegistrationPayment-BTLYhVxD.mjs → EventRegistrationPayment-Dth9L00x.mjs} +108 -45
- package/dist/client/{Page-CgbQZP5g.mjs → Page-DB5KODiu.mjs} +1735 -501
- package/dist/client/{ProtectedSubmitButton-BG7my0Qf.mjs → ProtectedSubmitButton-CY6u5sQa.mjs} +1 -1
- package/dist/client/{SiteTermsAgreementField-DQNkfNLA.mjs → SiteTermsAgreementField-BDVP_HeK.mjs} +2 -2
- package/dist/client/{StepIndicator-DvPekKeM.mjs → StepIndicator-CLgDVzCs.mjs} +1 -1
- package/dist/client/{StepIndicator-DyXoI3ob.mjs → StepIndicator-DRyZ8igu.mjs} +6 -6
- package/dist/client/{ThemedButton-Bc9DBbVp.mjs → ThemedButton-C4rCsPCt.mjs} +11 -2
- package/dist/client/{accessibleSurfaces-wj4Rloo5.mjs → accessibleSurfaces-CqroimVQ.mjs} +745 -557
- package/dist/client/{accordion-BVXfjnh-.mjs → accordion-BQYRP5xV.mjs} +1 -1
- package/dist/client/{booking-form.client-DycPGtke.mjs → booking-form.client-B7ckDuOC.mjs} +16 -16
- package/dist/client/{bookingForm-DrWSUqL3.mjs → bookingForm-BeD4650p.mjs} +7 -6
- package/dist/client/bookings.mjs +4 -4
- package/dist/client/{boxStyleClassNames-CduDRcIk.mjs → boxStyleClassNames-CA7FirMH.mjs} +2 -2
- package/dist/client/{buttonParts-CJEtVOUy.mjs → buttonParts-C39GC0kz.mjs} +9 -2
- package/dist/client/{carousel-DyCLMP8s.mjs → carousel-DJ9Aa1m3.mjs} +2 -2
- package/dist/client/{carousel.client-DffP_Nv0.mjs → carousel.client-DKWqVHHh.mjs} +1 -1
- package/dist/client/{cart-BuEp_cj4.mjs → cart-DdCenbTy.mjs} +3 -3
- package/dist/client/{cart.client-CAO39uDG.mjs → cart.client-BQm06qNw.mjs} +1 -1
- package/dist/client/{checkout-BoxzT64s.mjs → checkout-45wPQULN.mjs} +3 -3
- package/dist/client/{checkout.client-IGUy7XOx.mjs → checkout.client-bSv4cc5z.mjs} +1 -1
- package/dist/client/{checkoutUrls-D0UsiFmm.mjs → checkoutUrls-CwlaMl3W.mjs} +1 -1
- package/dist/client/client.mjs +23 -35
- package/dist/client/{constants-C_8AxMdm.mjs → constants-DXV4KR7l.mjs} +1 -1
- package/dist/client/{context-D1L0pe__.mjs → context-lCPfX-xe.mjs} +13 -3
- package/dist/client/{demoPortalMagicLink-BunFTnIq.mjs → demoPortalMagicLink-Ce3Gyin_.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-CtLAG651.mjs → enhanceHeaderSection-CGcDE9aE.mjs} +4 -4
- package/dist/client/{event-registration.client-DiSxkBUP.mjs → event-registration.client-DlPfn4YG.mjs} +51 -28
- package/dist/client/{eventCalendar-DUnhwZ1o.mjs → eventCalendar-CioAdryV.mjs} +4 -4
- package/dist/client/{eventCombined-BvBQo0nF.mjs → eventCombined-Dwt0G6ez.mjs} +4 -4
- package/dist/client/{eventListing-aTLifOX7.mjs → eventListing-B3H9ifOC.mjs} +4 -4
- package/dist/client/{eventRegistration-DFd7pr09.mjs → eventRegistration-Do7cAhXb.mjs} +7 -6
- package/dist/client/{form-Dikmc2AO.mjs → form-CsqzgC6v.mjs} +3 -3
- package/dist/client/{form.client-zHaQK5I9.mjs → form.client-DVDB7hY6.mjs} +4 -4
- package/dist/client/{form.parts-BLl9n8TH.mjs → form.parts-1q2rzSYt.mjs} +3 -3
- package/dist/client/gifting/client.mjs +7 -7
- package/dist/client/{gifting-CufPM38H.mjs → gifting-BrXQGX-k.mjs} +4 -4
- package/dist/client/{gifting.client--N1GaSY8.mjs → gifting.client--zAjnY5N.mjs} +6 -7
- package/dist/client/{gifting.interactive-D9MK4HkV.mjs → gifting.interactive-CrwHpUJG.mjs} +59 -9
- package/dist/client/{gifting.parts-CRtiRzo-.mjs → gifting.parts-CcKdDaQq.mjs} +7 -2
- package/dist/client/{headerSection-BIaBpmk3.mjs → headerSection-DlcDH4bi.mjs} +2 -2
- package/dist/client/{islands-DJDLGQEm.mjs → islands-dMh0Oxli.mjs} +1986 -1170
- package/dist/client/{newsletter-form.client-wg_JHTxm.mjs → newsletter-form.client-BxA1PsdS.mjs} +5 -5
- package/dist/client/{newsletter-form.interactive-hzpkW9NQ.mjs → newsletter-form.interactive-D0iRg7p2.mjs} +6 -5
- package/dist/client/{newsletter-form.parts-CgzpSv9p.mjs → newsletter-form.parts-Dmuklz0r.mjs} +2 -2
- package/dist/client/{newsletterForm-CvxLiEBT.mjs → newsletterForm-CBzvgIfg.mjs} +3 -3
- package/dist/client/portal/client.mjs +27 -15
- package/dist/client/{portalRoutes-DTHlWg_F.mjs → portalRoutes-DiGibcZI.mjs} +9 -2
- package/dist/client/portalSession-0XhXyTxT.mjs +41 -0
- package/dist/client/{product-detail.client-22Q7zgjN.mjs → product-detail.client-D9MP8hvH.mjs} +1 -1
- package/dist/client/{product-list.client-DFWYvK8z.mjs → product-list.client-wCz1qcUY.mjs} +1 -1
- package/dist/client/{productDetail-DhZAwo60.mjs → productDetail-D9-fCY6c.mjs} +3 -3
- package/dist/client/{productList-BiVpbZK2.mjs → productList-PJyxXSac.mjs} +3 -3
- package/dist/client/{propsDecoder-DFYqKnLy.mjs → propsDecoder-B8lrKGPw.mjs} +4 -4
- package/dist/client/{registry.server-C3OBRg7x.mjs → registry.server-CI63JVHW.mjs} +689 -569
- package/dist/client/rendering/client.mjs +28 -27
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +4 -4
- package/dist/client/{richText-coerce-ms477Z08.mjs → richText-coerce-Jt9hDHdh.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-B6nQeqvH.mjs → routeIslandApiConfig-ZSPcJWx1.mjs} +1 -1
- package/dist/client/runtimeResponse-DlPBWBd9.mjs +3 -0
- package/dist/client/{runtimeResponse-BYqsV1Kb.mjs → runtimeResponse-_iW9oEYc.mjs} +1 -1
- package/dist/client/{shop-xt4dQ3HH.mjs → shop-CbdJlWOw.mjs} +3 -3
- package/dist/client/{shop-commerce-DVsIcPaI.mjs → shop-commerce-BqLbzUUn.mjs} +44 -26
- package/dist/client/{shop-commerce-store-7mO6KY7_.mjs → shop-commerce-store-BT0-zRqN.mjs} +1 -1
- package/dist/client/{shop-discount-apply.state-L1Vge8tG.mjs → shop-discount-apply.state-Cws0lnSb.mjs} +1 -1
- package/dist/client/{shop.client-DNJfD3VQ.mjs → shop.client-0cNErhJT.mjs} +37 -18
- package/dist/client/{shopShared-DS8t6749.mjs → shopShared-COuQ2MhQ.mjs} +2 -2
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/{timetableModel-Dy3nNfTG.mjs → timetableModel-DqI6U1BS.mjs} +6 -6
- package/dist/client/{urlParams-C2QHo1Pa.mjs → useAutomaticDiscountPreview-CeVUVzGf.mjs} +44 -1
- package/dist/client/{useAvailableSlots-DcjtDpUu.mjs → useAvailableSlots-B0mjVhZr.mjs} +1 -1
- package/dist/client/{useDiscountCodeUi-DvdFFWOT.mjs → useDiscountCodeUi-B_hfgdAP.mjs} +6 -2
- package/dist/client/{useEventPagination-Cq-7sU5_.mjs → useEventPagination-Ct4A6iR1.mjs} +13 -15
- package/dist/client/{view-4gnPcpWJ.mjs → view-Cj151w4m.mjs} +4 -4
- package/dist/client/{wizardSteps-DDvL3iza.mjs → wizardSteps-B3gsXNnb.mjs} +212 -68
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-CLqSRUpt.mjs → EventEmbeddedCheckoutStep-CVy9oapv.mjs} +1 -1
- package/dist/preview-next/client/{LocationPickerEnvironment-CIdAg-Tm.mjs → LocationPickerEnvironment-DuRUwUrK.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-Bm85jX35.mjs → MapLibreEditMap-CdSDYBq9.mjs} +2 -2
- package/dist/preview-next/client/{PageSectionToolbar-D8srnz9R.mjs → PageSectionToolbar-Dv4CW0AQ.mjs} +582 -195
- package/dist/preview-next/client/{PreviewEditorSidebar-DVpk5cqp.mjs → PreviewEditorSidebar-B7WW58uE.mjs} +1095 -282
- package/dist/preview-next/client/{PreviewEditorUI-XoTtHSFH.mjs → PreviewEditorUI-BnJ1ughv.mjs} +65 -16
- package/dist/preview-next/client/{PreviewShell-VQHsRg2u.mjs → PreviewShell-C7qWzAe4.mjs} +39 -12
- package/dist/preview-next/client/{SdkPreviewModeRuntime-CLdF9f6o.mjs → SdkPreviewModeRuntime-CYi4UHtG.mjs} +128 -27
- package/dist/preview-next/client/{ThemedButton-ORNN4x-3.mjs → ThemedButton-CRgbU75r.mjs} +18 -2
- package/dist/preview-next/client/{lucide-react-eAi3tDAr.mjs → lucide-react-B4c6U3ZU.mjs} +1 -1
- package/dist/preview-next/client/{previewAssistantSlot-CqH91EwA.mjs → previewAssistantSlot-DrUoRNu9.mjs} +6239 -2558
- package/dist/preview-next/client/{previewChromeRoot-B3ySEu6p.mjs → previewChromeRoot-CEYp90mM.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-CdpSupcr.mjs → sdk-runtime-DnO2_c0A.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-C6eOP6QW.mjs → siteStyleAccess-B3PwHw2z.mjs} +16 -10
- package/dist/preview-next/client/{useAutosaveStatus-BhPg4e-r.mjs → useAutosaveStatus-DrdQ4ier.mjs} +3 -3
- package/dist/preview-next/client/{useOpenBlockForSetup-BaWUF9D7.mjs → useOpenBlockForSetup-kuGRKaRL.mjs} +4 -3
- package/dist/preview-next/container-responsive.css +150 -3
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-Ch0X99vE.mjs → route-contract-CwrXkLT3.mjs} +16 -28
- package/dist/server/{Block.shared-B2FmczLO.mjs → Block.shared-C5ucphCJ.mjs} +5 -5
- package/dist/server/{ThemeScopeCore-DtAyv9qA.mjs → ThemeScopeCore-DvbqYXdK.mjs} +34 -8
- package/dist/server/{accessibleSurfaces-BtPqb76u.mjs → accessibleSurfaces-CAcf1lHT.mjs} +317 -148
- package/dist/server/{accordions-vzdZ2Wt1.mjs → accordions-DjcsqjCK.mjs} +1 -1
- package/dist/server/{bindings-B_9JuU66.mjs → bindings-CFw4M-gZ.mjs} +68 -247
- package/dist/server/{client-DC7cjiSw.mjs → client-D0XCgITW.mjs} +26 -34
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/{constants-d6nPNJpe.mjs → constants-BZduY8jG.mjs} +9 -2
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-hb27HYic.mjs → loadContent-C-qyB8Tq.mjs} +4 -4
- package/dist/server/{loadPage-JToD8wDD.mjs → loadPage-BpKKmi8E.mjs} +3 -3
- package/dist/server/lookMediaFrame-EFws7tAj.mjs +31835 -0
- package/dist/server/manifest.mjs +2 -2
- package/dist/server/{navigation-B2WhGofA.mjs → navigation-DYkuiNXa.mjs} +1 -1
- package/dist/server/navigation.mjs +1 -1
- package/dist/server/next.mjs +9 -9
- package/dist/server/{overrideResolution-vD5KTClL.mjs → overrideResolution-DmZn4xUE.mjs} +1 -1
- package/dist/server/page-converter.mjs +17 -4
- package/dist/server/{pageRenderPlan-CdqJ1NQZ.mjs → pageRenderPlan-DRB7cUZ0.mjs} +595 -208
- package/dist/server/{pageRuntimeSupport-CAhr4oOf.mjs → pageRuntimeSupport-Uv1xDieJ.mjs} +12 -5
- package/dist/server/{pageShared-m80Xu2pd.mjs → pageShared-BdQF875z.mjs} +596 -383
- package/dist/server/{parseThemeForPersistence-CRwOZfpa.mjs → parseThemeForPersistence-CwcWZL7u.mjs} +3 -3
- package/dist/server/{portal-B2wCQno_.mjs → portal-BQ8qiQnk.mjs} +22 -2
- package/dist/server/portal.mjs +3 -3
- package/dist/server/{prebuild-BWIkFaXq.mjs → prebuild-B51QZVNe.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-D1PHU-K9.mjs → prefetchBlockData-CppDAfJW.mjs} +3 -3
- package/dist/server/{registry-KtsOsAzY.mjs → registry-Bf4W8Qa7.mjs} +1499 -28631
- 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-sjIDJYl7.mjs → resolveBlockData-DMHAZooQ.mjs} +2 -2
- package/dist/server/{expandPalette-DxPrNOAB.mjs → resolveButtonColourStates-BMtAAPzp.mjs} +1662 -1430
- package/dist/server/{responseMedia-IfH65QAH.mjs → responseMedia-DKYfR518.mjs} +1 -1
- package/dist/server/{schema-BBEqquBM.mjs → schema-DGaihVwp.mjs} +261 -6
- package/dist/server/server.mjs +3 -3
- package/dist/server/{servicePageContent-ChEZDRwU.mjs → servicePageContent-CRvmreX7.mjs} +8 -7
- package/dist/server/theme-bridge.mjs +5 -4
- package/dist/server/theme.mjs +2 -2
- package/dist/server/{three-pass-converter-DKCIBeb1.mjs → three-pass-converter-mcy2E1Yd.mjs} +1 -1
- package/dist/server/{titleSourceSchema-DybHErxH.mjs → titleSourceSchema-B2qFOUwZ.mjs} +2 -3
- package/dist/server/{types-vyz09w64.mjs → types-C_S0pWbR.mjs} +9 -2
- package/dist/server/{validation-Cvi-1TZZ.mjs → validation-CUtNT_EZ.mjs} +5 -5
- package/dist/server/{version-B-icAIV1.mjs → version-DebJQ4zn.mjs} +1 -1
- package/dist/styles/index.css +495 -50
- package/package.json +1 -1
- package/dist/client/runtimeResponse-CUX_lldL.mjs +0 -3
- package/dist/server/customCss-rtIfEYwQ.mjs +0 -230
- package/dist/server/lookMediaFrame-CTsycLLK.mjs +0 -2756
- package/dist/server/media-gvfIw3z8.mjs +0 -216
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as stableJsonStringify } from "./stable-json-D0XAEIXc.mjs";
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as isThemeColorToken, B as VARIANT_ROLES, C as parseOpaqueButtonColourToken, D as absoluteInkColors, E as PALETTE_TOKEN_NAMES, F as paletteModeSchema, I as parseColorTokenParts, L as parseThemeColorToken, N as paletteColorsFromEntries, S as opaqueButtonColourTokenSchema, T as isFreeButtonRadius, _ as buttonEffectApplicationSchema, c as STANDARD_BUTTON_SURFACE_POLICY, d as createStandardButtonSurfacePolicy, g as actionVariablePrefix, h as actionVariableName, i as buttonShadowLayersValue, j as normalizePaletteHex, k as hexColorSchema, p as unsafeAsOpaqueButtonColourToken, y as buttonSystemSchema } from "./buttonParts-C39GC0kz.mjs";
|
|
4
4
|
import { t as SURFACE_TRANSPORT_KEY } from "./surfaceTransportMarker-BuwkYxsI.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region ../theme-core/src/palette/utils/colorConversion.ts
|
|
@@ -584,12 +584,12 @@ function paletteInkOnSolid(groundHex, roles) {
|
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* The ink as token emitters write it: the role's theme token, so CSS follows
|
|
587
|
-
* the palette's variables, or
|
|
587
|
+
* the palette's variables, or a fixed absolute black/white token.
|
|
588
588
|
*/
|
|
589
589
|
function paletteInkToken(ink) {
|
|
590
|
-
|
|
591
|
-
if (!isThemeColorToken(
|
|
592
|
-
return
|
|
590
|
+
const token = ink.kind === "role" ? ink.role : ink.hex === "#000000" ? "absoluteBlack" : "absoluteWhite";
|
|
591
|
+
if (!isThemeColorToken(token)) throw new Error(`Palette ink is not a theme token: ${token}`);
|
|
592
|
+
return token;
|
|
593
593
|
}
|
|
594
594
|
/**
|
|
595
595
|
* Secondary text that has to read on several grounds (a surface and the tinted
|
|
@@ -642,7 +642,7 @@ function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
|
|
|
642
642
|
if (!underlayHex) return null;
|
|
643
643
|
const parts = parseColorTokenParts(reference);
|
|
644
644
|
if (parts.kind === "token" && parts.opacityPercent !== null) {
|
|
645
|
-
const foregroundHex =
|
|
645
|
+
const foregroundHex = resolveConcreteColorHex(parts.token, palette);
|
|
646
646
|
return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
|
|
647
647
|
}
|
|
648
648
|
const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
|
|
@@ -655,7 +655,7 @@ function resolveConcreteColorHex(reference, palette) {
|
|
|
655
655
|
const parts = parseColorTokenParts(reference);
|
|
656
656
|
if (parts.kind === "token") {
|
|
657
657
|
if (parts.opacityPercent !== null) return null;
|
|
658
|
-
return normalizePaletteHex(palette[parts.token] ?? "");
|
|
658
|
+
return normalizePaletteHex((parts.token === "absoluteBlack" || parts.token === "absoluteWhite" ? absoluteInkColors[parts.token] : palette[parts.token]) ?? "");
|
|
659
659
|
}
|
|
660
660
|
const literal = parts.kind === "raw" ? parts.value : reference;
|
|
661
661
|
if (literal.toLowerCase() === "black") return "#000000";
|
|
@@ -841,97 +841,6 @@ function surfaceForegroundInputFromResolved(foreground, color) {
|
|
|
841
841
|
function hoverDecoration(input) {
|
|
842
842
|
return input.hoverDecoration ?? "underline";
|
|
843
843
|
}
|
|
844
|
-
/**
|
|
845
|
-
* Derive the hover foreground that belongs with a resolved resting foreground.
|
|
846
|
-
*
|
|
847
|
-
* A resting foreground is chosen to be legible against a known surface. A hover
|
|
848
|
-
* state derived from it stays within a bounded distance of that colour, so it
|
|
849
|
-
* inherits most of the resting colour's contrast margin instead of asserting
|
|
850
|
-
* an unrelated brand colour that no one checked against the surface.
|
|
851
|
-
*
|
|
852
|
-
* That bounded-distance property is what lets this be used on a transparent
|
|
853
|
-
* overlay header, where the backdrop is only partly knowable: the scrolled
|
|
854
|
-
* state composites a 60% glass tint over arbitrary page content, so no
|
|
855
|
-
* compile-time contrast proof is available there. Staying near a colour that
|
|
856
|
-
* is already trusted in both states is a weaker claim than a contrast proof,
|
|
857
|
-
* and it is one this function can actually keep.
|
|
858
|
-
*
|
|
859
|
-
* Returns `null` when the resting token is not a plain palette token — an
|
|
860
|
-
* already-faded or raw value has no well-defined softening, and the caller
|
|
861
|
-
* should leave hover alone rather than guess.
|
|
862
|
-
*/
|
|
863
|
-
function deriveForegroundHoverToken(restingToken) {
|
|
864
|
-
const parts = parseColorTokenParts(restingToken);
|
|
865
|
-
if (parts.kind !== "token") return null;
|
|
866
|
-
if (parts.opacityPercent !== null) return null;
|
|
867
|
-
return parseThemeColorToken(`${parts.token}/85`);
|
|
868
|
-
}
|
|
869
|
-
/**
|
|
870
|
-
* Prefer an authored hover that survives every measured backdrop, then a
|
|
871
|
-
* checked softening of the resting colour. A null backdrop set represents a
|
|
872
|
-
* trusted treatment: only an explicit authored hover may change the colour.
|
|
873
|
-
* When neither option works, retain the resting colour and underline it.
|
|
874
|
-
*/
|
|
875
|
-
function planForegroundHover(input) {
|
|
876
|
-
const { restingToken, candidate, palette, backdrops } = input;
|
|
877
|
-
if (candidate && String(candidate) !== String(restingToken)) {
|
|
878
|
-
if (backdrops === null || survivesEveryBackdrop(candidate, palette, backdrops)) return {
|
|
879
|
-
kind: "candidate",
|
|
880
|
-
token: candidate,
|
|
881
|
-
decoration: "initial"
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
const resting = parseThemeColorToken(restingToken);
|
|
885
|
-
const softened = resting ? deriveForegroundHoverToken(resting) : null;
|
|
886
|
-
if (softened && backdrops && survivesEveryBackdrop(softened, palette, backdrops)) return {
|
|
887
|
-
kind: "softened",
|
|
888
|
-
token: softened,
|
|
889
|
-
decoration: "initial"
|
|
890
|
-
};
|
|
891
|
-
return {
|
|
892
|
-
kind: "resting",
|
|
893
|
-
token: restingToken,
|
|
894
|
-
decoration: "underline"
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
function survivesEveryBackdrop(token, palette, backdrops) {
|
|
898
|
-
return backdrops.length > 0 && backdrops.every((backdrop) => {
|
|
899
|
-
const foreground = resolveOpaqueSurfaceHex(token, palette, backdrop);
|
|
900
|
-
return foreground !== null && contrastRatio(foreground, backdrop) >= 4.5;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
//#endregion
|
|
904
|
-
//#region ../site-contracts/src/renderResults/buttonTypes.ts
|
|
905
|
-
const BUTTON_VISUAL_STATES = [
|
|
906
|
-
"base",
|
|
907
|
-
"hover",
|
|
908
|
-
"focus",
|
|
909
|
-
"active",
|
|
910
|
-
"disabled"
|
|
911
|
-
];
|
|
912
|
-
//#endregion
|
|
913
|
-
//#region ../theme-core/src/palette/utils/onColor.ts
|
|
914
|
-
const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
|
|
915
|
-
"primary",
|
|
916
|
-
"secondary",
|
|
917
|
-
"accent",
|
|
918
|
-
"success",
|
|
919
|
-
"warning",
|
|
920
|
-
"destructive",
|
|
921
|
-
"info",
|
|
922
|
-
"background",
|
|
923
|
-
"surface",
|
|
924
|
-
"surfaceAlt",
|
|
925
|
-
"muted",
|
|
926
|
-
"neutral"
|
|
927
|
-
]);
|
|
928
|
-
function onColorTokenName(backgroundToken) {
|
|
929
|
-
return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
|
|
930
|
-
}
|
|
931
|
-
function isOnColorBackgroundCandidateToken(token) {
|
|
932
|
-
const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
|
|
933
|
-
return BACKGROUND_ROLE_NAMES.has(role);
|
|
934
|
-
}
|
|
935
844
|
//#endregion
|
|
936
845
|
//#region ../theme-core/src/surfaces/inkCertificate.ts
|
|
937
846
|
/**
|
|
@@ -965,17 +874,20 @@ const surfaceTextPolicy = Object.freeze({
|
|
|
965
874
|
* the current-page link) keep the text threshold.
|
|
966
875
|
*/
|
|
967
876
|
const HOVER_TEXT_THRESHOLD = contrastThresholdByPolicy["large-text-aa"];
|
|
968
|
-
|
|
969
|
-
const isFallbackInk = (ink) => FALLBACK_INKS.includes(ink);
|
|
970
|
-
function inkReference(ink) {
|
|
971
|
-
return isFallbackInk(ink) ? `raw:${ink}` : ink;
|
|
972
|
-
}
|
|
973
|
-
/** A token, `rgba()` or literal, composited over each backdrop, clears the threshold on all of them. */
|
|
877
|
+
/** A sampled paint is continuous: also reject an ink whose luminance lies between its bounds. */
|
|
974
878
|
function inkClearsBackdrops(ink, threshold, backdrops, measurement) {
|
|
975
|
-
|
|
879
|
+
if (backdrops.length === 0) return true;
|
|
880
|
+
const readings = backdrops.flatMap((backdrop) => {
|
|
976
881
|
const hex = resolveOpaqueSurfaceHex(ink, measurement.palette, backdrop);
|
|
977
|
-
return hex
|
|
882
|
+
return hex === null ? [] : [{
|
|
883
|
+
ink: hexLuminance(hex, measurement.colourIndex),
|
|
884
|
+
ground: hexLuminance(backdrop, measurement.colourIndex)
|
|
885
|
+
}];
|
|
978
886
|
});
|
|
887
|
+
if (readings.length !== backdrops.length) return false;
|
|
888
|
+
const ground = luminanceInterval(Math.min(...readings.map((value) => value.ground)), Math.max(...readings.map((value) => value.ground)));
|
|
889
|
+
const inks = luminanceInterval(Math.min(...readings.map((value) => value.ink)), Math.max(...readings.map((value) => value.ink)));
|
|
890
|
+
return (inks.hi < ground.lo ? worstContrast(inks.hi, ground) : inks.lo > ground.hi ? worstContrast(inks.lo, ground) : 1) >= threshold;
|
|
979
891
|
}
|
|
980
892
|
/** The palette ink that clears every backdrop at ordinary-text contrast, or null when not even black or white does. */
|
|
981
893
|
function fallbackInk(backdrops, measurement) {
|
|
@@ -1045,316 +957,72 @@ function certifyPaint(place, ink, threshold, backdrop, measurement) {
|
|
|
1045
957
|
declared: ink
|
|
1046
958
|
};
|
|
1047
959
|
}
|
|
1048
|
-
//#endregion
|
|
1049
|
-
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
1050
960
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
* contrast ratios, not a simple luminance cutoff. This is
|
|
1053
|
-
* `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
|
|
1054
|
-
* only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
|
|
1055
|
-
* background and text colours first.
|
|
961
|
+
* Derive the hover foreground that belongs with a resolved resting foreground.
|
|
1056
962
|
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
963
|
+
* A resting foreground is chosen to be legible against a known surface. A hover
|
|
964
|
+
* state derived from it stays within a bounded distance of that colour, so it
|
|
965
|
+
* inherits most of the resting colour's contrast margin instead of asserting
|
|
966
|
+
* an unrelated brand colour that no one checked against the surface.
|
|
967
|
+
*
|
|
968
|
+
* That bounded-distance property is what lets this be used on a transparent
|
|
969
|
+
* overlay header, where the backdrop is only partly knowable: the scrolled
|
|
970
|
+
* state composites a 60% glass tint over arbitrary page content, so no
|
|
971
|
+
* compile-time contrast proof is available there. Staying near a colour that
|
|
972
|
+
* is already trusted in both states is a weaker claim than a contrast proof,
|
|
973
|
+
* and it is one this function can actually keep.
|
|
974
|
+
*
|
|
975
|
+
* Returns `null` when the resting token is not a plain palette token — an
|
|
976
|
+
* already-faded or raw value has no well-defined softening, and the caller
|
|
977
|
+
* should leave hover alone rather than guess.
|
|
1061
978
|
*/
|
|
1062
|
-
function
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
if (trimmed.startsWith("#")) return hexToRgb(trimmed);
|
|
1069
|
-
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);
|
|
1070
|
-
if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
|
|
1071
|
-
r: clamp255(Number(rgbMatch[1])),
|
|
1072
|
-
g: clamp255(Number(rgbMatch[2])),
|
|
1073
|
-
b: clamp255(Number(rgbMatch[3]))
|
|
1074
|
-
};
|
|
1075
|
-
throw new Error("Unsupported color format");
|
|
1076
|
-
}
|
|
1077
|
-
function clamp255(value) {
|
|
1078
|
-
if (Number.isNaN(value)) return 0;
|
|
1079
|
-
return Math.max(0, Math.min(255, value));
|
|
979
|
+
function deriveForegroundHoverToken(restingToken) {
|
|
980
|
+
const parts = parseColorTokenParts(restingToken);
|
|
981
|
+
if (parts.kind !== "token") return null;
|
|
982
|
+
if (parts.opacityPercent !== null) return null;
|
|
983
|
+
if (parts.token === "absoluteBlack" || parts.token === "absoluteWhite") return null;
|
|
984
|
+
return parseThemeColorToken(`${parts.token}/85`);
|
|
1080
985
|
}
|
|
1081
|
-
//#endregion
|
|
1082
|
-
//#region ../theme-core/src/surfaces/surfaceInks.ts
|
|
1083
|
-
/** Lines and focus rings are graphics: WCAG non-text contrast. */
|
|
1084
|
-
const GRAPHIC_MIN_CONTRAST_RATIO = 3;
|
|
1085
986
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
987
|
+
* Prefer an authored hover that survives every measured backdrop, then a
|
|
988
|
+
* checked softening of the resting colour. A null backdrop set represents a
|
|
989
|
+
* trusted treatment: only an explicit authored hover may change the colour.
|
|
990
|
+
* When neither option works, retain the resting colour and underline it.
|
|
1089
991
|
*/
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
|
|
1099
|
-
},
|
|
1100
|
-
focus: {
|
|
1101
|
-
token: "primary",
|
|
1102
|
-
ratio: GRAPHIC_MIN_CONTRAST_RATIO
|
|
1103
|
-
},
|
|
1104
|
-
control: {
|
|
1105
|
-
token: CONTROL_EDGE_SEED_TOKEN,
|
|
1106
|
-
ratio: GRAPHIC_MIN_CONTRAST_RATIO,
|
|
1107
|
-
maxDistance: 2
|
|
992
|
+
function planForegroundHover(input) {
|
|
993
|
+
const { restingToken, candidate, palette, backdrops } = input;
|
|
994
|
+
if (candidate && String(candidate) !== String(restingToken)) {
|
|
995
|
+
if (backdrops === null || survivesEveryBackdrop(candidate, palette, backdrops)) return {
|
|
996
|
+
kind: "candidate",
|
|
997
|
+
token: candidate,
|
|
998
|
+
decoration: "initial"
|
|
999
|
+
};
|
|
1108
1000
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
function solveSurfaceInks(backdropHex, textInk, palette, candidates = {}) {
|
|
1117
|
-
const paint = solidPaint(backdropHex);
|
|
1118
|
-
const fallback = literalInk$1(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
|
|
1001
|
+
const resting = parseThemeColorToken(restingToken);
|
|
1002
|
+
const softened = resting ? deriveForegroundHoverToken(resting) : null;
|
|
1003
|
+
if (softened && backdrops && survivesEveryBackdrop(softened, palette, backdrops)) return {
|
|
1004
|
+
kind: "softened",
|
|
1005
|
+
token: softened,
|
|
1006
|
+
decoration: "initial"
|
|
1007
|
+
};
|
|
1119
1008
|
return {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}, paint, palette, fallback),
|
|
1124
|
-
accent: solveInk({
|
|
1125
|
-
...INK_SEEDS.accent,
|
|
1126
|
-
token: candidates.accent ?? INK_SEEDS.accent.token
|
|
1127
|
-
}, paint, palette, fallback),
|
|
1128
|
-
focus: solveInk({
|
|
1129
|
-
...INK_SEEDS.focus,
|
|
1130
|
-
token: candidates.focus ?? INK_SEEDS.focus.token
|
|
1131
|
-
}, paint, palette, fallback),
|
|
1132
|
-
control: solveInk({
|
|
1133
|
-
...INK_SEEDS.control,
|
|
1134
|
-
token: candidates.control ?? INK_SEEDS.control.token
|
|
1135
|
-
}, paint, palette, fallback)
|
|
1009
|
+
kind: "resting",
|
|
1010
|
+
token: restingToken,
|
|
1011
|
+
decoration: "underline"
|
|
1136
1012
|
};
|
|
1137
1013
|
}
|
|
1138
|
-
function
|
|
1139
|
-
|
|
1140
|
-
const seedHex = hexColorSchema.safeParse(resolveConcreteColorHex(seed.token, palette));
|
|
1141
|
-
if (!token || !seedHex.success) return fallback;
|
|
1142
|
-
const solved = inkFrom(familyOf(seedHex.data), paint, seed.ratio, seed.maxDistance);
|
|
1143
|
-
switch (solved.kind) {
|
|
1144
|
-
case "ink": return solved.source === "exact" ? token : literalInk$1(solved.hex);
|
|
1145
|
-
case "too-far":
|
|
1146
|
-
case "unpaintable": return fallback;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
function literalInk$1(hex) {
|
|
1150
|
-
return hexColorSchema.parse(hex.toLowerCase());
|
|
1151
|
-
}
|
|
1152
|
-
const FAMILY_CACHE_LIMIT = 64;
|
|
1153
|
-
const families = /* @__PURE__ */ new Map();
|
|
1154
|
-
function familyOf(seed) {
|
|
1155
|
-
const cached = families.get(seed);
|
|
1156
|
-
if (cached) return cached;
|
|
1157
|
-
if (families.size >= FAMILY_CACHE_LIMIT) families.clear();
|
|
1158
|
-
const family = colourFamily(seed);
|
|
1159
|
-
families.set(seed, family);
|
|
1160
|
-
return family;
|
|
1014
|
+
function survivesEveryBackdrop(token, palette, backdrops) {
|
|
1015
|
+
return backdrops.length > 0 && inkClearsBackdrops(token, 4.5, backdrops, { palette });
|
|
1161
1016
|
}
|
|
1162
1017
|
//#endregion
|
|
1163
|
-
//#region ../
|
|
1164
|
-
const
|
|
1165
|
-
"
|
|
1166
|
-
"
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"onSecondary",
|
|
1171
|
-
"onAccent",
|
|
1172
|
-
"onSurface",
|
|
1173
|
-
"neutral-950",
|
|
1174
|
-
"neutral-50"
|
|
1018
|
+
//#region ../site-contracts/src/renderResults/buttonTypes.ts
|
|
1019
|
+
const BUTTON_VISUAL_STATES = [
|
|
1020
|
+
"base",
|
|
1021
|
+
"hover",
|
|
1022
|
+
"focus",
|
|
1023
|
+
"active",
|
|
1024
|
+
"disabled"
|
|
1175
1025
|
];
|
|
1176
|
-
function resolveSurfaceForeground(background, palette, candidates = {}, options = {}) {
|
|
1177
|
-
const authored = foregroundCandidates(background, candidates);
|
|
1178
|
-
if ("measuredBackdrop" in options) return resolveMeasuredForeground(background?.color ?? "background", options.measuredBackdrop, authored, palette);
|
|
1179
|
-
return resolveAuthoredBackground(background, palette, authored, options);
|
|
1180
|
-
}
|
|
1181
|
-
/** Legacy references may be measurable, inherited, or a trusted media treatment. */
|
|
1182
|
-
function resolveAuthoredBackground(background, palette, authored, options) {
|
|
1183
|
-
if (background === null) return resolveDeterministicForeground("background", {
|
|
1184
|
-
...authored,
|
|
1185
|
-
text: authored.text ?? "text"
|
|
1186
|
-
}, palette);
|
|
1187
|
-
if (background.type === "color") {
|
|
1188
|
-
const backgroundReference = normalizedReference(background.color);
|
|
1189
|
-
if (!backgroundReference || backgroundReference === "transparent") return { kind: "inherits" };
|
|
1190
|
-
return resolveDeterministicForeground(backgroundReference, authored, palette, options.compositeBase);
|
|
1191
|
-
}
|
|
1192
|
-
return resolveTrustedTreatmentForeground(authored, palette);
|
|
1193
|
-
}
|
|
1194
|
-
function foregroundCandidates(background, overrides) {
|
|
1195
|
-
return {
|
|
1196
|
-
text: candidateOrBackground(overrides.text, background?.textColor),
|
|
1197
|
-
heading: candidateOrBackground(overrides.heading, background?.headingColor),
|
|
1198
|
-
link: candidateOrBackground(overrides.link, background?.linkColor),
|
|
1199
|
-
linkHover: candidateOrBackground(overrides.linkHover),
|
|
1200
|
-
supporting: candidateOrBackground(overrides.supporting, background?.supportingColor)
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
function candidateOrBackground(candidate, backgroundValue) {
|
|
1204
|
-
return candidate ?? backgroundValue ?? null;
|
|
1205
|
-
}
|
|
1206
|
-
function resolveDeterministicForeground(backgroundReference, candidates, palette, compositeBase) {
|
|
1207
|
-
const backgroundHex = resolveOpaqueSurfaceHex(backgroundReference, palette, compositeBase);
|
|
1208
|
-
if (!backgroundHex) return resolveTrustedTreatmentForeground(candidates, palette);
|
|
1209
|
-
return resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette);
|
|
1210
|
-
}
|
|
1211
|
-
function resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette) {
|
|
1212
|
-
const backgroundToken = paletteToken(backgroundReference);
|
|
1213
|
-
const derivedOnToken = backgroundToken ? onColorTokenName(backgroundToken) : null;
|
|
1214
|
-
const text = firstSafeToken([candidates.text, derivedOnToken], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? paletteTextInk(backgroundHex, palette);
|
|
1215
|
-
return certifiedForeground(knownForeground({
|
|
1216
|
-
text,
|
|
1217
|
-
heading: safeTokenOr(candidates.heading, text, backgroundHex, palette),
|
|
1218
|
-
link: safeTokenOr(candidates.link, text, backgroundHex, palette),
|
|
1219
|
-
supporting: safeTokenOr(candidates.supporting, text, backgroundHex, palette)
|
|
1220
|
-
}, {
|
|
1221
|
-
kind: "measured",
|
|
1222
|
-
backdropHex: backgroundHex,
|
|
1223
|
-
inks: solveSurfaceInks(backgroundHex, text, palette)
|
|
1224
|
-
}, candidates.linkHover, palette), palette);
|
|
1225
|
-
}
|
|
1226
|
-
/** The automatic text when neither the authored ink nor the ground's on-colour reads: the palette's own pair, then black or white. */
|
|
1227
|
-
function paletteTextInk(backgroundHex, palette) {
|
|
1228
|
-
return paletteInkToken(paletteInkOnSolid(backgroundHex, paletteInkRoles(palette)));
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Every measured foreground goes through the ink certificate, whoever paints it
|
|
1232
|
-
* (sections, cards, header, footer, accordions). The candidates above are chosen
|
|
1233
|
-
* to pass, so the certificate is normally a no-op and the foreground is returned
|
|
1234
|
-
* as it was; an ink that misses takes black/white, and the solved inks follow
|
|
1235
|
-
* the certified text.
|
|
1236
|
-
*/
|
|
1237
|
-
function certifiedForeground(foreground, palette) {
|
|
1238
|
-
const { backdropHex } = foreground.provenance;
|
|
1239
|
-
const certified = certifySolidSurfaceInks({ foreground: foreground.roles }, backdropHex, { palette });
|
|
1240
|
-
if (certified.fallback.length === 0) return foreground;
|
|
1241
|
-
return {
|
|
1242
|
-
...foreground,
|
|
1243
|
-
roles: certified.foreground,
|
|
1244
|
-
provenance: {
|
|
1245
|
-
...foreground.provenance,
|
|
1246
|
-
inks: solveSurfaceInks(backdropHex, certified.foreground.text, palette),
|
|
1247
|
-
fallback: certified.fallback
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
function resolveTrustedTreatmentForeground(candidates, palette) {
|
|
1252
|
-
const text = canonicalInk(candidates.text, palette);
|
|
1253
|
-
if (!text) return { kind: "unmeasured-paint" };
|
|
1254
|
-
return knownForeground({
|
|
1255
|
-
text,
|
|
1256
|
-
heading: canonicalInk(candidates.heading, palette) ?? text,
|
|
1257
|
-
link: canonicalInk(candidates.link, palette) ?? text,
|
|
1258
|
-
supporting: canonicalInk(candidates.supporting, palette) ?? text
|
|
1259
|
-
}, { kind: "trusted-treatment" }, candidates.linkHover, palette);
|
|
1260
|
-
}
|
|
1261
|
-
function knownForeground(roles, provenance, hoverCandidate, palette) {
|
|
1262
|
-
const hover = planForegroundHover({
|
|
1263
|
-
restingToken: roles.link,
|
|
1264
|
-
candidate: canonicalHoverToken(hoverCandidate, palette),
|
|
1265
|
-
palette,
|
|
1266
|
-
backdrops: provenance.kind === "measured" ? [provenance.backdropHex] : null
|
|
1267
|
-
});
|
|
1268
|
-
return {
|
|
1269
|
-
kind: "known",
|
|
1270
|
-
provenance,
|
|
1271
|
-
roles: {
|
|
1272
|
-
...roles,
|
|
1273
|
-
linkHover: hover.token,
|
|
1274
|
-
muted: provenance.kind === "measured" ? paletteMutedInkOnSolid(provenance.backdropHex, resolveConcreteColorHex(roles.text, palette), paletteInkRoles(palette)) : roles.text
|
|
1275
|
-
},
|
|
1276
|
-
hoverDecoration: hover.decoration
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
function canonicalHoverToken(reference, palette) {
|
|
1280
|
-
const token = parseThemeColorToken(reference);
|
|
1281
|
-
if (token) {
|
|
1282
|
-
const parts = parseColorTokenParts(token);
|
|
1283
|
-
if (parts.kind === "token" && resolveConcreteColorHex(parts.token, palette)) return token;
|
|
1284
|
-
}
|
|
1285
|
-
return canonicalToken(reference, palette);
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* The one rule for what a resolved foreground publishes for the solved inks.
|
|
1289
|
-
* Only a measured paint under a publishing runtime publishes inks; any other
|
|
1290
|
-
* paint it owns resets them, and a paint it only inherits publishes nothing.
|
|
1291
|
-
*/
|
|
1292
|
-
function surfaceInkPublication(foreground, policy) {
|
|
1293
|
-
switch (foreground.kind) {
|
|
1294
|
-
case "inherits": return { kind: "none" };
|
|
1295
|
-
case "unmeasured-paint": return { kind: "reset" };
|
|
1296
|
-
case "known": return foreground.provenance.kind === "measured" && policy === "publish" ? {
|
|
1297
|
-
kind: "solved",
|
|
1298
|
-
inks: foreground.provenance.inks
|
|
1299
|
-
} : { kind: "reset" };
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
/** Keep a candidate only when it meets ordinary-text contrast on the ground. */
|
|
1303
|
-
function safeTokenOr(candidate, fallback, backgroundHex, palette) {
|
|
1304
|
-
return firstSafeToken([candidate], backgroundHex, palette) ?? fallback;
|
|
1305
|
-
}
|
|
1306
|
-
function firstSafeToken(candidates, backgroundHex, palette, preferredEquivalentTokens = []) {
|
|
1307
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1308
|
-
for (const candidate of candidates) {
|
|
1309
|
-
const token = canonicalToken(candidate, palette, preferredEquivalentTokens);
|
|
1310
|
-
if (!token || seen.has(token)) continue;
|
|
1311
|
-
seen.add(token);
|
|
1312
|
-
const foregroundHex = resolveConcreteColorHex(token, palette);
|
|
1313
|
-
if (foregroundHex && contrastRatio(backgroundHex, foregroundHex) >= 4.5) return token;
|
|
1314
|
-
}
|
|
1315
|
-
return null;
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* A media treatment's ink as the resolved contract spells it. Nothing measures
|
|
1319
|
-
* the paint, so literal black or white (the photo tint's fallback) stays that
|
|
1320
|
-
* literal colour rather than borrowing whichever palette token shares its value
|
|
1321
|
-
* today, or being dropped when none does. Any other reference is a palette token.
|
|
1322
|
-
* Measured solids keep `firstSafeToken`, whose equivalent on-colour carries the
|
|
1323
|
-
* ground's own hover softening.
|
|
1324
|
-
*/
|
|
1325
|
-
function canonicalInk(reference, palette) {
|
|
1326
|
-
return literalInk(reference) ?? canonicalToken(reference, palette);
|
|
1327
|
-
}
|
|
1328
|
-
function literalInk(reference) {
|
|
1329
|
-
const normalized = normalizedReference(reference)?.toUpperCase();
|
|
1330
|
-
return normalized === "#000000" || normalized === "#FFFFFF" ? normalized : null;
|
|
1331
|
-
}
|
|
1332
|
-
function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
|
|
1333
|
-
const normalized = normalizedReference(reference);
|
|
1334
|
-
if (!normalized || normalized === "transparent") return null;
|
|
1335
|
-
const direct = parseThemeColorToken(normalized);
|
|
1336
|
-
if (direct && resolveConcreteColorHex(direct, palette)) return direct;
|
|
1337
|
-
const referenceHex = resolveConcreteColorHex(normalized, palette);
|
|
1338
|
-
if (!referenceHex) return null;
|
|
1339
|
-
const equivalent = [
|
|
1340
|
-
...preferredEquivalentTokens,
|
|
1341
|
-
...CANONICAL_EQUIVALENT_TOKEN_ORDER,
|
|
1342
|
-
...Object.keys(palette).sort()
|
|
1343
|
-
].find((token) => {
|
|
1344
|
-
const parsed = parseThemeColorToken(token);
|
|
1345
|
-
return parsed !== null && resolveConcreteColorHex(parsed, palette)?.toLowerCase() === referenceHex.toLowerCase();
|
|
1346
|
-
});
|
|
1347
|
-
return equivalent ? parseThemeColorToken(equivalent) : null;
|
|
1348
|
-
}
|
|
1349
|
-
function paletteToken(reference) {
|
|
1350
|
-
const parts = parseColorTokenParts(reference);
|
|
1351
|
-
return parts.kind === "token" && parts.opacityPercent === null ? parts.token : null;
|
|
1352
|
-
}
|
|
1353
|
-
function normalizedReference(value) {
|
|
1354
|
-
if (typeof value !== "string") return null;
|
|
1355
|
-
const normalized = value.trim();
|
|
1356
|
-
return normalized.length > 0 ? normalized : null;
|
|
1357
|
-
}
|
|
1358
1026
|
//#endregion
|
|
1359
1027
|
//#region ../theme-core/src/palette/generateShades.ts
|
|
1360
1028
|
function generateShades(hexColor, name) {
|
|
@@ -1528,6 +1196,62 @@ function scrimTone(samples) {
|
|
|
1528
1196
|
return white === black ? null : white > black ? "dark" : "light";
|
|
1529
1197
|
}
|
|
1530
1198
|
//#endregion
|
|
1199
|
+
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
1200
|
+
/**
|
|
1201
|
+
* Pick the better of black/white text for a given background using actual
|
|
1202
|
+
* contrast ratios, not a simple luminance cutoff. This is
|
|
1203
|
+
* `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
|
|
1204
|
+
* only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
|
|
1205
|
+
* background and text colours first.
|
|
1206
|
+
*
|
|
1207
|
+
* @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
|
|
1208
|
+
* @param _minContrast - Kept for callers. It cannot change the result: when
|
|
1209
|
+
* only one of black or white reaches it, that one is also the better of the two.
|
|
1210
|
+
* @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
|
|
1211
|
+
*/
|
|
1212
|
+
function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
|
|
1213
|
+
const { r, g, b } = parseColorToRgb(background);
|
|
1214
|
+
return literalInkHex(maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink);
|
|
1215
|
+
}
|
|
1216
|
+
function parseColorToRgb(input) {
|
|
1217
|
+
const trimmed = input.trim();
|
|
1218
|
+
if (trimmed.startsWith("#")) return hexToRgb(trimmed);
|
|
1219
|
+
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);
|
|
1220
|
+
if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
|
|
1221
|
+
r: clamp255(Number(rgbMatch[1])),
|
|
1222
|
+
g: clamp255(Number(rgbMatch[2])),
|
|
1223
|
+
b: clamp255(Number(rgbMatch[3]))
|
|
1224
|
+
};
|
|
1225
|
+
throw new Error("Unsupported color format");
|
|
1226
|
+
}
|
|
1227
|
+
function clamp255(value) {
|
|
1228
|
+
if (Number.isNaN(value)) return 0;
|
|
1229
|
+
return Math.max(0, Math.min(255, value));
|
|
1230
|
+
}
|
|
1231
|
+
//#endregion
|
|
1232
|
+
//#region ../theme-core/src/palette/utils/onColor.ts
|
|
1233
|
+
const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
|
|
1234
|
+
"primary",
|
|
1235
|
+
"secondary",
|
|
1236
|
+
"accent",
|
|
1237
|
+
"success",
|
|
1238
|
+
"warning",
|
|
1239
|
+
"destructive",
|
|
1240
|
+
"info",
|
|
1241
|
+
"background",
|
|
1242
|
+
"surface",
|
|
1243
|
+
"surfaceAlt",
|
|
1244
|
+
"muted",
|
|
1245
|
+
"neutral"
|
|
1246
|
+
]);
|
|
1247
|
+
function onColorTokenName(backgroundToken) {
|
|
1248
|
+
return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
|
|
1249
|
+
}
|
|
1250
|
+
function isOnColorBackgroundCandidateToken(token) {
|
|
1251
|
+
const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
|
|
1252
|
+
return BACKGROUND_ROLE_NAMES.has(role);
|
|
1253
|
+
}
|
|
1254
|
+
//#endregion
|
|
1531
1255
|
//#region ../theme-core/src/palette/expandPalette.ts
|
|
1532
1256
|
function colorsToMap(palette) {
|
|
1533
1257
|
const map = {};
|
|
@@ -1651,109 +1375,423 @@ const MUTED_INK_TOKENS = {
|
|
|
1651
1375
|
* ground its colours were chosen for. Hosted palettes and the SDK bridge both
|
|
1652
1376
|
* derive it here.
|
|
1653
1377
|
*/
|
|
1654
|
-
function groundMutedInk(palette, ground) {
|
|
1655
|
-
const groundHex = palette[ground];
|
|
1656
|
-
if (!groundHex) return null;
|
|
1657
|
-
const preferred = palette[onColorTokenName(ground)] ?? null;
|
|
1658
|
-
const roles = paletteInkRoles(palette);
|
|
1659
|
-
const initial = {
|
|
1660
|
-
grounds: [groundHex],
|
|
1661
|
-
hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
|
|
1662
|
-
uncovered: []
|
|
1378
|
+
function groundMutedInk(palette, ground) {
|
|
1379
|
+
const groundHex = palette[ground];
|
|
1380
|
+
if (!groundHex) return null;
|
|
1381
|
+
const preferred = palette[onColorTokenName(ground)] ?? null;
|
|
1382
|
+
const roles = paletteInkRoles(palette);
|
|
1383
|
+
const initial = {
|
|
1384
|
+
grounds: [groundHex],
|
|
1385
|
+
hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
|
|
1386
|
+
uncovered: []
|
|
1387
|
+
};
|
|
1388
|
+
const solved = SURFACE_SECONDARY_TEXT_TINTS.reduce((kept, { token, alpha }) => {
|
|
1389
|
+
const tintHex = palette[token];
|
|
1390
|
+
if (!tintHex) return kept;
|
|
1391
|
+
const grounds = [...kept.grounds, compositeHex(tintHex, alpha, groundHex)];
|
|
1392
|
+
const ink = paletteMutedInk(grounds, preferred, roles);
|
|
1393
|
+
return ink.kind === "unpaintable" ? {
|
|
1394
|
+
...kept,
|
|
1395
|
+
uncovered: [...kept.uncovered, {
|
|
1396
|
+
token,
|
|
1397
|
+
alpha,
|
|
1398
|
+
tintHex
|
|
1399
|
+
}]
|
|
1400
|
+
} : {
|
|
1401
|
+
...kept,
|
|
1402
|
+
grounds,
|
|
1403
|
+
hex: ink.hex
|
|
1404
|
+
};
|
|
1405
|
+
}, initial);
|
|
1406
|
+
return {
|
|
1407
|
+
hex: solved.hex,
|
|
1408
|
+
fadedTints: solved.uncovered.map(({ token, alpha, tintHex }) => ({
|
|
1409
|
+
token,
|
|
1410
|
+
hex: tintFadedUntilInkReads(tintHex, alpha, groundHex, solved.hex)
|
|
1411
|
+
}))
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
/** The tint colour a ground publishes in place of a tint its muted ink can't read on, e.g. `surfaceTintMuted`. */
|
|
1415
|
+
function groundTintToken(ground, tint) {
|
|
1416
|
+
return `${ground}Tint${tint.charAt(0).toUpperCase()}${tint.slice(1)}`;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* The tint blended toward the ground in 1% steps, stopping at the first that
|
|
1420
|
+
* the ink reads on when laid at `alpha`. The ground itself always reads, since
|
|
1421
|
+
* the ink was solved on it.
|
|
1422
|
+
*/
|
|
1423
|
+
function tintFadedUntilInkReads(tintHex, alpha, groundHex, inkHex) {
|
|
1424
|
+
const tint = hexToRgb(tintHex);
|
|
1425
|
+
const ground = hexToRgb(groundHex);
|
|
1426
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
1427
|
+
const amount = index / 100;
|
|
1428
|
+
return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
|
|
1429
|
+
}).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* The muted ink tokens a palette doesn't store itself, and the faded tint
|
|
1433
|
+
* colours of each ground whose ink is solved here, as hex.
|
|
1434
|
+
*/
|
|
1435
|
+
function groundMutedInkTokens(palette) {
|
|
1436
|
+
return Object.fromEntries(Object.entries(MUTED_INK_TOKENS).flatMap(([ground, token]) => {
|
|
1437
|
+
if (palette[token]) return [];
|
|
1438
|
+
const ink = groundMutedInk(palette, ground);
|
|
1439
|
+
if (!ink) return [];
|
|
1440
|
+
const faded = ink.fadedTints.map(({ token: tint, hex }) => [groundTintToken(ground, tint), hex]);
|
|
1441
|
+
return [[token, ink.hex], ...faded.filter(([name]) => !palette[name])];
|
|
1442
|
+
}));
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* The neutral step stays when it reads on the ground. Otherwise (a dark palette
|
|
1446
|
+
* on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
|
|
1447
|
+
* with a 4.5:1 floor, heading for the palette's own ink on that ground.
|
|
1448
|
+
*/
|
|
1449
|
+
function readableMutedText(step, base, roles) {
|
|
1450
|
+
const ground = base.background || base.surface;
|
|
1451
|
+
if (!ground || contrastRatio(step, ground) >= 4.5) return step;
|
|
1452
|
+
return paletteMutedInkOnSolid(ground, null, roles);
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Derived decoration colours never become editable palette swatches. The mark
|
|
1456
|
+
* blends toward literal black or white: it's a graphic endpoint for a 3:1
|
|
1457
|
+
* search, not text, so it stays off the palette ink rule.
|
|
1458
|
+
*/
|
|
1459
|
+
/** `backdrops` lists every colour the decorations sit on, such as each step of a radial glow. */
|
|
1460
|
+
function deriveSurfaceDecorationColors(ground, text, accent, backdrops = [ground]) {
|
|
1461
|
+
const ink = pickBlackOrWhiteTextColor(ground);
|
|
1462
|
+
return {
|
|
1463
|
+
line: deriveSurfaceLineColor(ground, text, backdrops),
|
|
1464
|
+
mark: firstContrastBlend(accent, ink, backdrops, 3)
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Secondary ink blended from its ground toward its text, reading at 4.5:1 over
|
|
1469
|
+
* every backdrop a sampled finish paints under it. When no blend reads on all of
|
|
1470
|
+
* them the text itself is kept (or, with no concrete text, the ink solved on
|
|
1471
|
+
* the ground alone).
|
|
1472
|
+
*/
|
|
1473
|
+
function deriveSurfaceMutedColor(ground, text, backdrops = [ground], roles = null) {
|
|
1474
|
+
const ink = paletteMutedInk([ground, ...backdrops], text, roles);
|
|
1475
|
+
if (ink.kind === "muted") return ink.hex;
|
|
1476
|
+
return text ?? paletteMutedInkOnSolid(ground, null, roles);
|
|
1477
|
+
}
|
|
1478
|
+
/** A section rule is a quiet ground-to-text blend, certified over the complete backing. */
|
|
1479
|
+
function deriveSurfaceLineColor(ground, text, backdrops = [ground]) {
|
|
1480
|
+
return firstContrastBlend(ground, text, backdrops, 1.5);
|
|
1481
|
+
}
|
|
1482
|
+
function firstContrastBlend(from, to, backdrops, threshold) {
|
|
1483
|
+
const start = hexToRgb(from);
|
|
1484
|
+
const end = hexToRgb(to);
|
|
1485
|
+
const luminances = backdrops.map((backdrop) => hexLuminance(backdrop));
|
|
1486
|
+
const paint = luminanceInterval(Math.min(...luminances), Math.max(...luminances));
|
|
1487
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
1488
|
+
const amount = index / 100;
|
|
1489
|
+
return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
|
|
1490
|
+
}).find((hex) => worstContrast(hexLuminance(hex), paint) >= threshold) ?? to;
|
|
1491
|
+
}
|
|
1492
|
+
/** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
|
|
1493
|
+
function arrangementPaletteTokens(base, options) {
|
|
1494
|
+
if (options.arrangement !== true || !base.text) return {};
|
|
1495
|
+
return {
|
|
1496
|
+
onText: base.onText ?? paletteInkOnSolid(base.text, paletteInkRoles(base)).hex,
|
|
1497
|
+
...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
//#endregion
|
|
1501
|
+
//#region ../theme-core/src/surfaces/surfaceInks.ts
|
|
1502
|
+
/** Lines and focus rings are graphics: WCAG non-text contrast. */
|
|
1503
|
+
const GRAPHIC_MIN_CONTRAST_RATIO = 3;
|
|
1504
|
+
/**
|
|
1505
|
+
* The palette token the control edge ink is solved from. Input styles whose
|
|
1506
|
+
* border uses another token keep their own colour, since this ink would carry
|
|
1507
|
+
* the wrong hue for them.
|
|
1508
|
+
*/
|
|
1509
|
+
const CONTROL_EDGE_SEED_TOKEN = "border";
|
|
1510
|
+
const INK_SEEDS = {
|
|
1511
|
+
brand: {
|
|
1512
|
+
token: "primary",
|
|
1513
|
+
ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
|
|
1514
|
+
},
|
|
1515
|
+
accent: {
|
|
1516
|
+
token: "accent",
|
|
1517
|
+
ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
|
|
1518
|
+
},
|
|
1519
|
+
focus: {
|
|
1520
|
+
token: "primary",
|
|
1521
|
+
ratio: GRAPHIC_MIN_CONTRAST_RATIO
|
|
1522
|
+
},
|
|
1523
|
+
control: {
|
|
1524
|
+
token: CONTROL_EDGE_SEED_TOKEN,
|
|
1525
|
+
ratio: GRAPHIC_MIN_CONTRAST_RATIO,
|
|
1526
|
+
maxDistance: 2
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
/**
|
|
1530
|
+
* Solve the inks for a measured solid paint. `textInk` is the surface's
|
|
1531
|
+
* own (already certified) text ink: it stands in when the owner's colour is
|
|
1532
|
+
* missing, or can only clear the paint by drifting too far from itself.
|
|
1533
|
+
* A block owner can supply an authored shade candidate for a local ink.
|
|
1534
|
+
*/
|
|
1535
|
+
function solveSurfaceInks(backdrop, textInk, palette, candidates = {}) {
|
|
1536
|
+
const [backdropHex] = typeof backdrop === "string" ? [backdrop] : backdrop;
|
|
1537
|
+
const paint = typeof backdrop === "string" ? solidPaint(backdrop) : sampledInkPaint(backdrop);
|
|
1538
|
+
const fallback = literalInk(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
|
|
1539
|
+
return {
|
|
1540
|
+
brand: solveInk({
|
|
1541
|
+
...INK_SEEDS.brand,
|
|
1542
|
+
token: candidates.brand ?? INK_SEEDS.brand.token
|
|
1543
|
+
}, paint, palette, fallback),
|
|
1544
|
+
accent: solveInk({
|
|
1545
|
+
...INK_SEEDS.accent,
|
|
1546
|
+
token: candidates.accent ?? INK_SEEDS.accent.token
|
|
1547
|
+
}, paint, palette, fallback),
|
|
1548
|
+
focus: solveInk({
|
|
1549
|
+
...INK_SEEDS.focus,
|
|
1550
|
+
token: candidates.focus ?? INK_SEEDS.focus.token
|
|
1551
|
+
}, paint, palette, fallback),
|
|
1552
|
+
control: solveInk({
|
|
1553
|
+
...INK_SEEDS.control,
|
|
1554
|
+
token: candidates.control ?? INK_SEEDS.control.token
|
|
1555
|
+
}, paint, palette, fallback)
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
function solveInk(seed, paint, palette, fallback) {
|
|
1559
|
+
const token = parseThemeColorToken(seed.token);
|
|
1560
|
+
const seedHex = hexColorSchema.safeParse(resolveConcreteColorHex(seed.token, palette));
|
|
1561
|
+
if (!token || !seedHex.success) return fallback;
|
|
1562
|
+
const solved = inkFrom(familyOf(seedHex.data), paint, seed.ratio, seed.maxDistance);
|
|
1563
|
+
switch (solved.kind) {
|
|
1564
|
+
case "ink": return solved.source === "exact" ? token : literalInk(solved.hex);
|
|
1565
|
+
case "too-far":
|
|
1566
|
+
case "unpaintable": return fallback;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
function literalInk(hex) {
|
|
1570
|
+
return hexColorSchema.parse(hex.toLowerCase());
|
|
1571
|
+
}
|
|
1572
|
+
const FAMILY_CACHE_LIMIT = 64;
|
|
1573
|
+
const families = /* @__PURE__ */ new Map();
|
|
1574
|
+
function familyOf(seed) {
|
|
1575
|
+
const cached = families.get(seed);
|
|
1576
|
+
if (cached) return cached;
|
|
1577
|
+
if (families.size >= FAMILY_CACHE_LIMIT) families.clear();
|
|
1578
|
+
const family = colourFamily(seed);
|
|
1579
|
+
families.set(seed, family);
|
|
1580
|
+
return family;
|
|
1581
|
+
}
|
|
1582
|
+
/** The same solver holds local inks against the whole finished ground's luminance range. */
|
|
1583
|
+
function sampledInkPaint(backdrops) {
|
|
1584
|
+
const luminances = backdrops.map((colour) => hexLuminance(colour));
|
|
1585
|
+
return luminanceInterval(Math.min(...luminances), Math.max(...luminances));
|
|
1586
|
+
}
|
|
1587
|
+
//#endregion
|
|
1588
|
+
//#region ../theme-core/src/surfaces/resolveSurfaceForeground.ts
|
|
1589
|
+
const CANONICAL_EQUIVALENT_TOKEN_ORDER = [
|
|
1590
|
+
"text",
|
|
1591
|
+
"primaryForeground",
|
|
1592
|
+
"secondaryForeground",
|
|
1593
|
+
"accentForeground",
|
|
1594
|
+
"onPrimary",
|
|
1595
|
+
"onSecondary",
|
|
1596
|
+
"onAccent",
|
|
1597
|
+
"onSurface",
|
|
1598
|
+
"neutral-950",
|
|
1599
|
+
"neutral-50"
|
|
1600
|
+
];
|
|
1601
|
+
function resolveSurfaceForeground(background, palette, candidates = {}, options = {}) {
|
|
1602
|
+
const authored = foregroundCandidates(background, candidates);
|
|
1603
|
+
if ("measuredBackdrop" in options) return resolveMeasuredForeground(background?.color ?? "background", options.measuredBackdrop, authored, palette);
|
|
1604
|
+
return resolveAuthoredBackground(background, palette, authored, options);
|
|
1605
|
+
}
|
|
1606
|
+
/** Legacy references may be measurable, inherited, or a trusted media treatment. */
|
|
1607
|
+
function resolveAuthoredBackground(background, palette, authored, options) {
|
|
1608
|
+
if (background === null) return resolveDeterministicForeground("background", {
|
|
1609
|
+
...authored,
|
|
1610
|
+
text: authored.text ?? "text"
|
|
1611
|
+
}, palette);
|
|
1612
|
+
if (background.type === "color") {
|
|
1613
|
+
const backgroundReference = normalizedReference(background.color);
|
|
1614
|
+
if (!backgroundReference || backgroundReference === "transparent") return { kind: "inherits" };
|
|
1615
|
+
return resolveDeterministicForeground(backgroundReference, authored, palette, options.compositeBase);
|
|
1616
|
+
}
|
|
1617
|
+
return resolveTrustedTreatmentForeground(authored, palette);
|
|
1618
|
+
}
|
|
1619
|
+
function foregroundCandidates(background, overrides) {
|
|
1620
|
+
return {
|
|
1621
|
+
text: candidateOrBackground(overrides.text, background?.textColor),
|
|
1622
|
+
heading: candidateOrBackground(overrides.heading, background?.headingColor),
|
|
1623
|
+
link: candidateOrBackground(overrides.link, background?.linkColor),
|
|
1624
|
+
linkHover: candidateOrBackground(overrides.linkHover),
|
|
1625
|
+
supporting: candidateOrBackground(overrides.supporting, background?.supportingColor)
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
function candidateOrBackground(candidate, backgroundValue) {
|
|
1629
|
+
return candidate ?? backgroundValue ?? null;
|
|
1630
|
+
}
|
|
1631
|
+
function resolveDeterministicForeground(backgroundReference, candidates, palette, compositeBase) {
|
|
1632
|
+
const backgroundHex = resolveOpaqueSurfaceHex(backgroundReference, palette, compositeBase);
|
|
1633
|
+
if (!backgroundHex) return resolveTrustedTreatmentForeground(candidates, palette);
|
|
1634
|
+
return resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette);
|
|
1635
|
+
}
|
|
1636
|
+
function resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette) {
|
|
1637
|
+
const backgroundToken = paletteToken(backgroundReference);
|
|
1638
|
+
const derivedOnToken = backgroundToken ? onColorTokenName(backgroundToken) : null;
|
|
1639
|
+
const text = firstSafeToken([candidates.text, derivedOnToken], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? paletteTextInk(backgroundHex, palette);
|
|
1640
|
+
return certifiedForeground(knownForeground({
|
|
1641
|
+
text,
|
|
1642
|
+
heading: safeTokenOr(candidates.heading, text, backgroundHex, palette),
|
|
1643
|
+
link: safeTokenOr(candidates.link, text, backgroundHex, palette),
|
|
1644
|
+
supporting: safeTokenOr(candidates.supporting, text, backgroundHex, palette)
|
|
1645
|
+
}, {
|
|
1646
|
+
kind: "measured",
|
|
1647
|
+
backdropHex: backgroundHex,
|
|
1648
|
+
inks: solveSurfaceInks(backgroundHex, text, palette)
|
|
1649
|
+
}, candidates.linkHover, palette), palette);
|
|
1650
|
+
}
|
|
1651
|
+
/** The automatic text when neither the authored ink nor the ground's on-colour reads: the palette's own pair, then black or white. */
|
|
1652
|
+
function paletteTextInk(backgroundHex, palette) {
|
|
1653
|
+
return paletteInkToken(paletteInkOnSolid(backgroundHex, paletteInkRoles(palette)));
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Every measured foreground goes through the ink certificate, whoever paints it
|
|
1657
|
+
* (sections, cards, header, footer, accordions). The candidates above are chosen
|
|
1658
|
+
* to pass, so the certificate is normally a no-op and the foreground is returned
|
|
1659
|
+
* as it was; an ink that misses takes black/white, and the solved inks follow
|
|
1660
|
+
* the certified text.
|
|
1661
|
+
*/
|
|
1662
|
+
function certifiedForeground(foreground, palette) {
|
|
1663
|
+
const { backdropHex } = foreground.provenance;
|
|
1664
|
+
const certified = certifySolidSurfaceInks({ foreground: foreground.roles }, backdropHex, { palette });
|
|
1665
|
+
if (certified.fallback.length === 0) return foreground;
|
|
1666
|
+
return {
|
|
1667
|
+
...foreground,
|
|
1668
|
+
roles: certified.foreground,
|
|
1669
|
+
provenance: {
|
|
1670
|
+
...foreground.provenance,
|
|
1671
|
+
inks: solveSurfaceInks(backdropHex, certified.foreground.text, palette),
|
|
1672
|
+
fallback: certified.fallback
|
|
1673
|
+
}
|
|
1663
1674
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
} : {
|
|
1677
|
-
...kept,
|
|
1678
|
-
grounds,
|
|
1679
|
-
hex: ink.hex
|
|
1680
|
-
};
|
|
1681
|
-
}, initial);
|
|
1675
|
+
}
|
|
1676
|
+
function resolveTrustedTreatmentForeground(candidates, palette) {
|
|
1677
|
+
const text = canonicalInk(candidates.text, palette);
|
|
1678
|
+
if (!text) return { kind: "unmeasured-paint" };
|
|
1679
|
+
return knownForeground({
|
|
1680
|
+
text,
|
|
1681
|
+
heading: canonicalInk(candidates.heading, palette) ?? text,
|
|
1682
|
+
link: canonicalInk(candidates.link, palette) ?? text,
|
|
1683
|
+
supporting: canonicalInk(candidates.supporting, palette) ?? text
|
|
1684
|
+
}, { kind: "trusted-treatment" }, candidates.linkHover, palette);
|
|
1685
|
+
}
|
|
1686
|
+
function knownForeground(roles, provenance, hoverCandidate, palette) {
|
|
1682
1687
|
return {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
+
kind: "known",
|
|
1689
|
+
provenance,
|
|
1690
|
+
...deriveSurfaceForegroundDetails(roles, {
|
|
1691
|
+
palette,
|
|
1692
|
+
hoverCandidate,
|
|
1693
|
+
ground: provenance.kind === "measured" ? provenance.backdropHex : void 0,
|
|
1694
|
+
backdrops: provenance.kind === "measured" ? provenance.backdropSamples ?? [provenance.backdropHex] : null
|
|
1695
|
+
})
|
|
1688
1696
|
};
|
|
1689
1697
|
}
|
|
1690
|
-
/**
|
|
1691
|
-
function
|
|
1692
|
-
|
|
1698
|
+
/** Normal muted and hover derivation, using all of a sampled paint rather than one stop. */
|
|
1699
|
+
function deriveSurfaceForegroundDetails(roles, input) {
|
|
1700
|
+
const { palette, ground, backdrops } = input;
|
|
1701
|
+
const hover = planForegroundHover({
|
|
1702
|
+
restingToken: roles.link,
|
|
1703
|
+
candidate: canonicalHoverToken(input.hoverCandidate ?? null, palette),
|
|
1704
|
+
palette,
|
|
1705
|
+
backdrops
|
|
1706
|
+
});
|
|
1707
|
+
const text = resolveConcreteColorHex(roles.text, palette);
|
|
1708
|
+
const muted = ground && backdrops ? deriveSurfaceMutedColor(ground, text, backdrops, paletteInkRoles(palette)) : roles.text;
|
|
1709
|
+
return {
|
|
1710
|
+
roles: {
|
|
1711
|
+
...roles,
|
|
1712
|
+
linkHover: hover.token,
|
|
1713
|
+
muted
|
|
1714
|
+
},
|
|
1715
|
+
hoverDecoration: hover.decoration
|
|
1716
|
+
};
|
|
1693
1717
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
const ground = hexToRgb(groundHex);
|
|
1702
|
-
return Array.from({ length: 101 }, (_, index) => {
|
|
1703
|
-
const amount = index / 100;
|
|
1704
|
-
return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
|
|
1705
|
-
}).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
|
|
1718
|
+
function canonicalHoverToken(reference, palette) {
|
|
1719
|
+
const token = parseThemeColorToken(reference);
|
|
1720
|
+
if (token) {
|
|
1721
|
+
const parts = parseColorTokenParts(token);
|
|
1722
|
+
if (parts.kind === "token" && resolveConcreteColorHex(parts.token, palette)) return token;
|
|
1723
|
+
}
|
|
1724
|
+
return canonicalToken(reference, palette);
|
|
1706
1725
|
}
|
|
1707
1726
|
/**
|
|
1708
|
-
* The
|
|
1709
|
-
*
|
|
1727
|
+
* The one rule for what a resolved foreground publishes for the solved inks.
|
|
1728
|
+
* Only a measured paint under a publishing runtime publishes inks; any other
|
|
1729
|
+
* paint it owns resets them, and a paint it only inherits publishes nothing.
|
|
1710
1730
|
*/
|
|
1711
|
-
function
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1731
|
+
function surfaceInkPublication(foreground, policy) {
|
|
1732
|
+
switch (foreground.kind) {
|
|
1733
|
+
case "inherits": return { kind: "none" };
|
|
1734
|
+
case "unmeasured-paint": return { kind: "reset" };
|
|
1735
|
+
case "known": return foreground.provenance.kind === "measured" && policy === "publish" ? {
|
|
1736
|
+
kind: "solved",
|
|
1737
|
+
inks: foreground.provenance.inks
|
|
1738
|
+
} : { kind: "reset" };
|
|
1739
|
+
}
|
|
1719
1740
|
}
|
|
1720
|
-
/**
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1741
|
+
/** Keep a candidate only when it meets ordinary-text contrast on the ground. */
|
|
1742
|
+
function safeTokenOr(candidate, fallback, backgroundHex, palette) {
|
|
1743
|
+
return firstSafeToken([candidate], backgroundHex, palette) ?? fallback;
|
|
1744
|
+
}
|
|
1745
|
+
function firstSafeToken(candidates, backgroundHex, palette, preferredEquivalentTokens = []) {
|
|
1746
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1747
|
+
for (const candidate of candidates) {
|
|
1748
|
+
const token = canonicalToken(candidate, palette, preferredEquivalentTokens);
|
|
1749
|
+
if (!token || seen.has(token)) continue;
|
|
1750
|
+
seen.add(token);
|
|
1751
|
+
const foregroundHex = resolveConcreteColorHex(token, palette);
|
|
1752
|
+
if (foregroundHex && contrastRatio(backgroundHex, foregroundHex) >= 4.5) return token;
|
|
1753
|
+
}
|
|
1754
|
+
return null;
|
|
1729
1755
|
}
|
|
1730
1756
|
/**
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1757
|
+
* A media treatment's ink as the resolved contract spells it. Nothing measures
|
|
1758
|
+
* the paint, so black or white (the photo tint's fallback) uses its fixed token
|
|
1759
|
+
* rather than borrowing a palette role with the same value today. Any other reference is a palette token.
|
|
1760
|
+
* Measured solids keep `firstSafeToken`, whose equivalent on-colour carries the
|
|
1761
|
+
* ground's own hover softening.
|
|
1734
1762
|
*/
|
|
1735
|
-
function
|
|
1736
|
-
|
|
1737
|
-
return {
|
|
1738
|
-
line: firstContrastBlend(ground, text, ground, 1.5),
|
|
1739
|
-
mark: firstContrastBlend(accent, ink, ground, 3)
|
|
1740
|
-
};
|
|
1763
|
+
function canonicalInk(reference, palette) {
|
|
1764
|
+
return absoluteInk(reference) ?? canonicalToken(reference, palette);
|
|
1741
1765
|
}
|
|
1742
|
-
function
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
return Array.from({ length: 101 }, (_, index) => {
|
|
1746
|
-
const amount = index / 100;
|
|
1747
|
-
return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
|
|
1748
|
-
}).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
|
|
1766
|
+
function absoluteInk(reference) {
|
|
1767
|
+
const normalized = normalizedReference(reference)?.toUpperCase();
|
|
1768
|
+
return parseThemeColorToken(normalized === "#000000" ? "absoluteBlack" : normalized === "#FFFFFF" ? "absoluteWhite" : null);
|
|
1749
1769
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
if (
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1770
|
+
function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
|
|
1771
|
+
const normalized = normalizedReference(reference);
|
|
1772
|
+
if (!normalized || normalized === "transparent") return null;
|
|
1773
|
+
const direct = parseThemeColorToken(normalized);
|
|
1774
|
+
if (direct && resolveConcreteColorHex(direct, palette)) return direct;
|
|
1775
|
+
const referenceHex = resolveConcreteColorHex(normalized, palette);
|
|
1776
|
+
if (!referenceHex) return null;
|
|
1777
|
+
const equivalent = [
|
|
1778
|
+
...preferredEquivalentTokens,
|
|
1779
|
+
...CANONICAL_EQUIVALENT_TOKEN_ORDER,
|
|
1780
|
+
...Object.keys(palette).sort()
|
|
1781
|
+
].find((token) => {
|
|
1782
|
+
const parsed = parseThemeColorToken(token);
|
|
1783
|
+
return parsed !== null && resolveConcreteColorHex(parsed, palette)?.toLowerCase() === referenceHex.toLowerCase();
|
|
1784
|
+
});
|
|
1785
|
+
return equivalent ? parseThemeColorToken(equivalent) : null;
|
|
1786
|
+
}
|
|
1787
|
+
function paletteToken(reference) {
|
|
1788
|
+
const parts = parseColorTokenParts(reference);
|
|
1789
|
+
return parts.kind === "token" && parts.opacityPercent === null ? parts.token : null;
|
|
1790
|
+
}
|
|
1791
|
+
function normalizedReference(value) {
|
|
1792
|
+
if (typeof value !== "string") return null;
|
|
1793
|
+
const normalized = value.trim();
|
|
1794
|
+
return normalized.length > 0 ? normalized : null;
|
|
1757
1795
|
}
|
|
1758
1796
|
//#endregion
|
|
1759
1797
|
//#region ../theme-core/src/utils/cssValueSafety.ts
|
|
@@ -2520,7 +2558,7 @@ function buttonSurfaceSeparation(fill, surface, edge) {
|
|
|
2520
2558
|
}
|
|
2521
2559
|
/** The worst ground for a fill: the first it fails to stand out from, otherwise the closest. */
|
|
2522
2560
|
function buttonGroundSeparation(fill, grounds, edge) {
|
|
2523
|
-
const ink = edge?.border?.marksBoundary ? edge.border.boundaryInk ? edge.
|
|
2561
|
+
const ink = edge?.border?.marksBoundary ? edge.border.boundaryInk ? resolveConcreteColorHex(edge.border.boundaryInk, edge.palette) ?? void 0 : edge.labelInk : void 0;
|
|
2524
2562
|
return grounds.map((ground) => {
|
|
2525
2563
|
const separation = buttonFillSeparation(fill, ground);
|
|
2526
2564
|
const distinct = separation.distinct || ink !== void 0 && contrastRatio(ink, ground) >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio;
|
|
@@ -2536,7 +2574,7 @@ function buttonGroundSeparation(fill, grounds, edge) {
|
|
|
2536
2574
|
}
|
|
2537
2575
|
function validateButtonFillSeparation(input) {
|
|
2538
2576
|
const token = input.border?.marksBoundary ? input.border.boundaryInk : void 0;
|
|
2539
|
-
if (token && !input.palette
|
|
2577
|
+
if (token && !resolveConcreteColorHex(token, input.palette)) return {
|
|
2540
2578
|
ok: false,
|
|
2541
2579
|
error: {
|
|
2542
2580
|
tag: "unknown_palette_token",
|
|
@@ -2964,16 +3002,16 @@ function standsApartFromSurface(hex, labelInk, input) {
|
|
|
2964
3002
|
}
|
|
2965
3003
|
/** 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. */
|
|
2966
3004
|
function preferredInkHolds(token, input) {
|
|
2967
|
-
const hex = input.palette
|
|
2968
|
-
const labelInk =
|
|
2969
|
-
if (hex ===
|
|
3005
|
+
const hex = resolveConcreteColorHex(token, input.palette);
|
|
3006
|
+
const labelInk = resolveConcreteColorHex(solidForegroundToken(token), input.palette) ?? void 0;
|
|
3007
|
+
if (hex === null || !labelReadable(hex, labelInk, input.colourIndex)) return false;
|
|
2970
3008
|
return input.surface === void 0 || standsApartFromSurface(hex, labelInk, input) && contrastRatio(hex, input.surface.backgroundHex, input.colourIndex) >= FILL_CLEARS_GROUND;
|
|
2971
3009
|
}
|
|
2972
3010
|
/** The other steps of the seed's scale (`primary-100` … `primary-950`), measured against the seed and the ground. */
|
|
2973
3011
|
function shadeCandidates(input) {
|
|
2974
3012
|
const { instruction, palette, colourIndex } = input;
|
|
2975
|
-
const seedHex =
|
|
2976
|
-
if (seedHex ===
|
|
3013
|
+
const seedHex = resolveConcreteColorHex(instruction.seedToken, palette);
|
|
3014
|
+
if (seedHex === null) return [];
|
|
2977
3015
|
const family = String(instruction.seedToken).match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? String(instruction.seedToken);
|
|
2978
3016
|
const step = new RegExp(`^${escapeRegExp(family)}-\\d{2,3}$`);
|
|
2979
3017
|
const ground = input.surface?.backgroundHex ?? palette.background;
|
|
@@ -3000,7 +3038,7 @@ function describeShade(token, hex, seed, input) {
|
|
|
3000
3038
|
token,
|
|
3001
3039
|
hex,
|
|
3002
3040
|
direction,
|
|
3003
|
-
labelInk:
|
|
3041
|
+
labelInk: resolveConcreteColorHex(solidForegroundToken(token), palette) ?? void 0,
|
|
3004
3042
|
distance: hexOklabDistance(seed.hex, hex),
|
|
3005
3043
|
stronger: seed.ground === void 0 ? direction === instruction.fallbackDirection : seed.ground.contrast(hex) >= seed.ground.restContrast,
|
|
3006
3044
|
keepsHue: keepsHue(oklab(hex), seed.chroma),
|
|
@@ -3279,8 +3317,8 @@ function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
|
|
|
3279
3317
|
/** A solid rest fill with the label ink resolveSolidInk gives it, so a contextual hover compares against the ink visitors see. */
|
|
3280
3318
|
function restingFill(input, treatment) {
|
|
3281
3319
|
if (treatment.type !== "solid") return { kind: "not-solid" };
|
|
3282
|
-
const hex = input.palette
|
|
3283
|
-
if (hex ===
|
|
3320
|
+
const hex = resolveConcreteColorHex(treatment.colorToken, input.palette);
|
|
3321
|
+
if (hex === null) return { kind: "not-solid" };
|
|
3284
3322
|
const ink = resolveSolidInk(input, treatment.colorToken, hex, treatment.foregroundToken);
|
|
3285
3323
|
return {
|
|
3286
3324
|
kind: "solid",
|
|
@@ -3297,7 +3335,7 @@ function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForegro
|
|
|
3297
3335
|
return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
|
|
3298
3336
|
}
|
|
3299
3337
|
function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
|
|
3300
|
-
const candidate = input.palette
|
|
3338
|
+
const candidate = resolveConcreteColorHex(foregroundToken, input.palette);
|
|
3301
3339
|
if ((typeof candidate === "string" ? validateButtonTextContrast({
|
|
3302
3340
|
...input,
|
|
3303
3341
|
background: backgroundToken,
|
|
@@ -3381,7 +3419,7 @@ function resolveGradient(input, treatment) {
|
|
|
3381
3419
|
};
|
|
3382
3420
|
}
|
|
3383
3421
|
function paletteHex(input, token) {
|
|
3384
|
-
const hex = input.palette
|
|
3422
|
+
const hex = resolveConcreteColorHex(token, input.palette);
|
|
3385
3423
|
return typeof hex === "string" ? {
|
|
3386
3424
|
ok: true,
|
|
3387
3425
|
hex
|
|
@@ -3769,8 +3807,7 @@ function resolveKnownColour(value, palette) {
|
|
|
3769
3807
|
const reference = parseThemeColorReference(value, { palette });
|
|
3770
3808
|
if (reference.kind !== "literal-css") {
|
|
3771
3809
|
const token = String(reference.token);
|
|
3772
|
-
const
|
|
3773
|
-
const hex = paletteHex ? normalizeOpaqueHex(paletteHex) : null;
|
|
3810
|
+
const hex = resolveConcreteColorHex(token, palette);
|
|
3774
3811
|
if (hex) return {
|
|
3775
3812
|
hex,
|
|
3776
3813
|
css: resolveThemeColorReferenceValue(value, { palette }),
|
|
@@ -3958,8 +3995,8 @@ const surfaceRecipes = {
|
|
|
3958
3995
|
}
|
|
3959
3996
|
};
|
|
3960
3997
|
const missingBackgroundTokens = {
|
|
3961
|
-
background: "
|
|
3962
|
-
foreground: "
|
|
3998
|
+
background: "absoluteWhite",
|
|
3999
|
+
foreground: "absoluteBlack"
|
|
3963
4000
|
};
|
|
3964
4001
|
function toAccessibleColorSurfaceIntent(surface) {
|
|
3965
4002
|
switch (surface) {
|
|
@@ -4178,8 +4215,7 @@ function expandForegroundCandidate(candidate, backgroundToken) {
|
|
|
4178
4215
|
}
|
|
4179
4216
|
}
|
|
4180
4217
|
function readPaletteHex(palette, token) {
|
|
4181
|
-
|
|
4182
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
4218
|
+
return resolveConcreteColorHex(token, palette);
|
|
4183
4219
|
}
|
|
4184
4220
|
function asAccessibleSurfaceToken(token) {
|
|
4185
4221
|
if (token.length === 0) throw new Error("AccessibleSurfaceToken must be non-empty.");
|
|
@@ -4189,11 +4225,11 @@ function surfaceResolutionFailureReason(rejectedCandidates) {
|
|
|
4189
4225
|
return rejectedCandidates.some((candidate) => candidate.kind === "foreground-candidate") ? "no-safe-foreground-candidate" : "no-background-candidate";
|
|
4190
4226
|
}
|
|
4191
4227
|
function missingBackgroundSurface(input) {
|
|
4192
|
-
const contrast = contrastRatio(missingBackgroundTokens.foreground, missingBackgroundTokens.background);
|
|
4228
|
+
const contrast = contrastRatio(absoluteInkColors[missingBackgroundTokens.foreground], absoluteInkColors[missingBackgroundTokens.background]);
|
|
4193
4229
|
const foreground = {
|
|
4194
4230
|
kind: "safe-token",
|
|
4195
4231
|
token: asAccessibleSurfaceToken(missingBackgroundTokens.foreground),
|
|
4196
|
-
hex: missingBackgroundTokens.foreground,
|
|
4232
|
+
hex: absoluteInkColors[missingBackgroundTokens.foreground],
|
|
4197
4233
|
contrastRatio: contrast
|
|
4198
4234
|
};
|
|
4199
4235
|
return {
|
|
@@ -4201,7 +4237,7 @@ function missingBackgroundSurface(input) {
|
|
|
4201
4237
|
surface: input.surface,
|
|
4202
4238
|
background: {
|
|
4203
4239
|
token: asAccessibleSurfaceToken(missingBackgroundTokens.background),
|
|
4204
|
-
hex: missingBackgroundTokens.background,
|
|
4240
|
+
hex: absoluteInkColors[missingBackgroundTokens.background],
|
|
4205
4241
|
inherited: false
|
|
4206
4242
|
},
|
|
4207
4243
|
heading: {
|
|
@@ -4304,6 +4340,7 @@ function prepareSurfaceIndex(specs, context) {
|
|
|
4304
4340
|
colourIndex: context.colourIndex,
|
|
4305
4341
|
linkHoverToken: context.linkHoverToken,
|
|
4306
4342
|
foreground: context.foreground,
|
|
4343
|
+
backdropSamples: context.backdropSamples,
|
|
4307
4344
|
compositeBase: context.compositeBase,
|
|
4308
4345
|
buttonContext: context.buttonContext,
|
|
4309
4346
|
solvedInks: context.solvedInks
|
|
@@ -4356,6 +4393,7 @@ function surfaceResolutionKey(spec, context) {
|
|
|
4356
4393
|
declaration,
|
|
4357
4394
|
context.linkHoverToken,
|
|
4358
4395
|
context.foreground,
|
|
4396
|
+
context.backdropSamples,
|
|
4359
4397
|
context.compositeBase,
|
|
4360
4398
|
context.buttonContext,
|
|
4361
4399
|
context.solvedInks
|
|
@@ -4512,7 +4550,7 @@ function withCertifiedButtons(decision, context) {
|
|
|
4512
4550
|
}
|
|
4513
4551
|
/** A radial tint's grounds besides its painted end, so its buttons are judged on every sample. */
|
|
4514
4552
|
function tintGroundSamples(decision, context) {
|
|
4515
|
-
if (decision.tintBase === void 0) return void 0;
|
|
4553
|
+
if (decision.tintBase === void 0 && !decision.backdropSamples) return void 0;
|
|
4516
4554
|
const [first, ...rest] = surfaceBackdrops(decision, context).slice(0, -1);
|
|
4517
4555
|
return first === void 0 ? void 0 : [first, ...rest];
|
|
4518
4556
|
}
|
|
@@ -4532,15 +4570,13 @@ function surfaceContrast(roles, backdrop, palette, colourIndex) {
|
|
|
4532
4570
|
}
|
|
4533
4571
|
/** Runtime backgrounds retain authored media, compositing and unknown foregrounds. */
|
|
4534
4572
|
function resolveSectionSurface(background, context) {
|
|
4535
|
-
const foreground =
|
|
4536
|
-
linkHover: context.linkHoverToken,
|
|
4537
|
-
...context.foreground
|
|
4538
|
-
}, { compositeBase: context.compositeBase });
|
|
4573
|
+
const foreground = sectionSurfaceForeground(background, context);
|
|
4539
4574
|
const surface = background === null ? { kind: "inherit" } : background.type === "color" ? {
|
|
4540
4575
|
kind: "solid",
|
|
4541
4576
|
color: background.color,
|
|
4542
4577
|
composited: false,
|
|
4543
|
-
foreground: foreground.kind === "known" ? foreground.roles.link : void 0
|
|
4578
|
+
foreground: foreground.kind === "known" ? foreground.roles.link : void 0,
|
|
4579
|
+
backgroundSamples: nonemptySamples(context.backdropSamples)
|
|
4544
4580
|
} : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" };
|
|
4545
4581
|
const revision = ownSurfaceRevision(context);
|
|
4546
4582
|
const buttonContext = resolveSurfaceButtonContext({
|
|
@@ -4577,7 +4613,14 @@ function surfaceDecorationColors(foreground, palette) {
|
|
|
4577
4613
|
if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return void 0;
|
|
4578
4614
|
const text = resolveConcreteColorHex(foreground.roles.text, palette);
|
|
4579
4615
|
if (text === null) return void 0;
|
|
4580
|
-
|
|
4616
|
+
const decorations = deriveSurfaceDecorationColors(foreground.provenance.backdropHex, text, palette.markSource ?? palette.accent ?? text);
|
|
4617
|
+
if (!foreground.provenance.backdropSamples) return decorations;
|
|
4618
|
+
const samples = foreground.provenance.backdropSamples;
|
|
4619
|
+
const line = deriveSurfaceLineColor(samples[samples.length - 1] ?? foreground.provenance.backdropHex, text, samples);
|
|
4620
|
+
return {
|
|
4621
|
+
...decorations,
|
|
4622
|
+
line
|
|
4623
|
+
};
|
|
4581
4624
|
}
|
|
4582
4625
|
/** Composite the declared palette tint before checking every foreground role. */
|
|
4583
4626
|
function resolveTintSurface(spec, context) {
|
|
@@ -4585,12 +4628,8 @@ function resolveTintSurface(spec, context) {
|
|
|
4585
4628
|
kind: "token",
|
|
4586
4629
|
token: spec.base
|
|
4587
4630
|
}, context);
|
|
4588
|
-
const
|
|
4589
|
-
|
|
4590
|
-
const hex = source ? resolveConcreteColorHex(source, context.palette) : null;
|
|
4591
|
-
const tinted = token ?? (hex ? resolveOpaqueSurfaceHex(hexToRgba(hex, spec.opacity / 100), context.palette, spec.base) : null);
|
|
4592
|
-
if (!tinted) throw new Error(`Cannot derive tint on ${spec.base}`);
|
|
4593
|
-
const solid = resolveDeclaredSolidSurface({
|
|
4631
|
+
const { hex, tinted } = tintColour(spec, tintSource(spec.source, base, context.palette), context);
|
|
4632
|
+
if (spec.gradient !== "radial" && !context.backdropSamples) return resolveDeclaredSolidSurface({
|
|
4594
4633
|
kind: "solid",
|
|
4595
4634
|
token: tinted
|
|
4596
4635
|
}, {
|
|
@@ -4598,11 +4637,64 @@ function resolveTintSurface(spec, context) {
|
|
|
4598
4637
|
buttonContext: surfaceButtonRequest(spec, context),
|
|
4599
4638
|
foreground: base.foreground
|
|
4600
4639
|
});
|
|
4601
|
-
|
|
4640
|
+
const solid = {
|
|
4641
|
+
kind: "owned",
|
|
4642
|
+
paint: {
|
|
4643
|
+
kind: "solid",
|
|
4644
|
+
token: tinted
|
|
4645
|
+
},
|
|
4646
|
+
foreground: base.foreground,
|
|
4647
|
+
decorations: tintDecorations(spec, base, tinted, context),
|
|
4648
|
+
inks: base.inks,
|
|
4649
|
+
hoverDecoration: base.hoverDecoration,
|
|
4650
|
+
contrast: surfaceContrast(base.foreground, tinted, context.palette, context.colourIndex),
|
|
4651
|
+
primaryButton: surfaceButtonRequest(spec, context)
|
|
4652
|
+
};
|
|
4653
|
+
const samples = context.backdropSamples ? tintSamples(spec, hex, tinted, context.backdropSamples) : void 0;
|
|
4654
|
+
const sampled = samples ? {
|
|
4602
4655
|
...solid,
|
|
4603
|
-
|
|
4604
|
-
tintBase: spec.base
|
|
4656
|
+
backdropSamples: samples
|
|
4605
4657
|
} : solid;
|
|
4658
|
+
return {
|
|
4659
|
+
kind: "tint",
|
|
4660
|
+
painted: spec.gradient === "radial" ? {
|
|
4661
|
+
...sampled,
|
|
4662
|
+
inks: { kind: "reset" },
|
|
4663
|
+
tintBase: spec.base
|
|
4664
|
+
} : sampled,
|
|
4665
|
+
original: base
|
|
4666
|
+
};
|
|
4667
|
+
}
|
|
4668
|
+
/**
|
|
4669
|
+
* Decoration colours (mark, line) are chosen against the paint they sit on. A radial glow fades from
|
|
4670
|
+
* the tint back to its base, so its decorations must clear both ends; a mark that does keeps the glow.
|
|
4671
|
+
*/
|
|
4672
|
+
function tintDecorations(spec, base, tinted, context) {
|
|
4673
|
+
const { palette } = context;
|
|
4674
|
+
const tintHex = resolveOpaqueSurfaceHex(tinted, palette, context.compositeBase);
|
|
4675
|
+
const baseHex = resolveOpaqueSurfaceHex(base.paint.token, palette, context.compositeBase);
|
|
4676
|
+
const text = resolveConcreteColorHex(base.foreground.text, palette);
|
|
4677
|
+
if (tintHex === null || baseHex === null || text === null || !base.decorations) return base.decorations;
|
|
4678
|
+
const backdrops = spec.gradient === "radial" ? [tintHex, baseHex] : [tintHex];
|
|
4679
|
+
return deriveSurfaceDecorationColors(tintHex, text, palette.markSource ?? palette.accent ?? text, backdrops);
|
|
4680
|
+
}
|
|
4681
|
+
/** The tint's opaque paint, and its source as a concrete hex when it has one. */
|
|
4682
|
+
function tintColour(spec, source, context) {
|
|
4683
|
+
const token = source ? resolveOpaqueSurfaceHex(`${source}/${spec.opacity}`, context.palette, spec.base) : null;
|
|
4684
|
+
const hex = source ? resolveConcreteColorHex(source, context.palette) : null;
|
|
4685
|
+
const tinted = token ?? (hex ? resolveOpaqueSurfaceHex(hexToRgba(hex, spec.opacity / 100), context.palette, spec.base) : null);
|
|
4686
|
+
if (!tinted) throw new Error(`Cannot derive tint on ${spec.base}`);
|
|
4687
|
+
return {
|
|
4688
|
+
hex,
|
|
4689
|
+
tinted
|
|
4690
|
+
};
|
|
4691
|
+
}
|
|
4692
|
+
/** Every colour a tint shows over each backdrop: its end, or each step of a radial. */
|
|
4693
|
+
function tintSamples(spec, hex, tinted, backdrops) {
|
|
4694
|
+
return backdrops.flatMap((backdrop) => {
|
|
4695
|
+
const end = hex ? compositeHex(hex, spec.opacity / 100, backdrop) : tinted;
|
|
4696
|
+
return spec.gradient === "radial" ? TINT_SAMPLE_ALPHAS.map((alpha) => compositeHex(end, alpha, backdrop)) : [end];
|
|
4697
|
+
});
|
|
4606
4698
|
}
|
|
4607
4699
|
/**
|
|
4608
4700
|
* The button colour a surface asks for, which it also hands to what is painted on it. An explicit request
|
|
@@ -4625,7 +4717,7 @@ function tintSource(source, base, palette) {
|
|
|
4625
4717
|
case "mark": return base.decorations?.mark;
|
|
4626
4718
|
case "shade": {
|
|
4627
4719
|
const background = resolveOpaqueSurfaceHex("background", palette, "background");
|
|
4628
|
-
return background && featuresFromHex(background).Y < .5 ? "
|
|
4720
|
+
return background && featuresFromHex(background).Y < .5 ? "absoluteWhite" : "absoluteBlack";
|
|
4629
4721
|
}
|
|
4630
4722
|
}
|
|
4631
4723
|
}
|
|
@@ -4693,6 +4785,7 @@ const surfaceTransportSchema = z.object({ $surface: z.object({
|
|
|
4693
4785
|
buttonSystem: buttonSystemSchema.optional(),
|
|
4694
4786
|
foreground: foregroundInputSchema.optional(),
|
|
4695
4787
|
linkHoverToken: z.string().optional(),
|
|
4788
|
+
backdropSamples: z.array(z.string()).optional(),
|
|
4696
4789
|
compositeBase: z.string().optional(),
|
|
4697
4790
|
buttonContext: buttonInputSchema.optional(),
|
|
4698
4791
|
solvedInks: solvedInksSchema.optional()
|
|
@@ -4727,6 +4820,7 @@ function certifySurface(spec, context) {
|
|
|
4727
4820
|
...ownedThemeSnapshot({
|
|
4728
4821
|
foreground: context.foreground,
|
|
4729
4822
|
linkHoverToken: context.linkHoverToken,
|
|
4823
|
+
backdropSamples: context.backdropSamples,
|
|
4730
4824
|
compositeBase: context.compositeBase,
|
|
4731
4825
|
buttonContext: context.buttonContext,
|
|
4732
4826
|
solvedInks: context.solvedInks
|
|
@@ -4763,59 +4857,97 @@ const TINT_SAMPLE_ALPHAS = [
|
|
|
4763
4857
|
];
|
|
4764
4858
|
/**
|
|
4765
4859
|
* The certificate asserts every threshold it measures, on every backdrop the
|
|
4766
|
-
* paint shows
|
|
4767
|
-
*
|
|
4768
|
-
*
|
|
4769
|
-
* certified inks, so they never keep a link ink the certificate replaced, and
|
|
4860
|
+
* paint shows. A sampled tint keeps its original declared inks and mark or
|
|
4861
|
+
* returns to its original ground. Solid paints retain black/white fallback.
|
|
4862
|
+
* Buttons are derived from the certified inks, so they never keep a link ink the certificate replaced, and
|
|
4770
4863
|
* the button resolver judges them on every sample of a radial tint.
|
|
4771
4864
|
*/
|
|
4772
4865
|
function certifyThresholds(decision, context) {
|
|
4866
|
+
if (decision.kind === "tint") return certifyTintPaint(decision, context);
|
|
4773
4867
|
if (!isSolidInkDecision(decision)) return decision;
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4868
|
+
return withCertifiedButtons(withFallbackInks(decision, context) ?? decision, context);
|
|
4869
|
+
}
|
|
4870
|
+
/** One drop-or-keep decision, before any declared ink or mark can be replaced. */
|
|
4871
|
+
function certifyTintPaint(decision, context) {
|
|
4872
|
+
const certified = withFallbackInks(decision.painted, context);
|
|
4873
|
+
if (certified) return withCertifiedButtons(certified, context);
|
|
4874
|
+
const original = decision.original;
|
|
4875
|
+
return {
|
|
4876
|
+
...original,
|
|
4780
4877
|
contrast: {
|
|
4781
|
-
...
|
|
4782
|
-
fallback: ["radial-tint", ...
|
|
4878
|
+
...original.contrast,
|
|
4879
|
+
fallback: ["radial-tint", ...original.contrast.fallback ?? []]
|
|
4783
4880
|
}
|
|
4784
|
-
}
|
|
4881
|
+
};
|
|
4785
4882
|
}
|
|
4786
4883
|
/** Every backdrop a solid paint shows: its colour, or each sample from a radial tint's base to its paint. */
|
|
4787
4884
|
function surfaceBackdrops(decision, context) {
|
|
4885
|
+
if (decision.backdropSamples) return decision.backdropSamples;
|
|
4788
4886
|
const paint = resolveOpaqueSurfaceHex(decision.paint.token, context.palette, decision.tintBase ?? context.compositeBase);
|
|
4789
4887
|
if (!paint) return [];
|
|
4790
4888
|
const underlay = decision.tintBase ? resolveOpaqueSurfaceHex(decision.tintBase, context.palette, "background") : null;
|
|
4791
4889
|
return underlay ? TINT_SAMPLE_ALPHAS.map((alpha) => compositeHex(paint, alpha, underlay)) : [paint];
|
|
4792
4890
|
}
|
|
4793
|
-
/**
|
|
4891
|
+
/** A sampled finish may re-solve derived inks, but never replace a declared role or mark. */
|
|
4794
4892
|
function withFallbackInks(decision, context) {
|
|
4795
4893
|
const backdrops = surfaceBackdrops(decision, context);
|
|
4796
|
-
|
|
4797
|
-
|
|
4894
|
+
if (backdrops.length === 0) return decision;
|
|
4895
|
+
const derived = sampledPaint(decision) ? sampledPaintDetails(decision, backdrops, context) : decision;
|
|
4798
4896
|
const certified = certifySurfaceInks({
|
|
4799
|
-
foreground:
|
|
4800
|
-
mark:
|
|
4897
|
+
foreground: derived.foreground,
|
|
4898
|
+
mark: derived.decorations?.mark
|
|
4801
4899
|
}, backdrops, context);
|
|
4802
|
-
if (!certified) return null;
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4900
|
+
if (!certified || sampledPaint(decision) && requiresDeclaredInkFallback(certified)) return null;
|
|
4901
|
+
return applyPaintInkCertificate(derived, certified, backdrops, context);
|
|
4902
|
+
}
|
|
4903
|
+
function sampledPaint(decision) {
|
|
4904
|
+
return decision.tintBase !== void 0 || decision.backdropSamples !== void 0;
|
|
4905
|
+
}
|
|
4906
|
+
/** Muted and hover are derived; text, heading, link, supporting and mark decide drop-or-keep. */
|
|
4907
|
+
function requiresDeclaredInkFallback(certificate) {
|
|
4908
|
+
return certificate.fallback.some((role) => role !== "muted" && role !== "linkHover");
|
|
4909
|
+
}
|
|
4910
|
+
/** Keep the certificate and derived local inks on the exact samples the paint draws. */
|
|
4911
|
+
function applyPaintInkCertificate(decision, certified, backdrops, context) {
|
|
4912
|
+
const samples = nonemptySamples(backdrops);
|
|
4913
|
+
if (!samples || !sampledPaint(decision) && certified.fallback.length === 0) return decision;
|
|
4914
|
+
const endpoint = samples[samples.length - 1] ?? samples[0];
|
|
4915
|
+
const decorations = decision.decorations;
|
|
4916
|
+
const inks = decision.inks.kind === "solved" ? {
|
|
4917
|
+
kind: "solved",
|
|
4918
|
+
inks: solveSurfaceInks(samples, certified.foreground.text, context.palette)
|
|
4919
|
+
} : decision.inks;
|
|
4809
4920
|
return {
|
|
4810
4921
|
...decision,
|
|
4922
|
+
inks,
|
|
4811
4923
|
foreground: certified.foreground,
|
|
4812
4924
|
decorations,
|
|
4813
4925
|
contrast: {
|
|
4814
|
-
...
|
|
4926
|
+
...surfaceContrast(certified.foreground, endpoint, context.palette, context.colourIndex),
|
|
4815
4927
|
fallback: certified.fallback
|
|
4816
4928
|
}
|
|
4817
4929
|
};
|
|
4818
4930
|
}
|
|
4931
|
+
function sampledPaintDetails(decision, samples, context) {
|
|
4932
|
+
const ground = resolveOpaqueSurfaceHex(decision.paint.token, context.palette, decision.tintBase ?? context.compositeBase);
|
|
4933
|
+
const derived = deriveSurfaceForegroundDetails(decision.foreground, {
|
|
4934
|
+
palette: context.palette,
|
|
4935
|
+
ground: ground ?? void 0,
|
|
4936
|
+
backdrops: samples,
|
|
4937
|
+
hoverCandidate: context.foreground?.linkHover ?? context.linkHoverToken ?? decision.foreground.linkHover
|
|
4938
|
+
});
|
|
4939
|
+
const text = resolveConcreteColorHex(decision.foreground.text, context.palette);
|
|
4940
|
+
const decorations = decision.decorations && ground && text ? {
|
|
4941
|
+
...decision.decorations,
|
|
4942
|
+
line: deriveSurfaceLineColor(ground, text, samples)
|
|
4943
|
+
} : decision.decorations;
|
|
4944
|
+
return {
|
|
4945
|
+
...decision,
|
|
4946
|
+
foreground: derived.roles,
|
|
4947
|
+
hoverDecoration: derived.hoverDecoration,
|
|
4948
|
+
decorations
|
|
4949
|
+
};
|
|
4950
|
+
}
|
|
4819
4951
|
function surfaceProof(decision, spec) {
|
|
4820
4952
|
if (decision.kind === "inherit") return {
|
|
4821
4953
|
...decision,
|
|
@@ -4903,6 +5035,7 @@ const surfaceReferenceSchema = z.object({ $surface: z.object({
|
|
|
4903
5035
|
context: z.object({
|
|
4904
5036
|
foreground: foregroundInputSchema.optional(),
|
|
4905
5037
|
linkHoverToken: z.string().optional(),
|
|
5038
|
+
backdropSamples: z.array(z.string()).optional(),
|
|
4906
5039
|
compositeBase: z.string().optional(),
|
|
4907
5040
|
buttonContext: buttonInputSchema.optional(),
|
|
4908
5041
|
solvedInks: solvedInksSchema.optional()
|
|
@@ -4962,5 +5095,60 @@ function mapSurfaceTreeChildren(value, map) {
|
|
|
4962
5095
|
if (value instanceof Date) return value;
|
|
4963
5096
|
return isSurfaceTreeRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(item)])) : value;
|
|
4964
5097
|
}
|
|
5098
|
+
/** Section grounds and slot tints share the same all-samples ink certificate. */
|
|
5099
|
+
function certifyFinishedGround(finish, foreground, context) {
|
|
5100
|
+
const certified = certifySampledForeground(foreground, finish.samples, context);
|
|
5101
|
+
return certified ? {
|
|
5102
|
+
kind: "certified",
|
|
5103
|
+
finish,
|
|
5104
|
+
foreground: certified
|
|
5105
|
+
} : {
|
|
5106
|
+
kind: "dropped",
|
|
5107
|
+
reason: "unreadable-finish"
|
|
5108
|
+
};
|
|
5109
|
+
}
|
|
5110
|
+
function nonemptySamples(samples) {
|
|
5111
|
+
const [first, ...rest] = samples ?? [];
|
|
5112
|
+
return first === void 0 ? void 0 : [first, ...rest];
|
|
5113
|
+
}
|
|
5114
|
+
/** Certify section inks against the finish rather than just its base colour. */
|
|
5115
|
+
function sectionSurfaceForeground(background, context) {
|
|
5116
|
+
if (background === null) return { kind: "inherits" };
|
|
5117
|
+
const foreground = resolveSurfaceForeground(background, context.palette, {
|
|
5118
|
+
linkHover: context.linkHoverToken,
|
|
5119
|
+
...context.foreground
|
|
5120
|
+
}, { compositeBase: context.compositeBase });
|
|
5121
|
+
if (foreground.kind !== "known" || !context.backdropSamples) return foreground;
|
|
5122
|
+
return certifySampledForeground(foreground, context.backdropSamples, context) ?? foreground;
|
|
5123
|
+
}
|
|
5124
|
+
/** Foreground roles and published local inks must agree on the full sampled backing. */
|
|
5125
|
+
function certifySampledForeground(foreground, backdrops, context) {
|
|
5126
|
+
if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return null;
|
|
5127
|
+
const samples = nonemptySamples(backdrops);
|
|
5128
|
+
if (!samples) return null;
|
|
5129
|
+
const decorations = surfaceDecorationColors(foreground, context.palette);
|
|
5130
|
+
const derived = deriveSurfaceForegroundDetails(foreground.roles, {
|
|
5131
|
+
palette: context.palette,
|
|
5132
|
+
ground: samples[samples.length - 1],
|
|
5133
|
+
backdrops: samples,
|
|
5134
|
+
hoverCandidate: foreground.roles.linkHover
|
|
5135
|
+
});
|
|
5136
|
+
const certified = certifySurfaceInks({
|
|
5137
|
+
foreground: derived.roles,
|
|
5138
|
+
mark: decorations?.mark
|
|
5139
|
+
}, samples, context);
|
|
5140
|
+
if (!certified || requiresDeclaredInkFallback(certified)) return null;
|
|
5141
|
+
return {
|
|
5142
|
+
...foreground,
|
|
5143
|
+
hoverDecoration: derived.hoverDecoration,
|
|
5144
|
+
roles: certified.foreground,
|
|
5145
|
+
provenance: {
|
|
5146
|
+
...foreground.provenance,
|
|
5147
|
+
backdropSamples: samples,
|
|
5148
|
+
inks: solveSurfaceInks(samples, certified.foreground.text, context.palette),
|
|
5149
|
+
fallback: certified.fallback
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
}
|
|
4965
5153
|
//#endregion
|
|
4966
|
-
export {
|
|
5154
|
+
export { expandPalette as $, PUBLIC_BUTTON_ROLES as A, paletteValueKey as At, cssVarValue as B, featuresFromHex as Bt, materializeRuntimeButtonAppearance as C, resolveOpaqueSurfaceHex as Ct, ELEVATION_OFFSET as D, paletteInkToken as Dt, DEFAULT_BUTTON_SIZES as E, paletteInkRoles as Et, resolveOnColorForThemeToken as F, hexLuminance as Ft, callsCssLoadingFunction as G, oklchToHexGamut as Gt, rgbColorValue as H, linearToSrgb as Ht, resolveThemeColorReferenceValue as I, luminanceInterval as It, safeTokenOr as J, staysInsideDeclaration as K, rgbToHex as Kt, resolveTokenOrCssColorValue as L, preparePaletteColourIndex as Lt, mapButtonRoleAppearances as M, requirePaletteColorsFromEntries as Mt, mapButtonVisualAppearances as N, ORDINARY_TEXT_MIN_CONTRAST_RATIO as Nt, FONT_SIZE_MAP as O, _classPrivateFieldGet2 as Ot, isCssColorLiteral as P, contrastRatio as Pt, SURFACE_SECONDARY_TEXT_TINT_ALPHA as Q, backgroundColorStyle as R, solidPaint as Rt, buttonTypographyDeclarations as S, resolveConcreteColorHex as St, BORDER_WIDTH_MAP as T, paletteInk as Tt, textColorStyle as U, oklabToOklch as Ut, mergeStyles as V, hexToRgb as Vt, textColorValue as W, oklabToSrgb as Wt, CONTROL_EDGE_SEED_TOKEN as X, surfaceInkPublication as Y, solveSurfaceInks as Z, formatButtonColourContractError as _, surfaceInkDeclarations as _t, prepareThemeSurfaceRevision as a, planForegroundHover as at, buttonStateAppearanceDeclarations as b, freezeOwnedThemeValue as bt, serializeSurfaceTree as c, contrastThresholdByPolicy as ct, surfaceTransportContext as d, SURFACE_INK_CSS_VARS as dt, pickBlackOrWhiteTextColor as et, toAccessibleColorSurfaceIntent as f, surfaceForegroundDeclarations as ft, BUTTON_CONTRAST_POLICY as g, surfaceForegroundValueWithOpacity as gt, resolveSolidButtonColour as h, surfaceForegroundValue as ht, prepareSurfaceIndex as i, scrimTone as it, defineButtonStyleRecipe as j, paletteValueKeySchema as jt, generateShadowValue as k, _classPrivateFieldSet2 as kt, surfaceButtonRequest as l, DEFAULT_SURFACE_TEXT_COLOR as lt, compileButtonColourStates as m, surfaceForegroundStyle as mt, parseResolvedSurface as n, gradientScrimSamples as nt, requireResolvedSurface as o, HOVER_TEXT_THRESHOLD as ot, contextualButtonSurfaceResetStyles as p, surfaceForegroundInputFromResolved as pt, resolveSurfaceForeground as q, srgbToOklab as qt, parseSurfaceTree as r, minimumScrimOpacity as rt, resolveSurface as s, certifyPaint as st, certifyFinishedGround as t, compositeHex as tt, surfaceDecorationColors as u, SURFACE_FOREGROUND_CSS_VARS as ut, buttonBorder as v, surfaceInkStyle as vt, paddingDeclarations as w, neutralInk as wt, buttonStateShadow as x, ownedThemeSnapshot as xt, buttonRadius as y, surfaceInkValue as yt, borderColorStyle as z, _classPrivateFieldInitSpec as zt };
|