eidos-ui 4.0.0 → 4.1.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.
Files changed (51) hide show
  1. package/README.md +19 -9
  2. package/dist/{SegmentedControl.types-D_gHYL9X.d.cts → SegmentedControl.types-50fprBiO.d.cts} +9 -0
  3. package/dist/{SegmentedControl.types-CHtjABQM.d.ts → SegmentedControl.types-DKlamnBZ.d.ts} +9 -0
  4. package/dist/{ThemeProvider.types-DgXN0gEH.d.cts → ThemeProvider.types-CI9P1anY.d.cts} +53 -2
  5. package/dist/{ThemeProvider.types-DgXN0gEH.d.ts → ThemeProvider.types-CI9P1anY.d.ts} +53 -2
  6. package/dist/{chunk-363IKX3C.js → chunk-BHZ76J2K.js} +43 -31
  7. package/dist/chunk-BHZ76J2K.js.map +1 -0
  8. package/dist/{chunk-U5KD4BWL.js → chunk-DHOBGYRD.js} +159 -29
  9. package/dist/chunk-DHOBGYRD.js.map +1 -0
  10. package/dist/{chunk-YZEALKC4.cjs → chunk-E7BFBU6K.cjs} +43 -31
  11. package/dist/chunk-E7BFBU6K.cjs.map +1 -0
  12. package/dist/{chunk-XOUNVK45.js → chunk-EJWEG66P.js} +225 -41
  13. package/dist/chunk-EJWEG66P.js.map +1 -0
  14. package/dist/{chunk-FAXDWZQH.js → chunk-FFYPSLQV.js} +2 -2
  15. package/dist/{chunk-PVNBH7XN.cjs → chunk-JO4NDJRA.cjs} +177 -47
  16. package/dist/chunk-JO4NDJRA.cjs.map +1 -0
  17. package/dist/{chunk-QDZVZY53.cjs → chunk-O45W57Y4.cjs} +229 -45
  18. package/dist/chunk-O45W57Y4.cjs.map +1 -0
  19. package/dist/{chunk-NYGRVB2J.cjs → chunk-VGMRIXW4.cjs} +3 -3
  20. package/dist/{chunk-NYGRVB2J.cjs.map → chunk-VGMRIXW4.cjs.map} +1 -1
  21. package/dist/data-grid/index.cjs +3 -3
  22. package/dist/data-grid/index.d.cts +1 -1
  23. package/dist/data-grid/index.d.ts +1 -1
  24. package/dist/data-grid/index.js +2 -2
  25. package/dist/index.cjs +8 -8
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.css +345 -205
  28. package/dist/index.d.cts +2 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +7 -7
  31. package/dist/segmented-control/index.cjs +2 -2
  32. package/dist/segmented-control/index.d.cts +2 -2
  33. package/dist/segmented-control/index.d.ts +2 -2
  34. package/dist/segmented-control/index.js +1 -1
  35. package/dist/theme-editor/index.cjs +5 -3
  36. package/dist/theme-editor/index.cjs.map +1 -1
  37. package/dist/theme-editor/index.d.cts +1 -1
  38. package/dist/theme-editor/index.d.ts +1 -1
  39. package/dist/theme-editor/index.js +4 -2
  40. package/dist/theme-provider/index.cjs +2 -2
  41. package/dist/theme-provider/index.d.cts +2 -2
  42. package/dist/theme-provider/index.d.ts +2 -2
  43. package/dist/theme-provider/index.js +1 -1
  44. package/package.json +1 -1
  45. package/dist/chunk-363IKX3C.js.map +0 -1
  46. package/dist/chunk-PVNBH7XN.cjs.map +0 -1
  47. package/dist/chunk-QDZVZY53.cjs.map +0 -1
  48. package/dist/chunk-U5KD4BWL.js.map +0 -1
  49. package/dist/chunk-XOUNVK45.js.map +0 -1
  50. package/dist/chunk-YZEALKC4.cjs.map +0 -1
  51. /package/dist/{chunk-FAXDWZQH.js.map → chunk-FFYPSLQV.js.map} +0 -0
@@ -1,5 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
+ var _chunkIXZMKIV5cjs = require('./chunk-IXZMKIV5.cjs');
3
4
 
4
5
 
5
6
 
@@ -13,12 +14,18 @@
13
14
 
14
15
 
15
16
 
16
- var _chunkQDZVZY53cjs = require('./chunk-QDZVZY53.cjs');
17
+
18
+
19
+
20
+ var _chunkO45W57Y4cjs = require('./chunk-O45W57Y4.cjs');
17
21
 
18
22
 
19
23
  var _chunkOZZHOEN5cjs = require('./chunk-OZZHOEN5.cjs');
20
24
 
21
25
 
26
+ var _chunkE7BFBU6Kcjs = require('./chunk-E7BFBU6K.cjs');
27
+
28
+
22
29
  var _chunkBKUZF7CWcjs = require('./chunk-BKUZF7CW.cjs');
23
30
 
24
31
 
@@ -39,9 +46,25 @@ var _chunkRZMQCVAScjs = require('./chunk-RZMQCVAS.cjs');
39
46
 
40
47
  // src/components/ThemeEditor/ThemeEditor.component.tsx
41
48
  var _react = require('react');
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
42
57
  var _lucidereact = require('lucide-react');
43
58
  var _jsxruntime = require('react/jsx-runtime');
44
- var PAGE_SURFACE = _chunkQDZVZY53cjs.CONTRAST_LIGHT;
59
+ var PAGE_SURFACE = {
60
+ light: _chunkO45W57Y4cjs.CONTRAST_LIGHT,
61
+ dark: _chunkO45W57Y4cjs.DARK_SURFACE
62
+ };
63
+ var SCHEME_OPTIONS = [
64
+ { value: "light", label: "Light" },
65
+ { value: "dark", label: "Dark" },
66
+ { value: "system", label: "System" }
67
+ ];
45
68
  var EDGE_MIN_RATIO = 1.5;
46
69
  var COLOR_LABELS = {
47
70
  primary: "Primary",
@@ -58,7 +81,7 @@ var FONT_STACKS = [
58
81
  // matches an option exactly. A hand-copied shorter stack did not match, and
59
82
  // the row fell back to showing a synthetic "custom" entry instead of the
60
83
  // name of the font actually in use.
61
- { label: "Plus Jakarta Sans (theme default)", value: _chunkQDZVZY53cjs.defaultTheme.typography.fontFamily },
84
+ { label: "Plus Jakarta Sans (theme default)", value: _chunkO45W57Y4cjs.defaultTheme.typography.fontFamily },
62
85
  { label: "System UI", value: "system-ui, -apple-system, 'Segoe UI', sans-serif" },
63
86
  { label: "Helvetica / Arial", value: "Helvetica, Arial, sans-serif" },
64
87
  { label: "Georgia", value: "Georgia, 'Times New Roman', serif" },
@@ -66,7 +89,7 @@ var FONT_STACKS = [
66
89
  { label: "Serif (generic)", value: "serif" }
67
90
  ];
68
91
  var MONO_STACKS = [
69
- { label: "JetBrains Mono (theme default)", value: _chunkQDZVZY53cjs.defaultTheme.typography.monoFamily },
92
+ { label: "JetBrains Mono (theme default)", value: _chunkO45W57Y4cjs.defaultTheme.typography.monoFamily },
70
93
  { label: "Menlo / Consolas", value: "Menlo, Consolas, monospace" },
71
94
  { label: "Courier New", value: "'Courier New', Courier, monospace" },
72
95
  { label: "Monospace (generic)", value: "monospace" }
@@ -86,20 +109,21 @@ var GRADE_BADGE = {
86
109
  "aa-large": { label: "Too low for body text", icon: _lucidereact.TriangleAlert },
87
110
  fail: { label: "Fails AA", icon: _lucidereact.CircleX }
88
111
  };
89
- var diagnose = (key, base, explicitContrast) => {
112
+ var diagnose = (key, base, explicitContrast, scheme) => {
113
+ const page = PAGE_SURFACE[scheme];
90
114
  if (!isFill(key)) {
91
- const ratio2 = _chunkQDZVZY53cjs.contrastRatio.call(void 0, base, PAGE_SURFACE);
115
+ const ratio2 = _chunkO45W57Y4cjs.contrastRatio.call(void 0, base, page);
92
116
  const grade2 = gradeFor(ratio2);
93
117
  return {
94
118
  grade: grade2,
95
119
  ratio: ratio2,
96
- detail: `Link text on the page background: ${ratio2.toFixed(2)}:1 against white.${_nullishCoalesce(GRADE_CAVEAT[grade2], () => ( ""))}`
120
+ detail: `Link text on the page background: ${ratio2.toFixed(2)}:1 against the ${scheme} page.${_nullishCoalesce(GRADE_CAVEAT[grade2], () => ( ""))}`
97
121
  };
98
122
  }
99
- const foreground = _nullishCoalesce(explicitContrast, () => ( _chunkQDZVZY53cjs.pickContrast.call(void 0, base)));
100
- const ratio = _chunkQDZVZY53cjs.contrastRatio.call(void 0, base, foreground);
101
- const name = foreground.toLowerCase() === _chunkQDZVZY53cjs.CONTRAST_DARK ? "dark" : "white";
102
- const edge = _chunkQDZVZY53cjs.contrastRatio.call(void 0, base, PAGE_SURFACE);
123
+ const foreground = _nullishCoalesce(explicitContrast, () => ( _chunkO45W57Y4cjs.pickContrast.call(void 0, base)));
124
+ const ratio = _chunkO45W57Y4cjs.contrastRatio.call(void 0, base, foreground);
125
+ const name = foreground.toLowerCase() === _chunkO45W57Y4cjs.CONTRAST_DARK ? "dark" : "white";
126
+ const edge = _chunkO45W57Y4cjs.contrastRatio.call(void 0, base, page);
103
127
  const grade = gradeFor(ratio);
104
128
  return {
105
129
  grade,
@@ -121,14 +145,14 @@ var FontRow = ({
121
145
  const inputRef = _react.useRef.call(void 0, null);
122
146
  const [error, setError] = _react.useState.call(void 0, null);
123
147
  const [, onFontsLoaded] = _react.useReducer.call(void 0, (count) => count + 1, 0);
124
- _react.useEffect.call(void 0, () => _chunkQDZVZY53cjs.subscribeToFontLoads.call(void 0, onFontsLoaded), [onFontsLoaded]);
148
+ _react.useEffect.call(void 0, () => _chunkO45W57Y4cjs.subscribeToFontLoads.call(void 0, onFontsLoaded), [onFontsLoaded]);
125
149
  const baseOptions = _react.useMemo.call(void 0, () => {
126
150
  const known = options.some((o) => o.value === value);
127
151
  return known ? options : [...options, { label: `${firstFamily(value)} (custom)`, value }];
128
152
  }, [options, value]);
129
153
  const selectOptions = baseOptions.map((option) => ({
130
154
  id: option.value,
131
- label: _chunkQDZVZY53cjs.isFontStackAvailable.call(void 0, option.value) ? option.label : `${option.label} - not installed`,
155
+ label: _chunkO45W57Y4cjs.isFontStackAvailable.call(void 0, option.value) ? option.label : `${option.label} - not installed`,
132
156
  value: option.value
133
157
  }));
134
158
  const handleFile = _react.useCallback.call(void 0,
@@ -136,8 +160,8 @@ var FontRow = ({
136
160
  if (!file) return;
137
161
  setError(null);
138
162
  try {
139
- const family = await _chunkQDZVZY53cjs.registerFontFile.call(void 0, file);
140
- const stack = _chunkQDZVZY53cjs.toFontStack.call(void 0, family, mono);
163
+ const family = await _chunkO45W57Y4cjs.registerFontFile.call(void 0, file);
164
+ const stack = _chunkO45W57Y4cjs.toFontStack.call(void 0, family, mono);
141
165
  onUploaded({ label: `${family} (this session)`, value: stack }, file, family);
142
166
  onChange(stack);
143
167
  } catch (cause) {
@@ -148,7 +172,7 @@ var FontRow = ({
148
172
  },
149
173
  [mono, onChange, onUploaded]
150
174
  );
151
- const unavailable = !_chunkQDZVZY53cjs.isFontStackAvailable.call(void 0, value);
175
+ const unavailable = !_chunkO45W57Y4cjs.isFontStackAvailable.call(void 0, value);
152
176
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row eidos-theme-editor-row--wide", children: [
153
177
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label", children: label }),
154
178
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-row__control", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -195,7 +219,7 @@ var FontRow = ({
195
219
  {
196
220
  ref: inputRef,
197
221
  type: "file",
198
- accept: _chunkQDZVZY53cjs.FONT_ACCEPT,
222
+ accept: _chunkO45W57Y4cjs.FONT_ACCEPT,
199
223
  className: "eidos-theme-editor-file",
200
224
  tabIndex: -1,
201
225
  "aria-hidden": "true",
@@ -209,7 +233,7 @@ var FontRow = ({
209
233
  ] });
210
234
  };
211
235
  var ThemeEditor = ({
212
- colors = _chunkQDZVZY53cjs.THEME_COLOR_KEYS,
236
+ colors = _chunkO45W57Y4cjs.THEME_COLOR_KEYS,
213
237
  fontOptions = FONT_STACKS,
214
238
  monoFontOptions = MONO_STACKS,
215
239
  allowFontUpload = true,
@@ -219,13 +243,26 @@ var ThemeEditor = ({
219
243
  hideCssExport = false,
220
244
  className
221
245
  }) => {
222
- const { theme, resolvedTheme, setTheme, updateTheme, resetTheme, isDefault, toCss } = _chunkQDZVZY53cjs.useTheme.call(void 0, );
246
+ const {
247
+ theme,
248
+ resolvedTheme,
249
+ setTheme,
250
+ updateTheme,
251
+ resetTheme,
252
+ isDefault,
253
+ toCss,
254
+ colorScheme,
255
+ resolvedColorScheme,
256
+ setColorScheme
257
+ } = _chunkO45W57Y4cjs.useTheme.call(void 0, );
223
258
  const [copied, setCopied] = _react.useState.call(void 0, false);
259
+ const hasDarkOverrides = Object.keys(_nullishCoalesce(_optionalChain([theme, 'access', _14 => _14.dark, 'optionalAccess', _15 => _15.colors]), () => ( {}))).length > 0;
260
+ const [separateDark, setSeparateDark] = _react.useState.call(void 0, hasDarkOverrides);
224
261
  const [uploaded, setUploaded] = _react.useState.call(void 0, []);
225
262
  const [monoUploaded, setMonoUploaded] = _react.useState.call(void 0, []);
226
263
  const setColor = _react.useCallback.call(void 0,
227
264
  (key, hex) => {
228
- const current = _optionalChain([theme, 'access', _14 => _14.colors, 'optionalAccess', _15 => _15[key]]);
265
+ const current = _optionalChain([theme, 'access', _16 => _16.colors, 'optionalAccess', _17 => _17[key]]);
229
266
  const pinned = typeof current === "object" ? current.contrast : void 0;
230
267
  updateTheme({ colors: { [key]: pinned ? { base: hex, contrast: pinned } : hex } });
231
268
  },
@@ -239,12 +276,43 @@ var ThemeEditor = ({
239
276
  },
240
277
  [theme, setTheme]
241
278
  );
279
+ const setDarkColor = _react.useCallback.call(void 0,
280
+ (key, hex) => updateTheme({ dark: { colors: { [key]: hex } } }),
281
+ [updateTheme]
282
+ );
283
+ const resetDarkColor = _react.useCallback.call(void 0,
284
+ (key) => {
285
+ const nextDark = { ..._optionalChain([theme, 'access', _18 => _18.dark, 'optionalAccess', _19 => _19.colors]) };
286
+ delete nextDark[key];
287
+ setTheme({ ...theme, dark: { colors: nextDark } });
288
+ },
289
+ [theme, setTheme]
290
+ );
291
+ const toggleSeparateDark = _react.useCallback.call(void 0,
292
+ (on) => {
293
+ setSeparateDark(on);
294
+ if (!on && hasDarkOverrides) setTheme({ ...theme, dark: { colors: {} } });
295
+ },
296
+ [hasDarkOverrides, setTheme, theme]
297
+ );
242
298
  const diagnostics = _react.useMemo.call(void 0,
243
299
  () => colors.map((key) => {
244
- const { base, contrast } = resolvedTheme.colors[key];
245
- return { key, base, ...diagnose(key, base, contrast) };
300
+ const palette = resolvedColorScheme === "dark" ? resolvedTheme.dark.colors : resolvedTheme.colors;
301
+ const { base, contrast } = palette[key];
302
+ const diagnostic = diagnose(key, base, contrast, resolvedColorScheme);
303
+ const lightBase = resolvedTheme.colors[key].base;
304
+ return {
305
+ key,
306
+ base: lightBase,
307
+ darkBase: resolvedTheme.dark.colors[key].base,
308
+ ...diagnostic,
309
+ // In dark the picker still shows the colour as picked, but what is
310
+ // graded - and rendered - is its dark tone. Name it, or the badge
311
+ // appears to describe a colour that is not on screen.
312
+ detail: resolvedColorScheme === "dark" && base !== lightBase ? `In dark this renders as ${base}. ${diagnostic.detail}` : diagnostic.detail
313
+ };
246
314
  }),
247
- [colors, resolvedTheme]
315
+ [colors, resolvedTheme, resolvedColorScheme]
248
316
  );
249
317
  const failing = diagnostics.filter((d) => d.grade === "fail");
250
318
  const invisible = diagnostics.filter((d) => d.edgeWarning);
@@ -254,7 +322,7 @@ var ThemeEditor = ({
254
322
  setCopied(true);
255
323
  setTimeout(() => setCopied(false), 1600);
256
324
  };
257
- if (_optionalChain([navigator, 'access', _16 => _16.clipboard, 'optionalAccess', _17 => _17.writeText])) {
325
+ if (_optionalChain([navigator, 'access', _20 => _20.clipboard, 'optionalAccess', _21 => _21.writeText])) {
258
326
  navigator.clipboard.writeText(css).then(done, done);
259
327
  return;
260
328
  }
@@ -275,14 +343,52 @@ var ThemeEditor = ({
275
343
  "."
276
344
  ] })
277
345
  ] }),
346
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkV5RS3JZNcjs.Card, { variant: "outlined", padding: "lg", className: "eidos-theme-editor-section", children: [
347
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-section__header", children: [
348
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-section__title", id: "eidos-theme-editor-scheme", children: "Colour scheme" }),
349
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-section__hint", children: "Your colours apply to both schemes. In dark each one is lightened until it reads on the dark page, with dark text on it - turn on separate dark colours to pick them yourself." })
350
+ ] }),
351
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-rows", children: [
352
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row eidos-theme-editor-row--wide", children: [
353
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label", children: "Scheme" }),
354
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-row__control", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
355
+ _chunkE7BFBU6Kcjs.SegmentedControl,
356
+ {
357
+ options: SCHEME_OPTIONS,
358
+ value: colorScheme,
359
+ onChange: (value) => setColorScheme(value),
360
+ "aria-labelledby": "eidos-theme-editor-scheme",
361
+ size: "sm"
362
+ }
363
+ ) })
364
+ ] }),
365
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row eidos-theme-editor-row--wide", children: [
366
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label" }),
367
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-row__control", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
368
+ _chunkIXZMKIV5cjs.Switch,
369
+ {
370
+ label: "Separate dark colours",
371
+ checked: separateDark,
372
+ onChange: (event) => toggleSeparateDark(event.target.checked),
373
+ size: "sm"
374
+ }
375
+ ) })
376
+ ] })
377
+ ] })
378
+ ] }),
278
379
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkV5RS3JZNcjs.Card, { variant: "outlined", padding: "lg", className: "eidos-theme-editor-section", children: [
279
380
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-section__header", children: [
280
381
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-section__title", children: "Colours" }),
281
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-section__hint", children: "Shades, tints and foregrounds are derived from each base colour." })
382
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "eidos-theme-editor-section__hint", children: [
383
+ "Shades, tints and foregrounds are derived from each base colour. Contrast is measured against the ",
384
+ resolvedColorScheme,
385
+ " page."
386
+ ] })
282
387
  ] }),
283
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-rows", children: diagnostics.map(({ key, base, grade, ratio, detail, edgeWarning }) => {
388
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-rows", children: diagnostics.map(({ key, base, darkBase, grade, ratio, detail, edgeWarning }) => {
284
389
  const badge = GRADE_BADGE[grade];
285
- const overridden = _optionalChain([theme, 'access', _18 => _18.colors, 'optionalAccess', _19 => _19[key]]) !== void 0;
390
+ const overridden = _optionalChain([theme, 'access', _22 => _22.colors, 'optionalAccess', _23 => _23[key]]) !== void 0;
391
+ const darkOverridden = _optionalChain([theme, 'access', _24 => _24.dark, 'optionalAccess', _25 => _25.colors, 'optionalAccess', _26 => _26[key]]) !== void 0;
286
392
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row", children: [
287
393
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label", children: COLOR_LABELS[key] }),
288
394
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -294,6 +400,15 @@ var ThemeEditor = ({
294
400
  ariaLabel: COLOR_LABELS[key]
295
401
  }
296
402
  ),
403
+ separateDark && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
404
+ _chunkSJPCBRKRcjs.ColorPicker,
405
+ {
406
+ value: darkBase,
407
+ onChange: (hex) => setDarkColor(key, hex),
408
+ size: "md",
409
+ ariaLabel: `${COLOR_LABELS[key]} (dark)`
410
+ }
411
+ ),
297
412
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row__diagnostics", children: [
298
413
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRZMQCVAScjs.Tooltip, { message: detail, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: `eidos-theme-editor-badge eidos-theme-editor-badge--${grade}`, children: [
299
414
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, badge.icon, { className: "eidos-theme-editor-badge__icon" }),
@@ -304,19 +419,34 @@ var ThemeEditor = ({
304
419
  "Invisible on page"
305
420
  ] }) })
306
421
  ] }),
307
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-row__actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
308
- _chunkNSA7ASZ7cjs.IconButton,
309
- {
310
- icon: _lucidereact.RotateCcw,
311
- variant: "text",
312
- color: "secondary",
313
- size: "sm",
314
- disabled: !overridden,
315
- onClick: () => resetColor(key),
316
- tooltip: overridden ? `Reset ${COLOR_LABELS[key]} to the preset` : "Unchanged",
317
- "aria-label": `Reset ${COLOR_LABELS[key]}`
318
- }
319
- ) })
422
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row__actions", children: [
423
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
424
+ _chunkNSA7ASZ7cjs.IconButton,
425
+ {
426
+ icon: _lucidereact.RotateCcw,
427
+ variant: "text",
428
+ color: "secondary",
429
+ size: "sm",
430
+ disabled: !overridden,
431
+ onClick: () => resetColor(key),
432
+ tooltip: overridden ? `Reset ${COLOR_LABELS[key]} to the preset` : "Unchanged",
433
+ "aria-label": `Reset ${COLOR_LABELS[key]}`
434
+ }
435
+ ),
436
+ separateDark && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
437
+ _chunkNSA7ASZ7cjs.IconButton,
438
+ {
439
+ icon: _lucidereact.RotateCcw,
440
+ variant: "text",
441
+ color: "secondary",
442
+ size: "sm",
443
+ disabled: !darkOverridden,
444
+ onClick: () => resetDarkColor(key),
445
+ tooltip: darkOverridden ? `Use the derived dark ${COLOR_LABELS[key]} again` : "Derived from the light colour",
446
+ "aria-label": `Reset dark ${COLOR_LABELS[key]}`
447
+ }
448
+ )
449
+ ] })
320
450
  ] }, key);
321
451
  }) })
322
452
  ] }),
@@ -341,7 +471,7 @@ var ThemeEditor = ({
341
471
  onChange: (fontFamily) => updateTheme({ typography: { fontFamily } }),
342
472
  onUploaded: (option, file, family) => {
343
473
  setUploaded((prev) => [...prev, option]);
344
- _optionalChain([onFontUpload, 'optionalCall', _20 => _20(file, family, false)]);
474
+ _optionalChain([onFontUpload, 'optionalCall', _27 => _27(file, family, false)]);
345
475
  }
346
476
  }
347
477
  ),
@@ -356,7 +486,7 @@ var ThemeEditor = ({
356
486
  onChange: (monoFamily) => updateTheme({ typography: { monoFamily } }),
357
487
  onUploaded: (option, file, family) => {
358
488
  setMonoUploaded((prev) => [...prev, option]);
359
- _optionalChain([onFontUpload, 'optionalCall', _21 => _21(file, family, true)]);
489
+ _optionalChain([onFontUpload, 'optionalCall', _28 => _28(file, family, true)]);
360
490
  }
361
491
  }
362
492
  ),
@@ -366,8 +496,8 @@ var ThemeEditor = ({
366
496
  _chunkOZZHOEN5cjs.Slider,
367
497
  {
368
498
  value: resolvedTheme.typography.fontScale,
369
- min: _chunkQDZVZY53cjs.FONT_SCALE_MIN,
370
- max: _chunkQDZVZY53cjs.FONT_SCALE_MAX,
499
+ min: _chunkO45W57Y4cjs.FONT_SCALE_MIN,
500
+ max: _chunkO45W57Y4cjs.FONT_SCALE_MAX,
371
501
  step: 0.025,
372
502
  showValue: true,
373
503
  showMinMax: true,
@@ -384,9 +514,9 @@ var ThemeEditor = ({
384
514
  _chunkNSA7ASZ7cjs.Button,
385
515
  {
386
516
  variant: "outlined",
387
- preIcon: copied ? "Check" : "Clipboard",
517
+ preIcon: copied ? _lucidereact.Check : _lucidereact.Clipboard,
388
518
  onClick: copyCss,
389
- tooltip: "Copy the resolved tokens as a :root block you can paste into your own stylesheet",
519
+ tooltip: "Copy the resolved tokens - light and dark - as CSS you can paste into your own stylesheet",
390
520
  children: copied ? "Copied" : "Copy as CSS"
391
521
  }
392
522
  )
@@ -398,4 +528,4 @@ ThemeEditor.displayName = "ThemeEditor";
398
528
 
399
529
 
400
530
  exports.ThemeEditor = ThemeEditor;
401
- //# sourceMappingURL=chunk-PVNBH7XN.cjs.map
531
+ //# sourceMappingURL=chunk-JO4NDJRA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/chunk-JO4NDJRA.cjs","../src/components/ThemeEditor/ThemeEditor.component.tsx"],"names":["ratio","grade"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;AC9CA,8BAAqF;AACrF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,2CACK;AA0RD,+CAAA;AA/ON,IAAM,aAAA,EAAo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A;AD1MA;AACA;AACA;AACA","file":"/home/runner/work/eidos-ui/eidos-ui/dist/chunk-JO4NDJRA.cjs","sourcesContent":[null,"import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport {\n Check,\n CircleCheck,\n CircleX,\n Clipboard,\n RotateCcw,\n TriangleAlert,\n Upload,\n} from 'lucide-react';\nimport { Alert } from '../Alert';\nimport { Button, IconButton } from '../Button';\nimport { Card } from '../Card';\nimport { ColorPicker } from '../ColorPicker';\nimport { SegmentedControl } from '../SegmentedControl';\nimport { Select } from '../Select';\nimport { Slider } from '../Slider';\nimport { Switch } from '../Switch';\nimport { Tooltip } from '../Tooltip';\nimport { useTheme } from '../ThemeProvider';\nimport type {\n ColorScheme,\n ResolvedColorScheme,\n ThemeColorKey,\n ThemeFontOption,\n} from '../ThemeProvider';\nimport {\n THEME_COLOR_KEYS,\n FONT_SCALE_MAX,\n FONT_SCALE_MIN,\n defaultTheme,\n} from '../ThemeProvider/ThemeProvider.tokens';\nimport {\n CONTRAST_DARK,\n CONTRAST_LIGHT,\n DARK_SURFACE,\n contrastRatio,\n pickContrast,\n} from '../ThemeProvider/ThemeProvider.color';\nimport {\n FONT_ACCEPT,\n isFontStackAvailable,\n registerFontFile,\n subscribeToFontLoads,\n toFontStack,\n} from '../ThemeProvider/ThemeProvider.fonts';\nimport type { ThemeEditorProps } from './ThemeEditor.types';\n\n/**\n * The page surface each scheme's diagnostics are measured against - the\n * `--surface` token's value in that scheme.\n */\nconst PAGE_SURFACE: Record<ResolvedColorScheme, string> = {\n light: CONTRAST_LIGHT,\n dark: DARK_SURFACE,\n};\n\nconst SCHEME_OPTIONS: { value: ColorScheme; label: string }[] = [\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n { value: 'system', label: 'System' },\n];\n\n/** Below this, a fill is effectively invisible against the page behind it. */\nconst EDGE_MIN_RATIO = 1.5;\n\nconst COLOR_LABELS: Record<ThemeColorKey, string> = {\n primary: 'Primary',\n secondary: 'Secondary',\n success: 'Success',\n danger: 'Danger',\n warning: 'Warning',\n info: 'Info',\n hyperlink: 'Hyperlink',\n};\n\n/** `hyperlink` is only ever text on a surface, so it is graded differently. */\nconst isFill = (key: ThemeColorKey): boolean => key !== 'hyperlink';\n\n/**\n * Built-in stacks, deliberately limited to fonts that can be relied on.\n *\n * A dropdown implies its entries are available, but a font stack is only a list\n * of *names* - nothing here can install a font. So the list is restricted to\n * generic families (guaranteed by CSS), `system-ui` (whatever the OS provides),\n * and the handful of genuinely web-safe faces. Fonts like Inter, which are not\n * installed anywhere by default, were removed: offering one is offering a\n * choice that silently does nothing on most machines.\n *\n * The preset is included because it is the shipped default and therefore has to\n * be representable - and note that `eidos-ui` does not ship the Plus Jakarta\n * Sans file either, so it renders only where the consumer provides it. That is\n * exactly why unavailable options are labelled as such.\n *\n * Anything beyond this belongs to the consuming app, via `fontOptions`.\n */\nconst FONT_STACKS: ThemeFontOption[] = [\n // Taken from the preset rather than retyped, so the shipped default always\n // matches an option exactly. A hand-copied shorter stack did not match, and\n // the row fell back to showing a synthetic \"custom\" entry instead of the\n // name of the font actually in use.\n { label: 'Plus Jakarta Sans (theme default)', value: defaultTheme.typography.fontFamily! },\n { label: 'System UI', value: \"system-ui, -apple-system, 'Segoe UI', sans-serif\" },\n { label: 'Helvetica / Arial', value: 'Helvetica, Arial, sans-serif' },\n { label: 'Georgia', value: \"Georgia, 'Times New Roman', serif\" },\n { label: 'Sans-serif (generic)', value: 'sans-serif' },\n { label: 'Serif (generic)', value: 'serif' },\n];\n\nconst MONO_STACKS: ThemeFontOption[] = [\n { label: 'JetBrains Mono (theme default)', value: defaultTheme.typography.monoFamily! },\n { label: 'Menlo / Consolas', value: 'Menlo, Consolas, monospace' },\n { label: 'Courier New', value: \"'Courier New', Courier, monospace\" },\n { label: 'Monospace (generic)', value: 'monospace' },\n];\n\ntype Grade = 'aa' | 'aa-large' | 'fail';\n\nconst gradeFor = (ratio: number): Grade => (ratio >= 4.5 ? 'aa' : ratio >= 3 ? 'aa-large' : 'fail');\n\n/** Spelled out for the middle grade, which is the one that misleads. */\nconst GRADE_CAVEAT: Partial<Record<Grade, string>> = {\n 'aa-large':\n ' WCAG AA needs 4.5:1 for normal text and allows 3:1 only at 24px or larger - button and label text here is around 12px, so this does not pass.',\n fail: ' Below 3:1, which fails WCAG AA at every text size.',\n};\n\n/**\n * Severity is carried by an icon and the label text, not by colour.\n *\n * These badges cannot use `Pill`, or any themed `--x-color`: the theme being\n * edited also styles this editor, so a washed-out `success` colour would render\n * the \"passes AA\" badge illegible at precisely the moment it is reporting that\n * a colour is illegible. The badge styling comes from the gray ramp, which is\n * deliberately not themeable.\n *\n * Not relying on colour alone also satisfies WCAG 1.4.1 (Use of Colour).\n */\nconst GRADE_BADGE: Record<\n Grade,\n { label: string; icon: React.ComponentType<{ className?: string }> }\n> = {\n aa: { label: 'AA', icon: CircleCheck },\n // Named for what it means in practice, not just for the threshold it clears.\n // WCAG's relaxed 3:1 tier applies only to text at 24px (or 18.7px bold) and\n // above, and nothing in this library is that large - `--font-size-sm` is\n // ~12.25px at the default root size. A bare \"AA large only\" reads as a pass\n // when for every component here it is a fail.\n 'aa-large': { label: 'Too low for body text', icon: TriangleAlert },\n fail: { label: 'Fails AA', icon: CircleX },\n};\n\ninterface Diagnostic {\n grade: Grade;\n ratio: number;\n /** What the ratio describes, for the tooltip. */\n detail: string;\n /** Set when the fill is too close to the page surface to be seen. */\n edgeWarning?: string;\n}\n\nconst diagnose = (\n key: ThemeColorKey,\n base: string,\n explicitContrast: string | undefined,\n scheme: ResolvedColorScheme,\n): Diagnostic => {\n const page = PAGE_SURFACE[scheme];\n if (!isFill(key)) {\n // Link text sits on the page, so the page is what it must contrast with.\n const ratio = contrastRatio(base, page);\n const grade = gradeFor(ratio);\n return {\n grade,\n ratio,\n detail: `Link text on the page background: ${ratio.toFixed(2)}:1 against the ${scheme} page.${GRADE_CAVEAT[grade] ?? ''}`,\n };\n }\n\n const foreground = explicitContrast ?? pickContrast(base);\n const ratio = contrastRatio(base, foreground);\n const name = foreground.toLowerCase() === CONTRAST_DARK ? 'dark' : 'white';\n const edge = contrastRatio(base, page);\n\n const grade = gradeFor(ratio);\n\n return {\n grade,\n ratio,\n detail: `${name === 'white' ? 'White' : 'Near-black'} text on this fill is ${ratio.toFixed(2)}:1.${\n explicitContrast ? ' Foreground pinned via the theme.' : ''\n }${GRADE_CAVEAT[grade] ?? ''}`,\n edgeWarning:\n edge < EDGE_MIN_RATIO\n ? `Only ${edge.toFixed(2)}:1 against the page background - this fill is barely distinguishable from the page it sits on.`\n : undefined,\n };\n};\n\ninterface FontRowProps {\n label: string;\n /** Stack currently applied, used to pick the matching option. */\n value: string;\n options: ThemeFontOption[];\n mono: boolean;\n allowUpload: boolean;\n onChange: (stack: string) => void;\n onUploaded: (option: ThemeFontOption, file: File, family: string) => void;\n}\n\n/** Pulls the first family out of a stack, unquoted. */\nconst firstFamily = (stack: string): string =>\n stack\n .split(',')[0]\n ?.trim()\n .replace(/^['\"]|['\"]$/g, '') || 'Custom';\n\n/**\n * One font row: a `Select` over the known stacks, an optional upload, and an\n * availability warning.\n *\n * Uses `Select` rather than `Combobox` deliberately. `Combobox` filters its\n * options against the text in the field, and the field holds a full font stack\n * (`'Plus Jakarta Sans', -apple-system, …`) which matches no option label - so\n * the list read \"No results found\" until the text was cleared by hand. A font\n * is a choice from a known set, not a search.\n */\nconst FontRow: React.FC<FontRowProps> = ({\n label,\n value,\n options,\n mono,\n allowUpload,\n onChange,\n onUploaded,\n}) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Web fonts load asynchronously, so the first render always sees them as\n // unavailable. Without re-checking once they arrive, the row would sit on a\n // stale \"not installed\" warning for a font that is rendering perfectly.\n // The reducer exists only to schedule that re-render; its value is unused.\n const [, onFontsLoaded] = useReducer((count: number) => count + 1, 0);\n useEffect(() => subscribeToFontLoads(onFontsLoaded), [onFontsLoaded]);\n\n const baseOptions = useMemo(() => {\n // A stack the theme carries but that isn't in the list (loaded by the host\n // app, or set programmatically) still needs to be selectable, labelled with\n // its own first family so the row names the font actually in use.\n const known = options.some((o) => o.value === value);\n return known ? options : [...options, { label: `${firstFamily(value)} (custom)`, value }];\n }, [options, value]);\n\n // Probed on every render rather than memoised: availability changes over time\n // as fonts load, so a cached answer is a wrong answer. Four canvas\n // measurements are far cheaper than getting this wrong.\n //\n // Availability is annotated per option rather than filtered or disabled. A\n // theme is shared across machines, so a font present here may be absent for\n // the next user - and vice versa, which would mean hiding a font someone\n // legitimately wants. Annotating keeps every choice selectable while making\n // the list stop implying that a name is a guarantee.\n const selectOptions = baseOptions.map((option) => ({\n id: option.value,\n label: isFontStackAvailable(option.value) ? option.label : `${option.label} - not installed`,\n value: option.value,\n }));\n\n const handleFile = useCallback(\n async (file: File | undefined) => {\n if (!file) return;\n setError(null);\n try {\n const family = await registerFontFile(file);\n const stack = toFontStack(family, mono);\n onUploaded({ label: `${family} (this session)`, value: stack }, file, family);\n onChange(stack);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause.message : 'That file could not be loaded as a font.',\n );\n }\n },\n [mono, onChange, onUploaded],\n );\n\n const unavailable = !isFontStackAvailable(value);\n\n return (\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">{label}</span>\n\n <div className=\"eidos-theme-editor-row__control\">\n <Select\n options={selectOptions}\n value={value}\n onChange={(next) => onChange(Array.isArray(next) ? next[0] : next)}\n fullWidth\n // The row's visible label is a `<span>`, not a `<label htmlFor>`,\n // so nothing associates it with the control. Naming the input\n // directly keeps the two in step without restructuring the row.\n inputProps={{ 'aria-label': label }}\n />\n </div>\n\n {/* Occasional - lives before the action so it can never displace it. */}\n <div className=\"eidos-theme-editor-row__diagnostics\">\n {unavailable && (\n <Tooltip\n message={`${firstFamily(value)} isn't available here, so the browser is rendering the next family in the stack instead. Upload the file, or have your app serve it, to use it.`}\n >\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--aa-large\">\n <TriangleAlert className=\"eidos-theme-editor-badge__icon\" />\n Not installed\n </span>\n </Tooltip>\n )}\n {error && (\n <Tooltip message={error}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Upload failed\n </span>\n </Tooltip>\n )}\n </div>\n\n {allowUpload && (\n <div className=\"eidos-theme-editor-row__actions\">\n <Button\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n preIcon={Upload}\n onClick={() => inputRef.current?.click()}\n tooltip=\"Load a font file to use it right away. Not saved - see onFontUpload to persist it.\"\n >\n Upload\n </Button>\n {/* Plain input rather than FileUpload: this is a single inline\n action in a dense row, not a drop zone. */}\n <input\n ref={inputRef}\n type=\"file\"\n accept={FONT_ACCEPT}\n // Same proxy pattern as `MessageComposer` - see the note there.\n className=\"eidos-theme-editor-file\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onChange={(event) => {\n void handleFile(event.target.files?.[0]);\n // Allow re-picking the same file after a failure.\n event.target.value = '';\n }}\n />\n </div>\n )}\n </div>\n );\n};\n\n/**\n * Live editor for the active `ThemeProvider` theme.\n *\n * Renders no preview of its own: the provider writes tokens to\n * `document.documentElement`, so the surrounding page is the preview.\n *\n * Contrast readouts are diagnostics only - a colour that fails is still\n * applied. Automatically \"correcting\" a chosen colour would mean silently\n * rendering something other than what was picked.\n */\nexport const ThemeEditor: React.FC<ThemeEditorProps> = ({\n colors = THEME_COLOR_KEYS as ThemeColorKey[],\n fontOptions = FONT_STACKS,\n monoFontOptions = MONO_STACKS,\n allowFontUpload = true,\n onFontUpload,\n hideTypography = false,\n hideReset = false,\n hideCssExport = false,\n className,\n}) => {\n const {\n theme,\n resolvedTheme,\n setTheme,\n updateTheme,\n resetTheme,\n isDefault,\n toCss,\n colorScheme,\n resolvedColorScheme,\n setColorScheme,\n } = useTheme();\n const [copied, setCopied] = useState(false);\n\n // Separate dark colours are opt-in: most palettes want the derived dark\n // tones, which are accessible by construction. Starts on when the theme\n // already carries dark overrides, so none are hidden from view.\n const hasDarkOverrides = Object.keys(theme.dark?.colors ?? {}).length > 0;\n const [separateDark, setSeparateDark] = useState(hasDarkOverrides);\n\n // Fonts registered through the upload control this session. Kept local\n // because font *data* cannot live in a ThemeConfig - see the .mdx.\n const [uploaded, setUploaded] = useState<ThemeFontOption[]>([]);\n const [monoUploaded, setMonoUploaded] = useState<ThemeFontOption[]>([]);\n\n const setColor = useCallback(\n (key: ThemeColorKey, hex: string) => {\n const current = theme.colors?.[key];\n // Only the base is written here. A `contrast` pinned in the theme is\n // preserved rather than dropped, since the editor never sets one.\n const pinned = typeof current === 'object' ? current.contrast : undefined;\n updateTheme({ colors: { [key]: pinned ? { base: hex, contrast: pinned } : hex } });\n },\n [theme.colors, updateTheme],\n );\n\n const resetColor = useCallback(\n (key: ThemeColorKey) => {\n // Must go through setTheme, not updateTheme: updateTheme merges, so a key\n // left out of the patch keeps its existing value instead of being removed.\n // Removal is what restores the preset, since resolveTheme fills gaps.\n const nextColors = { ...theme.colors };\n delete nextColors[key];\n setTheme({ ...theme, colors: nextColors });\n },\n [theme, setTheme],\n );\n\n const setDarkColor = useCallback(\n (key: ThemeColorKey, hex: string) => updateTheme({ dark: { colors: { [key]: hex } } }),\n [updateTheme],\n );\n\n const resetDarkColor = useCallback(\n (key: ThemeColorKey) => {\n // As `resetColor`: removing the override is what restores the derived tone.\n const nextDark = { ...theme.dark?.colors };\n delete nextDark[key];\n setTheme({ ...theme, dark: { colors: nextDark } });\n },\n [theme, setTheme],\n );\n\n const toggleSeparateDark = useCallback(\n (on: boolean) => {\n setSeparateDark(on);\n // Turning it off discards the overrides rather than hiding them: a\n // hidden override would keep changing the dark scheme with no control\n // left on screen to explain or undo it.\n if (!on && hasDarkOverrides) setTheme({ ...theme, dark: { colors: {} } });\n },\n [hasDarkOverrides, setTheme, theme],\n );\n\n // Diagnostics follow the scheme being previewed: a colour is graded against\n // the page it is actually on right now, with the foreground it actually has.\n const diagnostics = useMemo(\n () =>\n colors.map((key) => {\n const palette =\n resolvedColorScheme === 'dark' ? resolvedTheme.dark.colors : resolvedTheme.colors;\n const { base, contrast } = palette[key];\n const diagnostic = diagnose(key, base, contrast, resolvedColorScheme);\n const lightBase = resolvedTheme.colors[key].base;\n return {\n key,\n base: lightBase,\n darkBase: resolvedTheme.dark.colors[key].base,\n ...diagnostic,\n // In dark the picker still shows the colour as picked, but what is\n // graded - and rendered - is its dark tone. Name it, or the badge\n // appears to describe a colour that is not on screen.\n detail:\n resolvedColorScheme === 'dark' && base !== lightBase\n ? `In dark this renders as ${base}. ${diagnostic.detail}`\n : diagnostic.detail,\n };\n }),\n [colors, resolvedTheme, resolvedColorScheme],\n );\n\n const failing = diagnostics.filter((d) => d.grade === 'fail');\n const invisible = diagnostics.filter((d) => d.edgeWarning);\n\n const copyCss = useCallback(() => {\n const css = toCss();\n const done = () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n };\n if (navigator.clipboard?.writeText) {\n navigator.clipboard.writeText(css).then(done, done);\n return;\n }\n done();\n }, [toCss]);\n\n return (\n <div className={['eidos-theme-editor', className].filter(Boolean).join(' ')}>\n {(failing.length > 0 || invisible.length > 0) && (\n <Alert variant=\"warning\" title=\"Contrast issues\">\n {failing.length > 0 && (\n <p>\n Cannot reach WCAG AA (4.5:1) with either foreground:{' '}\n {failing.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n {invisible.length > 0 && (\n <p>\n Too close to the page background to read as a filled surface:{' '}\n {invisible.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n </Alert>\n )}\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\" id=\"eidos-theme-editor-scheme\">\n Colour scheme\n </span>\n <span className=\"eidos-theme-editor-section__hint\">\n Your colours apply to both schemes. In dark each one is lightened until it reads on the\n dark page, with dark text on it - turn on separate dark colours to pick them yourself.\n </span>\n </div>\n <div className=\"eidos-theme-editor-rows\">\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scheme</span>\n <div className=\"eidos-theme-editor-row__control\">\n <SegmentedControl\n options={SCHEME_OPTIONS}\n value={colorScheme}\n onChange={(value) => setColorScheme(value as ColorScheme)}\n aria-labelledby=\"eidos-theme-editor-scheme\"\n size=\"sm\"\n />\n </div>\n </div>\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\" />\n <div className=\"eidos-theme-editor-row__control\">\n <Switch\n label=\"Separate dark colours\"\n checked={separateDark}\n onChange={(event) => toggleSeparateDark(event.target.checked)}\n size=\"sm\"\n />\n </div>\n </div>\n </div>\n </Card>\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Colours</span>\n <span className=\"eidos-theme-editor-section__hint\">\n Shades, tints and foregrounds are derived from each base colour. Contrast is measured\n against the {resolvedColorScheme} page.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n {diagnostics.map(({ key, base, darkBase, grade, ratio, detail, edgeWarning }) => {\n const badge = GRADE_BADGE[grade];\n const overridden = theme.colors?.[key] !== undefined;\n const darkOverridden = theme.dark?.colors?.[key] !== undefined;\n return (\n <div className=\"eidos-theme-editor-row\" key={key}>\n <span className=\"eidos-theme-editor-row__label\">{COLOR_LABELS[key]}</span>\n\n {/* `md` rather than `sm`: the size drives the panel's\n saturation/brightness canvas, and 120px is cramped for\n picking a lightness precisely. */}\n <ColorPicker\n value={base}\n onChange={(hex) => setColor(key, hex)}\n size=\"md\"\n // The row draws its own visible label, so the picker must\n // not draw a second one - but without a name of its own\n // every picker here announced as \"Open colour picker\" and\n // they were indistinguishable.\n ariaLabel={COLOR_LABELS[key]}\n />\n\n {separateDark && (\n <ColorPicker\n value={darkBase}\n onChange={(hex) => setDarkColor(key, hex)}\n size=\"md\"\n ariaLabel={`${COLOR_LABELS[key]} (dark)`}\n />\n )}\n\n <div className=\"eidos-theme-editor-row__diagnostics\">\n <Tooltip message={detail}>\n <span className={`eidos-theme-editor-badge eidos-theme-editor-badge--${grade}`}>\n <badge.icon className=\"eidos-theme-editor-badge__icon\" />\n {`${ratio.toFixed(2)}:1 ${badge.label}`}\n </span>\n </Tooltip>\n {edgeWarning && (\n <Tooltip message={edgeWarning}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Invisible on page\n </span>\n </Tooltip>\n )}\n </div>\n\n <div className=\"eidos-theme-editor-row__actions\">\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!overridden}\n onClick={() => resetColor(key)}\n tooltip={overridden ? `Reset ${COLOR_LABELS[key]} to the preset` : 'Unchanged'}\n aria-label={`Reset ${COLOR_LABELS[key]}`}\n />\n {separateDark && (\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!darkOverridden}\n onClick={() => resetDarkColor(key)}\n tooltip={\n darkOverridden\n ? `Use the derived dark ${COLOR_LABELS[key]} again`\n : 'Derived from the light colour'\n }\n aria-label={`Reset dark ${COLOR_LABELS[key]}`}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n </Card>\n\n {!hideTypography && (\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Typography</span>\n <span className=\"eidos-theme-editor-section__hint\">\n A stack only names a font - upload the file to use one the browser doesn&apos;t\n already have. Spacing is declared in <code>em</code>, so the scale moves padding with\n the text.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n <FontRow\n label=\"Body font\"\n value={resolvedTheme.typography.fontFamily}\n options={[...fontOptions, ...uploaded]}\n mono={false}\n allowUpload={allowFontUpload}\n onChange={(fontFamily) => updateTheme({ typography: { fontFamily } })}\n onUploaded={(option, file, family) => {\n setUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, false);\n }}\n />\n\n <FontRow\n label=\"Mono font\"\n value={resolvedTheme.typography.monoFamily}\n options={[...monoFontOptions, ...monoUploaded]}\n mono\n allowUpload={allowFontUpload}\n onChange={(monoFamily) => updateTheme({ typography: { monoFamily } })}\n onUploaded={(option, file, family) => {\n setMonoUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, true);\n }}\n />\n\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scale</span>\n <div className=\"eidos-theme-editor-row__control\">\n <Slider\n value={resolvedTheme.typography.fontScale}\n min={FONT_SCALE_MIN}\n max={FONT_SCALE_MAX}\n step={0.025}\n showValue\n showMinMax\n unit=\"×\"\n onChange={(value) => updateTheme({ typography: { fontScale: value } })}\n />\n </div>\n </div>\n </div>\n </Card>\n )}\n\n {(!hideReset || !hideCssExport) && (\n <div className=\"eidos-theme-editor-actions\">\n {!hideReset && (\n <Button variant=\"outlined\" color=\"secondary\" disabled={isDefault} onClick={resetTheme}>\n Reset all\n </Button>\n )}\n {!hideCssExport && (\n <Button\n variant=\"outlined\"\n preIcon={copied ? Check : Clipboard}\n onClick={copyCss}\n tooltip=\"Copy the resolved tokens - light and dark - as CSS you can paste into your own stylesheet\"\n >\n {copied ? 'Copied' : 'Copy as CSS'}\n </Button>\n )}\n </div>\n )}\n </div>\n );\n};\n\nThemeEditor.displayName = 'ThemeEditor';\n"]}