@adea-ai/ui 0.128.1 → 0.128.3
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 +7 -4
- package/dist/lib/accent-presets.d.ts +26 -0
- package/dist/lib/accent-presets.d.ts.map +1 -0
- package/dist/lib/accent-presets.js +11 -0
- package/dist/lib/accent-presets.js.map +1 -0
- package/dist/lib/accent-roles.js +94 -9
- package/dist/lib/accent-roles.js.map +1 -1
- package/dist/lib/font-zoom.js +4 -2
- package/dist/lib/font-zoom.js.map +1 -1
- package/dist/lib/overlay.js +3 -1
- package/dist/lib/overlay.js.map +1 -1
- 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/themes.d.ts +14 -48
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +24 -164
- 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/lib/tooltip-focus-gate.js +7 -1
- package/dist/lib/tooltip-focus-gate.js.map +1 -1
- package/dist/lib/variants.js +2 -2
- package/dist/r/lib.json +35 -0
- package/dist/r/registry.json +70 -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 +43 -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/themes.ts +27 -191
- package/dist/r/src/lib/tokens.ts +1 -35
- package/dist/r/theming.json +35 -0
- package/package.json +12 -3
- package/registry.json +70 -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 +43 -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/themes.ts +27 -191
- 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,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalogue-dependent operations a provider performs, as one seam.
|
|
3
|
+
*
|
|
4
|
+
* `ThemeProvider` needs to ask a handful of questions that only the catalogue can
|
|
5
|
+
* answer in general: the built-in variants, a variant's custom properties, the roles
|
|
6
|
+
* an accent paints over it, the accents a theme pair offers. Two engines answer them.
|
|
7
|
+
*
|
|
8
|
+
* - {@link catalogueThemeEngine} (`lib/theme-catalogue`) is the full answer, backed by
|
|
9
|
+
* the whole catalogue. It is what `ThemeProvider` uses and what the lazy provider
|
|
10
|
+
* switches to once the catalogue has loaded.
|
|
11
|
+
* - {@link lightThemeEngine} (`lib/theme-engine-light`) answers from the data that ships with the
|
|
12
|
+
* provider (`theme-defaults`): the default light/dark pair, host variants that are
|
|
13
|
+
* not in the catalogue, and nothing else. It imports no catalogue data, which is
|
|
14
|
+
* the point: a host that keeps the default pair never pays for the other 32
|
|
15
|
+
* themes. A question outside that set throws {@link CatalogueRequired}; the lazy
|
|
16
|
+
* provider asks {@link needsCatalogue} first and loads the catalogue instead.
|
|
17
|
+
*
|
|
18
|
+
* `tests/theme-engine.test.ts` holds the two to the same answers wherever the light
|
|
19
|
+
* engine can answer.
|
|
20
|
+
*/
|
|
21
|
+
import type { AccentPreset } from '@adea-ai/themes';
|
|
22
|
+
import type { AccentRoles } from './accent-roles';
|
|
23
|
+
import type { AccentVariableOptions, ThemeAppearance, ThemeCssVariableOptions, ThemeVariant } from './themes';
|
|
24
|
+
export type ThemeEngine = {
|
|
25
|
+
/** The built-in variants. A plain array, in catalogue order. */
|
|
26
|
+
readonly builtinThemes: readonly ThemeVariant[];
|
|
27
|
+
/** True for the catalogue's own variant, not a host's copy that merely shares its id. */
|
|
28
|
+
isCatalogueVariant(variant: ThemeVariant): boolean;
|
|
29
|
+
/** The custom properties a variant sets. */
|
|
30
|
+
themeCssVariables(variant: ThemeVariant, options?: ThemeCssVariableOptions): Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* The custom properties an accent selection overrides on the document (`--primary`, its
|
|
33
|
+
* foreground, hover and ring), or `undefined` when it overrides nothing.
|
|
34
|
+
*/
|
|
35
|
+
accentVariables(accentId: string, appearance: ThemeAppearance, pair: {
|
|
36
|
+
lightThemeId: string;
|
|
37
|
+
darkThemeId: string;
|
|
38
|
+
}, options?: AccentVariableOptions): Record<string, string> | undefined;
|
|
39
|
+
/** An accent selection resolved to its full roles against a theme pair, or `undefined`. */
|
|
40
|
+
accentRolesForSelection(accentId: string, appearance: ThemeAppearance, pair: {
|
|
41
|
+
lightThemeId: string;
|
|
42
|
+
darkThemeId: string;
|
|
43
|
+
}, options?: AccentVariableOptions): AccentRoles | undefined;
|
|
44
|
+
/** The accents a light/dark pair offers beside the presets. */
|
|
45
|
+
themeAccentsFor(lightThemeId: string, darkThemeId: string): readonly AccentPreset[];
|
|
46
|
+
};
|
|
47
|
+
/** Thrown by the light engine for a question that needs the whole catalogue. */
|
|
48
|
+
export declare class CatalogueRequired extends Error {
|
|
49
|
+
constructor(what: string);
|
|
50
|
+
}
|
|
51
|
+
/** The ids an id resolves to when the catalogue lacks it, as `getTheme ?? default` does. */
|
|
52
|
+
export declare function pairIds(lightThemeId: string, darkThemeId: string): [string, string];
|
|
53
|
+
/** A catalogue id other than the two defaults: its data is not in the light engine. */
|
|
54
|
+
export declare const needsData: (id: string) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether answering for this selection needs the catalogue.
|
|
57
|
+
*
|
|
58
|
+
* True when the variant being shown, the pinned terminal theme, or (for a
|
|
59
|
+
* theme-derived `ansi-*` accent) either theme of the pair is a catalogue theme other
|
|
60
|
+
* than the two defaults. Everything else — the default pair, a host's own variants,
|
|
61
|
+
* every preset and custom accent — the light engine answers from shipped data.
|
|
62
|
+
*/
|
|
63
|
+
export declare function needsCatalogue(selection: {
|
|
64
|
+
lightThemeId: string;
|
|
65
|
+
darkThemeId: string;
|
|
66
|
+
accent: string;
|
|
67
|
+
terminalThemeId?: string;
|
|
68
|
+
}, appearance: ThemeAppearance): boolean;
|
|
69
|
+
//# sourceMappingURL=theme-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-engine.d.ts","sourceRoot":"","sources":["../../src/lib/theme-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAQjD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,YAAY,EACb,MAAM,UAAU,CAAA;AA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,EAAE;IACT,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,EACD,UAAU,EAAE,eAAe,GAC1B,OAAO,CAQT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isThemeAccentId } from "./theme-accents.js";
|
|
2
|
+
import { defaultDarkThemeId, defaultLightThemeId, isCatalogueThemeId, isDefaultThemeId } from "./theme-defaults.js";
|
|
3
|
+
//#region src/lib/theme-engine.ts
|
|
4
|
+
/** Thrown by the light engine for a question that needs the whole catalogue. */
|
|
5
|
+
var CatalogueRequired = class extends Error {
|
|
6
|
+
constructor(what) {
|
|
7
|
+
super(`${what} needs the theme catalogue, which has not been loaded`);
|
|
8
|
+
this.name = "CatalogueRequired";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/** The ids an id resolves to when the catalogue lacks it, as `getTheme ?? default` does. */
|
|
12
|
+
function pairIds(lightThemeId, darkThemeId) {
|
|
13
|
+
return [isCatalogueThemeId(lightThemeId) ? lightThemeId : defaultLightThemeId, isCatalogueThemeId(darkThemeId) ? darkThemeId : defaultDarkThemeId];
|
|
14
|
+
}
|
|
15
|
+
/** A catalogue id other than the two defaults: its data is not in the light engine. */
|
|
16
|
+
var needsData = (id) => isCatalogueThemeId(id) && !isDefaultThemeId(id);
|
|
17
|
+
/**
|
|
18
|
+
* Whether answering for this selection needs the catalogue.
|
|
19
|
+
*
|
|
20
|
+
* True when the variant being shown, the pinned terminal theme, or (for a
|
|
21
|
+
* theme-derived `ansi-*` accent) either theme of the pair is a catalogue theme other
|
|
22
|
+
* than the two defaults. Everything else — the default pair, a host's own variants,
|
|
23
|
+
* every preset and custom accent — the light engine answers from shipped data.
|
|
24
|
+
*/
|
|
25
|
+
function needsCatalogue(selection, appearance) {
|
|
26
|
+
if (needsData(appearance === "dark" ? selection.darkThemeId : selection.lightThemeId)) return true;
|
|
27
|
+
if (selection.terminalThemeId !== void 0 && needsData(selection.terminalThemeId)) return true;
|
|
28
|
+
return isThemeAccentId(selection.accent) && (needsData(selection.lightThemeId) || needsData(selection.darkThemeId));
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CatalogueRequired, needsCatalogue, needsData, pairIds };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=theme-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-engine.js","names":[],"sources":["../../src/lib/theme-engine.ts"],"sourcesContent":["/**\n * The catalogue-dependent operations a provider performs, as one seam.\n *\n * `ThemeProvider` needs to ask a handful of questions that only the catalogue can\n * answer in general: the built-in variants, a variant's custom properties, the roles\n * an accent paints over it, the accents a theme pair offers. Two engines answer them.\n *\n * - {@link catalogueThemeEngine} (`lib/theme-catalogue`) is the full answer, backed by\n * the whole catalogue. It is what `ThemeProvider` uses and what the lazy provider\n * switches to once the catalogue has loaded.\n * - {@link lightThemeEngine} (`lib/theme-engine-light`) answers from the data that ships with the\n * provider (`theme-defaults`): the default light/dark pair, host variants that are\n * not in the catalogue, and nothing else. It imports no catalogue data, which is\n * the point: a host that keeps the default pair never pays for the other 32\n * themes. A question outside that set throws {@link CatalogueRequired}; the lazy\n * provider asks {@link needsCatalogue} first and loads the catalogue instead.\n *\n * `tests/theme-engine.test.ts` holds the two to the same answers wherever the light\n * engine can answer.\n */\nimport type { AccentPreset } from '@adea-ai/themes'\nimport type { AccentRoles } from './accent-roles'\nimport { isThemeAccentId } from './theme-accents'\nimport {\n defaultDarkThemeId,\n defaultLightThemeId,\n isCatalogueThemeId,\n isDefaultThemeId,\n} from './theme-defaults'\nimport type {\n AccentVariableOptions,\n ThemeAppearance,\n ThemeCssVariableOptions,\n ThemeVariant,\n} from './themes'\n\nexport type ThemeEngine = {\n /** The built-in variants. A plain array, in catalogue order. */\n readonly builtinThemes: readonly ThemeVariant[]\n /** True for the catalogue's own variant, not a host's copy that merely shares its id. */\n isCatalogueVariant(variant: ThemeVariant): boolean\n /** The custom properties a variant sets. */\n themeCssVariables(\n variant: ThemeVariant,\n options?: ThemeCssVariableOptions\n ): Record<string, string>\n /**\n * The custom properties an accent selection overrides on the document (`--primary`, its\n * foreground, hover and ring), or `undefined` when it overrides nothing.\n */\n accentVariables(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string },\n options?: AccentVariableOptions\n ): Record<string, string> | undefined\n /** An accent selection resolved to its full roles against a theme pair, or `undefined`. */\n accentRolesForSelection(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string },\n options?: AccentVariableOptions\n ): AccentRoles | undefined\n /** The accents a light/dark pair offers beside the presets. */\n themeAccentsFor(lightThemeId: string, darkThemeId: string): readonly AccentPreset[]\n}\n\n/** Thrown by the light engine for a question that needs the whole catalogue. */\nexport class CatalogueRequired extends Error {\n constructor(what: string) {\n super(`${what} needs the theme catalogue, which has not been loaded`)\n this.name = 'CatalogueRequired'\n }\n}\n\n/** The ids an id resolves to when the catalogue lacks it, as `getTheme ?? default` does. */\nexport function pairIds(lightThemeId: string, darkThemeId: string): [string, string] {\n return [\n isCatalogueThemeId(lightThemeId) ? lightThemeId : defaultLightThemeId,\n isCatalogueThemeId(darkThemeId) ? darkThemeId : defaultDarkThemeId,\n ]\n}\n\n/** A catalogue id other than the two defaults: its data is not in the light engine. */\nexport const needsData = (id: string) => isCatalogueThemeId(id) && !isDefaultThemeId(id)\n\n/**\n * Whether answering for this selection needs the catalogue.\n *\n * True when the variant being shown, the pinned terminal theme, or (for a\n * theme-derived `ansi-*` accent) either theme of the pair is a catalogue theme other\n * than the two defaults. Everything else — the default pair, a host's own variants,\n * every preset and custom accent — the light engine answers from shipped data.\n */\nexport function needsCatalogue(\n selection: {\n lightThemeId: string\n darkThemeId: string\n accent: string\n terminalThemeId?: string\n },\n appearance: ThemeAppearance\n): boolean {\n const shown = appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId\n if (needsData(shown)) return true\n if (selection.terminalThemeId !== undefined && needsData(selection.terminalThemeId)) return true\n return (\n isThemeAccentId(selection.accent) &&\n (needsData(selection.lightThemeId) || needsData(selection.darkThemeId))\n )\n}\n"],"mappings":";;;;AAoEA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,MAAc;EACxB,MAAM,GAAG,KAAK,sDAAsD;EACpE,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,QAAQ,cAAsB,aAAuC;CACnF,OAAO,CACL,mBAAmB,YAAY,IAAI,eAAe,qBAClD,mBAAmB,WAAW,IAAI,cAAc,kBAClD;AACF;;AAGA,IAAa,aAAa,OAAe,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,EAAE;;;;;;;;;AAUvF,SAAgB,eACd,WAMA,YACS;CAET,IAAI,UADU,eAAe,SAAS,UAAU,cAAc,UAAU,YACrD,GAAG,OAAO;CAC7B,IAAI,UAAU,oBAAoB,KAAA,KAAa,UAAU,UAAU,eAAe,GAAG,OAAO;CAC5F,OACE,gBAAgB,UAAU,MAAM,MAC/B,UAAU,UAAU,YAAY,KAAK,UAAU,UAAU,WAAW;AAEzE"}
|
package/dist/lib/themes.d.ts
CHANGED
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
import { type AccentPreset, type AdeaTheme, type AdeaThemeRecord } from '@adea-ai/themes';
|
|
36
36
|
import { type AccentRoles } from './accent-roles';
|
|
37
37
|
export { isThemeAccentId } from './theme-accents';
|
|
38
|
+
export { terminalCssVariables, tokensAsHex } from './theme-css';
|
|
39
|
+
export { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from './theme-defaults';
|
|
38
40
|
export type ThemeAppearance = 'light' | 'dark';
|
|
39
41
|
/**
|
|
40
42
|
* The surface and text roles, in shadcn's vocabulary.
|
|
@@ -174,27 +176,15 @@ export declare function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant;
|
|
|
174
176
|
* catalogue has nothing to measure, and gets its appearance's ceiling.
|
|
175
177
|
*/
|
|
176
178
|
export declare function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string;
|
|
177
|
-
/** The catalogue, in catalogue order. */
|
|
178
|
-
export declare const builtinThemes: readonly ThemeVariant[];
|
|
179
|
-
export declare function themeById(id: string): ThemeVariant | undefined;
|
|
180
179
|
/**
|
|
181
|
-
* The
|
|
182
|
-
*
|
|
183
|
-
* An id the registry does not hold — an imported theme that was deleted, a
|
|
184
|
-
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
185
|
-
* being shown*. Falling back to whichever variant happens to be first in the
|
|
186
|
-
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
187
|
-
* the fallback is the appearance's own default, then any variant of that
|
|
188
|
-
* appearance, then the registry's first entry only when it holds nothing else.
|
|
189
|
-
*
|
|
190
|
-
* `registry` is the builtin catalogue plus whatever extras the host supplies; the
|
|
191
|
-
* stored id is never rewritten, only resolved, so a host that keeps an unknown id
|
|
192
|
-
* keeps resolving it if the theme comes back.
|
|
180
|
+
* The catalogue, in catalogue order.
|
|
193
181
|
*
|
|
194
|
-
* The
|
|
195
|
-
*
|
|
182
|
+
* The `@__PURE__` marks let a bundler drop the whole table, and with it the catalogue,
|
|
183
|
+
* from a consumer that imports only this module's catalogue-free helpers
|
|
184
|
+
* (`tokensAsHex`, `isThemeAccentId`, `resolveVariant`…) and never reads it.
|
|
196
185
|
*/
|
|
197
|
-
export declare
|
|
186
|
+
export declare const builtinThemes: readonly ThemeVariant[];
|
|
187
|
+
export declare function themeById(id: string): ThemeVariant | undefined;
|
|
198
188
|
/** The variants of one appearance, which is what a picker for that mode shows. */
|
|
199
189
|
export declare function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[];
|
|
200
190
|
/** The families in the catalogue, in catalogue order. */
|
|
@@ -358,36 +348,14 @@ export declare function editorPaletteFor(theme: ThemeVariant, mode?: EditorRoles
|
|
|
358
348
|
/**
|
|
359
349
|
* The roles a variant sets, as CSS custom properties.
|
|
360
350
|
*
|
|
361
|
-
* The
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
368
|
-
* and the design-system artifact are built without it.
|
|
351
|
+
* The mapping itself is `themeCssVariablesWith` in `theme-css.ts`; this binds it to
|
|
352
|
+
* the catalogue, which measures a theme's `--primary-subtle` strength
|
|
353
|
+
* ({@link primarySubtleFor}) and projects its floor editor ramp
|
|
354
|
+
* ({@link editorPaletteFor}). Absent `options`, the result is what it has always
|
|
355
|
+
* been; the generated `theme-variants.css` and the design-system artifact are built
|
|
356
|
+
* without it.
|
|
369
357
|
*/
|
|
370
358
|
export declare function themeCssVariables(theme: ThemeVariant, options?: ThemeCssVariableOptions): Record<string, string>;
|
|
371
|
-
/**
|
|
372
|
-
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
373
|
-
*
|
|
374
|
-
* What a pinned terminal theme writes over the interface variant's own. Taken from
|
|
375
|
-
* {@link themeCssVariables} rather than rebuilt, so the names, and a custom
|
|
376
|
-
* variant's verbatim `tokens`, can never drift from what the interface variant
|
|
377
|
-
* would have written for the same palette.
|
|
378
|
-
*/
|
|
379
|
-
export declare function terminalCssVariables(theme: ThemeVariant): Record<string, string>;
|
|
380
|
-
/**
|
|
381
|
-
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
382
|
-
*
|
|
383
|
-
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
384
|
-
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
385
|
-
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
386
|
-
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
387
|
-
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
388
|
-
* `ThemeProvider`'s `transformTokens`.
|
|
389
|
-
*/
|
|
390
|
-
export declare function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string>;
|
|
391
359
|
export type ThemeFinding = {
|
|
392
360
|
themeId: string;
|
|
393
361
|
role: string;
|
|
@@ -397,8 +365,6 @@ export type ThemeFinding = {
|
|
|
397
365
|
export declare function validateTheme(theme: ThemeVariant): ThemeFinding[];
|
|
398
366
|
/** Validates the whole registry, including the catalogue-level invariants. */
|
|
399
367
|
export declare function validateThemeRegistry(themes?: readonly ThemeVariant[]): ThemeFinding[];
|
|
400
|
-
export declare const defaultLightThemeId = "adea-light";
|
|
401
|
-
export declare const defaultDarkThemeId = "adea-dark";
|
|
402
368
|
/** Re-exported so a consumer measuring a colour does not need a second import. */
|
|
403
369
|
export { contrastRatio } from '@adea-ai/themes';
|
|
404
370
|
//# sourceMappingURL=themes.d.ts.map
|
package/dist/lib/themes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/lib/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/lib/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAiBL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAK9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE1F,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAA;AAE9C;;;;;;GAMG;AACH,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YAAY,EAAE,CAMjE;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,SAAS,YAAY,EAAkB,GAC9C,YAAY,EAAE,CAchB;AAED,kFAAkF;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/lib/themes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { accentOverrideVariables, resolveAccentRoles } from "./accent-roles.js";
|
|
2
2
|
import { isThemeAccentId } from "./theme-accents.js";
|
|
3
|
-
import {
|
|
3
|
+
import { terminalCssVariables, themeCssVariablesWith, tokensAsHex } from "./theme-css.js";
|
|
4
|
+
import { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from "./theme-defaults.js";
|
|
5
|
+
import { ACCENTS, accentForeground, chartSeries, contrastRatio, editorRolesHex, getAccent, getTheme, hasTheme, primarySubtleCss, shadcnDestructiveProjection, statusForeground, syntaxRoles, themeAccentPresets, themes, themesByAppearance, tint, validateCatalogue } from "@adea-ai/themes";
|
|
4
6
|
import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
|
|
5
|
-
import { oklchToHex, parseColor } from "@adea-ai/themes/oklch";
|
|
6
7
|
//#region src/lib/themes.ts
|
|
7
8
|
/**
|
|
8
9
|
* The theme registry, now a bridge.
|
|
@@ -203,34 +204,17 @@ function primarySubtleFor(theme) {
|
|
|
203
204
|
const record = getTheme(theme.id);
|
|
204
205
|
return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance);
|
|
205
206
|
}
|
|
206
|
-
/** The catalogue, in catalogue order. */
|
|
207
|
-
var builtinThemes = Object.freeze(themes.map(lazyVariant));
|
|
208
|
-
function themeById(id) {
|
|
209
|
-
if (!hasTheme(id)) return void 0;
|
|
210
|
-
return builtinThemes.find((theme) => theme.id === id);
|
|
211
|
-
}
|
|
212
207
|
/**
|
|
213
|
-
* The
|
|
214
|
-
*
|
|
215
|
-
* An id the registry does not hold — an imported theme that was deleted, a
|
|
216
|
-
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
217
|
-
* being shown*. Falling back to whichever variant happens to be first in the
|
|
218
|
-
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
219
|
-
* the fallback is the appearance's own default, then any variant of that
|
|
220
|
-
* appearance, then the registry's first entry only when it holds nothing else.
|
|
208
|
+
* The catalogue, in catalogue order.
|
|
221
209
|
*
|
|
222
|
-
* `
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
|
|
227
|
-
* Copyright (c) 2026 Wing); see NOTICE.
|
|
210
|
+
* The `@__PURE__` marks let a bundler drop the whole table, and with it the catalogue,
|
|
211
|
+
* from a consumer that imports only this module's catalogue-free helpers
|
|
212
|
+
* (`tokensAsHex`, `isThemeAccentId`, `resolveVariant`…) and never reads it.
|
|
228
213
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
return registry.find((variant) => variant.id === defaultId) ?? registry.find((variant) => variant.appearance === appearance) ?? registry[0];
|
|
214
|
+
var builtinThemes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ themes.map(lazyVariant));
|
|
215
|
+
function themeById(id) {
|
|
216
|
+
if (!hasTheme(id)) return void 0;
|
|
217
|
+
return builtinThemes.find((theme) => theme.id === id);
|
|
234
218
|
}
|
|
235
219
|
/** The variants of one appearance, which is what a picker for that mode shows. */
|
|
236
220
|
function themesForAppearance(appearance) {
|
|
@@ -251,6 +235,8 @@ function themeFamilies() {
|
|
|
251
235
|
}
|
|
252
236
|
return [...families.values()];
|
|
253
237
|
}
|
|
238
|
+
/** The accent presets, in the order a picker should show them. */
|
|
239
|
+
var accents = ACCENTS;
|
|
254
240
|
/**
|
|
255
241
|
* The canonical catalogue records, in catalogue order.
|
|
256
242
|
*
|
|
@@ -452,142 +438,18 @@ function editorPaletteFor(theme, mode = "syntax") {
|
|
|
452
438
|
/**
|
|
453
439
|
* The roles a variant sets, as CSS custom properties.
|
|
454
440
|
*
|
|
455
|
-
* The
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
462
|
-
* and the design-system artifact are built without it.
|
|
441
|
+
* The mapping itself is `themeCssVariablesWith` in `theme-css.ts`; this binds it to
|
|
442
|
+
* the catalogue, which measures a theme's `--primary-subtle` strength
|
|
443
|
+
* ({@link primarySubtleFor}) and projects its floor editor ramp
|
|
444
|
+
* ({@link editorPaletteFor}). Absent `options`, the result is what it has always
|
|
445
|
+
* been; the generated `theme-variants.css` and the design-system artifact are built
|
|
446
|
+
* without it.
|
|
463
447
|
*/
|
|
464
448
|
function themeCssVariables(theme, options = {}) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
"--background": c.background,
|
|
470
|
-
"--foreground": c.foreground,
|
|
471
|
-
"--card": c.card,
|
|
472
|
-
"--card-foreground": c.cardForeground,
|
|
473
|
-
"--popover": c.popover,
|
|
474
|
-
"--popover-foreground": c.popoverForeground,
|
|
475
|
-
"--primary": c.primary,
|
|
476
|
-
"--primary-foreground": c.primaryForeground,
|
|
477
|
-
"--primary-hover": primaryHover(c.primary, theme.appearance),
|
|
478
|
-
"--primary-subtle": primarySubtleFor(theme),
|
|
479
|
-
"--secondary": c.secondary,
|
|
480
|
-
"--secondary-foreground": c.secondaryForeground,
|
|
481
|
-
"--muted": c.muted,
|
|
482
|
-
"--muted-foreground": c.mutedForeground,
|
|
483
|
-
"--accent": c.accent,
|
|
484
|
-
"--accent-foreground": c.accentForeground,
|
|
485
|
-
"--destructive": c.destructive,
|
|
486
|
-
"--destructive-foreground": c.destructiveForeground,
|
|
487
|
-
"--destructive-subtle": c.destructiveSubtle,
|
|
488
|
-
"--destructive-action": c.destructiveAction,
|
|
489
|
-
"--destructive-action-foreground": c.destructiveActionForeground,
|
|
490
|
-
"--success": c.success,
|
|
491
|
-
"--success-foreground": c.successForeground,
|
|
492
|
-
"--success-subtle": c.successSubtle,
|
|
493
|
-
"--warning": c.warning,
|
|
494
|
-
"--warning-foreground": c.warningForeground,
|
|
495
|
-
"--warning-subtle": c.warningSubtle,
|
|
496
|
-
"--info": c.info,
|
|
497
|
-
"--info-foreground": c.infoForeground,
|
|
498
|
-
"--info-subtle": c.infoSubtle,
|
|
499
|
-
"--border": c.border,
|
|
500
|
-
"--input": c.input,
|
|
501
|
-
"--ring": c.ring,
|
|
502
|
-
"--sidebar": c.sidebar,
|
|
503
|
-
"--sidebar-foreground": c.sidebarForeground,
|
|
504
|
-
"--sidebar-accent": c.sidebarAccent,
|
|
505
|
-
"--sidebar-border": c.sidebarBorder,
|
|
506
|
-
"--sidebar-primary": c.primary,
|
|
507
|
-
"--sidebar-primary-foreground": c.primaryForeground,
|
|
508
|
-
"--sidebar-ring": c.ring,
|
|
509
|
-
"--sidebar-muted-foreground": c.sidebarMutedForeground,
|
|
510
|
-
"--surface-sunken": c.muted,
|
|
511
|
-
"--surface-hover": c.accent,
|
|
512
|
-
"--surface-active": c.border,
|
|
513
|
-
"--chrome": c.background,
|
|
514
|
-
"--terminal-background": t.background,
|
|
515
|
-
"--terminal-foreground": t.foreground,
|
|
516
|
-
"--terminal-cursor": t.cursor,
|
|
517
|
-
"--terminal-selection": t.selection,
|
|
518
|
-
"--terminal-ansi-black": t.black,
|
|
519
|
-
"--terminal-ansi-red": t.red,
|
|
520
|
-
"--terminal-ansi-green": t.green,
|
|
521
|
-
"--terminal-ansi-yellow": t.yellow,
|
|
522
|
-
"--terminal-ansi-blue": t.blue,
|
|
523
|
-
"--terminal-ansi-magenta": t.magenta,
|
|
524
|
-
"--terminal-ansi-cyan": t.cyan,
|
|
525
|
-
"--terminal-ansi-white": t.white,
|
|
526
|
-
"--terminal-ansi-bright-black": t.brightBlack,
|
|
527
|
-
"--terminal-ansi-bright-red": t.brightRed,
|
|
528
|
-
"--terminal-ansi-bright-green": t.brightGreen,
|
|
529
|
-
"--terminal-ansi-bright-yellow": t.brightYellow,
|
|
530
|
-
"--terminal-ansi-bright-blue": t.brightBlue,
|
|
531
|
-
"--terminal-ansi-bright-magenta": t.brightMagenta,
|
|
532
|
-
"--terminal-ansi-bright-cyan": t.brightCyan,
|
|
533
|
-
"--terminal-ansi-bright-white": t.brightWhite,
|
|
534
|
-
"--editor-keyword": e.keyword,
|
|
535
|
-
"--editor-string": e.string,
|
|
536
|
-
"--editor-number": e.number,
|
|
537
|
-
"--editor-comment": e.comment,
|
|
538
|
-
"--editor-function": e.function,
|
|
539
|
-
"--editor-variable": e.variable,
|
|
540
|
-
"--editor-type": e.type,
|
|
541
|
-
"--editor-tag": e.tag,
|
|
542
|
-
"--editor-attribute": e.attribute,
|
|
543
|
-
"--editor-operator": e.operator,
|
|
544
|
-
"--editor-heading": e.heading,
|
|
545
|
-
"--editor-link": e.link,
|
|
546
|
-
"--editor-diff-add": e.diffAdd,
|
|
547
|
-
"--editor-diff-delete": e.diffDelete,
|
|
548
|
-
"--editor-diff-hunk": e.diffHunk,
|
|
549
|
-
"--editor-search-match": e.searchMatch,
|
|
550
|
-
"--chart-1": theme.chart[0] ?? c.primary,
|
|
551
|
-
"--chart-2": theme.chart[1] ?? c.info,
|
|
552
|
-
"--chart-3": theme.chart[2] ?? c.success,
|
|
553
|
-
"--chart-4": theme.chart[3] ?? c.warning,
|
|
554
|
-
"--chart-5": theme.chart[4] ?? c.destructive,
|
|
555
|
-
"--chart-6": theme.chart[5] ?? c.mutedForeground
|
|
556
|
-
};
|
|
557
|
-
return theme.tokens ? {
|
|
558
|
-
...derived,
|
|
559
|
-
...theme.tokens
|
|
560
|
-
} : derived;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
564
|
-
*
|
|
565
|
-
* What a pinned terminal theme writes over the interface variant's own. Taken from
|
|
566
|
-
* {@link themeCssVariables} rather than rebuilt, so the names, and a custom
|
|
567
|
-
* variant's verbatim `tokens`, can never drift from what the interface variant
|
|
568
|
-
* would have written for the same palette.
|
|
569
|
-
*/
|
|
570
|
-
function terminalCssVariables(theme) {
|
|
571
|
-
return Object.fromEntries(Object.entries(themeCssVariables(theme)).filter(([name]) => name.startsWith("--terminal-")));
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
575
|
-
*
|
|
576
|
-
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
577
|
-
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
578
|
-
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
579
|
-
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
580
|
-
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
581
|
-
* `ThemeProvider`'s `transformTokens`.
|
|
582
|
-
*/
|
|
583
|
-
function tokensAsHex(tokens) {
|
|
584
|
-
const converted = {};
|
|
585
|
-
for (const [name, value] of Object.entries(tokens)) {
|
|
586
|
-
const trimmed = value.trim();
|
|
587
|
-
const parsed = trimmed.startsWith("oklch(") && !trimmed.includes("/") ? parseColor(trimmed) : void 0;
|
|
588
|
-
converted[name] = parsed ? oklchToHex(parsed) : value;
|
|
589
|
-
}
|
|
590
|
-
return converted;
|
|
449
|
+
return themeCssVariablesWith({
|
|
450
|
+
primarySubtle: primarySubtleFor,
|
|
451
|
+
editor: (variant, mode) => editorPaletteFor(variant, mode)
|
|
452
|
+
}, theme, options);
|
|
591
453
|
}
|
|
592
454
|
function toFinding(finding) {
|
|
593
455
|
return {
|
|
@@ -615,9 +477,7 @@ function validateThemeRegistry(themes$1 = builtinThemes) {
|
|
|
615
477
|
message: `${theme.id} is in the registry but not in the catalogue`
|
|
616
478
|
})), ...validateCatalogue(records).map(toFinding)];
|
|
617
479
|
}
|
|
618
|
-
var defaultLightThemeId = "adea-light";
|
|
619
|
-
var defaultDarkThemeId = "adea-dark";
|
|
620
480
|
//#endregion
|
|
621
|
-
export { accentRolesForSelection, accentVariables, appearancePreviewThemes, builtinThemes, contrastRatio
|
|
481
|
+
export { accentRolesForSelection, accentVariables, accents, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, editorPaletteFor, floorEditorPalette, isCatalogueVariant, isThemeAccentId, primarySubtleFor, resolveAccentPreset, resolveVariant, terminalCssVariables, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent };
|
|
622
482
|
|
|
623
483
|
//# sourceMappingURL=themes.js.map
|