An open source design system that's fully customizable and agent ready
TypeScript
fix(lab): Schedule paints a timed event of 24 hours or more as an all-day span (#7057)
Cindy Zhangcc018abe9982
diff --git a/apps/storybook/stories/Schedule.stories.tsx b/apps/storybook/stories/Schedule.stories.tsxindex c440a50cb8..6414b39d67 100644--- a/apps/storybook/stories/Schedule.stories.tsx+++ b/apps/storybook/stories/Schedule.stories.tsx@@ -890,3 +890,91 @@ export const ViewSelectorPlugin: Story = {);},};++// A fixed UTC week for the long-span contract (component:Schedule FR21): a+// 48-hour offsite and an exactly-24-hour handoff are all-day spans; a+// 23-hour-59-minute shift and an overnight deploy stay in the day columns;+// Tuesday's standup and review keep their full column width; Saturday's+// retreat has too long a title for its times to fit.+const longSpanEvents: CalendarEvent[] = [+ createEventFromISO({+ id: 'offsite',+ title: 'Offsite',+ category: 'Company',+ start: '2026-05-11T09:00:00.000Z',+ end: '2026-05-13T09:00:00.000Z',+ }),+ createEventFromISO({+ id: 'handoff',+ title: 'On-call handoff',+ category: 'Incident',+ start: '2026-05-14T08:00:00.000Z',+ end: '2026-05-15T08:00:00.000Z',+ }),+ createEventFromISO({+ id: 'retreat',+ title: 'Leadership planning retreat',+ category: 'Company',+ start: '2026-05-16T06:00:00.000Z',+ end: '2026-05-17T06:00:00.000Z',+ }),+ createEventFromISO({+ id: 'shift',+ title: 'Long shift',+ category: 'Focus',+ start: '2026-05-15T00:00:00.000Z',+ end: '2026-05-15T23:59:00.000Z',+ }),+ createEventFromISO({+ id: 'deploy',+ title: 'Late deploy',+ category: 'Launch',+ start: '2026-05-12T22:00:00.000Z',+ end: '2026-05-13T02:00:00.000Z',+ }),+ fixtureEvent({+ id: 'standup',+ title: 'Standup',+ category: 'Company',+ day: 12,+ start: [9],+ end: [9, 30],+ }),+ fixtureEvent({+ id: 'review',+ title: 'Design review',+ category: 'Design',+ day: 12,+ start: [10],+ end: [11],+ }),+];++export const LongTimedEvents: Story = {+ render: () => {+ const [date, setDate] = useState<Instant>(FIXTURE_DATE);+ const view = useMemo(+ () =>+ createScheduleWeeklyView({+ renderPopover: event => (+ <Text type="label" weight="bold">+ {event.title}+ </Text>+ ),+ }),+ [],+ );++ return (+ <Schedule+ view={view}+ events={longSpanEvents}+ categories={categories}+ date={date}+ focusDate={FIXTURE_DATE}+ onChangeDate={setDate}+ timezoneID={FIXTURE_TIMEZONE}+ />+ );+ },+};diff --git a/packages/lab/src/Schedule/Schedule.doc.mjs b/packages/lab/src/Schedule/Schedule.doc.mjsindex cb87c7be6b..cea9d8c356 100644--- a/packages/lab/src/Schedule/Schedule.doc.mjs+++ b/packages/lab/src/Schedule/Schedule.doc.mjs@@ -82,7 +82,7 @@ export const docs = {name: 'View body',required: true,description:- 'Whatever the view renders: a month grid, a day/week time grid with an hour gutter and an all-day row, or a list grouped under day headings. Grid views expose ARIA grid, columnheader, and gridcell roles and are marked aria-readonly. The day/week time grid scrolls inside one keyboard-reachable region named after the range; its day header, all-day row, and hour gutter stay pinned while the columns scroll.',+ 'Whatever the view renders: a month grid, a day/week time grid with an hour gutter and an all-day row, or a list grouped under day headings. Grid views expose ARIA grid, columnheader, and gridcell roles and are marked aria-readonly. The day/week time grid scrolls inside one keyboard-reachable region named after the range; its day header, all-day row, and hour gutter stay pinned while the columns scroll. The all-day row also holds timed events that last 24 hours or more, as one span across their days.',},{name: 'Event',diff --git a/packages/lab/src/Schedule/TimeGridView.test.tsx b/packages/lab/src/Schedule/TimeGridView.test.tsxindex e9edfdf68a..93ed0edc8a 100644--- a/packages/lab/src/Schedule/TimeGridView.test.tsx+++ b/packages/lab/src/Schedule/TimeGridView.test.tsx@@ -1,7 +1,14 @@// Copyright (c) Meta Platforms, Inc. and affiliates.import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';-import {act, fireEvent, render, screen, waitFor} from '@testing-library/react';+import {+ act,+ fireEvent,+ render,+ screen,+ waitFor,+ within,+} from '@testing-library/react';import {useState} from 'react';import {createEventFromISO} from './CalendarEvent';import {Schedule} from './Schedule';@@ -76,10 +83,12 @@ function Harness({initialDate,eventSource = events,view = createScheduleWeeklyView(),+ timezoneID = 'UTC',}: {initialDate: Instant;eventSource?: ScheduleEventSource;view?: ReturnType<typeof createScheduleWeeklyView>;+ timezoneID?: string;}) {const [date, setDate] = useState<Instant>(initialDate);return (@@ -88,7 +97,7 @@ function Harness({events={eventSource}date={date}onChangeDate={setDate}- timezoneID="UTC"+ timezoneID={timezoneID}/>);}@@ -266,3 +275,165 @@ describe('time grid initial position', () => {expect(loadedViewport.scrollTop).toBe(700);});});++describe('time grid long spans', () => {+ // component:Schedule FR21: a timed event of 24 hours or more is a span in+ // the all-day row; a shorter one stays a block in each day it touches.+ const spanEvents: CalendarEvent[] = [+ createEventFromISO({+ id: 'offsite',+ title: 'Offsite',+ start: '2026-05-11T09:00:00.000Z',+ end: '2026-05-13T09:00:00.000Z',+ }),+ createEventFromISO({+ id: 'handoff',+ title: 'On-call handoff',+ start: '2026-05-14T08:00:00.000Z',+ end: '2026-05-15T08:00:00.000Z',+ }),+ createEventFromISO({+ id: 'shift',+ title: 'Long shift',+ start: '2026-05-15T00:00:00.000Z',+ end: '2026-05-15T23:59:00.000Z',+ }),+ createEventFromISO({+ id: 'deploy',+ title: 'Late deploy',+ start: '2026-05-12T22:00:00.000Z',+ end: '2026-05-13T02:00:00.000Z',+ }),+ ];+ const date = Date.UTC(2026, 4, 13, 12) as Instant;+ const popoverView = createScheduleWeeklyView({+ renderPopover: event => <p>{event.title} details</p>,+ });+ const allDay = () => screen.getByRole('group', {name: 'All-day events'});+ const day = (name: string) => screen.getByRole('group', {name});+ const buttonsIn = (group: HTMLElement, title: string) =>+ within(group).queryAllByRole('button', {+ name: new RegExp(`^${title},`),+ });++ it('paints a timed event of 24 hours or more as one all-day span named with its dates', () => {+ render(+ <Harness+ initialDate={date}+ eventSource={spanEvents}+ view={popoverView}+ />,+ );+ const [offsite, ...others] = buttonsIn(allDay(), 'Offsite');+ expect(others).toEqual([]);+ expect(offsite.getAttribute('aria-label')).toMatch(+ /^Offsite, May 11(,| at) 9:00\sAM\s–\sMay 13(,| at) 9:00\sAM, .+, Monday, May 11, 2026$/u,+ );+ for (const name of [+ 'Monday, May 11, 2026',+ 'Tuesday, May 12, 2026',+ 'Wednesday, May 13, 2026',+ ]) {+ expect(buttonsIn(day(name), 'Offsite')).toEqual([]);+ }+ expect(buttonsIn(allDay(), 'On-call handoff')).toHaveLength(1);+ });++ it('keeps a timed event shorter than 24 hours in the day columns', () => {+ render(+ <Harness+ initialDate={date}+ eventSource={spanEvents}+ view={popoverView}+ />,+ );+ expect(buttonsIn(allDay(), 'Long shift')).toEqual([]);+ expect(buttonsIn(day('Friday, May 15, 2026'), 'Long shift')).toHaveLength(+ 1,+ );+ expect(buttonsIn(allDay(), 'Late deploy')).toEqual([]);+ expect(buttonsIn(day('Tuesday, May 12, 2026'), 'Late deploy')).toHaveLength(+ 1,+ );+ expect(+ buttonsIn(day('Wednesday, May 13, 2026'), 'Late deploy'),+ ).toHaveLength(1);+ });++ it('leads a span pill with its title and follows it with its start and end times', () => {+ render(+ <Harness+ initialDate={date}+ eventSource={spanEvents}+ view={popoverView}+ />,+ );+ const offsite = buttonsIn(allDay(), 'Offsite')[0];+ // Whether the times fit is layout; their order in the pill is not.+ expect(offsite.textContent).toMatch(/^Offsite9:00\sAM - 9:00\sAM$/u);+ });++ it('measures the threshold on the event\u2019s own instants across daylight-saving days', () => {+ // America/Los_Angeles: March 8, 2026 lasts 23 hours and November 1,+ // 2026 lasts 25. Midnight to midnight is a block on the first and a span+ // on the second.+ const dstEvents: CalendarEvent[] = [+ createEventFromISO({+ id: 'spring',+ title: 'Spring day',+ start: '2026-03-08T08:00:00.000Z',+ end: '2026-03-09T07:00:00.000Z',+ }),+ createEventFromISO({+ id: 'fall',+ title: 'Fall day',+ start: '2026-11-01T07:00:00.000Z',+ end: '2026-11-02T08:00:00.000Z',+ }),+ ];+ const {unmount} = render(+ <Harness+ initialDate={Date.UTC(2026, 2, 10, 20) as Instant}+ eventSource={dstEvents}+ view={popoverView}+ timezoneID="America/Los_Angeles"+ />,+ );+ expect(buttonsIn(allDay(), 'Spring day')).toEqual([]);+ expect(buttonsIn(day('Sunday, March 8, 2026'), 'Spring day')).toHaveLength(+ 1,+ );+ unmount();+ render(+ <Harness+ initialDate={Date.UTC(2026, 10, 3, 20) as Instant}+ eventSource={dstEvents}+ view={popoverView}+ timezoneID="America/Los_Angeles"+ />,+ );+ expect(buttonsIn(allDay(), 'Fall day')).toHaveLength(1);+ expect(buttonsIn(day('Sunday, November 1, 2026'), 'Fall day')).toEqual([]);+ });++ it('lists a long timed event in the hidden grid’s all-day cells and in no hour cell', () => {+ render(<Harness initialDate={date} eventSource={spanEvents} />);+ const grid = screen.getByRole('grid', {name: 'Schedule time grid'});+ const offsiteCells = within(grid)+ .getAllByRole('gridcell')+ .map(cell => cell.getAttribute('aria-label') ?? '')+ .filter(label => label.includes('Offsite'));+ expect(offsiteCells.map(label => label.split('.')[0])).toEqual([+ 'Monday, May 11, 2026 all day',+ 'Tuesday, May 12, 2026 all day',+ 'Wednesday, May 13, 2026 all day',+ ]);+ // Each entry names the span by its title, its category, and its start and+ // end with their dates (component:Schedule AR2).+ for (const label of offsiteCells) {+ expect(label.split('. ')[1]).toMatch(+ /^Offsite, Event, May 11(,| at) 9:00\sAM\s–\sMay 13(,| at) 9:00\sAM$/u,+ );+ }+ });+});diff --git a/packages/lab/src/Schedule/TimeGridView.tsx b/packages/lab/src/Schedule/TimeGridView.tsxindex 7b8dc1a3a6..bd24feb3ba 100644--- a/packages/lab/src/Schedule/TimeGridView.tsx+++ b/packages/lab/src/Schedule/TimeGridView.tsx@@ -41,16 +41,17 @@ import {import {useScrollableArea} from '@astryxdesign/core/hooks';import {Heading, Text} from '@astryxdesign/core/Text';import {useScheduleContext} from './context';-import {eventOccursOnDate, isDayEvent} from './dateMath';+import {eventOccursOnDate, isAllDaySpan, isDayEvent} from './dateMath';import {timeGridViewportScope} from './schedule.stylex';import {clamp,EventPill,eventPastSurfaceColorStyle,eventSurfaceColorStyle,- formatEventAccessibilityLabel,formatDayNumber,+ formatEventDateTimeRange,formatEventTime,+ formatEventTimeRange,formatFullDate,formatHour,formatTimezoneAbbreviation,@@ -61,6 +62,7 @@ import {SchedulePopoverBody,ScheduleTime,styles,+ TitleFirstPill,} from './shared';import {layoutTimedEvents, type TimedEventPlacement} from './timeGridLayout';import {@@ -71,7 +73,6 @@ import {} from './timeGridScrollMemory';import {useCurrentTime} from './useCurrentTime';import type {- CalendarDayEvent,CalendarEvent,CalendarInstantEvent,ScheduleCategory,@@ -111,14 +112,17 @@ export function TimeGridView({{length: normalizedMaxHour - normalizedMinHour},(_, index) => normalizedMinHour + index,);- const allDayEvents = events.filter(isDayEvent);- const allDaySegments = getAllDayEventSegments(allDayEvents, days);+ // Date-only events and timed events of a day or more are spans in the+ // all-day row; every other timed event is a block in its day columns+ // (component:Schedule FR21).+ const allDayEvents = events.filter(isAllDaySpan);+ const allDaySegments = getAllDayEventSegments(allDayEvents, days, timezoneID);const allDayLevelCount = allDaySegments.reduce((levelCount, segment) => Math.max(levelCount, segment.level + 1),0,);const instantEvents = events.filter(- (event): event is CalendarInstantEvent => !isDayEvent(event),+ (event): event is CalendarInstantEvent => !isAllDaySpan(event),);const currentTime = useCurrentTime();const currentDate = plainDateFromInstant(currentTime, timezoneID);@@ -412,14 +416,25 @@ export function TimeGridView({const day = days[segment.columnStart] ?? focusDate;const dayISO = plainDateToISO(day);const key = `${segment.event.id}:${segment.columnStart}`;- const pill = (- <EventPill+ const isSegmentPast = isEventInPast(+ segment.event,+ currentTime,+ timezoneID,+ );+ // A timed span of a day or more leads with its title and+ // shows its start and end times when both fit+ // (component:Schedule FR21).+ const pill = isDayEvent(segment.event) ? (+ <EventPill event={segment.event} isPast={isSegmentPast} />+ ) : (+ <TitleFirstPillevent={segment.event}- isPast={isEventInPast(+ timeLabel={formatEventTimeRange(segment.event,- currentTime,timezoneID,+ locale,)}+ isPast={isSegmentPast}/>);const placement = styles.allDayEventSpan(@@ -685,7 +700,7 @@ function TimeGridAccessibilityGrid({timezoneID,timezoneLabel,}: {- allDayEvents: ReadonlyArray<CalendarDayEvent>;+ allDayEvents: ReadonlyArray<CalendarEvent>;categories: ReadonlyArray<ScheduleCategory>;days: ReadonlyArray<PlainDate>;events: ReadonlyArray<CalendarInstantEvent>;@@ -794,8 +809,14 @@ function formatTimeGridAccessibilityCellLabel({if (events.length === 0) {return label;}- const eventLabels = events.map(event =>- formatEventAccessibilityLabel(event, day, timezoneID, categories, locale),+ const eventLabels = events.map(+ event =>+ `${event.title}, ${getEventCategory(event, categories).label}, ${formatTimeGridEventTime(+ event,+ day,+ timezoneID,+ locale,+ )}`,);return `${label}. ${eventLabels.join('. ')}`;}@@ -818,9 +839,7 @@ function formatEventButtonLabel(locale: Locale,): string {const category = getEventCategory(event, categories);- const timeLabel = isDayEvent(event)- ? 'all day'- : formatEventTime(event, day, timezoneID, locale);+ const timeLabel = formatTimeGridEventTime(event, day, timezoneID, locale);return `${event.title}, ${timeLabel}, ${category.label}, ${formatFullDate(day,timezoneID,@@ -828,6 +847,25 @@ function formatEventButtonLabel()}`;}+/**+ * "all day" for a date-only event; the start and end with their dates for a+ * timed span of a day or more, which no single day frames; otherwise the+ * start and end times (component:Schedule AR2).+ */+function formatTimeGridEventTime(+ event: CalendarEvent,+ day: PlainDate,+ timezoneID: string,+ locale: Locale,+): string {+ if (isDayEvent(event)) {+ return 'all day';+ }+ return isAllDaySpan(event)+ ? formatEventDateTimeRange(event, timezoneID, locale)+ : formatEventTime(event, day, timezoneID, locale);+}+function eventOverlapsHour(event: CalendarInstantEvent,day: PlainDate,@@ -846,36 +884,42 @@ function eventOverlapsHour(}interface AllDayEventSegment {- event: CalendarDayEvent;+ event: CalendarEvent;columnStart: number;columnEnd: number;level: number;}function getAllDayEventSegments(- events: ReadonlyArray<CalendarDayEvent>,+ events: ReadonlyArray<CalendarEvent>,days: ReadonlyArray<PlainDate>,+ timezoneID: string,): AllDayEventSegment[] {const levels: number[] = [];return events.map(event => {- const startIndex = days.findIndex(- day => !plainDateIsBefore(day, event.start),+ // The days the event touches in the schedule's timezone; a timed span+ // ending at midnight does not touch the next day.+ const startIndex = days.findIndex(day =>+ eventOccursOnDate(event, day, timezoneID),);- const endIndexFromRight = [...days]- .reverse()- .findIndex(day => !plainDateIsBefore(event.end, day));- if (startIndex < 0 || endIndexFromRight < 0) {+ if (startIndex < 0) {return null;}- const endIndex = days.length - 1 - endIndexFromRight;+ let endIndex = startIndex;+ while (+ endIndex + 1 < days.length &&+ eventOccursOnDate(event, days[endIndex + 1], timezoneID)+ ) {+ endIndex += 1;+ }return {event, startIndex, endIndex};}).filter((segment,): segment is {- event: CalendarDayEvent;+ event: CalendarEvent;startIndex: number;endIndex: number;} => segment != null,diff --git a/packages/lab/src/Schedule/__tests__/ScheduleMonthEventPopover.a11y.chromium.spec.ts b/packages/lab/src/Schedule/__tests__/ScheduleMonthEventPopover.a11y.chromium.spec.tsindex 3ec4b27a4a..12abb4829f 100644--- a/packages/lab/src/Schedule/__tests__/ScheduleMonthEventPopover.a11y.chromium.spec.ts+++ b/packages/lab/src/Schedule/__tests__/ScheduleMonthEventPopover.a11y.chromium.spec.ts@@ -104,9 +104,9 @@ function readChips(page: Page) {});}-for (const [variant, globals] of [- ['ltr', undefined],- ['rtl-dark', 'direction:rtl;colorMode:dark'],+for (const [variant, direction, globals] of [+ ['ltr', 'ltr', undefined],+ ['rtl-dark', 'rtl', 'direction:rtl;colorMode:dark'],] as const) {test(`chips are named buttons in the cells where they start, inside their rows (${variant})`, async ({page,@@ -118,7 +118,7 @@ for (const [variant, globals] of [page,`month-event-buttons-${variant}`,STORY,- variant,+ direction,{chips},);expect(chips.length).toBeGreaterThan(0);diff --git a/packages/lab/src/Schedule/__tests__/ScheduleTimeGridLongSpan.a11y.chromium.spec.ts b/packages/lab/src/Schedule/__tests__/ScheduleTimeGridLongSpan.a11y.chromium.spec.tsnew file mode 100644index 0000000000..cc3a948326--- /dev/null+++ b/packages/lab/src/Schedule/__tests__/ScheduleTimeGridLongSpan.a11y.chromium.spec.ts@@ -0,0 +1,289 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ScheduleTimeGridLongSpan.a11y.chromium.spec.ts+ * @input The built Lab/Schedule long-timed-events story in real Chromium+ * @output Receipted evidence that a timed event of 24 hours or more is one+ * span in the all-day row whose edges meet its first and last day columns,+ * that it leaves the day columns and their overlap clusters alone, and that+ * shorter timed events stay one block per day, in LTR and RTL+ * @position Browser binding for `component:Schedule` FR21 and AR2. jsdom has+ * no layout, so it cannot measure where a span paints or how wide a block is.+ */++import {expect, test, type Page} from '@playwright/test';+import {+ finishEvidence,+ NARROW,+ openStory,+ readTimeGrid,+ record,+ startEvidence,+ WIDE,+ type Box,+ type Evidence,+} from './timeGridProbe';++const STORY = 'lab-schedule--long-timed-events';+// Day columns in document order: Sunday May 10 … Saturday May 16, 2026.+const MONDAY = 1;+const TUESDAY = 2;+const WEDNESDAY = 3;+const THURSDAY = 4;+const FRIDAY = 5;+const DAY_NAMES = [+ 'Sunday, May 10, 2026',+ 'Monday, May 11, 2026',+ 'Tuesday, May 12, 2026',+ 'Wednesday, May 13, 2026',+ 'Thursday, May 14, 2026',+ 'Friday, May 15, 2026',+ 'Saturday, May 16, 2026',+] as const;+// A span sits inside its columns by its pill margins: 2px at the start and+// 2px plus a 1px border at the end.+const SPAN_EDGE_TOLERANCE = 4;++let evidence: Evidence;+test.beforeAll(async () => {+ evidence = await startEvidence();+});+test.afterAll(async () => {+ await finishEvidence(evidence, 'long-span');+});++function eventButton(page: Page, group: string, title: string) {+ return page+ .getByRole('group', {name: group})+ .getByRole('button', {name: new RegExp(`^${title},`)});+}++async function boxOf(page: Page, group: string, title: string): Promise<Box> {+ const box = await eventButton(page, group, title).boundingBox();+ if (box == null) {+ throw new Error(`${title} has no box in ${group}`);+ }+ return {+ left: box.x,+ right: box.x + box.width,+ top: box.y,+ bottom: box.y + box.height,+ width: box.width,+ height: box.height,+ };+}++interface PillReading {+ readonly title: string;+ readonly timeVisible: boolean;+ readonly titleBeforeTime: boolean | null;+ readonly titleTruncated: boolean;+}++/**+ * How each span pill in the all-day row lays out its title and times: the+ * times count as shown only while they sit on the pill's one line.+ */+function readSpanPills(+ page: Page,+ titles: ReadonlyArray<string>,+): Promise<PillReading[]> {+ return page.evaluate(wanted => {+ const group = [...document.querySelectorAll('[role="group"]')].find(+ element => element.getAttribute('aria-label') === 'All-day events',+ );+ const isRtl = getComputedStyle(group ?? document.body).direction === 'rtl';+ const textNodes = (root: Node): Text[] => {+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);+ const nodes: Text[] = [];+ for (+ let node = walker.nextNode();+ node != null;+ node = walker.nextNode()+ ) {+ nodes.push(node as Text);+ }+ return nodes;+ };+ const rectOf = (node: Text) => {+ const range = document.createRange();+ range.selectNodeContents(node);+ return range.getBoundingClientRect();+ };+ return wanted.map(title => {+ const button = [...(group?.querySelectorAll('button') ?? [])].find(+ element => element.getAttribute('aria-label')?.startsWith(`${title},`),+ );+ if (button == null) {+ throw new Error(`no span pill titled ${title}`);+ }+ const nodes = textNodes(button);+ const titleNode = nodes.find(node => node.textContent === title);+ const timeNode = nodes.find(node =>+ /\d{1,2}:\d{2}/.test(node.textContent ?? ''),+ );+ const pill = (button.firstElementChild ?? button) as HTMLElement;+ const pillRect = pill.getBoundingClientRect();+ const pillStyle = getComputedStyle(pill);+ const lineTop =+ pillRect.top + Number.parseFloat(pillStyle.borderTopWidth);+ const lineBottom =+ pillRect.bottom - Number.parseFloat(pillStyle.borderBottomWidth);+ const titleRect = titleNode == null ? null : rectOf(titleNode);+ const timeRect = timeNode == null ? null : rectOf(timeNode);+ const timeVisible =+ timeRect != null &&+ timeRect.top >= lineTop - 1 &&+ timeRect.bottom <= lineBottom + 1 &&+ timeRect.width > 0;+ const titleElement = titleNode?.parentElement;+ return {+ title,+ timeVisible,+ titleBeforeTime:+ titleRect == null || timeRect == null || !timeVisible+ ? null+ : isRtl+ ? titleRect.left >= timeRect.right - 1+ : titleRect.right <= timeRect.left + 1,+ titleTruncated:+ titleElement == null+ ? false+ : titleElement.scrollWidth > titleElement.clientWidth + 1,+ };+ });+ }, titles);+}++function union(columns: ReadonlyArray<Box>): {left: number; right: number} {+ return {+ left: Math.min(...columns.map(column => column.left)),+ right: Math.max(...columns.map(column => column.right)),+ };+}++for (const [direction, globals] of [+ ['ltr', undefined],+ ['rtl', 'direction:rtl'],+] as const) {+ test(`a timed event of 24 hours or more is one all-day span across its days (${direction})`, async ({+ page,+ }) => {+ await openStory(evidence, page, STORY, WIDE, globals);+ // Spans live in the all-day row and nowhere in the day columns.+ await expect(eventButton(page, 'All-day events', 'Offsite')).toHaveCount(1);+ await expect(+ eventButton(page, 'All-day events', 'On-call handoff'),+ ).toHaveCount(1);+ for (const day of [MONDAY, TUESDAY, WEDNESDAY]) {+ await expect(eventButton(page, DAY_NAMES[day], 'Offsite')).toHaveCount(0);+ }+ // Shorter timed events stay blocks, one per day they touch.+ await expect(eventButton(page, 'All-day events', 'Long shift')).toHaveCount(+ 0,+ );+ await expect(+ eventButton(page, DAY_NAMES[FRIDAY], 'Long shift'),+ ).toHaveCount(1);+ await expect(+ eventButton(page, DAY_NAMES[TUESDAY], 'Late deploy'),+ ).toHaveCount(1);+ await expect(+ eventButton(page, DAY_NAMES[WEDNESDAY], 'Late deploy'),+ ).toHaveCount(1);++ const grid = await readTimeGrid(page);+ const offsite = await boxOf(page, 'All-day events', 'Offsite');+ const handoff = await boxOf(page, 'All-day events', 'On-call handoff');+ const offsiteColumns = union(+ [MONDAY, TUESDAY, WEDNESDAY].map(day => grid.bodyColumns[day]),+ );+ const handoffColumns = union(+ [THURSDAY, FRIDAY].map(day => grid.bodyColumns[day]),+ );+ const standup = await boxOf(page, DAY_NAMES[TUESDAY], 'Standup');+ const tuesday = grid.bodyColumns[TUESDAY];+ const name = await eventButton(+ page,+ 'All-day events',+ 'Offsite',+ ).getAttribute('aria-label');+ const reading = {+ direction: grid.direction,+ offsite: {+ startGap: Math.abs(offsite.left - offsiteColumns.left),+ endGap: Math.abs(offsite.right - offsiteColumns.right),+ name,+ },+ handoff: {+ startGap: Math.abs(handoff.left - handoffColumns.left),+ endGap: Math.abs(handoff.right - handoffColumns.right),+ },+ // A block that shares no cluster with the span keeps its column.+ standupWidthShare: standup.width / tuesday.width,+ };+ await record(+ evidence,+ page,+ `long-span-${direction}`,+ STORY,+ direction,+ reading,+ );++ expect(grid.direction).toBe(direction);+ expect(reading.offsite.startGap).toBeLessThanOrEqual(SPAN_EDGE_TOLERANCE);+ expect(reading.offsite.endGap).toBeLessThanOrEqual(SPAN_EDGE_TOLERANCE);+ expect(reading.handoff.startGap).toBeLessThanOrEqual(SPAN_EDGE_TOLERANCE);+ expect(reading.handoff.endGap).toBeLessThanOrEqual(SPAN_EDGE_TOLERANCE);+ expect(reading.standupWidthShare).toBeGreaterThan(0.85);+ expect(name).toMatch(+ /^Offsite, May 11(,| at) 9:00\sAM\s–\sMay 13(,| at) 9:00\sAM, Company, Monday, May 11, 2026$/u,+ );+ });++ test(`a span pill leads with its title and shows its times only when both fit (${direction})`, async ({+ page,+ }) => {+ const readings: Record<string, PillReading[]> = {};+ for (const [name, viewport] of [+ ['wide', WIDE],+ ['narrow', NARROW],+ ] as const) {+ await openStory(evidence, page, STORY, viewport, globals);+ readings[name] = await readSpanPills(page, [+ 'Offsite',+ 'On-call handoff',+ 'Leadership planning retreat',+ ]);+ }+ await record(+ evidence,+ page,+ `long-span-pills-${direction}`,+ STORY,+ direction,+ {+ readings,+ },+ );+ // Wide, three columns leave room: the times follow the title.+ const offsite = readings.wide[0];+ expect(offsite.timeVisible, 'Offsite times show when they fit').toBe(true);+ expect(offsite.titleBeforeTime, 'Offsite: title before times').toBe(true);+ // A title too long for one column keeps the line: the times give way.+ const retreat = readings.wide[2];+ expect(retreat.timeVisible, 'a long title hides the times').toBe(false);+ for (const pill of [...readings.wide, ...readings.narrow]) {+ if (pill.timeVisible) {+ expect(pill.titleBeforeTime, `${pill.title}: title before times`).toBe(+ true,+ );+ expect(+ pill.titleTruncated,+ `${pill.title}: shown times never cut the title`,+ ).toBe(false);+ }+ }+ });+}diff --git a/packages/lab/src/Schedule/dateMath.ts b/packages/lab/src/Schedule/dateMath.tsindex ac16b05784..918ded80d8 100644--- a/packages/lab/src/Schedule/dateMath.ts+++ b/packages/lab/src/Schedule/dateMath.ts@@ -26,6 +26,17 @@ export function isDayEvent(event: CalendarEvent): event is CalendarDayEvent {return typeof event.start !== 'number';}+const ALL_DAY_SPAN_MS = 24 * 60 * 60 * 1000;++/**+ * Whether the week and day views paint an event as a span in the all-day row:+ * a date-only event, or a timed event lasting 24 hours or more, measured on+ * its own instants (component:Schedule FR21).+ */+export function isAllDaySpan(event: CalendarEvent): boolean {+ return isDayEvent(event) || event.end - event.start >= ALL_DAY_SPAN_MS;+}+export function getScheduleRangeFromDates({startDate,endDate,diff --git a/packages/lab/src/Schedule/shared.tsx b/packages/lab/src/Schedule/shared.tsxindex a745d89b99..26afb84c86 100644--- a/packages/lab/src/Schedule/shared.tsx+++ b/packages/lab/src/Schedule/shared.tsx@@ -631,6 +631,25 @@ export function formatEventTimeRange()}`;}+/**+ * An event's start and end with their dates, such as "May 11 at 9:00 AM – May+ * 13 at 9:00 AM" in en-US, for a timed span of a day or more+ * (component:Schedule AR2).+ */+export function formatEventDateTimeRange(+ event: CalendarInstantEvent,+ timezoneID: string,+ locale: Locale,+): string {+ return new Intl.DateTimeFormat(locale, {+ month: 'long',+ day: 'numeric',+ hour: 'numeric',+ minute: '2-digit',+ timeZone: timezoneID,+ }).formatRange(new Date(event.start), new Date(event.end));+}+export function formatEventStartTime(event: CalendarInstantEvent,timezoneID: string,