@multiplatform.one/components 10.1.2 → 10.1.3

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 (102) hide show
  1. package/dist/cjs/layouts/timeline.cjs +0 -1
  2. package/dist/cjs/layouts/timeline.native.cjs +0 -1
  3. package/dist/cjs/layouts/timeline.native.js +0 -1
  4. package/dist/cjs/layouts/timeline.native.js.map +1 -1
  5. package/dist/cjs/views/Calendar.cjs +54 -76
  6. package/dist/cjs/views/Calendar.native.cjs +54 -76
  7. package/dist/cjs/views/Calendar.native.js +54 -76
  8. package/dist/cjs/views/Calendar.native.js.map +1 -1
  9. package/dist/cjs/views/Gantt.cjs +185 -69
  10. package/dist/cjs/views/Gantt.native.cjs +190 -72
  11. package/dist/cjs/views/Gantt.native.js +190 -72
  12. package/dist/cjs/views/Gantt.native.js.map +1 -1
  13. package/dist/cjs/views/GanttDateGrip.cjs +20 -14
  14. package/dist/cjs/views/GanttDateGrip.native.cjs +24 -14
  15. package/dist/cjs/views/GanttDateGrip.native.js +24 -14
  16. package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
  17. package/dist/cjs/views/GanttGripDot.cjs +43 -0
  18. package/dist/cjs/views/GanttGripDot.native.cjs +46 -0
  19. package/dist/cjs/views/GanttGripDot.native.js +48 -0
  20. package/dist/cjs/views/GanttGripDot.native.js.map +1 -0
  21. package/dist/cjs/views/eventTint.cjs +242 -0
  22. package/dist/cjs/views/eventTint.native.cjs +346 -0
  23. package/dist/cjs/views/eventTint.native.js +348 -0
  24. package/dist/cjs/views/eventTint.native.js.map +1 -0
  25. package/dist/esm/layouts/timeline.mjs +0 -1
  26. package/dist/esm/layouts/timeline.mjs.map +1 -1
  27. package/dist/esm/layouts/timeline.native.js +0 -1
  28. package/dist/esm/layouts/timeline.native.js.map +1 -1
  29. package/dist/esm/views/Calendar.mjs +53 -75
  30. package/dist/esm/views/Calendar.mjs.map +1 -1
  31. package/dist/esm/views/Calendar.native.js +53 -75
  32. package/dist/esm/views/Calendar.native.js.map +1 -1
  33. package/dist/esm/views/Gantt.mjs +186 -70
  34. package/dist/esm/views/Gantt.mjs.map +1 -1
  35. package/dist/esm/views/Gantt.native.js +191 -73
  36. package/dist/esm/views/Gantt.native.js.map +1 -1
  37. package/dist/esm/views/GanttDateGrip.mjs +21 -15
  38. package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
  39. package/dist/esm/views/GanttDateGrip.native.js +25 -15
  40. package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
  41. package/dist/esm/views/GanttGripDot.mjs +24 -0
  42. package/dist/esm/views/GanttGripDot.mjs.map +1 -0
  43. package/dist/esm/views/GanttGripDot.native.js +25 -0
  44. package/dist/esm/views/GanttGripDot.native.js.map +1 -0
  45. package/dist/esm/views/eventTint.mjs +196 -0
  46. package/dist/esm/views/eventTint.mjs.map +1 -0
  47. package/dist/esm/views/eventTint.native.js +298 -0
  48. package/dist/esm/views/eventTint.native.js.map +1 -0
  49. package/dist/jsx/layouts/timeline.mjs +0 -1
  50. package/dist/jsx/layouts/timeline.mjs.map +1 -1
  51. package/dist/jsx/layouts/timeline.native.cjs +0 -1
  52. package/dist/jsx/layouts/timeline.native.js +0 -1
  53. package/dist/jsx/layouts/timeline.native.js.map +1 -1
  54. package/dist/jsx/views/Calendar.mjs +53 -75
  55. package/dist/jsx/views/Calendar.mjs.map +1 -1
  56. package/dist/jsx/views/Calendar.native.cjs +54 -76
  57. package/dist/jsx/views/Calendar.native.js +54 -76
  58. package/dist/jsx/views/Calendar.native.js.map +1 -1
  59. package/dist/jsx/views/Gantt.mjs +186 -70
  60. package/dist/jsx/views/Gantt.mjs.map +1 -1
  61. package/dist/jsx/views/Gantt.native.cjs +190 -72
  62. package/dist/jsx/views/Gantt.native.js +190 -72
  63. package/dist/jsx/views/Gantt.native.js.map +1 -1
  64. package/dist/jsx/views/GanttDateGrip.mjs +21 -15
  65. package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
  66. package/dist/jsx/views/GanttDateGrip.native.cjs +24 -14
  67. package/dist/jsx/views/GanttDateGrip.native.js +24 -14
  68. package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
  69. package/dist/jsx/views/GanttGripDot.mjs +24 -0
  70. package/dist/jsx/views/GanttGripDot.mjs.map +1 -0
  71. package/dist/jsx/views/GanttGripDot.native.cjs +46 -0
  72. package/dist/jsx/views/GanttGripDot.native.js +48 -0
  73. package/dist/jsx/views/GanttGripDot.native.js.map +1 -0
  74. package/dist/jsx/views/eventTint.mjs +196 -0
  75. package/dist/jsx/views/eventTint.mjs.map +1 -0
  76. package/dist/jsx/views/eventTint.native.cjs +346 -0
  77. package/dist/jsx/views/eventTint.native.js +348 -0
  78. package/dist/jsx/views/eventTint.native.js.map +1 -0
  79. package/package.json +7 -7
  80. package/src/hoverTouchPath.coarse.spec.tsx +28 -4
  81. package/src/layouts/timeline.replyInset.spec.tsx +72 -22
  82. package/src/layouts/timeline.tsx +0 -1
  83. package/src/views/Calendar.eventFill.spec.tsx +44 -9
  84. package/src/views/Calendar.tsx +23 -31
  85. package/src/views/Gantt.barInk.spec.tsx +257 -0
  86. package/src/views/Gantt.grips.spec.tsx +226 -0
  87. package/src/views/Gantt.tint.palette.spec.ts +288 -0
  88. package/src/views/Gantt.tsx +224 -65
  89. package/src/views/GanttDateGrip.native.spec.tsx +8 -0
  90. package/src/views/GanttDateGrip.tsx +28 -17
  91. package/src/views/GanttGripDot.tsx +36 -0
  92. package/src/views/dataIdentity.spec.tsx +29 -13
  93. package/src/views/eventTint.ts +305 -0
  94. package/types/layouts/timeline.d.ts.map +1 -1
  95. package/types/views/Calendar.d.ts.map +1 -1
  96. package/types/views/Gantt.d.ts.map +1 -1
  97. package/types/views/GanttDateGrip.d.ts +7 -0
  98. package/types/views/GanttDateGrip.d.ts.map +1 -1
  99. package/types/views/GanttGripDot.d.ts +9 -0
  100. package/types/views/GanttGripDot.d.ts.map +1 -0
  101. package/types/views/eventTint.d.ts +72 -0
  102. package/types/views/eventTint.d.ts.map +1 -0
@@ -0,0 +1,226 @@
1
+ import { act, cleanup } from "@testing-library/react";
2
+ import { atomicStyle, renderWithProviders } from "@multiplatform.one/test-utils";
3
+ import { afterEach, describe, expect, it, vi } from "vitest";
4
+ import { GanttView } from "./Gantt";
5
+
6
+ afterEach(cleanup);
7
+ const day = (n: number) => new Date(2026, 2, n);
8
+
9
+ function fiberProps(node: Element, has: string): Record<string, any> {
10
+ const key = Object.keys(node).find((k) => k.startsWith("__reactFiber$"));
11
+ let fiber = key ? (node as any)[key] : null;
12
+ while (fiber && fiber.memoizedProps?.[has] === undefined) fiber = fiber.return;
13
+ return fiber?.memoizedProps ?? {};
14
+ }
15
+
16
+ function scrollerProps(node: Element): Record<string, any> {
17
+ const key = Object.keys(node).find((k) => k.startsWith("__reactFiber$"));
18
+ let fiber = key ? (node as any)[key] : null;
19
+ while (
20
+ fiber &&
21
+ !(
22
+ typeof fiber.memoizedProps?.onScroll === "function" &&
23
+ typeof fiber.memoizedProps?.onLayout === "function" &&
24
+ fiber.memoizedProps?.horizontal === true &&
25
+ "flex" in fiber.memoizedProps
26
+ )
27
+ )
28
+ fiber = fiber.return;
29
+ return fiber?.memoizedProps ?? {};
30
+ }
31
+
32
+ function setup() {
33
+ const view = renderWithProviders(
34
+ <GanttView
35
+ tasks={[
36
+ { id: "policy", title: "Effective policy", start: day(4) },
37
+ { id: "contract", title: "Prior contract", start: day(2), end: day(9) },
38
+ ]}
39
+ initialDate={day(1)}
40
+ onIntervalChange={vi.fn()}
41
+ />,
42
+ );
43
+ const glyphs = (row: string) =>
44
+ Array.from(
45
+ view.container.querySelectorAll(`[data-gantt-grip-of="${row}"] [data-gantt-date-grip-glyph]`),
46
+ );
47
+ const opacities = (row: string) =>
48
+ glyphs(row).map((glyph) => {
49
+ const opacity = atomicStyle(glyph).opacity;
50
+ return opacity === "1" ? 1 : opacity === "0" ? 0 : Number.NaN;
51
+ });
52
+ const bar = (row: string) =>
53
+ view.container.querySelector(`[data-gantt-bar="${row}"]`) as HTMLElement;
54
+ return { view, glyphs, opacities, bar };
55
+ }
56
+
57
+ describe("Gantt endpoint grips (FZ-9366)", () => {
58
+ it("draws no grip at rest; the fade alone marks an open end", () => {
59
+ const { glyphs, opacities, bar } = setup();
60
+ expect(glyphs("policy").length).toBe(2);
61
+ expect(glyphs("contract").length).toBe(2);
62
+ expect(opacities("policy")).toEqual([0, 0]);
63
+ expect(opacities("contract")).toEqual([0, 0]);
64
+ expect(bar("policy").querySelector('[data-gantt-open-fade="end"]')).not.toBeNull();
65
+ });
66
+
67
+ it("shows the grips of the focused bar only", () => {
68
+ const { opacities, bar } = setup();
69
+ act(() => bar("contract").focus());
70
+ expect(opacities("contract")).toEqual([1, 1]);
71
+ expect(opacities("policy")).toEqual([0, 0]);
72
+ });
73
+
74
+ it("a keyboard-focused grip shows itself while its bar is at rest", () => {
75
+ const { view, opacities } = setup();
76
+ const grip = view.container.querySelector(
77
+ '[data-gantt-grip-of="policy"][data-gantt-date-grip="end"]',
78
+ ) as HTMLElement;
79
+ act(() => grip.focus());
80
+ expect(opacities("policy")).toEqual([0, 1]);
81
+ });
82
+
83
+ it("both grips are dots on opposite corners, ringed in the bar colour, clear of the label", () => {
84
+ const { view, glyphs, bar } = setup();
85
+ act(() => bar("contract").focus());
86
+ expect(dotBoxes(bar("contract"), glyphs("contract"))).toSatisfy(cornersClearOfLabel);
87
+ const fill = bar("contract")
88
+ .querySelector("[data-gantt-bar-fill]")!
89
+ .getAttribute("data-gantt-bar-fill");
90
+ for (const glyph of glyphs("contract"))
91
+ expect(fiberProps(glyph, "borderColor").borderColor).toBe(fill);
92
+ expect(view.container.querySelectorAll("[data-gantt-resize-handle]")).toHaveLength(0);
93
+ });
94
+
95
+ it("with drag on, a bounded bar takes the same corner dots and nothing else", () => {
96
+ const view = renderWithProviders(
97
+ <GanttView
98
+ tasks={[{ id: "build", title: "Implementation", start: day(2), end: day(12) }]}
99
+ initialDate={day(1)}
100
+ onItemMove={vi.fn()}
101
+ />,
102
+ );
103
+ const target = view.container.querySelector('[data-gantt-bar="build"]') as HTMLElement;
104
+ const handles = Array.from(target.querySelectorAll("[data-gantt-resize-handle]"));
105
+ expect(handles).toHaveLength(2);
106
+ for (const handle of handles) {
107
+ expect(fiberProps(handle, "cursor").backgroundColor).toBeUndefined();
108
+ expect(fiberProps(handle, "cursor").opacity).toBeUndefined();
109
+ }
110
+ const dots = handles.map((h) => h.querySelector("[data-gantt-date-grip-glyph]")!);
111
+ act(() => target.focus());
112
+ expect(dotBoxes(target, dots)).toSatisfy(cornersClearOfLabel);
113
+ });
114
+
115
+ it.each([
116
+ ["an open-start interval", "prior", { onIntervalChange: vi.fn() }],
117
+ ["a dragged bar scrolled past its start", "early", { onItemMove: vi.fn() }],
118
+ ] as const)("%s keeps each grip dot's box inside the scroll viewport", (_, id, handlers) => {
119
+ const view = renderWithProviders(
120
+ <GanttView
121
+ tasks={[
122
+ { id: "prior", title: "Prior contract", end: day(9) },
123
+ { id: "early", title: "Early build", start: day(-40), end: day(6) },
124
+ ]}
125
+ initialDate={day(1)}
126
+ {...handlers}
127
+ />,
128
+ );
129
+ const chart = view.container.querySelector("[data-gantt-chart]")!;
130
+ const bar = view.container.querySelector(`[data-gantt-bar="${id}"]`) as HTMLElement;
131
+ const early = view.container.querySelector('[data-gantt-bar="early"]')!;
132
+ const offset = Number(fiberProps(early, "width").left) + 30;
133
+ const viewport = { left: offset, right: offset + 400 };
134
+ const event = (nativeEvent: unknown) => ({ nativeEvent, stopPropagation() {}, persist() {} });
135
+ act(() => bar.focus());
136
+ act(() => {
137
+ scrollerProps(chart).onLayout(event({ layout: { width: 400 } }));
138
+ scrollerProps(chart).onScroll(event({ contentOffset: { x: offset } }));
139
+ });
140
+ const barLeft = Number(fiberProps(bar, "width").left);
141
+ const dots = [
142
+ ...Array.from(
143
+ view.container.querySelectorAll(
144
+ `[data-gantt-grip-of="${id}"] [data-gantt-date-grip-glyph]`,
145
+ ),
146
+ ),
147
+ ...Array.from(
148
+ bar.querySelectorAll("[data-gantt-resize-handle] [data-gantt-date-grip-glyph]"),
149
+ ),
150
+ ];
151
+ expect(dots.length).toBeGreaterThan(0);
152
+ for (const dot of dots) {
153
+ const own = fiberProps(dot, "borderRadius");
154
+ const holder = dot.parentElement!;
155
+ const handle = holder.hasAttribute("data-gantt-resize-handle")
156
+ ? fiberProps(holder, "cursor")
157
+ : null;
158
+ const origin = handle
159
+ ? barLeft + (handle.left === 0 ? 0 : Number(fiberProps(bar, "width").width) - handle.width)
160
+ : Number.parseFloat((holder as HTMLElement).style.left);
161
+ const left = origin + Number(own.left);
162
+ const label = `${id} ${dot.getAttribute("data-gantt-date-grip-glyph")}`;
163
+ expect(left, label).toBeGreaterThanOrEqual(viewport.left);
164
+ expect(left + Number(own.width), label).toBeLessThanOrEqual(viewport.right);
165
+ }
166
+ });
167
+ });
168
+
169
+ interface Box {
170
+ left: number;
171
+ top: number;
172
+ right: number;
173
+ bottom: number;
174
+ }
175
+
176
+ function dotBoxes(bar: HTMLElement, dots: Element[]) {
177
+ const { left: barLeft, width: barWidth, height: barHeight } = fiberProps(bar, "width");
178
+ const barTop = Number(fiberProps(bar, "top").top);
179
+ const label = bar.querySelector("[data-gantt-bar-ink]")!;
180
+ const pad = Number(fiberProps(label, "paddingHorizontal").paddingHorizontal);
181
+ const boxes = dots.map((dot) => {
182
+ const own = fiberProps(dot, "borderRadius");
183
+ const holder = dot.parentElement!;
184
+ const handle = holder.hasAttribute("data-gantt-resize-handle");
185
+ const holderProps = handle ? fiberProps(holder, "cursor") : null;
186
+ const originX = handle
187
+ ? holderProps!.left === 0
188
+ ? 0
189
+ : Number(barWidth) - Number(holderProps!.width)
190
+ : Number.parseFloat(fiberProps(holder, "style").style.left) - Number(barLeft);
191
+ const originY = handle ? 0 : -barTop;
192
+ const left = originX + Number(own.left);
193
+ const top = originY + Number(own.top);
194
+ return {
195
+ edge: dot.getAttribute("data-gantt-date-grip-glyph"),
196
+ shown: atomicStyle(dot).opacity === "1",
197
+ box: { left, top, right: left + Number(own.width), bottom: top + Number(own.height) },
198
+ };
199
+ });
200
+ return {
201
+ boxes,
202
+ bar: { left: 0, top: 0, right: Number(barWidth), bottom: Number(barHeight) },
203
+ label: { left: pad, top: 0, right: Number(barWidth) - pad, bottom: Number(barHeight) },
204
+ };
205
+ }
206
+
207
+ function cornersClearOfLabel({
208
+ boxes,
209
+ bar,
210
+ label,
211
+ }: {
212
+ boxes: { edge: string | null; shown: boolean; box: Box }[];
213
+ bar: Box;
214
+ label: Box;
215
+ }) {
216
+ const overlaps = (a: Box, b: Box) =>
217
+ a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
218
+ const centre = (b: Box) => ({ x: (b.left + b.right) / 2, y: (b.top + b.bottom) / 2 });
219
+ const start = boxes.find((b) => b.edge === "start")!;
220
+ const end = boxes.find((b) => b.edge === "end")!;
221
+ expect(boxes.every((b) => b.shown)).toBe(true);
222
+ expect(centre(start.box)).toEqual({ x: bar.left, y: bar.bottom });
223
+ expect(centre(end.box)).toEqual({ x: bar.right, y: bar.top });
224
+ for (const { box } of boxes) expect(overlaps(box, label)).toBe(false);
225
+ return true;
226
+ }
@@ -0,0 +1,288 @@
1
+ /**
2
+ * FZ-9366: in dark an event paints its hue's own ramp step, so a yellow stays
3
+ * gold and the ink stays near-white; a colour with no ramp blends instead.
4
+ */
5
+ import * as Colors from "@tamagui/colors";
6
+ import {
7
+ aaTextContrastRatio,
8
+ apcaContrast,
9
+ contrastRatio,
10
+ createDefaultThemeConfig,
11
+ fillLabelLc,
12
+ normalizeToHex,
13
+ relativeLuminance,
14
+ resolveChartPalette,
15
+ } from "@multiplatform.one/theme";
16
+ import { describe, expect, it } from "vitest";
17
+ import {
18
+ blendOver,
19
+ EVENT_GHOST_DARK,
20
+ EVENT_REST_STANDOFF,
21
+ EVENT_STRIP_FLOOR,
22
+ EVENT_STRIP_STEP,
23
+ eventLabelInk,
24
+ eventPaint,
25
+ eventRamp,
26
+ eventSolid,
27
+ eventStripPaint,
28
+ eventTints,
29
+ type EventThemeValues,
30
+ } from "./eventTint";
31
+
32
+ const themes = createDefaultThemeConfig({}).tamagui.themes as unknown as Record<
33
+ string,
34
+ EventThemeValues
35
+ >;
36
+ const hues = ["", "_blue", "_gray", "_green", "_orange", "_pink", "_purple", "_red", "_yellow"];
37
+ const intents = ["success", "warning", "error"] as const;
38
+ const weekendBand = 0.55;
39
+
40
+ const hex = (theme: EventThemeValues, token: string) => {
41
+ const key = token.startsWith("$") ? token.slice(1) : token;
42
+ const raw = theme[key]?.val ?? (token.startsWith("$") ? undefined : token);
43
+ const out = typeof raw === "string" ? normalizeToHex(raw) : null;
44
+ if (!out) throw new Error(`no ${token}`);
45
+ return out;
46
+ };
47
+ const ratio = (a: string, b: string) => contrastRatio(relativeLuminance(a), relativeLuminance(b));
48
+ const paletteFills = [
49
+ ...resolveChartPalette({ scheme: "dark" }).categorical,
50
+ ...resolveChartPalette({ scheme: "light" }).categorical,
51
+ ];
52
+
53
+ function barFills(hue: string) {
54
+ const base = themes[`dark${hue}`]!;
55
+ const intentFills = intents.map((intent) => {
56
+ const theme = themes[`dark${hue}_${intent}`] ?? themes[`dark_${intent}`];
57
+ if (!theme) throw new Error(`no dark${hue}_${intent}`);
58
+ return { name: intent, fill: "$color-9", theme };
59
+ });
60
+ return [...paletteFills.map((fill) => ({ name: fill, fill, theme: base })), ...intentFills];
61
+ }
62
+
63
+ function fillsFor(scheme: "light" | "dark", hue: string) {
64
+ if (scheme === "dark") return barFills(hue);
65
+ const base = themes[`light${hue}`]!;
66
+ return [
67
+ ...paletteFills.map((fill) => ({ name: fill, fill, theme: base })),
68
+ ...intents.map((intent) => ({
69
+ name: intent,
70
+ fill: "$color-9",
71
+ theme: themes[`light${hue}_${intent}`] ?? themes[`light_${intent}`]!,
72
+ })),
73
+ ];
74
+ }
75
+
76
+ describe("dark events paint their hue's ramp (FZ-9366)", () => {
77
+ it("every palette colour finds its ramp; a foreign hex does not", () => {
78
+ for (const fill of paletteFills) expect(eventRamp({}, fill, true), fill).not.toBeNull();
79
+ expect(eventRamp({}, "#f59e0b", true)).toBeNull();
80
+ const amber = eventPaint({}, Colors.amberDark.amber9, "rest", {
81
+ dark: true,
82
+ surface: "#111111",
83
+ });
84
+ expect(amber).toBe(normalizeToHex(Colors.amberDark.amber6));
85
+ });
86
+
87
+ for (const hue of hues)
88
+ it(`dark${hue}: every bar stands off the canvas and the weekend band`, () => {
89
+ const base = themes[`dark${hue}`]!;
90
+ const canvas = hex(base, "$background");
91
+ const weekend = blendOver(hex(base, "$color-3"), canvas, weekendBand)!;
92
+ for (const { name, fill, theme } of barFills(hue)) {
93
+ const rest = eventPaint(theme, fill, "rest", { dark: true, surface: canvas })!;
94
+ const ghost = eventPaint(theme, fill, "ghost", { dark: true, surface: canvas })!;
95
+ expect(ratio(rest, canvas), `${name} vs canvas`).toBeGreaterThanOrEqual(1.5);
96
+ expect(ratio(rest, weekend), `${name} vs weekend`).toBeGreaterThanOrEqual(1.4);
97
+ expect(ratio(ghost, canvas), `${name} ghost vs canvas`).toBeGreaterThanOrEqual(1.2);
98
+ expect(ghost, `${name} ghost is its rest hue, fainter`).toBe(
99
+ blendOver(rest, canvas, EVENT_GHOST_DARK),
100
+ );
101
+ }
102
+ });
103
+
104
+ for (const hue of hues)
105
+ it(`dark${hue}: Calendar titles take their hue's 12 at 4.5:1 or better`, () => {
106
+ const base = themes[`dark${hue}`]!;
107
+ const canvas = hex(base, "$background");
108
+ for (const fill of paletteFills)
109
+ for (const state of ["rest", "selected"] as const) {
110
+ const paint = eventPaint(base, fill, state, { dark: true, surface: canvas })!;
111
+ const ink = eventLabelInk(base, fill, [paint], true);
112
+ expect(ink, `${fill} ${state}`).toBe(normalizeToHex(eventRamp(base, fill, true)!(12)!));
113
+ expect(ratio(ink, paint), `${fill} ${state}`).toBeGreaterThanOrEqual(aaTextContrastRatio);
114
+ }
115
+ });
116
+ });
117
+
118
+ describe("the progress strip holds one step and 3:1 on its bar (FZ-9366)", () => {
119
+ it("pins the light selected blue strip at the 3:1 floor it sits on", () => {
120
+ const base = themes.light_blue!;
121
+ const canvas = hex(base, "$background");
122
+ const blue = Colors.blue.blue9;
123
+ const strip = eventStripPaint(base, blue, { dark: false, surface: canvas })!;
124
+ const selected = eventPaint(base, blue, "selected", { dark: false, surface: canvas })!;
125
+ expect([strip, selected]).toEqual(["#0d74ce", "#9dd4ff"]);
126
+ expect(ratio(strip, selected)).toBeCloseTo(3.02, 2);
127
+ });
128
+
129
+ for (const hue of hues)
130
+ it(`light${hue}: yellow12 lightens its rest tint until its strip clears 3:1`, () => {
131
+ const base = themes[`light${hue}`]!;
132
+ const canvas = hex(base, "$background");
133
+ const fill = Colors.yellow.yellow12;
134
+ expect(resolveChartPalette({ scheme: "light" }).categorical).toContain(fill);
135
+ const strip = eventStripPaint(base, fill, { dark: false, surface: canvas })!;
136
+ const flat = blendOver(fill, canvas, eventTints.light.rest)!;
137
+ expect(ratio(strip, flat), `flat ${flat}`).toBeLessThan(EVENT_STRIP_FLOOR);
138
+ const rest = eventPaint(base, fill, "rest", { dark: false, surface: canvas })!;
139
+ const selected = eventPaint(base, fill, "selected", { dark: false, surface: canvas })!;
140
+ expect(ratio(strip, rest), `rest ${rest}`).toBeGreaterThanOrEqual(EVENT_STRIP_FLOOR);
141
+ expect(ratio(strip, selected), `selected ${selected}`).toBeGreaterThanOrEqual(
142
+ EVENT_STRIP_FLOOR,
143
+ );
144
+ expect(ratio(rest, canvas), `rest ${rest} vs canvas`).toBeGreaterThanOrEqual(
145
+ EVENT_REST_STANDOFF,
146
+ );
147
+ expect(ratio(rest, canvas)).toBeLessThan(ratio(flat, canvas));
148
+ expect(ratio(selected, rest), "selection still deepens").toBeGreaterThan(1);
149
+ });
150
+
151
+ for (const scheme of ["light", "dark"] as const)
152
+ for (const hue of hues)
153
+ it(`${scheme}${hue}`, () => {
154
+ const dark = scheme === "dark";
155
+ const base = themes[`${scheme}${hue}`]!;
156
+ const canvas = hex(base, "$background");
157
+ for (const { name, fill, theme } of fillsFor(scheme, hue)) {
158
+ const strip = eventStripPaint(theme, fill, { dark, surface: canvas })!;
159
+ expect(strip, `${name} strip step`).toBe(
160
+ normalizeToHex(eventRamp(theme, fill, dark)!(EVENT_STRIP_STEP)!),
161
+ );
162
+ for (const state of ["rest", "selected"] as const) {
163
+ const paint = eventPaint(theme, fill, state, { dark, surface: canvas })!;
164
+ const label = `${name} ${state}: ${strip} on ${paint}`;
165
+ expect(ratio(strip, paint), label).toBeGreaterThanOrEqual(EVENT_STRIP_FLOOR);
166
+ expect(strip, `${label} is not the label ink`).not.toBe(
167
+ hex(theme, eventLabelInk(theme, fill, [paint], dark)),
168
+ );
169
+ }
170
+ if (!dark)
171
+ expect(
172
+ ratio(
173
+ eventPaint(theme, fill, "selected", { dark, surface: canvas })!,
174
+ eventPaint(theme, fill, "rest", { dark, surface: canvas })!,
175
+ ),
176
+ `${name} selection still deepens the fill`,
177
+ ).toBeGreaterThan(1);
178
+ }
179
+ const strip = eventStripPaint(base, "#f59e0b", { dark, surface: canvas })!;
180
+ for (const state of ["rest", "selected"] as const) {
181
+ const paint = eventPaint(base, "#f59e0b", state, { dark, surface: canvas })!;
182
+ expect(ratio(strip, paint), `foreign ${state}`).toBeGreaterThanOrEqual(EVENT_STRIP_FLOOR);
183
+ }
184
+ });
185
+ });
186
+
187
+ describe("a light Gantt bar is a solid with on-solid ink (FZ-9366)", () => {
188
+ for (const hue of hues)
189
+ it(`light${hue}`, () => {
190
+ for (const { name, fill, theme } of fillsFor("light", hue)) {
191
+ const rest = eventSolid(theme, fill, "rest")!;
192
+ const selected = eventSolid(theme, fill, "selected")!;
193
+ expect(selected.ink, `${name} ink holds across selection`).toBe(rest.ink);
194
+ expect(selected.paint, `${name} selection moves the fill`).not.toBe(rest.paint);
195
+ for (const { paint, ink } of [rest, selected]) {
196
+ const label = `${name}: ${ink} on ${paint}`;
197
+ expect(ratio(ink, paint), label).toBeGreaterThanOrEqual(aaTextContrastRatio);
198
+ expect(Math.abs(apcaContrast(ink, paint)), label).toBeGreaterThanOrEqual(fillLabelLc);
199
+ }
200
+ expect(
201
+ [
202
+ hex(theme, "$color-1"),
203
+ normalizeToHex(eventRamp(theme, fill, false)?.(12) ?? "") ?? hex(theme, "$color-12"),
204
+ hex(theme, "$color-12"),
205
+ ],
206
+ `${name} ink is a theme anchor`,
207
+ ).toContain(rest.ink);
208
+ }
209
+ });
210
+
211
+ it.each([
212
+ ["blue", Colors.blue.blue9],
213
+ ["green", Colors.green.green9],
214
+ ["red", Colors.red.red9],
215
+ ["purple", Colors.purple.purple9],
216
+ ])("%s carries near-white, not black", (_, fill) => {
217
+ const theme = themes.light_blue!;
218
+ const { paint, ink } = eventSolid(theme, fill, "rest")!;
219
+ expect(ink).toBe(hex(theme, "$color-1"));
220
+ expect(ratio(ink, paint)).toBeGreaterThanOrEqual(aaTextContrastRatio);
221
+ });
222
+
223
+ it("yellow keeps a dark ink on its own solid", () => {
224
+ const theme = themes.light_blue!;
225
+ const { paint, ink } = eventSolid(theme, Colors.yellow.yellow9, "rest")!;
226
+ expect(paint).toBe(normalizeToHex(Colors.yellow.yellow9));
227
+ expect(ink).toBe(normalizeToHex(Colors.yellow.yellow12));
228
+ });
229
+ });
230
+
231
+ describe("secondary tones sit on the AA floor, pinned (FZ-9366)", () => {
232
+ it.each([
233
+ ["light Calendar green time", "light_blue", "#2b9a66", "selected", "#1e6446", 4.54],
234
+ ["dark Calendar green time", "dark_blue", "#2b9a66", "selected", "#8ae8b6", 4.51],
235
+ ["light proposed label", "light_blue", Colors.blue.blue9, "ghost", "#0e6abe", 4.52],
236
+ ] as const)("%s", (_, name, fill, state, tone, floor) => {
237
+ const theme = themes[name]!;
238
+ const dark = name.startsWith("dark");
239
+ const paint = eventPaint(theme, fill, state, { dark, surface: hex(theme, "$background") })!;
240
+ const ink = eventLabelInk(theme, fill, [paint], dark, "secondary");
241
+ expect(ink).toBe(tone);
242
+ expect(ratio(ink, paint)).toBeCloseTo(floor, 2);
243
+ });
244
+ });
245
+
246
+ describe("bar labels hold AA and keep their preferred ink where it reads (FZ-9366)", () => {
247
+ for (const scheme of ["light", "dark"] as const)
248
+ for (const hue of hues)
249
+ it(`${scheme}${hue}`, () => {
250
+ const base = themes[`${scheme}${hue}`]!;
251
+ const canvas = hex(base, "$background");
252
+ for (const { name, fill, theme } of fillsFor(scheme, hue))
253
+ for (const state of ["rest", "selected", "ghost"] as const) {
254
+ const paint = eventPaint(theme, fill, state, {
255
+ dark: scheme === "dark",
256
+ surface: canvas,
257
+ })!;
258
+ const tone = state === "ghost" ? "secondary" : "primary";
259
+ const ink = eventLabelInk(theme, fill, [paint], scheme === "dark", tone);
260
+ const inkHex = hex(theme, ink);
261
+ const label = `${name} ${state}`;
262
+ const ramp = eventRamp(theme, fill, scheme === "dark")!;
263
+ const [dim, full] = [11, 12].map((step) => normalizeToHex(ramp(step)!)!);
264
+ const reads = (tone: string) => ratio(tone, paint) >= aaTextContrastRatio;
265
+ if (tone === "primary") {
266
+ if (reads(full!)) expect(ink, `${label} keeps step 12`).toBe(full);
267
+ } else if (reads(full!)) {
268
+ const percent = Array.from({ length: 100 }, (_, p) => p).find(
269
+ (p) => blendOver(full!, dim!, p / 100) === ink,
270
+ );
271
+ expect(
272
+ percent,
273
+ `${label} secondary ${ink} lies between steps 11 and 12`,
274
+ ).toBeDefined();
275
+ if (percent! > 0)
276
+ expect(
277
+ reads(blendOver(full!, dim!, (percent! - 1) / 100)!),
278
+ `${label} secondary is the dimmest tone that reads`,
279
+ ).toBe(false);
280
+ if (percent! < 99)
281
+ expect(ink, `${label} secondary sits dimmer than its title`).not.toBe(full);
282
+ }
283
+ expect(ratio(inkHex, paint), `${label}: ${inkHex} on ${paint}`).toBeGreaterThanOrEqual(
284
+ aaTextContrastRatio,
285
+ );
286
+ }
287
+ });
288
+ });