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.
- package/README.md +19 -9
- package/dist/{SegmentedControl.types-D_gHYL9X.d.cts → SegmentedControl.types-50fprBiO.d.cts} +9 -0
- package/dist/{SegmentedControl.types-CHtjABQM.d.ts → SegmentedControl.types-DKlamnBZ.d.ts} +9 -0
- package/dist/{ThemeProvider.types-DgXN0gEH.d.cts → ThemeProvider.types-CI9P1anY.d.cts} +53 -2
- package/dist/{ThemeProvider.types-DgXN0gEH.d.ts → ThemeProvider.types-CI9P1anY.d.ts} +53 -2
- package/dist/{chunk-363IKX3C.js → chunk-BHZ76J2K.js} +43 -31
- package/dist/chunk-BHZ76J2K.js.map +1 -0
- package/dist/{chunk-U5KD4BWL.js → chunk-DHOBGYRD.js} +159 -29
- package/dist/chunk-DHOBGYRD.js.map +1 -0
- package/dist/{chunk-YZEALKC4.cjs → chunk-E7BFBU6K.cjs} +43 -31
- package/dist/chunk-E7BFBU6K.cjs.map +1 -0
- package/dist/{chunk-XOUNVK45.js → chunk-EJWEG66P.js} +225 -41
- package/dist/chunk-EJWEG66P.js.map +1 -0
- package/dist/{chunk-FAXDWZQH.js → chunk-FFYPSLQV.js} +2 -2
- package/dist/{chunk-PVNBH7XN.cjs → chunk-JO4NDJRA.cjs} +177 -47
- package/dist/chunk-JO4NDJRA.cjs.map +1 -0
- package/dist/{chunk-QDZVZY53.cjs → chunk-O45W57Y4.cjs} +229 -45
- package/dist/chunk-O45W57Y4.cjs.map +1 -0
- package/dist/{chunk-NYGRVB2J.cjs → chunk-VGMRIXW4.cjs} +3 -3
- package/dist/{chunk-NYGRVB2J.cjs.map → chunk-VGMRIXW4.cjs.map} +1 -1
- package/dist/data-grid/index.cjs +3 -3
- package/dist/data-grid/index.d.cts +1 -1
- package/dist/data-grid/index.d.ts +1 -1
- package/dist/data-grid/index.js +2 -2
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +345 -205
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/segmented-control/index.cjs +2 -2
- package/dist/segmented-control/index.d.cts +2 -2
- package/dist/segmented-control/index.d.ts +2 -2
- package/dist/segmented-control/index.js +1 -1
- package/dist/theme-editor/index.cjs +5 -3
- package/dist/theme-editor/index.cjs.map +1 -1
- package/dist/theme-editor/index.d.cts +1 -1
- package/dist/theme-editor/index.d.ts +1 -1
- package/dist/theme-editor/index.js +4 -2
- package/dist/theme-provider/index.cjs +2 -2
- package/dist/theme-provider/index.d.cts +2 -2
- package/dist/theme-provider/index.d.ts +2 -2
- package/dist/theme-provider/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-363IKX3C.js.map +0 -1
- package/dist/chunk-PVNBH7XN.cjs.map +0 -1
- package/dist/chunk-QDZVZY53.cjs.map +0 -1
- package/dist/chunk-U5KD4BWL.js.map +0 -1
- package/dist/chunk-XOUNVK45.js.map +0 -1
- package/dist/chunk-YZEALKC4.cjs.map +0 -1
- /package/dist/{chunk-FAXDWZQH.js.map → chunk-FFYPSLQV.js.map} +0 -0
|
@@ -3,7 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-PP6HS4GR.js";
|
|
4
4
|
|
|
5
5
|
// src/components/ThemeProvider/ThemeProvider.component.tsx
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useCallback,
|
|
8
|
+
useEffect,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
useSyncExternalStore
|
|
14
|
+
} from "react";
|
|
7
15
|
|
|
8
16
|
// src/components/ThemeProvider/ThemeProvider.context.tsx
|
|
9
17
|
import { createContext, useContext } from "react";
|
|
@@ -176,6 +184,52 @@ var isRampViable = (base) => {
|
|
|
176
184
|
const { l } = hexToOklch(base);
|
|
177
185
|
return l < 0.95 && l > 0.12;
|
|
178
186
|
};
|
|
187
|
+
var DARK_SURFACE = "#0f172a";
|
|
188
|
+
var DARK_SURFACE_RAISED = "#1e293b";
|
|
189
|
+
var DARK_BASE_MIN_CONTRAST = 5;
|
|
190
|
+
var deriveDarkBase = (base) => {
|
|
191
|
+
const reaches = (hex) => contrastRatio(hex, DARK_SURFACE) >= DARK_BASE_MIN_CONTRAST && contrastRatio(hex, DARK_SURFACE_RAISED) >= DARK_BASE_MIN_CONTRAST;
|
|
192
|
+
if (reaches(base)) return base;
|
|
193
|
+
const start = hexToOklch(base);
|
|
194
|
+
for (let l = start.l; l <= 1; l += 5e-3) {
|
|
195
|
+
const candidate = oklchToHex({ ...start, l });
|
|
196
|
+
if (reaches(candidate)) return candidate;
|
|
197
|
+
}
|
|
198
|
+
return "#ffffff";
|
|
199
|
+
};
|
|
200
|
+
var DARK_HOVER_DELTA = 0.07;
|
|
201
|
+
var DARK_LIGHT_DELTA = 0.35;
|
|
202
|
+
var deriveDarkHover = (darkBase) => {
|
|
203
|
+
const { l, c, h } = hexToOklch(darkBase);
|
|
204
|
+
return oklchToHex({ l: Math.min(LIGHT_CEILING, l + DARK_HOVER_DELTA), c, h });
|
|
205
|
+
};
|
|
206
|
+
var deriveDarkLight = (darkBase) => {
|
|
207
|
+
const { l, c, h } = hexToOklch(darkBase);
|
|
208
|
+
return oklchToHex({ l: Math.max(0.2, l - DARK_LIGHT_DELTA), c, h });
|
|
209
|
+
};
|
|
210
|
+
var DARK_RAMP_CURVE = {
|
|
211
|
+
50: { l: 0.235, chroma: 0.35 },
|
|
212
|
+
100: { l: 0.27, chroma: 0.45 },
|
|
213
|
+
200: { l: 0.33, chroma: 0.6 },
|
|
214
|
+
300: { l: 0.42, chroma: 0.8 },
|
|
215
|
+
400: { l: 0.55, chroma: 0.95 },
|
|
216
|
+
600: { l: 0.76, chroma: 0.8 },
|
|
217
|
+
700: { l: 0.83, chroma: 0.6 },
|
|
218
|
+
800: { l: 0.89, chroma: 0.4 },
|
|
219
|
+
900: { l: 0.945, chroma: 0.2 }
|
|
220
|
+
};
|
|
221
|
+
var buildDarkRamp = (darkBase) => {
|
|
222
|
+
const { c, h } = hexToOklch(darkBase);
|
|
223
|
+
const out = {};
|
|
224
|
+
for (const step of RAMP_STEPS) {
|
|
225
|
+
out[step] = step === BASE_STEP ? darkBase : oklchToHex({
|
|
226
|
+
l: DARK_RAMP_CURVE[step].l,
|
|
227
|
+
c: c * DARK_RAMP_CURVE[step].chroma,
|
|
228
|
+
h
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
};
|
|
179
233
|
|
|
180
234
|
// src/components/ThemeProvider/ThemeProvider.tokens.ts
|
|
181
235
|
var THEME_COLOR_KEYS = [
|
|
@@ -220,7 +274,10 @@ var defaultTheme = {
|
|
|
220
274
|
fontFamily: "'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
221
275
|
monoFamily: "'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace",
|
|
222
276
|
fontScale: 1
|
|
223
|
-
}
|
|
277
|
+
},
|
|
278
|
+
// Empty on purpose: the preset's dark colours are *derived* from `colors`
|
|
279
|
+
// (see `_color-schemes.scss`), exactly as a consumer's are.
|
|
280
|
+
dark: {}
|
|
224
281
|
};
|
|
225
282
|
var DEFAULT_PRIMARY_RAMP = {
|
|
226
283
|
50: "#eef2ff",
|
|
@@ -237,33 +294,46 @@ var DEFAULT_PRIMARY_RAMP = {
|
|
|
237
294
|
var FONT_SCALE_MIN = 0.875;
|
|
238
295
|
var FONT_SCALE_MAX = 1.25;
|
|
239
296
|
var normalizeColor = (value) => typeof value === "string" ? { base: value } : value;
|
|
297
|
+
var resolveColor = (supplied, path) => {
|
|
298
|
+
if (supplied === void 0) return void 0;
|
|
299
|
+
const { base, contrast } = normalizeColor(supplied);
|
|
300
|
+
if (!isValidHex(base)) {
|
|
301
|
+
devWarn(
|
|
302
|
+
`theme-color-${path}`,
|
|
303
|
+
`ThemeProvider: ${path} is not a valid hex colour (received ${JSON.stringify(base)}). Falling back to the preset.`
|
|
304
|
+
);
|
|
305
|
+
return void 0;
|
|
306
|
+
}
|
|
307
|
+
if (contrast !== void 0 && !isValidHex(contrast)) {
|
|
308
|
+
devWarn(
|
|
309
|
+
`theme-contrast-${path}`,
|
|
310
|
+
`ThemeProvider: ${path}.contrast is not a valid hex colour (received ${JSON.stringify(contrast)}). It will be computed instead.`
|
|
311
|
+
);
|
|
312
|
+
return { base };
|
|
313
|
+
}
|
|
314
|
+
return contrast === void 0 ? { base } : { base, contrast };
|
|
315
|
+
};
|
|
240
316
|
var resolveTheme = (theme) => {
|
|
241
317
|
const colors = {};
|
|
318
|
+
const darkColors = {};
|
|
242
319
|
for (const key of THEME_COLOR_KEYS) {
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const { base, contrast } = normalizeColor(supplied);
|
|
250
|
-
if (!isValidHex(base)) {
|
|
251
|
-
devWarn(
|
|
252
|
-
`theme-color-${key}`,
|
|
253
|
-
`ThemeProvider: colors.${key} is not a valid hex colour (received ${JSON.stringify(base)}). Falling back to the preset.`
|
|
320
|
+
colors[key] = resolveColor(theme.colors?.[key], `colors.${key}`) ?? normalizeColor(defaultTheme.colors[key]);
|
|
321
|
+
const explicitDark = resolveColor(theme.dark?.colors?.[key], `dark.colors.${key}`);
|
|
322
|
+
if (explicitDark) {
|
|
323
|
+
const worst = Math.min(
|
|
324
|
+
contrastRatio(explicitDark.base, DARK_SURFACE),
|
|
325
|
+
contrastRatio(explicitDark.base, DARK_SURFACE_RAISED)
|
|
254
326
|
);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
continue;
|
|
327
|
+
if (worst < 4.5) {
|
|
328
|
+
devWarn(
|
|
329
|
+
`theme-dark-contrast-${key}`,
|
|
330
|
+
`ThemeProvider: dark.colors.${key} (${explicitDark.base}) is ${worst.toFixed(2)}:1 against the dark surfaces, below the 4.5:1 text needs. It is used as given, but text in it will fail WCAG AA in the dark scheme - omit it to have a compliant tone derived from colors.${key}.`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
darkColors[key] = explicitDark;
|
|
334
|
+
} else {
|
|
335
|
+
darkColors[key] = { base: deriveDarkBase(colors[key].base) };
|
|
265
336
|
}
|
|
266
|
-
colors[key] = contrast === void 0 ? { base } : { base, contrast };
|
|
267
337
|
}
|
|
268
338
|
const scale = theme.typography?.fontScale;
|
|
269
339
|
let fontScale = defaultTheme.typography.fontScale;
|
|
@@ -283,10 +353,12 @@ var resolveTheme = (theme) => {
|
|
|
283
353
|
fontFamily: theme.typography?.fontFamily || defaultTheme.typography.fontFamily,
|
|
284
354
|
monoFamily: theme.typography?.monoFamily || defaultTheme.typography.monoFamily,
|
|
285
355
|
fontScale
|
|
286
|
-
}
|
|
356
|
+
},
|
|
357
|
+
dark: { colors: darkColors }
|
|
287
358
|
};
|
|
288
359
|
};
|
|
289
|
-
var buildTokens = (resolved) => {
|
|
360
|
+
var buildTokens = (resolved, scheme = "light") => {
|
|
361
|
+
if (scheme === "dark") return buildDarkTokens(resolved);
|
|
290
362
|
const tokens = {};
|
|
291
363
|
for (const key of THEME_COLOR_KEYS) {
|
|
292
364
|
const { base, contrast } = resolved.colors[key];
|
|
@@ -311,6 +383,11 @@ var buildTokens = (resolved) => {
|
|
|
311
383
|
}
|
|
312
384
|
}
|
|
313
385
|
}
|
|
386
|
+
Object.assign(tokens, typographyTokens(resolved));
|
|
387
|
+
return tokens;
|
|
388
|
+
};
|
|
389
|
+
var typographyTokens = (resolved) => {
|
|
390
|
+
const tokens = {};
|
|
314
391
|
const { fontFamily, monoFamily, fontScale } = resolved.typography;
|
|
315
392
|
tokens["--font-family-primary"] = fontFamily;
|
|
316
393
|
tokens["--font-family-mono"] = monoFamily;
|
|
@@ -319,35 +396,84 @@ var buildTokens = (resolved) => {
|
|
|
319
396
|
}
|
|
320
397
|
return tokens;
|
|
321
398
|
};
|
|
322
|
-
var
|
|
323
|
-
|
|
399
|
+
var buildDarkTokens = (resolved) => {
|
|
400
|
+
const tokens = {};
|
|
401
|
+
for (const key of THEME_COLOR_KEYS) {
|
|
402
|
+
const { base, contrast } = resolved.dark.colors[key];
|
|
403
|
+
tokens[`--${key}-color`] = base;
|
|
404
|
+
tokens[`--${key}-rgb`] = hexToRgbTriple(base);
|
|
405
|
+
tokens[`--${key}-dark`] = deriveDarkHover(base);
|
|
406
|
+
tokens[`--${key}-light`] = deriveDarkLight(base);
|
|
407
|
+
if (FILL_COLOR_KEYS.includes(key)) {
|
|
408
|
+
tokens[`--${key}-contrast`] = contrast ?? pickContrast(base);
|
|
409
|
+
}
|
|
410
|
+
if (key === RAMP_COLOR_KEY) {
|
|
411
|
+
const ramp = buildDarkRamp(base);
|
|
412
|
+
for (const step of RAMP_STEPS) tokens[`--${key}-${step}`] = ramp[step];
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
Object.assign(tokens, typographyTokens(resolved));
|
|
416
|
+
return tokens;
|
|
417
|
+
};
|
|
418
|
+
var DEFAULT_TOKENS = {
|
|
419
|
+
light: buildTokens(resolveTheme(defaultTheme), "light"),
|
|
420
|
+
dark: buildTokens(resolveTheme(defaultTheme), "dark")
|
|
421
|
+
};
|
|
422
|
+
var diffFromDefault = (tokens, scheme = "light") => {
|
|
324
423
|
const diff = {};
|
|
325
424
|
for (const [name, value] of Object.entries(tokens)) {
|
|
326
|
-
if (DEFAULT_TOKENS[name] !== value) diff[name] = value;
|
|
425
|
+
if (DEFAULT_TOKENS[scheme][name] !== value) diff[name] = value;
|
|
327
426
|
}
|
|
328
427
|
return diff;
|
|
329
428
|
};
|
|
429
|
+
var block = (selector, tokens, indent = "") => `${indent}${selector} {
|
|
430
|
+
` + Object.entries(tokens).map(([name, value]) => `${indent} ${name}: ${value};`).join("\n") + `
|
|
431
|
+
${indent}}`;
|
|
330
432
|
var themeToCss = (resolved) => {
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
433
|
+
const light = buildTokens(resolved, "light");
|
|
434
|
+
const dark = Object.fromEntries(
|
|
435
|
+
Object.entries(buildTokens(resolved, "dark")).filter(([name]) => !name.startsWith("--font-"))
|
|
436
|
+
);
|
|
437
|
+
return [
|
|
438
|
+
block(":root", light),
|
|
439
|
+
block(":root[data-color-scheme='dark']", dark),
|
|
440
|
+
`@media (prefers-color-scheme: dark) {
|
|
441
|
+
${block(":root[data-color-scheme='system']", dark, " ")}
|
|
442
|
+
}`
|
|
443
|
+
].join("\n\n");
|
|
336
444
|
};
|
|
337
445
|
|
|
338
446
|
// src/components/ThemeProvider/ThemeProvider.component.tsx
|
|
339
447
|
import { jsx } from "react/jsx-runtime";
|
|
448
|
+
var SCHEME_ATTRIBUTE = "data-color-scheme";
|
|
449
|
+
var isColorScheme = (value) => value === "light" || value === "dark" || value === "system";
|
|
450
|
+
var readPageScheme = () => {
|
|
451
|
+
const value = document.documentElement.getAttribute(SCHEME_ATTRIBUTE);
|
|
452
|
+
return isColorScheme(value) ? value : "light";
|
|
453
|
+
};
|
|
454
|
+
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
455
|
+
var subscribeToPrefersDark = (onChange) => {
|
|
456
|
+
const query = window.matchMedia?.(DARK_QUERY);
|
|
457
|
+
query?.addEventListener("change", onChange);
|
|
458
|
+
return () => query?.removeEventListener("change", onChange);
|
|
459
|
+
};
|
|
460
|
+
var getPrefersDark = () => window.matchMedia?.(DARK_QUERY).matches ?? false;
|
|
461
|
+
var getServerPrefersDark = () => false;
|
|
340
462
|
var EMPTY_THEME = {};
|
|
341
463
|
var mountedProviders = 0;
|
|
342
464
|
var mergeTheme = (base, patch) => ({
|
|
343
465
|
colors: { ...base.colors, ...patch.colors },
|
|
344
|
-
typography: { ...base.typography, ...patch.typography }
|
|
466
|
+
typography: { ...base.typography, ...patch.typography },
|
|
467
|
+
dark: { colors: { ...base.dark?.colors, ...patch.dark?.colors } }
|
|
345
468
|
});
|
|
346
469
|
var ThemeProvider = ({
|
|
347
470
|
children,
|
|
348
471
|
theme: controlledTheme,
|
|
349
472
|
defaultTheme: initialTheme,
|
|
350
|
-
onThemeChange
|
|
473
|
+
onThemeChange,
|
|
474
|
+
colorScheme: controlledScheme,
|
|
475
|
+
defaultColorScheme,
|
|
476
|
+
onColorSchemeChange
|
|
351
477
|
}) => {
|
|
352
478
|
const isControlled = controlledTheme !== void 0;
|
|
353
479
|
const [uncontrolledTheme, setUncontrolledTheme] = useState(
|
|
@@ -366,8 +492,51 @@ var ThemeProvider = ({
|
|
|
366
492
|
mountedProviders -= 1;
|
|
367
493
|
};
|
|
368
494
|
}, []);
|
|
495
|
+
const [uncontrolledScheme, setUncontrolledScheme] = useState(
|
|
496
|
+
defaultColorScheme
|
|
497
|
+
);
|
|
498
|
+
const managedScheme = controlledScheme ?? uncontrolledScheme;
|
|
499
|
+
const [pageScheme, setPageScheme] = useState("light");
|
|
500
|
+
useLayoutEffect(() => {
|
|
501
|
+
if (managedScheme !== void 0) return;
|
|
502
|
+
setPageScheme(readPageScheme());
|
|
503
|
+
const observer = new MutationObserver(() => setPageScheme(readPageScheme()));
|
|
504
|
+
observer.observe(document.documentElement, { attributeFilter: [SCHEME_ATTRIBUTE] });
|
|
505
|
+
return () => observer.disconnect();
|
|
506
|
+
}, [managedScheme]);
|
|
507
|
+
useLayoutEffect(() => {
|
|
508
|
+
if (managedScheme === void 0) return;
|
|
509
|
+
const root = document.documentElement;
|
|
510
|
+
const previous = root.getAttribute(SCHEME_ATTRIBUTE);
|
|
511
|
+
root.setAttribute(SCHEME_ATTRIBUTE, managedScheme);
|
|
512
|
+
return () => {
|
|
513
|
+
if (previous === null) root.removeAttribute(SCHEME_ATTRIBUTE);
|
|
514
|
+
else root.setAttribute(SCHEME_ATTRIBUTE, previous);
|
|
515
|
+
};
|
|
516
|
+
}, [managedScheme]);
|
|
517
|
+
const colorScheme = managedScheme ?? pageScheme;
|
|
518
|
+
const prefersDark = useSyncExternalStore(
|
|
519
|
+
subscribeToPrefersDark,
|
|
520
|
+
getPrefersDark,
|
|
521
|
+
getServerPrefersDark
|
|
522
|
+
);
|
|
523
|
+
const resolvedColorScheme = colorScheme === "system" ? prefersDark ? "dark" : "light" : colorScheme;
|
|
524
|
+
const setColorScheme = useCallback(
|
|
525
|
+
(next) => {
|
|
526
|
+
if (controlledScheme === void 0) setUncontrolledScheme(next);
|
|
527
|
+
onColorSchemeChange?.(next);
|
|
528
|
+
},
|
|
529
|
+
[controlledScheme, onColorSchemeChange]
|
|
530
|
+
);
|
|
369
531
|
const resolvedTheme = useMemo(() => resolveTheme(theme), [theme]);
|
|
370
|
-
const tokens = useMemo(
|
|
532
|
+
const tokens = useMemo(
|
|
533
|
+
() => diffFromDefault(buildTokens(resolvedTheme, resolvedColorScheme), resolvedColorScheme),
|
|
534
|
+
[resolvedTheme, resolvedColorScheme]
|
|
535
|
+
);
|
|
536
|
+
const isDefault = useMemo(
|
|
537
|
+
() => Object.keys(diffFromDefault(buildTokens(resolvedTheme, "light"), "light")).length === 0 && Object.keys(diffFromDefault(buildTokens(resolvedTheme, "dark"), "dark")).length === 0,
|
|
538
|
+
[resolvedTheme]
|
|
539
|
+
);
|
|
371
540
|
const appliedRef = useRef([]);
|
|
372
541
|
useLayoutEffect(() => {
|
|
373
542
|
if (typeof document === "undefined") return;
|
|
@@ -407,10 +576,24 @@ var ThemeProvider = ({
|
|
|
407
576
|
setTheme,
|
|
408
577
|
updateTheme,
|
|
409
578
|
resetTheme,
|
|
410
|
-
isDefault
|
|
411
|
-
toCss
|
|
579
|
+
isDefault,
|
|
580
|
+
toCss,
|
|
581
|
+
colorScheme,
|
|
582
|
+
resolvedColorScheme,
|
|
583
|
+
setColorScheme
|
|
412
584
|
}),
|
|
413
|
-
[
|
|
585
|
+
[
|
|
586
|
+
theme,
|
|
587
|
+
resolvedTheme,
|
|
588
|
+
setTheme,
|
|
589
|
+
updateTheme,
|
|
590
|
+
resetTheme,
|
|
591
|
+
isDefault,
|
|
592
|
+
toCss,
|
|
593
|
+
colorScheme,
|
|
594
|
+
resolvedColorScheme,
|
|
595
|
+
setColorScheme
|
|
596
|
+
]
|
|
414
597
|
);
|
|
415
598
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
416
599
|
};
|
|
@@ -507,6 +690,7 @@ export {
|
|
|
507
690
|
CONTRAST_LIGHT,
|
|
508
691
|
CONTRAST_DARK,
|
|
509
692
|
pickContrast,
|
|
693
|
+
DARK_SURFACE,
|
|
510
694
|
THEME_COLOR_KEYS,
|
|
511
695
|
defaultTheme,
|
|
512
696
|
FONT_SCALE_MIN,
|
|
@@ -521,4 +705,4 @@ export {
|
|
|
521
705
|
isFontAvailable,
|
|
522
706
|
isFontStackAvailable
|
|
523
707
|
};
|
|
524
|
-
//# sourceMappingURL=chunk-
|
|
708
|
+
//# sourceMappingURL=chunk-EJWEG66P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ThemeProvider/ThemeProvider.component.tsx","../src/components/ThemeProvider/ThemeProvider.context.tsx","../src/components/ThemeProvider/ThemeProvider.color.ts","../src/components/ThemeProvider/ThemeProvider.tokens.ts","../src/components/ThemeProvider/ThemeProvider.fonts.ts"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { devWarn } from '../../utils';\nimport { ThemeContext } from './ThemeProvider.context';\nimport { buildTokens, diffFromDefault, resolveTheme, themeToCss } from './ThemeProvider.tokens';\nimport type {\n ColorScheme,\n ResolvedColorScheme,\n ThemeConfig,\n ThemeContextValue,\n ThemeProviderProps,\n} from './ThemeProvider.types';\n\n/** The attribute `dist/index.css` keys the dark and `system` schemes on. */\nconst SCHEME_ATTRIBUTE = 'data-color-scheme';\n\nconst isColorScheme = (value: string | null): value is ColorScheme =>\n value === 'light' || value === 'dark' || value === 'system';\n\n/** The scheme the page itself declares, for a provider not managing it. */\nconst readPageScheme = (): ColorScheme => {\n const value = document.documentElement.getAttribute(SCHEME_ATTRIBUTE);\n return isColorScheme(value) ? value : 'light';\n};\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\nconst subscribeToPrefersDark = (onChange: () => void) => {\n const query = window.matchMedia?.(DARK_QUERY);\n query?.addEventListener('change', onChange);\n return () => query?.removeEventListener('change', onChange);\n};\nconst getPrefersDark = () => window.matchMedia?.(DARK_QUERY).matches ?? false;\n// The server cannot know; `light` matches what `dist/index.css` renders for a\n// page without the attribute, so hydration agrees.\nconst getServerPrefersDark = () => false;\n\nconst EMPTY_THEME: ThemeConfig = {};\n\n/**\n * Number of providers currently mounted.\n *\n * Because tokens are written to `document.documentElement` (see the component\n * comment for why), providers do not compose: two of them target the same\n * element, so whichever applied a given token last wins for the entire page -\n * including for the subtree of the other one. That looks like a broken theme\n * rather than a misuse, so it is worth saying out loud.\n */\nlet mountedProviders = 0;\n\n/** Merges `patch` over `base` one level into `colors`/`typography`. */\nconst mergeTheme = (base: ThemeConfig, patch: ThemeConfig): ThemeConfig => ({\n colors: { ...base.colors, ...patch.colors },\n typography: { ...base.typography, ...patch.typography },\n dark: { colors: { ...base.dark?.colors, ...patch.dark?.colors } },\n});\n\n/**\n * Applies a theme by writing CSS custom properties to `document.documentElement`.\n *\n * Two deliberate choices worth knowing:\n *\n * **The target is `documentElement`, not a wrapper element.** Every overlay in\n * this library (`Dropdown`, `Modal`, `Drawer`, `Snackbar`, `Tooltip`, …) portals\n * to `document.body`, so tokens scoped to a wrapper `<div>` would leave every\n * popup rendering the preset instead.\n *\n * **Properties are set through the CSSOM** (`style.setProperty`), which no CSP\n * directive gates - `style-src` and `style-src-attr` only cover the `style`\n * HTML attribute and stylesheet loads. Nothing here needs a nonce, and no\n * `<style>` element is ever created. See `ContentSecurityPolicy.mdx`.\n *\n * Under SSR the server sends the preset from `dist/index.css` and the theme is\n * applied on hydration; use `toCss()` if you need a themed first paint.\n */\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n children,\n theme: controlledTheme,\n defaultTheme: initialTheme,\n onThemeChange,\n colorScheme: controlledScheme,\n defaultColorScheme,\n onColorSchemeChange,\n}) => {\n const isControlled = controlledTheme !== undefined;\n const [uncontrolledTheme, setUncontrolledTheme] = useState<ThemeConfig>(\n initialTheme ?? EMPTY_THEME,\n );\n const theme = isControlled ? controlledTheme : uncontrolledTheme;\n\n useEffect(() => {\n mountedProviders += 1;\n if (mountedProviders > 1) {\n devWarn(\n 'theme-multiple-providers',\n `ThemeProvider: ${mountedProviders} providers are mounted at once. They all write to document.documentElement, so the last one to apply each token wins for the whole page - nested or sibling providers cannot theme separate subtrees. Use a single provider at your app root.`,\n );\n }\n return () => {\n mountedProviders -= 1;\n };\n }, []);\n\n // ── Colour scheme ─────────────────────────────────────────────────────────\n //\n // \"Managed\" once a scheme has been given - by prop, by default, or through\n // `setColorScheme`. Until then the provider never touches the attribute: an\n // app that server-renders `data-color-scheme` to avoid a flash of the wrong\n // scheme must not have it overwritten by a client default. An unmanaged\n // provider follows whatever the page declares instead.\n const [uncontrolledScheme, setUncontrolledScheme] = useState<ColorScheme | undefined>(\n defaultColorScheme,\n );\n const managedScheme = controlledScheme ?? uncontrolledScheme;\n\n const [pageScheme, setPageScheme] = useState<ColorScheme>('light');\n useLayoutEffect(() => {\n if (managedScheme !== undefined) return;\n setPageScheme(readPageScheme());\n // The app owns the attribute in this mode and may change it at any time.\n const observer = new MutationObserver(() => setPageScheme(readPageScheme()));\n observer.observe(document.documentElement, { attributeFilter: [SCHEME_ATTRIBUTE] });\n return () => observer.disconnect();\n }, [managedScheme]);\n\n useLayoutEffect(() => {\n if (managedScheme === undefined) return;\n const root = document.documentElement;\n const previous = root.getAttribute(SCHEME_ATTRIBUTE);\n root.setAttribute(SCHEME_ATTRIBUTE, managedScheme);\n return () => {\n if (previous === null) root.removeAttribute(SCHEME_ATTRIBUTE);\n else root.setAttribute(SCHEME_ATTRIBUTE, previous);\n };\n }, [managedScheme]);\n\n const colorScheme = managedScheme ?? pageScheme;\n const prefersDark = useSyncExternalStore(\n subscribeToPrefersDark,\n getPrefersDark,\n getServerPrefersDark,\n );\n const resolvedColorScheme: ResolvedColorScheme =\n colorScheme === 'system' ? (prefersDark ? 'dark' : 'light') : colorScheme;\n\n const setColorScheme = useCallback(\n (next: ColorScheme) => {\n if (controlledScheme === undefined) setUncontrolledScheme(next);\n onColorSchemeChange?.(next);\n },\n [controlledScheme, onColorSchemeChange],\n );\n\n // ── Tokens ────────────────────────────────────────────────────────────────\n //\n // Written for the scheme *in effect*. They are inline styles on `<html>`,\n // which outrank every stylesheet rule - including the dark and `system`\n // blocks in `dist/index.css` - so a custom colour written for light would\n // pin the light value in dark mode. Hence the scheme-aware build, and the\n // diff against the same scheme's preset: an unthemed provider still writes\n // nothing, in either scheme.\n const resolvedTheme = useMemo(() => resolveTheme(theme), [theme]);\n const tokens = useMemo(\n () => diffFromDefault(buildTokens(resolvedTheme, resolvedColorScheme), resolvedColorScheme),\n [resolvedTheme, resolvedColorScheme],\n );\n const isDefault = useMemo(\n () =>\n Object.keys(diffFromDefault(buildTokens(resolvedTheme, 'light'), 'light')).length === 0 &&\n Object.keys(diffFromDefault(buildTokens(resolvedTheme, 'dark'), 'dark')).length === 0,\n [resolvedTheme],\n );\n\n // Names written on the previous pass, so properties dropped from the theme\n // are removed rather than left behind at their last value.\n const appliedRef = useRef<string[]>([]);\n\n useLayoutEffect(() => {\n if (typeof document === 'undefined') return;\n const root = document.documentElement;\n\n for (const name of appliedRef.current) {\n if (!(name in tokens)) root.style.removeProperty(name);\n }\n for (const [name, value] of Object.entries(tokens)) {\n root.style.setProperty(name, value);\n }\n appliedRef.current = Object.keys(tokens);\n\n return () => {\n for (const name of appliedRef.current) {\n root.style.removeProperty(name);\n }\n appliedRef.current = [];\n };\n }, [tokens]);\n\n const commit = useCallback(\n (next: ThemeConfig) => {\n if (!isControlled) setUncontrolledTheme(next);\n onThemeChange?.(next);\n },\n [isControlled, onThemeChange],\n );\n\n const setTheme = useCallback((next: ThemeConfig) => commit(next), [commit]);\n\n const updateTheme = useCallback(\n (patch: ThemeConfig) => commit(mergeTheme(theme, patch)),\n [commit, theme],\n );\n\n const resetTheme = useCallback(() => commit(EMPTY_THEME), [commit]);\n\n const toCss = useCallback(() => themeToCss(resolvedTheme), [resolvedTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({\n theme,\n resolvedTheme,\n setTheme,\n updateTheme,\n resetTheme,\n isDefault,\n toCss,\n colorScheme,\n resolvedColorScheme,\n setColorScheme,\n }),\n [\n theme,\n resolvedTheme,\n setTheme,\n updateTheme,\n resetTheme,\n isDefault,\n toCss,\n colorScheme,\n resolvedColorScheme,\n setColorScheme,\n ],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n};\n\nThemeProvider.displayName = 'ThemeProvider';\n","import { createContext, useContext } from 'react';\nimport type { ThemeContextValue } from './ThemeProvider.types';\n\nexport const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\n/**\n * Reads the active theme. Throws outside a `ThemeProvider`, matching\n * `useSnackbarContext` - a silent fallback would make a missing provider look\n * like a theme that simply is not applying.\n */\nexport const useTheme = (): ThemeContextValue => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n};\n","/**\n * Colour maths for the theme system.\n *\n * All conversions are done in JS and emitted as `#rrggbb`, so browser support\n * for `oklch()` is irrelevant here - nothing in the generated CSS uses a modern\n * colour function.\n *\n * OKLab is used rather than HSL for every interpolation. HSL lightness\n * interpolation is ~40 lines shorter but produces muddy, desaturated ramps for\n * exactly the saturated brand hues this feature exists to support, because its\n * \"lightness\" is not perceptual.\n */\n\n// ============================================================================\n// sRGB <-> OKLab\n// ============================================================================\n\nexport interface Oklch {\n /** Perceptual lightness, 0-1. */\n l: number;\n /** Chroma (colourfulness), 0 to ~0.4 in sRGB. */\n c: number;\n /** Hue angle in radians. */\n h: number;\n}\n\nconst srgbToLinear = (v: number): number =>\n v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n\nconst linearToSrgb = (v: number): number =>\n v <= 0.0031308 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;\n\nconst clamp01 = (v: number): number => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/** Parses `#rgb` / `#rrggbb` into 0-1 sRGB channels. Returns null if unparseable. */\nexport const parseHex = (hex: string): [number, number, number] | null => {\n if (typeof hex !== 'string') return null;\n const raw = hex.trim().replace(/^#/, '');\n const full =\n raw.length === 3\n ? raw\n .split('')\n .map((c) => c + c)\n .join('')\n : raw;\n if (!/^[0-9a-fA-F]{6}$/.test(full)) return null;\n const n = parseInt(full, 16);\n return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];\n};\n\nexport const isValidHex = (hex: string): boolean => parseHex(hex) !== null;\n\nconst toHex = ([r, g, b]: [number, number, number]): string =>\n '#' +\n [r, g, b]\n .map((v) =>\n Math.round(clamp01(v) * 255)\n .toString(16)\n .padStart(2, '0'),\n )\n .join('');\n\n/** `#rrggbb` -> the comma-separated triple the `--x-rgb` tokens use. */\nexport const hexToRgbTriple = (hex: string): string => {\n const rgb = parseHex(hex);\n if (!rgb) return '0, 0, 0';\n return rgb.map((v) => Math.round(v * 255)).join(', ');\n};\n\nconst linearToOklab = ([r, g, b]: [number, number, number]): [number, number, number] => {\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ];\n};\n\nconst oklabToLinear = ([L, A, B]: [number, number, number]): [number, number, number] => {\n const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;\n const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;\n const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ];\n};\n\nexport const hexToOklch = (hex: string): Oklch => {\n const rgb = parseHex(hex) ?? [0, 0, 0];\n const [l, a, b] = linearToOklab(rgb.map(srgbToLinear) as [number, number, number]);\n return { l, c: Math.hypot(a, b), h: Math.atan2(b, a) };\n};\n\nconst inGamut = ([r, g, b]: [number, number, number]): boolean =>\n [r, g, b].every((v) => v >= -1e-4 && v <= 1 + 1e-4);\n\n/**\n * Largest chroma that still fits in sRGB at this lightness and hue.\n *\n * Needed because OKLab is a much larger space than sRGB: naively keeping a\n * colour's chroma while changing its lightness frequently lands outside the\n * gamut, where channels clip and the hue visibly shifts.\n */\nconst maxChroma = (l: number, h: number): number => {\n let lo = 0;\n let hi = 0.45;\n for (let i = 0; i < 24; i++) {\n const mid = (lo + hi) / 2;\n if (inGamut(oklabToLinear([l, mid * Math.cos(h), mid * Math.sin(h)]))) lo = mid;\n else hi = mid;\n }\n return lo;\n};\n\nexport const oklchToHex = ({ l, c, h }: Oklch): string => {\n const lc = clamp01(l);\n const cc = Math.min(Math.max(c, 0), maxChroma(lc, h));\n return toHex(\n oklabToLinear([lc, cc * Math.cos(h), cc * Math.sin(h)]).map(linearToSrgb) as [\n number,\n number,\n number,\n ],\n );\n};\n\n// ============================================================================\n// WCAG 2.1 contrast\n// ============================================================================\n\n/**\n * WCAG 2.1 is used rather than APCA. APCA models perception better but is\n * still a draft (targeted at WCAG 3), while WCAG 2 is what consumers are\n * actually audited against. Its known weakness - mis-ranking some mid-tone\n * blues and greens - is accepted for that reason.\n */\nexport const relativeLuminance = (hex: string): number => {\n const [r, g, b] = (parseHex(hex) ?? [0, 0, 0]).map(srgbToLinear);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\n/** Contrast ratio between two colours, 1 (identical) to 21 (black on white). */\nexport const contrastRatio = (a: string, b: string): number => {\n const [x, y] = [relativeLuminance(a), relativeLuminance(b)];\n return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);\n};\n\n/** The two foreground candidates, matching `--white` and `--gray-900`. */\nexport const CONTRAST_LIGHT = '#ffffff';\nexport const CONTRAST_DARK = '#0f172a';\n\n/**\n * Foreground to place on `fill`.\n *\n * White wins unless it drops below 3:1, at which point the better of the two\n * candidates is used. The threshold is deliberately 3:1 rather than \"whichever\n * scores higher\": on mid-tone reds the dark candidate often scores marginally\n * better while looking plainly wrong, and every preset base clears 4.5:1\n * against white anyway.\n */\nexport const pickContrast = (fill: string): string => {\n const onLight = contrastRatio(fill, CONTRAST_LIGHT);\n if (onLight >= 3) return CONTRAST_LIGHT;\n return onLight >= contrastRatio(fill, CONTRAST_DARK) ? CONTRAST_LIGHT : CONTRAST_DARK;\n};\n\n// ============================================================================\n// Ramp generation\n// ============================================================================\n\n/** The ramp steps, in the order `--x-50` … `--x-900` are declared. */\nexport const RAMP_STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900] as const;\n\nexport type RampStep = (typeof RAMP_STEPS)[number];\n\n/** The step the supplied base colour occupies; the ramp is built around it. */\nconst BASE_STEP = 500;\n\n/**\n * Target lightness per step, and how much of the base's chroma to keep.\n *\n * Measured from the preset indigo ramp, so feeding the preset primary through\n * `buildRamp` lands close to the shipped `--primary-*` values rather than\n * something arbitrary. It is deliberately not an exact reproduction - see the\n * note on `buildRamp`.\n */\nconst RAMP_CURVE: Record<RampStep, { l: number; chroma: number }> = {\n 50: { l: 0.962, chroma: 0.09 },\n 100: { l: 0.93, chroma: 0.16 },\n 200: { l: 0.87, chroma: 0.3 },\n 300: { l: 0.785, chroma: 0.51 },\n 400: { l: 0.68, chroma: 0.77 },\n 500: { l: 0.558, chroma: 1.0 },\n 600: { l: 0.511, chroma: 1.12 },\n 700: { l: 0.457, chroma: 1.05 },\n 800: { l: 0.398, chroma: 0.87 },\n 900: { l: 0.359, chroma: 0.66 },\n};\n\n/** Ceiling/floor the generated ends aim for, leaving the base itself untouched. */\nconst LIGHT_CEILING = 0.985;\nconst DARK_FLOOR = 0.22;\n\n/** Minimum lightness gap between adjacent steps, so none can collapse together. */\nconst MIN_STEP_DELTA = 0.012;\n\n/**\n * Generates a 50-900 ramp around `base`, which is placed at the 500 step.\n *\n * The base's own hue is always preserved, and `--x-500` is returned as the base\n * hex verbatim, so the colour a consumer picked is never silently replaced.\n *\n * The curve above is *rescaled* to whatever lightness headroom the base leaves,\n * rather than being applied absolutely or simply shifted:\n *\n * - Applying it absolutely would reassign the base - pick a pale yellow and\n * `--x-500` would come back a mid-olive, contradicting `--x-color`.\n * - Shifting it so 500 sits at the base's lightness pushes the light end past\n * `l = 1`, where it clips and 50/100/200/300 all come out pure white.\n *\n * The ends are **absolute**, not relative to the base: step 50 lands near-white\n * and step 900 near-dark whatever lightness the base has, with the remaining\n * steps interpolated between the base and those anchors. Only a base that is\n * already past an anchor compresses that side into what headroom is left.\n *\n * Getting this wrong is subtle. An earlier version offset every step *from the\n * base* by the curve's own distances, capped so the preset reproduced exactly.\n * That looks right - and reproduces the preset ramp perfectly - but it makes the\n * tints relative: a dark navy base (`#1a1a2e`) returned `--primary-50: #8a8a8c`,\n * a mid grey rather than a tint, because 50 sits only 0.404 lightness above 500\n * on the curve. Every consumer of the tint end broke visibly - `Navigation`'s\n * active item paints `--primary-50` and turned into a charcoal pill.\n *\n * Two inputs are genuinely degenerate and are handled rather than solved: a\n * base at or above `LIGHT_CEILING` has no room for tints, and one with zero\n * chroma (pure white, black, any gray) has no saturation to separate them with\n * either. For those the light end converges, and `isRampViable` reports it so\n * the caller can warn. Realistic light picks are fine - `#fde047` still yields\n * five distinct tints.\n */\nexport const buildRamp = (base: string): Record<RampStep, string> => {\n const { l: baseL, c: baseC, h } = hexToOklch(base);\n const anchor = RAMP_CURVE[BASE_STEP].l;\n\n // Where the ends of the scale sit, independent of the base. A base already\n // lighter than the curve's own 50 (or darker than its 900) has nowhere left\n // to go, so that side compresses into the remaining headroom instead.\n const curveLight = RAMP_CURVE[50].l;\n const curveDark = RAMP_CURVE[900].l;\n const lightTarget = baseL >= curveLight ? Math.min(LIGHT_CEILING, baseL + 0.02) : curveLight;\n const darkTarget = baseL <= curveDark ? Math.max(DARK_FLOOR * 0.2, baseL - 0.02) : curveDark;\n\n const lightSpan = curveLight - anchor;\n const darkSpan = anchor - curveDark;\n\n const out = {} as Record<RampStep, string>;\n for (const step of RAMP_STEPS) {\n if (step === BASE_STEP) {\n out[step] = base;\n continue;\n }\n const { l: curveL, chroma } = RAMP_CURVE[step];\n const offset = curveL - anchor;\n // How far along its half of the curve this step sits: 0 at the base, 1 at\n // the end. Interpolating that fraction between the base and the target\n // keeps the curve's shape while pinning where it ends up.\n const t = offset > 0 ? offset / lightSpan : -offset / darkSpan;\n const l = offset > 0 ? baseL + t * (lightTarget - baseL) : baseL - t * (baseL - darkTarget);\n out[step] = oklchToHex({ l, c: baseC * chroma, h });\n }\n\n return enforceSeparation(out, h, baseC);\n};\n\n/**\n * Walks outward from the base step, pushing any step that ended up too close to\n * its neighbour further away. Only bites for extreme inputs (near-white,\n * near-black, zero-chroma), where the rescale above has almost no room left.\n */\nconst enforceSeparation = (\n ramp: Record<RampStep, string>,\n h: number,\n baseC: number,\n): Record<RampStep, string> => {\n const baseIndex = RAMP_STEPS.indexOf(BASE_STEP);\n const lightness = RAMP_STEPS.map((s) => hexToOklch(ramp[s]).l);\n\n // Lighter steps: walk from the base toward 50, each must be lighter.\n for (let i = baseIndex - 1; i >= 0; i--) {\n const limit = lightness[i + 1] + MIN_STEP_DELTA;\n if (lightness[i] < limit) lightness[i] = Math.min(1, limit);\n }\n // Darker steps: walk from the base toward 900, each must be darker.\n for (let i = baseIndex + 1; i < RAMP_STEPS.length; i++) {\n const limit = lightness[i - 1] - MIN_STEP_DELTA;\n if (lightness[i] > limit) lightness[i] = Math.max(0, limit);\n }\n\n const out = {} as Record<RampStep, string>;\n RAMP_STEPS.forEach((step, i) => {\n if (step === BASE_STEP) {\n out[step] = ramp[step];\n return;\n }\n out[step] = oklchToHex({\n l: lightness[i],\n c: baseC * RAMP_CURVE[step].chroma,\n h,\n });\n });\n return out;\n};\n\n/** How far `--x-dark` / `--x-light` sit from the base, in OKLab lightness. */\nconst DARK_DELTA = 0.086;\nconst LIGHT_DELTA = 0.169;\n\n/** Below this lightness there is no room left to darken, so the hover lightens. */\nconst HOVER_INVERT_BELOW = DARK_DELTA * 1.5;\n\n/**\n * The hover/active colour. Must differ *visibly* from the base and stay legible\n * as text on white, since `--x-dark` is used both as a fill (Button, Chip\n * hovers) and as text (Snackbar, link hover in `global.scss`).\n *\n * A fixed ramp step is not good enough: for a near-white base the 600 step\n * lands barely darker than the base and the hover reads as no change at all.\n * Hence a guaranteed delta.\n *\n * For a base that is already near-black the delta is applied *upwards* instead.\n * Clamping to a floor would return a colour lighter than the base while still\n * being named \"dark\", and returning the base unchanged would leave the control\n * with no hover affordance at all; lightening is what dark-surface design\n * systems do anyway.\n */\nexport const deriveDark = (base: string): string => {\n const { l, c, h } = hexToOklch(base);\n const target = l < HOVER_INVERT_BELOW ? l + DARK_DELTA : l - DARK_DELTA;\n return oklchToHex({ l: target, c, h });\n};\n\n/**\n * The light companion. Lightening has a hard ceiling, so for an already-pale\n * base this lands very close to it - acceptable, as `--x-light` is a public\n * token that nothing inside the library currently consumes.\n */\nexport const deriveLight = (base: string): string => {\n const { l, c, h } = hexToOklch(base);\n return oklchToHex({ l: Math.min(LIGHT_CEILING, l + LIGHT_DELTA), c, h });\n};\n\n/**\n * Whether `base` leaves enough lightness headroom to generate a usable 50-900\n * ramp. False only for near-white and near-black, where the tint or shade end\n * necessarily converges - the caller surfaces that as a developer warning\n * rather than silently shipping identical tokens.\n *\n * Deliberately does not test chroma: an unsaturated gray separates perfectly\n * well by lightness alone, and a saturated light colour like `#fde047` still\n * produces five distinct tints. Only the extremes genuinely fail.\n */\nexport const isRampViable = (base: string): boolean => {\n const { l } = hexToOklch(base);\n return l < 0.95 && l > 0.12;\n};\n\n// ============================================================================\n// Dark scheme\n// ============================================================================\n//\n// One token cannot be both a fill for white text and readable text on a dark\n// page. White text needs a fill at relative luminance <= 0.18 (4.5:1); coloured\n// text on the dark page needs >= 0.23. The ranges do not overlap, so the dark\n// scheme *tone-shifts* every family instead: `--x-color` becomes a lighter tone\n// that reads as text on the dark surfaces, and `--x-contrast` flips to dark\n// text on it. Every \"fill + `--x-contrast`\" pairing in the library stays valid\n// by construction, and so does every `color: var(--x-color)`.\n//\n// The preset dark palette in `_color-schemes.scss` is produced by exactly these\n// functions from the light preset, and a unit test holds the two in step - so\n// a consumer's own colour is derived by the same rule the preset was.\n\n/** The dark scheme's page surface (`--surface`). Equal to `CONTRAST_DARK`. */\nexport const DARK_SURFACE = '#0f172a';\n\n/** The dark scheme's raised surface (`--surface-raised`): menus, dialogs. */\nexport const DARK_SURFACE_RAISED = '#1e293b';\n\n/**\n * Minimum contrast a dark-scheme base must reach against **both** dark\n * surfaces. 5:1 rather than 4.5:1 for the same reason the light bases sit at\n * ~5:1: a hundredth of headroom is a threshold the next tweak falls through.\n * Against the page this lands at ~6.1:1.\n */\nexport const DARK_BASE_MIN_CONTRAST = 5;\n\n/**\n * The dark-scheme tone of `base`: the same hue and chroma, lightened just far\n * enough to clear `DARK_BASE_MIN_CONTRAST` against both dark surfaces.\n *\n * A base that already clears it is returned unchanged - a consumer who picks a\n * light brand colour gets exactly that colour in dark mode too.\n */\nexport const deriveDarkBase = (base: string): string => {\n const reaches = (hex: string) =>\n contrastRatio(hex, DARK_SURFACE) >= DARK_BASE_MIN_CONTRAST &&\n contrastRatio(hex, DARK_SURFACE_RAISED) >= DARK_BASE_MIN_CONTRAST;\n if (reaches(base)) return base;\n\n const start = hexToOklch(base);\n // 0.005 steps: fine enough that the result lands within a few hundredths of\n // the threshold, coarse enough to be a few dozen iterations at most.\n for (let l = start.l; l <= 1; l += 0.005) {\n const candidate = oklchToHex({ ...start, l });\n if (reaches(candidate)) return candidate;\n }\n return '#ffffff';\n};\n\n/** How far the dark hover sits above its base, in OKLab lightness. */\nconst DARK_HOVER_DELTA = 0.07;\n/** How far the dark `--x-light` companion sits below its base. */\nconst DARK_LIGHT_DELTA = 0.35;\n\n/**\n * The dark-scheme hover (`--x-dark`). *Lighter* than the base, because on a\n * dark surface lightening is what reads as emphasis - and lightening also\n * moves the fill further from the dark `--x-contrast` text on it, so the hover\n * state can only gain contrast, never lose it (~8:1 for the preset).\n */\nexport const deriveDarkHover = (darkBase: string): string => {\n const { l, c, h } = hexToOklch(darkBase);\n return oklchToHex({ l: Math.min(LIGHT_CEILING, l + DARK_HOVER_DELTA), c, h });\n};\n\n/**\n * The dark-scheme `--x-light`: the low-emphasis companion, which on a dark\n * surface means *darker* than the base. Public token; nothing in the library\n * consumes it, matching the light scheme.\n */\nexport const deriveDarkLight = (darkBase: string): string => {\n const { l, c, h } = hexToOklch(darkBase);\n return oklchToHex({ l: Math.max(0.2, l - DARK_LIGHT_DELTA), c, h });\n};\n\n/**\n * Lightness and chroma share per step of the dark `--primary-50…900` ramp.\n *\n * The ramp is **inverted** relative to the light one: step 50 is the faintest\n * tint *on the dark page* - a near-page colour - and 900 is the lightest. That\n * keeps every consumer's intent intact. \"`-50` behind, `-700` as text\" is a\n * quiet tinted surface with strong text in both schemes (9.9:1 in dark).\n */\nconst DARK_RAMP_CURVE: Record<Exclude<RampStep, 500>, { l: number; chroma: number }> = {\n 50: { l: 0.235, chroma: 0.35 },\n 100: { l: 0.27, chroma: 0.45 },\n 200: { l: 0.33, chroma: 0.6 },\n 300: { l: 0.42, chroma: 0.8 },\n 400: { l: 0.55, chroma: 0.95 },\n 600: { l: 0.76, chroma: 0.8 },\n 700: { l: 0.83, chroma: 0.6 },\n 800: { l: 0.89, chroma: 0.4 },\n 900: { l: 0.945, chroma: 0.2 },\n};\n\n/** The dark `--x-50…900` ramp around a dark-scheme base, placed at 500. */\nexport const buildDarkRamp = (darkBase: string): Record<RampStep, string> => {\n const { c, h } = hexToOklch(darkBase);\n const out = {} as Record<RampStep, string>;\n for (const step of RAMP_STEPS) {\n out[step] =\n step === BASE_STEP\n ? darkBase\n : oklchToHex({\n l: DARK_RAMP_CURVE[step as Exclude<RampStep, 500>].l,\n c: c * DARK_RAMP_CURVE[step as Exclude<RampStep, 500>].chroma,\n h,\n });\n }\n return out;\n};\n","import { devWarn } from '../../utils';\nimport {\n DARK_SURFACE,\n DARK_SURFACE_RAISED,\n RAMP_STEPS,\n buildDarkRamp,\n buildRamp,\n contrastRatio,\n deriveDark,\n deriveDarkBase,\n deriveDarkHover,\n deriveDarkLight,\n deriveLight,\n hexToRgbTriple,\n isValidHex,\n isRampViable,\n pickContrast,\n} from './ThemeProvider.color';\nimport type {\n ResolvedColorScheme,\n ResolvedTheme,\n ThemeColorKey,\n ThemeColorValue,\n ThemeConfig,\n} from './ThemeProvider.types';\n\nexport const THEME_COLOR_KEYS: readonly ThemeColorKey[] = [\n 'primary',\n 'secondary',\n 'success',\n 'danger',\n 'warning',\n 'info',\n 'hyperlink',\n] as const;\n\n/**\n * `hyperlink` is link text on a surface, never a fill, so it has no\n * `--hyperlink-contrast` token - nothing in the library would read it.\n */\nconst FILL_COLOR_KEYS: readonly ThemeColorKey[] = [\n 'primary',\n 'secondary',\n 'success',\n 'danger',\n 'warning',\n 'info',\n] as const;\n\n/** Only `primary` has a 50-900 ramp in `variables.scss`. */\nconst RAMP_COLOR_KEY: ThemeColorKey = 'primary';\n\n/** The eight preset `--font-size-*` values, in declaration order. */\nconst FONT_SIZE_STEPS: readonly [string, number][] = [\n ['xs', 0.75],\n ['sm', 0.875],\n ['base', 1],\n ['md', 1.1],\n ['lg', 1.125],\n ['xl', 1.25],\n ['2xl', 1.5],\n ['3xl', 1.875],\n] as const;\n\n/**\n * The shipped values from `src/styles/variables.scss`.\n *\n * This is a literal copy, not something derived: the ramp is hand-tuned and no\n * generator reproduces it byte for byte. Keeping it literal means a theme equal\n * to the preset writes no CSS properties at all, so default rendering is\n * identical to `dist/index.css`.\n *\n * Must be kept in sync with `variables.scss` by hand. The bases are all chosen\n * to clear WCAG AA against white text; see the comment at the top of that file.\n */\nexport const defaultTheme: Required<ThemeConfig> = {\n colors: {\n primary: '#5c5de8',\n secondary: '#617087',\n success: '#007f57',\n danger: '#d6272f',\n warning: '#9c6300',\n info: '#007a90',\n hyperlink: '#007b84',\n },\n typography: {\n fontFamily:\n \"'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif\",\n monoFamily:\n \"'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace\",\n fontScale: 1,\n },\n // Empty on purpose: the preset's dark colours are *derived* from `colors`\n // (see `_color-schemes.scss`), exactly as a consumer's are.\n dark: {},\n};\n\n/** The preset `--primary-*` ramp, needed so an unthemed primary emits nothing. */\nconst DEFAULT_PRIMARY_RAMP: Record<number, string> = {\n 50: '#eef2ff',\n 100: '#e0e7ff',\n 200: '#c7d2fe',\n 300: '#a5b4fc',\n 400: '#818cf8',\n 500: '#5c5de8',\n 600: '#4f46e5',\n 700: '#4338ca',\n 800: '#3730a3',\n 900: '#312e81',\n};\n\nexport const FONT_SCALE_MIN = 0.875;\nexport const FONT_SCALE_MAX = 1.25;\n\nconst normalizeColor = (value: ThemeColorValue): { base: string; contrast?: string } =>\n typeof value === 'string' ? { base: value } : value;\n\ntype ResolvedColor = { base: string; contrast?: string };\n\n/**\n * Validates one supplied colour. `undefined` means \"use the fallback\" - either\n * nothing was supplied or the base was invalid (which warns).\n */\nconst resolveColor = (\n supplied: ThemeColorValue | undefined,\n path: string,\n): ResolvedColor | undefined => {\n if (supplied === undefined) return undefined;\n const { base, contrast } = normalizeColor(supplied);\n if (!isValidHex(base)) {\n devWarn(\n `theme-color-${path}`,\n `ThemeProvider: ${path} is not a valid hex colour (received ${JSON.stringify(base)}). Falling back to the preset.`,\n );\n return undefined;\n }\n if (contrast !== undefined && !isValidHex(contrast)) {\n devWarn(\n `theme-contrast-${path}`,\n `ThemeProvider: ${path}.contrast is not a valid hex colour (received ${JSON.stringify(contrast)}). It will be computed instead.`,\n );\n return { base };\n }\n return contrast === undefined ? { base } : { base, contrast };\n};\n\n/** Fills every absent field from the preset. */\nexport const resolveTheme = (theme: ThemeConfig): ResolvedTheme => {\n const colors = {} as ResolvedTheme['colors'];\n const darkColors = {} as ResolvedTheme['colors'];\n\n for (const key of THEME_COLOR_KEYS) {\n colors[key] =\n resolveColor(theme.colors?.[key], `colors.${key}`) ??\n normalizeColor(defaultTheme.colors[key]!);\n\n // The dark colour: an explicit `dark.colors` entry wins; otherwise the\n // light colour is tone-shifted, exactly as the preset's was. A pinned\n // light `contrast` does not carry over - it was chosen for the light fill.\n const explicitDark = resolveColor(theme.dark?.colors?.[key], `dark.colors.${key}`);\n if (explicitDark) {\n const worst = Math.min(\n contrastRatio(explicitDark.base, DARK_SURFACE),\n contrastRatio(explicitDark.base, DARK_SURFACE_RAISED),\n );\n if (worst < 4.5) {\n devWarn(\n `theme-dark-contrast-${key}`,\n `ThemeProvider: dark.colors.${key} (${explicitDark.base}) is ${worst.toFixed(2)}:1 against the dark surfaces, below the 4.5:1 text needs. It is used as given, but text in it will fail WCAG AA in the dark scheme - omit it to have a compliant tone derived from colors.${key}.`,\n );\n }\n darkColors[key] = explicitDark;\n } else {\n darkColors[key] = { base: deriveDarkBase(colors[key].base) };\n }\n }\n\n const scale = theme.typography?.fontScale;\n let fontScale = defaultTheme.typography.fontScale!;\n if (scale !== undefined) {\n if (!Number.isFinite(scale) || scale < FONT_SCALE_MIN || scale > FONT_SCALE_MAX) {\n devWarn(\n 'theme-font-scale',\n `ThemeProvider: typography.fontScale must be between ${FONT_SCALE_MIN} and ${FONT_SCALE_MAX} (received ${String(scale)}). Falling back to ${fontScale}.`,\n );\n } else {\n fontScale = scale;\n }\n }\n\n return {\n colors,\n typography: {\n fontFamily: theme.typography?.fontFamily || defaultTheme.typography.fontFamily!,\n monoFamily: theme.typography?.monoFamily || defaultTheme.typography.monoFamily!,\n fontScale,\n },\n dark: { colors: darkColors },\n };\n};\n\n/**\n * Expands a resolved theme into the flat `--token: value` map to apply.\n *\n * Every family contributes `--x-color`, `--x-rgb`, `--x-dark` and `--x-light`;\n * the six fill families also get `--x-contrast`, and `primary` additionally\n * gets the full `--primary-50…900` ramp.\n */\nexport const buildTokens = (\n resolved: ResolvedTheme,\n scheme: ResolvedColorScheme = 'light',\n): Record<string, string> => {\n if (scheme === 'dark') return buildDarkTokens(resolved);\n const tokens: Record<string, string> = {};\n\n for (const key of THEME_COLOR_KEYS) {\n const { base, contrast } = resolved.colors[key];\n tokens[`--${key}-color`] = base;\n tokens[`--${key}-rgb`] = hexToRgbTriple(base);\n tokens[`--${key}-dark`] = deriveDark(base);\n tokens[`--${key}-light`] = deriveLight(base);\n\n if (FILL_COLOR_KEYS.includes(key)) {\n tokens[`--${key}-contrast`] = contrast ?? pickContrast(base);\n }\n\n if (key === RAMP_COLOR_KEY) {\n const isPreset = base === normalizeColor(defaultTheme.colors[key]!).base;\n // The preset ramp is hand-tuned, so reuse it verbatim rather than\n // regenerating a near-identical one.\n const ramp = isPreset ? DEFAULT_PRIMARY_RAMP : buildRamp(base);\n if (!isPreset && !isRampViable(base)) {\n devWarn(\n `theme-ramp-${key}`,\n `ThemeProvider: colors.${key} (${base}) is too light or too dark to generate a usable --${key}-50…900 scale; several steps will be identical. Pick a colour with more headroom.`,\n );\n }\n for (const step of RAMP_STEPS) {\n tokens[`--${key}-${step}`] = ramp[step];\n }\n }\n }\n\n Object.assign(tokens, typographyTokens(resolved));\n return tokens;\n};\n\nconst typographyTokens = (resolved: ResolvedTheme): Record<string, string> => {\n const tokens: Record<string, string> = {};\n const { fontFamily, monoFamily, fontScale } = resolved.typography;\n tokens['--font-family-primary'] = fontFamily;\n tokens['--font-family-mono'] = monoFamily;\n for (const [name, rem] of FONT_SIZE_STEPS) {\n // Trailing zeros trimmed so 1 * 0.75 reads as `0.75rem`, not `0.750rem`.\n tokens[`--font-size-${name}`] = `${parseFloat((rem * fontScale).toFixed(4))}rem`;\n }\n return tokens;\n};\n\n/**\n * The dark scheme's colour tokens, from `resolved.dark` - by the same\n * functions that generated the preset dark palette in `_color-schemes.scss`,\n * so an unthemed dark provider reproduces it exactly and writes nothing.\n */\nconst buildDarkTokens = (resolved: ResolvedTheme): Record<string, string> => {\n const tokens: Record<string, string> = {};\n for (const key of THEME_COLOR_KEYS) {\n const { base, contrast } = resolved.dark.colors[key];\n tokens[`--${key}-color`] = base;\n tokens[`--${key}-rgb`] = hexToRgbTriple(base);\n tokens[`--${key}-dark`] = deriveDarkHover(base);\n tokens[`--${key}-light`] = deriveDarkLight(base);\n if (FILL_COLOR_KEYS.includes(key)) {\n tokens[`--${key}-contrast`] = contrast ?? pickContrast(base);\n }\n if (key === RAMP_COLOR_KEY) {\n const ramp = buildDarkRamp(base);\n for (const step of RAMP_STEPS) tokens[`--${key}-${step}`] = ramp[step];\n }\n }\n Object.assign(tokens, typographyTokens(resolved));\n return tokens;\n};\n\n/** Tokens for the preset in each scheme, used to tell which are overrides. */\nconst DEFAULT_TOKENS: Record<ResolvedColorScheme, Record<string, string>> = {\n light: buildTokens(resolveTheme(defaultTheme), 'light'),\n dark: buildTokens(resolveTheme(defaultTheme), 'dark'),\n};\n\n/**\n * Only the tokens that differ from the preset *in the same scheme*.\n *\n * This is what makes an unthemed `ThemeProvider` a no-op in both schemes: it\n * writes nothing, so `dist/index.css` stays authoritative - including its dark\n * and `system` blocks, which inline styles would otherwise override.\n */\nexport const diffFromDefault = (\n tokens: Record<string, string>,\n scheme: ResolvedColorScheme = 'light',\n): Record<string, string> => {\n const diff: Record<string, string> = {};\n for (const [name, value] of Object.entries(tokens)) {\n if (DEFAULT_TOKENS[scheme][name] !== value) diff[name] = value;\n }\n return diff;\n};\n\nconst block = (selector: string, tokens: Record<string, string>, indent = '') =>\n `${indent}${selector} {\\n` +\n Object.entries(tokens)\n .map(([name, value]) => `${indent} ${name}: ${value};`)\n .join('\\n') +\n `\\n${indent}}`;\n\n/**\n * The resolved theme as CSS: `:root` for the light scheme, plus the dark\n * scheme's colours under `[data-color-scheme='dark']` and, inside a\n * `prefers-color-scheme` query, `[data-color-scheme='system']` - the same\n * selectors `dist/index.css` uses, so the pasted theme follows the scheme\n * exactly as the preset does.\n *\n * Paste it into your own stylesheet to bake a theme in at build time - that\n * avoids the brief flash of the preset that any runtime theme has when the\n * value arrives after first paint, and needs no JavaScript at all.\n */\nexport const themeToCss = (resolved: ResolvedTheme): string => {\n const light = buildTokens(resolved, 'light');\n // Typography is scheme-independent, so it is only written once.\n const dark = Object.fromEntries(\n Object.entries(buildTokens(resolved, 'dark')).filter(([name]) => !name.startsWith('--font-')),\n );\n return [\n block(':root', light),\n block(\":root[data-color-scheme='dark']\", dark),\n `@media (prefers-color-scheme: dark) {\\n${block(\":root[data-color-scheme='system']\", dark, ' ')}\\n}`,\n ].join('\\n\\n');\n};\n","/**\n * Runtime font registration for the theme system.\n *\n * `--font-family-primary` only *names* families - it cannot make a font\n * available. Selecting \"Plus Jakarta Sans\" on a machine that doesn't have it\n * installed silently falls through to the next stack entry, which is why a\n * theme needs a way to supply the font data itself.\n *\n * ## Why this is CSP-safe\n *\n * Fonts are registered with the CSS Font Loading API from an `ArrayBuffer`:\n *\n * ```ts\n * document.fonts.add(new FontFace(family, buffer));\n * ```\n *\n * CSP's `font-src` directive governs *fetching* a font resource by URL - it is\n * what gates `@font-face { src: url(...) }` and the string form of the\n * `FontFace` constructor. The binary form performs no fetch at all, so there is\n * no request for `font-src` to check and no allowance to configure. Notably\n * this also avoids `blob:` URLs, which *would* require `font-src blob:`.\n *\n * No `<style>` element is created either, so nothing here needs a nonce - the\n * same position as the rest of the theme system.\n */\n\n/** A font registered at runtime, as listed by the editor. */\nexport interface RegisteredFont {\n /** The family name to reference in a font stack. */\n family: string;\n /** Where it came from, so the UI can distinguish uploads from built-ins. */\n source: 'upload';\n}\n\n/**\n * Turns a filename into a usable CSS family name.\n *\n * Deliberately conservative: the real family name lives in the font's internal\n * `name` table, and parsing SFNT tables to read it would be a disproportionate\n * amount of binary handling for a label. The filename is what the user\n * recognises anyway.\n */\nexport const familyNameFromFile = (filename: string): string => {\n const base = filename.replace(/\\.[^.]+$/, '');\n const cleaned = base\n // Strip the weight/style suffixes font vendors append.\n .replace(/[-_](regular|normal|book|roman)$/i, '')\n .replace(/[-_]+/g, ' ')\n // A quoted family name may contain spaces but not quotes or control chars.\n .replace(/[\"'\\\\]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n return cleaned || 'Custom Font';\n};\n\n/** Wraps a family name for use in a CSS font stack if it needs quoting. */\nexport const quoteFamily = (family: string): string =>\n /^[a-zA-Z][a-zA-Z0-9-]*$/.test(family) ? family : `'${family}'`;\n\n/**\n * Builds a full stack from a custom family, keeping sensible fallbacks so the\n * page stays readable if the font is ever unavailable.\n */\nexport const toFontStack = (family: string, mono = false): string =>\n mono\n ? `${quoteFamily(family)}, 'SF Mono', Monaco, monospace`\n : `${quoteFamily(family)}, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`;\n\n/** Font formats accepted for upload, as an `accept` attribute value. */\nexport const FONT_ACCEPT = '.woff2,.woff,.ttf,.otf';\n\nconst SUPPORTED_EXTENSIONS = /\\.(woff2|woff|ttf|otf)$/i;\n\nexport const isSupportedFontFile = (filename: string): boolean =>\n SUPPORTED_EXTENSIONS.test(filename);\n\n/**\n * Registers font data with the document so a theme can reference its family.\n *\n * Resolves with the family name actually registered. Rejects if the data is not\n * a font the browser can parse, or if the Font Loading API is unavailable\n * (notably during SSR, where there is no `document` to register against).\n */\nexport const registerFontFace = async (family: string, data: ArrayBuffer): Promise<string> => {\n if (typeof document === 'undefined' || !document.fonts) {\n throw new Error('registerFontFace requires a document with the CSS Font Loading API.');\n }\n\n // ArrayBuffer source - no URL is fetched, so CSP's font-src never applies.\n const face = new FontFace(family, data);\n await face.load();\n document.fonts.add(face);\n // No cache invalidation needed: only positive results are cached, and this\n // family could not have been cached positive while it was still unavailable.\n // `document.fonts.add` also fires `loadingdone`, which wakes subscribers.\n return family;\n};\n\n/** Reads a File and registers it, returning the family name it was given. */\nexport const registerFontFile = async (file: File, family?: string): Promise<string> => {\n if (!isSupportedFontFile(file.name)) {\n throw new Error(`Unsupported font format: ${file.name}. Use ${FONT_ACCEPT}.`);\n }\n const buffer = await file.arrayBuffer();\n return registerFontFace(family ?? familyNameFromFile(file.name), buffer);\n};\n\n/**\n * CSS generic families, which always resolve and must never be reported\n * missing. They also cannot be probed by the method below, since asking for\n * `monospace, monospace` measures identically to `monospace` alone.\n */\nconst GENERIC_FAMILIES = new Set([\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n 'inherit',\n 'initial',\n 'unset',\n]);\n\n/**\n * Mixed-width glyphs, so a real font is very unlikely to measure identically\n * to a fallback by coincidence.\n */\nconst PROBE_TEXT = 'mmmmmmmmmmlliI0OWw@';\n\n/** Two structurally different fallbacks - a font need only differ from one. */\nconst PROBE_FALLBACKS = ['monospace', 'serif'] as const;\n\n/**\n * Cached per family - **positive results only**.\n *\n * A negative answer is not stable: web fonts load asynchronously (always, with\n * `font-display: swap`), so a family probed during the first render is\n * legitimately unavailable and becomes available moments later. Caching that\n * `false` pinned the answer forever, which showed a permanent \"not installed\"\n * warning for fonts that had in fact loaded.\n *\n * A positive answer cannot go stale the same way - a loaded font is not\n * unloaded - so those are worth keeping. Re-probing the misses costs one canvas\n * measurement each.\n */\nconst availabilityCache = new Map<string, true>();\n\n/**\n * Notifies when the set of usable fonts changes, so a caller rendering an\n * availability state can re-check.\n *\n * Both signals are needed: `loadingdone` covers fonts that begin loading after\n * subscription, while `ready` covers those already in flight when the listener\n * was attached - which is the common case for a stylesheet's `@font-face`\n * rules, since they start loading before any component mounts.\n */\nexport const subscribeToFontLoads = (onChange: () => void): (() => void) => {\n if (typeof document === 'undefined' || !document.fonts) return () => {};\n\n let active = true;\n const handler = () => {\n if (active) onChange();\n };\n\n document.fonts.addEventListener('loadingdone', handler);\n void document.fonts.ready.then(handler);\n\n return () => {\n active = false;\n document.fonts.removeEventListener('loadingdone', handler);\n };\n};\n\n/**\n * Whether a font family will actually render, rather than silently falling\n * through to the next entry in the stack.\n *\n * **`document.fonts.check` cannot answer this.** Per spec it reports whether\n * the faces *in the FontFaceSet* matching the query are loaded, so with no\n * matching face it returns `true` vacuously. Verified in a real browser: it\n * answers `true` for `'Totally Not A Real Font 12345'`, and therefore for every\n * uninstalled system font too. Using it here produced a check that could never\n * fail.\n *\n * Instead the family is measured on a canvas against two fallbacks. If it\n * resolves to anything real, the text measures differently from at least one\n * fallback alone; if it does not resolve, the browser renders that fallback and\n * the widths match exactly.\n */\nexport const isFontAvailable = (family: string): boolean => {\n const name = family.trim().replace(/^['\"]|['\"]$/g, '');\n if (!name) return true;\n if (GENERIC_FAMILIES.has(name.toLowerCase())) return true;\n if (typeof document === 'undefined') return true;\n\n if (availabilityCache.get(name)) return true;\n\n try {\n const context = document.createElement('canvas').getContext('2d');\n if (!context) return true;\n\n const available = PROBE_FALLBACKS.some((fallback) => {\n context.font = `100px ${fallback}`;\n const baseline = context.measureText(PROBE_TEXT).width;\n context.font = `100px ${quoteFamily(name)}, ${fallback}`;\n // An invalid font shorthand leaves `font` untouched, which measures as\n // the baseline and correctly reports the family as unavailable.\n return Math.abs(context.measureText(PROBE_TEXT).width - baseline) > 0.5;\n });\n\n if (available) availabilityCache.set(name, true);\n return available;\n } catch {\n // Never report a font missing because probing itself failed - and don't\n // cache a failure, so a later call can still get a real answer.\n return true;\n }\n};\n\n/** Whether the first family in a stack will render. */\nexport const isFontStackAvailable = (stack: string): boolean =>\n isFontAvailable(stack.split(',')[0] ?? '');\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACRP,SAAS,eAAe,kBAAkB;AAGnC,IAAM,eAAe,cAA6C,MAAS;AAO3E,IAAM,WAAW,MAAyB;AAC/C,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;;;ACUA,IAAM,eAAe,CAAC,MACpB,KAAK,UAAU,IAAI,QAAQ,KAAK,KAAK,IAAI,SAAS,OAAO,GAAG;AAE9D,IAAM,eAAe,CAAC,MACpB,KAAK,WAAY,QAAQ,IAAI,QAAQ,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI;AAE9D,IAAM,UAAU,CAAC,MAAuB,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI;AAGzD,IAAM,WAAW,CAAC,QAAiD;AACxE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,MAAM,IAAI,KAAK,EAAE,QAAQ,MAAM,EAAE;AACvC,QAAM,OACJ,IAAI,WAAW,IACX,IACG,MAAM,EAAE,EACR,IAAI,CAAC,MAAM,IAAI,CAAC,EAChB,KAAK,EAAE,IACV;AACN,MAAI,CAAC,mBAAmB,KAAK,IAAI,EAAG,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AI;AAAA,IACtE,CAAC;AAED,QAAI,UAAW,mBAAkB,IAAI,MAAM,IAAI;AAC/C,WAAO;AAAA,EACT,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;AAGO,IAAM,uBAAuB,CAAC,UACnC,gBAAgB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,EAAE;","names":["value"]}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-D2PXPX56.js";
|
|
15
15
|
import {
|
|
16
16
|
SegmentedControl
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-BHZ76J2K.js";
|
|
18
18
|
import {
|
|
19
19
|
SplitButton
|
|
20
20
|
} from "./chunk-UTOTOWPS.js";
|
|
@@ -1725,4 +1725,4 @@ var DataGrid = Object.assign(DataGridInner, { displayName: "DataGrid" });
|
|
|
1725
1725
|
export {
|
|
1726
1726
|
DataGrid
|
|
1727
1727
|
};
|
|
1728
|
-
//# sourceMappingURL=chunk-
|
|
1728
|
+
//# sourceMappingURL=chunk-FFYPSLQV.js.map
|