// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; /** * @file Timestamp.tsx * @input Uses React, Text, provider locale, and Timestamp formatters * @output Exports Timestamp component and related types * @position Core implementation; renders formatted timestamps * * SYNC: When modified, update these files to stay in sync: * - /packages/core/src/Timestamp/formatRelativeTime.ts * - /packages/core/src/Timestamp/Timestamp.doc.mjs * - /packages/core/src/Timestamp/Timestamp.test.tsx * - /packages/core/src/Timestamp/index.ts * - /apps/storybook/stories/Timestamp.stories.tsx * - /packages/cli/assets/templates/blocks/components/Timestamp/ (showcase blocks) */ import { lazy, Suspense, useEffect, useRef, useState } from 'react'; import * as stylex from "../style-runtime.js"; import { Text } from "../Text/index.js"; import type { TextType, TextSize, TextColor, TextWeight } from "../theme/types.js"; import { mergeProps } from "../utils/index.js"; import { useDevWarning } from "../hooks/useDevWarning.js"; import { useTranslator } from "../i18n/index.js"; import { useLocale } from "../i18n/useLocale.js"; import type { BaseProps } from "../BaseProps.js"; import { themeProps } from "../utils/themeProps.js"; import { formatInstant } from "./formatInstant.js"; import { formatRelativeTime } from "./formatRelativeTime.js"; import { formatTooltipLines } from "./tooltipEntries.js"; import type { TimestampTooltipEntry, TimestampTooltipLine } from "./tooltipEntries.js"; import { useMergedRefs } from "../hooks/useMergedRefs.js"; // Load the overlay lazily so a card-less Timestamp — the default — never // bundles HoverCard or the copy affordance's Icon/IconButton. Mirrors the code // split the read-only Tooltip path used before it. const LazyTimestampHoverCard = lazy(async () => import("./TimestampHoverCard.js")); // ============================================================================= // Types // ============================================================================= export type TimestampFormat = 'relative' | 'relative_short' | 'auto' | 'date' | 'date_long' | 'date_weekday' | 'date_time' | 'time' | 'system_date' | 'system_date_time' | 'system_time' | 'unix_seconds'; export interface TimestampProps extends BaseProps { /** Ref forwarded to the root `