@camstack/ui-library 1.2.200 → 1.2.201

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.cjs CHANGED
@@ -45811,9 +45811,11 @@ function resolveControlAlign(type, placement) {
45811
45811
  * Relative "last seen" formatter for the offline affordance.
45812
45812
  *
45813
45813
  * Renders a short relative-time label from a millisecond epoch:
45814
- * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for
45815
- * missing/non-positive inputs so callers can render nothing rather
45816
- * than a misleading "—" or "NaN ago".
45814
+ * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for missing
45815
+ * inputs, or inputs below {@link MIN_PLAUSIBLE_TIMESTAMP_MS} (a
45816
+ * placeholder or a seeded "known value, unknown change time" stamp), so
45817
+ * callers can render nothing rather than a misleading "—", "NaN ago", or
45818
+ * (for a seeded `1`) "20000 days ago".
45817
45819
  *
45818
45820
  * Future timestamps (clock skew between the device and the browser)
45819
45821
  * collapse to "just now" instead of a negative duration.
@@ -45823,8 +45825,15 @@ var MINUTE_MS = 60 * SECOND_MS;
45823
45825
  var HOUR_MS = 60 * MINUTE_MS;
45824
45826
  var DAY_MS = 24 * HOUR_MS;
45825
45827
  var JUST_NOW_MS = 30 * SECOND_MS;
45828
+ /**
45829
+ * The earliest timestamp a real "last seen" could plausibly carry. Below
45830
+ * this, a value is a placeholder or a seeded "known value, unknown change
45831
+ * time" stamp (e.g. Homematic's `HM_SEEDED_CHANGED_AT = 1`) — never a real
45832
+ * instant. Year 2000 predates every device this renders.
45833
+ */
45834
+ var MIN_PLAUSIBLE_TIMESTAMP_MS = Date.UTC(2e3, 0, 1);
45826
45835
  function formatLastSeen(timestampMs) {
45827
- if (timestampMs === null || timestampMs === void 0 || timestampMs <= 0) return null;
45836
+ if (timestampMs === null || timestampMs === void 0 || timestampMs < MIN_PLAUSIBLE_TIMESTAMP_MS) return null;
45828
45837
  const delta = Date.now() - timestampMs;
45829
45838
  if (delta < JUST_NOW_MS) return "just now";
45830
45839
  if (delta < HOUR_MS) return `${String(Math.floor(delta / MINUTE_MS))}m ago`;
package/dist/index.js CHANGED
@@ -45787,9 +45787,11 @@ function resolveControlAlign(type, placement) {
45787
45787
  * Relative "last seen" formatter for the offline affordance.
45788
45788
  *
45789
45789
  * Renders a short relative-time label from a millisecond epoch:
45790
- * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for
45791
- * missing/non-positive inputs so callers can render nothing rather
45792
- * than a misleading "—" or "NaN ago".
45790
+ * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for missing
45791
+ * inputs, or inputs below {@link MIN_PLAUSIBLE_TIMESTAMP_MS} (a
45792
+ * placeholder or a seeded "known value, unknown change time" stamp), so
45793
+ * callers can render nothing rather than a misleading "—", "NaN ago", or
45794
+ * (for a seeded `1`) "20000 days ago".
45793
45795
  *
45794
45796
  * Future timestamps (clock skew between the device and the browser)
45795
45797
  * collapse to "just now" instead of a negative duration.
@@ -45799,8 +45801,15 @@ var MINUTE_MS = 60 * SECOND_MS;
45799
45801
  var HOUR_MS = 60 * MINUTE_MS;
45800
45802
  var DAY_MS = 24 * HOUR_MS;
45801
45803
  var JUST_NOW_MS = 30 * SECOND_MS;
45804
+ /**
45805
+ * The earliest timestamp a real "last seen" could plausibly carry. Below
45806
+ * this, a value is a placeholder or a seeded "known value, unknown change
45807
+ * time" stamp (e.g. Homematic's `HM_SEEDED_CHANGED_AT = 1`) — never a real
45808
+ * instant. Year 2000 predates every device this renders.
45809
+ */
45810
+ var MIN_PLAUSIBLE_TIMESTAMP_MS = Date.UTC(2e3, 0, 1);
45802
45811
  function formatLastSeen(timestampMs) {
45803
- if (timestampMs === null || timestampMs === void 0 || timestampMs <= 0) return null;
45812
+ if (timestampMs === null || timestampMs === void 0 || timestampMs < MIN_PLAUSIBLE_TIMESTAMP_MS) return null;
45804
45813
  const delta = Date.now() - timestampMs;
45805
45814
  if (delta < JUST_NOW_MS) return "just now";
45806
45815
  if (delta < HOUR_MS) return `${String(Math.floor(delta / MINUTE_MS))}m ago`;
@@ -2,11 +2,20 @@
2
2
  * Relative "last seen" formatter for the offline affordance.
3
3
  *
4
4
  * Renders a short relative-time label from a millisecond epoch:
5
- * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for
6
- * missing/non-positive inputs so callers can render nothing rather
7
- * than a misleading "—" or "NaN ago".
5
+ * "just now", "5m ago", "3h ago", "2d ago". Returns `null` for missing
6
+ * inputs, or inputs below {@link MIN_PLAUSIBLE_TIMESTAMP_MS} (a
7
+ * placeholder or a seeded "known value, unknown change time" stamp), so
8
+ * callers can render nothing rather than a misleading "—", "NaN ago", or
9
+ * (for a seeded `1`) "20000 days ago".
8
10
  *
9
11
  * Future timestamps (clock skew between the device and the browser)
10
12
  * collapse to "just now" instead of a negative duration.
11
13
  */
14
+ /**
15
+ * The earliest timestamp a real "last seen" could plausibly carry. Below
16
+ * this, a value is a placeholder or a seeded "known value, unknown change
17
+ * time" stamp (e.g. Homematic's `HM_SEEDED_CHANGED_AT = 1`) — never a real
18
+ * instant. Year 2000 predates every device this renders.
19
+ */
20
+ export declare const MIN_PLAUSIBLE_TIMESTAMP_MS: number;
12
21
  export declare function formatLastSeen(timestampMs: number | null | undefined): string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/ui-library",
3
- "version": "1.2.200",
3
+ "version": "1.2.201",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",