@eqtylab/equality 3.7.0 → 3.9.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.
package/dist/index.d.cts CHANGED
@@ -838,19 +838,25 @@ declare const Tabs: ({ id, items, className, tabsListBackground, defaultValue, o
838
838
 
839
839
  declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React$1.RefAttributes<HTMLTextAreaElement>>;
840
840
 
841
- type FormatDateDisplayMode = 'relative' | 'absolute';
841
+ type FormatDateDisplayMode = 'relative' | 'absolute' | 'until' | 'since';
842
842
  interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
843
843
  /** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. A missing value (null, undefined, or empty string) renders a placeholder. */
844
844
  date: string | number | Date | null | undefined;
845
- /** Render relative ("2 weeks ago") or absolute ("Jun 09 2026, 18:42:03 UTC") time. */
845
+ /**
846
+ * How to render the date:
847
+ * - `absolute` — the full date and time ("Jun 09 2026, 18:42:03 UTC")
848
+ * - `relative` — idiomatic distance from now, in either direction ("2 weeks ago", "next week")
849
+ * - `until` — exact countdown to a future date ("10 days"), a placeholder once it has passed
850
+ * - `since` — exact time elapsed since a past date ("10 days ago"), a placeholder until it arrives
851
+ */
846
852
  displayAs?: FormatDateDisplayMode;
847
853
  /** Time zone used for absolute formatting. Defaults to "UTC". */
848
854
  timeZone?: string;
849
855
  /** BCP 47 locale used for formatting. Defaults to "en-US". */
850
856
  locale?: string;
851
- /** When relative, show a tooltip with the absolute time on hover/focus. Defaults to true. */
857
+ /** Unless absolute, show a tooltip with the absolute time on hover/focus. Defaults to true. */
852
858
  tooltip?: boolean;
853
- /** When relative, re-render on an interval so the value stays current. Defaults to true. */
859
+ /** Unless absolute, re-render on an interval so the value stays current. Defaults to true. */
854
860
  live?: boolean;
855
861
  /** Override the Intl options used for absolute formatting. */
856
862
  absoluteOptions?: Intl.DateTimeFormatOptions;
@@ -933,7 +939,7 @@ declare const TruncatedDescription: ({ className, description, maxLength, }: Tru
933
939
 
934
940
  declare const iconVariants: (props?: ({
935
941
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
936
- background?: "square" | "circle" | "transparent" | null | undefined;
942
+ background?: "circle" | "square" | "transparent" | null | undefined;
937
943
  } & class_variance_authority_types.ClassProp) | undefined) => string;
938
944
  declare const iconElevationVariants: (props?: ({
939
945
  elevation?: string | number | null | undefined;
@@ -1018,16 +1024,22 @@ declare const useTheme: () => readonly [Theme$1 | undefined, (theme: Theme$1) =>
1018
1024
  */
1019
1025
  declare const CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1020
1026
  /**
1021
- * Queue a rescan of every mounted code block, coalescing a frame's worth of mounts into one pass.
1027
+ * Queue a rescan of every code block in `root`, coalescing a frame's worth of mounts into one pass.
1028
+ *
1029
+ * `root` is the tree the block lives in, as `pre.getRootNode()` returns it, and defaults to the
1030
+ * document. Blocks are found by querying that tree, and a query never crosses a shadow boundary,
1031
+ * so a block inside a shadow root is only found by passing its root. Scanning is tree-wide rather
1032
+ * than per block because each pass replaces the ranges the previous one registered, so a per-block
1033
+ * call would erase the other blocks.
1022
1034
  *
1023
- * Scanning is document-wide by necessity: each `highlightAll` clears the ranges the last one
1024
- * registered, so a per-block call would erase every other block on the page. Blocks inside a
1025
- * shadow root are out of reach.
1035
+ * The highlighter forgets every range it registered on each pass, whatever tree it scanned, so a
1036
+ * pass on a shadow root clears the document's blocks and the reverse; the two cannot both stay
1037
+ * highlighted until upstream scopes that to the scanned tree.
1026
1038
  *
1027
- * Passes are serialized for the same reason. `highlightAll` collects its elements before awaiting
1028
- * their grammars and clears every registered range once they land, so overlapping passes let the
1029
- * slower one finish last and wipe the blocks it was too early to see.
1039
+ * Passes are serialized. `highlightAll` collects its elements before awaiting their grammars and
1040
+ * clears the registered ranges once they land, so overlapping passes let the slower one finish
1041
+ * last and wipe the blocks it was too early to see.
1030
1042
  */
1031
- declare const scheduleHighlight: () => Promise<void>;
1043
+ declare const scheduleHighlight: (root?: Node) => Promise<void>;
1032
1044
 
1033
1045
  export { Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeDisplayMode, type BadgeProps, BarGraph, type BarGraphProps, BarGraphSegment, type BarGraphSegmentProps, BgGradient, Button, type ButtonProps, CODE_BLOCK_ATTRIBUTE, Card, CardContent, CardContentHeader, type CardContentHeaderProps, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ControlStatusBadge, type ControlStatusBadgeDisplayMode, CopyButton, type CopyButtonProps, DateRangePicker, Dialog, DialogClose, DialogContainer, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHeaderIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayField, type DisplayFieldProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerHeaderActions, DrawerInnerContent, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSearch, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELEVATION, type Elevation, EmptyTableState, FilterDropdown, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatDate, type FormatDateDisplayMode, type FormatDateProps, Heading, Icon, IconButton, type IconButtonProps, type IconProps, InfoCard, Input, type InputProps, Label, ListOrGridViewToggle, LoadingOverlay, MetricCard, MotionCollapsibleContent, NotFound, PORTAL_ROOT_ID, Pagination, PanelLabel, Popover, PopoverContent, PopoverTrigger, PortalContainerProvider, Progress, ProgressIndicator, type ProgressIndicatorProps, ProgressIndicatorStep, type ProgressIndicatorStepProps, RadialGraph, type RadialGraphProps, RadioDropdown, RadioGroup, RadioGroupItem, ResourceBadge, type ResourceDisplayMode, type ResourceType, ScrollArea, ScrollBar, SearchBar, SectionHeading, type SegmentedControlOption, SegmentedControls, type SegmentedControlsDisplay, type SegmentedControlsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContainer, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetHeaderIcon, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, SortButton, type SortField, type SortMode, type SortOrder, SortSelector, Spinner, Switch, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContainer, TabsContent, TabsList, TabsTrigger, Textarea, type Theme, ThemeProvider, Toast, ToastAction, type ToastActionElement, ToastClose, ToastContainer, ToastDescription, type ToastProps$1 as ToastProps, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toaster, type ToasterToast, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruncatedDescription, type ViewMode, type ViewOrder, badgeVariants, buttonVariants, reducer, scheduleHighlight, toast, useFormField, usePortalContainer, useTheme, useToast };
package/dist/index.d.ts CHANGED
@@ -838,19 +838,25 @@ declare const Tabs: ({ id, items, className, tabsListBackground, defaultValue, o
838
838
 
839
839
  declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React$1.RefAttributes<HTMLTextAreaElement>>;
840
840
 
841
- type FormatDateDisplayMode = 'relative' | 'absolute';
841
+ type FormatDateDisplayMode = 'relative' | 'absolute' | 'until' | 'since';
842
842
  interface FormatDateProps extends Omit<React$1.TimeHTMLAttributes<HTMLTimeElement>, 'dateTime' | 'children'> {
843
843
  /** The date to display. Accepts an ISO 8601 string, epoch milliseconds, or a Date. A missing value (null, undefined, or empty string) renders a placeholder. */
844
844
  date: string | number | Date | null | undefined;
845
- /** Render relative ("2 weeks ago") or absolute ("Jun 09 2026, 18:42:03 UTC") time. */
845
+ /**
846
+ * How to render the date:
847
+ * - `absolute` — the full date and time ("Jun 09 2026, 18:42:03 UTC")
848
+ * - `relative` — idiomatic distance from now, in either direction ("2 weeks ago", "next week")
849
+ * - `until` — exact countdown to a future date ("10 days"), a placeholder once it has passed
850
+ * - `since` — exact time elapsed since a past date ("10 days ago"), a placeholder until it arrives
851
+ */
846
852
  displayAs?: FormatDateDisplayMode;
847
853
  /** Time zone used for absolute formatting. Defaults to "UTC". */
848
854
  timeZone?: string;
849
855
  /** BCP 47 locale used for formatting. Defaults to "en-US". */
850
856
  locale?: string;
851
- /** When relative, show a tooltip with the absolute time on hover/focus. Defaults to true. */
857
+ /** Unless absolute, show a tooltip with the absolute time on hover/focus. Defaults to true. */
852
858
  tooltip?: boolean;
853
- /** When relative, re-render on an interval so the value stays current. Defaults to true. */
859
+ /** Unless absolute, re-render on an interval so the value stays current. Defaults to true. */
854
860
  live?: boolean;
855
861
  /** Override the Intl options used for absolute formatting. */
856
862
  absoluteOptions?: Intl.DateTimeFormatOptions;
@@ -933,7 +939,7 @@ declare const TruncatedDescription: ({ className, description, maxLength, }: Tru
933
939
 
934
940
  declare const iconVariants: (props?: ({
935
941
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
936
- background?: "square" | "circle" | "transparent" | null | undefined;
942
+ background?: "circle" | "square" | "transparent" | null | undefined;
937
943
  } & class_variance_authority_types.ClassProp) | undefined) => string;
938
944
  declare const iconElevationVariants: (props?: ({
939
945
  elevation?: string | number | null | undefined;
@@ -1018,16 +1024,22 @@ declare const useTheme: () => readonly [Theme$1 | undefined, (theme: Theme$1) =>
1018
1024
  */
1019
1025
  declare const CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1020
1026
  /**
1021
- * Queue a rescan of every mounted code block, coalescing a frame's worth of mounts into one pass.
1027
+ * Queue a rescan of every code block in `root`, coalescing a frame's worth of mounts into one pass.
1028
+ *
1029
+ * `root` is the tree the block lives in, as `pre.getRootNode()` returns it, and defaults to the
1030
+ * document. Blocks are found by querying that tree, and a query never crosses a shadow boundary,
1031
+ * so a block inside a shadow root is only found by passing its root. Scanning is tree-wide rather
1032
+ * than per block because each pass replaces the ranges the previous one registered, so a per-block
1033
+ * call would erase the other blocks.
1022
1034
  *
1023
- * Scanning is document-wide by necessity: each `highlightAll` clears the ranges the last one
1024
- * registered, so a per-block call would erase every other block on the page. Blocks inside a
1025
- * shadow root are out of reach.
1035
+ * The highlighter forgets every range it registered on each pass, whatever tree it scanned, so a
1036
+ * pass on a shadow root clears the document's blocks and the reverse; the two cannot both stay
1037
+ * highlighted until upstream scopes that to the scanned tree.
1026
1038
  *
1027
- * Passes are serialized for the same reason. `highlightAll` collects its elements before awaiting
1028
- * their grammars and clears every registered range once they land, so overlapping passes let the
1029
- * slower one finish last and wipe the blocks it was too early to see.
1039
+ * Passes are serialized. `highlightAll` collects its elements before awaiting their grammars and
1040
+ * clears the registered ranges once they land, so overlapping passes let the slower one finish
1041
+ * last and wipe the blocks it was too early to see.
1030
1042
  */
1031
- declare const scheduleHighlight: () => Promise<void>;
1043
+ declare const scheduleHighlight: (root?: Node) => Promise<void>;
1032
1044
 
1033
1045
  export { Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeDisplayMode, type BadgeProps, BarGraph, type BarGraphProps, BarGraphSegment, type BarGraphSegmentProps, BgGradient, Button, type ButtonProps, CODE_BLOCK_ATTRIBUTE, Card, CardContent, CardContentHeader, type CardContentHeaderProps, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ControlStatusBadge, type ControlStatusBadgeDisplayMode, CopyButton, type CopyButtonProps, DateRangePicker, Dialog, DialogClose, DialogContainer, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHeaderIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayField, type DisplayFieldProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerHeaderActions, DrawerInnerContent, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSearch, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELEVATION, type Elevation, EmptyTableState, FilterDropdown, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatDate, type FormatDateDisplayMode, type FormatDateProps, Heading, Icon, IconButton, type IconButtonProps, type IconProps, InfoCard, Input, type InputProps, Label, ListOrGridViewToggle, LoadingOverlay, MetricCard, MotionCollapsibleContent, NotFound, PORTAL_ROOT_ID, Pagination, PanelLabel, Popover, PopoverContent, PopoverTrigger, PortalContainerProvider, Progress, ProgressIndicator, type ProgressIndicatorProps, ProgressIndicatorStep, type ProgressIndicatorStepProps, RadialGraph, type RadialGraphProps, RadioDropdown, RadioGroup, RadioGroupItem, ResourceBadge, type ResourceDisplayMode, type ResourceType, ScrollArea, ScrollBar, SearchBar, SectionHeading, type SegmentedControlOption, SegmentedControls, type SegmentedControlsDisplay, type SegmentedControlsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContainer, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetHeaderIcon, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, SortButton, type SortField, type SortMode, type SortOrder, SortSelector, Spinner, Switch, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContainer, TabsContent, TabsList, TabsTrigger, Textarea, type Theme, ThemeProvider, Toast, ToastAction, type ToastActionElement, ToastClose, ToastContainer, ToastDescription, type ToastProps$1 as ToastProps, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toaster, type ToasterToast, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruncatedDescription, type ViewMode, type ViewOrder, badgeVariants, buttonVariants, reducer, scheduleHighlight, toast, useFormField, usePortalContainer, useTheme, useToast };
package/dist/index.js CHANGED
@@ -1124,23 +1124,25 @@ function CopyButton({
1124
1124
  var CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1125
1125
  var SELECTOR = `pre[${CODE_BLOCK_ATTRIBUTE}] > code`;
1126
1126
  var tail = Promise.resolve();
1127
- var queued = null;
1127
+ var queued = /* @__PURE__ */ new Map();
1128
1128
  var isSupported = () => typeof window !== "undefined" && typeof CSS !== "undefined" && Boolean(CSS.highlights);
1129
- var scheduleHighlight = () => {
1129
+ var scheduleHighlight = (root) => {
1130
1130
  if (!isSupported()) return Promise.resolve();
1131
- if (queued) return queued;
1131
+ const tree = root ?? document;
1132
+ const pending = queued.get(tree);
1133
+ if (pending) return pending;
1132
1134
  const pass = tail.then(
1133
1135
  () => new Promise((resolve) => {
1134
1136
  window.requestAnimationFrame(() => {
1135
- queued = null;
1136
- highlightAll({ selector: SELECTOR }).then(
1137
+ queued.delete(tree);
1138
+ highlightAll({ root: tree, selector: SELECTOR }).then(
1137
1139
  () => resolve(),
1138
1140
  () => resolve()
1139
1141
  );
1140
1142
  });
1141
1143
  })
1142
1144
  );
1143
- queued = pass;
1145
+ queued.set(tree, pass);
1144
1146
  tail = pass;
1145
1147
  return pass;
1146
1148
  };
@@ -1154,9 +1156,11 @@ var CodeBlock = ({
1154
1156
  copy,
1155
1157
  lineNumbers = false
1156
1158
  }) => {
1159
+ const preRef = useRef(null);
1157
1160
  useEffect(() => {
1158
- void scheduleHighlight();
1159
- return () => void scheduleHighlight();
1161
+ const root = preRef.current?.getRootNode();
1162
+ void scheduleHighlight(root);
1163
+ return () => void scheduleHighlight(root);
1160
1164
  }, [code, language]);
1161
1165
  const gutter = useMemo(() => {
1162
1166
  if (!lineNumbers) return null;
@@ -1180,7 +1184,7 @@ var CodeBlock = ({
1180
1184
  "aria-label": title ? `${title}, code block` : "Code block",
1181
1185
  children: /* @__PURE__ */ jsxs("div", { className: cn(styles15.body, { [styles15.numbered]: lineNumbers }), children: [
1182
1186
  gutter && /* @__PURE__ */ jsx("pre", { "aria-hidden": "true", className: styles15.gutter, children: gutter }),
1183
- /* @__PURE__ */ jsx("pre", { className: styles15.pre, ...{ [CODE_BLOCK_ATTRIBUTE]: "" }, children: /* @__PURE__ */ jsx(
1187
+ /* @__PURE__ */ jsx("pre", { ref: preRef, className: styles15.pre, ...{ [CODE_BLOCK_ATTRIBUTE]: "" }, children: /* @__PURE__ */ jsx(
1184
1188
  "code",
1185
1189
  {
1186
1190
  className: cn(styles15.code, `language-${language}`, { [styles15.wrap]: !lineNumbers }),
@@ -3669,6 +3673,22 @@ var RELATIVE_DIVISIONS = [
3669
3673
  { amount: Number.POSITIVE_INFINITY, unit: "year" }
3670
3674
  ];
3671
3675
  var LIVE_INTERVAL_MS = 3e4;
3676
+ var MINUTE_MS = 6e4;
3677
+ var HOUR_MS = 60 * MINUTE_MS;
3678
+ var DAY_MS = 24 * HOUR_MS;
3679
+ var YEAR_MS = 365.25 * DAY_MS;
3680
+ var MONTH_MS = YEAR_MS / 12;
3681
+ var JUST_NOW_MS = 45e3;
3682
+ var COARSE_AFTER_MS = 90 * DAY_MS;
3683
+ var FINE_UNITS = [
3684
+ { ms: DAY_MS, unit: "day" },
3685
+ { ms: HOUR_MS, unit: "hour" },
3686
+ { ms: MINUTE_MS, unit: "minute" }
3687
+ ];
3688
+ var COARSE_UNITS = [
3689
+ { ms: YEAR_MS, unit: "year" },
3690
+ { ms: MONTH_MS, unit: "month" }
3691
+ ];
3672
3692
  var NO_DATE_PLACEHOLDER = "---";
3673
3693
  function isMissing(value) {
3674
3694
  return value == null || typeof value === "string" && value.trim() === "";
@@ -3681,8 +3701,8 @@ function formatAbsolute(date, timeZone, options, locale) {
3681
3701
  return new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(date);
3682
3702
  }
3683
3703
  function formatRelative(date, now, locale) {
3704
+ if (Math.abs(date.getTime() - now.getTime()) < JUST_NOW_MS) return "Just now";
3684
3705
  let duration = (date.getTime() - now.getTime()) / 1e3;
3685
- if (Math.abs(duration) < 45) return "Just now";
3686
3706
  const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
3687
3707
  for (const division of RELATIVE_DIVISIONS) {
3688
3708
  if (Math.abs(duration) < division.amount) {
@@ -3692,6 +3712,30 @@ function formatRelative(date, now, locale) {
3692
3712
  }
3693
3713
  return "Just now";
3694
3714
  }
3715
+ function measureSpan(spanMs) {
3716
+ const units = spanMs < COARSE_AFTER_MS ? FINE_UNITS : COARSE_UNITS;
3717
+ const index = units.findIndex(({ ms: ms2 }) => spanMs >= ms2);
3718
+ if (index === -1) return { value: 1, unit: units[units.length - 1].unit };
3719
+ const { ms, unit } = units[index];
3720
+ const value = Math.round(spanMs / ms);
3721
+ const next = units[index - 1];
3722
+ if (next && value * ms >= next.ms) {
3723
+ return { value: Math.round(spanMs / next.ms), unit: next.unit };
3724
+ }
3725
+ return { value, unit };
3726
+ }
3727
+ function formatDirected(date, now, mode, locale) {
3728
+ const spanMs = mode === "until" ? date.getTime() - now.getTime() : now.getTime() - date.getTime();
3729
+ if (spanMs <= 0) return null;
3730
+ if (mode === "since" && spanMs < JUST_NOW_MS) return "Just now";
3731
+ const { value, unit } = measureSpan(spanMs);
3732
+ if (mode === "until") {
3733
+ return new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(
3734
+ value
3735
+ );
3736
+ }
3737
+ return new Intl.RelativeTimeFormat(locale, { numeric: "always" }).format(-value, unit);
3738
+ }
3695
3739
  function FormatDate({
3696
3740
  date,
3697
3741
  displayAs = "absolute",
@@ -3707,13 +3751,13 @@ function FormatDate({
3707
3751
  const parsed = React15.useMemo(() => isMissing(date) ? null : toDate(date), [date]);
3708
3752
  const [now, setNow] = React15.useState(() => /* @__PURE__ */ new Date());
3709
3753
  const [mounted, setMounted] = React15.useState(false);
3710
- const isRelative = displayAs === "relative";
3754
+ const isAbsolute = displayAs === "absolute";
3711
3755
  React15.useEffect(() => setMounted(true), []);
3712
3756
  React15.useEffect(() => {
3713
- if (!isRelative || !live) return;
3757
+ if (isAbsolute || !live) return;
3714
3758
  const id = setInterval(() => setNow(/* @__PURE__ */ new Date()), LIVE_INTERVAL_MS);
3715
3759
  return () => clearInterval(id);
3716
- }, [isRelative, live]);
3760
+ }, [isAbsolute, live]);
3717
3761
  if (missing) {
3718
3762
  return /* @__PURE__ */ jsx("span", { className: cn(styles57["format-date"], className), "aria-label": "No date", ...props, children: NO_DATE_PLACEHOLDER });
3719
3763
  }
@@ -3727,12 +3771,23 @@ function FormatDate({
3727
3771
  absoluteOptions ?? DEFAULT_ABSOLUTE_OPTIONS,
3728
3772
  locale
3729
3773
  );
3730
- if (!isRelative) {
3774
+ if (isAbsolute) {
3731
3775
  return /* @__PURE__ */ jsx("time", { dateTime: machineValue, className: cn(styles57["format-date"], className), ...props, children: absolute });
3732
3776
  }
3733
- const relative = mounted ? formatRelative(parsed, now, locale) : absolute;
3777
+ const measured = !mounted ? absolute : displayAs === "relative" ? formatRelative(parsed, now, locale) : formatDirected(parsed, now, displayAs, locale);
3778
+ if (measured === null) {
3779
+ return /* @__PURE__ */ jsx(
3780
+ "span",
3781
+ {
3782
+ className: cn(styles57["format-date"], className),
3783
+ "aria-label": displayAs === "until" ? "Date has passed" : "Date not yet reached",
3784
+ ...props,
3785
+ children: NO_DATE_PLACEHOLDER
3786
+ }
3787
+ );
3788
+ }
3734
3789
  if (!tooltip) {
3735
- return /* @__PURE__ */ jsx("time", { dateTime: machineValue, className: cn(styles57["format-date"], className), ...props, children: relative });
3790
+ return /* @__PURE__ */ jsx("time", { dateTime: machineValue, className: cn(styles57["format-date"], className), ...props, children: measured });
3736
3791
  }
3737
3792
  return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
3738
3793
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
@@ -3742,7 +3797,7 @@ function FormatDate({
3742
3797
  tabIndex: 0,
3743
3798
  className: cn(styles57["format-date"], styles57["format-date--interactive"], className),
3744
3799
  ...props,
3745
- children: relative
3800
+ children: measured
3746
3801
  }
3747
3802
  ) }),
3748
3803
  /* @__PURE__ */ jsx(TooltipContent, { children: absolute })