@adea-ai/ui 0.128.2 → 0.128.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/theme/appearance-panel.js +1 -1
- package/dist/components/theme/index.js +1 -1
- package/dist/components/theme/lazy.d.ts +15 -0
- package/dist/components/theme/lazy.d.ts.map +1 -0
- package/dist/components/theme/lazy.js +9 -0
- package/dist/components/theme/theme-catalogue-source.d.ts +15 -0
- package/dist/components/theme/theme-catalogue-source.d.ts.map +1 -0
- package/dist/components/theme/theme-catalogue-source.js +51 -0
- package/dist/components/theme/theme-catalogue-source.js.map +1 -0
- package/dist/components/theme/theme-document-core.d.ts +123 -0
- package/dist/components/theme/theme-document-core.d.ts.map +1 -0
- package/dist/components/theme/{theme-document.js → theme-document-core.js} +12 -12
- package/dist/components/theme/theme-document-core.js.map +1 -0
- package/dist/components/theme/theme-document.d.ts +8 -107
- package/dist/components/theme/theme-document.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.d.ts +1 -1
- package/dist/components/theme/theme-persistence.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.js +9 -6
- package/dist/components/theme/theme-persistence.js.map +1 -1
- package/dist/components/theme/theme-provider-core.d.ts +19 -0
- package/dist/components/theme/theme-provider-core.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-core.js +28 -0
- package/dist/components/theme/theme-provider-core.js.map +1 -0
- package/dist/components/theme/theme-provider-lazy.d.ts +28 -0
- package/dist/components/theme/theme-provider-lazy.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-lazy.js +36 -0
- package/dist/components/theme/theme-provider-lazy.js.map +1 -0
- package/dist/components/theme/theme-provider-value.d.ts +175 -0
- package/dist/components/theme/theme-provider-value.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-value.js +200 -0
- package/dist/components/theme/theme-provider-value.js.map +1 -0
- package/dist/components/theme/theme-provider.d.ts +11 -136
- package/dist/components/theme/theme-provider.d.ts.map +1 -1
- package/dist/components/theme/theme-provider.js +27 -149
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-script.js +4 -3
- package/dist/components/theme/theme-script.js.map +1 -1
- package/dist/components/theme/theme-state-core.d.ts +248 -0
- package/dist/components/theme/theme-state-core.d.ts.map +1 -0
- package/dist/components/theme/{theme-state.js → theme-state-core.js} +8 -7
- package/dist/components/theme/theme-state-core.js.map +1 -0
- package/dist/components/theme/theme-state.d.ts +8 -214
- package/dist/components/theme/theme-state.d.ts.map +1 -1
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/index.js +8 -4
- package/dist/lib/accent-presets.d.ts +35 -0
- package/dist/lib/accent-presets.d.ts.map +1 -0
- package/dist/lib/accent-presets.js +20 -0
- package/dist/lib/accent-presets.js.map +1 -0
- package/dist/lib/theme-catalogue.d.ts +3 -0
- package/dist/lib/theme-catalogue.d.ts.map +1 -0
- package/dist/lib/theme-catalogue.js +22 -0
- package/dist/lib/theme-catalogue.js.map +1 -0
- package/dist/lib/theme-css.d.ts +43 -0
- package/dist/lib/theme-css.d.ts.map +1 -0
- package/dist/lib/theme-css.js +167 -0
- package/dist/lib/theme-css.js.map +1 -0
- package/dist/lib/theme-defaults.d.ts +46 -0
- package/dist/lib/theme-defaults.d.ts.map +1 -0
- package/dist/lib/theme-defaults.generated.d.ts +13 -0
- package/dist/lib/theme-defaults.generated.d.ts.map +1 -0
- package/dist/lib/theme-defaults.generated.js +318 -0
- package/dist/lib/theme-defaults.generated.js.map +1 -0
- package/dist/lib/theme-defaults.js +47 -0
- package/dist/lib/theme-defaults.js.map +1 -0
- package/dist/lib/theme-engine-light.d.ts +3 -0
- package/dist/lib/theme-engine-light.d.ts.map +1 -0
- package/dist/lib/theme-engine-light.js +75 -0
- package/dist/lib/theme-engine-light.js.map +1 -0
- package/dist/lib/theme-engine.d.ts +69 -0
- package/dist/lib/theme-engine.d.ts.map +1 -0
- package/dist/lib/theme-engine.js +33 -0
- package/dist/lib/theme-engine.js.map +1 -0
- package/dist/lib/theme-records.d.ts +39 -0
- package/dist/lib/theme-records.d.ts.map +1 -0
- package/dist/lib/theme-records.js +178 -0
- package/dist/lib/theme-records.js.map +1 -0
- package/dist/lib/themes.d.ts +16 -60
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +23 -322
- package/dist/lib/themes.js.map +1 -1
- package/dist/lib/tokens.d.ts +1 -25
- package/dist/lib/tokens.d.ts.map +1 -1
- package/dist/lib/tokens.js +1 -24
- package/dist/lib/tokens.js.map +1 -1
- package/dist/r/lib.json +40 -0
- package/dist/r/registry.json +75 -0
- package/dist/r/src/components/theme/lazy.ts +35 -0
- package/dist/r/src/components/theme/theme-catalogue-source.ts +59 -0
- package/dist/r/src/components/theme/theme-document-core.ts +262 -0
- package/dist/r/src/components/theme/theme-document.ts +23 -240
- package/dist/r/src/components/theme/theme-persistence.ts +14 -6
- package/dist/r/src/components/theme/theme-provider-core.tsx +40 -0
- package/dist/r/src/components/theme/theme-provider-lazy.tsx +34 -0
- package/dist/r/src/components/theme/theme-provider-value.ts +445 -0
- package/dist/r/src/components/theme/theme-provider.tsx +23 -346
- package/dist/r/src/components/theme/theme-script.ts +3 -3
- package/dist/r/src/components/theme/theme-state-core.ts +364 -0
- package/dist/r/src/components/theme/theme-state.ts +10 -329
- package/dist/r/src/components/theme/theme-toggle.tsx +1 -1
- package/dist/r/src/lib/accent-presets.ts +54 -0
- package/dist/r/src/lib/theme-catalogue.ts +26 -0
- package/dist/r/src/lib/theme-css.ts +201 -0
- package/dist/r/src/lib/theme-defaults.generated.ts +319 -0
- package/dist/r/src/lib/theme-defaults.ts +79 -0
- package/dist/r/src/lib/theme-engine-light.ts +117 -0
- package/dist/r/src/lib/theme-engine.ts +111 -0
- package/dist/r/src/lib/theme-records.ts +205 -0
- package/dist/r/src/lib/themes.ts +30 -375
- package/dist/r/src/lib/tokens.ts +1 -35
- package/dist/r/theming.json +35 -0
- package/package.json +10 -2
- package/registry.json +75 -0
- package/src/components/theme/lazy.ts +35 -0
- package/src/components/theme/theme-catalogue-source.ts +59 -0
- package/src/components/theme/theme-document-core.ts +262 -0
- package/src/components/theme/theme-document.ts +23 -240
- package/src/components/theme/theme-persistence.ts +14 -6
- package/src/components/theme/theme-provider-core.tsx +40 -0
- package/src/components/theme/theme-provider-lazy.tsx +34 -0
- package/src/components/theme/theme-provider-value.ts +445 -0
- package/src/components/theme/theme-provider.tsx +23 -346
- package/src/components/theme/theme-script.ts +3 -3
- package/src/components/theme/theme-state-core.ts +364 -0
- package/src/components/theme/theme-state.ts +10 -329
- package/src/components/theme/theme-toggle.tsx +1 -1
- package/src/lib/accent-presets.ts +54 -0
- package/src/lib/theme-catalogue.ts +26 -0
- package/src/lib/theme-css.ts +201 -0
- package/src/lib/theme-defaults.generated.ts +319 -0
- package/src/lib/theme-defaults.ts +79 -0
- package/src/lib/theme-engine-light.ts +117 -0
- package/src/lib/theme-engine.ts +111 -0
- package/src/lib/theme-records.ts +205 -0
- package/src/lib/themes.ts +30 -375
- package/src/lib/tokens.ts +1 -35
- package/dist/components/theme/theme-document.js.map +0 -1
- package/dist/components/theme/theme-state.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accent axis.
|
|
3
|
+
*
|
|
4
|
+
* adea's accent presets, as a selection rather than a constant. `theme` is the
|
|
5
|
+
* default and means "the variant's own primary" — monochrome in adea's palette —
|
|
6
|
+
* and each named preset overrides the interactive roles through the
|
|
7
|
+
* `[data-accent]` blocks in `theme.css`.
|
|
8
|
+
*
|
|
9
|
+
* These are the same six presets `accentPresets` exports in adea's own
|
|
10
|
+
* `appearance.ts`, and the values match. A consumer's appearance picker and the
|
|
11
|
+
* workshop's theme toolbar read this one list, so the two cannot disagree about
|
|
12
|
+
* what a preset is called or what colour it is.
|
|
13
|
+
*/
|
|
14
|
+
export type AccentPreset = {
|
|
15
|
+
/** The `data-accent` value. `theme` is the variant's own primary. */
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
/** What the preset is for, in the gallery and in a picker. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** The accent as it appears in the light theme. Absent for `theme`. */
|
|
21
|
+
light?: string;
|
|
22
|
+
/** The accent as it appears in the dark theme. Absent for `theme`. */
|
|
23
|
+
dark?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const accentPresets: readonly AccentPreset[];
|
|
26
|
+
/**
|
|
27
|
+
* The six brand accent presets, in the order a picker should show them: the list
|
|
28
|
+
* `accentPresets` carries after its own `theme` entry.
|
|
29
|
+
*
|
|
30
|
+
* Here and not beside the theme table in `lib/themes.ts` (which re-exports it, so
|
|
31
|
+
* `@adea-ai/ui/lib/themes` still has it) because a bundler places a module whole, and
|
|
32
|
+
* a host that wants only the list should not ship the 34-theme catalogue with it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const accents: readonly import("@adea-ai/themes").AccentPreset[];
|
|
35
|
+
//# sourceMappingURL=accent-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accent-presets.d.ts","sourceRoot":"","sources":["../../src/lib/accent-presets.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAA;IACnB,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAQ/C,CAAA;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,mDAAU,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ACCENTS } from "@adea-ai/themes";
|
|
2
|
+
//#region src/lib/accent-presets.ts
|
|
3
|
+
var accentPresets = Object.freeze([{
|
|
4
|
+
id: "theme",
|
|
5
|
+
label: "Theme",
|
|
6
|
+
description: "The variant's own primary. Neutral in adea's palette, so the interface stays monochrome."
|
|
7
|
+
}, ...ACCENTS]);
|
|
8
|
+
/**
|
|
9
|
+
* The six brand accent presets, in the order a picker should show them: the list
|
|
10
|
+
* `accentPresets` carries after its own `theme` entry.
|
|
11
|
+
*
|
|
12
|
+
* Here and not beside the theme table in `lib/themes.ts` (which re-exports it, so
|
|
13
|
+
* `@adea-ai/ui/lib/themes` still has it) because a bundler places a module whole, and
|
|
14
|
+
* a host that wants only the list should not ship the 34-theme catalogue with it.
|
|
15
|
+
*/
|
|
16
|
+
var accents = ACCENTS;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { accentPresets, accents };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=accent-presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accent-presets.js","names":[],"sources":["../../src/lib/accent-presets.ts"],"sourcesContent":["import { ACCENTS } from '@adea-ai/themes'\n\n/*\n * Its own module so the theme provider's start-up path (the stored-preference reader\n * and the boot script both need the preset ids) does not import the token manifest in\n * `tokens.ts`, which is 20 KB of documentation data a provider never reads.\n * `tokens.ts` re-exports `accentPresets` and `AccentPreset`, and `themes.ts` re-exports\n * `accents`, so every existing import keeps working.\n */\n\n/**\n * The accent axis.\n *\n * adea's accent presets, as a selection rather than a constant. `theme` is the\n * default and means \"the variant's own primary\" — monochrome in adea's palette —\n * and each named preset overrides the interactive roles through the\n * `[data-accent]` blocks in `theme.css`.\n *\n * These are the same six presets `accentPresets` exports in adea's own\n * `appearance.ts`, and the values match. A consumer's appearance picker and the\n * workshop's theme toolbar read this one list, so the two cannot disagree about\n * what a preset is called or what colour it is.\n */\nexport type AccentPreset = {\n /** The `data-accent` value. `theme` is the variant's own primary. */\n id: string\n label: string\n /** What the preset is for, in the gallery and in a picker. */\n description: string\n /** The accent as it appears in the light theme. Absent for `theme`. */\n light?: string\n /** The accent as it appears in the dark theme. Absent for `theme`. */\n dark?: string\n}\n\nexport const accentPresets: readonly AccentPreset[] = Object.freeze([\n {\n id: 'theme',\n label: 'Theme',\n description:\n \"The variant's own primary. Neutral in adea's palette, so the interface stays monochrome.\",\n },\n ...ACCENTS,\n])\n\n/**\n * The six brand accent presets, in the order a picker should show them: the list\n * `accentPresets` carries after its own `theme` entry.\n *\n * Here and not beside the theme table in `lib/themes.ts` (which re-exports it, so\n * `@adea-ai/ui/lib/themes` still has it) because a bundler places a module whole, and\n * a host that wants only the list should not ship the 34-theme catalogue with it.\n */\nexport const accents = ACCENTS\n"],"mappings":";;AAmCA,IAAa,gBAAyC,OAAO,OAAO,CAClE;CACE,IAAI;CACJ,OAAO;CACP,aACE;AACJ,GACA,GAAG,OACL,CAAC;;;;;;;;;AAUD,IAAa,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-catalogue.d.ts","sourceRoot":"","sources":["../../src/lib/theme-catalogue.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,eAAO,MAAM,oBAAoB,EAAE,WAOlC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { accentRolesForSelection, accentVariables, builtinThemes, isCatalogueVariant, themeAccentsFor, themeCssVariables } from "./themes.js";
|
|
2
|
+
//#region src/lib/theme-catalogue.ts
|
|
3
|
+
/**
|
|
4
|
+
* The full theme engine, backed by the whole catalogue.
|
|
5
|
+
*
|
|
6
|
+
* This is the module a provider loads when it needs more than the default pair — and,
|
|
7
|
+
* for `ThemeProvider`, always. It imports `lib/themes` (which imports the catalogue)
|
|
8
|
+
* and nothing imports it statically except the eager provider, so a bundler can put
|
|
9
|
+
* it, and the catalogue behind it, in a chunk of its own for the lazy provider.
|
|
10
|
+
*/
|
|
11
|
+
var catalogueThemeEngine = {
|
|
12
|
+
builtinThemes,
|
|
13
|
+
isCatalogueVariant,
|
|
14
|
+
themeCssVariables,
|
|
15
|
+
accentVariables,
|
|
16
|
+
accentRolesForSelection,
|
|
17
|
+
themeAccentsFor
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { catalogueThemeEngine };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=theme-catalogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-catalogue.js","names":[],"sources":["../../src/lib/theme-catalogue.ts"],"sourcesContent":["/**\n * The full theme engine, backed by the whole catalogue.\n *\n * This is the module a provider loads when it needs more than the default pair — and,\n * for `ThemeProvider`, always. It imports `lib/themes` (which imports the catalogue)\n * and nothing imports it statically except the eager provider, so a bundler can put\n * it, and the catalogue behind it, in a chunk of its own for the lazy provider.\n */\nimport {\n accentRolesForSelection,\n accentVariables,\n builtinThemes,\n isCatalogueVariant,\n themeAccentsFor,\n themeCssVariables,\n} from './themes'\nimport type { ThemeEngine } from './theme-engine'\n\nexport const catalogueThemeEngine: ThemeEngine = {\n builtinThemes,\n isCatalogueVariant,\n themeCssVariables,\n accentVariables,\n accentRolesForSelection,\n themeAccentsFor,\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAa,uBAAoC;CAC/C;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EditorRolesMode, ThemeCssVariableOptions, ThemeEditorPalette, ThemeVariant } from './themes';
|
|
2
|
+
/** What a variant's custom properties need that depends on the catalogue. */
|
|
3
|
+
export type ThemeCssHooks = {
|
|
4
|
+
/** The `--primary-subtle` expression of a variant. */
|
|
5
|
+
primarySubtle(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string;
|
|
6
|
+
/** The editor ramp of a variant under a projection. */
|
|
7
|
+
editor(theme: ThemeVariant, mode: EditorRolesMode): ThemeEditorPalette;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The roles a variant sets, as CSS custom properties.
|
|
11
|
+
*
|
|
12
|
+
* The one place that knows the mapping from a theme's roles to this system's variable
|
|
13
|
+
* names. A provider applies this; nothing else repeats it. The `--terminal-*` and
|
|
14
|
+
* `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather
|
|
15
|
+
* than separate roles, which is why they are built here and not in the catalogue.
|
|
16
|
+
*
|
|
17
|
+
* `options.editor` picks the `--editor-*` projection ({@link EditorRolesMode}).
|
|
18
|
+
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
19
|
+
* and the design-system artifact are built without it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function themeCssVariablesWith(hooks: ThemeCssHooks, theme: ThemeVariant, options?: ThemeCssVariableOptions): Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
24
|
+
*
|
|
25
|
+
* What a pinned terminal theme writes over the interface variant's own. The names
|
|
26
|
+
* are the ones {@link themeCssVariablesWith} writes, and a custom variant's verbatim
|
|
27
|
+
* `tokens` still win, so they can never drift from what the interface variant would
|
|
28
|
+
* have written for the same palette. Built from the terminal palette alone: it needs
|
|
29
|
+
* neither the catalogue nor the rest of the variant's roles.
|
|
30
|
+
*/
|
|
31
|
+
export declare function terminalCssVariables(theme: ThemeVariant): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
34
|
+
*
|
|
35
|
+
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
36
|
+
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
37
|
+
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
38
|
+
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
39
|
+
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
40
|
+
* `ThemeProvider`'s `transformTokens`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string>;
|
|
43
|
+
//# sourceMappingURL=theme-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-css.d.ts","sourceRoot":"","sources":["../../src/lib/theme-css.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAA;AAEjB,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GAAG;IAC1B,sDAAsD;IACtD,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,YAAY,CAAC,GAAG,MAAM,CAAA;IACrE,uDAAuD;IACvD,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAAA;CACvE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2FxB;AA2BD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOhF;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU5F"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { primaryHover } from "@adea-ai/themes";
|
|
2
|
+
import { oklchToHex, parseColor } from "@adea-ai/themes/oklch";
|
|
3
|
+
//#region src/lib/theme-css.ts
|
|
4
|
+
/**
|
|
5
|
+
* The mapping from a variant's roles to this system's custom properties, without the
|
|
6
|
+
* catalogue.
|
|
7
|
+
*
|
|
8
|
+
* `themeCssVariables` needs two things only the catalogue can measure for a theme:
|
|
9
|
+
* the strength of its `--primary-subtle` tint and its floor-projected editor ramp.
|
|
10
|
+
* Those are the `hooks`, so this module imports no catalogue data and a host that
|
|
11
|
+
* never loads the catalogue can still paint a variant it already holds. `lib/themes`
|
|
12
|
+
* binds the hooks to the catalogue and keeps exporting the same
|
|
13
|
+
* `themeCssVariables`; `lib/theme-engine` binds them to the precomputed default pair.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The roles a variant sets, as CSS custom properties.
|
|
17
|
+
*
|
|
18
|
+
* The one place that knows the mapping from a theme's roles to this system's variable
|
|
19
|
+
* names. A provider applies this; nothing else repeats it. The `--terminal-*` and
|
|
20
|
+
* `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather
|
|
21
|
+
* than separate roles, which is why they are built here and not in the catalogue.
|
|
22
|
+
*
|
|
23
|
+
* `options.editor` picks the `--editor-*` projection ({@link EditorRolesMode}).
|
|
24
|
+
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
25
|
+
* and the design-system artifact are built without it.
|
|
26
|
+
*/
|
|
27
|
+
function themeCssVariablesWith(hooks, theme, options = {}) {
|
|
28
|
+
const c = theme.colors;
|
|
29
|
+
const t = theme.terminal;
|
|
30
|
+
const e = hooks.editor(theme, options.editor ?? "syntax");
|
|
31
|
+
const derived = {
|
|
32
|
+
"--background": c.background,
|
|
33
|
+
"--foreground": c.foreground,
|
|
34
|
+
"--card": c.card,
|
|
35
|
+
"--card-foreground": c.cardForeground,
|
|
36
|
+
"--popover": c.popover,
|
|
37
|
+
"--popover-foreground": c.popoverForeground,
|
|
38
|
+
"--primary": c.primary,
|
|
39
|
+
"--primary-foreground": c.primaryForeground,
|
|
40
|
+
"--primary-hover": primaryHover(c.primary, theme.appearance),
|
|
41
|
+
"--primary-subtle": hooks.primarySubtle(theme),
|
|
42
|
+
"--secondary": c.secondary,
|
|
43
|
+
"--secondary-foreground": c.secondaryForeground,
|
|
44
|
+
"--muted": c.muted,
|
|
45
|
+
"--muted-foreground": c.mutedForeground,
|
|
46
|
+
"--accent": c.accent,
|
|
47
|
+
"--accent-foreground": c.accentForeground,
|
|
48
|
+
"--destructive": c.destructive,
|
|
49
|
+
"--destructive-foreground": c.destructiveForeground,
|
|
50
|
+
"--destructive-subtle": c.destructiveSubtle,
|
|
51
|
+
"--destructive-action": c.destructiveAction,
|
|
52
|
+
"--destructive-action-foreground": c.destructiveActionForeground,
|
|
53
|
+
"--success": c.success,
|
|
54
|
+
"--success-foreground": c.successForeground,
|
|
55
|
+
"--success-subtle": c.successSubtle,
|
|
56
|
+
"--warning": c.warning,
|
|
57
|
+
"--warning-foreground": c.warningForeground,
|
|
58
|
+
"--warning-subtle": c.warningSubtle,
|
|
59
|
+
"--info": c.info,
|
|
60
|
+
"--info-foreground": c.infoForeground,
|
|
61
|
+
"--info-subtle": c.infoSubtle,
|
|
62
|
+
"--border": c.border,
|
|
63
|
+
"--input": c.input,
|
|
64
|
+
"--ring": c.ring,
|
|
65
|
+
"--sidebar": c.sidebar,
|
|
66
|
+
"--sidebar-foreground": c.sidebarForeground,
|
|
67
|
+
"--sidebar-accent": c.sidebarAccent,
|
|
68
|
+
"--sidebar-border": c.sidebarBorder,
|
|
69
|
+
"--sidebar-primary": c.primary,
|
|
70
|
+
"--sidebar-primary-foreground": c.primaryForeground,
|
|
71
|
+
"--sidebar-ring": c.ring,
|
|
72
|
+
"--sidebar-muted-foreground": c.sidebarMutedForeground,
|
|
73
|
+
"--surface-sunken": c.muted,
|
|
74
|
+
"--surface-hover": c.accent,
|
|
75
|
+
"--surface-active": c.border,
|
|
76
|
+
"--chrome": c.background,
|
|
77
|
+
...terminalVariables(t),
|
|
78
|
+
"--editor-keyword": e.keyword,
|
|
79
|
+
"--editor-string": e.string,
|
|
80
|
+
"--editor-number": e.number,
|
|
81
|
+
"--editor-comment": e.comment,
|
|
82
|
+
"--editor-function": e.function,
|
|
83
|
+
"--editor-variable": e.variable,
|
|
84
|
+
"--editor-type": e.type,
|
|
85
|
+
"--editor-tag": e.tag,
|
|
86
|
+
"--editor-attribute": e.attribute,
|
|
87
|
+
"--editor-operator": e.operator,
|
|
88
|
+
"--editor-heading": e.heading,
|
|
89
|
+
"--editor-link": e.link,
|
|
90
|
+
"--editor-diff-add": e.diffAdd,
|
|
91
|
+
"--editor-diff-delete": e.diffDelete,
|
|
92
|
+
"--editor-diff-hunk": e.diffHunk,
|
|
93
|
+
"--editor-search-match": e.searchMatch,
|
|
94
|
+
"--chart-1": theme.chart[0] ?? c.primary,
|
|
95
|
+
"--chart-2": theme.chart[1] ?? c.info,
|
|
96
|
+
"--chart-3": theme.chart[2] ?? c.success,
|
|
97
|
+
"--chart-4": theme.chart[3] ?? c.warning,
|
|
98
|
+
"--chart-5": theme.chart[4] ?? c.destructive,
|
|
99
|
+
"--chart-6": theme.chart[5] ?? c.mutedForeground
|
|
100
|
+
};
|
|
101
|
+
return theme.tokens ? {
|
|
102
|
+
...derived,
|
|
103
|
+
...theme.tokens
|
|
104
|
+
} : derived;
|
|
105
|
+
}
|
|
106
|
+
function terminalVariables(t) {
|
|
107
|
+
return {
|
|
108
|
+
"--terminal-background": t.background,
|
|
109
|
+
"--terminal-foreground": t.foreground,
|
|
110
|
+
"--terminal-cursor": t.cursor,
|
|
111
|
+
"--terminal-selection": t.selection,
|
|
112
|
+
"--terminal-ansi-black": t.black,
|
|
113
|
+
"--terminal-ansi-red": t.red,
|
|
114
|
+
"--terminal-ansi-green": t.green,
|
|
115
|
+
"--terminal-ansi-yellow": t.yellow,
|
|
116
|
+
"--terminal-ansi-blue": t.blue,
|
|
117
|
+
"--terminal-ansi-magenta": t.magenta,
|
|
118
|
+
"--terminal-ansi-cyan": t.cyan,
|
|
119
|
+
"--terminal-ansi-white": t.white,
|
|
120
|
+
"--terminal-ansi-bright-black": t.brightBlack,
|
|
121
|
+
"--terminal-ansi-bright-red": t.brightRed,
|
|
122
|
+
"--terminal-ansi-bright-green": t.brightGreen,
|
|
123
|
+
"--terminal-ansi-bright-yellow": t.brightYellow,
|
|
124
|
+
"--terminal-ansi-bright-blue": t.brightBlue,
|
|
125
|
+
"--terminal-ansi-bright-magenta": t.brightMagenta,
|
|
126
|
+
"--terminal-ansi-bright-cyan": t.brightCyan,
|
|
127
|
+
"--terminal-ansi-bright-white": t.brightWhite
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
132
|
+
*
|
|
133
|
+
* What a pinned terminal theme writes over the interface variant's own. The names
|
|
134
|
+
* are the ones {@link themeCssVariablesWith} writes, and a custom variant's verbatim
|
|
135
|
+
* `tokens` still win, so they can never drift from what the interface variant would
|
|
136
|
+
* have written for the same palette. Built from the terminal palette alone: it needs
|
|
137
|
+
* neither the catalogue nor the rest of the variant's roles.
|
|
138
|
+
*/
|
|
139
|
+
function terminalCssVariables(theme) {
|
|
140
|
+
const properties = terminalVariables(theme.terminal);
|
|
141
|
+
if (!theme.tokens) return properties;
|
|
142
|
+
for (const [name, value] of Object.entries(theme.tokens)) if (name.startsWith("--terminal-")) properties[name] = value;
|
|
143
|
+
return properties;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
147
|
+
*
|
|
148
|
+
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
149
|
+
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
150
|
+
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
151
|
+
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
152
|
+
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
153
|
+
* `ThemeProvider`'s `transformTokens`.
|
|
154
|
+
*/
|
|
155
|
+
function tokensAsHex(tokens) {
|
|
156
|
+
const converted = {};
|
|
157
|
+
for (const [name, value] of Object.entries(tokens)) {
|
|
158
|
+
const trimmed = value.trim();
|
|
159
|
+
const parsed = trimmed.startsWith("oklch(") && !trimmed.includes("/") ? parseColor(trimmed) : void 0;
|
|
160
|
+
converted[name] = parsed ? oklchToHex(parsed) : value;
|
|
161
|
+
}
|
|
162
|
+
return converted;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { terminalCssVariables, themeCssVariablesWith, tokensAsHex };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=theme-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-css.js","names":[],"sources":["../../src/lib/theme-css.ts"],"sourcesContent":["/**\n * The mapping from a variant's roles to this system's custom properties, without the\n * catalogue.\n *\n * `themeCssVariables` needs two things only the catalogue can measure for a theme:\n * the strength of its `--primary-subtle` tint and its floor-projected editor ramp.\n * Those are the `hooks`, so this module imports no catalogue data and a host that\n * never loads the catalogue can still paint a variant it already holds. `lib/themes`\n * binds the hooks to the catalogue and keeps exporting the same\n * `themeCssVariables`; `lib/theme-engine` binds them to the precomputed default pair.\n */\nimport { primaryHover } from '@adea-ai/themes'\nimport { oklchToHex, parseColor } from '@adea-ai/themes/oklch'\nimport type {\n EditorRolesMode,\n ThemeCssVariableOptions,\n ThemeEditorPalette,\n ThemeVariant,\n} from './themes'\n\n/** What a variant's custom properties need that depends on the catalogue. */\nexport type ThemeCssHooks = {\n /** The `--primary-subtle` expression of a variant. */\n primarySubtle(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string\n /** The editor ramp of a variant under a projection. */\n editor(theme: ThemeVariant, mode: EditorRolesMode): ThemeEditorPalette\n}\n\n/**\n * The roles a variant sets, as CSS custom properties.\n *\n * The one place that knows the mapping from a theme's roles to this system's variable\n * names. A provider applies this; nothing else repeats it. The `--terminal-*` and\n * `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather\n * than separate roles, which is why they are built here and not in the catalogue.\n *\n * `options.editor` picks the `--editor-*` projection ({@link EditorRolesMode}).\n * Absent it, the result is what it has always been; the generated `theme-variants.css`\n * and the design-system artifact are built without it.\n */\nexport function themeCssVariablesWith(\n hooks: ThemeCssHooks,\n theme: ThemeVariant,\n options: ThemeCssVariableOptions = {}\n): Record<string, string> {\n const c = theme.colors\n const t = theme.terminal\n const e = hooks.editor(theme, options.editor ?? 'syntax')\n const derived = {\n '--background': c.background,\n '--foreground': c.foreground,\n '--card': c.card,\n '--card-foreground': c.cardForeground,\n '--popover': c.popover,\n '--popover-foreground': c.popoverForeground,\n '--primary': c.primary,\n '--primary-foreground': c.primaryForeground,\n /*\n * The two tokens derived from the primary, and they are here rather than left to\n * `theme.css` because they must follow `--primary` — which this function writes\n * for *any* theme in the catalogue, not just the two defaults `theme.css` carries.\n *\n * `--primary-hover` is a resolved colour, not a `color-mix()`: a uniform hover\n * step cannot be expressed as a mix (see `primaryHover`). Left out, a theme switch\n * would keep the previous theme's hover on the new theme's primary.\n *\n * `--primary-subtle` is a mix over `--primary`, so it follows an accent on its\n * own, but its *strength* is per theme: `primarySubtleCss(record)` lowers the\n * appearance ceiling only as far as this theme needs for body text to clear 4.5:1\n * on the tint, over every surface, for every accent it offers. It has to be\n * written per theme for that reason — the appearance-wide value is not legible on\n * every palette.\n */\n '--primary-hover': primaryHover(c.primary, theme.appearance),\n '--primary-subtle': hooks.primarySubtle(theme),\n '--secondary': c.secondary,\n '--secondary-foreground': c.secondaryForeground,\n '--muted': c.muted,\n '--muted-foreground': c.mutedForeground,\n '--accent': c.accent,\n '--accent-foreground': c.accentForeground,\n '--destructive': c.destructive,\n '--destructive-foreground': c.destructiveForeground,\n '--destructive-subtle': c.destructiveSubtle,\n '--destructive-action': c.destructiveAction,\n '--destructive-action-foreground': c.destructiveActionForeground,\n '--success': c.success,\n '--success-foreground': c.successForeground,\n '--success-subtle': c.successSubtle,\n '--warning': c.warning,\n '--warning-foreground': c.warningForeground,\n '--warning-subtle': c.warningSubtle,\n '--info': c.info,\n '--info-foreground': c.infoForeground,\n '--info-subtle': c.infoSubtle,\n '--border': c.border,\n '--input': c.input,\n '--ring': c.ring,\n '--sidebar': c.sidebar,\n '--sidebar-foreground': c.sidebarForeground,\n '--sidebar-accent': c.sidebarAccent,\n '--sidebar-border': c.sidebarBorder,\n '--sidebar-primary': c.primary,\n '--sidebar-primary-foreground': c.primaryForeground,\n '--sidebar-ring': c.ring,\n '--sidebar-muted-foreground': c.sidebarMutedForeground,\n '--surface-sunken': c.muted,\n '--surface-hover': c.accent,\n '--surface-active': c.border,\n '--chrome': c.background,\n ...terminalVariables(t),\n '--editor-keyword': e.keyword,\n '--editor-string': e.string,\n '--editor-number': e.number,\n '--editor-comment': e.comment,\n '--editor-function': e.function,\n '--editor-variable': e.variable,\n '--editor-type': e.type,\n '--editor-tag': e.tag,\n '--editor-attribute': e.attribute,\n '--editor-operator': e.operator,\n '--editor-heading': e.heading,\n '--editor-link': e.link,\n '--editor-diff-add': e.diffAdd,\n '--editor-diff-delete': e.diffDelete,\n '--editor-diff-hunk': e.diffHunk,\n '--editor-search-match': e.searchMatch,\n '--chart-1': theme.chart[0] ?? c.primary,\n '--chart-2': theme.chart[1] ?? c.info,\n '--chart-3': theme.chart[2] ?? c.success,\n '--chart-4': theme.chart[3] ?? c.warning,\n '--chart-5': theme.chart[4] ?? c.destructive,\n '--chart-6': theme.chart[5] ?? c.mutedForeground,\n }\n return theme.tokens ? { ...derived, ...theme.tokens } : derived\n}\n\nfunction terminalVariables(t: ThemeVariant['terminal']): Record<string, string> {\n return {\n '--terminal-background': t.background,\n '--terminal-foreground': t.foreground,\n '--terminal-cursor': t.cursor,\n '--terminal-selection': t.selection,\n '--terminal-ansi-black': t.black,\n '--terminal-ansi-red': t.red,\n '--terminal-ansi-green': t.green,\n '--terminal-ansi-yellow': t.yellow,\n '--terminal-ansi-blue': t.blue,\n '--terminal-ansi-magenta': t.magenta,\n '--terminal-ansi-cyan': t.cyan,\n '--terminal-ansi-white': t.white,\n '--terminal-ansi-bright-black': t.brightBlack,\n '--terminal-ansi-bright-red': t.brightRed,\n '--terminal-ansi-bright-green': t.brightGreen,\n '--terminal-ansi-bright-yellow': t.brightYellow,\n '--terminal-ansi-bright-blue': t.brightBlue,\n '--terminal-ansi-bright-magenta': t.brightMagenta,\n '--terminal-ansi-bright-cyan': t.brightCyan,\n '--terminal-ansi-bright-white': t.brightWhite,\n }\n}\n\n/**\n * The `--terminal-*` properties of a variant: the palette a terminal paints.\n *\n * What a pinned terminal theme writes over the interface variant's own. The names\n * are the ones {@link themeCssVariablesWith} writes, and a custom variant's verbatim\n * `tokens` still win, so they can never drift from what the interface variant would\n * have written for the same palette. Built from the terminal palette alone: it needs\n * neither the catalogue nor the rest of the variant's roles.\n */\nexport function terminalCssVariables(theme: ThemeVariant): Record<string, string> {\n const properties = terminalVariables(theme.terminal)\n if (!theme.tokens) return properties\n for (const [name, value] of Object.entries(theme.tokens)) {\n if (name.startsWith('--terminal-')) properties[name] = value\n }\n return properties\n}\n\n/**\n * Token values with every `oklch()` colour written as `#rrggbb`.\n *\n * For a host whose stylesheet, tests or native shell speak hex: the catalogue's\n * roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the\n * catalogue's own `oklchToHex`. A value that is already hex, carries alpha\n * (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for\n * byte, because converting would either lose the alpha or be a guess. Suitable as\n * `ThemeProvider`'s `transformTokens`.\n */\nexport function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string> {\n const converted: Record<string, string> = {}\n for (const [name, value] of Object.entries(tokens)) {\n const trimmed = value.trim()\n // `parseOklch` discards alpha, so a translucent oklch() stays as written.\n const opaque = trimmed.startsWith('oklch(') && !trimmed.includes('/')\n const parsed = opaque ? parseColor(trimmed) : undefined\n converted[name] = parsed ? oklchToHex(parsed) : value\n }\n return converted\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a provider knows about the catalogue without loading it.
|
|
3
|
+
*
|
|
4
|
+
* The catalogue (`@adea-ai/themes`, 34 themes) is the heavy part of the theme
|
|
5
|
+
* system. Most hosts start on the default pair, paint a catalogue theme from a
|
|
6
|
+
* stylesheet, and open a picker rarely, so this module holds the few facts needed
|
|
7
|
+
* to start without it: the default ids, every catalogue id with its appearance (to
|
|
8
|
+
* recognise a stored preference), and the default pair as complete variants.
|
|
9
|
+
*
|
|
10
|
+
* It imports no catalogue code and no catalogue data. The facts themselves are in
|
|
11
|
+
* `theme-defaults.generated.ts`, copied from the catalogue by
|
|
12
|
+
* `scripts/build-theme-defaults.ts` and checked against it by
|
|
13
|
+
* `tests/theme-defaults.test.ts`.
|
|
14
|
+
*/
|
|
15
|
+
import type { ThemeAppearance, ThemeVariant } from './themes';
|
|
16
|
+
import { DEFAULT_VARIANTS } from './theme-defaults.generated';
|
|
17
|
+
export { DEFAULT_FLOOR_EDITOR, DEFAULT_PRIMARY_SUBTLE, DEFAULT_THEME_ACCENTS, DEFAULT_VARIANTS, THEME_INDEX, } from './theme-defaults.generated';
|
|
18
|
+
export declare const defaultLightThemeId = "adea-light";
|
|
19
|
+
export declare const defaultDarkThemeId = "adea-dark";
|
|
20
|
+
/** The appearance of a catalogue theme id, or `undefined` for an id the catalogue lacks. */
|
|
21
|
+
export declare function catalogueThemeAppearance(id: string): ThemeAppearance | undefined;
|
|
22
|
+
/** Whether the catalogue holds a theme with this id (loaded or not). */
|
|
23
|
+
export declare function isCatalogueThemeId(id: string): boolean;
|
|
24
|
+
/** Whether an id is one of the two default themes, whose data ships with the provider. */
|
|
25
|
+
export declare function isDefaultThemeId(id: string): id is keyof typeof DEFAULT_VARIANTS;
|
|
26
|
+
/** The default variant of an appearance. */
|
|
27
|
+
export declare function defaultVariantFor(appearance: ThemeAppearance): ThemeVariant;
|
|
28
|
+
/**
|
|
29
|
+
* The variant a stored id means, or the default of the same appearance.
|
|
30
|
+
*
|
|
31
|
+
* An id the registry does not hold — an imported theme that was deleted, a
|
|
32
|
+
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
33
|
+
* being shown*. Falling back to whichever variant happens to be first in the
|
|
34
|
+
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
35
|
+
* the fallback is the appearance's own default, then any variant of that
|
|
36
|
+
* appearance, then the registry's first entry only when it holds nothing else.
|
|
37
|
+
*
|
|
38
|
+
* `registry` is the builtin catalogue plus whatever extras the host supplies; the
|
|
39
|
+
* stored id is never rewritten, only resolved, so a host that keeps an unknown id
|
|
40
|
+
* keeps resolving it if the theme comes back.
|
|
41
|
+
*
|
|
42
|
+
* The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
|
|
43
|
+
* Copyright (c) 2026 Wing); see NOTICE.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveVariant(registry: readonly ThemeVariant[], id: string, appearance: ThemeAppearance): ThemeVariant;
|
|
46
|
+
//# sourceMappingURL=theme-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-defaults.d.ts","sourceRoot":"","sources":["../../src/lib/theme-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAe,MAAM,4BAA4B,CAAA;AAE1E,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,GACZ,MAAM,4BAA4B,CAAA;AAEnC,eAAO,MAAM,mBAAmB,eAAe,CAAA;AAC/C,eAAO,MAAM,kBAAkB,cAAc,CAAA;AAE7C,4FAA4F;AAC5F,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAEhF;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,MAAM,OAAO,gBAAgB,CAEhF;AAED,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,YAAY,CAE3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,eAAe,GAC1B,YAAY,CASd"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AccentPreset } from '@adea-ai/themes';
|
|
2
|
+
import type { ThemeEditorPalette, ThemeVariant } from './themes';
|
|
3
|
+
/** Every catalogue theme id and its appearance, in catalogue order. */
|
|
4
|
+
export declare const THEME_INDEX: readonly (readonly [id: string, appearance: 'light' | 'dark'])[];
|
|
5
|
+
/** The default light and dark themes, complete. */
|
|
6
|
+
export declare const DEFAULT_VARIANTS: Readonly<Record<'adea-light' | 'adea-dark', ThemeVariant>>;
|
|
7
|
+
/** The accents the default light/dark pair offers beside the presets. */
|
|
8
|
+
export declare const DEFAULT_THEME_ACCENTS: readonly AccentPreset[];
|
|
9
|
+
/** Each default's measured `--primary-subtle` expression. */
|
|
10
|
+
export declare const DEFAULT_PRIMARY_SUBTLE: Readonly<Record<string, string>>;
|
|
11
|
+
/** Each default's `--editor-*` ramp held to 4.5:1 on its canvas (`editorRoles: 'floor'`). */
|
|
12
|
+
export declare const DEFAULT_FLOOR_EDITOR: Readonly<Record<string, ThemeEditorPalette>>;
|
|
13
|
+
//# sourceMappingURL=theme-defaults.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-defaults.generated.d.ts","sourceRoot":"","sources":["../../src/lib/theme-defaults.generated.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEhE,uEAAuE;AACvE,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,EAmCvF,CAAA;AAED,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,GAAG,WAAW,EAAE,YAAY,CAAC,CAiMvF,CAAA;AAED,yEAAyE;AACzE,eAAO,MAAM,qBAAqB,EAAE,SAAS,YAAY,EA6BxD,CAAA;AAED,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGnE,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAqC7E,CAAA"}
|