tempest-react-sdk 0.73.0 → 0.75.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 +6 -4
- package/dist/br/BrazilMap.module.cjs.map +1 -1
- package/dist/br/BrazilMap.module.js.map +1 -1
- package/dist/br/MapMarkers.cjs +1 -1
- package/dist/br/MapMarkers.cjs.map +1 -1
- package/dist/br/MapMarkers.js +19 -22
- package/dist/br/MapMarkers.js.map +1 -1
- package/dist/br/MunicipalitySearch.cjs +1 -1
- package/dist/br/MunicipalitySearch.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.js +66 -48
- package/dist/br/MunicipalitySearch.js.map +1 -1
- package/dist/br/MunicipalitySearch.module.cjs +1 -1
- package/dist/br/MunicipalitySearch.module.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.module.js +4 -3
- package/dist/br/MunicipalitySearch.module.js.map +1 -1
- package/dist/br.d.ts +12 -0
- package/dist/components/AIChat/AIChat.module.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.module.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js +1 -0
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppBar/AppBar.module.cjs +1 -1
- package/dist/components/AppBar/AppBar.module.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.module.js +12 -11
- package/dist/components/AppBar/AppBar.module.js.map +1 -1
- package/dist/components/AppShell/AppShell.module.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.module.js.map +1 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js +41 -36
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.module.cjs.map +1 -1
- package/dist/components/Button/Button.module.js.map +1 -1
- package/dist/components/Button/ButtonContent.cjs +2 -0
- package/dist/components/Button/ButtonContent.cjs.map +1 -0
- package/dist/components/Button/ButtonContent.js +34 -0
- package/dist/components/Button/ButtonContent.js.map +1 -0
- package/dist/components/Button/ButtonSlot.cjs +2 -0
- package/dist/components/Button/ButtonSlot.cjs.map +1 -0
- package/dist/components/Button/ButtonSlot.js +36 -0
- package/dist/components/Button/ButtonSlot.js.map +1 -0
- package/dist/components/Button/button-class.cjs +2 -0
- package/dist/components/Button/button-class.cjs.map +1 -0
- package/dist/components/Button/button-class.js +13 -0
- package/dist/components/Button/button-class.js.map +1 -0
- package/dist/components/Button/link-rel.cjs +2 -0
- package/dist/components/Button/link-rel.cjs.map +1 -0
- package/dist/components/Button/link-rel.js +11 -0
- package/dist/components/Button/link-rel.js.map +1 -0
- package/dist/components/Button/slot.cjs +2 -0
- package/dist/components/Button/slot.cjs.map +1 -0
- package/dist/components/Button/slot.js +41 -0
- package/dist/components/Button/slot.js.map +1 -0
- package/dist/components/Carousel/Carousel.module.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.module.js.map +1 -1
- package/dist/components/Chat/Chat.module.cjs.map +1 -1
- package/dist/components/Chat/Chat.module.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.cjs +1 -1
- package/dist/components/Collapsible/Collapsible.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.js +1 -1
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js +18 -23
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Combobox/use-listbox-dismiss.cjs +2 -0
- package/dist/components/Combobox/use-listbox-dismiss.cjs.map +1 -0
- package/dist/components/Combobox/use-listbox-dismiss.js +34 -0
- package/dist/components/Combobox/use-listbox-dismiss.js.map +1 -0
- package/dist/components/Dropzone/Dropzone.module.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.module.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.module.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.module.js.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.module.cjs.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.module.js.map +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.module.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.module.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/ListTile/ListTile.module.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.module.js.map +1 -1
- package/dist/components/Markdown/Markdown.module.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.module.js.map +1 -1
- package/dist/components/Menubar/Menubar.module.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.module.js.map +1 -1
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/Modal.module.cjs +1 -1
- package/dist/components/Modal/Modal.module.cjs.map +1 -1
- package/dist/components/Modal/Modal.module.js +1 -1
- package/dist/components/Modal/Modal.module.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +55 -54
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/Navbar/Navbar.cjs +1 -1
- package/dist/components/Navbar/Navbar.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.js +1 -0
- package/dist/components/Navbar/Navbar.js.map +1 -1
- package/dist/components/Navbar/Navbar.module.cjs +1 -1
- package/dist/components/Navbar/Navbar.module.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.module.js +9 -8
- package/dist/components/Navbar/Navbar.module.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.module.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.module.js.map +1 -1
- package/dist/components/Page/Page.cjs +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js +23 -39
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Page/Page.module.cjs +1 -1
- package/dist/components/Page/Page.module.cjs.map +1 -1
- package/dist/components/Page/Page.module.js +5 -11
- package/dist/components/Page/Page.module.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.module.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.module.js.map +1 -1
- package/dist/components/PinInput/PinInput.module.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.module.js.map +1 -1
- package/dist/components/Reveal/Reveal.cjs +2 -0
- package/dist/components/Reveal/Reveal.cjs.map +1 -0
- package/dist/components/Reveal/Reveal.js +56 -0
- package/dist/components/Reveal/Reveal.js.map +1 -0
- package/dist/components/Reveal/Reveal.module.cjs +3 -0
- package/dist/components/Reveal/Reveal.module.cjs.map +1 -0
- package/dist/components/Reveal/Reveal.module.js +7 -0
- package/dist/components/Reveal/Reveal.module.js.map +1 -0
- package/dist/components/Reveal/reveal-threshold.cjs +2 -0
- package/dist/components/Reveal/reveal-threshold.cjs.map +1 -0
- package/dist/components/Reveal/reveal-threshold.js +13 -0
- package/dist/components/Reveal/reveal-threshold.js.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.cjs +2 -0
- package/dist/components/SectionHeader/SectionHeader.cjs.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.js +66 -0
- package/dist/components/SectionHeader/SectionHeader.js.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.module.cjs +3 -0
- package/dist/components/SectionHeader/SectionHeader.module.cjs.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.module.js +15 -0
- package/dist/components/SectionHeader/SectionHeader.module.js.map +1 -0
- package/dist/components/Timeline/Timeline.cjs +1 -1
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.js +22 -15
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Timeline/Timeline.module.cjs +1 -1
- package/dist/components/Timeline/Timeline.module.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.module.js +1 -1
- package/dist/components/Timeline/Timeline.module.js.map +1 -1
- package/dist/components/Tour/Tour.module.cjs.map +1 -1
- package/dist/components/Tour/Tour.module.js.map +1 -1
- package/dist/components/Transfer/Transfer.module.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.module.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.module.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.module.js.map +1 -1
- package/dist/geo/TrajectoryMap.module.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.module.js.map +1 -1
- package/dist/icons/IconPicker.module.cjs.map +1 -1
- package/dist/icons/IconPicker.module.js.map +1 -1
- package/dist/styles/Reveal.css +2 -0
- package/dist/styles/SectionHeader.css +2 -0
- package/dist/styles/actions.css +26 -24
- package/dist/styles/base.css +3 -1
- package/dist/styles/br.css +3 -3
- package/dist/styles/chat.css +5 -5
- package/dist/styles/component/AIChat.css +3 -3
- package/dist/styles/component/AppBar.css +1 -0
- package/dist/styles/component/AppShell.css +1 -1
- package/dist/styles/component/BrazilMap.css +2 -2
- package/dist/styles/component/Button.css +25 -23
- package/dist/styles/component/Carousel.css +3 -3
- package/dist/styles/component/Chat.css +2 -2
- package/dist/styles/component/Dropzone.css +2 -1
- package/dist/styles/component/FilterBar.css +2 -2
- package/dist/styles/component/FloatingActionButton.css +1 -1
- package/dist/styles/component/IconPicker.css +1 -1
- package/dist/styles/component/ImageCropper.css +2 -2
- package/dist/styles/component/ListTile.css +1 -1
- package/dist/styles/component/Markdown.css +1 -1
- package/dist/styles/component/Menubar.css +1 -1
- package/dist/styles/component/Modal.css +2 -2
- package/dist/styles/component/MunicipalitySearch.css +1 -1
- package/dist/styles/component/Navbar.css +1 -0
- package/dist/styles/component/NavigationMenu.css +1 -1
- package/dist/styles/component/NavigationRail.css +1 -1
- package/dist/styles/component/NotificationCenter.css +3 -3
- package/dist/styles/component/Page.css +0 -6
- package/dist/styles/component/PasswordInput.css +1 -1
- package/dist/styles/component/PinInput.css +1 -1
- package/dist/styles/component/Reveal.css +9 -0
- package/dist/styles/component/SectionHeader.css +9 -0
- package/dist/styles/component/Timeline.css +5 -5
- package/dist/styles/component/Tour.css +2 -2
- package/dist/styles/component/TrajectoryMap.css +1 -1
- package/dist/styles/component/Transfer.css +2 -2
- package/dist/styles/component/VirtualTable.css +2 -2
- package/dist/styles/core.css +3 -1
- package/dist/styles/data.css +15 -15
- package/dist/styles/feedback.css +3 -3
- package/dist/styles/forms.css +6 -5
- package/dist/styles/geo.css +1 -1
- package/dist/styles/icons.css +1 -1
- package/dist/styles/inverse.css +372 -0
- package/dist/styles/layout.css +9 -7
- package/dist/styles/manifest.json +14 -1
- package/dist/styles/navigation.css +8 -6
- package/dist/styles/overlay.css +2 -2
- package/dist/styles/utility.css +8 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +473 -11
- package/dist/tempest-react-sdk.js +350 -346
- package/dist/theme/create-theme.cjs +3 -3
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js +72 -55
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/inverse-render.cjs +3 -0
- package/dist/theme/inverse-render.cjs.map +1 -0
- package/dist/theme/inverse-render.js +10 -0
- package/dist/theme/inverse-render.js.map +1 -0
- package/dist/theme/inverse-restore.cjs +5 -0
- package/dist/theme/inverse-restore.cjs.map +1 -0
- package/dist/theme/inverse-restore.js +30 -0
- package/dist/theme/inverse-restore.js.map +1 -0
- package/dist/theme/inverse-surface.cjs +2 -0
- package/dist/theme/inverse-surface.cjs.map +1 -0
- package/dist/theme/inverse-surface.js +255 -0
- package/dist/theme/inverse-surface.js.map +1 -0
- package/dist/theme/status-tokens.cjs +2 -0
- package/dist/theme/status-tokens.cjs.map +1 -0
- package/dist/theme/status-tokens.js +15 -0
- package/dist/theme/status-tokens.js.map +1 -0
- package/dist/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +6 -4
- package/dist/vite/create-vite-config.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var e=`[data-tempest-tone="default"]`,t=`[data-tempest-theme="dark"]`,n={selector:`:root`,darkSelector:t};function r(e){return e.replace(`--tempest-`,`--tempest-default-`)}function i(n,i,a){let o=[...new Set([`:root`,`[data-tempest-theme]`,a.selector,a.darkSelector])].filter(e=>e!==t).join(`, `),s=(e,t)=>`${e} {\n${t.map(([e,t])=>` ${e}: ${t};`).join(`
|
|
2
|
+
`)}\n}`;return[s(`:where(:is(${o}):not(${i}))`,n.map(e=>[r(e),`var(${e})`])),s(`:where(${e}:not(${o}))`,n.map(e=>[e,`var(${r(e)})`])),s(`:where(${e})`,[[`color-scheme`,`light`],[`background-color`,`var(--tempest-bg)`],[`color`,`var(--tempest-text)`]]),s(`:where(:is(${a.darkSelector}) ${e})`,[[`color-scheme`,`dark`]])].join(`
|
|
3
|
+
|
|
4
|
+
`)}exports.DEFAULT_PAGE_SELECTORS=n,exports.DEFAULT_TONE_SELECTOR=e,exports.defaultToneRules=i;
|
|
5
|
+
//# sourceMappingURL=inverse-restore.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-restore.cjs","names":[],"sources":["../../src/theme/inverse-restore.ts"],"sourcesContent":["/**\n * The default tone: a region inside an inverse surface that goes back to the\n * page's tokens — `data-tempest-tone=\"default\"`, or `<Section tone=\"default\">`.\n * A white form or price `Card` in a navy hero.\n *\n * Lives beside the generator, not in `inverse-render.ts`, so only an app that\n * imports `createInverseSurface` ships it: `createTheme` alone stays the size it\n * was.\n */\nimport type { PageSelectors } from \"./inverse-render\";\n\n/** Selector that hands a region inside an inverse surface back to the page's tokens. */\nexport const DEFAULT_TONE_SELECTOR = '[data-tempest-tone=\"default\"]';\n\n/** `createTheme`'s default `darkSelector`, already covered by `[data-tempest-theme]`. */\nconst DARK_SELECTOR = '[data-tempest-theme=\"dark\"]';\n\n/** Where `createTheme` writes the page's schemes when told nothing else. */\nexport const DEFAULT_PAGE_SELECTORS: PageSelectors = {\n selector: \":root\",\n darkSelector: DARK_SELECTOR,\n};\n\n/**\n * Name of the custom property that keeps the page's value of `token`.\n *\n * @param token - A `--tempest-*` token.\n * @returns The `--tempest-default-*` twin it is saved under.\n */\nfunction twinOf(token: string): string {\n return token.replace(\"--tempest-\", \"--tempest-default-\");\n}\n\n/**\n * The rules that let a region inside an inverse surface go back to the page's\n * tokens, light or dark — whichever the page is on.\n *\n * Custom properties inherit from the parent, so a rule cannot \"skip\" the\n * inverse section and read `:root` again — and scoping the inverse block away\n * from the region (`@scope (…) to (…)`, `:not()`) changes nothing either, since\n * the region still inherits what its inverse parent declared. Measured in\n * Chromium on a `Card`, an `Input` and a `Button` inside the region, 25 of 28\n * computed values differed from the same trio on the page in light and 18 of 28\n * in dark, with or without `@scope`.\n *\n * What works is saving the page's values before the section overrides them.\n * Every element a theme is declared on (`:root`, `[data-tempest-theme]`, and the\n * theme's own selectors) copies each token the surface redefines into a\n * `--tempest-default-*` twin. `var()` in a custom property resolves on the\n * element that declares it, so the twin holds the page's value — the SDK's, a\n * theme's or the app's own `:root` override — and inherits through the section\n * untouched. The region reads its tokens back from the twins: 0 of 28 values\n * differ, in light, in dark and under a dark subtree.\n *\n * Two alternatives were measured and rejected. Writing the page's values out,\n * one block per scheme, is 1257 B brotli and restores the SDK's defaults rather\n * than the page: with a brand override on `:root`, 3 of 28 values came back\n * wrong. Adding the region to the selectors of `colors.css` costs 15 B brotli,\n * but charges every app and misses the same override.\n *\n * Everything sits under `:where()`, so a class the app puts on the same element\n * still wins. The anchors are left out of the region and the section out of the\n * anchors: a token and its twin declared on one element reference each other,\n * and both resolve to nothing.\n *\n * @param tokens - The tokens the surface redefines.\n * @param selector - Selector the inverse surface is written under.\n * @param page - Selectors the page's schemes are written under.\n * @returns The CSS text of the rules, in the order they must be written.\n */\nexport function defaultToneRules(\n tokens: readonly string[],\n selector: string,\n page: PageSelectors,\n): string {\n const anchors = [\n ...new Set([\":root\", \"[data-tempest-theme]\", page.selector, page.darkSelector]),\n ]\n .filter((anchor) => anchor !== DARK_SELECTOR)\n .join(\", \");\n const block = (rule: string, declarations: readonly (readonly [string, string])[]): string =>\n `${rule} {\\n${declarations.map(([name, value]) => ` ${name}: ${value};`).join(\"\\n\")}\\n}`;\n return [\n block(\n `:where(:is(${anchors}):not(${selector}))`,\n tokens.map((token) => [twinOf(token), `var(${token})`]),\n ),\n block(\n `:where(${DEFAULT_TONE_SELECTOR}:not(${anchors}))`,\n tokens.map((token) => [token, `var(${twinOf(token)})`]),\n ),\n block(`:where(${DEFAULT_TONE_SELECTOR})`, [\n [\"color-scheme\", \"light\"],\n [\"background-color\", \"var(--tempest-bg)\"],\n [\"color\", \"var(--tempest-text)\"],\n ]),\n block(`:where(:is(${page.darkSelector}) ${DEFAULT_TONE_SELECTOR})`, [\n [\"color-scheme\", \"dark\"],\n ]),\n ].join(\"\\n\\n\");\n}\n"],"mappings":"AAYA,IAAa,EAAwB,gCAG/B,EAAgB,8BAGT,EAAwC,CACjD,SAAU,QACV,aAAc,CAClB,EAQA,SAAS,EAAO,EAAuB,CACnC,OAAO,EAAM,QAAQ,aAAc,oBAAoB,CAC3D,CAuCA,SAAgB,EACZ,EACA,EACA,EACM,CACN,IAAM,EAAU,CACZ,GAAG,IAAI,IAAI,CAAC,QAAS,uBAAwB,EAAK,SAAU,EAAK,YAAY,CAAC,CAClF,CAAC,CACI,OAAQ,GAAW,IAAW,CAAa,CAAC,CAC5C,KAAK,IAAI,EACR,GAAS,EAAc,IACzB,GAAG,EAAK,MAAM,EAAa,KAAK,CAAC,EAAM,KAAW,OAAO,EAAK,IAAI,EAAM,EAAE,CAAC,CAAC,KAAK;CAAI,EAAE,KAC3F,MAAO,CACH,EACI,cAAc,EAAQ,QAAQ,EAAS,IACvC,EAAO,IAAK,GAAU,CAAC,EAAO,CAAK,EAAG,OAAO,EAAM,EAAE,CAAC,CAC1D,EACA,EACI,UAAU,EAAsB,OAAO,EAAQ,IAC/C,EAAO,IAAK,GAAU,CAAC,EAAO,OAAO,EAAO,CAAK,EAAE,EAAE,CAAC,CAC1D,EACA,EAAM,UAAU,EAAsB,GAAI,CACtC,CAAC,eAAgB,OAAO,EACxB,CAAC,mBAAoB,mBAAmB,EACxC,CAAC,QAAS,qBAAqB,CACnC,CAAC,EACD,EAAM,cAAc,EAAK,aAAa,IAAI,EAAsB,GAAI,CAChE,CAAC,eAAgB,MAAM,CAC3B,CAAC,CACL,CAAC,CAAC,KAAK;;CAAM,CACjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/theme/inverse-restore.ts
|
|
2
|
+
var e = "[data-tempest-tone=\"default\"]", t = "[data-tempest-theme=\"dark\"]", n = {
|
|
3
|
+
selector: ":root",
|
|
4
|
+
darkSelector: t
|
|
5
|
+
};
|
|
6
|
+
function r(e) {
|
|
7
|
+
return e.replace("--tempest-", "--tempest-default-");
|
|
8
|
+
}
|
|
9
|
+
function i(n, i, a) {
|
|
10
|
+
let o = [.../* @__PURE__ */ new Set([
|
|
11
|
+
":root",
|
|
12
|
+
"[data-tempest-theme]",
|
|
13
|
+
a.selector,
|
|
14
|
+
a.darkSelector
|
|
15
|
+
])].filter((e) => e !== t).join(", "), s = (e, t) => `${e} {\n${t.map(([e, t]) => ` ${e}: ${t};`).join("\n")}\n}`;
|
|
16
|
+
return [
|
|
17
|
+
s(`:where(:is(${o}):not(${i}))`, n.map((e) => [r(e), `var(${e})`])),
|
|
18
|
+
s(`:where(${e}:not(${o}))`, n.map((e) => [e, `var(${r(e)})`])),
|
|
19
|
+
s(`:where(${e})`, [
|
|
20
|
+
["color-scheme", "light"],
|
|
21
|
+
["background-color", "var(--tempest-bg)"],
|
|
22
|
+
["color", "var(--tempest-text)"]
|
|
23
|
+
]),
|
|
24
|
+
s(`:where(:is(${a.darkSelector}) ${e})`, [["color-scheme", "dark"]])
|
|
25
|
+
].join("\n\n");
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { n as DEFAULT_PAGE_SELECTORS, e as DEFAULT_TONE_SELECTOR, i as defaultToneRules };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=inverse-restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-restore.js","names":[],"sources":["../../src/theme/inverse-restore.ts"],"sourcesContent":["/**\n * The default tone: a region inside an inverse surface that goes back to the\n * page's tokens — `data-tempest-tone=\"default\"`, or `<Section tone=\"default\">`.\n * A white form or price `Card` in a navy hero.\n *\n * Lives beside the generator, not in `inverse-render.ts`, so only an app that\n * imports `createInverseSurface` ships it: `createTheme` alone stays the size it\n * was.\n */\nimport type { PageSelectors } from \"./inverse-render\";\n\n/** Selector that hands a region inside an inverse surface back to the page's tokens. */\nexport const DEFAULT_TONE_SELECTOR = '[data-tempest-tone=\"default\"]';\n\n/** `createTheme`'s default `darkSelector`, already covered by `[data-tempest-theme]`. */\nconst DARK_SELECTOR = '[data-tempest-theme=\"dark\"]';\n\n/** Where `createTheme` writes the page's schemes when told nothing else. */\nexport const DEFAULT_PAGE_SELECTORS: PageSelectors = {\n selector: \":root\",\n darkSelector: DARK_SELECTOR,\n};\n\n/**\n * Name of the custom property that keeps the page's value of `token`.\n *\n * @param token - A `--tempest-*` token.\n * @returns The `--tempest-default-*` twin it is saved under.\n */\nfunction twinOf(token: string): string {\n return token.replace(\"--tempest-\", \"--tempest-default-\");\n}\n\n/**\n * The rules that let a region inside an inverse surface go back to the page's\n * tokens, light or dark — whichever the page is on.\n *\n * Custom properties inherit from the parent, so a rule cannot \"skip\" the\n * inverse section and read `:root` again — and scoping the inverse block away\n * from the region (`@scope (…) to (…)`, `:not()`) changes nothing either, since\n * the region still inherits what its inverse parent declared. Measured in\n * Chromium on a `Card`, an `Input` and a `Button` inside the region, 25 of 28\n * computed values differed from the same trio on the page in light and 18 of 28\n * in dark, with or without `@scope`.\n *\n * What works is saving the page's values before the section overrides them.\n * Every element a theme is declared on (`:root`, `[data-tempest-theme]`, and the\n * theme's own selectors) copies each token the surface redefines into a\n * `--tempest-default-*` twin. `var()` in a custom property resolves on the\n * element that declares it, so the twin holds the page's value — the SDK's, a\n * theme's or the app's own `:root` override — and inherits through the section\n * untouched. The region reads its tokens back from the twins: 0 of 28 values\n * differ, in light, in dark and under a dark subtree.\n *\n * Two alternatives were measured and rejected. Writing the page's values out,\n * one block per scheme, is 1257 B brotli and restores the SDK's defaults rather\n * than the page: with a brand override on `:root`, 3 of 28 values came back\n * wrong. Adding the region to the selectors of `colors.css` costs 15 B brotli,\n * but charges every app and misses the same override.\n *\n * Everything sits under `:where()`, so a class the app puts on the same element\n * still wins. The anchors are left out of the region and the section out of the\n * anchors: a token and its twin declared on one element reference each other,\n * and both resolve to nothing.\n *\n * @param tokens - The tokens the surface redefines.\n * @param selector - Selector the inverse surface is written under.\n * @param page - Selectors the page's schemes are written under.\n * @returns The CSS text of the rules, in the order they must be written.\n */\nexport function defaultToneRules(\n tokens: readonly string[],\n selector: string,\n page: PageSelectors,\n): string {\n const anchors = [\n ...new Set([\":root\", \"[data-tempest-theme]\", page.selector, page.darkSelector]),\n ]\n .filter((anchor) => anchor !== DARK_SELECTOR)\n .join(\", \");\n const block = (rule: string, declarations: readonly (readonly [string, string])[]): string =>\n `${rule} {\\n${declarations.map(([name, value]) => ` ${name}: ${value};`).join(\"\\n\")}\\n}`;\n return [\n block(\n `:where(:is(${anchors}):not(${selector}))`,\n tokens.map((token) => [twinOf(token), `var(${token})`]),\n ),\n block(\n `:where(${DEFAULT_TONE_SELECTOR}:not(${anchors}))`,\n tokens.map((token) => [token, `var(${twinOf(token)})`]),\n ),\n block(`:where(${DEFAULT_TONE_SELECTOR})`, [\n [\"color-scheme\", \"light\"],\n [\"background-color\", \"var(--tempest-bg)\"],\n [\"color\", \"var(--tempest-text)\"],\n ]),\n block(`:where(:is(${page.darkSelector}) ${DEFAULT_TONE_SELECTOR})`, [\n [\"color-scheme\", \"dark\"],\n ]),\n ].join(\"\\n\\n\");\n}\n"],"mappings":";AAYA,IAAa,IAAwB,mCAG/B,IAAgB,iCAGT,IAAwC;CACjD,UAAU;CACV,cAAc;AAClB;AAQA,SAAS,EAAO,GAAuB;CACnC,OAAO,EAAM,QAAQ,cAAc,oBAAoB;AAC3D;AAuCA,SAAgB,EACZ,GACA,GACA,GACM;CACN,IAAM,IAAU,CACZ,mBAAG,IAAI,IAAI;EAAC;EAAS;EAAwB,EAAK;EAAU,EAAK;CAAY,CAAC,CAClF,CAAC,CACI,QAAQ,MAAW,MAAW,CAAa,CAAC,CAC5C,KAAK,IAAI,GACR,KAAS,GAAc,MACzB,GAAG,EAAK,MAAM,EAAa,KAAK,CAAC,GAAM,OAAW,OAAO,EAAK,IAAI,EAAM,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;CAC3F,OAAO;EACH,EACI,cAAc,EAAQ,QAAQ,EAAS,KACvC,EAAO,KAAK,MAAU,CAAC,EAAO,CAAK,GAAG,OAAO,EAAM,EAAE,CAAC,CAC1D;EACA,EACI,UAAU,EAAsB,OAAO,EAAQ,KAC/C,EAAO,KAAK,MAAU,CAAC,GAAO,OAAO,EAAO,CAAK,EAAE,EAAE,CAAC,CAC1D;EACA,EAAM,UAAU,EAAsB,IAAI;GACtC,CAAC,gBAAgB,OAAO;GACxB,CAAC,oBAAoB,mBAAmB;GACxC,CAAC,SAAS,qBAAqB;EACnC,CAAC;EACD,EAAM,cAAc,EAAK,aAAa,IAAI,EAAsB,IAAI,CAChE,CAAC,gBAAgB,MAAM,CAC3B,CAAC;CACL,CAAC,CAAC,KAAK,MAAM;AACjB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./color.cjs"),t=require("./data-viz-ramps.cjs");require("./inverse-render.cjs");const n=require("./status-tokens.cjs"),r=require("./inverse-restore.cjs");var i=4.5,a=4.75,o=3,s=4.5,c=7,l=[500,600,400,700,300,800,200,900],u={dark:{surfaces:[.046,.094,.14],border:.155,borderStrong:.222},light:{surfaces:[.018,.037,.073],border:.073,borderStrong:.128}},d=.1,f={dark:`#ffffff`,light:`#101828`},p={success:`#16a34a`,warning:`#d97706`,danger:`#dc2626`,info:`#2563eb`},m={light:[`#2563eb`,`#16a34a`,`#f59e0b`,`#7c3aed`,`#ec4899`,`#06b6d4`,`#ea580c`,`#0f766e`],dark:[`#60a5fa`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f472b6`,`#22d3ee`,`#fb923c`,`#2dd4bf`]},h=[`comment`,`punctuation`,`string`,`number`,`keyword`,`literal`,`function`,`tag`,`attribute`,`property`],g={light:[`#5f666e`,`#5d6671`,`#327243`,`#9d5035`,`#625baf`,`#9f4c4f`,`#1a6c94`,`#974d72`,`#127171`,`#127171`],dark:[`#838b93`,`#818b95`,`#589866`,`#c57558`,`#8580d8`,`#c87172`,`#2893c6`,`#c07197`,`#349897`,`#349897`]},_={light:{xs:`0 1px 2px rgba(15, 23, 42, 0.04)`,sm:`0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)`,md:`0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)`,lg:`0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)`,xl:`0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)`,inner:`inset 0 2px 4px rgba(15, 23, 42, 0.06)`},dark:{xs:`0 1px 2px rgba(0, 0, 0, 0.3)`,sm:`0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)`,md:`0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)`,lg:`0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)`,xl:`0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)`,inner:`inset 0 2px 4px rgba(15, 23, 42, 0.06)`}},v=.005;function y(t,n,r,i=t.c){let a=Math.min(1,Math.max(0,t.l+n*r));return e.oklchToHex({l:a,c:i,h:t.h})}function b(t,n){return Math.min(...n.map(n=>e.contrastRatio(t,n)))}function x(t,n,r,i,a){let o=e.hexToOklch(t);for(let e=0;e<=1;e+=v){let t=y(o,n,e);if(b(t,r)>=i)return t;if(n===1&&o.l+e>=1||n===-1&&o.l-e<=0)break}return a}var S={dark:.07,light:.05},C=1.6;function w(e,t,n,r){for(let i=n;i>v;i-=v){let n=[y(e,t,i),y(e,t,i*C)];if(b(r,n)>=a)return n}return[y(e,t,-n),y(e,t,-n*C)]}function T(e,t,n){let r=e=>[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16)),[i,a]=[r(e),r(t)];return`#${i.map((e,t)=>Math.round(e+(a[t]-e)*n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function E(r,i){let c=e.readableForeground(r,f.dark,f.light),l=c===f.dark?`dark`:`light`,v=l===`dark`?1:-1,C=e.hexToOklch(r),E=u[l],D={},O=[r,...E.surfaces.map(e=>y(C,v,-e))],[k,A,j,M]=O,N=y(C,v,d),P=[...O,N];D[`--tempest-bg`]=k,D[`--tempest-surface`]=A,D[`--tempest-surface-2`]=j,D[`--tempest-surface-3`]=M,D[`--tempest-border`]=y(C,v,E.border),D[`--tempest-border-strong`]=y(C,v,E.borderStrong);let F=b(c,P),I=C.c*.4;D[`--tempest-text`]=c,D[`--tempest-text-muted`]=x(y(C,v,0,I),v,P,Math.max(a,Math.sqrt(F*a)),c),D[`--tempest-text-subtle`]=x(y(C,v,0,I),v,[k,A,N],a,c);let L={...e.hexToOklch(c),h:C.h};D[`--tempest-primary`]=c,D[`--tempest-primary-hover`]=y(L,v,-.05,C.c*.25),D[`--tempest-primary-active`]=y(L,v,-.1,C.c*.3),D[`--tempest-primary-foreground`]=r,D[`--tempest-text-on-primary`]=r;let[R,z]=w(C,v,S[l],c);D[`--tempest-primary-soft`]=R,D[`--tempest-primary-soft-hover`]=z,D[`--tempest-primary-on-soft`]=x(R,v,[R,z],a,c);let B=x(r,v,P,s,c);D[`--tempest-focus-ring-color`]=B,D[`--tempest-selected-indicator`]=B;let V=e.createColorScale(i.primary,l,{anchor:!1});for(let[e,t]of Object.entries(V))D[`--tempest-primary-${e}`]=t;for(let t of n.THEME_STATUSES){let r=e.createColorScale(i.statuses?.[t]??p[t],l);n.writeStatus(D,t,r,l),D[`--tempest-${t}`]=x(D[`--tempest-${t}`],v,P,a,c),t===`danger`&&(D[`--tempest-danger-hover`]=r[D[`--tempest-danger-on-solid`]===`#ffffff`?l===`dark`?400:700:l===`dark`?600:500])}(i.chart?.length?i.chart:m[l]).forEach((e,t)=>{D[`--tempest-chart-${t+1}`]=x(e,v,[k,A,N],o,c)});let H=t.hueOf(i.chart?.[0]??i.primary),U=i.statuses?.danger?t.hueOf(i.statuses.danger):(H+180)%360;t.buildRamp(H,l).forEach((e,t)=>{D[`--tempest-chart-sequential-${t+1}`]=e});let W=t.buildDivergingRamp({coolHue:H,warmHue:U,mid:M,mode:l});[...W.cool,W.mid,...W.warm].forEach((e,t)=>{D[`--tempest-chart-diverging-${t+1}`]=e}),D[`--tempest-chart-grid`]=D[`--tempest-border`],D[`--tempest-chart-axis`]=D[`--tempest-text-subtle`];let G=[k,A,T(A,c,.1)];h.forEach((e,t)=>{D[`--tempest-code-${e}`]=x(g[l][t],v,G,a,c)});for(let[e,t]of Object.entries(_[l]))D[`--tempest-shadow-${e}`]=t;return{tokens:D,scheme:l,glow:N}}function D(e,t){let n=t=>e[t],r=[n(`--tempest-bg`),n(`--tempest-surface`),n(`--tempest-surface-2`),n(`--tempest-surface-3`)],a=n(`--tempest-primary-foreground`),s=[b(n(`--tempest-text`),[...r,t])/c,b(n(`--tempest-text-muted`),[...r,t])/i,b(n(`--tempest-text-subtle`),[...r.slice(0,2),t])/i,b(n(`--tempest-focus-ring-color`),[...r,t])/o,b(a,[n(`--tempest-primary`),n(`--tempest-primary-hover`),n(`--tempest-primary-active`)])/i];return Math.min(...s)-1}function O(t){let n=e.createColorScale(t.primary,`light`),i=null,a=-1/0;for(let e of l){let r=E(n[e],t),o=D(r.tokens,r.glow);if(o>a&&(i={tokens:r.tokens,scheme:r.scheme,step:e},a=o),o>=0)break}let o=i;return o.rules=r.defaultToneRules(Object.keys(o.tokens),t.selector??`[data-tempest-tone="inverse"]`,t.page??r.DEFAULT_PAGE_SELECTORS),o}exports.DEFAULT_CHART_COLORS=m,exports.DEFAULT_CODE_COLORS=g,exports.DEFAULT_STATUS_COLORS=p,exports.createInverseSurface=O;
|
|
2
|
+
//# sourceMappingURL=inverse-surface.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-surface.cjs","names":[],"sources":["../../src/theme/inverse-surface.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines — the inverse surface is a whole scheme: surfaces,\n * text, the action color, focus, selection, statuses, charts and syntax colors,\n * each derived and then measured against the brand fill it sits on. Splitting\n * the derivation from the table it is measured against is how the two drift.\n */\n/**\n * Inverse surface: the token set for a section painted in the brand color —\n * a hero, a call-to-action band, a footer — so the components inside it invert\n * instead of inheriting the page's tokens.\n *\n * Every value is derived from the brand and measured against the fill it will\n * sit on, the same way {@link createTheme} measures the page schemes. Overriding\n * eight tokens by hand (what #409 had to do) leaves the rest of the scheme on\n * the page's values: measured over a navy `#1e2a5a`, the inherited\n * `--tempest-text-subtle` lands at 2.75:1, `--tempest-danger` at 2.12:1, the\n * selected indicator at 2.01:1, and a `Card` puts white text on\n * `--tempest-surface` at 1.05:1.\n */\nimport {\n contrastRatio,\n createColorScale,\n hexToOklch,\n oklchToHex,\n readableForeground,\n type ColorScale,\n type Oklch,\n type ScaleStep,\n} from \"./color\";\nimport { buildDivergingRamp, buildRamp, hueOf } from \"./data-viz-ramps\";\nimport {\n INVERSE_SELECTOR,\n type InverseScheme,\n type InverseSurface,\n type InverseSurfaceOptions,\n} from \"./inverse-render\";\nimport { DEFAULT_PAGE_SELECTORS, defaultToneRules } from \"./inverse-restore\";\nimport { THEME_STATUSES, writeStatus, type ThemeStatus } from \"./status-tokens\";\n\nexport { INVERSE_SELECTOR, renderInverseSurface } from \"./inverse-render\";\nexport { DEFAULT_TONE_SELECTOR } from \"./inverse-restore\";\nexport type {\n InverseScheme,\n InverseSurface,\n InverseSurfaceGenerator,\n InverseSurfaceOptions,\n PageSelectors,\n} from \"./inverse-render\";\n\n/** WCAG 2.x AA floor for body text. */\nconst AA_TEXT = 4.5;\n\n/**\n * What text is fitted to, rather than the floor itself.\n *\n * The margin the SDK's dark theme keeps on `--tempest-text-subtle` (4.79 over its\n * surface): a value solved to exactly 4.5 turns the next rounding into a failure.\n */\nconst TEXT_TARGET = 4.75;\n\n/** WCAG 2.2 SC 1.4.11 floor for a non-text indicator. */\nconst INDICATOR_FLOOR = 3;\n\n/**\n * What the focus ring and the selected indicator are fitted to.\n *\n * Well above the 3:1 floor on purpose: the SDK's own rings keep 5.40:1 (dark)\n * and 5.50:1 (light) worst case, because a ring travels onto surfaces nobody\n * validated it against.\n */\nconst RING_TARGET = 4.5;\n\n/**\n * The smallest contrast the ink must keep — on the fill, the surfaces and the\n * glow — before the fill is accepted.\n *\n * AA (4.5) is not enough here, because the surface has three text levels — text,\n * muted and subtle — and all three must clear AA. With text at 4.83:1 (white on\n * the default `#0066ff`) the three collapse into one color. 7:1 (AAA) leaves room\n * for muted to sit visibly between text and subtle.\n */\nconst MIN_TEXT_RATIO = 7;\n\n/**\n * Fill candidates, nearest the brand first, darker before lighter on a tie.\n *\n * `500` is the brand itself and wins whenever it can carry the scheme. When it\n * cannot — a mid-tone brand such as `#0066ff`, where white measures 4.83:1 —\n * the walk moves one step at a time, so the section stays as close to the brand\n * as the measurement allows.\n *\n * Measuring the glow is what most of the walking pays for: against the flat\n * fill and the surfaces alone, 9 of the 14 test brands keep their `500`; with\n * the glow, 6 do. The three that move (`#8100D7`, `#22d3ee`, `#14b8a6`) are the\n * ones whose subtle text would fail on a lifted region of their own band.\n */\nconst FILL_CANDIDATES: readonly ScaleStep[] = [500, 600, 400, 700, 300, 800, 200, 900];\n\n/**\n * Lightness offsets from the fill, per scheme.\n *\n * The sizes are the SDK's own, measured in OKLCH: the dark theme's surfaces sit\n * 0.046, 0.094 and 0.140 from `#0b0d12`, its borders 0.155 and 0.222; the light\n * theme's surfaces sit 0.018, 0.037 and 0.073 from white, its borders 0.073 and\n * 0.128.\n *\n * The direction is not the SDK's. On the page, raised surfaces move toward the\n * ink, which costs nothing there: the page fill is near-white or near-black, so\n * the ink keeps 13:1 or more on the third surface. A brand fill sits mid-axis,\n * and moving toward the ink spends exactly the contrast the text needs. Measured\n * across the fourteen brands of the contrast test, every text level held to AA\n * on every surface and on the glow ({@link GLOW_OFFSET}):\n *\n * | surfaces move | brands keeping their own `500` | where `#8100D7` / `#4f46e5` land |\n * | --- | --- | --- |\n * | toward the ink | 6 of 14 | `800` / `800` |\n * | away from the ink | 6 of 14 | `700` / `700` |\n *\n * Never worse and one step nearer the brand for the purples, and with every\n * surface carrying the ink at least as well as the fill does.\n *\n * So surfaces move away from the ink — a card in a navy band is a deeper navy,\n * one in a yellow band a paler yellow — and every surface then carries the ink\n * at least as well as the fill does. Borders still move toward the ink, since a\n * border has to separate from the fill and the surfaces alike.\n */\nconst OFFSETS: Record<\n InverseScheme,\n { surfaces: readonly [number, number, number]; border: number; borderStrong: number }\n> = {\n dark: { surfaces: [0.046, 0.094, 0.14], border: 0.155, borderStrong: 0.222 },\n light: { surfaces: [0.018, 0.037, 0.073], border: 0.073, borderStrong: 0.128 },\n};\n\n/**\n * How far toward the ink a region of the band may lift and still be measured.\n *\n * A brand section is rarely one flat color: the landing that opened #409 lays a\n * radial glow of `#1f3f8f` at 55% over its navy `#03184b`, which lifts the\n * ground by 0.09 in OKLCH lightness, and a hover tint does the same. Text fitted\n * to the flat fill alone failed there — subtle measured 3.64:1 on that glow. So\n * every text and indicator token is also fitted against the fill lifted by this\n * much; darker variations (the landing's `#020f30` footer) only add contrast.\n */\nconst GLOW_OFFSET = 0.1;\n\n/** Text ink per scheme — the SDK's own extremes. */\nconst INK: Record<InverseScheme, string> = { dark: \"#ffffff\", light: \"#101828\" };\n\n/**\n * The SDK's default status colors, used when a theme names none.\n *\n * Ported from `src/styles/colors.css` (`--tempest-*-solid` in the light block),\n * and pinned by a test that reads that file.\n */\nexport const DEFAULT_STATUS_COLORS: Record<ThemeStatus, string> = {\n success: \"#16a34a\",\n warning: \"#d97706\",\n danger: \"#dc2626\",\n info: \"#2563eb\",\n};\n\n/**\n * The SDK's categorical chart colors, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-chart-1` … `-8`), pinned by a\n * test that reads that file. Used as the starting hue for each slot, then fitted\n * to the inverse fill.\n */\nexport const DEFAULT_CHART_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\"#2563eb\", \"#16a34a\", \"#f59e0b\", \"#7c3aed\", \"#ec4899\", \"#06b6d4\", \"#ea580c\", \"#0f766e\"],\n dark: [\"#60a5fa\", \"#4ade80\", \"#fbbf24\", \"#a78bfa\", \"#f472b6\", \"#22d3ee\", \"#fb923c\", \"#2dd4bf\"],\n};\n\n/** Names of the `CodeBlock` syntax tokens, in `colors.css` order. */\nconst CODE_TOKENS = [\n \"comment\",\n \"punctuation\",\n \"string\",\n \"number\",\n \"keyword\",\n \"literal\",\n \"function\",\n \"tag\",\n \"attribute\",\n \"property\",\n] as const;\n\n/**\n * The SDK's syntax colors, per scheme, in {@link CODE_TOKENS} order.\n *\n * Ported from `src/styles/colors.css` (`--tempest-code-*`), pinned by a test\n * that reads that file. Used as the starting hue, then fitted to the inverse\n * code grounds.\n */\nexport const DEFAULT_CODE_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\n \"#5f666e\",\n \"#5d6671\",\n \"#327243\",\n \"#9d5035\",\n \"#625baf\",\n \"#9f4c4f\",\n \"#1a6c94\",\n \"#974d72\",\n \"#127171\",\n \"#127171\",\n ],\n dark: [\n \"#838b93\",\n \"#818b95\",\n \"#589866\",\n \"#c57558\",\n \"#8580d8\",\n \"#c87172\",\n \"#2893c6\",\n \"#c07197\",\n \"#349897\",\n \"#349897\",\n ],\n};\n\n/**\n * The SDK's elevation shadows, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-shadow-*`). A light-ink fill\n * takes the dark theme's heavier shadows, since a faint shadow vanishes on it.\n * The dark block does not override `--tempest-shadow-inner`, so the dark row\n * carries the light value it inherits.\n */\nconst SHADOWS: Record<InverseScheme, Record<string, string>> = {\n light: {\n xs: \"0 1px 2px rgba(15, 23, 42, 0.04)\",\n sm: \"0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)\",\n lg: \"0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)\",\n xl: \"0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n dark: {\n xs: \"0 1px 2px rgba(0, 0, 0, 0.3)\",\n sm: \"0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)\",\n md: \"0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)\",\n lg: \"0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)\",\n xl: \"0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n};\n\n/** Lightness step used when fitting a color toward the ink. */\nconst FIT_STEP = 0.005;\n\n/**\n * Move a color along the lightness axis toward (positive `delta`) or away from\n * the ink, keeping its hue.\n *\n * @param base - The color to move, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param delta - How far to move, in OKLCH lightness.\n * @param chroma - Chroma of the result; defaults to the base's.\n * @returns The moved color as hex, gamut-mapped.\n */\nfunction shift(base: Oklch, direction: 1 | -1, delta: number, chroma: number = base.c): string {\n const l = Math.min(1, Math.max(0, base.l + direction * delta));\n return oklchToHex({ l, c: chroma, h: base.h });\n}\n\n/** Weakest contrast of `color` against every ground. */\nfunction worst(color: string, grounds: readonly string[]): number {\n return Math.min(...grounds.map((ground) => contrastRatio(color, ground)));\n}\n\n/**\n * Walk a color toward the ink until it clears `floor` against every ground.\n *\n * Hue and chroma are kept, so a danger stays red and a keyword stays violet;\n * only lightness moves, and only as far as the measurement asks. When the walk\n * reaches the end of the lightness axis without clearing, the ink itself is\n * returned — it is the most contrasting color the scheme has.\n *\n * @param start - Where to start, as hex.\n * @param direction - `1` when the ink is lighter than the grounds, `-1` otherwise.\n * @param grounds - Every background the color will sit on.\n * @param floor - The ratio to clear against all of them.\n * @param ink - Fallback when nothing on the walk clears.\n * @returns The first color on the walk that clears, else `ink`.\n */\nfunction fitToward(\n start: string,\n direction: 1 | -1,\n grounds: readonly string[],\n floor: number,\n ink: string,\n): string {\n const base = hexToOklch(start);\n for (let delta = 0; delta <= 1; delta += FIT_STEP) {\n const candidate = shift(base, direction, delta);\n if (worst(candidate, grounds) >= floor) return candidate;\n if ((direction === 1 && base.l + delta >= 1) || (direction === -1 && base.l - delta <= 0)) {\n break;\n }\n }\n return ink;\n}\n\n/**\n * How far the soft tint sits from the fill, per scheme; the hover tint sits\n * {@link SOFT_HOVER_FACTOR} times as far.\n */\nconst SOFT_OFFSET: Record<InverseScheme, number> = { dark: 0.07, light: 0.05 };\n\n/** Distance of the soft hover tint, relative to the soft tint's. */\nconst SOFT_HOVER_FACTOR = 1.6;\n\n/**\n * The soft tint and its hover, lifted toward the ink only as far as the ink\n * still reads on both.\n *\n * A tint toward the ink is what reads as \"highlighted\" on a fill, and it is also\n * what eats the ink's contrast: on the `#8100D7` fill, the full offset left white\n * at 4.42:1 on the hover tint. So the offset shrinks until the ink clears\n * {@link TEXT_TARGET} on both, and when even a sliver cannot — the fill gives the\n * ink no room — the tints move away from the ink instead, like the surfaces.\n *\n * @param base - The fill, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param offset - The preferred distance of the soft tint.\n * @param ink - The scheme's text ink.\n * @returns The soft tint and its hover, as hex.\n */\nfunction softTints(base: Oklch, direction: 1 | -1, offset: number, ink: string): [string, string] {\n for (let delta = offset; delta > FIT_STEP; delta -= FIT_STEP) {\n const tints: [string, string] = [\n shift(base, direction, delta),\n shift(base, direction, delta * SOFT_HOVER_FACTOR),\n ];\n if (worst(ink, tints) >= TEXT_TARGET) return tints;\n }\n return [shift(base, direction, -offset), shift(base, direction, -offset * SOFT_HOVER_FACTOR)];\n}\n\n/** Mix `top` over `bottom` at `amount`, the way `color-mix(in srgb, …)` composites. */\nfunction mix(bottom: string, top: string, amount: number): string {\n const parse = (hex: string): number[] =>\n [1, 3, 5].map((index) => Number.parseInt(hex.slice(index, index + 2), 16));\n const [a, b] = [parse(bottom), parse(top)];\n const channels = a.map((channel, index) =>\n Math.round(channel + ((b[index] as number) - channel) * amount),\n );\n return `#${channels.map((channel) => channel.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Derive the inverse scheme over one candidate fill.\n *\n * Text is three levels, like the page: the ink, then `muted` fitted to the\n * geometric mean of the ink's contrast and {@link TEXT_TARGET} (so it sits\n * visibly between the two), then `subtle` fitted to {@link TEXT_TARGET} on\n * `bg` and `surface` — the same pairs the SDK holds its own `text-subtle` to.\n *\n * The action color is the ink itself: a white button on a navy band, labelled in\n * the fill. Hover and active step back toward the fill, because the ink is\n * already the end of the axis and has nowhere further to go.\n *\n * `--tempest-danger-hover` steps toward the side that keeps `-on-solid`\n * readable: darker when the ink is white, lighter when it is dark. A fixed\n * direction cannot hold one ink over both fills — over the dark scheme's\n * `#dc2626` it measured 4.00:1 with the lighter hover.\n *\n * The ramp (`--tempest-primary-50` … `-900`) is emitted too, because `Tag` and\n * `Sidebar` pair raw steps (`100` under `700`). It is the scheme's unanchored\n * ramp, so that pair keeps the shape it has on the page.\n *\n * @param fill - The fill, as hex.\n * @param options - The brand description.\n * @returns The token map and the scheme it reads as.\n */\nfunction deriveOver(\n fill: string,\n options: InverseSurfaceOptions,\n): { tokens: Record<string, string>; scheme: InverseScheme; glow: string } {\n const ink = readableForeground(fill, INK.dark, INK.light);\n const scheme: InverseScheme = ink === INK.dark ? \"dark\" : \"light\";\n const direction: 1 | -1 = scheme === \"dark\" ? 1 : -1;\n const base = hexToOklch(fill);\n const offsets = OFFSETS[scheme];\n const tokens: Record<string, string> = {};\n\n const surfaces = [fill, ...offsets.surfaces.map((delta) => shift(base, direction, -delta))];\n const [bg, surface, surface2, surface3] = surfaces as [string, string, string, string];\n const glow = shift(base, direction, GLOW_OFFSET);\n const grounds = [...surfaces, glow];\n tokens[\"--tempest-bg\"] = bg;\n tokens[\"--tempest-surface\"] = surface;\n tokens[\"--tempest-surface-2\"] = surface2;\n tokens[\"--tempest-surface-3\"] = surface3;\n tokens[\"--tempest-border\"] = shift(base, direction, offsets.border);\n tokens[\"--tempest-border-strong\"] = shift(base, direction, offsets.borderStrong);\n\n const textWorst = worst(ink, grounds);\n const tint = base.c * 0.4;\n tokens[\"--tempest-text\"] = ink;\n tokens[\"--tempest-text-muted\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n grounds,\n Math.max(TEXT_TARGET, Math.sqrt(textWorst * TEXT_TARGET)),\n ink,\n );\n tokens[\"--tempest-text-subtle\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n [bg, surface, glow],\n TEXT_TARGET,\n ink,\n );\n\n const inkBase: Oklch = { ...hexToOklch(ink), h: base.h };\n tokens[\"--tempest-primary\"] = ink;\n tokens[\"--tempest-primary-hover\"] = shift(inkBase, direction, -0.05, base.c * 0.25);\n tokens[\"--tempest-primary-active\"] = shift(inkBase, direction, -0.1, base.c * 0.3);\n tokens[\"--tempest-primary-foreground\"] = fill;\n tokens[\"--tempest-text-on-primary\"] = fill;\n\n const [soft, softHover] = softTints(base, direction, SOFT_OFFSET[scheme], ink);\n tokens[\"--tempest-primary-soft\"] = soft;\n tokens[\"--tempest-primary-soft-hover\"] = softHover;\n tokens[\"--tempest-primary-on-soft\"] = fitToward(\n soft,\n direction,\n [soft, softHover],\n TEXT_TARGET,\n ink,\n );\n\n const ring = fitToward(fill, direction, grounds, RING_TARGET, ink);\n tokens[\"--tempest-focus-ring-color\"] = ring;\n tokens[\"--tempest-selected-indicator\"] = ring;\n\n const ramp: ColorScale = createColorScale(options.primary, scheme, { anchor: false });\n for (const [step, value] of Object.entries(ramp)) {\n tokens[`--tempest-primary-${step}`] = value;\n }\n\n for (const status of THEME_STATUSES) {\n const scale = createColorScale(\n options.statuses?.[status] ?? DEFAULT_STATUS_COLORS[status],\n scheme,\n );\n writeStatus(tokens, status, scale, scheme);\n tokens[`--tempest-${status}`] = fitToward(\n tokens[`--tempest-${status}`] as string,\n direction,\n grounds,\n TEXT_TARGET,\n ink,\n );\n if (status === \"danger\") {\n const whiteInk = tokens[\"--tempest-danger-on-solid\"] === \"#ffffff\";\n const darker: ScaleStep = scheme === \"dark\" ? 400 : 700;\n const lighter: ScaleStep = scheme === \"dark\" ? 600 : 500;\n tokens[\"--tempest-danger-hover\"] = scale[whiteInk ? darker : lighter];\n }\n }\n\n const chart = options.chart?.length ? options.chart : DEFAULT_CHART_COLORS[scheme];\n chart.forEach((color, index) => {\n tokens[`--tempest-chart-${index + 1}`] = fitToward(\n color,\n direction,\n [bg, surface, glow],\n INDICATOR_FLOOR,\n ink,\n );\n });\n const coolHue = hueOf(options.chart?.[0] ?? options.primary);\n const warmHue = options.statuses?.danger\n ? hueOf(options.statuses.danger)\n : (coolHue + 180) % 360;\n buildRamp(coolHue, scheme).forEach((value, index) => {\n tokens[`--tempest-chart-sequential-${index + 1}`] = value;\n });\n const diverging = buildDivergingRamp({ coolHue, warmHue, mid: surface3, mode: scheme });\n [...diverging.cool, diverging.mid, ...diverging.warm].forEach((value, index) => {\n tokens[`--tempest-chart-diverging-${index + 1}`] = value;\n });\n tokens[\"--tempest-chart-grid\"] = tokens[\"--tempest-border\"] as string;\n tokens[\"--tempest-chart-axis\"] = tokens[\"--tempest-text-subtle\"] as string;\n\n const codeGrounds = [bg, surface, mix(surface, ink, 0.1)];\n CODE_TOKENS.forEach((name, index) => {\n tokens[`--tempest-code-${name}`] = fitToward(\n DEFAULT_CODE_COLORS[scheme][index] as string,\n direction,\n codeGrounds,\n TEXT_TARGET,\n ink,\n );\n });\n\n for (const [name, value] of Object.entries(SHADOWS[scheme])) {\n tokens[`--tempest-shadow-${name}`] = value;\n }\n\n return { tokens, scheme, glow };\n}\n\n/**\n * The gates a candidate fill must clear before it is accepted.\n *\n * Text reaches {@link MIN_TEXT_RATIO} on every surface, every fitted text token\n * clears AA where it is used, the ring clears 3:1 on every surface, and the\n * action label clears AA on all three button states.\n *\n * @param tokens - A derived token map.\n * @param glow - The fill lifted by {@link GLOW_OFFSET}, measured alongside the surfaces.\n * @returns The weakest margin over its floor across all gates; `>= 0` passes.\n */\nfunction margin(tokens: Record<string, string>, glow: string): number {\n const read = (name: string): string => tokens[name] as string;\n const surfaces = [\n read(\"--tempest-bg\"),\n read(\"--tempest-surface\"),\n read(\"--tempest-surface-2\"),\n read(\"--tempest-surface-3\"),\n ];\n const label = read(\"--tempest-primary-foreground\");\n const checks: number[] = [\n worst(read(\"--tempest-text\"), [...surfaces, glow]) / MIN_TEXT_RATIO,\n worst(read(\"--tempest-text-muted\"), [...surfaces, glow]) / AA_TEXT,\n worst(read(\"--tempest-text-subtle\"), [...surfaces.slice(0, 2), glow]) / AA_TEXT,\n worst(read(\"--tempest-focus-ring-color\"), [...surfaces, glow]) / INDICATOR_FLOOR,\n worst(label, [\n read(\"--tempest-primary\"),\n read(\"--tempest-primary-hover\"),\n read(\"--tempest-primary-active\"),\n ]) / AA_TEXT,\n ];\n return Math.min(...checks) - 1;\n}\n\n/**\n * Build the inverse surface for a brand.\n *\n * The fill is the brand's own `500` whenever it can carry the scheme, and\n * otherwise the nearest ramp step that can (see {@link FILL_CANDIDATES}). Whether\n * the surface reads light-on-dark or dark-on-light follows the fill, so a yellow\n * brand gets dark ink and a navy one white — the same pick `createTheme` makes\n * for `--tempest-primary-foreground`.\n *\n * The values are literal colors, not references to the page's ramp, so the\n * section paints the same in the light and the dark page scheme: the brand is\n * the brand in both.\n *\n * The result also carries the rules that let a region inside the surface go\n * back to the page's tokens (`data-tempest-tone=\"default\"`), written for the\n * selectors in `options`.\n *\n * @param options - The brand, plus the status and chart colors the theme names\n * and the selectors the surface and the page are written under.\n * @returns The token map, the scheme it reads as, the fill step used and the\n * default-tone rules.\n */\nexport function createInverseSurface(options: InverseSurfaceOptions): InverseSurface {\n const ramp = createColorScale(options.primary, \"light\");\n let best: InverseSurface | null = null;\n let bestMargin = Number.NEGATIVE_INFINITY;\n for (const step of FILL_CANDIDATES) {\n const derived = deriveOver(ramp[step], options);\n const measured = margin(derived.tokens, derived.glow);\n if (measured > bestMargin) {\n best = { tokens: derived.tokens, scheme: derived.scheme, step };\n bestMargin = measured;\n }\n if (measured >= 0) break;\n }\n const surface = best as InverseSurface;\n surface.rules = defaultToneRules(\n Object.keys(surface.tokens),\n options.selector ?? INVERSE_SELECTOR,\n options.page ?? DEFAULT_PAGE_SELECTORS,\n );\n return surface;\n}\n"],"mappings":"2KAkDA,IAAM,EAAU,IAQV,EAAc,KAGd,EAAkB,EASlB,EAAc,IAWd,EAAiB,EAejB,EAAwC,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EA8B/E,EAGF,CACA,KAAM,CAAE,SAAU,CAAC,KAAO,KAAO,GAAI,EAAG,OAAQ,KAAO,aAAc,IAAM,EAC3E,MAAO,CAAE,SAAU,CAAC,KAAO,KAAO,IAAK,EAAG,OAAQ,KAAO,aAAc,IAAM,CACjF,EAYM,EAAc,GAGd,EAAqC,CAAE,KAAM,UAAW,MAAO,SAAU,EAQlE,EAAqD,CAC9D,QAAS,UACT,QAAS,UACT,OAAQ,UACR,KAAM,SACV,EASa,EAAiE,CAC1E,MAAO,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,EAC9F,KAAM,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,CACjG,EAGM,EAAc,CAChB,UACA,cACA,SACA,SACA,UACA,UACA,WACA,MACA,YACA,UACJ,EASa,EAAgE,CACzE,MAAO,CACH,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACJ,EACA,KAAM,CACF,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACJ,CACJ,EAUM,EAAyD,CAC3D,MAAO,CACH,GAAI,mCACJ,GAAI,qEACJ,GAAI,sEACJ,GAAI,uEACJ,GAAI,wEACJ,MAAO,wCACX,EACA,KAAM,CACF,GAAI,+BACJ,GAAI,6DACJ,GAAI,8DACJ,GAAI,+DACJ,GAAI,gEACJ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EAC3D,EAAM,EAAK,uBAAuB,EAAG,CAAC,GAAG,EAAS,MAAM,EAAG,CAAC,EAAG,CAAI,CAAC,EAAI,EACxE,EAAM,EAAK,4BAA4B,EAAG,CAAC,GAAG,EAAU,CAAI,CAAC,EAAI,EACjE,EAAM,EAAO,CACT,EAAK,mBAAmB,EACxB,EAAK,yBAAyB,EAC9B,EAAK,0BAA0B,CACnC,CAAC,EAAI,CACT,EACA,OAAO,KAAK,IAAI,GAAG,CAAM,EAAI,CACjC,CAwBA,SAAgB,EAAqB,EAAgD,CACjF,IAAM,EAAO,EAAA,iBAAiB,EAAQ,QAAS,OAAO,EAClD,EAA8B,KAC9B,EAAa,KACjB,IAAK,IAAM,KAAQ,EAAiB,CAChC,IAAM,EAAU,EAAW,EAAK,GAAO,CAAO,EACxC,EAAW,EAAO,EAAQ,OAAQ,EAAQ,IAAI,EAKpD,GAJI,EAAW,IACX,EAAO,CAAE,OAAQ,EAAQ,OAAQ,OAAQ,EAAQ,OAAQ,MAAK,EAC9D,EAAa,GAEb,GAAY,EAAG,KACvB,CACA,IAAM,EAAU,EAMhB,MALA,GAAQ,MAAQ,EAAA,iBACZ,OAAO,KAAK,EAAQ,MAAM,EAC1B,EAAQ,UAAA,gCACR,EAAQ,MAAQ,EAAA,sBACpB,EACO,CACX"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { contrastRatio as e, createColorScale as t, hexToOklch as n, oklchToHex as r, readableForeground as i } from "./color.js";
|
|
2
|
+
import { buildDivergingRamp as a, buildRamp as o, hueOf as s } from "./data-viz-ramps.js";
|
|
3
|
+
import "./inverse-render.js";
|
|
4
|
+
import { THEME_STATUSES as c, writeStatus as l } from "./status-tokens.js";
|
|
5
|
+
import { DEFAULT_PAGE_SELECTORS as u, defaultToneRules as d } from "./inverse-restore.js";
|
|
6
|
+
//#region src/theme/inverse-surface.ts
|
|
7
|
+
var f = 4.5, p = 4.75, m = 3, h = 4.5, g = 7, _ = [
|
|
8
|
+
500,
|
|
9
|
+
600,
|
|
10
|
+
400,
|
|
11
|
+
700,
|
|
12
|
+
300,
|
|
13
|
+
800,
|
|
14
|
+
200,
|
|
15
|
+
900
|
|
16
|
+
], v = {
|
|
17
|
+
dark: {
|
|
18
|
+
surfaces: [
|
|
19
|
+
.046,
|
|
20
|
+
.094,
|
|
21
|
+
.14
|
|
22
|
+
],
|
|
23
|
+
border: .155,
|
|
24
|
+
borderStrong: .222
|
|
25
|
+
},
|
|
26
|
+
light: {
|
|
27
|
+
surfaces: [
|
|
28
|
+
.018,
|
|
29
|
+
.037,
|
|
30
|
+
.073
|
|
31
|
+
],
|
|
32
|
+
border: .073,
|
|
33
|
+
borderStrong: .128
|
|
34
|
+
}
|
|
35
|
+
}, y = .1, b = {
|
|
36
|
+
dark: "#ffffff",
|
|
37
|
+
light: "#101828"
|
|
38
|
+
}, x = {
|
|
39
|
+
success: "#16a34a",
|
|
40
|
+
warning: "#d97706",
|
|
41
|
+
danger: "#dc2626",
|
|
42
|
+
info: "#2563eb"
|
|
43
|
+
}, S = {
|
|
44
|
+
light: [
|
|
45
|
+
"#2563eb",
|
|
46
|
+
"#16a34a",
|
|
47
|
+
"#f59e0b",
|
|
48
|
+
"#7c3aed",
|
|
49
|
+
"#ec4899",
|
|
50
|
+
"#06b6d4",
|
|
51
|
+
"#ea580c",
|
|
52
|
+
"#0f766e"
|
|
53
|
+
],
|
|
54
|
+
dark: [
|
|
55
|
+
"#60a5fa",
|
|
56
|
+
"#4ade80",
|
|
57
|
+
"#fbbf24",
|
|
58
|
+
"#a78bfa",
|
|
59
|
+
"#f472b6",
|
|
60
|
+
"#22d3ee",
|
|
61
|
+
"#fb923c",
|
|
62
|
+
"#2dd4bf"
|
|
63
|
+
]
|
|
64
|
+
}, C = [
|
|
65
|
+
"comment",
|
|
66
|
+
"punctuation",
|
|
67
|
+
"string",
|
|
68
|
+
"number",
|
|
69
|
+
"keyword",
|
|
70
|
+
"literal",
|
|
71
|
+
"function",
|
|
72
|
+
"tag",
|
|
73
|
+
"attribute",
|
|
74
|
+
"property"
|
|
75
|
+
], w = {
|
|
76
|
+
light: [
|
|
77
|
+
"#5f666e",
|
|
78
|
+
"#5d6671",
|
|
79
|
+
"#327243",
|
|
80
|
+
"#9d5035",
|
|
81
|
+
"#625baf",
|
|
82
|
+
"#9f4c4f",
|
|
83
|
+
"#1a6c94",
|
|
84
|
+
"#974d72",
|
|
85
|
+
"#127171",
|
|
86
|
+
"#127171"
|
|
87
|
+
],
|
|
88
|
+
dark: [
|
|
89
|
+
"#838b93",
|
|
90
|
+
"#818b95",
|
|
91
|
+
"#589866",
|
|
92
|
+
"#c57558",
|
|
93
|
+
"#8580d8",
|
|
94
|
+
"#c87172",
|
|
95
|
+
"#2893c6",
|
|
96
|
+
"#c07197",
|
|
97
|
+
"#349897",
|
|
98
|
+
"#349897"
|
|
99
|
+
]
|
|
100
|
+
}, T = {
|
|
101
|
+
light: {
|
|
102
|
+
xs: "0 1px 2px rgba(15, 23, 42, 0.04)",
|
|
103
|
+
sm: "0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)",
|
|
104
|
+
md: "0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)",
|
|
105
|
+
lg: "0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)",
|
|
106
|
+
xl: "0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)",
|
|
107
|
+
inner: "inset 0 2px 4px rgba(15, 23, 42, 0.06)"
|
|
108
|
+
},
|
|
109
|
+
dark: {
|
|
110
|
+
xs: "0 1px 2px rgba(0, 0, 0, 0.3)",
|
|
111
|
+
sm: "0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)",
|
|
112
|
+
md: "0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)",
|
|
113
|
+
lg: "0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)",
|
|
114
|
+
xl: "0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)",
|
|
115
|
+
inner: "inset 0 2px 4px rgba(15, 23, 42, 0.06)"
|
|
116
|
+
}
|
|
117
|
+
}, E = .005;
|
|
118
|
+
function D(e, t, n, i = e.c) {
|
|
119
|
+
let a = Math.min(1, Math.max(0, e.l + t * n));
|
|
120
|
+
return r({
|
|
121
|
+
l: a,
|
|
122
|
+
c: i,
|
|
123
|
+
h: e.h
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function O(t, n) {
|
|
127
|
+
return Math.min(...n.map((n) => e(t, n)));
|
|
128
|
+
}
|
|
129
|
+
function k(e, t, r, i, a) {
|
|
130
|
+
let o = n(e);
|
|
131
|
+
for (let e = 0; e <= 1; e += E) {
|
|
132
|
+
let n = D(o, t, e);
|
|
133
|
+
if (O(n, r) >= i) return n;
|
|
134
|
+
if (t === 1 && o.l + e >= 1 || t === -1 && o.l - e <= 0) break;
|
|
135
|
+
}
|
|
136
|
+
return a;
|
|
137
|
+
}
|
|
138
|
+
var A = {
|
|
139
|
+
dark: .07,
|
|
140
|
+
light: .05
|
|
141
|
+
}, j = 1.6;
|
|
142
|
+
function M(e, t, n, r) {
|
|
143
|
+
for (let i = n; i > E; i -= E) {
|
|
144
|
+
let n = [D(e, t, i), D(e, t, i * j)];
|
|
145
|
+
if (O(r, n) >= p) return n;
|
|
146
|
+
}
|
|
147
|
+
return [D(e, t, -n), D(e, t, -n * j)];
|
|
148
|
+
}
|
|
149
|
+
function N(e, t, n) {
|
|
150
|
+
let r = (e) => [
|
|
151
|
+
1,
|
|
152
|
+
3,
|
|
153
|
+
5
|
|
154
|
+
].map((t) => Number.parseInt(e.slice(t, t + 2), 16)), [i, a] = [r(e), r(t)];
|
|
155
|
+
return `#${i.map((e, t) => Math.round(e + (a[t] - e) * n)).map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
156
|
+
}
|
|
157
|
+
function P(e, r) {
|
|
158
|
+
let u = i(e, b.dark, b.light), d = u === b.dark ? "dark" : "light", f = d === "dark" ? 1 : -1, g = n(e), _ = v[d], E = {}, j = [e, ..._.surfaces.map((e) => D(g, f, -e))], [P, F, I, L] = j, R = D(g, f, y), z = [...j, R];
|
|
159
|
+
E["--tempest-bg"] = P, E["--tempest-surface"] = F, E["--tempest-surface-2"] = I, E["--tempest-surface-3"] = L, E["--tempest-border"] = D(g, f, _.border), E["--tempest-border-strong"] = D(g, f, _.borderStrong);
|
|
160
|
+
let B = O(u, z), V = g.c * .4;
|
|
161
|
+
E["--tempest-text"] = u, E["--tempest-text-muted"] = k(D(g, f, 0, V), f, z, Math.max(p, Math.sqrt(B * p)), u), E["--tempest-text-subtle"] = k(D(g, f, 0, V), f, [
|
|
162
|
+
P,
|
|
163
|
+
F,
|
|
164
|
+
R
|
|
165
|
+
], p, u);
|
|
166
|
+
let H = {
|
|
167
|
+
...n(u),
|
|
168
|
+
h: g.h
|
|
169
|
+
};
|
|
170
|
+
E["--tempest-primary"] = u, E["--tempest-primary-hover"] = D(H, f, -.05, g.c * .25), E["--tempest-primary-active"] = D(H, f, -.1, g.c * .3), E["--tempest-primary-foreground"] = e, E["--tempest-text-on-primary"] = e;
|
|
171
|
+
let [U, W] = M(g, f, A[d], u);
|
|
172
|
+
E["--tempest-primary-soft"] = U, E["--tempest-primary-soft-hover"] = W, E["--tempest-primary-on-soft"] = k(U, f, [U, W], p, u);
|
|
173
|
+
let G = k(e, f, z, h, u);
|
|
174
|
+
E["--tempest-focus-ring-color"] = G, E["--tempest-selected-indicator"] = G;
|
|
175
|
+
let K = t(r.primary, d, { anchor: !1 });
|
|
176
|
+
for (let [e, t] of Object.entries(K)) E[`--tempest-primary-${e}`] = t;
|
|
177
|
+
for (let e of c) {
|
|
178
|
+
let n = t(r.statuses?.[e] ?? x[e], d);
|
|
179
|
+
l(E, e, n, d), E[`--tempest-${e}`] = k(E[`--tempest-${e}`], f, z, p, u), e === "danger" && (E["--tempest-danger-hover"] = n[E["--tempest-danger-on-solid"] === "#ffffff" ? d === "dark" ? 400 : 700 : d === "dark" ? 600 : 500]);
|
|
180
|
+
}
|
|
181
|
+
(r.chart?.length ? r.chart : S[d]).forEach((e, t) => {
|
|
182
|
+
E[`--tempest-chart-${t + 1}`] = k(e, f, [
|
|
183
|
+
P,
|
|
184
|
+
F,
|
|
185
|
+
R
|
|
186
|
+
], m, u);
|
|
187
|
+
});
|
|
188
|
+
let q = s(r.chart?.[0] ?? r.primary), J = r.statuses?.danger ? s(r.statuses.danger) : (q + 180) % 360;
|
|
189
|
+
o(q, d).forEach((e, t) => {
|
|
190
|
+
E[`--tempest-chart-sequential-${t + 1}`] = e;
|
|
191
|
+
});
|
|
192
|
+
let Y = a({
|
|
193
|
+
coolHue: q,
|
|
194
|
+
warmHue: J,
|
|
195
|
+
mid: L,
|
|
196
|
+
mode: d
|
|
197
|
+
});
|
|
198
|
+
[
|
|
199
|
+
...Y.cool,
|
|
200
|
+
Y.mid,
|
|
201
|
+
...Y.warm
|
|
202
|
+
].forEach((e, t) => {
|
|
203
|
+
E[`--tempest-chart-diverging-${t + 1}`] = e;
|
|
204
|
+
}), E["--tempest-chart-grid"] = E["--tempest-border"], E["--tempest-chart-axis"] = E["--tempest-text-subtle"];
|
|
205
|
+
let X = [
|
|
206
|
+
P,
|
|
207
|
+
F,
|
|
208
|
+
N(F, u, .1)
|
|
209
|
+
];
|
|
210
|
+
C.forEach((e, t) => {
|
|
211
|
+
E[`--tempest-code-${e}`] = k(w[d][t], f, X, p, u);
|
|
212
|
+
});
|
|
213
|
+
for (let [e, t] of Object.entries(T[d])) E[`--tempest-shadow-${e}`] = t;
|
|
214
|
+
return {
|
|
215
|
+
tokens: E,
|
|
216
|
+
scheme: d,
|
|
217
|
+
glow: R
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function F(e, t) {
|
|
221
|
+
let n = (t) => e[t], r = [
|
|
222
|
+
n("--tempest-bg"),
|
|
223
|
+
n("--tempest-surface"),
|
|
224
|
+
n("--tempest-surface-2"),
|
|
225
|
+
n("--tempest-surface-3")
|
|
226
|
+
], i = n("--tempest-primary-foreground"), a = [
|
|
227
|
+
O(n("--tempest-text"), [...r, t]) / g,
|
|
228
|
+
O(n("--tempest-text-muted"), [...r, t]) / f,
|
|
229
|
+
O(n("--tempest-text-subtle"), [...r.slice(0, 2), t]) / f,
|
|
230
|
+
O(n("--tempest-focus-ring-color"), [...r, t]) / m,
|
|
231
|
+
O(i, [
|
|
232
|
+
n("--tempest-primary"),
|
|
233
|
+
n("--tempest-primary-hover"),
|
|
234
|
+
n("--tempest-primary-active")
|
|
235
|
+
]) / f
|
|
236
|
+
];
|
|
237
|
+
return Math.min(...a) - 1;
|
|
238
|
+
}
|
|
239
|
+
function I(e) {
|
|
240
|
+
let n = t(e.primary, "light"), r = null, i = -Infinity;
|
|
241
|
+
for (let t of _) {
|
|
242
|
+
let a = P(n[t], e), o = F(a.tokens, a.glow);
|
|
243
|
+
if (o > i && (r = {
|
|
244
|
+
tokens: a.tokens,
|
|
245
|
+
scheme: a.scheme,
|
|
246
|
+
step: t
|
|
247
|
+
}, i = o), o >= 0) break;
|
|
248
|
+
}
|
|
249
|
+
let a = r;
|
|
250
|
+
return a.rules = d(Object.keys(a.tokens), e.selector ?? "[data-tempest-tone=\"inverse\"]", e.page ?? u), a;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
export { S as DEFAULT_CHART_COLORS, w as DEFAULT_CODE_COLORS, x as DEFAULT_STATUS_COLORS, I as createInverseSurface };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=inverse-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-surface.js","names":[],"sources":["../../src/theme/inverse-surface.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines — the inverse surface is a whole scheme: surfaces,\n * text, the action color, focus, selection, statuses, charts and syntax colors,\n * each derived and then measured against the brand fill it sits on. Splitting\n * the derivation from the table it is measured against is how the two drift.\n */\n/**\n * Inverse surface: the token set for a section painted in the brand color —\n * a hero, a call-to-action band, a footer — so the components inside it invert\n * instead of inheriting the page's tokens.\n *\n * Every value is derived from the brand and measured against the fill it will\n * sit on, the same way {@link createTheme} measures the page schemes. Overriding\n * eight tokens by hand (what #409 had to do) leaves the rest of the scheme on\n * the page's values: measured over a navy `#1e2a5a`, the inherited\n * `--tempest-text-subtle` lands at 2.75:1, `--tempest-danger` at 2.12:1, the\n * selected indicator at 2.01:1, and a `Card` puts white text on\n * `--tempest-surface` at 1.05:1.\n */\nimport {\n contrastRatio,\n createColorScale,\n hexToOklch,\n oklchToHex,\n readableForeground,\n type ColorScale,\n type Oklch,\n type ScaleStep,\n} from \"./color\";\nimport { buildDivergingRamp, buildRamp, hueOf } from \"./data-viz-ramps\";\nimport {\n INVERSE_SELECTOR,\n type InverseScheme,\n type InverseSurface,\n type InverseSurfaceOptions,\n} from \"./inverse-render\";\nimport { DEFAULT_PAGE_SELECTORS, defaultToneRules } from \"./inverse-restore\";\nimport { THEME_STATUSES, writeStatus, type ThemeStatus } from \"./status-tokens\";\n\nexport { INVERSE_SELECTOR, renderInverseSurface } from \"./inverse-render\";\nexport { DEFAULT_TONE_SELECTOR } from \"./inverse-restore\";\nexport type {\n InverseScheme,\n InverseSurface,\n InverseSurfaceGenerator,\n InverseSurfaceOptions,\n PageSelectors,\n} from \"./inverse-render\";\n\n/** WCAG 2.x AA floor for body text. */\nconst AA_TEXT = 4.5;\n\n/**\n * What text is fitted to, rather than the floor itself.\n *\n * The margin the SDK's dark theme keeps on `--tempest-text-subtle` (4.79 over its\n * surface): a value solved to exactly 4.5 turns the next rounding into a failure.\n */\nconst TEXT_TARGET = 4.75;\n\n/** WCAG 2.2 SC 1.4.11 floor for a non-text indicator. */\nconst INDICATOR_FLOOR = 3;\n\n/**\n * What the focus ring and the selected indicator are fitted to.\n *\n * Well above the 3:1 floor on purpose: the SDK's own rings keep 5.40:1 (dark)\n * and 5.50:1 (light) worst case, because a ring travels onto surfaces nobody\n * validated it against.\n */\nconst RING_TARGET = 4.5;\n\n/**\n * The smallest contrast the ink must keep — on the fill, the surfaces and the\n * glow — before the fill is accepted.\n *\n * AA (4.5) is not enough here, because the surface has three text levels — text,\n * muted and subtle — and all three must clear AA. With text at 4.83:1 (white on\n * the default `#0066ff`) the three collapse into one color. 7:1 (AAA) leaves room\n * for muted to sit visibly between text and subtle.\n */\nconst MIN_TEXT_RATIO = 7;\n\n/**\n * Fill candidates, nearest the brand first, darker before lighter on a tie.\n *\n * `500` is the brand itself and wins whenever it can carry the scheme. When it\n * cannot — a mid-tone brand such as `#0066ff`, where white measures 4.83:1 —\n * the walk moves one step at a time, so the section stays as close to the brand\n * as the measurement allows.\n *\n * Measuring the glow is what most of the walking pays for: against the flat\n * fill and the surfaces alone, 9 of the 14 test brands keep their `500`; with\n * the glow, 6 do. The three that move (`#8100D7`, `#22d3ee`, `#14b8a6`) are the\n * ones whose subtle text would fail on a lifted region of their own band.\n */\nconst FILL_CANDIDATES: readonly ScaleStep[] = [500, 600, 400, 700, 300, 800, 200, 900];\n\n/**\n * Lightness offsets from the fill, per scheme.\n *\n * The sizes are the SDK's own, measured in OKLCH: the dark theme's surfaces sit\n * 0.046, 0.094 and 0.140 from `#0b0d12`, its borders 0.155 and 0.222; the light\n * theme's surfaces sit 0.018, 0.037 and 0.073 from white, its borders 0.073 and\n * 0.128.\n *\n * The direction is not the SDK's. On the page, raised surfaces move toward the\n * ink, which costs nothing there: the page fill is near-white or near-black, so\n * the ink keeps 13:1 or more on the third surface. A brand fill sits mid-axis,\n * and moving toward the ink spends exactly the contrast the text needs. Measured\n * across the fourteen brands of the contrast test, every text level held to AA\n * on every surface and on the glow ({@link GLOW_OFFSET}):\n *\n * | surfaces move | brands keeping their own `500` | where `#8100D7` / `#4f46e5` land |\n * | --- | --- | --- |\n * | toward the ink | 6 of 14 | `800` / `800` |\n * | away from the ink | 6 of 14 | `700` / `700` |\n *\n * Never worse and one step nearer the brand for the purples, and with every\n * surface carrying the ink at least as well as the fill does.\n *\n * So surfaces move away from the ink — a card in a navy band is a deeper navy,\n * one in a yellow band a paler yellow — and every surface then carries the ink\n * at least as well as the fill does. Borders still move toward the ink, since a\n * border has to separate from the fill and the surfaces alike.\n */\nconst OFFSETS: Record<\n InverseScheme,\n { surfaces: readonly [number, number, number]; border: number; borderStrong: number }\n> = {\n dark: { surfaces: [0.046, 0.094, 0.14], border: 0.155, borderStrong: 0.222 },\n light: { surfaces: [0.018, 0.037, 0.073], border: 0.073, borderStrong: 0.128 },\n};\n\n/**\n * How far toward the ink a region of the band may lift and still be measured.\n *\n * A brand section is rarely one flat color: the landing that opened #409 lays a\n * radial glow of `#1f3f8f` at 55% over its navy `#03184b`, which lifts the\n * ground by 0.09 in OKLCH lightness, and a hover tint does the same. Text fitted\n * to the flat fill alone failed there — subtle measured 3.64:1 on that glow. So\n * every text and indicator token is also fitted against the fill lifted by this\n * much; darker variations (the landing's `#020f30` footer) only add contrast.\n */\nconst GLOW_OFFSET = 0.1;\n\n/** Text ink per scheme — the SDK's own extremes. */\nconst INK: Record<InverseScheme, string> = { dark: \"#ffffff\", light: \"#101828\" };\n\n/**\n * The SDK's default status colors, used when a theme names none.\n *\n * Ported from `src/styles/colors.css` (`--tempest-*-solid` in the light block),\n * and pinned by a test that reads that file.\n */\nexport const DEFAULT_STATUS_COLORS: Record<ThemeStatus, string> = {\n success: \"#16a34a\",\n warning: \"#d97706\",\n danger: \"#dc2626\",\n info: \"#2563eb\",\n};\n\n/**\n * The SDK's categorical chart colors, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-chart-1` … `-8`), pinned by a\n * test that reads that file. Used as the starting hue for each slot, then fitted\n * to the inverse fill.\n */\nexport const DEFAULT_CHART_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\"#2563eb\", \"#16a34a\", \"#f59e0b\", \"#7c3aed\", \"#ec4899\", \"#06b6d4\", \"#ea580c\", \"#0f766e\"],\n dark: [\"#60a5fa\", \"#4ade80\", \"#fbbf24\", \"#a78bfa\", \"#f472b6\", \"#22d3ee\", \"#fb923c\", \"#2dd4bf\"],\n};\n\n/** Names of the `CodeBlock` syntax tokens, in `colors.css` order. */\nconst CODE_TOKENS = [\n \"comment\",\n \"punctuation\",\n \"string\",\n \"number\",\n \"keyword\",\n \"literal\",\n \"function\",\n \"tag\",\n \"attribute\",\n \"property\",\n] as const;\n\n/**\n * The SDK's syntax colors, per scheme, in {@link CODE_TOKENS} order.\n *\n * Ported from `src/styles/colors.css` (`--tempest-code-*`), pinned by a test\n * that reads that file. Used as the starting hue, then fitted to the inverse\n * code grounds.\n */\nexport const DEFAULT_CODE_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\n \"#5f666e\",\n \"#5d6671\",\n \"#327243\",\n \"#9d5035\",\n \"#625baf\",\n \"#9f4c4f\",\n \"#1a6c94\",\n \"#974d72\",\n \"#127171\",\n \"#127171\",\n ],\n dark: [\n \"#838b93\",\n \"#818b95\",\n \"#589866\",\n \"#c57558\",\n \"#8580d8\",\n \"#c87172\",\n \"#2893c6\",\n \"#c07197\",\n \"#349897\",\n \"#349897\",\n ],\n};\n\n/**\n * The SDK's elevation shadows, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-shadow-*`). A light-ink fill\n * takes the dark theme's heavier shadows, since a faint shadow vanishes on it.\n * The dark block does not override `--tempest-shadow-inner`, so the dark row\n * carries the light value it inherits.\n */\nconst SHADOWS: Record<InverseScheme, Record<string, string>> = {\n light: {\n xs: \"0 1px 2px rgba(15, 23, 42, 0.04)\",\n sm: \"0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)\",\n lg: \"0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)\",\n xl: \"0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n dark: {\n xs: \"0 1px 2px rgba(0, 0, 0, 0.3)\",\n sm: \"0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)\",\n md: \"0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)\",\n lg: \"0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)\",\n xl: \"0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n};\n\n/** Lightness step used when fitting a color toward the ink. */\nconst FIT_STEP = 0.005;\n\n/**\n * Move a color along the lightness axis toward (positive `delta`) or away from\n * the ink, keeping its hue.\n *\n * @param base - The color to move, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param delta - How far to move, in OKLCH lightness.\n * @param chroma - Chroma of the result; defaults to the base's.\n * @returns The moved color as hex, gamut-mapped.\n */\nfunction shift(base: Oklch, direction: 1 | -1, delta: number, chroma: number = base.c): string {\n const l = Math.min(1, Math.max(0, base.l + direction * delta));\n return oklchToHex({ l, c: chroma, h: base.h });\n}\n\n/** Weakest contrast of `color` against every ground. */\nfunction worst(color: string, grounds: readonly string[]): number {\n return Math.min(...grounds.map((ground) => contrastRatio(color, ground)));\n}\n\n/**\n * Walk a color toward the ink until it clears `floor` against every ground.\n *\n * Hue and chroma are kept, so a danger stays red and a keyword stays violet;\n * only lightness moves, and only as far as the measurement asks. When the walk\n * reaches the end of the lightness axis without clearing, the ink itself is\n * returned — it is the most contrasting color the scheme has.\n *\n * @param start - Where to start, as hex.\n * @param direction - `1` when the ink is lighter than the grounds, `-1` otherwise.\n * @param grounds - Every background the color will sit on.\n * @param floor - The ratio to clear against all of them.\n * @param ink - Fallback when nothing on the walk clears.\n * @returns The first color on the walk that clears, else `ink`.\n */\nfunction fitToward(\n start: string,\n direction: 1 | -1,\n grounds: readonly string[],\n floor: number,\n ink: string,\n): string {\n const base = hexToOklch(start);\n for (let delta = 0; delta <= 1; delta += FIT_STEP) {\n const candidate = shift(base, direction, delta);\n if (worst(candidate, grounds) >= floor) return candidate;\n if ((direction === 1 && base.l + delta >= 1) || (direction === -1 && base.l - delta <= 0)) {\n break;\n }\n }\n return ink;\n}\n\n/**\n * How far the soft tint sits from the fill, per scheme; the hover tint sits\n * {@link SOFT_HOVER_FACTOR} times as far.\n */\nconst SOFT_OFFSET: Record<InverseScheme, number> = { dark: 0.07, light: 0.05 };\n\n/** Distance of the soft hover tint, relative to the soft tint's. */\nconst SOFT_HOVER_FACTOR = 1.6;\n\n/**\n * The soft tint and its hover, lifted toward the ink only as far as the ink\n * still reads on both.\n *\n * A tint toward the ink is what reads as \"highlighted\" on a fill, and it is also\n * what eats the ink's contrast: on the `#8100D7` fill, the full offset left white\n * at 4.42:1 on the hover tint. So the offset shrinks until the ink clears\n * {@link TEXT_TARGET} on both, and when even a sliver cannot — the fill gives the\n * ink no room — the tints move away from the ink instead, like the surfaces.\n *\n * @param base - The fill, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param offset - The preferred distance of the soft tint.\n * @param ink - The scheme's text ink.\n * @returns The soft tint and its hover, as hex.\n */\nfunction softTints(base: Oklch, direction: 1 | -1, offset: number, ink: string): [string, string] {\n for (let delta = offset; delta > FIT_STEP; delta -= FIT_STEP) {\n const tints: [string, string] = [\n shift(base, direction, delta),\n shift(base, direction, delta * SOFT_HOVER_FACTOR),\n ];\n if (worst(ink, tints) >= TEXT_TARGET) return tints;\n }\n return [shift(base, direction, -offset), shift(base, direction, -offset * SOFT_HOVER_FACTOR)];\n}\n\n/** Mix `top` over `bottom` at `amount`, the way `color-mix(in srgb, …)` composites. */\nfunction mix(bottom: string, top: string, amount: number): string {\n const parse = (hex: string): number[] =>\n [1, 3, 5].map((index) => Number.parseInt(hex.slice(index, index + 2), 16));\n const [a, b] = [parse(bottom), parse(top)];\n const channels = a.map((channel, index) =>\n Math.round(channel + ((b[index] as number) - channel) * amount),\n );\n return `#${channels.map((channel) => channel.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Derive the inverse scheme over one candidate fill.\n *\n * Text is three levels, like the page: the ink, then `muted` fitted to the\n * geometric mean of the ink's contrast and {@link TEXT_TARGET} (so it sits\n * visibly between the two), then `subtle` fitted to {@link TEXT_TARGET} on\n * `bg` and `surface` — the same pairs the SDK holds its own `text-subtle` to.\n *\n * The action color is the ink itself: a white button on a navy band, labelled in\n * the fill. Hover and active step back toward the fill, because the ink is\n * already the end of the axis and has nowhere further to go.\n *\n * `--tempest-danger-hover` steps toward the side that keeps `-on-solid`\n * readable: darker when the ink is white, lighter when it is dark. A fixed\n * direction cannot hold one ink over both fills — over the dark scheme's\n * `#dc2626` it measured 4.00:1 with the lighter hover.\n *\n * The ramp (`--tempest-primary-50` … `-900`) is emitted too, because `Tag` and\n * `Sidebar` pair raw steps (`100` under `700`). It is the scheme's unanchored\n * ramp, so that pair keeps the shape it has on the page.\n *\n * @param fill - The fill, as hex.\n * @param options - The brand description.\n * @returns The token map and the scheme it reads as.\n */\nfunction deriveOver(\n fill: string,\n options: InverseSurfaceOptions,\n): { tokens: Record<string, string>; scheme: InverseScheme; glow: string } {\n const ink = readableForeground(fill, INK.dark, INK.light);\n const scheme: InverseScheme = ink === INK.dark ? \"dark\" : \"light\";\n const direction: 1 | -1 = scheme === \"dark\" ? 1 : -1;\n const base = hexToOklch(fill);\n const offsets = OFFSETS[scheme];\n const tokens: Record<string, string> = {};\n\n const surfaces = [fill, ...offsets.surfaces.map((delta) => shift(base, direction, -delta))];\n const [bg, surface, surface2, surface3] = surfaces as [string, string, string, string];\n const glow = shift(base, direction, GLOW_OFFSET);\n const grounds = [...surfaces, glow];\n tokens[\"--tempest-bg\"] = bg;\n tokens[\"--tempest-surface\"] = surface;\n tokens[\"--tempest-surface-2\"] = surface2;\n tokens[\"--tempest-surface-3\"] = surface3;\n tokens[\"--tempest-border\"] = shift(base, direction, offsets.border);\n tokens[\"--tempest-border-strong\"] = shift(base, direction, offsets.borderStrong);\n\n const textWorst = worst(ink, grounds);\n const tint = base.c * 0.4;\n tokens[\"--tempest-text\"] = ink;\n tokens[\"--tempest-text-muted\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n grounds,\n Math.max(TEXT_TARGET, Math.sqrt(textWorst * TEXT_TARGET)),\n ink,\n );\n tokens[\"--tempest-text-subtle\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n [bg, surface, glow],\n TEXT_TARGET,\n ink,\n );\n\n const inkBase: Oklch = { ...hexToOklch(ink), h: base.h };\n tokens[\"--tempest-primary\"] = ink;\n tokens[\"--tempest-primary-hover\"] = shift(inkBase, direction, -0.05, base.c * 0.25);\n tokens[\"--tempest-primary-active\"] = shift(inkBase, direction, -0.1, base.c * 0.3);\n tokens[\"--tempest-primary-foreground\"] = fill;\n tokens[\"--tempest-text-on-primary\"] = fill;\n\n const [soft, softHover] = softTints(base, direction, SOFT_OFFSET[scheme], ink);\n tokens[\"--tempest-primary-soft\"] = soft;\n tokens[\"--tempest-primary-soft-hover\"] = softHover;\n tokens[\"--tempest-primary-on-soft\"] = fitToward(\n soft,\n direction,\n [soft, softHover],\n TEXT_TARGET,\n ink,\n );\n\n const ring = fitToward(fill, direction, grounds, RING_TARGET, ink);\n tokens[\"--tempest-focus-ring-color\"] = ring;\n tokens[\"--tempest-selected-indicator\"] = ring;\n\n const ramp: ColorScale = createColorScale(options.primary, scheme, { anchor: false });\n for (const [step, value] of Object.entries(ramp)) {\n tokens[`--tempest-primary-${step}`] = value;\n }\n\n for (const status of THEME_STATUSES) {\n const scale = createColorScale(\n options.statuses?.[status] ?? DEFAULT_STATUS_COLORS[status],\n scheme,\n );\n writeStatus(tokens, status, scale, scheme);\n tokens[`--tempest-${status}`] = fitToward(\n tokens[`--tempest-${status}`] as string,\n direction,\n grounds,\n TEXT_TARGET,\n ink,\n );\n if (status === \"danger\") {\n const whiteInk = tokens[\"--tempest-danger-on-solid\"] === \"#ffffff\";\n const darker: ScaleStep = scheme === \"dark\" ? 400 : 700;\n const lighter: ScaleStep = scheme === \"dark\" ? 600 : 500;\n tokens[\"--tempest-danger-hover\"] = scale[whiteInk ? darker : lighter];\n }\n }\n\n const chart = options.chart?.length ? options.chart : DEFAULT_CHART_COLORS[scheme];\n chart.forEach((color, index) => {\n tokens[`--tempest-chart-${index + 1}`] = fitToward(\n color,\n direction,\n [bg, surface, glow],\n INDICATOR_FLOOR,\n ink,\n );\n });\n const coolHue = hueOf(options.chart?.[0] ?? options.primary);\n const warmHue = options.statuses?.danger\n ? hueOf(options.statuses.danger)\n : (coolHue + 180) % 360;\n buildRamp(coolHue, scheme).forEach((value, index) => {\n tokens[`--tempest-chart-sequential-${index + 1}`] = value;\n });\n const diverging = buildDivergingRamp({ coolHue, warmHue, mid: surface3, mode: scheme });\n [...diverging.cool, diverging.mid, ...diverging.warm].forEach((value, index) => {\n tokens[`--tempest-chart-diverging-${index + 1}`] = value;\n });\n tokens[\"--tempest-chart-grid\"] = tokens[\"--tempest-border\"] as string;\n tokens[\"--tempest-chart-axis\"] = tokens[\"--tempest-text-subtle\"] as string;\n\n const codeGrounds = [bg, surface, mix(surface, ink, 0.1)];\n CODE_TOKENS.forEach((name, index) => {\n tokens[`--tempest-code-${name}`] = fitToward(\n DEFAULT_CODE_COLORS[scheme][index] as string,\n direction,\n codeGrounds,\n TEXT_TARGET,\n ink,\n );\n });\n\n for (const [name, value] of Object.entries(SHADOWS[scheme])) {\n tokens[`--tempest-shadow-${name}`] = value;\n }\n\n return { tokens, scheme, glow };\n}\n\n/**\n * The gates a candidate fill must clear before it is accepted.\n *\n * Text reaches {@link MIN_TEXT_RATIO} on every surface, every fitted text token\n * clears AA where it is used, the ring clears 3:1 on every surface, and the\n * action label clears AA on all three button states.\n *\n * @param tokens - A derived token map.\n * @param glow - The fill lifted by {@link GLOW_OFFSET}, measured alongside the surfaces.\n * @returns The weakest margin over its floor across all gates; `>= 0` passes.\n */\nfunction margin(tokens: Record<string, string>, glow: string): number {\n const read = (name: string): string => tokens[name] as string;\n const surfaces = [\n read(\"--tempest-bg\"),\n read(\"--tempest-surface\"),\n read(\"--tempest-surface-2\"),\n read(\"--tempest-surface-3\"),\n ];\n const label = read(\"--tempest-primary-foreground\");\n const checks: number[] = [\n worst(read(\"--tempest-text\"), [...surfaces, glow]) / MIN_TEXT_RATIO,\n worst(read(\"--tempest-text-muted\"), [...surfaces, glow]) / AA_TEXT,\n worst(read(\"--tempest-text-subtle\"), [...surfaces.slice(0, 2), glow]) / AA_TEXT,\n worst(read(\"--tempest-focus-ring-color\"), [...surfaces, glow]) / INDICATOR_FLOOR,\n worst(label, [\n read(\"--tempest-primary\"),\n read(\"--tempest-primary-hover\"),\n read(\"--tempest-primary-active\"),\n ]) / AA_TEXT,\n ];\n return Math.min(...checks) - 1;\n}\n\n/**\n * Build the inverse surface for a brand.\n *\n * The fill is the brand's own `500` whenever it can carry the scheme, and\n * otherwise the nearest ramp step that can (see {@link FILL_CANDIDATES}). Whether\n * the surface reads light-on-dark or dark-on-light follows the fill, so a yellow\n * brand gets dark ink and a navy one white — the same pick `createTheme` makes\n * for `--tempest-primary-foreground`.\n *\n * The values are literal colors, not references to the page's ramp, so the\n * section paints the same in the light and the dark page scheme: the brand is\n * the brand in both.\n *\n * The result also carries the rules that let a region inside the surface go\n * back to the page's tokens (`data-tempest-tone=\"default\"`), written for the\n * selectors in `options`.\n *\n * @param options - The brand, plus the status and chart colors the theme names\n * and the selectors the surface and the page are written under.\n * @returns The token map, the scheme it reads as, the fill step used and the\n * default-tone rules.\n */\nexport function createInverseSurface(options: InverseSurfaceOptions): InverseSurface {\n const ramp = createColorScale(options.primary, \"light\");\n let best: InverseSurface | null = null;\n let bestMargin = Number.NEGATIVE_INFINITY;\n for (const step of FILL_CANDIDATES) {\n const derived = deriveOver(ramp[step], options);\n const measured = margin(derived.tokens, derived.glow);\n if (measured > bestMargin) {\n best = { tokens: derived.tokens, scheme: derived.scheme, step };\n bestMargin = measured;\n }\n if (measured >= 0) break;\n }\n const surface = best as InverseSurface;\n surface.rules = defaultToneRules(\n Object.keys(surface.tokens),\n options.selector ?? INVERSE_SELECTOR,\n options.page ?? DEFAULT_PAGE_SELECTORS,\n );\n return surface;\n}\n"],"mappings":";;;;;;AAkDA,IAAM,IAAU,KAQV,IAAc,MAGd,IAAkB,GASlB,IAAc,KAWd,IAAiB,GAejB,IAAwC;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG,GA8B/E,IAGF;CACA,MAAM;EAAE,UAAU;GAAC;GAAO;GAAO;EAAI;EAAG,QAAQ;EAAO,cAAc;CAAM;CAC3E,OAAO;EAAE,UAAU;GAAC;GAAO;GAAO;EAAK;EAAG,QAAQ;EAAO,cAAc;CAAM;AACjF,GAYM,IAAc,IAGd,IAAqC;CAAE,MAAM;CAAW,OAAO;AAAU,GAQlE,IAAqD;CAC9D,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;AACV,GASa,IAAiE;CAC1E,OAAO;EAAC;EAAW;EAAW;EAAW;EAAW;EAAW;EAAW;EAAW;CAAS;CAC9F,MAAM;EAAC;EAAW;EAAW;EAAW;EAAW;EAAW;EAAW;EAAW;CAAS;AACjG,GAGM,IAAc;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,GASa,IAAgE;CACzE,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,MAAM;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ,GAUM,IAAyD;CAC3D,OAAO;EACH,IAAI;EACJ,IAAI;EACJ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AC,IAAI;EACrD,EAAM,EAAK,sBAAsB,GAAG,CAAC,GAAG,GAAU,CAAI,CAAC,IAAI;EAC3D,EAAM,EAAK,uBAAuB,GAAG,CAAC,GAAG,EAAS,MAAM,GAAG,CAAC,GAAG,CAAI,CAAC,IAAI;EACxE,EAAM,EAAK,4BAA4B,GAAG,CAAC,GAAG,GAAU,CAAI,CAAC,IAAI;EACjE,EAAM,GAAO;GACT,EAAK,mBAAmB;GACxB,EAAK,yBAAyB;GAC9B,EAAK,0BAA0B;EACnC,CAAC,IAAI;CACT;CACA,OAAO,KAAK,IAAI,GAAG,CAAM,IAAI;AACjC;AAwBA,SAAgB,EAAqB,GAAgD;CACjF,IAAM,IAAO,EAAiB,EAAQ,SAAS,OAAO,GAClD,IAA8B,MAC9B,IAAa;CACjB,KAAK,IAAM,KAAQ,GAAiB;EAChC,IAAM,IAAU,EAAW,EAAK,IAAO,CAAO,GACxC,IAAW,EAAO,EAAQ,QAAQ,EAAQ,IAAI;EAKpD,IAJI,IAAW,MACX,IAAO;GAAE,QAAQ,EAAQ;GAAQ,QAAQ,EAAQ;GAAQ;EAAK,GAC9D,IAAa,IAEb,KAAY,GAAG;CACvB;CACA,IAAM,IAAU;CAMhB,OALA,EAAQ,QAAQ,EACZ,OAAO,KAAK,EAAQ,MAAM,GAC1B,EAAQ,YAAA,mCACR,EAAQ,QAAQ,CACpB,GACO;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./color.cjs");var t=[`success`,`warning`,`danger`,`info`],n=`#1f0606`;function r(t,r,i,a){a===`light`?(t[`--tempest-${r}`]=i[700],t[`--tempest-${r}-fg`]=i[800],t[`--tempest-${r}-bg`]=i[50],t[`--tempest-${r}-border`]=i[200],t[`--tempest-${r}-solid`]=i[600],t[`--tempest-${r}-on-solid`]=e.readableForeground(i[600],`#ffffff`,n)):(t[`--tempest-${r}`]=i[700],t[`--tempest-${r}-fg`]=i[700],t[`--tempest-${r}-bg`]=i[50],t[`--tempest-${r}-border`]=i[200],t[`--tempest-${r}-solid`]=i[500],t[`--tempest-${r}-on-solid`]=e.readableForeground(i[500],`#ffffff`,n))}exports.ON_SOLID_INK=n,exports.THEME_STATUSES=t,exports.writeStatus=r;
|
|
2
|
+
//# sourceMappingURL=status-tokens.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-tokens.cjs","names":[],"sources":["../../src/theme/status-tokens.ts"],"sourcesContent":["/**\n * Status token families, shared by the page schemes {@link createTheme} emits and\n * by the inverse surface.\n */\nimport { readableForeground, type ColorScale } from \"./color\";\n\n/** Status token families that {@link createTheme} can regenerate. */\nexport type ThemeStatus = \"success\" | \"warning\" | \"danger\" | \"info\";\n\n/** The four status families, in the order they are emitted. */\nexport const THEME_STATUSES: readonly ThemeStatus[] = [\"success\", \"warning\", \"danger\", \"info\"];\n\n/**\n * The dark ink for content sitting on a saturated fill.\n *\n * Near-black tinted toward warm rather than pure black, matching the value\n * `colors.css` uses for the same job: it reads as part of the swatch instead of\n * a hole punched in it.\n */\nexport const ON_SOLID_INK = \"#1f0606\";\n\n/**\n * Emit one status family (`--tempest-danger`, `-fg`, `-bg`, `-border`, `-solid`).\n *\n * `-fg` is the text shade over `-bg`, so it has to cross the ramp in opposite\n * directions per scheme; `-solid` stays the saturated fill used by badges.\n *\n * `-on-solid` is derived from the `-solid` this call just emitted, rather than\n * left to fall through. Falling through was the bug: the SDK's own\n * `-on-solid` values are measured against the SDK's own fills, so a brand whose\n * `danger-600` lands light kept white ink over it and nothing said so. The\n * generated neutral hit exactly that — white over a generated `gray-700` of\n * `#a8b2c6` measures 2.13:1.\n *\n * @param tokens - The token map for this scheme, written in place.\n * @param name - Which status family.\n * @param scale - The generated ramp for that status, in the scheme's direction.\n * @param scheme - Which scheme is being emitted.\n */\nexport function writeStatus(\n tokens: Record<string, string>,\n name: ThemeStatus,\n scale: ColorScale,\n scheme: \"light\" | \"dark\",\n): void {\n if (scheme === \"light\") {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[800];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[600];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[600],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n } else {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[700];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[500];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[500],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n }\n}\n"],"mappings":"+BAUA,IAAa,EAAyC,CAAC,UAAW,UAAW,SAAU,MAAM,EAShF,EAAe,UAoB5B,SAAgB,EACZ,EACA,EACA,EACA,EACI,CACA,IAAW,SACX,EAAO,aAAa,KAAU,EAAM,KACpC,EAAO,aAAa,EAAK,MAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,MAAQ,EAAM,IACvC,EAAO,aAAa,EAAK,UAAY,EAAM,KAC3C,EAAO,aAAa,EAAK,SAAW,EAAM,KAC1C,EAAO,aAAa,EAAK,YAAc,EAAA,mBACnC,EAAM,KACN,UACA,CACJ,IAEA,EAAO,aAAa,KAAU,EAAM,KACpC,EAAO,aAAa,EAAK,MAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,MAAQ,EAAM,IACvC,EAAO,aAAa,EAAK,UAAY,EAAM,KAC3C,EAAO,aAAa,EAAK,SAAW,EAAM,KAC1C,EAAO,aAAa,EAAK,YAAc,EAAA,mBACnC,EAAM,KACN,UACA,CACJ,EAER"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readableForeground as e } from "./color.js";
|
|
2
|
+
//#region src/theme/status-tokens.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"success",
|
|
5
|
+
"warning",
|
|
6
|
+
"danger",
|
|
7
|
+
"info"
|
|
8
|
+
], n = "#1f0606";
|
|
9
|
+
function r(t, r, i, a) {
|
|
10
|
+
a === "light" ? (t[`--tempest-${r}`] = i[700], t[`--tempest-${r}-fg`] = i[800], t[`--tempest-${r}-bg`] = i[50], t[`--tempest-${r}-border`] = i[200], t[`--tempest-${r}-solid`] = i[600], t[`--tempest-${r}-on-solid`] = e(i[600], "#ffffff", n)) : (t[`--tempest-${r}`] = i[700], t[`--tempest-${r}-fg`] = i[700], t[`--tempest-${r}-bg`] = i[50], t[`--tempest-${r}-border`] = i[200], t[`--tempest-${r}-solid`] = i[500], t[`--tempest-${r}-on-solid`] = e(i[500], "#ffffff", n));
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as ON_SOLID_INK, t as THEME_STATUSES, r as writeStatus };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=status-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-tokens.js","names":[],"sources":["../../src/theme/status-tokens.ts"],"sourcesContent":["/**\n * Status token families, shared by the page schemes {@link createTheme} emits and\n * by the inverse surface.\n */\nimport { readableForeground, type ColorScale } from \"./color\";\n\n/** Status token families that {@link createTheme} can regenerate. */\nexport type ThemeStatus = \"success\" | \"warning\" | \"danger\" | \"info\";\n\n/** The four status families, in the order they are emitted. */\nexport const THEME_STATUSES: readonly ThemeStatus[] = [\"success\", \"warning\", \"danger\", \"info\"];\n\n/**\n * The dark ink for content sitting on a saturated fill.\n *\n * Near-black tinted toward warm rather than pure black, matching the value\n * `colors.css` uses for the same job: it reads as part of the swatch instead of\n * a hole punched in it.\n */\nexport const ON_SOLID_INK = \"#1f0606\";\n\n/**\n * Emit one status family (`--tempest-danger`, `-fg`, `-bg`, `-border`, `-solid`).\n *\n * `-fg` is the text shade over `-bg`, so it has to cross the ramp in opposite\n * directions per scheme; `-solid` stays the saturated fill used by badges.\n *\n * `-on-solid` is derived from the `-solid` this call just emitted, rather than\n * left to fall through. Falling through was the bug: the SDK's own\n * `-on-solid` values are measured against the SDK's own fills, so a brand whose\n * `danger-600` lands light kept white ink over it and nothing said so. The\n * generated neutral hit exactly that — white over a generated `gray-700` of\n * `#a8b2c6` measures 2.13:1.\n *\n * @param tokens - The token map for this scheme, written in place.\n * @param name - Which status family.\n * @param scale - The generated ramp for that status, in the scheme's direction.\n * @param scheme - Which scheme is being emitted.\n */\nexport function writeStatus(\n tokens: Record<string, string>,\n name: ThemeStatus,\n scale: ColorScale,\n scheme: \"light\" | \"dark\",\n): void {\n if (scheme === \"light\") {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[800];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[600];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[600],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n } else {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[700];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[500];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[500],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n }\n}\n"],"mappings":";;AAUA,IAAa,IAAyC;CAAC;CAAW;CAAW;CAAU;AAAM,GAShF,IAAe;AAoB5B,SAAgB,EACZ,GACA,GACA,GACA,GACI;CACJ,AAAI,MAAW,WACX,EAAO,aAAa,OAAU,EAAM,MACpC,EAAO,aAAa,EAAK,QAAQ,EAAM,MACvC,EAAO,aAAa,EAAK,QAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,YAAY,EAAM,MAC3C,EAAO,aAAa,EAAK,WAAW,EAAM,MAC1C,EAAO,aAAa,EAAK,cAAc,EACnC,EAAM,MACN,WACA,CACJ,MAEA,EAAO,aAAa,OAAU,EAAM,MACpC,EAAO,aAAa,EAAK,QAAQ,EAAM,MACvC,EAAO,aAAa,EAAK,QAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,YAAY,EAAM,MAC3C,EAAO,aAAa,EAAK,WAAW,EAAM,MAC1C,EAAO,aAAa,EAAK,cAAc,EACnC,EAAM,MACN,WACA,CACJ;AAER"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("./tempest-icons.cjs"),t=require("./tempest-vitest.cjs");let n=require("node:path"),r=require("vite");function i(e){let t={};for(let[n,r]of Object.entries(e))t[n]=typeof r==`string`?{target:r,changeOrigin:!0}:r;return t}function a(){return import(`@vitejs/plugin-react`).then(e=>e.default())}function o(o={}){let{srcDir:s=`src`,port:c=5173,host:l=`127.0.0.1`,open:u=!1,proxy:d,alias:f={},plugins:p=[],icons:m=!0,overrides:h={}}=o,g=h,_=m?[e.tempestIcons({dir:s,...typeof m==`object`?m:{}})]:[],v={plugins:[a(),..._,t.tempestVitest(),...p],resolve:{alias:{"@":(0,n.resolve)(process.cwd(),s),...f}},server:{port:c,host:l,open:u,...d?{proxy:i(d)}:{}}},y={...v,...g,plugins:[...v.plugins??[],...g.plugins??[]],resolve:{...v.resolve,...g.resolve},server:{...v.server,...g.server}};return(0,r.defineConfig)(y)}exports.createViteConfig=o;
|
|
2
2
|
//# sourceMappingURL=create-vite-config.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-vite-config.cjs","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { ProxyOptions, UserConfig } from \"vite\";\
|
|
1
|
+
{"version":3,"file":"create-vite-config.cjs","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { PluginOption, ProxyOptions, UserConfig } from \"vite\";\n\nimport { tempestIcons, type TempestIconsOptions } from \"./tempest-icons\";\nimport { tempestVitest } from \"./tempest-vitest\";\n\n/**\n * A Vite proxy entry: either a target URL string (expanded to\n * `{ target, changeOrigin: true }`) or a raw Vite `ProxyOptions` object.\n */\nexport type ProxyEntry = string | Record<string, unknown>;\n\nexport interface CreateViteConfigOptions {\n /**\n * Source directory aliased to `@`, relative to the project root.\n * Default: `\"src\"` (so `@/components/Button` → `<root>/src/components/Button`).\n */\n srcDir?: string;\n /** Dev server port. Default: `5173`. */\n port?: number;\n /** Dev server host. Default: `\"127.0.0.1\"`. */\n host?: string | boolean;\n /** Open the browser on `dev` start. Default: `false`. */\n open?: boolean;\n /**\n * Dev proxy table. String values are expanded to\n * `{ target, changeOrigin: true }`; objects are passed through untouched.\n *\n * @example { \"/api\": \"http://127.0.0.1:8000\" }\n */\n proxy?: Record<string, ProxyEntry>;\n /** Extra path aliases merged on top of the default `@` → src alias. */\n alias?: Record<string, string>;\n /** Vite plugins appended after `@vitejs/plugin-react`. */\n plugins?: unknown[];\n /**\n * The `tempestIcons()` plugin, which generates `virtual:tempest-icons` from the\n * icon slugs your source mentions. On by default — it only ever removes\n * requests. Pass `false` to leave it out, or an options object to configure the\n * scan.\n */\n icons?: boolean | TempestIconsOptions;\n /**\n * Arbitrary Vite config (a `UserConfig` object) deep-merged last, for\n * escape-hatch overrides (build target, define, extra `server` keys, …).\n */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * The resulting Vite config object. Typed loosely so the SDK's published\n * declarations stay free of `vite`'s internal types; assign it straight to a\n * `vite.config.ts` default export.\n */\nexport type TempestViteConfig = Record<string, unknown>;\n\nfunction normalizeProxy(proxy: Record<string, ProxyEntry>): Record<string, ProxyOptions> {\n const out: Record<string, ProxyOptions> = {};\n for (const [path, value] of Object.entries(proxy)) {\n out[path] =\n typeof value === \"string\"\n ? { target: value, changeOrigin: true }\n : (value as ProxyOptions);\n }\n return out;\n}\n\n/**\n * Load `@vitejs/plugin-react` when a config is built, not when this module loads.\n *\n * The plugin is an optional peer, and every helper of `tempest-react-sdk/vite`\n * ships through one barrel. A top-level import made the whole barrel require it:\n * a project without the React plugin could not load a config importing only\n * `tempestVitest` or `tempestCsp` (`ERR_MODULE_NOT_FOUND`, #401). Vite resolves a\n * promise in `plugins` before using it, so {@link createViteConfig} stays\n * synchronous and only it needs the peer.\n *\n * @returns The React plugin, once its module has loaded.\n */\nfunction reactPlugin(): Promise<PluginOption> {\n return import(\"@vitejs/plugin-react\").then((module) => module.default());\n}\n\n/**\n * Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`\n * plugin, the `@` → `src` import alias, sane dev-server defaults and\n * {@link tempestVitest}, which lets a Vitest suite import the SDK — so a\n * consuming app's `vite.config.ts` is a single call instead of repeated\n * boilerplate. Everything is overridable.\n *\n * Import it from the dedicated Node entry point:\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({\n * proxy: { \"/api\": \"http://127.0.0.1:8000\" },\n * });\n */\nexport function createViteConfig(options: CreateViteConfigOptions = {}): TempestViteConfig {\n const {\n srcDir = \"src\",\n port = 5173,\n host = \"127.0.0.1\",\n open = false,\n proxy,\n alias = {},\n plugins = [],\n icons = true,\n overrides = {},\n } = options;\n\n const overridesConfig = overrides as UserConfig;\n const iconsPlugin = icons\n ? [tempestIcons({ dir: srcDir, ...(typeof icons === \"object\" ? icons : {}) })]\n : [];\n\n const base: UserConfig = {\n plugins: [\n reactPlugin(),\n ...iconsPlugin,\n tempestVitest(),\n ...plugins,\n ] as UserConfig[\"plugins\"],\n resolve: {\n alias: {\n \"@\": resolve(process.cwd(), srcDir),\n ...alias,\n },\n },\n server: {\n port,\n host,\n open,\n ...(proxy ? { proxy: normalizeProxy(proxy) } : {}),\n },\n };\n\n const merged: UserConfig = {\n ...base,\n ...overridesConfig,\n plugins: [...(base.plugins ?? []), ...(overridesConfig.plugins ?? [])],\n resolve: { ...base.resolve, ...overridesConfig.resolve },\n server: { ...base.server, ...overrid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 -2,9 +2,8 @@ import { tempestIcons as e } from "./tempest-icons.js";
|
|
|
2
2
|
import { tempestVitest as t } from "./tempest-vitest.js";
|
|
3
3
|
import { resolve as n } from "node:path";
|
|
4
4
|
import { defineConfig as r } from "vite";
|
|
5
|
-
import i from "@vitejs/plugin-react";
|
|
6
5
|
//#region src/vite/create-vite-config.ts
|
|
7
|
-
function
|
|
6
|
+
function i(e) {
|
|
8
7
|
let t = {};
|
|
9
8
|
for (let [n, r] of Object.entries(e)) t[n] = typeof r == "string" ? {
|
|
10
9
|
target: r,
|
|
@@ -12,13 +11,16 @@ function a(e) {
|
|
|
12
11
|
} : r;
|
|
13
12
|
return t;
|
|
14
13
|
}
|
|
14
|
+
function a() {
|
|
15
|
+
return import("@vitejs/plugin-react").then((e) => e.default());
|
|
16
|
+
}
|
|
15
17
|
function o(o = {}) {
|
|
16
18
|
let { srcDir: s = "src", port: c = 5173, host: l = "127.0.0.1", open: u = !1, proxy: d, alias: f = {}, plugins: p = [], icons: m = !0, overrides: h = {} } = o, g = h, _ = m ? [e({
|
|
17
19
|
dir: s,
|
|
18
20
|
...typeof m == "object" ? m : {}
|
|
19
21
|
})] : [], v = {
|
|
20
22
|
plugins: [
|
|
21
|
-
|
|
23
|
+
a(),
|
|
22
24
|
..._,
|
|
23
25
|
t(),
|
|
24
26
|
...p
|
|
@@ -31,7 +33,7 @@ function o(o = {}) {
|
|
|
31
33
|
port: c,
|
|
32
34
|
host: l,
|
|
33
35
|
open: u,
|
|
34
|
-
...d ? { proxy:
|
|
36
|
+
...d ? { proxy: i(d) } : {}
|
|
35
37
|
}
|
|
36
38
|
}, y = {
|
|
37
39
|
...v,
|