@danxbot/ui 21.1.0 → 21.2.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.js +13276 -13191
- package/dist/index.js.map +1 -1
- package/dist/types/components/RelativeTime.d.ts +17 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lib/time/instant.d.ts +2 -0
- package/dist/types/lib/time/relativeAge.d.ts +4 -1
- package/dist/types/lib/time/relativeClock.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type RelativeFormat } from "../lib/time/relativeClock";
|
|
3
|
+
export interface RelativeTimeProps {
|
|
4
|
+
/** The moment: an ISO string, epoch millis or a `Date`. */
|
|
5
|
+
at: string | number | Date;
|
|
6
|
+
/** Words for the moment as of `now`. Default: `relativeAge` in the provider's words and locale. A pure function of `(at, now)`, and a STABLE one (memoize it; a new `format` re-reads when the text next changes). */
|
|
7
|
+
format?: RelativeFormat;
|
|
8
|
+
/** The tooltip content. Default: the absolute moment, in the provider's locale. `false` for none (the caller wraps its own). */
|
|
9
|
+
tooltip?: ReactNode | false;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The text of a moment, re-read whenever it changes: what `RelativeTime` draws, for a caller that needs the words themselves
|
|
14
|
+
* (a sentence built around them, a layout key that must move when the shown age does). Same `format` rules as `RelativeTimeProps`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useRelativeText(at: string | number | Date, format?: RelativeFormat): string;
|
|
17
|
+
export declare function RelativeTime({ at, format, tooltip, className }: RelativeTimeProps): import("react").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -134,6 +134,9 @@ export { ContextMeter, ChatStatus, type ContextMeterProps, type ContextSegment,
|
|
|
134
134
|
export { cn } from "./lib/cn";
|
|
135
135
|
export { formatBytes, formatTokens, formatCompactNumber } from "./lib/format";
|
|
136
136
|
export { copyText } from "./lib/clipboard";
|
|
137
|
+
export { RelativeTime, useRelativeText, type RelativeTimeProps } from "./components/RelativeTime";
|
|
138
|
+
export type { RelativeFormat } from "./lib/time/relativeClock";
|
|
139
|
+
export { toEpochMs } from "./lib/time/instant";
|
|
137
140
|
export { CopyValue, type CopyValueProps } from "./components/CopyValue";
|
|
138
141
|
export { formatDate, parseDate, formatDateTime, parseDateTime, type FormatDateTimeOptions, type ParseDateTimeOptions, formatCurrency, parseCurrency, formatNumber, parseNumber, type FormatNumberOptions, formatBoolean, parseBoolean, type FormatBooleanOptions, } from "./lib/values";
|
|
139
142
|
export { COMPONENT_GUIDANCE, type ComponentGuidanceRule } from "./lib/component-guidance";
|
|
@@ -11,5 +11,8 @@ import type { RelativeAgeStrings } from "../i18n/areas/formats";
|
|
|
11
11
|
* every sibling formatter in this codebase — nobody needs "9d ago" instead
|
|
12
12
|
* of "1w 2d ago", and nobody needs either instead of a calendar date, but a
|
|
13
13
|
* chat message's hover row has no room for a calendar date, so weeks it is.
|
|
14
|
+
*
|
|
15
|
+
* `now` is the instant to measure against (default: the clock). `RelativeTime`'s shared ticker passes later instants to find
|
|
16
|
+
* when this text next changes.
|
|
14
17
|
*/
|
|
15
|
-
export declare function relativeAge(when: string | number | Date, strings: RelativeAgeStrings, locale: string): string;
|
|
18
|
+
export declare function relativeAge(when: string | number | Date, strings: RelativeAgeStrings, locale: string, now?: number): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The text of a moment as of `now` (epoch ms). `relativeAge` is one. */
|
|
2
|
+
export type RelativeFormat = (at: string | number | Date, now?: number) => string;
|
|
3
|
+
/** The first instant after `now` at which `format(at, instant)` differs from `format(at, now)`, within `HORIZON_MS`. */
|
|
4
|
+
export declare function nextTextChangeAt(at: number, format: RelativeFormat, now: number): number;
|
|
5
|
+
/** Calls `onChange` whenever `format(at)` may now read differently. Returns the unsubscribe. The last unsubscribe stops the timer. */
|
|
6
|
+
export declare function subscribeRelativeClock(at: number, format: RelativeFormat, onChange: () => void): () => void;
|
|
7
|
+
/** Mounted subscribers right now; the tests pin that it returns to zero. */
|
|
8
|
+
export declare function relativeClockSubscriberCount(): number;
|