@multiplatform.one/theme 9.1.0 → 9.3.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 (145) hide show
  1. package/README.md +23 -0
  2. package/dist/cjs/index.gnome.cjs +9 -0
  3. package/dist/cjs/index.gnome.native.js +9 -0
  4. package/dist/cjs/index.gnome.native.js.map +1 -1
  5. package/dist/cjs/menuRow.cjs +4 -0
  6. package/dist/cjs/menuRow.native.js +4 -0
  7. package/dist/cjs/menuRow.native.js.map +1 -1
  8. package/dist/cjs/theme/accentHue.cjs +71 -0
  9. package/dist/cjs/theme/accentHue.native.js +82 -0
  10. package/dist/cjs/theme/accentHue.native.js.map +1 -0
  11. package/dist/cjs/theme/chartPalette.cjs +50 -29
  12. package/dist/cjs/theme/chartPalette.native.js +60 -33
  13. package/dist/cjs/theme/chartPalette.native.js.map +1 -1
  14. package/dist/cjs/theme/createDefaultThemeConfig.cjs +14 -1
  15. package/dist/cjs/theme/createDefaultThemeConfig.native.js +14 -1
  16. package/dist/cjs/theme/createDefaultThemeConfig.native.js.map +1 -1
  17. package/dist/cjs/theme/createThemes.cjs +84 -40
  18. package/dist/cjs/theme/createThemes.native.js +112 -39
  19. package/dist/cjs/theme/createThemes.native.js.map +1 -1
  20. package/dist/cjs/theme/defaults/builderOptions.cjs +30 -5
  21. package/dist/cjs/theme/defaults/builderOptions.native.js +34 -6
  22. package/dist/cjs/theme/defaults/builderOptions.native.js.map +1 -1
  23. package/dist/cjs/theme/index.cjs +1 -0
  24. package/dist/cjs/theme/index.native.js +1 -0
  25. package/dist/cjs/theme/index.native.js.map +1 -1
  26. package/dist/cjs/theme/overlaySurfaces.cjs +53 -4
  27. package/dist/cjs/theme/overlaySurfaces.native.js +53 -4
  28. package/dist/cjs/theme/overlaySurfaces.native.js.map +1 -1
  29. package/dist/cjs/theme/pageGutter.cjs +27 -2
  30. package/dist/cjs/theme/pageGutter.native.js +52 -2
  31. package/dist/cjs/theme/pageGutter.native.js.map +1 -1
  32. package/dist/cjs/theme/resolveKnobs.cjs +12 -0
  33. package/dist/cjs/theme/resolveKnobs.native.js +12 -0
  34. package/dist/cjs/theme/resolveKnobs.native.js.map +1 -1
  35. package/dist/cjs/theme/tintHues.cjs +8 -2
  36. package/dist/cjs/theme/tintHues.native.js +7 -1
  37. package/dist/cjs/theme/tintHues.native.js.map +1 -1
  38. package/dist/cjs/theme/v3TokenRoles.cjs +2 -2
  39. package/dist/cjs/theme/v3TokenRoles.native.js +2 -2
  40. package/dist/cjs/theme/v3TokenRoles.native.js.map +1 -1
  41. package/dist/esm/index.gnome.mjs +4 -4
  42. package/dist/esm/index.gnome.mjs.map +1 -1
  43. package/dist/esm/index.gnome.native.js +4 -4
  44. package/dist/esm/index.gnome.native.js.map +1 -1
  45. package/dist/esm/menuRow.mjs +4 -1
  46. package/dist/esm/menuRow.mjs.map +1 -1
  47. package/dist/esm/menuRow.native.js +4 -1
  48. package/dist/esm/menuRow.native.js.map +1 -1
  49. package/dist/esm/theme/accentHue.mjs +42 -0
  50. package/dist/esm/theme/accentHue.mjs.map +1 -0
  51. package/dist/esm/theme/accentHue.native.js +50 -0
  52. package/dist/esm/theme/accentHue.native.js.map +1 -0
  53. package/dist/esm/theme/chartPalette.mjs +51 -30
  54. package/dist/esm/theme/chartPalette.mjs.map +1 -1
  55. package/dist/esm/theme/chartPalette.native.js +61 -34
  56. package/dist/esm/theme/chartPalette.native.js.map +1 -1
  57. package/dist/esm/theme/createDefaultThemeConfig.mjs +14 -1
  58. package/dist/esm/theme/createDefaultThemeConfig.mjs.map +1 -1
  59. package/dist/esm/theme/createDefaultThemeConfig.native.js +14 -1
  60. package/dist/esm/theme/createDefaultThemeConfig.native.js.map +1 -1
  61. package/dist/esm/theme/createThemes.mjs +85 -42
  62. package/dist/esm/theme/createThemes.mjs.map +1 -1
  63. package/dist/esm/theme/createThemes.native.js +113 -41
  64. package/dist/esm/theme/createThemes.native.js.map +1 -1
  65. package/dist/esm/theme/defaults/builderOptions.mjs +31 -6
  66. package/dist/esm/theme/defaults/builderOptions.mjs.map +1 -1
  67. package/dist/esm/theme/defaults/builderOptions.native.js +35 -7
  68. package/dist/esm/theme/defaults/builderOptions.native.js.map +1 -1
  69. package/dist/esm/theme/index.mjs +1 -0
  70. package/dist/esm/theme/index.mjs.map +1 -1
  71. package/dist/esm/theme/index.native.js +1 -0
  72. package/dist/esm/theme/index.native.js.map +1 -1
  73. package/dist/esm/theme/overlaySurfaces.mjs +47 -4
  74. package/dist/esm/theme/overlaySurfaces.mjs.map +1 -1
  75. package/dist/esm/theme/overlaySurfaces.native.js +47 -4
  76. package/dist/esm/theme/overlaySurfaces.native.js.map +1 -1
  77. package/dist/esm/theme/pageGutter.mjs +27 -4
  78. package/dist/esm/theme/pageGutter.mjs.map +1 -1
  79. package/dist/esm/theme/pageGutter.native.js +52 -4
  80. package/dist/esm/theme/pageGutter.native.js.map +1 -1
  81. package/dist/esm/theme/resolveKnobs.mjs +12 -0
  82. package/dist/esm/theme/resolveKnobs.mjs.map +1 -1
  83. package/dist/esm/theme/resolveKnobs.native.js +12 -0
  84. package/dist/esm/theme/resolveKnobs.native.js.map +1 -1
  85. package/dist/esm/theme/tintHues.mjs +6 -1
  86. package/dist/esm/theme/tintHues.mjs.map +1 -1
  87. package/dist/esm/theme/tintHues.native.js +6 -1
  88. package/dist/esm/theme/tintHues.native.js.map +1 -1
  89. package/dist/esm/theme/v3TokenRoles.mjs +2 -2
  90. package/dist/esm/theme/v3TokenRoles.native.js +2 -2
  91. package/package.json +5 -5
  92. package/src/figma/figmaTokens.spec.ts +2 -2
  93. package/src/index.gnome.ts +9 -0
  94. package/src/menuRow.palette.spec.ts +26 -1
  95. package/src/menuRow.spec.ts +17 -1
  96. package/src/menuRow.ts +12 -0
  97. package/src/theme/accentHue.spec.ts +252 -0
  98. package/src/theme/accentHue.ts +73 -0
  99. package/src/theme/chartCategoricalSeverity.spec.ts +190 -0
  100. package/src/theme/chartPalette.spec.ts +37 -34
  101. package/src/theme/chartPalette.ts +90 -39
  102. package/src/theme/colorRules.spec.ts +3 -3
  103. package/src/theme/createDefaultThemeConfig.spec.ts +71 -2
  104. package/src/theme/createDefaultThemeConfig.ts +47 -5
  105. package/src/theme/createThemes.ts +167 -59
  106. package/src/theme/defaults/builderOptions.ts +41 -9
  107. package/src/theme/defaults/secondaryInk.spec.ts +71 -0
  108. package/src/theme/index.ts +1 -0
  109. package/src/theme/intentFill.spec.ts +8 -3
  110. package/src/theme/overlaySurfaces.tsx +75 -6
  111. package/src/theme/pageGutter.spec.tsx +2 -2
  112. package/src/theme/pageGutter.tsx +55 -2
  113. package/src/theme/rampRoles.spec.ts +60 -0
  114. package/src/theme/recipes.ts +2 -0
  115. package/src/theme/resolveKnobs.spec.ts +17 -0
  116. package/src/theme/resolveKnobs.ts +12 -0
  117. package/src/theme/severityChannel.spec.ts +202 -0
  118. package/src/theme/sheetHandle.spec.ts +54 -0
  119. package/src/theme/tintHues.ts +10 -0
  120. package/src/theme/v3TokenRoles.ts +2 -2
  121. package/types/index.gnome.d.ts +3 -3
  122. package/types/index.gnome.d.ts.map +1 -1
  123. package/types/menuRow.d.ts +9 -0
  124. package/types/menuRow.d.ts.map +1 -1
  125. package/types/theme/accentHue.d.ts +20 -0
  126. package/types/theme/accentHue.d.ts.map +1 -0
  127. package/types/theme/chartPalette.d.ts +2 -2
  128. package/types/theme/chartPalette.d.ts.map +1 -1
  129. package/types/theme/createDefaultThemeConfig.d.ts +12 -10
  130. package/types/theme/createDefaultThemeConfig.d.ts.map +1 -1
  131. package/types/theme/createThemes.d.ts +17 -2
  132. package/types/theme/createThemes.d.ts.map +1 -1
  133. package/types/theme/defaults/builderOptions.d.ts.map +1 -1
  134. package/types/theme/index.d.ts +1 -0
  135. package/types/theme/index.d.ts.map +1 -1
  136. package/types/theme/overlaySurfaces.d.ts +61 -3
  137. package/types/theme/overlaySurfaces.d.ts.map +1 -1
  138. package/types/theme/pageGutter.d.ts +26 -1
  139. package/types/theme/pageGutter.d.ts.map +1 -1
  140. package/types/theme/recipes.d.ts +4 -0
  141. package/types/theme/recipes.d.ts.map +1 -1
  142. package/types/theme/resolveKnobs.d.ts.map +1 -1
  143. package/types/theme/tintHues.d.ts +5 -0
  144. package/types/theme/tintHues.d.ts.map +1 -1
  145. package/types/theme/v3TokenRoles.d.ts +2 -2
@@ -29,11 +29,12 @@ import {
29
29
  export const overlayScrim = "$shadow4" as const;
30
30
 
31
31
  /**
32
- * A sheet's grabber (HIG, FZ-8557, FZ-8648): a 36×5 capsule 5pt inside the
32
+ * A floating panel's grabber (HIG, FZ-8557, FZ-8648): a 36×5 capsule 5pt inside the
33
33
  * sheet's top edge, drawn over the frame rather than floating on the scrim.
34
34
  * Its margins net to no height, so it lands the same on a web `Sheet.Handle`
35
- * laid out above the frame and on a native grab zone's first child. The one
36
- * recipe for every sheet: spread it and set nothing else.
35
+ * laid out above the frame and on a native grab zone's first child. The
36
+ * recipe for FloatingPanel's sheet face only (Select, Combobox): every other
37
+ * sheet draws `sheetHandle`.
37
38
  */
38
39
  export const sheetGrabber = {
39
40
  width: 36,
@@ -58,6 +59,56 @@ export const sheetGrabberZone = {
58
59
  height: 21,
59
60
  } as const;
60
61
 
62
+ /** The share of the sheet's width its handle spans, tamagui's `marginHorizontal: "35%"`. */
63
+ export const sheetHandleWidthRatio = 0.3;
64
+
65
+ /**
66
+ * A sheet's handle (FZ-11418), tamagui's `Sheet.Handle`: a 10pt pill 30% of
67
+ * the sheet's width, detached ABOVE the frame on the scrim with `$2` between
68
+ * them. tamagui's v3 Sheet on tamagui.dev measures 10pt tall, 30% wide and
69
+ * 8pt above a 16pt top corner. Every sheet but FloatingPanel's draws it:
70
+ * SheetModal on both platforms, AdaptivePopup's sheet and the house Dialog's
71
+ * phone sheet. Spread it, then `sheetHandleTone(scheme)`, on `Sheet.Handle`
72
+ * (web) or inside `sheetHandleZone` (native); a regular-width
73
+ * panel narrower than its band sets a width of `sheetHandleWidthRatio` of
74
+ * the panel.
75
+ */
76
+ export const sheetHandle = {
77
+ width: "30%",
78
+ height: 10,
79
+ borderRadius: 100,
80
+ backgroundColor: "$background",
81
+ opacity: 0.5,
82
+ alignSelf: "center",
83
+ marginHorizontal: 0,
84
+ marginTop: 0,
85
+ marginBottom: "$2",
86
+ zIndex: 10,
87
+ } as const;
88
+
89
+ /**
90
+ * A native sheet's grab zone around `sheetHandle`: the row above the frame,
91
+ * with room over the pill so a finger finds it.
92
+ */
93
+ export const sheetHandleZone = {
94
+ alignSelf: "stretch",
95
+ alignItems: "center",
96
+ paddingTop: 8,
97
+ } as const;
98
+
99
+ const sheetHandleToneLight = { backgroundColor: "$background", opacity: 0.5 } as const;
100
+ const sheetHandleToneDark = { backgroundColor: "$color5", opacity: 1 } as const;
101
+
102
+ /**
103
+ * The handle's tone per scheme (FZ-11418), spread after `sheetHandle`. Light
104
+ * keeps tamagui's page ground at half opacity. Dark takes the house overlay
105
+ * fill at full strength: the page ground at half opacity vanishes on a dark
106
+ * scrim, and tamagui.dev's dark handle measures that same #333 grey.
107
+ */
108
+ export function sheetHandleTone(scheme: "light" | "dark") {
109
+ return scheme === "dark" ? sheetHandleToneDark : sheetHandleToneLight;
110
+ }
111
+
61
112
  // ── Overlay frame focus (LC-71) ──────────────────────────────────────────
62
113
  // Radix Dialog.Content / Primer Dialog are tabIndex=-1 and auto-focused on
63
114
  // open. The frame is not a control: UA :focus-visible must not ring the
@@ -189,6 +240,24 @@ export function useIsInDialogRegion(): boolean {
189
240
 
190
241
  const IN_DIALOG_REGION: DialogRegionContextValue = { inDialogRegion: true };
191
242
 
243
+ // ── Sheet body (FZ-11418) ───────────────────────────────────────────────
244
+
245
+ const SheetBodyContext = createContext(false);
246
+
247
+ /**
248
+ * Marks a subtree as a sheet's body (FZ-11418): SheetModal on both platforms
249
+ * and AdaptivePopup's sheet provide it. A sheet has no header bar and no ✕,
250
+ * as tamagui's Sheet has none, so an `OverlayHeader` inside one draws its
251
+ * title as content. A centred dialog or popover opened from a sheet resets
252
+ * it, so its own header keeps its close.
253
+ */
254
+ export const SheetBodyProvider = SheetBodyContext.Provider;
255
+
256
+ /** True inside a sheet's body and not inside a centred overlay opened from it. */
257
+ export function useIsInSheetBody(): boolean {
258
+ return useContext(SheetBodyContext);
259
+ }
260
+
192
261
  // ── Dialog sheet face (LC-269) ──────────────────────────────────────────
193
262
 
194
263
  const DialogSheetFaceContext = createContext(false);
@@ -290,7 +359,7 @@ const DialogContentInner = forwardRef<
290
359
  {...(windowFit as object)}
291
360
  >
292
361
  <DialogRegionContext.Provider value={IN_DIALOG_REGION}>
293
- {children}
362
+ <SheetBodyContext.Provider value={false}>{children}</SheetBodyContext.Provider>
294
363
  </DialogRegionContext.Provider>
295
364
  </Dialog.Content>
296
365
  );
@@ -371,7 +440,7 @@ const AlertDialogContentInner = forwardRef<
371
440
  {...props}
372
441
  >
373
442
  <DialogRegionContext.Provider value={IN_DIALOG_REGION}>
374
- {children}
443
+ <SheetBodyContext.Provider value={false}>{children}</SheetBodyContext.Provider>
375
444
  </DialogRegionContext.Provider>
376
445
  </AlertDialog.Content>
377
446
  );
@@ -429,7 +498,7 @@ export const PopoverContent = forwardRef<TamaguiElement, PopoverContentProps>(
429
498
  {...props}
430
499
  >
431
500
  <Surface painted={false} elevated>
432
- {children}
501
+ <SheetBodyContext.Provider value={false}>{children}</SheetBodyContext.Provider>
433
502
  </Surface>
434
503
  </Popover.Content>
435
504
  );
@@ -78,7 +78,7 @@ describe("screen nesting (LC-159, FZ-7993)", () => {
78
78
  {probe}
79
79
  </ScreenNesting>
80
80
  )),
81
- ).toEqual({ scrolls: true, inset: "$4", capped: false });
81
+ ).toEqual({ scrolls: true, inset: "$4", capped: false, underChrome: 0 });
82
82
  });
83
83
 
84
84
  it("keeps the record's identity while the shell's values hold", () => {
@@ -98,6 +98,6 @@ describe("screen nesting (LC-159, FZ-7993)", () => {
98
98
  expect(seen).toHaveLength(3);
99
99
  expect(seen[1]).toBe(seen[0]);
100
100
  expect(seen[2]).not.toBe(seen[0]);
101
- expect(seen[2]).toEqual({ scrolls: false, inset: null, capped: false });
101
+ expect(seen[2]).toEqual({ scrolls: false, inset: null, capped: false, underChrome: 0 });
102
102
  });
103
103
  });
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  import type { ReactNode } from "react";
15
- import { createContext, useContext, useMemo } from "react";
15
+ import { createContext, useContext, useMemo, useSyncExternalStore } from "react";
16
16
  import { useMedia } from "tamagui";
17
17
 
18
18
  const PageGutterContext = createContext<string | null>(null);
@@ -51,6 +51,18 @@ export interface ParentScreen {
51
51
  inset: string | null;
52
52
  /** A content cap is already applied above. */
53
53
  capped: boolean;
54
+ /**
55
+ * The height of bottom chrome the region runs under (a native tab screen's
56
+ * bar), or 0. A scroll view the nested Screen owns there ends with that
57
+ * clearance and the page's bottom gutter, as a page shell's does (FZ-8640).
58
+ */
59
+ underChrome?: number;
60
+ /**
61
+ * The page shell's bottom edge. A native tab host inside the page's content
62
+ * claims it while it shows a tab, so the system bar sits on the screen's
63
+ * bottom inset and the page drops its own bottom padding under it (FZ-8640).
64
+ */
65
+ holdBottomEdge?: (id: symbol, held: boolean) => void;
54
66
  }
55
67
 
56
68
  const ParentScreenContext = createContext<ParentScreen | null>(null);
@@ -60,9 +72,14 @@ export function ScreenNesting({
60
72
  scrolls,
61
73
  inset,
62
74
  capped,
75
+ underChrome = 0,
76
+ holdBottomEdge,
63
77
  children,
64
78
  }: ParentScreen & { children: ReactNode }) {
65
- const value = useMemo(() => ({ scrolls, inset, capped }), [scrolls, inset, capped]);
79
+ const value = useMemo(
80
+ () => ({ scrolls, inset, capped, underChrome, holdBottomEdge }),
81
+ [scrolls, inset, capped, underChrome, holdBottomEdge],
82
+ );
66
83
  return <ParentScreenContext.Provider value={value}>{children}</ParentScreenContext.Provider>;
67
84
  }
68
85
 
@@ -71,6 +88,42 @@ export function useParentScreen(): ParentScreen | null {
71
88
  return useContext(ParentScreenContext);
72
89
  }
73
90
 
91
+ const edgeOwners = new Set<symbol>();
92
+ const edgeListeners = new Set<() => void>();
93
+
94
+ function subscribeEdgeOwners(listener: () => void) {
95
+ edgeListeners.add(listener);
96
+ return () => {
97
+ edgeListeners.delete(listener);
98
+ };
99
+ }
100
+
101
+ const edgeOwned = () => edgeOwners.size > 0;
102
+ const edgeFree = () => false;
103
+
104
+ /**
105
+ * A native tab host inside a page claims (or releases) the screen's bottom edge.
106
+ * The claim lives here, not in the components package: a Kitchen Sink story
107
+ * renders the host from source while the frame around it comes from the built
108
+ * package, and only this module is shared by both (FZ-8640).
109
+ */
110
+ export function setBottomEdgeOwnedByTabHost(id: symbol, owned: boolean) {
111
+ const was = edgeOwned();
112
+ if (owned) edgeOwners.add(id);
113
+ else edgeOwners.delete(id);
114
+ if (edgeOwned() === was) return;
115
+ for (const listener of edgeListeners) listener();
116
+ }
117
+
118
+ /**
119
+ * True while a native tab host inside a page owns the screen's bottom edge: the
120
+ * system bar sits on the bottom inset, so a host frame around the page pads no
121
+ * bottom inset of its own under it (FZ-8640).
122
+ */
123
+ export function useBottomEdgeOwnedByTabHost(): boolean {
124
+ return useSyncExternalStore(subscribeEdgeOwners, edgeOwned, edgeFree);
125
+ }
126
+
74
127
  /** `$4` → `$-4`. */
75
128
  export function negateSpaceToken(token: string): string {
76
129
  if (token.startsWith("$-")) return `$${token.slice(2)}`;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Ramp roles a bridged palette must respect (FZ-10761), as the theme README
3
+ * states them. Card, ListItem, Button and the field shells ride Tamagui v5's
4
+ * surface templates, whose `color` is one step short of the ramp's end, so
5
+ * inside them `$color` is base step 11 while the page's `$color` is step 12.
6
+ * A palette that parks a muted grey on step 11 inks every title in those
7
+ * components with it.
8
+ */
9
+
10
+ import { describe, expect, it, vi } from "vitest";
11
+
12
+ vi.mock("tamagui", () => ({
13
+ createTamagui: vi.fn((config: Record<string, unknown>) => config),
14
+ }));
15
+
16
+ vi.mock("./animations/index", () => ({ animations: {} }));
17
+
18
+ import { createDefaultThemeConfig } from "./createDefaultThemeConfig";
19
+ import { defaultBaseTheme } from "./defaults";
20
+ import { resolveThemeThroughParents } from "./dedupeInherited";
21
+
22
+ type RawThemes = Record<string, Record<string, string>>;
23
+
24
+ const surfaceComponents = ["Card", "ListItem", "Button", "Input", "SelectTrigger"] as const;
25
+
26
+ function buildThemes(options: Parameters<typeof createDefaultThemeConfig>[0] = {}): RawThemes {
27
+ const config = createDefaultThemeConfig(options) as unknown as {
28
+ tamagui: { themes: RawThemes };
29
+ };
30
+ return config.tamagui.themes;
31
+ }
32
+
33
+ describe("ramp roles (FZ-10761)", () => {
34
+ const themes = buildThemes();
35
+
36
+ for (const scheme of ["light", "dark"] as const) {
37
+ it(`${scheme}: the page inks with step 12, surface components with step 11`, () => {
38
+ const page = themes[scheme];
39
+ expect(page.color).toBe(page.color12);
40
+ for (const component of surfaceComponents) {
41
+ const theme = resolveThemeThroughParents(themes, `${scheme}_${component}`);
42
+ expect(theme.color, `${scheme}_${component}`).toBe(page.color11);
43
+ }
44
+ });
45
+ }
46
+
47
+ it("a muted colour on step 11 becomes every surface component's ink", () => {
48
+ const muted = "#8e8e93";
49
+ const lightPalette = [...defaultBaseTheme.lightPalette];
50
+ lightPalette[10] = muted;
51
+ const bridged = buildThemes({ base: { ...defaultBaseTheme, lightPalette } });
52
+ const ink = bridged.light.color11;
53
+ expect(ink).not.toBe(themes.light.color11);
54
+ expect(bridged.light.color).toBe(themes.light.color);
55
+ for (const component of surfaceComponents) {
56
+ const theme = resolveThemeThroughParents(bridged, `light_${component}`);
57
+ expect(theme.color, `light_${component}`).toBe(ink);
58
+ }
59
+ });
60
+ });
@@ -210,6 +210,8 @@ export interface KnobProps {
210
210
  */
211
211
  containerRadius: { borderRadius: string | number } & CornerSmoothingCarrier;
212
212
  fieldRadius: { borderRadius: string | number } & CornerSmoothingCarrier;
213
+ /** A sheet's top corners (FZ-11418): one radius stop above `containerRadius`, capped the same way. */
214
+ sheetRadius: { borderRadius: string | number } & CornerSmoothingCarrier;
213
215
  /** Size token on web ("$1"); numeric tokens.size value on native (RN-safe). */
214
216
  elevation: string | number | undefined;
215
217
  /**
@@ -67,6 +67,7 @@ const expectedKnobPropKeys: (keyof KnobProps)[] = [
67
67
  "borderRadiusNested",
68
68
  "containerRadius",
69
69
  "fieldRadius",
70
+ "sheetRadius",
70
71
  "elevation",
71
72
  "overlayElevation",
72
73
  "elevationChrome",
@@ -918,6 +919,22 @@ describe("resolveKnobs", () => {
918
919
  }
919
920
  });
920
921
 
922
+ it("sheetRadius sits one stop above containerRadius, capped at the padding (FZ-11418)", () => {
923
+ for (const [borderRadius, sheetPx] of [
924
+ ["none", 0],
925
+ ["small", 14],
926
+ ["medium", 16],
927
+ ["large", 16],
928
+ ["full", 16],
929
+ ] as const) {
930
+ const { knobProps } = resolveKnobs(knobsWith({ borderRadius }));
931
+ const value = knobProps.sheetRadius.borderRadius;
932
+ const px =
933
+ typeof value === "number" ? value : defaultScaleTokens.radius[value.slice(1) as "0"];
934
+ expect(px, borderRadius).toBe(sheetPx);
935
+ }
936
+ });
937
+
921
938
  // ── cornerSmoothing (Axiom 15 OPTICS) ─────────────────────
922
939
 
923
940
  describe("cornerSmoothing knob", () => {
@@ -226,6 +226,16 @@ export function capContainerRadius(borderRadius: Knobs["borderRadius"]): string
226
226
  return radiusPx > paddingPx ? paddingPx : containerRadiusMap[borderRadius];
227
227
  }
228
228
 
229
+ // FZ-11418: a sheet's top corners sit one radius stop above a container's,
230
+ // still capped at the padding, which lands on tamagui's 16pt sheet corner.
231
+ const sheetRadiusStop: Record<Knobs["borderRadius"], Knobs["borderRadius"]> = {
232
+ none: "none",
233
+ small: "medium",
234
+ medium: "large",
235
+ large: "full",
236
+ full: "full",
237
+ };
238
+
229
239
  export function capFieldRadius(borderRadius: Knobs["borderRadius"]): string | number {
230
240
  const token = borderRadiusMap[borderRadius];
231
241
  const radiusPx = getActiveScaleTokens().radius[token.slice(1) as "0" | "2" | "4" | "6" | "12"];
@@ -844,6 +854,7 @@ export function resolveKnobs(
844
854
  const motion = motionFor(knobs.animation);
845
855
 
846
856
  const containerRadiusValue = capContainerRadius(knobs.borderRadius);
857
+ const sheetRadiusValue = capContainerRadius(sheetRadiusStop[knobs.borderRadius]);
847
858
 
848
859
  const { scaleSmoothing, containerSmoothing } = smoothingFor(knobs);
849
860
  const { outlined, smallEdge, borderWidthValue, edge, overlayEdgeWidth, overlayEdge } =
@@ -880,6 +891,7 @@ export function resolveKnobs(
880
891
  // keep the uncapped `borderRadius` fragment.
881
892
  containerRadius: { borderRadius: containerRadiusValue, ...containerSmoothing },
882
893
  fieldRadius: { borderRadius: capFieldRadius(knobs.borderRadius), ...containerSmoothing },
894
+ sheetRadius: { borderRadius: sheetRadiusValue, ...containerSmoothing },
883
895
  elevation: platformElevation(elevationToken),
884
896
  overlayElevation: platformElevation(overlayElevationToken),
885
897
  elevationChrome,
@@ -0,0 +1,202 @@
1
+ /**
2
+ * LC-288 SEVERITY-CHANNEL. The severity ramps (error, warning, success) are
3
+ * reserved for severity: every preset's accent sits at least 30° of OKLCH hue
4
+ * from each of them, in both schemes, read from the resolved tokens. Radix's
5
+ * neighbouring scales sit about 20° apart (red 23°, orange 45°, amber 64°), so
6
+ * under 30° the accent is the severity's own scale or its neighbour.
7
+ */
8
+ import { readFileSync } from "node:fs";
9
+ import { dirname, join } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ import { describe, expect, it, vi } from "vitest";
12
+
13
+ vi.mock("tamagui", () => ({
14
+ createTamagui: vi.fn((config: Record<string, unknown>) => config),
15
+ }));
16
+ vi.mock("./animations/index", () => ({ animations: {} }));
17
+
18
+ import { apcaContrast, contrastRatio, normalizeToHex, relativeLuminance } from "./colorRules";
19
+ import { resolveChartPalette } from "./chartPalette";
20
+ import { createDefaultThemeConfig } from "./createDefaultThemeConfig";
21
+ import { resolveAllThemes } from "./dedupeInherited";
22
+ import { oklab } from "./fillContrast";
23
+ import {
24
+ boldPreset,
25
+ consolePreset,
26
+ defaultPreset,
27
+ densePreset,
28
+ heroPreset,
29
+ roomyPreset,
30
+ storefrontPreset,
31
+ } from "./presets";
32
+
33
+ const minHueDistance = 30;
34
+ const severities = ["error", "warning", "success"] as const;
35
+
36
+ /**
37
+ * Presets that still wear a severity hue, as of 2026-11-03. This list may only
38
+ * shrink: an entry that passes fails the spec until it is removed.
39
+ */
40
+ const baseline: Record<string, string> = {
41
+ ocean: "FZ-9260",
42
+ paper: "FZ-9260",
43
+ };
44
+
45
+ const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "../../../..");
46
+
47
+ function appPresetThemes(): Record<string, string> {
48
+ const source = readFileSync(join(repoRoot, "packages/themes/presets.ts"), "utf8");
49
+ const out: Record<string, string> = {};
50
+ for (const block of source.split(/export const /).slice(1)) {
51
+ const name = block.match(/^(\w+)Preset\b/)?.[1];
52
+ if (!name) continue;
53
+ out[name] = block.match(/\btheme:\s*"([^"]*)"/)?.[1] ?? "";
54
+ }
55
+ return out;
56
+ }
57
+
58
+ const presetThemes: Record<string, string> = {
59
+ default: defaultPreset.theme,
60
+ hero: heroPreset.theme,
61
+ bold: boldPreset.theme,
62
+ dense: densePreset.theme,
63
+ roomy: roomyPreset.theme,
64
+ console: consolePreset.theme,
65
+ storefront: storefrontPreset.theme,
66
+ ...appPresetThemes(),
67
+ };
68
+
69
+ const resolved = resolveAllThemes(
70
+ createDefaultThemeConfig().tamagui.themes as unknown as Record<string, Record<string, unknown>>,
71
+ );
72
+
73
+ function text(value: unknown): string | undefined {
74
+ if (typeof value === "string") return value;
75
+ const val = (value as { val?: unknown } | undefined)?.val;
76
+ return typeof val === "string" ? val : undefined;
77
+ }
78
+
79
+ function hue(color: string | undefined): number {
80
+ const lab = color ? oklab(color) : null;
81
+ if (!lab) throw new Error(`no colour: ${color}`);
82
+ return ((Math.atan2(lab[2], lab[1]) * 180) / Math.PI + 360) % 360;
83
+ }
84
+
85
+ function hueDistance(a: number, b: number): number {
86
+ const d = Math.abs(a - b) % 360;
87
+ return d > 180 ? 360 - d : d;
88
+ }
89
+
90
+ function severityHue(scheme: "light" | "dark", severity: string): number {
91
+ return hue(text(resolved[`${scheme}_${severity}`]?.color9));
92
+ }
93
+
94
+ function accentHue(scheme: "light" | "dark", theme: string): number {
95
+ const scope = resolved[theme ? `${scheme}_${theme}` : scheme] ?? {};
96
+ return hue(text(scope.accentBackground) ?? text(scope.color9));
97
+ }
98
+
99
+ function collisions(preset: string): string[] {
100
+ const out: string[] = [];
101
+ for (const scheme of ["light", "dark"] as const) {
102
+ const accent = accentHue(scheme, presetThemes[preset] as string);
103
+ for (const severity of severities) {
104
+ const d = hueDistance(accent, severityHue(scheme, severity));
105
+ if (d < minHueDistance) out.push(`${scheme} ${severity} ${Math.round(d)}°`);
106
+ }
107
+ }
108
+ return out;
109
+ }
110
+
111
+ describe("LC-288 SEVERITY-CHANNEL", () => {
112
+ it("audits the catalog's and the app's presets", () => {
113
+ expect(Object.keys(presetThemes)).toEqual(
114
+ expect.arrayContaining(["default", "console", "storefront", "ocean", "paper"]),
115
+ );
116
+ });
117
+
118
+ for (const preset of Object.keys(presetThemes)) {
119
+ if (baseline[preset]) {
120
+ it(`${preset} is baselined (${baseline[preset]}) and still collides`, () => {
121
+ expect(collisions(preset)).not.toEqual([]);
122
+ });
123
+ } else {
124
+ it(`${preset}'s accent sits ${minHueDistance}° or more from every severity hue`, () => {
125
+ expect(collisions(preset)).toEqual([]);
126
+ });
127
+ }
128
+ }
129
+
130
+ it("keeps the severities themselves 30° apart in both schemes", () => {
131
+ for (const scheme of ["light", "dark"] as const) {
132
+ const [error, warning, success] = severities.map((s) => severityHue(scheme, s));
133
+ expect(hueDistance(error as number, warning as number)).toBeGreaterThanOrEqual(
134
+ minHueDistance,
135
+ );
136
+ expect(hueDistance(warning as number, success as number)).toBeGreaterThanOrEqual(
137
+ minHueDistance,
138
+ );
139
+ }
140
+ });
141
+
142
+ it("draws warning in amber, not olive, in both schemes", () => {
143
+ for (const scheme of ["light", "dark"] as const) {
144
+ const scope = resolved[`${scheme}_warning`] ?? {};
145
+ for (const step of [9, 11]) {
146
+ const h = hue(text(scope[`color${step}`]));
147
+ expect(h, `${scheme} warning color${step} at ${Math.round(h)}°`).toBeGreaterThan(55);
148
+ expect(h, `${scheme} warning color${step} at ${Math.round(h)}°`).toBeLessThan(90);
149
+ }
150
+ }
151
+ });
152
+
153
+ it("holds light warning ink at 4.5:1 on the page and gives the chart that ink", () => {
154
+ const ink = normalizeToHex(text(resolved.light_warning?.color11) as string) as string;
155
+ const page = normalizeToHex(text(resolved.light?.color2) as string) as string;
156
+ expect(contrastRatio(relativeLuminance(ink), relativeLuminance(page))).toBeGreaterThanOrEqual(
157
+ 4.5,
158
+ );
159
+ expect(hue(ink)).toBeGreaterThan(55);
160
+ expect(hue(ink)).toBeLessThan(72);
161
+ const light = resolveChartPalette({ scheme: "light", identitySolid: "#0e6abe" });
162
+ expect(normalizeToHex(light.semantic.warning)).toBe(ink);
163
+ });
164
+
165
+ for (const severity of severities) {
166
+ it(`draws a ${severity} bar at 3:1 or more on every preset's track (WCAG 1.4.11)`, () => {
167
+ const short: string[] = [];
168
+ for (const scheme of ["light", "dark"] as const) {
169
+ const steps = [9, 10, 11].map((step) =>
170
+ text(resolved[`${scheme}_${severity}`]?.[`color${step}`]),
171
+ );
172
+ for (const [preset, theme] of Object.entries({ ...presetThemes, root: "" })) {
173
+ const scope = resolved[theme ? `${scheme}_${theme}` : scheme] ?? {};
174
+ const track = normalizeToHex(text(scope.color4) as string) as string;
175
+ const raw = text(scope[`${severity}Fill`]);
176
+ expect(steps, `${scheme} ${severity}Fill is one of steps 9 to 11`).toContain(raw);
177
+ const fill = normalizeToHex(raw as string) as string;
178
+ const ratio = contrastRatio(relativeLuminance(fill), relativeLuminance(track));
179
+ if (ratio < 3) short.push(`${scheme} ${preset} ${ratio.toFixed(2)}`);
180
+ }
181
+ }
182
+ expect(short).toEqual([]);
183
+ });
184
+ }
185
+
186
+ it("fills a warning Button with amber step 9 under its dark ink, never a darkened brown", () => {
187
+ for (const scheme of ["light", "dark"] as const) {
188
+ const button = resolved[`${scheme}_warning_Button`] ?? {};
189
+ const fill = normalizeToHex(text(button.background) as string) as string;
190
+ const ink = normalizeToHex(text(button.color) as string) as string;
191
+ const nine = normalizeToHex(text(resolved[`${scheme}_warning`]?.color9) as string);
192
+ expect(fill, `${scheme} warning Button fill`).toBe(nine);
193
+ expect(relativeLuminance(ink), `${scheme} warning label is the dark ink`).toBeLessThan(
194
+ relativeLuminance(fill),
195
+ );
196
+ expect(contrastRatio(relativeLuminance(ink), relativeLuminance(fill))).toBeGreaterThanOrEqual(
197
+ 4.5,
198
+ );
199
+ expect(Math.abs(apcaContrast(ink, fill))).toBeGreaterThanOrEqual(60);
200
+ }
201
+ });
202
+ });
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as theme from "../index";
3
+ import {
4
+ sheetGrabber,
5
+ sheetHandle,
6
+ sheetHandleTone,
7
+ sheetHandleWidthRatio,
8
+ sheetHandleZone,
9
+ } from "./overlaySurfaces";
10
+
11
+ describe("sheetHandle (FZ-11418, tamagui's Sheet.Handle)", () => {
12
+ it("is tamagui's pill: 10pt tall, 30% of the sheet wide, fully round", () => {
13
+ expect(sheetHandle).toMatchObject({
14
+ height: 10,
15
+ width: `${sheetHandleWidthRatio * 100}%`,
16
+ borderRadius: 100,
17
+ alignSelf: "center",
18
+ });
19
+ expect(sheetHandleWidthRatio).toBe(0.3);
20
+ });
21
+
22
+ it("paints the page ground at half opacity, as tamagui's does", () => {
23
+ expect(sheetHandle).toMatchObject({ backgroundColor: "$background", opacity: 0.5 });
24
+ });
25
+
26
+ it("sits detached above the frame: no margin pulls it onto the frame, and $2 separates them", () => {
27
+ expect(sheetHandle.marginTop).toBe(0);
28
+ expect(sheetHandle.marginBottom).toBe("$2");
29
+ });
30
+
31
+ it("gives a native finger room above the pill", () => {
32
+ expect(sheetHandleZone).toMatchObject({ alignSelf: "stretch", alignItems: "center" });
33
+ expect(sheetHandleZone.paddingTop).toBeGreaterThan(0);
34
+ });
35
+
36
+ it("is a different recipe from FloatingPanel's grabber, which keeps its own look", () => {
37
+ expect(sheetHandle).toBeDefined();
38
+ expect(sheetHandle).not.toEqual(sheetGrabber);
39
+ expect(sheetGrabber).toMatchObject({ width: 36, height: 5 });
40
+ });
41
+
42
+ it("is exported from the package", () => {
43
+ expect(theme.sheetHandle).toBeDefined();
44
+ expect(theme.sheetHandle).toBe(sheetHandle);
45
+ expect(theme.sheetHandleZone).toBe(sheetHandleZone);
46
+ expect(theme.sheetHandleWidthRatio).toBe(sheetHandleWidthRatio);
47
+ });
48
+
49
+ it("keeps tamagui's tone in light and the overlay fill in dark, so the pill reads on a dark scrim", () => {
50
+ expect(sheetHandleTone("light")).toEqual({ backgroundColor: "$background", opacity: 0.5 });
51
+ expect(sheetHandleTone("dark")).toEqual({ backgroundColor: "$color5", opacity: 1 });
52
+ expect(theme.sheetHandleTone).toBe(sheetHandleTone);
53
+ });
54
+ });
@@ -34,3 +34,13 @@ export const tintHueNames = new Set([
34
34
  "violet",
35
35
  "yellow",
36
36
  ]);
37
+
38
+ /**
39
+ * The scheme of a tint theme (`light_purple`) or one of its sub-themes
40
+ * (`dark_red_Button`), else undefined.
41
+ */
42
+ export function tintThemeScheme(name: string): "light" | "dark" | undefined {
43
+ const [scheme, hue] = name.split("_");
44
+ if (scheme !== "light" && scheme !== "dark") return undefined;
45
+ return hue && tintHueNames.has(hue) ? scheme : undefined;
46
+ }
@@ -23,8 +23,8 @@ export const v3TokenRoles = {
23
23
  grabColor: "color8",
24
24
  good: "green9",
25
25
  goodSoft: "green3",
26
- warning: "yellow9",
27
- warningSoft: "yellow3",
26
+ warning: "warningMark",
27
+ warningSoft: "warningSoft",
28
28
  critical: "red9",
29
29
  criticalSoft: "red3",
30
30
  info: "blue9",
@@ -22,7 +22,7 @@ export { clampSurfaceSize, compareSizeTokens, sizeTokenBelow, sizeTokenStep, siz
22
22
  export type { SurfaceIntent, SurfaceSize } from "./theme/Surface";
23
23
  export { controlTierDisabled, controlTierPaint, controlTierWash, controlTrackFill, isDarkThemeName, } from "./theme/controlTiers";
24
24
  export type { ControlTier, ControlTierPaint } from "./theme/controlTiers";
25
- export { AlertDialogContent, AlertDialogOverlay, DialogContent, DialogOverlay, DialogRegionContext, DialogSheetFaceProvider, DialogShowFocus, overlayScrim, PopoverContent, sheetGrabber, sheetGrabberClearance, sheetGrabberZone, useDialogRegionContext, useDialogSheetFace, useIsInDialogRegion, } from "./theme/overlaySurfaces";
25
+ export { AlertDialogContent, AlertDialogOverlay, DialogContent, DialogOverlay, DialogRegionContext, DialogSheetFaceProvider, DialogShowFocus, overlayScrim, PopoverContent, sheetGrabber, sheetGrabberClearance, sheetGrabberZone, sheetHandle, sheetHandleTone, sheetHandleWidthRatio, sheetHandleZone, SheetBodyProvider, useDialogRegionContext, useDialogSheetFace, useIsInDialogRegion, useIsInSheetBody, } from "./theme/overlaySurfaces";
26
26
  export type { DialogContentProps, DialogRegionContextValue } from "./theme/overlaySurfaces";
27
27
  export { boldPreset, consolePreset, defaultPreset, densePreset, heroPreset, roomyPreset, storefrontPreset, } from "./theme/presets";
28
28
  export { IntentContext, solidButtonIntents, solidPaletteThemes, useIntentContext, useResolvedKnobs, } from "./theme/useResolvedKnobs";
@@ -42,7 +42,7 @@ export { ensureHairlineFallback, hairline, hairlineBorderWidth, hairlineFallback
42
42
  export { compositeFocusRingCss, ensureCompositeFocusRing, ensureKeyboardModalityTracking, focusOnOpen, keyboardFocusRingProps, wasKeyboardFocus, } from "./keyboardFocusRing";
43
43
  export { CLOCK_TIME, formatAbsoluteDate, formatAbsoluteDateTime, formatCalendarDate, formatDayLong, formatDayOfMonth, formatMonthYear, formatRelativeTimestamp, formatTimeOfDay, getMonthNames, getWeekdayNames, ISO_DATE_ONLY, parseCalendarDate, } from "./dates";
44
44
  export type { AbsoluteDateFormatOptions, CalendarDateShape, DateInput, DayLongFormatOptions, MonthYearFormatOptions, TimeOfDayFormatOptions, WeekdayNamesOptions, } from "./dates";
45
- export { menuRowChecked, menuRowCheckGlyph, menuRowCheckInk, menuRowFrame, menuRowIconGlyph, resolveMenuRowCheckInk, useMenuRowCheckInk, } from "./menuRow";
45
+ export { menuRowActive, menuRowChecked, menuRowCheckGlyph, menuRowCheckInk, menuRowFrame, menuRowIconGlyph, resolveMenuRowCheckInk, useMenuRowCheckInk, } from "./menuRow";
46
46
  export type { MenuRowGlyph } from "./menuRow";
47
47
  export { currencyAffix, formatCurrency, formatNumber, formatPercent, resolveCurrencyCode, } from "./numbers";
48
48
  export type { CurrencyAffix, CurrencyFormatOptions, NumberFormatOptions, NumberInput, PercentFormatOptions, } from "./numbers";
@@ -70,7 +70,7 @@ export { Anchor, Paragraph, SizableText, Text } from "./theme/Text";
70
70
  export type { AnchorProps, ParagraphProps, SizableTextProps, TextProps } from "./theme/Text";
71
71
  export { H1, H2, H3, H4, H5, H6, Heading } from "./theme/Heading";
72
72
  export type { HeadingProps } from "./theme/Heading";
73
- export { negateSpaceToken, PageGutter, ScreenNesting, usePageGutter, useParentScreen, usePhoneTableBleed, } from "./theme/pageGutter";
73
+ export { negateSpaceToken, PageGutter, ScreenNesting, setBottomEdgeOwnedByTabHost, useBottomEdgeOwnedByTabHost, usePageGutter, useParentScreen, usePhoneTableBleed, } from "./theme/pageGutter";
74
74
  export type { PageGutterProps, ParentScreen, PhoneTableBleed } from "./theme/pageGutter";
75
75
  export { dynamicTypeFit, effectiveFontScale, headingMaxFontScale, maxFontScaleToFit, } from "./theme/dynamicType";
76
76
  export { animationConfig as nativeAnimationConfig } from "./theme/animations/reactNative";