@tempots/ui 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,3 +1,68 @@
1
1
  import { Value } from '@tempots/dom';
2
- export declare function timeDiffToString(diffInMillis: number): string;
3
- export declare const makeRelativeTime: (date: Value<Date>, now?: Value<Date>) => import('@tempots/dom').Computed<string>;
2
+ /**
3
+ * Creates a signal that automatically updates with the current time at a specified frequency.
4
+ * The signal will clean up its interval when disposed.
5
+ *
6
+ * @param frequency - Milliseconds between updates (defaults to 1000ms/1 second)
7
+ * @returns A Value<Date> that updates with the current time at the specified frequency
8
+ * @public
9
+ */
10
+ export declare const makeNowSignal: (frequency?: number) => Value<Date>;
11
+ /**
12
+ * Converts a time difference in milliseconds to a human-readable relative time string.
13
+ *
14
+ * @param diffInMillis - The time difference in milliseconds. Negative values indicate past times,
15
+ * positive values indicate future times.
16
+ * @returns A human-readable string representing the relative time difference:
17
+ * - For very recent times (< 1 minute): "just now" or "in a moment"
18
+ * - For other times: formatted strings like "2 minutes ago", "in 3 hours", "yesterday", etc.
19
+ * @throws {Error} Should never throw due to the Infinity max value in units array
20
+ * @public
21
+ */
22
+ export declare const timeDiffToString: (diffInMillis: number) => string;
23
+ /**
24
+ * Creates a signal that computes the time difference in milliseconds between a target date and a reference date.
25
+ *
26
+ * @param date - The target date to compare
27
+ * @param options - Configuration options
28
+ * @param options.now - Optional reference date signal (defaults to current time)
29
+ * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds)
30
+ * @returns A signal containing the time difference in milliseconds. Negative values indicate past times,
31
+ * positive values indicate future times. The signal will clean up its resources when disposed.
32
+ * @public
33
+ */
34
+ export declare const makeRelativeTimeMillisSignal: (date: Value<Date>, { now, frequency }?: {
35
+ now?: Value<Date>;
36
+ frequency?: number;
37
+ }) => import('@tempots/dom').Computed<number>;
38
+ /**
39
+ * Creates a signal that computes a human-readable relative time string between a target date and a reference date.
40
+ *
41
+ * @param date - The target date to compare
42
+ * @param options - Configuration options
43
+ * @param options.now - Optional reference date signal (defaults to current time)
44
+ * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds)
45
+ * @returns A signal containing a human-readable relative time string (e.g., "2 minutes ago", "in 3 hours").
46
+ * The signal will clean up its resources when disposed.
47
+ * @public
48
+ */
49
+ export declare const makeRelativeTimeSignal: (date: Value<Date>, options?: {
50
+ now?: Value<Date>;
51
+ frequency?: number;
52
+ }) => import('@tempots/dom').Computed<string>;
53
+ /**
54
+ * Creates a signal that computes a human-readable relative time string between a target date and a reference date.
55
+ *
56
+ * @param date - The target date to compare
57
+ * @param options - Configuration options
58
+ * @param options.now - Optional reference date signal (defaults to current time)
59
+ * @param options.frequency - Update frequency in milliseconds when using default current time (defaults to 10000ms/10 seconds)
60
+ * @returns A signal containing a human-readable relative time string (e.g., "2 minutes ago", "in 3 hours").
61
+ * The signal will clean up its resources when disposed.
62
+ * @deprecated Use makeRelativeTimeSignal instead
63
+ * @public
64
+ */
65
+ export declare const makeRelativeTime: (date: Value<Date>, options?: {
66
+ now?: Value<Date>;
67
+ frequency?: number;
68
+ }) => import('@tempots/dom').Computed<string>;
package/utils/ticker.d.ts CHANGED
@@ -1,5 +1,22 @@
1
1
  import { Prop } from '@tempots/dom';
2
+ /**
3
+ * A property that can be used to force an update. Internally, it's a number that is incremented by one on each tick.
4
+ * Extends the Prop class with a number value.
5
+ *
6
+ * It can be used as a counter Signal.
7
+ * @public
8
+ */
2
9
  export declare class Ticker extends Prop<number> {
10
+ /**
11
+ * Triggers an update of the Ticker by incrementing its internal value.
12
+ * @returns void
13
+ */
3
14
  readonly tick: () => void;
4
15
  }
16
+ /**
17
+ * Creates a new Ticker instance with an optional initial value.
18
+ * @param initial - The initial value for the ticker (defaults to 0)
19
+ * @returns A new Ticker instance that only updates when the value changes
20
+ * @public
21
+ */
5
22
  export declare const makeTicker: (initial?: number) => Ticker;