@aglyn/shared-ui-theme 1.27.0 → 1.29.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-ui-theme",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-data-types": "1.
|
|
29
|
-
"@aglyn/shared-util-tools": "1.
|
|
30
|
-
"@aglyn/shared-util-vendor": "1.
|
|
28
|
+
"@aglyn/shared-data-types": "1.29.0",
|
|
29
|
+
"@aglyn/shared-util-tools": "1.29.0",
|
|
30
|
+
"@aglyn/shared-util-vendor": "1.29.0",
|
|
31
31
|
"@emotion/cache": "^11.14.0",
|
|
32
32
|
"@emotion/react": "11.14.0",
|
|
33
33
|
"@swc/helpers": "0.5.24",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { HostTheme, HostThemeScheme } from '@aglyn/shared-data-types';
|
|
7
|
-
import { type ThemeColorToken, type ThemeComponentLookId } from './theme-editor-fields';
|
|
7
|
+
import { type ThemeColorToken, type ThemeComponentLookId, type ThemeFontSelection } from './theme-editor-fields';
|
|
8
8
|
/** One control's change; a null value clears it back to the theme's own. */
|
|
9
9
|
export type ThemeEditorEdit = {
|
|
10
10
|
control: 'color';
|
|
@@ -17,6 +17,15 @@ export type ThemeEditorEdit = {
|
|
|
17
17
|
} | {
|
|
18
18
|
control: 'fontFamily';
|
|
19
19
|
value: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The fonts plugin's picker (AGL-3656): the body font and the heading font
|
|
23
|
+
* together, as its `writeThemeFonts` writes them; a null role is the
|
|
24
|
+
* theme default (body) or "same as body text" (heading).
|
|
25
|
+
*/
|
|
26
|
+
| {
|
|
27
|
+
control: 'fonts';
|
|
28
|
+
value: ThemeFontSelection;
|
|
20
29
|
} | {
|
|
21
30
|
control: 'borderRadius';
|
|
22
31
|
value: number | null;
|
|
@@ -36,6 +45,9 @@ export type ThemeEditorEdit = {
|
|
|
36
45
|
};
|
|
37
46
|
/** The most edits one save may carry: every color of both schemes and the rest. */
|
|
38
47
|
export declare const THEME_EDITOR_EDITS_MAX: number;
|
|
48
|
+
/** The longest family name a font choice may carry, and the most weights in either list. */
|
|
49
|
+
export declare const THEME_FONT_FAMILY_MAX = 100;
|
|
50
|
+
export declare const THEME_FONT_WEIGHTS_MAX = 20;
|
|
39
51
|
/** One edit from a request body, or why it was refused. */
|
|
40
52
|
export declare function readThemeEditorEdit(raw: unknown): ThemeEditorEdit | string;
|
|
41
53
|
/** Every edit of a request body, or the first refusal. */
|
|
@@ -47,6 +59,8 @@ export interface ThemeEditorValues {
|
|
|
47
59
|
colors: Record<HostThemeScheme, Record<string, string | null>>;
|
|
48
60
|
darkScheme: 'auto' | 'off';
|
|
49
61
|
fontFamily: string;
|
|
62
|
+
/** The fonts plugin's body and heading fonts (`readThemeFonts`). */
|
|
63
|
+
fonts: ThemeFontSelection;
|
|
50
64
|
borderRadius: number | null;
|
|
51
65
|
spacing: number | null;
|
|
52
66
|
navHeight: {
|
|
@@ -3,9 +3,55 @@
|
|
|
3
3
|
* Copyright 2026 Aglyn LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
6
|
-
import { BORDER_RADIUS_FIELD, DARK_SCHEME_FIELD, GOOGLE_FONT_OPTIONS, SPACING_FIELD, SYSTEM_FONT_VALUE, THEME_COLOR_FIELDS, THEME_COMPONENT_LOOK_FIELDS, THEME_COMPONENT_LOOK_GROUPS, THEME_EDITOR_SCHEMES, THEME_LOOK_DEFAULT, TOOLBAR_HEIGHT_FIELDS, readComponentLook, readDarkScheme, readFontFamily, readThemeColor, readToolbarHeight, themeComponentLookField, writeBorderRadius, writeComponentLook, writeDarkScheme, writeFontFamily, writeSpacing, writeThemeColor, writeToolbarHeight } from "./theme-editor-fields.js";
|
|
6
|
+
import { BORDER_RADIUS_FIELD, DARK_SCHEME_FIELD, GOOGLE_FONT_OPTIONS, SPACING_FIELD, SYSTEM_FONT_VALUE, THEME_COLOR_FIELDS, THEME_COMPONENT_LOOK_FIELDS, THEME_COMPONENT_LOOK_GROUPS, THEME_EDITOR_SCHEMES, THEME_LOOK_DEFAULT, TOOLBAR_HEIGHT_FIELDS, readComponentLook, readDarkScheme, readFontFamily, readThemeColor, readThemeFonts, readToolbarHeight, themeComponentLookField, writeBorderRadius, writeComponentLook, writeDarkScheme, writeFontFamily, writeSpacing, writeThemeColor, writeThemeFonts, writeToolbarHeight } from "./theme-editor-fields.js";
|
|
7
7
|
/** The most edits one save may carry: every color of both schemes and the rest. */ export const THEME_EDITOR_EDITS_MAX = THEME_COLOR_FIELDS.length * 2 + 8 + THEME_COMPONENT_LOOK_FIELDS.length;
|
|
8
8
|
const HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
9
|
+
/** The categories a font choice may name (`HostThemeFontCategory`). */ const FONT_CATEGORIES = [
|
|
10
|
+
'sans-serif',
|
|
11
|
+
'serif',
|
|
12
|
+
'monospace',
|
|
13
|
+
'display',
|
|
14
|
+
'handwriting'
|
|
15
|
+
];
|
|
16
|
+
/** The longest family name a font choice may carry, and the most weights in either list. */ export const THEME_FONT_FAMILY_MAX = 100;
|
|
17
|
+
export const THEME_FONT_WEIGHTS_MAX = 20;
|
|
18
|
+
function readWeights(value) {
|
|
19
|
+
if (value === undefined || value === null) return [];
|
|
20
|
+
if (!Array.isArray(value) || value.length > THEME_FONT_WEIGHTS_MAX) return 'Pick the font’s weights again.';
|
|
21
|
+
const weights = [];
|
|
22
|
+
for (const entry of value){
|
|
23
|
+
const weight = typeof entry === 'number' ? entry : Number(entry);
|
|
24
|
+
if (!Number.isInteger(weight) || weight < 1 || weight > 1000) return 'Pick the font’s weights again.';
|
|
25
|
+
weights.push(weight);
|
|
26
|
+
}
|
|
27
|
+
return weights;
|
|
28
|
+
}
|
|
29
|
+
/** One role's font choice from a request body (null for none), or why it was refused. */ function readFontChoice(raw) {
|
|
30
|
+
if (raw === null || raw === undefined) return null;
|
|
31
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) return 'That font could not be read.';
|
|
32
|
+
const choice = raw;
|
|
33
|
+
const family = typeof choice['family'] === 'string' ? choice['family'].trim() : '';
|
|
34
|
+
if (!family || family.length > THEME_FONT_FAMILY_MAX || /["\\;{}<>]/.test(family)) return 'Pick a font from the list.';
|
|
35
|
+
const category = choice['category'];
|
|
36
|
+
if (!FONT_CATEGORIES.includes(category)) return 'Pick a font from the list.';
|
|
37
|
+
const source = choice['source'];
|
|
38
|
+
if (source !== 'google' && source !== 'custom') return 'Pick a font from the list.';
|
|
39
|
+
const weights = readWeights(choice['weights']);
|
|
40
|
+
if (typeof weights === 'string') return weights;
|
|
41
|
+
const italics = readWeights(choice['italics']);
|
|
42
|
+
if (typeof italics === 'string') return italics;
|
|
43
|
+
return _extends({
|
|
44
|
+
family,
|
|
45
|
+
category: category,
|
|
46
|
+
weights: weights.length ? weights : [
|
|
47
|
+
400
|
|
48
|
+
]
|
|
49
|
+
}, italics.length ? {
|
|
50
|
+
italics
|
|
51
|
+
} : {}, {
|
|
52
|
+
source
|
|
53
|
+
});
|
|
54
|
+
}
|
|
9
55
|
function readNumber(value, range) {
|
|
10
56
|
if (value === null || value === undefined || value === '') return null;
|
|
11
57
|
const parsed = typeof value === 'number' ? value : Number(value);
|
|
@@ -55,6 +101,22 @@ function readNumber(value, range) {
|
|
|
55
101
|
value: value
|
|
56
102
|
};
|
|
57
103
|
}
|
|
104
|
+
case 'fonts':
|
|
105
|
+
{
|
|
106
|
+
const value = edit['value'];
|
|
107
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return 'Pick a font from the list.';
|
|
108
|
+
const body = readFontChoice(value['body']);
|
|
109
|
+
if (typeof body === 'string') return body;
|
|
110
|
+
const heading = readFontChoice(value['heading']);
|
|
111
|
+
if (typeof heading === 'string') return heading;
|
|
112
|
+
return {
|
|
113
|
+
control: 'fonts',
|
|
114
|
+
value: {
|
|
115
|
+
body,
|
|
116
|
+
heading
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
58
120
|
case 'borderRadius':
|
|
59
121
|
{
|
|
60
122
|
const value = readNumber(edit['value'], BORDER_RADIUS_FIELD);
|
|
@@ -127,6 +189,9 @@ function readNumber(value, range) {
|
|
|
127
189
|
case 'fontFamily':
|
|
128
190
|
next = writeFontFamily(next, edit.value);
|
|
129
191
|
break;
|
|
192
|
+
case 'fonts':
|
|
193
|
+
next = writeThemeFonts(next, edit.value);
|
|
194
|
+
break;
|
|
130
195
|
case 'borderRadius':
|
|
131
196
|
var _edit_value1;
|
|
132
197
|
next = writeBorderRadius(next, (_edit_value1 = edit.value) != null ? _edit_value1 : undefined);
|
|
@@ -163,6 +228,7 @@ export function readThemeEditorValues(theme) {
|
|
|
163
228
|
colors,
|
|
164
229
|
darkScheme: readDarkScheme(safe),
|
|
165
230
|
fontFamily: readFontFamily(safe),
|
|
231
|
+
fonts: readThemeFonts(safe),
|
|
166
232
|
borderRadius: typeof radius === 'number' && Number.isFinite(radius) ? radius : null,
|
|
167
233
|
spacing: typeof safe.spacing === 'number' ? safe.spacing : null,
|
|
168
234
|
navHeight: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-edits.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { HostTheme, HostThemeScheme } from '@aglyn/shared-data-types'\nimport {\n BORDER_RADIUS_FIELD,\n DARK_SCHEME_FIELD,\n GOOGLE_FONT_OPTIONS,\n SPACING_FIELD,\n SYSTEM_FONT_VALUE,\n THEME_COLOR_FIELDS,\n THEME_COMPONENT_LOOK_FIELDS,\n THEME_COMPONENT_LOOK_GROUPS,\n THEME_EDITOR_SCHEMES,\n THEME_LOOK_DEFAULT,\n TOOLBAR_HEIGHT_FIELDS,\n readComponentLook,\n readDarkScheme,\n readFontFamily,\n readThemeColor,\n readToolbarHeight,\n themeComponentLookField,\n writeBorderRadius,\n writeComponentLook,\n writeDarkScheme,\n writeFontFamily,\n writeSpacing,\n writeThemeColor,\n writeToolbarHeight,\n type ThemeColorToken,\n type ThemeComponentLookId,\n} from './theme-editor-fields'\n\n/*\n * THE THEME EDITOR'S CONTROLS AS EDITS (AGL-3668).\n *\n * The console's theme section edits the resolved theme in the browser with\n * the writers in `theme-editor-fields.ts` and saves the difference from the\n * picked theme as the site's override. A native app sends the same controls\n * as named edits instead — one color for one scheme, the font, the radius,\n * the spacing unit, a nav height, the dark scheme — and `/api/hosts/theme`\n * applies them here with those same writers, so both clients make exactly the\n * same theme from the same choice. The Style components card's twelve\n * choices (buttons, form inputs, cards) are the `componentLook` edit.\n * `readThemeEditorValues` is the other half:\n * what each control currently shows.\n */\n\n/** One control's change; a null value clears it back to the theme's own. */\nexport type ThemeEditorEdit =\n | { control: 'color'; scheme: HostThemeScheme; token: ThemeColorToken; value: string | null }\n | { control: 'darkScheme'; value: 'auto' | 'off' }\n | { control: 'fontFamily'; value: string }\n | { control: 'borderRadius'; value: number | null }\n | { control: 'spacing'; value: number | null }\n | { control: 'navHeight'; breakpoint: 'xs' | 'sm'; value: number | null }\n /** One of the Style components choices; `''` (\"Theme default\") clears what it wrote. */\n | { control: 'componentLook'; field: ThemeComponentLookId; value: string }\n\n/** The most edits one save may carry: every color of both schemes and the rest. */\nexport const THEME_EDITOR_EDITS_MAX = THEME_COLOR_FIELDS.length * 2 + 8 + THEME_COMPONENT_LOOK_FIELDS.length\n\nconst HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/\n\nfunction readNumber(\n value: unknown,\n range: { min: number; max: number },\n): number | null | string {\n if (value === null || value === undefined || value === '') return null\n const parsed = typeof value === 'number' ? value : Number(value)\n if (!Number.isFinite(parsed)) return 'Use a number.'\n if (parsed < range.min || parsed > range.max) {\n return `Use a number from ${range.min} to ${range.max}.`\n }\n return parsed\n}\n\n/** One edit from a request body, or why it was refused. */\nexport function readThemeEditorEdit(raw: unknown): ThemeEditorEdit | string {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return 'That change could not be read.'\n const edit = raw as Record<string, unknown>\n switch (edit['control']) {\n case 'color': {\n const scheme = edit['scheme']\n if (!THEME_EDITOR_SCHEMES.includes(scheme as HostThemeScheme)) return 'Pick light or dark.'\n const token = edit['token']\n if (!THEME_COLOR_FIELDS.some((field) => field.token === token)) return 'That is not a theme color.'\n const value = edit['value']\n if (value !== null && value !== undefined && value !== '' && (typeof value !== 'string' || !HEX_COLOR.test(value))) {\n return 'Use a hex color such as #1A73E8.'\n }\n return {\n control: 'color',\n scheme: scheme as HostThemeScheme,\n token: token as ThemeColorToken,\n value: typeof value === 'string' && value ? value : null,\n }\n }\n case 'darkScheme':\n return edit['value'] === 'off' ? { control: 'darkScheme', value: 'off' } : { control: 'darkScheme', value: 'auto' }\n case 'fontFamily': {\n const value = edit['value']\n if (value !== SYSTEM_FONT_VALUE && !GOOGLE_FONT_OPTIONS.some((option) => option.family === value)) {\n return 'Pick a font from the list.'\n }\n return { control: 'fontFamily', value: value as string }\n }\n case 'borderRadius': {\n const value = readNumber(edit['value'], BORDER_RADIUS_FIELD)\n return typeof value === 'string' ? value : { control: 'borderRadius', value }\n }\n case 'spacing': {\n const value = readNumber(edit['value'], SPACING_FIELD)\n return typeof value === 'string' ? value : { control: 'spacing', value }\n }\n case 'navHeight': {\n const breakpoint = edit['breakpoint']\n if (breakpoint !== 'xs' && breakpoint !== 'sm') return 'Pick mobile or desktop.'\n const value = readNumber(edit['value'], TOOLBAR_HEIGHT_FIELDS[breakpoint])\n return typeof value === 'string' ? value : { control: 'navHeight', breakpoint, value }\n }\n case 'componentLook': {\n const field = THEME_COMPONENT_LOOK_FIELDS.find((entry) => entry.id === edit['field'])\n if (!field) return 'That is not a component style.'\n const value = edit['value'] ?? THEME_LOOK_DEFAULT\n if (typeof value !== 'string') return 'Pick one of the choices.'\n if (value !== THEME_LOOK_DEFAULT && !field.options.some((option) => option.value === value)) {\n return 'Pick one of the choices.'\n }\n return { control: 'componentLook', field: field.id, value }\n }\n default:\n return 'That is not a theme control.'\n }\n}\n\n/** Every edit of a request body, or the first refusal. */\nexport function readThemeEditorEdits(raw: unknown): ThemeEditorEdit[] | string {\n if (!Array.isArray(raw) || raw.length === 0) return 'Nothing to change.'\n if (raw.length > THEME_EDITOR_EDITS_MAX) return 'Too many changes at once.'\n const edits: ThemeEditorEdit[] = []\n for (const entry of raw) {\n const edit = readThemeEditorEdit(entry)\n if (typeof edit === 'string') return edit\n edits.push(edit)\n }\n return edits\n}\n\n/** The theme with [edits] applied, in order, by the editor's own writers. */\nexport function applyThemeEditorEdits(theme: HostTheme, edits: readonly ThemeEditorEdit[]): HostTheme {\n let next = theme\n for (const edit of edits) {\n switch (edit.control) {\n case 'color':\n next = writeThemeColor(next, edit.scheme, edit.token, edit.value ?? undefined)\n break\n case 'darkScheme':\n next = writeDarkScheme(next, edit.value)\n break\n case 'fontFamily':\n next = writeFontFamily(next, edit.value)\n break\n case 'borderRadius':\n next = writeBorderRadius(next, edit.value ?? undefined)\n break\n case 'spacing':\n next = writeSpacing(next, edit.value ?? undefined)\n break\n case 'navHeight':\n next = writeToolbarHeight(next, edit.breakpoint, edit.value ?? undefined)\n break\n case 'componentLook':\n next = writeComponentLook(next, themeComponentLookField(edit.field), edit.value)\n break\n }\n }\n return next\n}\n\n/** What each control shows for [theme]; an absent value inherits the platform's. */\nexport interface ThemeEditorValues {\n colors: Record<HostThemeScheme, Record<string, string | null>>\n darkScheme: 'auto' | 'off'\n fontFamily: string\n borderRadius: number | null\n spacing: number | null\n navHeight: { xs: number | null; sm: number | null }\n /** Each Style components field's choice: `''` for the theme's own, `'__custom__'` for a value no choice names. */\n componentLooks: Record<string, string>\n}\n\nexport function readThemeEditorValues(theme: HostTheme | undefined): ThemeEditorValues {\n const safe = theme ?? {}\n const colors = {} as Record<HostThemeScheme, Record<string, string | null>>\n for (const scheme of THEME_EDITOR_SCHEMES) {\n colors[scheme] = {}\n for (const field of THEME_COLOR_FIELDS) {\n colors[scheme][field.token] = readThemeColor(safe, scheme, field.token) ?? null\n }\n }\n const radius = safe.shape?.borderRadius\n return {\n colors,\n darkScheme: readDarkScheme(safe),\n fontFamily: readFontFamily(safe),\n borderRadius: typeof radius === 'number' && Number.isFinite(radius) ? radius : null,\n spacing: typeof safe.spacing === 'number' ? safe.spacing : null,\n navHeight: {\n xs: readToolbarHeight(safe, 'xs') ?? null,\n sm: readToolbarHeight(safe, 'sm') ?? null,\n },\n componentLooks: Object.fromEntries(\n THEME_COMPONENT_LOOK_FIELDS.map((field) => [field.id, readComponentLook(safe, field)]),\n ),\n }\n}\n\n/**\n * The controls themselves, for a client that draws the editor from data:\n * every color field, the font list, and each number's range and label.\n */\nexport const THEME_EDITOR_CATALOG = {\n schemes: THEME_EDITOR_SCHEMES,\n colors: THEME_COLOR_FIELDS,\n darkScheme: DARK_SCHEME_FIELD,\n systemFont: SYSTEM_FONT_VALUE,\n fonts: GOOGLE_FONT_OPTIONS,\n borderRadius: BORDER_RADIUS_FIELD,\n spacing: SPACING_FIELD,\n navHeight: TOOLBAR_HEIGHT_FIELDS,\n /** The Style components card: its groups and each field's choices (what a choice stores stays here). */\n componentLooks: {\n groups: THEME_COMPONENT_LOOK_GROUPS,\n fields: THEME_COMPONENT_LOOK_FIELDS.map((field) => ({\n id: field.id,\n group: field.group,\n label: field.label,\n kind: field.kind,\n options: field.options.map((option) => ({\n value: option.value,\n label: option.label,\n ...(option.token ? { token: option.token } : {}),\n })),\n })),\n },\n} as const\n"],"names":["BORDER_RADIUS_FIELD","DARK_SCHEME_FIELD","GOOGLE_FONT_OPTIONS","SPACING_FIELD","SYSTEM_FONT_VALUE","THEME_COLOR_FIELDS","THEME_COMPONENT_LOOK_FIELDS","THEME_COMPONENT_LOOK_GROUPS","THEME_EDITOR_SCHEMES","THEME_LOOK_DEFAULT","TOOLBAR_HEIGHT_FIELDS","readComponentLook","readDarkScheme","readFontFamily","readThemeColor","readToolbarHeight","themeComponentLookField","writeBorderRadius","writeComponentLook","writeDarkScheme","writeFontFamily","writeSpacing","writeThemeColor","writeToolbarHeight","THEME_EDITOR_EDITS_MAX","length","HEX_COLOR","readNumber","value","range","undefined","parsed","Number","isFinite","min","max","readThemeEditorEdit","raw","Array","isArray","edit","scheme","includes","token","some","field","test","control","option","family","breakpoint","find","entry","id","options","readThemeEditorEdits","edits","push","applyThemeEditorEdits","theme","next","readThemeEditorValues","safe","colors","radius","shape","borderRadius","darkScheme","fontFamily","spacing","navHeight","xs","sm","componentLooks","Object","fromEntries","map","THEME_EDITOR_CATALOG","schemes","systemFont","fonts","groups","fields","group","label","kind"],"mappings":"AAAA;;;;CAIC;AAGD,SACEA,mBAAmB,EACnBC,iBAAiB,EACjBC,mBAAmB,EACnBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,oBAAoB,EACpBC,kBAAkB,EAClBC,qBAAqB,EACrBC,iBAAiB,EACjBC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,eAAe,EACfC,kBAAkB,QAGb,2BAAuB;AA4B9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SAAStE;IACTuD,QAAQ1D;IACR8D,YAAYlE;IACZ8E,YAAY3E;IACZ4E,OAAO9E;IACPgE,cAAclE;IACdqE,SAASlE;IACTmE,WAAW5D;IACX,sGAAsG,GACtG+D,gBAAgB;QACdQ,QAAQ1E;QACR2E,QAAQ5E,4BAA4BsE,GAAG,CAAC,CAAC/B,QAAW,CAAA;gBAClDQ,IAAIR,MAAMQ,EAAE;gBACZ8B,OAAOtC,MAAMsC,KAAK;gBAClBC,OAAOvC,MAAMuC,KAAK;gBAClBC,MAAMxC,MAAMwC,IAAI;gBAChB/B,SAAST,MAAMS,OAAO,CAACsB,GAAG,CAAC,CAAC5B,SAAY;wBACtCpB,OAAOoB,OAAOpB,KAAK;wBACnBwD,OAAOpC,OAAOoC,KAAK;uBACfpC,OAAOL,KAAK,GAAG;wBAAEA,OAAOK,OAAOL,KAAK;oBAAC,IAAI,CAAC;YAElD,CAAA;IACF;AACF,EAAU"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-edits.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { HostTheme, HostThemeFontCategory, HostThemeScheme } from '@aglyn/shared-data-types'\nimport {\n BORDER_RADIUS_FIELD,\n DARK_SCHEME_FIELD,\n GOOGLE_FONT_OPTIONS,\n SPACING_FIELD,\n SYSTEM_FONT_VALUE,\n THEME_COLOR_FIELDS,\n THEME_COMPONENT_LOOK_FIELDS,\n THEME_COMPONENT_LOOK_GROUPS,\n THEME_EDITOR_SCHEMES,\n THEME_LOOK_DEFAULT,\n TOOLBAR_HEIGHT_FIELDS,\n readComponentLook,\n readDarkScheme,\n readFontFamily,\n readThemeColor,\n readThemeFonts,\n readToolbarHeight,\n themeComponentLookField,\n writeBorderRadius,\n writeComponentLook,\n writeDarkScheme,\n writeFontFamily,\n writeSpacing,\n writeThemeColor,\n writeThemeFonts,\n writeToolbarHeight,\n type ThemeColorToken,\n type ThemeComponentLookId,\n type ThemeFontChoice,\n type ThemeFontSelection,\n} from './theme-editor-fields'\n\n/*\n * THE THEME EDITOR'S CONTROLS AS EDITS (AGL-3668).\n *\n * The console's theme section edits the resolved theme in the browser with\n * the writers in `theme-editor-fields.ts` and saves the difference from the\n * picked theme as the site's override. A native app sends the same controls\n * as named edits instead — one color for one scheme, the font, the radius,\n * the spacing unit, a nav height, the dark scheme — and `/api/hosts/theme`\n * applies them here with those same writers, so both clients make exactly the\n * same theme from the same choice. The Style components card's twelve\n * choices (buttons, form inputs, cards) are the `componentLook` edit.\n * `readThemeEditorValues` is the other half:\n * what each control currently shows.\n */\n\n/** One control's change; a null value clears it back to the theme's own. */\nexport type ThemeEditorEdit =\n | { control: 'color'; scheme: HostThemeScheme; token: ThemeColorToken; value: string | null }\n | { control: 'darkScheme'; value: 'auto' | 'off' }\n | { control: 'fontFamily'; value: string }\n /**\n * The fonts plugin's picker (AGL-3656): the body font and the heading font\n * together, as its `writeThemeFonts` writes them; a null role is the\n * theme default (body) or \"same as body text\" (heading).\n */\n | { control: 'fonts'; value: ThemeFontSelection }\n | { control: 'borderRadius'; value: number | null }\n | { control: 'spacing'; value: number | null }\n | { control: 'navHeight'; breakpoint: 'xs' | 'sm'; value: number | null }\n /** One of the Style components choices; `''` (\"Theme default\") clears what it wrote. */\n | { control: 'componentLook'; field: ThemeComponentLookId; value: string }\n\n/** The most edits one save may carry: every color of both schemes and the rest. */\nexport const THEME_EDITOR_EDITS_MAX = THEME_COLOR_FIELDS.length * 2 + 8 + THEME_COMPONENT_LOOK_FIELDS.length\n\nconst HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/\n\n/** The categories a font choice may name (`HostThemeFontCategory`). */\nconst FONT_CATEGORIES: readonly HostThemeFontCategory[] = ['sans-serif', 'serif', 'monospace', 'display', 'handwriting']\n\n/** The longest family name a font choice may carry, and the most weights in either list. */\nexport const THEME_FONT_FAMILY_MAX = 100\nexport const THEME_FONT_WEIGHTS_MAX = 20\n\nfunction readWeights(value: unknown): number[] | string {\n if (value === undefined || value === null) return []\n if (!Array.isArray(value) || value.length > THEME_FONT_WEIGHTS_MAX) return 'Pick the font’s weights again.'\n const weights: number[] = []\n for (const entry of value) {\n const weight = typeof entry === 'number' ? entry : Number(entry)\n if (!Number.isInteger(weight) || weight < 1 || weight > 1000) return 'Pick the font’s weights again.'\n weights.push(weight)\n }\n return weights\n}\n\n/** One role's font choice from a request body (null for none), or why it was refused. */\nfunction readFontChoice(raw: unknown): ThemeFontChoice | null | string {\n if (raw === null || raw === undefined) return null\n if (typeof raw !== 'object' || Array.isArray(raw)) return 'That font could not be read.'\n const choice = raw as Record<string, unknown>\n const family = typeof choice['family'] === 'string' ? choice['family'].trim() : ''\n if (!family || family.length > THEME_FONT_FAMILY_MAX || /[\"\\\\;{}<>]/.test(family)) return 'Pick a font from the list.'\n const category = choice['category']\n if (!FONT_CATEGORIES.includes(category as HostThemeFontCategory)) return 'Pick a font from the list.'\n const source = choice['source']\n if (source !== 'google' && source !== 'custom') return 'Pick a font from the list.'\n const weights = readWeights(choice['weights'])\n if (typeof weights === 'string') return weights\n const italics = readWeights(choice['italics'])\n if (typeof italics === 'string') return italics\n return {\n family,\n category: category as HostThemeFontCategory,\n weights: weights.length ? weights : [400],\n ...(italics.length ? { italics } : {}),\n source,\n }\n}\n\nfunction readNumber(\n value: unknown,\n range: { min: number; max: number },\n): number | null | string {\n if (value === null || value === undefined || value === '') return null\n const parsed = typeof value === 'number' ? value : Number(value)\n if (!Number.isFinite(parsed)) return 'Use a number.'\n if (parsed < range.min || parsed > range.max) {\n return `Use a number from ${range.min} to ${range.max}.`\n }\n return parsed\n}\n\n/** One edit from a request body, or why it was refused. */\nexport function readThemeEditorEdit(raw: unknown): ThemeEditorEdit | string {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return 'That change could not be read.'\n const edit = raw as Record<string, unknown>\n switch (edit['control']) {\n case 'color': {\n const scheme = edit['scheme']\n if (!THEME_EDITOR_SCHEMES.includes(scheme as HostThemeScheme)) return 'Pick light or dark.'\n const token = edit['token']\n if (!THEME_COLOR_FIELDS.some((field) => field.token === token)) return 'That is not a theme color.'\n const value = edit['value']\n if (value !== null && value !== undefined && value !== '' && (typeof value !== 'string' || !HEX_COLOR.test(value))) {\n return 'Use a hex color such as #1A73E8.'\n }\n return {\n control: 'color',\n scheme: scheme as HostThemeScheme,\n token: token as ThemeColorToken,\n value: typeof value === 'string' && value ? value : null,\n }\n }\n case 'darkScheme':\n return edit['value'] === 'off' ? { control: 'darkScheme', value: 'off' } : { control: 'darkScheme', value: 'auto' }\n case 'fontFamily': {\n const value = edit['value']\n if (value !== SYSTEM_FONT_VALUE && !GOOGLE_FONT_OPTIONS.some((option) => option.family === value)) {\n return 'Pick a font from the list.'\n }\n return { control: 'fontFamily', value: value as string }\n }\n case 'fonts': {\n const value = edit['value']\n if (!value || typeof value !== 'object' || Array.isArray(value)) return 'Pick a font from the list.'\n const body = readFontChoice((value as Record<string, unknown>)['body'])\n if (typeof body === 'string') return body\n const heading = readFontChoice((value as Record<string, unknown>)['heading'])\n if (typeof heading === 'string') return heading\n return { control: 'fonts', value: { body, heading } }\n }\n case 'borderRadius': {\n const value = readNumber(edit['value'], BORDER_RADIUS_FIELD)\n return typeof value === 'string' ? value : { control: 'borderRadius', value }\n }\n case 'spacing': {\n const value = readNumber(edit['value'], SPACING_FIELD)\n return typeof value === 'string' ? value : { control: 'spacing', value }\n }\n case 'navHeight': {\n const breakpoint = edit['breakpoint']\n if (breakpoint !== 'xs' && breakpoint !== 'sm') return 'Pick mobile or desktop.'\n const value = readNumber(edit['value'], TOOLBAR_HEIGHT_FIELDS[breakpoint])\n return typeof value === 'string' ? value : { control: 'navHeight', breakpoint, value }\n }\n case 'componentLook': {\n const field = THEME_COMPONENT_LOOK_FIELDS.find((entry) => entry.id === edit['field'])\n if (!field) return 'That is not a component style.'\n const value = edit['value'] ?? THEME_LOOK_DEFAULT\n if (typeof value !== 'string') return 'Pick one of the choices.'\n if (value !== THEME_LOOK_DEFAULT && !field.options.some((option) => option.value === value)) {\n return 'Pick one of the choices.'\n }\n return { control: 'componentLook', field: field.id, value }\n }\n default:\n return 'That is not a theme control.'\n }\n}\n\n/** Every edit of a request body, or the first refusal. */\nexport function readThemeEditorEdits(raw: unknown): ThemeEditorEdit[] | string {\n if (!Array.isArray(raw) || raw.length === 0) return 'Nothing to change.'\n if (raw.length > THEME_EDITOR_EDITS_MAX) return 'Too many changes at once.'\n const edits: ThemeEditorEdit[] = []\n for (const entry of raw) {\n const edit = readThemeEditorEdit(entry)\n if (typeof edit === 'string') return edit\n edits.push(edit)\n }\n return edits\n}\n\n/** The theme with [edits] applied, in order, by the editor's own writers. */\nexport function applyThemeEditorEdits(theme: HostTheme, edits: readonly ThemeEditorEdit[]): HostTheme {\n let next = theme\n for (const edit of edits) {\n switch (edit.control) {\n case 'color':\n next = writeThemeColor(next, edit.scheme, edit.token, edit.value ?? undefined)\n break\n case 'darkScheme':\n next = writeDarkScheme(next, edit.value)\n break\n case 'fontFamily':\n next = writeFontFamily(next, edit.value)\n break\n case 'fonts':\n next = writeThemeFonts(next, edit.value)\n break\n case 'borderRadius':\n next = writeBorderRadius(next, edit.value ?? undefined)\n break\n case 'spacing':\n next = writeSpacing(next, edit.value ?? undefined)\n break\n case 'navHeight':\n next = writeToolbarHeight(next, edit.breakpoint, edit.value ?? undefined)\n break\n case 'componentLook':\n next = writeComponentLook(next, themeComponentLookField(edit.field), edit.value)\n break\n }\n }\n return next\n}\n\n/** What each control shows for [theme]; an absent value inherits the platform's. */\nexport interface ThemeEditorValues {\n colors: Record<HostThemeScheme, Record<string, string | null>>\n darkScheme: 'auto' | 'off'\n fontFamily: string\n /** The fonts plugin's body and heading fonts (`readThemeFonts`). */\n fonts: ThemeFontSelection\n borderRadius: number | null\n spacing: number | null\n navHeight: { xs: number | null; sm: number | null }\n /** Each Style components field's choice: `''` for the theme's own, `'__custom__'` for a value no choice names. */\n componentLooks: Record<string, string>\n}\n\nexport function readThemeEditorValues(theme: HostTheme | undefined): ThemeEditorValues {\n const safe = theme ?? {}\n const colors = {} as Record<HostThemeScheme, Record<string, string | null>>\n for (const scheme of THEME_EDITOR_SCHEMES) {\n colors[scheme] = {}\n for (const field of THEME_COLOR_FIELDS) {\n colors[scheme][field.token] = readThemeColor(safe, scheme, field.token) ?? null\n }\n }\n const radius = safe.shape?.borderRadius\n return {\n colors,\n darkScheme: readDarkScheme(safe),\n fontFamily: readFontFamily(safe),\n fonts: readThemeFonts(safe),\n borderRadius: typeof radius === 'number' && Number.isFinite(radius) ? radius : null,\n spacing: typeof safe.spacing === 'number' ? safe.spacing : null,\n navHeight: {\n xs: readToolbarHeight(safe, 'xs') ?? null,\n sm: readToolbarHeight(safe, 'sm') ?? null,\n },\n componentLooks: Object.fromEntries(\n THEME_COMPONENT_LOOK_FIELDS.map((field) => [field.id, readComponentLook(safe, field)]),\n ),\n }\n}\n\n/**\n * The controls themselves, for a client that draws the editor from data:\n * every color field, the font list, and each number's range and label.\n */\nexport const THEME_EDITOR_CATALOG = {\n schemes: THEME_EDITOR_SCHEMES,\n colors: THEME_COLOR_FIELDS,\n darkScheme: DARK_SCHEME_FIELD,\n systemFont: SYSTEM_FONT_VALUE,\n fonts: GOOGLE_FONT_OPTIONS,\n borderRadius: BORDER_RADIUS_FIELD,\n spacing: SPACING_FIELD,\n navHeight: TOOLBAR_HEIGHT_FIELDS,\n /** The Style components card: its groups and each field's choices (what a choice stores stays here). */\n componentLooks: {\n groups: THEME_COMPONENT_LOOK_GROUPS,\n fields: THEME_COMPONENT_LOOK_FIELDS.map((field) => ({\n id: field.id,\n group: field.group,\n label: field.label,\n kind: field.kind,\n options: field.options.map((option) => ({\n value: option.value,\n label: option.label,\n ...(option.token ? { token: option.token } : {}),\n })),\n })),\n },\n} as const\n"],"names":["BORDER_RADIUS_FIELD","DARK_SCHEME_FIELD","GOOGLE_FONT_OPTIONS","SPACING_FIELD","SYSTEM_FONT_VALUE","THEME_COLOR_FIELDS","THEME_COMPONENT_LOOK_FIELDS","THEME_COMPONENT_LOOK_GROUPS","THEME_EDITOR_SCHEMES","THEME_LOOK_DEFAULT","TOOLBAR_HEIGHT_FIELDS","readComponentLook","readDarkScheme","readFontFamily","readThemeColor","readThemeFonts","readToolbarHeight","themeComponentLookField","writeBorderRadius","writeComponentLook","writeDarkScheme","writeFontFamily","writeSpacing","writeThemeColor","writeThemeFonts","writeToolbarHeight","THEME_EDITOR_EDITS_MAX","length","HEX_COLOR","FONT_CATEGORIES","THEME_FONT_FAMILY_MAX","THEME_FONT_WEIGHTS_MAX","readWeights","value","undefined","Array","isArray","weights","entry","weight","Number","isInteger","push","readFontChoice","raw","choice","family","trim","test","category","includes","source","italics","readNumber","range","parsed","isFinite","min","max","readThemeEditorEdit","edit","scheme","token","some","field","control","option","body","heading","breakpoint","find","id","options","readThemeEditorEdits","edits","applyThemeEditorEdits","theme","next","readThemeEditorValues","safe","colors","radius","shape","borderRadius","darkScheme","fontFamily","fonts","spacing","navHeight","xs","sm","componentLooks","Object","fromEntries","map","THEME_EDITOR_CATALOG","schemes","systemFont","groups","fields","group","label","kind"],"mappings":"AAAA;;;;CAIC;AAGD,SACEA,mBAAmB,EACnBC,iBAAiB,EACjBC,mBAAmB,EACnBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,oBAAoB,EACpBC,kBAAkB,EAClBC,qBAAqB,EACrBC,iBAAiB,EACjBC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QAKb,2BAAuB;AAkC9B,iFAAiF,GACjF,OAAO,MAAMC,yBAAyBrB,mBAAmBsB,M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