An open source design system that's fully customizable and agent ready
TypeScript
fix(Timestamp): the hover card keeps description-list structure (#9041)
Cindy Zhange49ae744331e
diff --git a/.changeset/timestamp-card-dl.md b/.changeset/timestamp-card-dl.mdnew file mode 100644index 0000000000..9e02f7bbc1--- /dev/null+++ b/.changeset/timestamp-card-dl.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] Timestamp: every value in the hover card now has a name for screen readers (WCAG 2.2 1.3.1). A copy button sits inside its row's value, so the card passes the description-list check, and a row without a label is named by its time zone's long name, which is visually hidden.++@cixzhangdiff --git a/docs/specs/components/Timestamp/Timestamp.spec.md b/docs/specs/components/Timestamp/Timestamp.spec.mdindex 851cabecd3..736c8cc332 100644--- a/docs/specs/components/Timestamp/Timestamp.spec.md+++ b/docs/specs/components/Timestamp/Timestamp.spec.md@@ -39,15 +39,15 @@ system_specs: [spec:AST-009, spec:AST-013/FR12, spec:AST-085, spec:AST-111/FR18]## Contract at a glance-| Area | Contract |-| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Public contract | A `time` element for a `value` (Unix seconds, milliseconds, or ISO 8601) in one of twelve `format`s, with optional live updates, time-zone suffix, and a copyable hover card. |-| Behavior | Relative output carries the full absolute date as its default accessible name; relative output, or configured `tooltipEntries`, attach a keyboard-reachable hover card of copyable rows. |-| End-user impact | Readers see compact or exact times in their locale; screen-reader users hear the full date and time zone; keyboard users can open and copy the exact time. |-| Builder impact | Optional: set `calendar` on the `InternationalizationProvider` to write dates in another calendar. Optional: map the hover card's copy glyph through the `timestamp-copy` icon slot (FR10). |-| Compatibility/readiness | No prop or default changes; FR10 adds the opt-in `timestamp-copy` theme slot, which is current and awaits implementation. Without a provider calendar the output is unchanged; under one, date-bearing formats change calendar, and calendars that need `Temporal` fall back to Gregorian where it is missing (the `spec:AST-013` FR12 exception). A provider locale with a `-u-ca-` keyword keeps Gregorian dates (`spec:AST-111` DEC-2); set the provider's `calendar` to choose one. Three implementation gaps are listed under Current-state impact. |-| Review checks | Reject a relative timestamp without the full absolute name when the caller names nothing, a hover card without a tab stop, a change that makes more server markup depend on the server's zone, or a crash on an unparseable value. |-| Governing rules | `architecture:internationalization/INV4,INV8,INV10`; `spec:AST-111/FR18`; `spec:AST-013` FR12; `architecture:react-component-runtime/INV1,INV3,INV5`; `architecture:public-component-api/INV5,INV6,INV8`; `architecture:icon-resolution-and-component-slots/INV2,INV4–INV8`. |+| Area | Contract |+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| Public contract | A `time` element for a `value` (Unix seconds, milliseconds, or ISO 8601) in one of twelve `format`s, with optional live updates, time-zone suffix, and a copyable hover card. |+| Behavior | Relative output carries the full absolute date as its default accessible name; relative output, or configured `tooltipEntries`, attach a keyboard-reachable hover card of copyable rows. |+| End-user impact | Readers see compact or exact times in their locale; screen-reader users hear the full date and time zone; keyboard users can open and copy the exact time. |+| Builder impact | Optional: set `calendar` on the `InternationalizationProvider` to write dates in another calendar. Optional: map the hover card's copy glyph through the `timestamp-copy` icon slot (FR10). |+| Compatibility/readiness | No prop or default changes; FR10 adds the opt-in `timestamp-copy` theme slot, which is current and awaits implementation. Without a provider calendar the output is unchanged; under one, date-bearing formats change calendar, and calendars that need `Temporal` fall back to Gregorian where it is missing (the `spec:AST-013` FR12 exception). A provider locale with a `-u-ca-` keyword keeps Gregorian dates (`spec:AST-111` DEC-2); set the provider's `calendar` to choose one. Two implementation gaps are listed under Current-state impact. |+| Review checks | Reject a relative timestamp without the full absolute name when the caller names nothing, a hover card without a tab stop, a change that makes more server markup depend on the server's zone, or a crash on an unparseable value. |+| Governing rules | `architecture:internationalization/INV4,INV8,INV10`; `spec:AST-111/FR18`; `spec:AST-013` FR12; `architecture:react-component-runtime/INV1,INV3,INV5`; `architecture:public-component-api/INV5,INV6,INV8`; `architecture:icon-resolution-and-component-slots/INV2,INV4–INV8`. |This table is a review projection; the body below is authoritative.@@ -81,13 +81,6 @@ Consumer migration instructions belong in consumer docs and release notes.replaces that element, so keyboard focus placed on it falls to the page bodyand no card opens, where `spec:AST-085` FR4 keeps focus on a control thatstays available.-- **Card fails the description-list structure (FR7).** Once any row is- copyable, every row puts an action cell, a `div` (empty on read-only rows),- inside its row group in the card's `dl`, so the open card fails the- `definition-list` structure check (WCAG 2.2 1.3.1); the default card always- has a copyable row. A card with no labelled rows,- the default card included, also renders each row as a lone `dd` with no- `dt`, so its values have no names.- **Absolute formats depend on the server's zone (FR3).** An absolute formatother than `unix_seconds` renders in the host's time zone, so the same instant reads "Mar 25" from aUTC server and "Mar 26" from a Tokyo server, and a viewer in another zone@@ -132,7 +125,7 @@ Consumer migration instructions belong in consumer docs and release notes.| FR4 | With `isLive` and relative output, the clock refreshes every second under a minute old, every 30 seconds under an hour, every minute under a day, and every five minutes beyond; the timer is cleared on unmount or when the inputs change. Locale changes update the output live. | Current source and tests || FR5 | Relative output is named by the full absolute date and the long time-zone name unless a caller names the element; absolute output adds no name. A caller's explicit `aria-label` reaches the element (`architecture:public-component-api` INV5). | Current source and tests || FR6 | When `hasTooltip` is true and the output is relative or `tooltipEntries` is non-empty, a lazily loaded HoverCard named "Timestamp details" attaches above the timestamp, opening on hover and on keyboard focus; the `time` element gains `tabIndex={0}`. Otherwise no card renders and no tab stop is added. Focus placed on the timestamp stays there when the card attaches (`spec:AST-085` FR4). Implementation gap: while the card module loads, a fallback `time` with the tab stop renders, and attaching the card replaces it, so focus placed on it falls to the page body and no card opens (Current-state impact). | Current source and tests |-| FR7 | The card is a description list in a grid: an optional label column (present when any row has a label), the value column, and a trailing action column (present when any row is copyable). Without entries it has one copyable row with the full absolute time in the viewer's zone. Each configured entry is one row in the given order, rendered in its own time zone and format, read-only unless `isCopyable`. An unknown time zone does not crash. A description list holds only name-value groups (WCAG 2.2 1.3.1). Implementation gaps: once any row is copyable, every row carries an action-cell `div` inside its row group (empty on read-only rows), so the open card fails the `definition-list` structure check, and a card with no labelled rows, the default card included, renders each row as a lone `dd` with no `dt` (Current-state impact). | Current source and tests |+| FR7 | The card is a description list in a grid: an optional label column (present when any row has a label), the value column, and a trailing action column (present when any row is copyable). Without entries it has one copyable row with the full absolute time in the viewer's zone. Each configured entry is one row in the given order, rendered in its own time zone and format, read-only unless `isCopyable`. An unknown time zone does not crash. A description list holds only name-value groups (WCAG 2.2 1.3.1). Each row is a name-value group; a row without a label is named by its time zone's long name, which is visually hidden. A copy button sits inside its row's value. | Current source and tests || FR8 | A copy button is a small ghost IconButton on the `timestamp-copy-button` target, named "Copy {value}" with a "Copy" tooltip; activating it writes the row's value to the clipboard, switches to the copied glyph (`check` unless a theme maps `timestamp-copy`, FR10) and the "Copied" name and tooltip for 1.5 seconds, and announces "Copied" politely. A clipboard rejection does nothing. | Current source and tests || FR9 | `ref`, `data-testid`, and other supported DOM, ARIA, data, and event props reach the `time` element; `xstyle`, `className`, and `style` reach the Text wrapper. A caller `aria-labelledby` names the element in place of FR5's name. A caller's explicit `tabIndex` reaches the element (`architecture:public-component-api` INV5). | Current source and tests || FR10 | The copy button's glyph resolves through the `timestamp-copy` component icon slot, passing `{copied}`, which is true while the copied state (FR8) shows. With no theme entry, the glyph is `copy`, and `check` while copied. When the slot resolves to no icon (a theme value of `null`, a slot function that returns `null`, or a request with `icon: null`), only the glyph is hidden: the button keeps its size, name, tooltip, and copy behavior, and shows no glyph at rest or while copied. A request `size` changes only the glyph, never the button. | Proposal; `architecture:icon-resolution-and-component-slots/INV2,INV4–INV8` |@@ -255,19 +248,19 @@ Consumer migration instructions belong in consumer docs and release notes.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |-| FR1, FR2 | `Timestamp.test.tsx` format, auto, locale, calendar-system, and invalid-value tests; `tooltipEntries.test.ts` calendar tests; stable visual baseline `core-timestamp--default` | Every format; thresholds; locales; `persian`, `hebrew`, and `buddhist` under English and native locales, with and without `Temporal`; `iso8601`; `chinese` where `Intl` and `Temporal` disagree; unparseable values; default | A wrong phrase, a crossed tier, a non-Gregorian year without a provider calendar, a date-bearing format that ignores the provider calendar or names another day than `component:Calendar`, a changed `system_*` or `time` output, a missing `time` element or `datetime`, a crash, or a missing development warning for an unparseable value fails; a changed default type or color comes back changed for review. Gap: no test asserts the `timestamp` target or its format reflection. | `audit:Timestamp/behavior` |-| FR3 | `Timestamp.test.tsx` server-rendering suite and "hydrates a clock format rendered on a server without Temporal" | Server zones; hydration | Zone-dependent markup, a hydration mismatch, or a committed placeholder fails. Gap: no test covers an absolute format rendered on a server in another zone. | `audit:Timestamp/behavior` |-| FR4, PR1 | `Timestamp.test.tsx` live-update and locale tests | Live relative output; locale change | A missing refresh or a stale locale fails. Gap: the per-tier refresh intervals and the timer cleanup on unmount or input change have no automated check. | `audit:Timestamp/behavior` |-| FR5, AR2 | `Timestamp.test.tsx` naming tests | Relative, absolute, time-zone spelling | A missing or short-zone name, or a name on absolute output, fails. A caller `aria-label` replaced on relative output fails. | `audit:Timestamp/a11y` |-| FR6, AR3 | `Timestamp.test.tsx` keyboard-reachability suite | Relative, absolute, disabled, entries removed | A missing tab stop, `aria-expanded` on the trigger, or a stray tab stop fails. The aria-expanded test also pins `aria-haspopup` on the Text wrapper, which is current behavior, not contract. Gap: no test covers focus on the timestamp while the card module loads, or `aria-controls`. | `audit:Timestamp/a11y` |-| FR7, FR8, AR4 | `Timestamp.test.tsx` hover-card suites; `tooltipEntries.test.ts`; `useClipboard.test.tsx` | Default row, entries, copyable rows, unknown zone | A wrong row count or order, an unpaired label, a copy button on a read-only row, a wrong copied value, a missing copied state, or a missing announcement fails. Gap: no check runs the `definition-list` structure rule on the open card (the recorded gap); the grid columns and the 1.5-second reset have no automated check; `useClipboard.test.tsx` covers the clipboard-rejection no-op. The lone-`dd` rows of a label-less card are also unchecked. | `audit:Timestamp/behavior` |-| FR9 | `Timestamp.test.tsx` ref, test-id, and pass-through tests | Ref, test id, caller props | A ref, test id, or caller prop missing from the `time` element fails. A caller `tabIndex` replaced while a card is attached fails. Gap: no test asserts that `xstyle`, `className`, and `style` reach the Text wrapper, or covers a caller `aria-labelledby`. | `audit:Timestamp/behavior` |-| FR10 | `Timestamp.test.tsx` copy icon slot suite; the slot inventory test | No entry, a slot function in both states, `null`, a size request | The glyph ignores the slot or its state, `null` removes the button, its name, or its copy action, a size request resizes the button, or the consumer docs do not list the slot. | `audit:Timestamp/theming` |-| Theming anatomy map | `scripts/check-knowledge.mjs` | Consumer anatomy, targets, HoverCard delegate | Missing, extra, or stale mappings fail repository validation. | `audit:Timestamp/theming` |-| AR1 | `Timestamp.test.tsx` `datetime` tests | `date_time`; `date` | A missing or wrong ISO `datetime` on `date_time`, or a missing one on `date`, fails. Gap: no test asserts the exact `datetime` on relative or other absolute formats. | `audit:Timestamp/a11y` |-| AR2, AR4 | Accessibility-tree evidence (`spec:AST-009` FR3) | Relative output; copy buttons | Gap: no accessibility-tree check proves the computed name of relative output or the copy-button names; the unit tests query the DOM. | `audit:Timestamp/a11y` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |+| FR1, FR2 | `Timestamp.test.tsx` format, auto, locale, calendar-system, and invalid-value tests; `tooltipEntries.test.ts` calendar tests; stable visual baseline `core-timestamp--default` | Every format; thresholds; locales; `persian`, `hebrew`, and `buddhist` under English and native locales, with and without `Temporal`; `iso8601`; `chinese` where `Intl` and `Temporal` disagree; unparseable values; default | A wrong phrase, a crossed tier, a non-Gregorian year without a provider calendar, a date-bearing format that ignores the provider calendar or names another day than `component:Calendar`, a changed `system_*` or `time` output, a missing `time` element or `datetime`, a crash, or a missing development warning for an unparseable value fails; a changed default type or color comes back changed for review. Gap: no test asserts the `timestamp` target or its format reflection. | `audit:Timestamp/behavior` |+| FR3 | `Timestamp.test.tsx` server-rendering suite and "hydrates a clock format rendered on a server without Temporal" | Server zones; hydration | Zone-dependent markup, a hydration mismatch, or a committed placeholder fails. Gap: no test covers an absolute format rendered on a server in another zone. | `audit:Timestamp/behavior` |+| FR4, PR1 | `Timestamp.test.tsx` live-update and locale tests | Live relative output; locale change | A missing refresh or a stale locale fails. Gap: the per-tier refresh intervals and the timer cleanup on unmount or input change have no automated check. | `audit:Timestamp/behavior` |+| FR5, AR2 | `Timestamp.test.tsx` naming tests | Relative, absolute, time-zone spelling | A missing or short-zone name, or a name on absolute output, fails. A caller `aria-label` replaced on relative output fails. | `audit:Timestamp/a11y` |+| FR6, AR3 | `Timestamp.test.tsx` keyboard-reachability suite | Relative, absolute, disabled, entries removed | A missing tab stop, `aria-expanded` on the trigger, or a stray tab stop fails. The aria-expanded test also pins `aria-haspopup` on the Text wrapper, which is current behavior, not contract. Gap: no test covers focus on the timestamp while the card module loads, or `aria-controls`. | `audit:Timestamp/a11y` |+| FR7, FR8, AR4 | `Timestamp.test.tsx` hover-card suites, including "keeps a copyable labelled card a valid description list" and the default card's hidden zone name; `tooltipEntries.test.ts`; `useClipboard.test.tsx` | Default row, entries, copyable rows, unknown zone | A wrong row count or order, an unpaired label, a copy button on a read-only row, a wrong copied value, a missing copied state, or a missing announcement fails. Gap: no check runs the `definition-list` structure rule on the open card; the grid columns and the 1.5-second reset have no automated check; `useClipboard.test.tsx` covers the clipboard-rejection no-op. | `audit:Timestamp/behavior` |+| FR9 | `Timestamp.test.tsx` ref, test-id, and pass-through tests | Ref, test id, caller props | A ref, test id, or caller prop missing from the `time` element fails. A caller `tabIndex` replaced while a card is attached fails. Gap: no test asserts that `xstyle`, `className`, and `style` reach the Text wrapper, or covers a caller `aria-labelledby`. | `audit:Timestamp/behavior` |+| FR10 | `Timestamp.test.tsx` copy icon slot suite; the slot inventory test | No entry, a slot function in both states, `null`, a size request | The glyph ignores the slot or its state, `null` removes the button, its name, or its copy action, a size request resizes the button, or the consumer docs do not list the slot. | `audit:Timestamp/theming` |+| Theming anatomy map | `scripts/check-knowledge.mjs` | Consumer anatomy, targets, HoverCard delegate | Missing, extra, or stale mappings fail repository validation. | `audit:Timestamp/theming` |+| AR1 | `Timestamp.test.tsx` `datetime` tests | `date_time`; `date` | A missing or wrong ISO `datetime` on `date_time`, or a missing one on `date`, fails. Gap: no test asserts the exact `datetime` on relative or other absolute formats. | `audit:Timestamp/a11y` |+| AR2, AR4 | Accessibility-tree evidence (`spec:AST-009` FR3) | Relative output; copy buttons | Gap: no accessibility-tree check proves the computed name of relative output or the copy-button names; the unit tests query the DOM. | `audit:Timestamp/a11y` |## Decision logdiff --git a/packages/core/src/Timestamp/Timestamp.test.tsx b/packages/core/src/Timestamp/Timestamp.test.tsxindex c5cc9de3db..134a077051 100644--- a/packages/core/src/Timestamp/Timestamp.test.tsx+++ b/packages/core/src/Timestamp/Timestamp.test.tsx@@ -56,6 +56,15 @@ async function openTimestampHoverCard(): Promise<HTMLElement> {return screen.getByRole('dialog', {hidden: true});}+/** The long name of a zone at an instant, as Intl spells it in en-US. */+function longZoneName(timeZone?: string, at: Date = new Date()): string {+ return (+ new Intl.DateTimeFormat('en-US', {timeZoneName: 'long', timeZone})+ .formatToParts(at)+ .find(part => part.type === 'timeZoneName')?.value ?? ''+ );+}+describe('Timestamp', () => {// The hover card is loaded lazily (React.lazy + Suspense), so its chunk// resolves asynchronously the first time a card renders. Warm the module@@ -958,7 +967,12 @@ describe('Timestamp', () => {// aria-label spells the timezone out in full (WCAG 3.1.4), so the two// strings intentionally differ — compare the row against an// independently formatted short-form string.- expect(card.querySelectorAll('dd')).toHaveLength(1);+ // Without labels the card is still a description list: the value is+ // named by its long time-zone name, which is visually hidden.+ expect(card.querySelectorAll('dl > div > dd')).toHaveLength(1);+ expect(card.querySelector('dl > div > dt')?.textContent).toBe(+ longZoneName(),+ );expect(card.querySelectorAll('button')).toHaveLength(1);const normalize = (s: string) => s.replace(/\s+/g, ' ');@@ -980,7 +994,7 @@ describe('Timestamp', () => {it("copies the default absolute row's value", async () => {render(<Timestamp value={Date.now() / 1000 - 3600} format="relative" />);const card = await openTimestampHoverCard();- const rowValue = card.querySelector('dd')?.textContent ?? '';+ const rowValue = card.querySelector('dd > span')?.textContent ?? '';expect(rowValue).toBeTruthy();fireEvent.click(card.querySelector('button')!);expect(navigator.clipboard.writeText).toHaveBeenCalledWith(rowValue);@@ -1421,10 +1435,37 @@ describe('Timestamp', () => {);const card = await openTimestampHoverCard();// An unlabeled entry still emits its label cell, so the grid stays- // aligned and the <dl> stays valid markup.+ // aligned; its zone's long name, visually hidden, names its value.expect(card.querySelectorAll('dt')).toHaveLength(3);expect(card.querySelectorAll('dd')).toHaveLength(3);- expect(card.querySelectorAll('dt')[1].textContent).toBe('');+ expect(card.querySelectorAll('dt')[1].textContent).toBe(+ longZoneName('Asia/Tokyo', new Date(VALUE)),+ );+ });++ it('keeps a copyable labelled card a valid description list', async () => {+ render(+ <Timestamp+ value={VALUE}+ format="relative"+ tooltipEntries={[+ {timezoneID: 'UTC', label: 'UTC', isCopyable: true},+ {timezoneID: 'Asia/Tokyo', label: 'Tokyo'},+ ]}+ />,+ );+ const card = await openTimestampHoverCard();+ const list = card.querySelector('dl')!;+ // Each group holds only its dt and dd (WCAG 2.2 1.3.1); the copy+ // button sits inside the value.+ for (const group of Array.from(list.children)) {+ expect(group.tagName).toBe('DIV');+ expect(Array.from(group.children, el => el.tagName)).toEqual([+ 'DT',+ 'DD',+ ]);+ }+ expect(list.querySelectorAll('dd button')).toHaveLength(1);});it('gives the tab stop back when entries are removed', () => {diff --git a/packages/core/src/Timestamp/Timestamp.tsx b/packages/core/src/Timestamp/Timestamp.tsxindex e9fc6d9160..f5f91c3636 100644--- a/packages/core/src/Timestamp/Timestamp.tsx+++ b/packages/core/src/Timestamp/Timestamp.tsx@@ -34,7 +34,7 @@ import {useLocale} from '../i18n/useLocale';import {useCalendarSystem} from '../i18n/useCalendarSystem';import type {BaseProps} from '../BaseProps';import {themeProps} from '../utils/themeProps';-import {formatInstant} from './formatInstant';+import {formatInstant, formatZoneName} from './formatInstant';import {formatRelativeTime} from './formatRelativeTime';import {formatTooltipLines} from './tooltipEntries';import type {@@ -428,7 +428,13 @@ export function Timestamp({// full absolute time, itself copyable, just like a configured entry.const lines: ReadonlyArray<TimestampTooltipLine> =entries === undefined- ? [{value: fullAbsoluteText, isCopyable: true}]+ ? [+ {+ value: fullAbsoluteText,+ zoneName: isValidDate ? formatZoneName(date, locale) : '',+ isCopyable: true,+ },+ ]: formatTooltipLines(date, entries, locale, calendar);const timestampProps = mergeProps(diff --git a/packages/core/src/Timestamp/TimestampHoverCard.tsx b/packages/core/src/Timestamp/TimestampHoverCard.tsxindex 6601919b7e..5ba867c881 100644--- a/packages/core/src/Timestamp/TimestampHoverCard.tsx+++ b/packages/core/src/Timestamp/TimestampHoverCard.tsx@@ -15,8 +15,10 @@* columns — label, value, and a trailing action column for copy buttons —* so the buttons align down a single column no matter how wide each value* is. The action column is only added when at least one row is copyable, so- * a fully read-only card carries no dangling gutter. Label-less cards drop- * the label column and stack to whatever columns remain.+ * a fully read-only card carries no dangling gutter. A copy button sits+ * inside its row's value, which spans the value and action columns through+ * a subgrid. A row without a label is named by its zone's long name, which+ * is visually hidden. A card with no labels drops the label column.** SYNC: When modified, update these files to stay in sync:* - /packages/core/src/Timestamp/Timestamp.tsx (the lazy() + Suspense wrapper)@@ -32,6 +34,7 @@ import {IconButton} from '../IconButton/IconButton';import {ComponentIcon} from '../Icon/ComponentIcon';import {useClipboard} from '../hooks/useClipboard';import {themeProps} from '../utils/themeProps';+import {VisuallyHidden} from '../VisuallyHidden/VisuallyHidden';import {colorVars,spacingVars,@@ -87,6 +90,19 @@ const styles = stylex.create({padding: 0,whiteSpace: 'nowrap',},+ // A value carrying the action cell spans the value and action columns and+ // shares the card's tracks, so the copy buttons still align.+ // Without subgrid, a flex row keeps the button at the row's end.+ valueCells: {+ gridColumn: 'span 2',+ display: {+ default: 'flex',+ '@supports (grid-template-columns: subgrid)': 'grid',+ },+ justifyContent: 'space-between',+ gridTemplateColumns: 'subgrid',+ alignItems: 'center',+ },// The trailing action cell holds the copy button (or nothing, on a// read-only row). It lives in its own grid column so buttons align.action: {@@ -179,17 +195,28 @@ function EntryRow({hasLabelColumn: boolean;hasActionColumn: boolean;}) {+ // A description list holds only name-value groups, so the action cell lives+ // inside the value. A row without a label is named by its zone, out of+ // sight, so the card looks the same.+ const hasLabel = line.label != null && line.label !== '';+ const hiddenName = <VisuallyHidden>{line.zoneName}</VisuallyHidden>;return (<div {...stylex.props(styles.row)}>- {hasLabelColumn && (- <dt {...stylex.props(styles.label)}>{line.label ?? ''}</dt>- )}- <dd {...stylex.props(styles.value)}>{line.value}</dd>- {hasActionColumn && (- <div {...stylex.props(styles.action)}>- {line.isCopyable && <CopyButton value={line.value} />}- </div>+ {hasLabelColumn ? (+ <dt {...stylex.props(styles.label)}>+ {hasLabel ? line.label : hiddenName}+ </dt>+ ) : (+ <VisuallyHidden as="dt">{line.zoneName}</VisuallyHidden>)}+ <dd {...stylex.props(styles.value, hasActionColumn && styles.valueCells)}>+ {hasActionColumn ? <span>{line.value}</span> : line.value}+ {hasActionColumn && (+ <span {...stylex.props(styles.action)}>+ {line.isCopyable && <CopyButton value={line.value} />}+ </span>+ )}+ </dd></div>);}diff --git a/packages/core/src/Timestamp/formatInstant.ts b/packages/core/src/Timestamp/formatInstant.tsindex 7760e2f744..7f5f2a69ee 100644--- a/packages/core/src/Timestamp/formatInstant.ts+++ b/packages/core/src/Timestamp/formatInstant.ts@@ -137,6 +137,25 @@ function pad(n: number): string {return String(n).padStart(2, '0');}+/**+ * The long name of the zone an instant is shown in ("Pacific Standard Time"),+ * in the viewer's zone when no `timeZone` is given.+ */+export function formatZoneName(+ date: Date,+ locale: Locale,+ timeZone?: string,+): string {+ return (+ new Intl.DateTimeFormat(locale, {+ timeZoneName: 'long',+ ...(timeZone === undefined ? {} : {timeZone}),+ })+ .formatToParts(date)+ .find(part => part.type === 'timeZoneName')?.value ?? ''+ );+}+/*** Renders one instant in one absolute format.*diff --git a/packages/core/src/Timestamp/tooltipEntries.ts b/packages/core/src/Timestamp/tooltipEntries.tsindex d891390f4c..07763b13cb 100644--- a/packages/core/src/Timestamp/tooltipEntries.ts+++ b/packages/core/src/Timestamp/tooltipEntries.ts@@ -22,7 +22,7 @@*/import {devWarn} from '../utils/devWarning';-import {formatInstant} from './formatInstant';+import {formatInstant, formatZoneName} from './formatInstant';import type {InstantFormat} from './formatInstant';import type {Locale} from '../i18n/types';import type {CalendarSystem} from '../utils/calendarSystem';@@ -92,6 +92,8 @@ export interface TimestampTooltipEntry {/** A rendered tooltip line. */export interface TimestampTooltipLine {label?: string;+ /** The long name of the line's zone; it names a line without a label. */+ zoneName: string;value: string;isCopyable: boolean;}@@ -220,6 +222,7 @@ export function formatTooltipLines(return {...(entry.label === undefined ? {} : {label: entry.label}),isCopyable: entry.isCopyable ?? false,+ zoneName: formatZoneName(date, locale, timeZone),value: formatInstant(date, format, locale, {timeZone,calendar,