@adea-ai/ui 0.123.1 → 0.125.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/dist/NOTICE +36 -0
- package/dist/components/theme/appearance-panel.js +1 -1
- package/dist/components/theme/index.d.ts +1 -1
- package/dist/components/theme/index.d.ts.map +1 -1
- package/dist/components/theme/index.js +5 -2
- package/dist/components/theme/theme-context.d.ts +13 -0
- package/dist/components/theme/theme-context.d.ts.map +1 -0
- package/dist/components/theme/theme-context.js +41 -0
- package/dist/components/theme/theme-context.js.map +1 -0
- package/dist/components/theme/theme-document.d.ts +82 -0
- package/dist/components/theme/theme-document.d.ts.map +1 -0
- package/dist/components/theme/theme-document.js +98 -0
- package/dist/components/theme/theme-document.js.map +1 -0
- package/dist/components/theme/theme-persistence.d.ts +50 -0
- package/dist/components/theme/theme-persistence.d.ts.map +1 -0
- package/dist/components/theme/theme-persistence.js +87 -0
- package/dist/components/theme/theme-persistence.js.map +1 -0
- package/dist/components/theme/theme-provider.d.ts +52 -75
- package/dist/components/theme/theme-provider.d.ts.map +1 -1
- package/dist/components/theme/theme-provider.js +60 -116
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-state.d.ts +167 -0
- package/dist/components/theme/theme-state.d.ts.map +1 -0
- package/dist/components/theme/theme-state.js +122 -0
- package/dist/components/theme/theme-state.js.map +1 -0
- package/dist/components/theme/theme-toggle.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/lib/accent-roles.d.ts +124 -0
- package/dist/lib/accent-roles.d.ts.map +1 -0
- package/dist/lib/accent-roles.js +163 -0
- package/dist/lib/accent-roles.js.map +1 -0
- package/dist/lib/appearance-font-settings.d.ts +1 -1
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/themes.d.ts +71 -1
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +172 -48
- package/dist/lib/themes.js.map +1 -1
- package/dist/r/lib.json +5 -0
- package/dist/r/registry.json +25 -0
- package/dist/r/src/components/theme/index.ts +3 -0
- package/dist/r/src/components/theme/theme-context.ts +43 -0
- package/dist/r/src/components/theme/theme-document.ts +184 -0
- package/dist/r/src/components/theme/theme-persistence.ts +143 -0
- package/dist/r/src/components/theme/theme-provider.tsx +147 -253
- package/dist/r/src/components/theme/theme-state.ts +274 -0
- package/dist/r/src/lib/accent-roles.ts +338 -0
- package/dist/r/src/lib/appearance-font-settings.ts +1 -1
- package/dist/r/src/lib/themes.ts +225 -59
- package/dist/r/theming.json +20 -0
- package/package.json +1 -1
- package/registry.json +25 -0
- package/src/components/theme/index.ts +3 -0
- package/src/components/theme/theme-context.ts +43 -0
- package/src/components/theme/theme-document.ts +184 -0
- package/src/components/theme/theme-persistence.ts +143 -0
- package/src/components/theme/theme-provider.tsx +147 -253
- package/src/components/theme/theme-state.ts +274 -0
- package/src/index.ts +11 -0
- package/src/lib/accent-roles.ts +338 -0
- package/src/lib/appearance-font-settings.ts +1 -1
- package/src/lib/themes.ts +225 -59
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type AppearanceEditorFontSettings } from '#lib/appearance-font-settings';
|
|
2
|
+
import type { AccentPreset } from '@adea-ai/themes';
|
|
3
|
+
import { type AccentRoles } from '#lib/accent-roles';
|
|
4
|
+
import { type ThemeAppearance, type ThemeVariant } from '#lib/themes';
|
|
5
|
+
/**
|
|
6
|
+
* The pure half of the theme provider: what a selection is, how two selections
|
|
7
|
+
* merge, and what a selection resolves to.
|
|
8
|
+
*
|
|
9
|
+
* Nothing here touches the document, storage or a signal, so each rule can be
|
|
10
|
+
* tested by calling it. `ThemeProvider` owns the reactivity and wires these to it;
|
|
11
|
+
* `theme-document.ts` owns the writes; `theme-persistence.ts` owns the store.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Four independent choices, and keeping them independent is the point:
|
|
15
|
+
*
|
|
16
|
+
* - **appearance** — light, dark, or follow the system.
|
|
17
|
+
* - **a theme per appearance** — so a user can run Catppuccin Mocha by night and
|
|
18
|
+
* Solarized Light by day without re-choosing when the system flips.
|
|
19
|
+
* - **an accent** — adea's six presets, or one of the accents the selected theme
|
|
20
|
+
* pair carries itself (`ansi-blue`…), which re-colour the interactive roles on
|
|
21
|
+
* top of whichever theme is active.
|
|
22
|
+
* - **fonts** — separate family and size choices for UI, content and code.
|
|
23
|
+
*/
|
|
24
|
+
export type ThemeSelection = {
|
|
25
|
+
/** `system` follows `prefers-color-scheme` and updates when it changes. */
|
|
26
|
+
appearance: ThemeAppearance | 'system';
|
|
27
|
+
/** The variant to use when the resolved appearance is light. */
|
|
28
|
+
lightThemeId: string;
|
|
29
|
+
/** The variant to use when the resolved appearance is dark. */
|
|
30
|
+
darkThemeId: string;
|
|
31
|
+
/**
|
|
32
|
+
* An `accentPresets` id, a theme accent id from `themeAccents()` (`ansi-blue`…),
|
|
33
|
+
* `theme` for the variant's own primary, or a custom colour as `#rrggbb`. A theme
|
|
34
|
+
* accent the current pair does not offer falls back to the variant's own primary.
|
|
35
|
+
*
|
|
36
|
+
* A custom colour is stored lower case and is raised to the contrast floor when it
|
|
37
|
+
* is painted, never when it is stored: the selection keeps what the user chose.
|
|
38
|
+
* Anything else that is not an id is dropped at paint, not rejected here.
|
|
39
|
+
*/
|
|
40
|
+
accent: string;
|
|
41
|
+
/** UI-family alias for consumers of the original single-font preference. */
|
|
42
|
+
font: string;
|
|
43
|
+
/** UI, content and code font settings. Omitted legacy records are migrated from `font`. */
|
|
44
|
+
fonts?: AppearanceEditorFontSettings;
|
|
45
|
+
/**
|
|
46
|
+
* `comfortable` is the system's default geometry; `compact` moves the control
|
|
47
|
+
* ladder down one rung.
|
|
48
|
+
*
|
|
49
|
+
* Optional, and defaulted on read, so a preference stored before density existed
|
|
50
|
+
* keeps working and `ThemeSelection` stays assignable without it.
|
|
51
|
+
*/
|
|
52
|
+
density?: ThemeDensity;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The two density rungs.
|
|
56
|
+
*
|
|
57
|
+
* `comfortable` is the geometry in `theme.css`, so it is the absence of an
|
|
58
|
+
* attribute rather than a value: a document that ships no `data-density` at all
|
|
59
|
+
* renders correctly, which is what keeps this additive.
|
|
60
|
+
*/
|
|
61
|
+
export type ThemeDensity = 'comfortable' | 'compact';
|
|
62
|
+
/**
|
|
63
|
+
* Deliberately lists only the fields every consumer has always had. A field added
|
|
64
|
+
* to {@link ThemeSelection} later gets no default here: `JSON.stringify` drops an
|
|
65
|
+
* `undefined`, so a store written by a consumer that never sets the field stays
|
|
66
|
+
* byte-identical to what it was before the field existed.
|
|
67
|
+
*/
|
|
68
|
+
export declare const defaultThemeSelection: ThemeSelection;
|
|
69
|
+
/**
|
|
70
|
+
* A stored selection's density, defaulted.
|
|
71
|
+
*
|
|
72
|
+
* The stored value is read through here rather than trusted, because a preference
|
|
73
|
+
* written before density existed has no `density` key and a hand-edited store may
|
|
74
|
+
* hold anything.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolvedDensity(selection: ThemeSelection): ThemeDensity;
|
|
77
|
+
export type ThemeContextValue = {
|
|
78
|
+
/** The preference as stored. A {@link ThemeContextValue.preview} does not change it. */
|
|
79
|
+
selection: () => ThemeSelection;
|
|
80
|
+
/** What the preference resolves to right now, after `system`. */
|
|
81
|
+
resolvedAppearance: () => ThemeAppearance;
|
|
82
|
+
/** The variant in use. */
|
|
83
|
+
variant: () => ThemeVariant;
|
|
84
|
+
/** Update part of the preference. */
|
|
85
|
+
setSelection: (patch: Partial<ThemeSelection>) => void;
|
|
86
|
+
/**
|
|
87
|
+
* The built-in catalogue, so a picker does not import it separately. A plain
|
|
88
|
+
* array: {@link ThemeContextValue.allThemes} is the one that follows a host's
|
|
89
|
+
* extra themes.
|
|
90
|
+
*/
|
|
91
|
+
themes: readonly ThemeVariant[];
|
|
92
|
+
/**
|
|
93
|
+
* The accents the selected light/dark pair carries, offered beside the presets.
|
|
94
|
+
* Follows the selection: a different theme pair may offer different slots.
|
|
95
|
+
*/
|
|
96
|
+
themeAccents: () => readonly AccentPreset[];
|
|
97
|
+
/**
|
|
98
|
+
* The built-in catalogue followed by the provider's `themes` prop. Reactive when
|
|
99
|
+
* that prop is a function that reads signals.
|
|
100
|
+
*/
|
|
101
|
+
allThemes: () => readonly ThemeVariant[];
|
|
102
|
+
/**
|
|
103
|
+
* Paint the document from `draft` laid over the stored selection, without
|
|
104
|
+
* persisting it or changing what {@link ThemeContextValue.selection} returns.
|
|
105
|
+
* `undefined` ends the preview. A {@link ThemeContextValue.setSelection} ends it
|
|
106
|
+
* too, because the committed selection is then what should be showing.
|
|
107
|
+
*/
|
|
108
|
+
preview: (draft: Partial<ThemeSelection> | undefined) => void;
|
|
109
|
+
/** True while a {@link ThemeContextValue.preview} draft is on the document. */
|
|
110
|
+
previewing: () => boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The roles `accent` paints over `variantId` (default: the variant in use), held
|
|
113
|
+
* to the provider's `accentContrastFloor`, for an element-scoped override with
|
|
114
|
+
* `paintAccentRoles` — a workspace that carries its own colour. `undefined` for
|
|
115
|
+
* `null`, for `theme`, for an id that resolves to nothing, and for a variant the
|
|
116
|
+
* registry does not hold: each means "keep the inherited accent".
|
|
117
|
+
*/
|
|
118
|
+
accentRolesFor: (accent: string | null, variantId?: string) => AccentRoles | undefined;
|
|
119
|
+
};
|
|
120
|
+
/** Keep the deprecated single-font view synchronized with the UI axis. */
|
|
121
|
+
export declare function mergeThemeSelection(base: ThemeSelection, patch: Partial<ThemeSelection>): ThemeSelection;
|
|
122
|
+
/**
|
|
123
|
+
* The selection a provider starts from: the defaults, then whatever the store
|
|
124
|
+
* returned, then `initial`.
|
|
125
|
+
*
|
|
126
|
+
* `initial` wins over the store on every mount. That precedence is part of the
|
|
127
|
+
* contract Cortana relies on (its `initial` pins `appearance` and `font`), and it
|
|
128
|
+
* is why the store's answer is only the middle layer. A store that returned
|
|
129
|
+
* nothing, or threw, or answered with explicit `undefined`s, leaves the defaults
|
|
130
|
+
* standing for those fields.
|
|
131
|
+
*/
|
|
132
|
+
export declare function initialThemeSelection(stored: Partial<ThemeSelection> | undefined, initial: Partial<ThemeSelection> | undefined): ThemeSelection;
|
|
133
|
+
/** `system` resolved against what the operating system reports. */
|
|
134
|
+
export declare function resolveAppearance(preference: ThemeSelection['appearance'], system: ThemeAppearance): ThemeAppearance;
|
|
135
|
+
/** The theme id the selection names for a resolved appearance. */
|
|
136
|
+
export declare function selectedThemeId(selection: ThemeSelection, appearance: ThemeAppearance): string;
|
|
137
|
+
/**
|
|
138
|
+
* What a selection paints: the resolved appearance and the variant for it.
|
|
139
|
+
*
|
|
140
|
+
* An id the registry does not hold resolves to the appearance's default rather than
|
|
141
|
+
* being rewritten (see `resolveVariant`), so the selection a host stores is never
|
|
142
|
+
* changed by being unresolvable.
|
|
143
|
+
*/
|
|
144
|
+
export declare function resolveThemeState(selection: ThemeSelection, system: ThemeAppearance, registry: readonly ThemeVariant[]): {
|
|
145
|
+
appearance: ThemeAppearance;
|
|
146
|
+
variant: ThemeVariant;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The registry a provider resolves against: the catalogue, then the host's extras.
|
|
150
|
+
*
|
|
151
|
+
* The catalogue wins an id collision, because it is listed first and `resolveVariant`
|
|
152
|
+
* takes the first match: a host's variant can add a theme but cannot shadow one.
|
|
153
|
+
*/
|
|
154
|
+
export declare function mergeRegistry(builtin: readonly ThemeVariant[], extra: readonly ThemeVariant[] | undefined): readonly ThemeVariant[];
|
|
155
|
+
/**
|
|
156
|
+
* The roles an accent paints over a variant, for {@link ThemeContextValue.accentRolesFor}.
|
|
157
|
+
*
|
|
158
|
+
* Resolved against the committed selection's theme pair, so an `ansi-*` accent means
|
|
159
|
+
* the same colour here as it does on `<html>`.
|
|
160
|
+
*/
|
|
161
|
+
export declare function accentRolesForState(accent: string | null, variantId: string | undefined, state: {
|
|
162
|
+
selection: ThemeSelection;
|
|
163
|
+
variant: ThemeVariant;
|
|
164
|
+
registry: readonly ThemeVariant[];
|
|
165
|
+
accentContrastFloor?: number;
|
|
166
|
+
}): AccentRoles | undefined;
|
|
167
|
+
//# sourceMappingURL=theme-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-state.d.ts","sourceRoot":"","sources":["../../../src/components/theme/theme-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAA;AAEpB;;;;;;;GAOG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2EAA2E;IAC3E,UAAU,EAAE,eAAe,GAAG,QAAQ,CAAA;IACtC,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAA;IACnB;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAA;IACZ,2FAA2F;IAC3F,KAAK,CAAC,EAAE,4BAA4B,CAAA;IACpC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAQnC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,cAAc,GAAG,YAAY,CAEvE;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wFAA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AM,CAE9F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,SAAS,YAAY,EAAE,GAChC;IAAE,UAAU,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,GACzC,SAAS,YAAY,EAAE,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE;IACL,SAAS,EAAE,cAAc,CAAA;IACzB,OAAO,EAAE,YAAY,CAAA;IACrB,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAA;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B,GACA,WAAW,GAAG,SAAS,CAYzB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { normalizeCustomAccent } from "../../lib/accent-roles.js";
|
|
2
|
+
import { accentRolesForSelection, defaultDarkThemeId, defaultLightThemeId, resolveVariant } from "../../lib/themes.js";
|
|
3
|
+
import { DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, normalizeAppearanceEditorFontSettings } from "../../lib/appearance-font-settings.js";
|
|
4
|
+
//#region src/components/theme/theme-state.ts
|
|
5
|
+
/**
|
|
6
|
+
* Deliberately lists only the fields every consumer has always had. A field added
|
|
7
|
+
* to {@link ThemeSelection} later gets no default here: `JSON.stringify` drops an
|
|
8
|
+
* `undefined`, so a store written by a consumer that never sets the field stays
|
|
9
|
+
* byte-identical to what it was before the field existed.
|
|
10
|
+
*/
|
|
11
|
+
var defaultThemeSelection = {
|
|
12
|
+
appearance: "system",
|
|
13
|
+
lightThemeId: defaultLightThemeId,
|
|
14
|
+
darkThemeId: defaultDarkThemeId,
|
|
15
|
+
accent: "theme",
|
|
16
|
+
font: "system",
|
|
17
|
+
fonts: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,
|
|
18
|
+
density: "comfortable"
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A stored selection's density, defaulted.
|
|
22
|
+
*
|
|
23
|
+
* The stored value is read through here rather than trusted, because a preference
|
|
24
|
+
* written before density existed has no `density` key and a hand-edited store may
|
|
25
|
+
* hold anything.
|
|
26
|
+
*/
|
|
27
|
+
function resolvedDensity(selection) {
|
|
28
|
+
return selection.density === "compact" ? "compact" : "comfortable";
|
|
29
|
+
}
|
|
30
|
+
/** A selection with the `undefined` keys of a patch left out. */
|
|
31
|
+
function definedOnly(value) {
|
|
32
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
33
|
+
}
|
|
34
|
+
/** Keep the deprecated single-font view synchronized with the UI axis. */
|
|
35
|
+
function mergeThemeSelection(base, patch) {
|
|
36
|
+
const merged = {
|
|
37
|
+
...base,
|
|
38
|
+
...patch
|
|
39
|
+
};
|
|
40
|
+
let fonts;
|
|
41
|
+
if (patch.fonts !== void 0) fonts = normalizeAppearanceEditorFontSettings(patch.fonts).settings;
|
|
42
|
+
else if (patch.font !== void 0) {
|
|
43
|
+
const currentFonts = normalizeAppearanceEditorFontSettings(base.fonts, base.font).settings;
|
|
44
|
+
fonts = normalizeAppearanceEditorFontSettings({
|
|
45
|
+
...currentFonts,
|
|
46
|
+
ui: {
|
|
47
|
+
...currentFonts.ui,
|
|
48
|
+
family: patch.font
|
|
49
|
+
}
|
|
50
|
+
}).settings;
|
|
51
|
+
} else fonts = normalizeAppearanceEditorFontSettings(merged.fonts, merged.font).settings;
|
|
52
|
+
return {
|
|
53
|
+
...merged,
|
|
54
|
+
accent: normalizeCustomAccent(merged.accent) ?? merged.accent,
|
|
55
|
+
fonts,
|
|
56
|
+
font: fonts.ui.family
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The selection a provider starts from: the defaults, then whatever the store
|
|
61
|
+
* returned, then `initial`.
|
|
62
|
+
*
|
|
63
|
+
* `initial` wins over the store on every mount. That precedence is part of the
|
|
64
|
+
* contract Cortana relies on (its `initial` pins `appearance` and `font`), and it
|
|
65
|
+
* is why the store's answer is only the middle layer. A store that returned
|
|
66
|
+
* nothing, or threw, or answered with explicit `undefined`s, leaves the defaults
|
|
67
|
+
* standing for those fields.
|
|
68
|
+
*/
|
|
69
|
+
function initialThemeSelection(stored, initial) {
|
|
70
|
+
return mergeThemeSelection(mergeThemeSelection(defaultThemeSelection, definedOnly(stored ?? {})), initial ?? {});
|
|
71
|
+
}
|
|
72
|
+
/** `system` resolved against what the operating system reports. */
|
|
73
|
+
function resolveAppearance(preference, system) {
|
|
74
|
+
return preference === "system" ? system : preference;
|
|
75
|
+
}
|
|
76
|
+
/** The theme id the selection names for a resolved appearance. */
|
|
77
|
+
function selectedThemeId(selection, appearance) {
|
|
78
|
+
return appearance === "dark" ? selection.darkThemeId : selection.lightThemeId;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* What a selection paints: the resolved appearance and the variant for it.
|
|
82
|
+
*
|
|
83
|
+
* An id the registry does not hold resolves to the appearance's default rather than
|
|
84
|
+
* being rewritten (see `resolveVariant`), so the selection a host stores is never
|
|
85
|
+
* changed by being unresolvable.
|
|
86
|
+
*/
|
|
87
|
+
function resolveThemeState(selection, system, registry) {
|
|
88
|
+
const appearance = resolveAppearance(selection.appearance, system);
|
|
89
|
+
return {
|
|
90
|
+
appearance,
|
|
91
|
+
variant: resolveVariant(registry, selectedThemeId(selection, appearance), appearance)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The registry a provider resolves against: the catalogue, then the host's extras.
|
|
96
|
+
*
|
|
97
|
+
* The catalogue wins an id collision, because it is listed first and `resolveVariant`
|
|
98
|
+
* takes the first match: a host's variant can add a theme but cannot shadow one.
|
|
99
|
+
*/
|
|
100
|
+
function mergeRegistry(builtin, extra) {
|
|
101
|
+
return extra && extra.length > 0 ? [...builtin, ...extra] : builtin;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The roles an accent paints over a variant, for {@link ThemeContextValue.accentRolesFor}.
|
|
105
|
+
*
|
|
106
|
+
* Resolved against the committed selection's theme pair, so an `ansi-*` accent means
|
|
107
|
+
* the same colour here as it does on `<html>`.
|
|
108
|
+
*/
|
|
109
|
+
function accentRolesForState(accent, variantId, state) {
|
|
110
|
+
if (accent === null) return void 0;
|
|
111
|
+
const variant = variantId === void 0 ? state.variant : state.registry.find((candidate) => candidate.id === variantId);
|
|
112
|
+
if (!variant) return void 0;
|
|
113
|
+
return accentRolesForSelection(accent, variant.appearance, state.selection, {
|
|
114
|
+
background: variant.colors.background,
|
|
115
|
+
floor: state.accentContrastFloor,
|
|
116
|
+
variantId: variant.id
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { accentRolesForState, defaultThemeSelection, initialThemeSelection, mergeRegistry, mergeThemeSelection, resolveAppearance, resolveThemeState, resolvedDensity, selectedThemeId };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=theme-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-state.js","names":[],"sources":["../../../src/components/theme/theme-state.ts"],"sourcesContent":["import {\n DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n normalizeAppearanceEditorFontSettings,\n type AppearanceEditorFontSettings,\n} from '#lib/appearance-font-settings'\nimport type { AccentPreset } from '@adea-ai/themes'\nimport { normalizeCustomAccent, type AccentRoles } from '#lib/accent-roles'\nimport {\n accentRolesForSelection,\n defaultDarkThemeId,\n defaultLightThemeId,\n resolveVariant,\n type ThemeAppearance,\n type ThemeVariant,\n} from '#lib/themes'\n\n/**\n * The pure half of the theme provider: what a selection is, how two selections\n * merge, and what a selection resolves to.\n *\n * Nothing here touches the document, storage or a signal, so each rule can be\n * tested by calling it. `ThemeProvider` owns the reactivity and wires these to it;\n * `theme-document.ts` owns the writes; `theme-persistence.ts` owns the store.\n */\n\n/**\n * Four independent choices, and keeping them independent is the point:\n *\n * - **appearance** — light, dark, or follow the system.\n * - **a theme per appearance** — so a user can run Catppuccin Mocha by night and\n * Solarized Light by day without re-choosing when the system flips.\n * - **an accent** — adea's six presets, or one of the accents the selected theme\n * pair carries itself (`ansi-blue`…), which re-colour the interactive roles on\n * top of whichever theme is active.\n * - **fonts** — separate family and size choices for UI, content and code.\n */\nexport type ThemeSelection = {\n /** `system` follows `prefers-color-scheme` and updates when it changes. */\n appearance: ThemeAppearance | 'system'\n /** The variant to use when the resolved appearance is light. */\n lightThemeId: string\n /** The variant to use when the resolved appearance is dark. */\n darkThemeId: string\n /**\n * An `accentPresets` id, a theme accent id from `themeAccents()` (`ansi-blue`…),\n * `theme` for the variant's own primary, or a custom colour as `#rrggbb`. A theme\n * accent the current pair does not offer falls back to the variant's own primary.\n *\n * A custom colour is stored lower case and is raised to the contrast floor when it\n * is painted, never when it is stored: the selection keeps what the user chose.\n * Anything else that is not an id is dropped at paint, not rejected here.\n */\n accent: string\n /** UI-family alias for consumers of the original single-font preference. */\n font: string\n /** UI, content and code font settings. Omitted legacy records are migrated from `font`. */\n fonts?: AppearanceEditorFontSettings\n /**\n * `comfortable` is the system's default geometry; `compact` moves the control\n * ladder down one rung.\n *\n * Optional, and defaulted on read, so a preference stored before density existed\n * keeps working and `ThemeSelection` stays assignable without it.\n */\n density?: ThemeDensity\n}\n\n/**\n * The two density rungs.\n *\n * `comfortable` is the geometry in `theme.css`, so it is the absence of an\n * attribute rather than a value: a document that ships no `data-density` at all\n * renders correctly, which is what keeps this additive.\n */\nexport type ThemeDensity = 'comfortable' | 'compact'\n\n/**\n * Deliberately lists only the fields every consumer has always had. A field added\n * to {@link ThemeSelection} later gets no default here: `JSON.stringify` drops an\n * `undefined`, so a store written by a consumer that never sets the field stays\n * byte-identical to what it was before the field existed.\n */\nexport const defaultThemeSelection: ThemeSelection = {\n appearance: 'system',\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n accent: 'theme',\n font: 'system',\n fonts: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n density: 'comfortable',\n}\n\n/**\n * A stored selection's density, defaulted.\n *\n * The stored value is read through here rather than trusted, because a preference\n * written before density existed has no `density` key and a hand-edited store may\n * hold anything.\n */\nexport function resolvedDensity(selection: ThemeSelection): ThemeDensity {\n return selection.density === 'compact' ? 'compact' : 'comfortable'\n}\n\nexport type ThemeContextValue = {\n /** The preference as stored. A {@link ThemeContextValue.preview} does not change it. */\n selection: () => ThemeSelection\n /** What the preference resolves to right now, after `system`. */\n resolvedAppearance: () => ThemeAppearance\n /** The variant in use. */\n variant: () => ThemeVariant\n /** Update part of the preference. */\n setSelection: (patch: Partial<ThemeSelection>) => void\n /**\n * The built-in catalogue, so a picker does not import it separately. A plain\n * array: {@link ThemeContextValue.allThemes} is the one that follows a host's\n * extra themes.\n */\n themes: readonly ThemeVariant[]\n /**\n * The accents the selected light/dark pair carries, offered beside the presets.\n * Follows the selection: a different theme pair may offer different slots.\n */\n themeAccents: () => readonly AccentPreset[]\n /**\n * The built-in catalogue followed by the provider's `themes` prop. Reactive when\n * that prop is a function that reads signals.\n */\n allThemes: () => readonly ThemeVariant[]\n /**\n * Paint the document from `draft` laid over the stored selection, without\n * persisting it or changing what {@link ThemeContextValue.selection} returns.\n * `undefined` ends the preview. A {@link ThemeContextValue.setSelection} ends it\n * too, because the committed selection is then what should be showing.\n */\n preview: (draft: Partial<ThemeSelection> | undefined) => void\n /** True while a {@link ThemeContextValue.preview} draft is on the document. */\n previewing: () => boolean\n /**\n * The roles `accent` paints over `variantId` (default: the variant in use), held\n * to the provider's `accentContrastFloor`, for an element-scoped override with\n * `paintAccentRoles` — a workspace that carries its own colour. `undefined` for\n * `null`, for `theme`, for an id that resolves to nothing, and for a variant the\n * registry does not hold: each means \"keep the inherited accent\".\n */\n accentRolesFor: (accent: string | null, variantId?: string) => AccentRoles | undefined\n}\n\n/** A selection with the `undefined` keys of a patch left out. */\nfunction definedOnly<T extends object>(value: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(value).filter(([, entry]) => entry !== undefined)\n ) as Partial<T>\n}\n\n/** Keep the deprecated single-font view synchronized with the UI axis. */\nexport function mergeThemeSelection(\n base: ThemeSelection,\n patch: Partial<ThemeSelection>\n): ThemeSelection {\n const merged = { ...base, ...patch }\n let fonts: AppearanceEditorFontSettings\n\n if (patch.fonts !== undefined) {\n fonts = normalizeAppearanceEditorFontSettings(patch.fonts).settings\n } else if (patch.font !== undefined) {\n const currentFonts = normalizeAppearanceEditorFontSettings(base.fonts, base.font).settings\n fonts = normalizeAppearanceEditorFontSettings({\n ...currentFonts,\n ui: { ...currentFonts.ui, family: patch.font },\n }).settings\n } else {\n fonts = normalizeAppearanceEditorFontSettings(merged.fonts, merged.font).settings\n }\n\n return {\n ...merged,\n // One spelling for a custom colour, so equal choices compare and store equal.\n accent: normalizeCustomAccent(merged.accent) ?? merged.accent,\n fonts,\n font: fonts.ui.family,\n }\n}\n\n/**\n * The selection a provider starts from: the defaults, then whatever the store\n * returned, then `initial`.\n *\n * `initial` wins over the store on every mount. That precedence is part of the\n * contract Cortana relies on (its `initial` pins `appearance` and `font`), and it\n * is why the store's answer is only the middle layer. A store that returned\n * nothing, or threw, or answered with explicit `undefined`s, leaves the defaults\n * standing for those fields.\n */\nexport function initialThemeSelection(\n stored: Partial<ThemeSelection> | undefined,\n initial: Partial<ThemeSelection> | undefined\n): ThemeSelection {\n const base = mergeThemeSelection(defaultThemeSelection, definedOnly(stored ?? {}))\n return mergeThemeSelection(base, initial ?? {})\n}\n\n/** `system` resolved against what the operating system reports. */\nexport function resolveAppearance(\n preference: ThemeSelection['appearance'],\n system: ThemeAppearance\n): ThemeAppearance {\n return preference === 'system' ? system : preference\n}\n\n/** The theme id the selection names for a resolved appearance. */\nexport function selectedThemeId(selection: ThemeSelection, appearance: ThemeAppearance): string {\n return appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId\n}\n\n/**\n * What a selection paints: the resolved appearance and the variant for it.\n *\n * An id the registry does not hold resolves to the appearance's default rather than\n * being rewritten (see `resolveVariant`), so the selection a host stores is never\n * changed by being unresolvable.\n */\nexport function resolveThemeState(\n selection: ThemeSelection,\n system: ThemeAppearance,\n registry: readonly ThemeVariant[]\n): { appearance: ThemeAppearance; variant: ThemeVariant } {\n const appearance = resolveAppearance(selection.appearance, system)\n return {\n appearance,\n variant: resolveVariant(registry, selectedThemeId(selection, appearance), appearance),\n }\n}\n\n/**\n * The registry a provider resolves against: the catalogue, then the host's extras.\n *\n * The catalogue wins an id collision, because it is listed first and `resolveVariant`\n * takes the first match: a host's variant can add a theme but cannot shadow one.\n */\nexport function mergeRegistry(\n builtin: readonly ThemeVariant[],\n extra: readonly ThemeVariant[] | undefined\n): readonly ThemeVariant[] {\n return extra && extra.length > 0 ? [...builtin, ...extra] : builtin\n}\n\n/**\n * The roles an accent paints over a variant, for {@link ThemeContextValue.accentRolesFor}.\n *\n * Resolved against the committed selection's theme pair, so an `ansi-*` accent means\n * the same colour here as it does on `<html>`.\n */\nexport function accentRolesForState(\n accent: string | null,\n variantId: string | undefined,\n state: {\n selection: ThemeSelection\n variant: ThemeVariant\n registry: readonly ThemeVariant[]\n accentContrastFloor?: number\n }\n): AccentRoles | undefined {\n if (accent === null) return undefined\n const variant =\n variantId === undefined\n ? state.variant\n : state.registry.find((candidate) => candidate.id === variantId)\n if (!variant) return undefined\n return accentRolesForSelection(accent, variant.appearance, state.selection, {\n background: variant.colors.background,\n floor: state.accentContrastFloor,\n variantId: variant.id,\n })\n}\n"],"mappings":";;;;;;;;;;AAkFA,IAAa,wBAAwC;CACnD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;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;;;;;;AAQA,SAAgB,cACd,SACA,OACyB;CACzB,OAAO,SAAS,MAAM,SAAS,IAAI,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI;AAC9D;;;;;;;AAQA,SAAgB,oBACd,QACA,WACA,OAMyB;CACzB,IAAI,WAAW,MAAM,OAAO,KAAA;CAC5B,MAAM,UACJ,cAAc,KAAA,IACV,MAAM,UACN,MAAM,SAAS,MAAM,cAAc,UAAU,OAAO,SAAS;CACnE,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,OAAO,wBAAwB,QAAQ,QAAQ,YAAY,MAAM,WAAW;EAC1E,YAAY,QAAQ,OAAO;EAC3B,OAAO,MAAM;EACb,WAAW,QAAQ;CACrB,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../lib/utils.js";
|
|
2
2
|
import { ToggleGroup, ToggleGroupItem } from "../ui/toggle-group/toggle-group.js";
|
|
3
|
-
import { useTheme } from "./theme-
|
|
3
|
+
import { useTheme } from "./theme-context.js";
|
|
4
4
|
import { createComponent, insert, memo, mergeProps, template } from "solid-js/web";
|
|
5
5
|
import { Monitor, Moon, Sun } from "lucide-solid";
|
|
6
6
|
import { For, splitProps } from "solid-js";
|
package/dist/index.d.ts
CHANGED
|
@@ -103,8 +103,9 @@ export * from './components/composites/about-dialog';
|
|
|
103
103
|
export * from './components/composites/help-center';
|
|
104
104
|
export * from './components/composites/workspace-mark';
|
|
105
105
|
export { cn } from './lib/utils';
|
|
106
|
+
export { isCustomAccent, normalizeCustomAccent, paintAccentRoles, resolveAccentRoles, type AccentRoles, type AccentTarget, } from './lib/accent-roles';
|
|
106
107
|
export { controlInteractive, controlSize, controlSizeIcon, controlSizes, cva, surfaceInteractive, type ControlSize, type VariantProps, } from './lib/variants';
|
|
107
|
-
export { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, resolveAccentPreset, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, validateTheme, validateThemeRegistry, withAccent, type ThemeAppearance, type ThemeColors, type ThemeEditorPalette, type ThemeFinding, type ThemeProvenance, type ThemeTerminalPalette, type ThemeVariant, } from './lib/themes';
|
|
108
|
+
export { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, resolveAccentPreset, resolveVariant, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent, type ThemeAppearance, type ThemeColors, type ThemeEditorPalette, type ThemeFinding, type ThemeProvenance, type ThemeTerminalPalette, type ThemeVariant, } from './lib/themes';
|
|
108
109
|
export { keyedRows, type KeyedRow } from './lib/keyed-rows';
|
|
109
110
|
export { writeClipboardText } from './lib/clipboard';
|
|
110
111
|
export { formatBytes, formatReleaseDate, plainTextFromMarkdown } from './lib/version-notes';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oCAAoC,CAAA;AAClD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,c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;AACrB,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3F,OAAO,EACL,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -103,12 +103,16 @@ import { AttachmentCard, ThreadPanel } from "./components/conversation/thread-pa
|
|
|
103
103
|
import { PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, countLines, expandAll, findTokenRanges, formatToken, isPasteBlock, nextSeq, pruneBlocks, recollapsePastes, remapCarriedBlocks, shouldCollapse, stripTrailingBlankLines, tokenRangeAt } from "./components/conversation/paste-tokens.js";
|
|
104
104
|
import { fontOptions } from "./lib/font-catalog.js";
|
|
105
105
|
import { accentPresets, allTokens, colorTokens, densityTokens, designTokens, elevationTokens, motionTokens, radiusTokens, typographyTokens, undocumentedTokenAliases, zIndexTokens } from "./lib/tokens.js";
|
|
106
|
+
import { isCustomAccent, normalizeCustomAccent, paintAccentRoles, resolveAccentRoles } from "./lib/accent-roles.js";
|
|
106
107
|
import { isThemeAccentId } from "./lib/theme-accents.js";
|
|
107
|
-
import { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, resolveAccentPreset, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, validateTheme, validateThemeRegistry, withAccent } from "./lib/themes.js";
|
|
108
|
+
import { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, resolveAccentPreset, resolveVariant, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent } from "./lib/themes.js";
|
|
108
109
|
import { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize } from "./lib/appearance-font-settings.js";
|
|
109
110
|
import { AppearanceFontSettingsGroup } from "./components/composites/appearance-editor/font-settings-group.js";
|
|
110
111
|
import { ThemePicker, ThemePreview, ThemeSwatch } from "./components/theme/theme-picker.js";
|
|
111
|
-
import {
|
|
112
|
+
import { useOptionalTheme, useTheme } from "./components/theme/theme-context.js";
|
|
113
|
+
import { defaultThemeSelection, resolvedDensity } from "./components/theme/theme-state.js";
|
|
114
|
+
import { localStoragePersistence } from "./components/theme/theme-persistence.js";
|
|
115
|
+
import { ThemeProvider, inlineScriptLiteral, themeScript } from "./components/theme/theme-provider.js";
|
|
112
116
|
import { AppearancePanel } from "./components/theme/appearance-panel.js";
|
|
113
117
|
import { ThemeToggle } from "./components/theme/theme-toggle.js";
|
|
114
118
|
import { ThemeModeToggle } from "./components/theme/theme-mode-toggle.js";
|
|
@@ -133,4 +137,4 @@ import { AboutDialog } from "./components/composites/about-dialog/about-dialog.j
|
|
|
133
137
|
import { HelpCenter } from "./components/composites/help-center/help-center.js";
|
|
134
138
|
import { WorkspaceMark } from "./components/composites/workspace-mark/workspace-mark.js";
|
|
135
139
|
import { writeClipboardText } from "./lib/clipboard.js";
|
|
136
|
-
export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, AboutDialog, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, AspectRatio, AttachmentCard, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CalendarSurface, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChatComposer, Checkbox, CheckboxDescription, CheckboxLabel, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, ListGroup, ListRow, ListRowControl, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MessageBody, MessageComposer, MessageDayDivider, MessageGroup, MessageRow, ModalDialog, Motion, NO_FLOATING_PREVIEW_OBSTACLES, NO_PREVIEW_MINI_PLAYER_OBSTACLES, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, PREVIEW_MINI_PLAYER_CORNER_RADIUS, PREVIEW_MINI_PLAYER_EDGE_GAP, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelResizeHandle, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PropertyList, PropertyRow, PropertyTerm, PropertyValue, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Spinner, SplitLayout, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, TranscriptComposition, Tree, TreeRow, TreeRowActions, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WorkspaceMark, accentPresets, alertVariants, allTokens, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, builtinThemes, buttonVariants, cardVariants, clampFloatingPreviewPosition, clampPreviewMiniPlayerPosition, closePane, cn, colorTokens, computeLayoutFrames, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countLeaves, countLines, createAppMenuItems, createLayoutState, cva, defaultDarkThemeId, defaultLightThemeId, defaultThemeSelection, densityTokens, designTokens, diffLineVariants, diffStats, diffTargetPath, elevationTokens, entityIconVariants, expandAll, findTokenRanges, focusPane, fontOptions, fontSettingsBootstrapScript, formatBytes, formatReleaseDate, formatToken, headingElement, headingVariants, initialsFrom, inlineScriptLiteral, isPasteBlock, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, monogram, motionTokens, movePane, neighborLeaf, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeLayout, parseDiff, plainTextFromMarkdown, platformModifierKey, pruneBlocks, radiusTokens, recollapsePastes, remapCarriedBlocks, resizeFloatingPreview, resizePreviewMiniPlayer, resizeSplit, resolveAccentPreset, resolveFloatingPreviewFrame, resolvePreviewMiniPlayerFrame, resolvedDensity, searchShortcutKeyshortcuts, searchShortcutLabel, sheetVariants, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, splitPane, splitPaneBalanced, statusDotVariants, stripTrailingBlankLines, surfaceInteractive, swapPanes, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, transcriptDisclosureKey, typographyTokens, undoClosePane, undocumentedTokenAliases, useSideRail, useTheme, validateTheme, validateThemeRegistry, withAccent, writeClipboardText, zIndexTokens };
|
|
140
|
+
export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, AboutDialog, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, AspectRatio, AttachmentCard, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CalendarSurface, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChatComposer, Checkbox, CheckboxDescription, CheckboxLabel, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, ListGroup, ListRow, ListRowControl, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MessageBody, MessageComposer, MessageDayDivider, MessageGroup, MessageRow, ModalDialog, Motion, NO_FLOATING_PREVIEW_OBSTACLES, NO_PREVIEW_MINI_PLAYER_OBSTACLES, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, PREVIEW_MINI_PLAYER_CORNER_RADIUS, PREVIEW_MINI_PLAYER_EDGE_GAP, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelResizeHandle, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PropertyList, PropertyRow, PropertyTerm, PropertyValue, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Spinner, SplitLayout, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, TranscriptComposition, Tree, TreeRow, TreeRowActions, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WorkspaceMark, accentPresets, alertVariants, allTokens, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, builtinThemes, buttonVariants, cardVariants, clampFloatingPreviewPosition, clampPreviewMiniPlayerPosition, closePane, cn, colorTokens, computeLayoutFrames, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countLeaves, countLines, createAppMenuItems, createLayoutState, cva, defaultDarkThemeId, defaultLightThemeId, defaultThemeSelection, densityTokens, designTokens, diffLineVariants, diffStats, diffTargetPath, elevationTokens, entityIconVariants, expandAll, findTokenRanges, focusPane, fontOptions, fontSettingsBootstrapScript, formatBytes, formatReleaseDate, formatToken, headingElement, headingVariants, initialsFrom, inlineScriptLiteral, isCustomAccent, isPasteBlock, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, localStoragePersistence, monogram, motionTokens, movePane, neighborLeaf, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeCustomAccent, normalizeLayout, paintAccentRoles, parseDiff, plainTextFromMarkdown, platformModifierKey, pruneBlocks, radiusTokens, recollapsePastes, remapCarriedBlocks, resizeFloatingPreview, resizePreviewMiniPlayer, resizeSplit, resolveAccentPreset, resolveAccentRoles, resolveFloatingPreviewFrame, resolvePreviewMiniPlayerFrame, resolveVariant, resolvedDensity, searchShortcutKeyshortcuts, searchShortcutLabel, sheetVariants, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, splitPane, splitPaneBalanced, statusDotVariants, stripTrailingBlankLines, surfaceInteractive, swapPanes, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, tokensAsHex, transcriptDisclosureKey, typographyTokens, undoClosePane, undocumentedTokenAliases, useOptionalTheme, useSideRail, useTheme, validateTheme, validateThemeRegistry, variantFromRecord, withAccent, writeClipboardText, zIndexTokens };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { accentRoles, type AccentPreset, type AccentRoles as CatalogueAccentRoles } from '@adea-ai/themes';
|
|
2
|
+
/**
|
|
3
|
+
* Accent colour maths and the roles an accent paints.
|
|
4
|
+
*
|
|
5
|
+
* Three questions live here, and none of them touches the document or a signal:
|
|
6
|
+
*
|
|
7
|
+
* - **What colour is this?** `parseColor`, `colorToHex`, `contrastRatio` and
|
|
8
|
+
* `ensureContrast` are the hex helpers a host needs around an accent (an
|
|
9
|
+
* imported theme's colours, a colour field). Hex is the host preference format;
|
|
10
|
+
* the catalogue's colour engine does the maths.
|
|
11
|
+
* - **Is this accent readable on this surface?** The *contrast floor*. A preset is
|
|
12
|
+
* curated, so the catalogue already measured it against its own themes and the
|
|
13
|
+
* floor is the identity for it; a custom `#rrggbb` is anyone's choice, so it is
|
|
14
|
+
* raised until it clears the floor and can never ship unreadable. A host that
|
|
15
|
+
* imports themes (whose backgrounds the catalogue never saw) turns the floor on
|
|
16
|
+
* for presets too.
|
|
17
|
+
* - **Which custom properties does an accent own?** `AccentRoles`, written on
|
|
18
|
+
* `<html>` by the provider and onto one element by {@link paintAccentRoles}.
|
|
19
|
+
*/
|
|
20
|
+
export type RgbColor = Readonly<{
|
|
21
|
+
r: number;
|
|
22
|
+
g: number;
|
|
23
|
+
b: number;
|
|
24
|
+
a: number;
|
|
25
|
+
}>;
|
|
26
|
+
/** Parse a hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`). `undefined` for anything else. */
|
|
27
|
+
export declare function parseColor(value: string): RgbColor | undefined;
|
|
28
|
+
/** `#rrggbb`, or `#rrggbbaa` when the colour is not opaque. */
|
|
29
|
+
export declare function colorToHex(color: RgbColor): string;
|
|
30
|
+
/** WCAG contrast ratio between two colours. Alpha composites over the background first. */
|
|
31
|
+
export declare function contrastRatio(foreground: RgbColor | string, background: RgbColor | string): number;
|
|
32
|
+
/** Preserve the host hex shape while delegating contrast repair to the catalogue. */
|
|
33
|
+
export declare function ensureContrast(color: RgbColor, background: RgbColor, minimum: number): RgbColor;
|
|
34
|
+
/** The contrast an accent is held to against its surface unless the host sets another. */
|
|
35
|
+
export declare const DEFAULT_ACCENT_CONTRAST_FLOOR = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Normalise a custom accent against a surface: unparseable input is rejected
|
|
38
|
+
* (`undefined`), and any accepted colour is raised to `minimum` so an accent can
|
|
39
|
+
* never ship unreadable. Accepts every CSS hex length; for the stored grammar use
|
|
40
|
+
* {@link normalizeCustomAccent}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function normalizeAccentValue(value: string, background: string, minimum?: number): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The stored form of a custom accent: `#rrggbb`, six digits, opaque, lower case.
|
|
45
|
+
*
|
|
46
|
+
* Deliberately narrower than {@link parseColor}. A stored accent is compared,
|
|
47
|
+
* deduplicated and used as an attribute, so it has one spelling; a host that
|
|
48
|
+
* accepts `#abc` in a field expands it before storing. Anything else — a name, an
|
|
49
|
+
* `rgb()`, a short or alpha form, a non-string — is not an accent and returns
|
|
50
|
+
* `undefined`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function normalizeCustomAccent(value: unknown): string | undefined;
|
|
53
|
+
/** Whether a selection's accent is the custom `#rrggbb` form (any letter case). */
|
|
54
|
+
export declare function isCustomAccent(value: unknown): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The roles an accent paints, as CSS values: the catalogue's `AccentRoles`, so the
|
|
57
|
+
* provider, the generated stylesheet and a host's own paint cannot disagree about
|
|
58
|
+
* what a role is. `primarySubtle` is an expression over `var(--primary)`; the
|
|
59
|
+
* document writer never sets it (see {@link accentOverrideVariables}), an element
|
|
60
|
+
* paint must.
|
|
61
|
+
*/
|
|
62
|
+
export type AccentRoles = CatalogueAccentRoles;
|
|
63
|
+
/** What an accent resolves against: the surface it sits on and the theme it sits in. */
|
|
64
|
+
export type AccentTarget = {
|
|
65
|
+
/** The theme, or only its appearance. A theme gives the tint its measured strength. */
|
|
66
|
+
target: Parameters<typeof accentRoles>[1];
|
|
67
|
+
/** The surface the accent must read on. Without it nothing can be measured or repaired. */
|
|
68
|
+
background: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The contrast to hold the accent to against `background`. Absent, a preset is
|
|
71
|
+
* painted verbatim and a custom colour is held to {@link DEFAULT_ACCENT_CONTRAST_FLOOR}.
|
|
72
|
+
*/
|
|
73
|
+
floor?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The accents the selected theme pair carries (`ansi-blue`…), for an id that is
|
|
76
|
+
* neither a preset nor a colour.
|
|
77
|
+
*/
|
|
78
|
+
themeAccents?: readonly AccentPreset[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The roles for a preset (or a custom colour made into one), held to the floor.
|
|
82
|
+
*
|
|
83
|
+
* A preset that clears the floor keeps the catalogue's roles untouched. One that
|
|
84
|
+
* does not is repaired to the nearest passing colour and the whole role set is
|
|
85
|
+
* rebuilt from the repaired value, so the label, hover and ring follow it instead
|
|
86
|
+
* of describing a colour that is no longer on screen.
|
|
87
|
+
*/
|
|
88
|
+
export declare function accentRolesForPreset(preset: AccentPreset, context: AccentTarget): AccentRoles | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve an accent selection to its roles, or `undefined` when it overrides nothing.
|
|
91
|
+
*
|
|
92
|
+
* `undefined` is "use the theme's own primary": the literal `theme`, an id that is
|
|
93
|
+
* neither a preset, an offered theme accent nor a colour, and a colour that does not
|
|
94
|
+
* parse. A host that wants one of those to mean something else decides before
|
|
95
|
+
* asking (Adea's codec maps a stored `theme` to its default preset when it reads).
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveAccentRoles(accent: string, context: AccentTarget): AccentRoles | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The custom properties an accent override owns on `<html>`.
|
|
100
|
+
*
|
|
101
|
+
* `--primary-subtle` is deliberately not among them. It is a `color-mix()` over
|
|
102
|
+
* `var(--primary)`, so on the same element it follows an accent by itself, and its
|
|
103
|
+
* strength is the theme's, measured to keep body text at 4.5:1 on the tint.
|
|
104
|
+
* Writing one here would replace that measurement with the argument's.
|
|
105
|
+
*/
|
|
106
|
+
export declare function accentOverrideVariables(roles: AccentRoles): Record<string, string>;
|
|
107
|
+
/** The custom properties {@link paintAccentRoles} writes and clears. */
|
|
108
|
+
export declare const ACCENT_PAINT_PROPERTIES: readonly ["--primary", "--primary-foreground", "--primary-hover", "--primary-subtle", "--ring"];
|
|
109
|
+
/**
|
|
110
|
+
* Scope an accent to one element and its descendants.
|
|
111
|
+
*
|
|
112
|
+
* Unlike the document, an element must write `--primary-subtle` too. A custom
|
|
113
|
+
* property that uses `var()` is resolved where it is declared, so the tint inherited
|
|
114
|
+
* from `<html>` is already a mix over *`<html>`'s* primary and an element that only
|
|
115
|
+
* overrides `--primary` would keep the old tint. Declared here, the same expression
|
|
116
|
+
* resolves against this element's primary.
|
|
117
|
+
*
|
|
118
|
+
* `undefined` clears every property, and the element inherits the document's accent
|
|
119
|
+
* again.
|
|
120
|
+
*/
|
|
121
|
+
export declare function paintAccentRoles(element: {
|
|
122
|
+
style: Pick<CSSStyleDeclaration, 'setProperty' | 'removeProperty'>;
|
|
123
|
+
}, roles: AccentRoles | undefined): void;
|
|
124
|
+
//# sourceMappingURL=accent-roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accent-roles.d.ts","sourceRoot":"","sources":["../../src/lib/accent-roles.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,WAAW,EAGX,KAAK,YAAY,EACjB,KAAK,WAAW,IAAI,oBAAoB,EACzC,MAAM,iBAAiB,CAAA;AAUxB;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAI/E,mGAAmG;AACnG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAc9D;AAMD,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAGlD;AAiBD,2FAA2F;AAC3F,wBAAgB,aAAa,CAC3B,UAAU,EAAE,QAAQ,GAAG,MAAM,EAC7B,UAAU,EAAE,QAAQ,GAAG,MAAM,GAC5B,MAAM,CASR;AAyBD,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAQ/F;AAED,0FAA0F;AAC1F,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAE9C;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,E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