@burdenoff/fe-libs 2026.1119.5 → 2026.1119.7

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.
Files changed (94) hide show
  1. package/dist/chrome/HeaderThemeSwitcher.js +1 -1
  2. package/dist/chrome/PersonaSurfaceControls.js +82 -189
  3. package/dist/chrome/PersonaViewsList.d.ts +28 -0
  4. package/dist/chrome/PersonaViewsList.js +139 -0
  5. package/dist/chrome/ThemePreferences.js +16 -16
  6. package/dist/chrome/appearance/AppearanceColourSection.d.ts +17 -0
  7. package/dist/chrome/appearance/AppearanceColourSection.js +337 -0
  8. package/dist/chrome/appearance/AppearanceDisplaySection.d.ts +7 -0
  9. package/dist/chrome/appearance/AppearanceDisplaySection.js +137 -0
  10. package/dist/chrome/appearance/AppearanceModeDepth.d.ts +11 -0
  11. package/dist/chrome/appearance/AppearanceModeDepth.js +158 -0
  12. package/dist/chrome/appearance/AppearancePreferences.d.ts +13 -0
  13. package/dist/chrome/appearance/AppearancePreferences.js +308 -0
  14. package/dist/chrome/appearance/AppearancePreview.d.ts +23 -0
  15. package/dist/chrome/appearance/AppearancePreview.js +218 -0
  16. package/dist/chrome/appearance/AppearanceThemeSection.d.ts +14 -0
  17. package/dist/chrome/appearance/AppearanceThemeSection.js +162 -0
  18. package/dist/chrome/appearance/ColourPanel.d.ts +37 -0
  19. package/dist/chrome/appearance/ColourPanel.js +264 -0
  20. package/dist/chrome/appearance/ThemeDialog.d.ts +21 -0
  21. package/dist/chrome/appearance/ThemeDialog.js +378 -0
  22. package/dist/chrome/appearance/appearanceShared.d.ts +24 -0
  23. package/dist/chrome/appearance/appearanceShared.js +46 -0
  24. package/dist/chrome/appearance/appearanceUi.d.ts +49 -0
  25. package/dist/chrome/appearance/appearanceUi.js +98 -0
  26. package/dist/chrome/appearance/useAppearanceLabels.d.ts +181 -0
  27. package/dist/chrome/appearance/useAppearanceLabels.js +259 -0
  28. package/dist/chrome/index.d.ts +1 -0
  29. package/dist/chrome/personaViewOptions.d.ts +8 -0
  30. package/dist/chrome/personaViewOptions.js +14 -0
  31. package/dist/chrome/shell/NewMenu.d.ts +13 -1
  32. package/dist/chrome/shell/NewMenu.js +27 -14
  33. package/dist/chrome/shell/ShellSidebar.js +2 -0
  34. package/dist/chrome/shell/SidebarProfileMenu.d.ts +36 -4
  35. package/dist/chrome/shell/SidebarProfileMenu.js +423 -331
  36. package/dist/chrome/shell/WorkspaceAccountCard.d.ts +22 -0
  37. package/dist/chrome/shell/WorkspaceAccountCard.js +102 -0
  38. package/dist/chrome/shell/pageHost.d.ts +19 -0
  39. package/dist/chrome/shell/pageHost.js +21 -0
  40. package/dist/chrome/shell/pageWidth.d.ts +39 -0
  41. package/dist/chrome/shell/pageWidth.js +18 -0
  42. package/dist/chrome/shellLabelManifest.d.ts +6 -0
  43. package/dist/chrome.js +26 -25
  44. package/dist/platform-pages/AppearanceSettingsPage.d.ts +11 -1
  45. package/dist/platform-pages/AppearanceSettingsPage.js +15 -8
  46. package/dist/shared/assistant/ui/composer/AssistantComposer.js +346 -345
  47. package/dist/shared/backgrounds/BackgroundSettingsSection.d.ts +11 -0
  48. package/dist/shared/backgrounds/BackgroundSettingsSection.js +67 -0
  49. package/dist/shared/backgrounds/backgroundSectionLabels.d.ts +14 -0
  50. package/dist/shared/backgrounds/backgroundSectionLabels.js +36 -0
  51. package/dist/shared/backgrounds/index.d.ts +3 -0
  52. package/dist/shared/backgrounds/useBackgroundColors.js +3 -2
  53. package/dist/shared/backgrounds/useStartPageBackground.d.ts +12 -0
  54. package/dist/shared/backgrounds/useStartPageBackground.js +23 -0
  55. package/dist/shared/providers/AppShellProvider.d.ts +20 -1
  56. package/dist/shared/providers/AppShellProvider.js +230 -222
  57. package/dist/shared/providers/shell/PaletteThemeProvider.d.ts +13 -0
  58. package/dist/shared/providers/shell/PaletteThemeProvider.js +366 -0
  59. package/dist/shared/providers/shell/ThemeProvider.d.ts +9 -76
  60. package/dist/shared/providers/shell/ThemeProvider.js +63 -55
  61. package/dist/shared/providers/shell/appearance/colour.d.ts +29 -0
  62. package/dist/shared/providers/shell/appearance/colour.js +79 -0
  63. package/dist/shared/providers/shell/appearance/contrastFix.d.ts +70 -0
  64. package/dist/shared/providers/shell/appearance/contrastFix.js +117 -0
  65. package/dist/shared/providers/shell/appearance/index.d.ts +9 -0
  66. package/dist/shared/providers/shell/appearance/model.d.ts +68 -0
  67. package/dist/shared/providers/shell/appearance/model.js +92 -0
  68. package/dist/shared/providers/shell/appearance/operations.d.ts +70 -0
  69. package/dist/shared/providers/shell/appearance/operations.js +160 -0
  70. package/dist/shared/providers/shell/appearance/palettes.d.ts +111 -0
  71. package/dist/shared/providers/shell/appearance/palettes.js +460 -0
  72. package/dist/shared/providers/shell/appearance/storage.d.ts +39 -0
  73. package/dist/shared/providers/shell/appearance/storage.js +186 -0
  74. package/dist/shared/providers/shell/appearance/tokens.d.ts +5 -0
  75. package/dist/shared/providers/shell/appearance/tokens.js +43 -0
  76. package/dist/shared/providers/shell/appearance/types.d.ts +80 -0
  77. package/dist/shared/providers/shell/appearance/types.js +28 -0
  78. package/dist/shared/providers/shell/index.d.ts +1 -1
  79. package/dist/shared/providers/shell/responsiveDisplaySettings.d.ts +27 -0
  80. package/dist/shared/providers/shell/responsiveDisplaySettings.js +6 -0
  81. package/dist/shared/providers/shell/themeContext.d.ts +162 -0
  82. package/dist/shared/providers/shell/themeContext.js +4 -0
  83. package/dist/shared-backgrounds.js +4 -1
  84. package/dist/shell-native/system-bars.d.ts +5 -1
  85. package/dist/shell-native/system-bars.js +1 -1
  86. package/dist/ui/dropdown-menu.js +2 -0
  87. package/dist/ui/popover.js +1 -0
  88. package/dist/ui/select.js +1 -0
  89. package/package.json +5 -1
  90. package/src/shared/styles/page-widths.css +38 -0
  91. package/src/shared/tokens/build/brands/healthybowl.css +25 -3
  92. package/src/shared/tokens/build/themes.css +266 -0
  93. package/src/shared/tokens/display-settings.css +569 -0
  94. package/src/shared/tokens/tokens.css +4 -0
@@ -1,16 +1,19 @@
1
1
  import { desktopSetTheme as e } from "../../native/desktop.js";
2
2
  import { brandAttribute as t } from "./brandAttribute.js";
3
- import { applyThemedNativeControls as n } from "./themedNativeControls.js";
4
- import { createContext as r, use as i, useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
5
- import { jsx as l } from "react/jsx-runtime";
3
+ import { PaletteThemeProvider as n } from "./PaletteThemeProvider.js";
4
+ import { applyResponsiveDisplaySettings as r } from "./responsiveDisplaySettings.js";
5
+ import { applyThemedNativeControls as ee } from "./themedNativeControls.js";
6
+ import { ThemeContext as i } from "./themeContext.js";
7
+ import { use as a, useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
8
+ import { jsx as u } from "react/jsx-runtime";
6
9
  // src/shared/providers/shell/ThemeProvider.tsx
7
- var u = /* @__PURE__ */ new Set([
10
+ var d = /* @__PURE__ */ new Set([
8
11
  "dark",
9
12
  "forest",
10
13
  "ocean",
11
14
  "sunset",
12
15
  "high-contrast"
13
- ]), d = [
16
+ ]), f = [
14
17
  {
15
18
  value: "light",
16
19
  label: "Light",
@@ -41,8 +44,8 @@ var u = /* @__PURE__ */ new Set([
41
44
  label: "High Contrast",
42
45
  family: "dark"
43
46
  }
44
- ], ee = (e) => u.has(e) ? "dark" : "light";
45
- function f(e) {
47
+ ], p = (e) => d.has(e) ? "dark" : "light";
48
+ function m(e) {
46
49
  let t = /^#?([0-9a-f]{6})$/i.exec(e.trim());
47
50
  if (!t) return null;
48
51
  let n = parseInt(t[1], 16), r = [
@@ -55,8 +58,8 @@ function f(e) {
55
58
  });
56
59
  return .2126 * r[0] + .7152 * r[1] + .0722 * r[2];
57
60
  }
58
- var p = (e) => f(e) ?? 0, m = (e) => p(e) > .45;
59
- function h(e, t) {
61
+ var h = (e) => m(e) ?? 0, g = (e) => h(e) > .45;
62
+ function te(e, t) {
60
63
  if (typeof window > "u") return t;
61
64
  try {
62
65
  let n = localStorage.getItem(e);
@@ -65,30 +68,34 @@ function h(e, t) {
65
68
  return t;
66
69
  }
67
70
  }
68
- var g = r(null);
69
- function _({ children: r, defaultMode: i = "system", defaultBrand: u = "default", defaultDensity: d = "comfortable", defaultTypography: p = "default", defaultGlass: _ = "full", storageKey: v = "burdenoff-theme", themedNativeControls: y = !1 }) {
70
- let b = (e, t) => typeof window > "u" ? t : localStorage.getItem(`${v}-${e}`) || t, [x, te] = c(() => b("mode", i)), [S, ne] = c(() => b("brand", u)), [re, ie] = c(() => b("density", d)), [C, w] = c(() => b("typography", p)), [T, E] = c(() => b("glass", _)), [D, O] = c(() => b("reduce-motion", "") === "1"), [k, A] = c(() => h(`${v}-custom-list`, [])), [j, M] = c(() => b("active-custom", "") || null), N = s(() => x === "custom" ? k.find((e) => e.id === j) ?? null : null, [
71
- x,
71
+ function _(e) {
72
+ return e.paletteAppearance ? /* @__PURE__ */ u(n, { ...e }) : /* @__PURE__ */ u(v, { ...e });
73
+ }
74
+ function v({ children: n, defaultMode: a = "system", defaultBrand: d = "default", defaultDensity: f = "comfortable", defaultTypography: h = "default", defaultGlass: _ = "full", storageKey: v = "burdenoff-theme", themedNativeControls: y = !1, responsiveDisplaySettings: b = !1 }) {
75
+ let x = (e, t) => typeof window > "u" ? t : localStorage.getItem(`${v}-${e}`) || t, [S, ne] = l(() => x("mode", a)), [C, re] = l(() => x("brand", d)), [ie, ae] = l(() => x("density", f)), [oe, w] = l(() => x("typography", h)), [T, E] = l(() => x("glass", _)), [D, O] = l(() => x("reduce-motion", "") === "1"), [k, A] = l(() => te(`${v}-custom-list`, [])), [j, M] = l(() => x("active-custom", "") || null), N = c(() => S === "custom" ? k.find((e) => e.id === j) ?? null : null, [
76
+ S,
72
77
  k,
73
78
  j
74
- ]), [P, F] = c(() => x === "custom" ? "light" : x === "system" ? typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : x);
75
- o(() => {
76
- if (x === "system") {
79
+ ]), [P, F] = l(() => S === "custom" ? "light" : S === "system" ? typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : S);
80
+ s(() => {
81
+ if (S === "system") {
77
82
  let e = window.matchMedia("(prefers-color-scheme: dark)"), t = (e) => F(e.matches ? "dark" : "light");
78
83
  return e.addEventListener("change", t), F(e.matches ? "dark" : "light"), () => e.removeEventListener("change", t);
79
84
  }
80
- F(x === "custom" ? N?.base ?? "light" : x);
81
- }, [x, N]);
82
- let I = ee(P), L = N?.density ?? re, R = N?.typography ?? C, z = N?.glass ?? T, B = N?.reduceMotion ?? D;
83
- o(() => {
84
- if (y) return n(document, I);
85
- }, [y, I]), o(() => {
85
+ F(S === "custom" ? N?.base ?? "light" : S);
86
+ }, [S, N]);
87
+ let I = p(P), L = N?.density ?? ie, R = N?.typography ?? oe, z = N?.glass ?? T, B = N?.reduceMotion ?? D;
88
+ s(() => {
89
+ if (y) return ee(document, I);
90
+ }, [y, I]), s(() => {
91
+ if (b) return r(document.documentElement);
92
+ }, [b]), s(() => {
86
93
  let n = document.documentElement;
87
- if (n.setAttribute("data-theme", P), n.setAttribute("data-brand", t(S)), n.setAttribute("data-density", L), n.setAttribute("data-typography", R), n.setAttribute("data-glass", z), n.toggleAttribute("data-reduce-motion", B), I === "dark" ? n.classList.add("dark") : n.classList.remove("dark"), N) {
94
+ if (n.setAttribute("data-theme", P), n.setAttribute("data-brand", t(C)), n.setAttribute("data-density", L), n.setAttribute("data-typography", R), n.setAttribute("data-glass", z), n.toggleAttribute("data-reduce-motion", B), I === "dark" ? n.classList.add("dark") : n.classList.remove("dark"), N) {
88
95
  let e = N.accent;
89
- n.setAttribute("data-accent", "custom"), m(e) ? n.setAttribute("data-accent-label", "dark") : n.removeAttribute("data-accent-label");
90
- let t = f(e);
91
- t === null ? n.style.removeProperty("--custom-accent-luminance") : n.style.setProperty("--custom-accent-luminance", t.toFixed(4)), n.style.setProperty("--color-action-primary-bg", e), n.style.setProperty("--color-action-primary-bgHover", `color-mix(in oklab, ${e} 84%, black)`), n.style.setProperty("--color-action-primary-bgActive", `color-mix(in oklab, ${e} 70%, black)`), n.style.setProperty("--color-action-primary-text", m(e) ? "#0a0a0a" : "#ffffff");
96
+ n.setAttribute("data-accent", "custom"), g(e) ? n.setAttribute("data-accent-label", "dark") : n.removeAttribute("data-accent-label");
97
+ let t = m(e);
98
+ t === null ? n.style.removeProperty("--custom-accent-luminance") : n.style.setProperty("--custom-accent-luminance", t.toFixed(4)), n.style.setProperty("--color-action-primary-bg", e), n.style.setProperty("--color-action-primary-bgHover", `color-mix(in oklab, ${e} 84%, black)`), n.style.setProperty("--color-action-primary-bgActive", `color-mix(in oklab, ${e} 70%, black)`), n.style.setProperty("--color-action-primary-text", g(e) ? "#0a0a0a" : "#ffffff");
92
99
  } else n.removeAttribute("data-accent"), n.removeAttribute("data-accent-label"), n.style.removeProperty("--custom-accent-luminance"), n.style.removeProperty("--color-action-primary-bg"), n.style.removeProperty("--color-action-primary-bgHover"), n.style.removeProperty("--color-action-primary-bgActive"), n.style.removeProperty("--color-action-primary-text");
93
100
  let r = () => {
94
101
  let t = getComputedStyle(n).getPropertyValue("--color-bg-canvas").trim();
@@ -105,39 +112,39 @@ function _({ children: r, defaultMode: i = "system", defaultBrand: u = "default"
105
112
  }, [
106
113
  P,
107
114
  I,
108
- S,
115
+ C,
109
116
  L,
110
117
  R,
111
118
  z,
112
119
  B,
113
120
  N
114
121
  ]);
115
- let V = a((e, t) => localStorage.setItem(`${v}-${e}`, t), [v]), H = a((e) => {
116
- te(e), V("mode", e);
117
- }, [V]), U = a((e) => {
118
- ne(e), V("brand", e);
119
- }, [V]), W = a((e) => {
120
- ie(e), V("density", e);
121
- }, [V]), G = a((e) => {
122
+ let V = o((e, t) => localStorage.setItem(`${v}-${e}`, t), [v]), H = o((e) => {
123
+ ne(e), V("mode", e);
124
+ }, [V]), U = o((e) => {
125
+ re(e), V("brand", e);
126
+ }, [V]), W = o((e) => {
127
+ ae(e), V("density", e);
128
+ }, [V]), G = o((e) => {
122
129
  w(e), V("typography", e);
123
- }, [V]), K = a((e) => {
130
+ }, [V]), K = o((e) => {
124
131
  E(e), V("glass", e);
125
- }, [V]), q = a((e) => {
132
+ }, [V]), q = o((e) => {
126
133
  O(e), V("reduce-motion", e ? "1" : "0");
127
- }, [V]), J = a((e) => {
134
+ }, [V]), J = o((e) => {
128
135
  A(e), localStorage.setItem(`${v}-custom-list`, JSON.stringify(e));
129
- }, [v]), Y = a((e) => {
136
+ }, [v]), Y = o((e) => {
130
137
  let t = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `ct-${Date.now()}-${Math.floor(performance.now())}`, n = {
131
138
  ...e,
132
139
  id: t
133
140
  };
134
141
  return J([...k, n]), n;
135
- }, [k, J]), X = a((e, t) => {
142
+ }, [k, J]), X = o((e, t) => {
136
143
  J(k.map((n) => n.id === e ? {
137
144
  ...n,
138
145
  ...t
139
146
  } : n));
140
- }, [k, J]), Z = a((e) => {
147
+ }, [k, J]), Z = o((e) => {
141
148
  J(k.filter((t) => t.id !== e)), j === e && (M(null), V("active-custom", ""), H("system"));
142
149
  }, [
143
150
  k,
@@ -145,13 +152,13 @@ function _({ children: r, defaultMode: i = "system", defaultBrand: u = "default"
145
152
  j,
146
153
  V,
147
154
  H
148
- ]), Q = a((e) => {
155
+ ]), Q = o((e) => {
149
156
  M(e), V("active-custom", e), H("custom");
150
- }, [V, H]), $ = a(() => {
157
+ }, [V, H]), $ = o(() => {
151
158
  H(I === "light" ? "dark" : "light");
152
- }, [I, H]), ae = s(() => ({
153
- mode: x,
154
- brand: S,
159
+ }, [I, H]), se = c(() => ({
160
+ mode: S,
161
+ brand: C,
155
162
  density: L,
156
163
  typography: R,
157
164
  glass: z,
@@ -171,10 +178,11 @@ function _({ children: r, defaultMode: i = "system", defaultBrand: u = "default"
171
178
  deleteCustomTheme: Z,
172
179
  applyCustomTheme: Q,
173
180
  colorMode: I,
174
- toggleColorMode: $
181
+ toggleColorMode: $,
182
+ appearance: null
175
183
  }), [
176
- x,
177
184
  S,
185
+ C,
178
186
  L,
179
187
  R,
180
188
  z,
@@ -195,17 +203,17 @@ function _({ children: r, defaultMode: i = "system", defaultBrand: u = "default"
195
203
  Q,
196
204
  $
197
205
  ]);
198
- return /* @__PURE__ */ l(g.Provider, {
199
- value: ae,
200
- children: r
206
+ return /* @__PURE__ */ u(i.Provider, {
207
+ value: se,
208
+ children: n
201
209
  });
202
210
  }
203
- function v() {
204
- let e = i(g);
211
+ function y() {
212
+ let e = a(i);
205
213
  if (!e) throw Error("useTheme must be used within a ThemeProvider");
206
214
  return e;
207
215
  }
208
- function y() {
209
- return i(g);
216
+ function b() {
217
+ return a(i);
210
218
  }
211
- export { d as THEME_OPTIONS, _ as ThemeProvider, v as useTheme, y as useThemeOrNull };
219
+ export { f as THEME_OPTIONS, _ as ThemeProvider, y as useTheme, b as useThemeOrNull };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * BOFF-15524: the colour maths of the palette appearance model: WCAG 2.x contrast and the
3
+ * OKLab / OKLCH conversions the contrast fix walks along (same hue and chroma, another
4
+ * lightness). Pure functions on `#RRGGBB` strings; nothing here touches the DOM.
5
+ */
6
+ /** A colour as `#RRGGBB` (upper case), or null for anything else. */
7
+ export declare function normalizeHex(value: string | null | undefined): string | null;
8
+ /** WCAG relative luminance (0..1) of a `#RRGGBB` colour. */
9
+ export declare function luminance(hex: string): number;
10
+ /** WCAG contrast ratio (1..21) between two `#RRGGBB` colours. */
11
+ export declare function contrastRatio(a: string, b: string): number;
12
+ /** The lowest contrast of `colour` against each of `backgrounds`. */
13
+ export declare function minContrast(colour: string, backgrounds: readonly string[]): number;
14
+ /** OKLCH of a colour: lightness 0..1, chroma, hue in radians. */
15
+ export interface Oklch {
16
+ l: number;
17
+ c: number;
18
+ h: number;
19
+ }
20
+ export declare function toOklch(hex: string): Oklch;
21
+ /**
22
+ * The sRGB colour at this OKLCH lightness and hue, with the chroma reduced until it fits the
23
+ * sRGB gamut (a light or dark step of a vivid colour cannot keep all of its chroma).
24
+ */
25
+ export declare function fromOklch(l: number, c: number, h: number): string;
26
+ /** `a` mixed toward `b` by `t` (0 = a, 1 = b) in OKLab. */
27
+ export declare function mixOklab(a: string, b: string, t: number): string;
28
+ /** `rgba()` of a `#RRGGBB` colour at this alpha. */
29
+ export declare function rgbaOf(hex: string, alpha: number): string;
@@ -0,0 +1,79 @@
1
+ // src/shared/providers/shell/appearance/colour.ts
2
+ function e(e) {
3
+ let t = /^#?([0-9a-f]{6})$/i.exec(String(e ?? "").trim());
4
+ return t?.[1] ? `#${t[1].toUpperCase()}` : null;
5
+ }
6
+ var t = (e, t, n) => Math.min(n, Math.max(t, e));
7
+ function n(e) {
8
+ let t = parseInt(e.slice(1), 16);
9
+ return [
10
+ t >> 16 & 255,
11
+ t >> 8 & 255,
12
+ t & 255
13
+ ];
14
+ }
15
+ function r(e) {
16
+ return `#${e.map((e) => t(Math.round(e), 0, 255).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
17
+ }
18
+ var i = (e) => {
19
+ let t = e / 255;
20
+ return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
21
+ }, a = (e) => 255 * (e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055);
22
+ function o(e) {
23
+ let [t, r, a] = n(e).map(i);
24
+ return .2126 * t + .7152 * r + .0722 * a;
25
+ }
26
+ function s(e, t) {
27
+ let n = o(e), r = o(t);
28
+ return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
29
+ }
30
+ function c(e, t) {
31
+ return Math.min(...t.map((t) => s(e, t)));
32
+ }
33
+ function l(e) {
34
+ let [t, r, a] = n(e).map(i), o = Math.cbrt(.4122214708 * t + .5363325363 * r + .0514459929 * a), s = Math.cbrt(.2119034982 * t + .6806995451 * r + .1073969566 * a), c = Math.cbrt(.0883024619 * t + .2817188376 * r + .6299787005 * a);
35
+ return [
36
+ .2104542553 * o + .793617785 * s - .0040720468 * c,
37
+ 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
38
+ .0259040371 * o + .7827717662 * s - .808675766 * c
39
+ ];
40
+ }
41
+ function u([e, t, n]) {
42
+ let r = (e + .3963377774 * t + .2158037573 * n) ** 3, i = (e - .1055613458 * t - .0638541728 * n) ** 3, a = (e - .0894841775 * t - 1.291485548 * n) ** 3;
43
+ return [
44
+ 4.0767416621 * r - 3.3077115913 * i + .2309699292 * a,
45
+ -1.2684380046 * r + 2.6097574011 * i - .3413193965 * a,
46
+ -.0041960863 * r - .7034186147 * i + 1.707614701 * a
47
+ ];
48
+ }
49
+ var d = (e) => r(e.map((e) => a(t(e, 0, 1))));
50
+ function f(e) {
51
+ let [t, n, r] = l(e);
52
+ return {
53
+ l: t,
54
+ c: Math.hypot(n, r),
55
+ h: Math.atan2(r, n)
56
+ };
57
+ }
58
+ function p(e, t, n) {
59
+ let r = t;
60
+ for (let t = 0; t < 48; t += 1) {
61
+ let t = u([
62
+ e,
63
+ r * Math.cos(n),
64
+ r * Math.sin(n)
65
+ ]);
66
+ if (t.every((e) => e >= -1e-4 && e <= 1.0001)) return d(t);
67
+ r *= .9;
68
+ }
69
+ return d(u([
70
+ e,
71
+ 0,
72
+ 0
73
+ ]));
74
+ }
75
+ function m(e, t) {
76
+ let [r, i, a] = n(e);
77
+ return `rgba(${r}, ${i}, ${a}, ${t})`;
78
+ }
79
+ export { s as contrastRatio, p as fromOklch, o as luminance, c as minContrast, e as normalizeHex, m as rgbaOf, f as toOklch };
@@ -0,0 +1,70 @@
1
+ import { AccentPair } from './palettes';
2
+ export declare const TEXT_MIN = 4.5;
3
+ export declare const UI_MIN = 3;
4
+ /** What an accent is measured against: the page, a card and a menu, and the dark label. */
5
+ export interface AccentGround {
6
+ canvas: string;
7
+ surface: string;
8
+ elevated: string;
9
+ /** The palette's dark label (a light fill's label). */
10
+ darkLabel: string;
11
+ dark: boolean;
12
+ /** How far a dark label must read (default 4.5:1; more for a chosen accent, see above). */
13
+ darkLabelMin?: number;
14
+ }
15
+ /**
16
+ * The dark label's margin for a chosen accent, from depthContrast.test.ts's sweep of the
17
+ * palette model's accents under the depth layer: the glow takes a dark label's contrast down to
18
+ * 0.69 of itself on a dark page (so 6.5:1 keeps 4.5:1) and to 0.95 on a light one (4.75:1).
19
+ */
20
+ export declare const DARK_LABEL_MIN_ON_DARK = 6.5;
21
+ export declare const DARK_LABEL_MIN_ON_LIGHT = 4.75;
22
+ /** An accent the app can paint, with the ratios it reaches and the ones the raw colour had. */
23
+ export interface SolvedAccent {
24
+ /** The colour the person chose. */
25
+ raw: string;
26
+ fill: string;
27
+ on: string;
28
+ /** The label is the palette's dark one (a light fill), not white. */
29
+ onDark: boolean;
30
+ hover: string;
31
+ active: string;
32
+ ink: string;
33
+ inkHover: string;
34
+ /** The fill or its label moved off the raw colour. */
35
+ adjusted: boolean;
36
+ /** The ink moved off the raw colour. */
37
+ inkAdjusted: boolean;
38
+ onRatio: number;
39
+ fillRatio: number;
40
+ inkRatio: number;
41
+ rawOnRatio: number;
42
+ rawFillRatio: number;
43
+ rawInkRatio: number;
44
+ }
45
+ /** White or the dark label, whichever reads better on `fill`, with its ratio. */
46
+ export declare function bestLabel(fill: string, darkLabel: string): {
47
+ label: string;
48
+ ratio: number;
49
+ };
50
+ /**
51
+ * The label a fill carries: white where it reads at 4.5:1, else the dark label where it reads
52
+ * at the ground's minimum; null where neither does.
53
+ */
54
+ export declare function labelFor(fill: string, ground: AccentGround): {
55
+ label: string;
56
+ ratio: number;
57
+ } | null;
58
+ /** The fill against the page and a card (where buttons and toggles sit). */
59
+ export declare const fillRatioOf: (fill: string, ground: AccentGround) => number;
60
+ /** The ink against the page, a card and a menu. */
61
+ export declare const inkRatioOf: (ink: string, ground: AccentGround) => number;
62
+ /** The accent the app paints for any colour on this ground. */
63
+ export declare function solveAccent(colour: string, ground: AccentGround): SolvedAccent;
64
+ /**
65
+ * A hand-picked pair (a preset, a palette's own accent) as it is, when every check holds on
66
+ * this ground; otherwise the contrast fix of its fill.
67
+ */
68
+ export declare function accentFromPair(pair: AccentPair, ground: AccentGround): SolvedAccent;
69
+ /** The accent's relative luminance, as the depth layer reads it (4 decimals). */
70
+ export declare const accentLuminance: (fill: string) => string;
@@ -0,0 +1,117 @@
1
+ import { contrastRatio as e, fromOklch as t, luminance as n, minContrast as r, normalizeHex as i, toOklch as a } from "./colour.js";
2
+ // src/shared/providers/shell/appearance/contrastFix.ts
3
+ var o = 4.5, s = 6.5, c = 4.75, l = "#FFFFFF", u = .004, d = 250;
4
+ function f(t, n) {
5
+ let r = e(l, t), i = e(n, t);
6
+ return r >= i ? {
7
+ label: l,
8
+ ratio: r
9
+ } : {
10
+ label: n,
11
+ ratio: i
12
+ };
13
+ }
14
+ function p(t, n) {
15
+ let r = e(l, t);
16
+ if (r >= 4.5) return {
17
+ label: l,
18
+ ratio: r
19
+ };
20
+ let i = e(n.darkLabel, t);
21
+ return i >= (n.darkLabelMin ?? 4.5) ? {
22
+ label: n.darkLabel,
23
+ ratio: i
24
+ } : null;
25
+ }
26
+ var m = (e, t) => r(e, [t.canvas, t.surface]), h = (e, t) => r(e, [
27
+ t.canvas,
28
+ t.surface,
29
+ t.elevated
30
+ ]), g = (e, t) => p(e, t) !== null && m(e, t) >= 3;
31
+ function _(e, n) {
32
+ let { l: r, c: i, h: o } = a(e), s = n === l, c = (e) => t(Math.min(1, Math.max(0, s ? r - e : r + e)), i, o);
33
+ return {
34
+ hover: c(.07),
35
+ active: c(.14)
36
+ };
37
+ }
38
+ function v(e, n) {
39
+ let { l: r, c: i, h: o } = a(e);
40
+ return t(Math.min(1, Math.max(0, n.dark ? r + .08 : r - .08)), i, o);
41
+ }
42
+ function y(e, n) {
43
+ if (h(e, n) >= 4.5) return e;
44
+ let { l: r, c: i, h: o } = a(e), s = n.dark ? 1 : -1;
45
+ for (let e = 1; e <= 260; e += 1) {
46
+ let a = r + s * e * u;
47
+ if (a < 0 || a > 1) break;
48
+ let c = t(a, i, o);
49
+ if (h(c, n) >= 4.5) return c;
50
+ }
51
+ return n.dark ? l : "#000000";
52
+ }
53
+ function b(e, n) {
54
+ if (g(e, n)) return e;
55
+ let { l: r, c: i, h: o } = a(e);
56
+ for (let e = 1; e <= d; e += 1) for (let a of [1, -1]) {
57
+ let s = r + a * e * u;
58
+ if (s < 0 || s > 1) continue;
59
+ let c = t(s, i, o);
60
+ if (g(c, n)) return c;
61
+ }
62
+ return n.dark ? l : "#000000";
63
+ }
64
+ function x(e, t) {
65
+ let n = i(e) ?? l, r = b(n, t), { label: a, ratio: o } = p(r, t) ?? f(r, t.darkLabel), s = y(n, t);
66
+ return {
67
+ raw: n,
68
+ fill: r,
69
+ on: a,
70
+ onDark: a !== l,
71
+ ..._(r, a),
72
+ ink: s,
73
+ inkHover: v(s, t),
74
+ adjusted: r !== n,
75
+ inkAdjusted: s !== n,
76
+ onRatio: o,
77
+ fillRatio: m(r, t),
78
+ inkRatio: h(s, t),
79
+ rawOnRatio: f(n, t.darkLabel).ratio,
80
+ rawFillRatio: m(n, t),
81
+ rawInkRatio: h(n, t)
82
+ };
83
+ }
84
+ function S(t, n) {
85
+ let r = e(t.on, t.fill), i = m(t.fill, n), a = h(t.ink, n);
86
+ if (r < (t.on === l ? 4.5 : n.darkLabelMin ?? 4.5) || i < 3 || a < 4.5) {
87
+ let e = x(t.fill, n);
88
+ return a < 4.5 ? e : {
89
+ ...e,
90
+ ink: t.ink,
91
+ inkHover: v(t.ink, n),
92
+ inkAdjusted: !1,
93
+ inkRatio: a,
94
+ rawInkRatio: a
95
+ };
96
+ }
97
+ return {
98
+ raw: t.fill,
99
+ fill: t.fill,
100
+ on: t.on,
101
+ onDark: t.on !== l,
102
+ hover: t.hover,
103
+ active: t.active,
104
+ ink: t.ink,
105
+ inkHover: v(t.ink, n),
106
+ adjusted: !1,
107
+ inkAdjusted: !1,
108
+ onRatio: r,
109
+ fillRatio: i,
110
+ inkRatio: a,
111
+ rawOnRatio: r,
112
+ rawFillRatio: i,
113
+ rawInkRatio: a
114
+ };
115
+ }
116
+ var C = (e) => n(e).toFixed(4);
117
+ export { s as DARK_LABEL_MIN_ON_DARK, c as DARK_LABEL_MIN_ON_LIGHT, o as TEXT_MIN, S as accentFromPair, C as accentLuminance, f as bestLabel, m as fillRatioOf, h as inkRatioOf, p as labelFor, x as solveAccent };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * BOFF-15524: the palette appearance model (opt-in via `ThemeProvider paletteAppearance`).
3
+ */
4
+ export * from './types';
5
+ export { ACCENT_PRESETS, PALETTES, SITE_COLOURS, paletteAccent, paletteGlows, paletteSurfaces, paletteText, type AccentPair, type AccentPreset, type GlowTokens, type PaletteDefinition, type SurfaceTokens, type TextTokens, } from './palettes';
6
+ export { TEXT_MIN, UI_MIN, accentFromPair, bestLabel, solveAccent, type AccentGround, type SolvedAccent, } from './contrastFix';
7
+ export { accentHexOf, accentKey, activeLookOf, choicesAreLook, cssThemeOf, groundOf, hasLightMode, lookAccentOf, lookModeFor, lookModeOf, presetPair, resolveAppearance, schemeOf, type ResolvedAppearance, } from './model';
8
+ export { lookTokenStyle, type TokenStyle } from './tokens';
9
+ export { contrastRatio, luminance, normalizeHex } from './colour';
@@ -0,0 +1,68 @@
1
+ import { AccentGround, SolvedAccent } from './contrastFix';
2
+ import { AccentPair, GlowTokens, SurfaceTokens, TextTokens } from './palettes';
3
+ import { AccentChoice, AccentPresetId, AppearanceSettings, ColorModeSetting, ColorScheme, DarkDepth, LookMode, PaletteName, SavedColour, SavedLook } from './types';
4
+ /** Whether a palette has a light version (the expressive themes and High contrast do not). */
5
+ export declare const hasLightMode: (palette: PaletteName) => boolean;
6
+ /** What a Mode setting resolves to for a palette (a dark-only palette is always dark). */
7
+ export declare function schemeOf(palette: PaletteName, mode: ColorModeSetting, systemDark: boolean): ColorScheme;
8
+ /** The `<html data-theme>` value: Classic keeps today's `light` / `dark`. */
9
+ export declare function cssThemeOf(palette: PaletteName, scheme: ColorScheme): string;
10
+ /** The preset that is a palette's own colour, where one is (choosing it is choosing the theme's). */
11
+ export declare function ownPresetOf(palette: PaletteName, brand: string | null | undefined): AccentPresetId | null;
12
+ /** The preset's pair at a mode, its dark label the palette's own. */
13
+ export declare function presetPair(id: AccentPresetId, scheme: ColorScheme, darkLabel: string): AccentPair;
14
+ /** The `#RRGGBB` a choice stands for, or null for the theme's own colour (or a lost colour). */
15
+ export declare function accentHexOf(choice: AccentChoice, colours: readonly SavedColour[]): string | null;
16
+ /** A stable key for comparing two choices (a saved colour compares by its colour). */
17
+ export declare function accentKey(choice: AccentChoice, colours: readonly SavedColour[]): string;
18
+ /** Everything a look paints. */
19
+ export interface ResolvedAppearance {
20
+ palette: PaletteName;
21
+ scheme: ColorScheme;
22
+ cssTheme: string;
23
+ depth: DarkDepth;
24
+ surfaces: SurfaceTokens;
25
+ text: TextTokens;
26
+ glows: GlowTokens;
27
+ darkLabel: string;
28
+ /** The accent as the app paints it (the theme's own when `auto`). */
29
+ accent: SolvedAccent;
30
+ /** True when the accent is the theme's own: the stylesheets paint it, nothing inline. */
31
+ auto: boolean;
32
+ }
33
+ export interface ResolveInput {
34
+ palette: PaletteName;
35
+ mode: ColorModeSetting;
36
+ darkDepth: DarkDepth;
37
+ accent: AccentChoice;
38
+ colours: readonly SavedColour[];
39
+ }
40
+ export interface ResolveContext {
41
+ systemDark: boolean;
42
+ brand?: string | null;
43
+ }
44
+ /**
45
+ * The ground an accent is measured against, for a palette at a mode and depth. A chosen accent
46
+ * (`chosen`, painted inline) needs its dark label with the depth layer's margin; the palette's
47
+ * own accent is the stylesheet's, held to 4.5:1 with the layer by depthContrast.test.ts.
48
+ */
49
+ export declare function groundOf(palette: PaletteName, scheme: ColorScheme, depth: DarkDepth, chosen?: boolean): AccentGround;
50
+ export declare function resolveAppearance(input: ResolveInput, context: ResolveContext): ResolvedAppearance;
51
+ /** The Mode setting a look applies: its own, or the current one when it follows it. */
52
+ export declare const lookModeOf: (look: Pick<SavedLook, "mode">, current: ColorModeSetting) => "system" | ColorScheme;
53
+ /** Whether the choices are a look's: its palette, its colour and (unless it follows it) its mode. */
54
+ export declare function choicesAreLook(look: SavedLook, settings: Pick<AppearanceSettings, 'palette' | 'mode' | 'accent' | 'colours'>): boolean;
55
+ /**
56
+ * The saved look that is on: the one the person last switched to, while the choices are still
57
+ * its (another colour, or a mode it does not follow, turns it off; switching back turns it on).
58
+ * Kept by id, not found by its choices: a duplicate has the same choices as the look it copies,
59
+ * and the one switched to is the one that is on.
60
+ */
61
+ export declare function activeLookOf(settings: Pick<AppearanceSettings, 'palette' | 'mode' | 'accent' | 'colours' | 'looks' | 'activeLookId'>): SavedLook | null;
62
+ /**
63
+ * A choice as a look keeps it: a saved colour becomes its colour (so deleting the colour later
64
+ * leaves the look as it was).
65
+ */
66
+ export declare function lookAccentOf(choice: AccentChoice, colours: readonly SavedColour[]): SavedLook['accent'];
67
+ /** A look's mode, or the current Mode setting it follows, never light for a dark-only palette. */
68
+ export declare function lookModeFor(palette: PaletteName, mode: LookMode): LookMode;