@camstack/ui-library 1.2.324 → 1.2.326

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.
@@ -1,20 +1,10 @@
1
1
  /**
2
- * Shared, pure resolution of a sensor's DISPLAY unit + precision + value
3
- * transform. One function so the two renderers (`SensorValueAtom`,
4
- * `SensorHeroCard`) can never diverge — they duplicated this precedence before.
5
- *
6
- * Resolution order (device override → role default → live slice →
7
- * ROLE_DESCRIPTOR canonicalUnit). `??` everywhere, never `||`: `precision: 0`
8
- * is a legal override and must win over a slice `precision: 2`.
9
- *
10
- * Conversion happens at RENDER only — storage stays in source units. An
11
- * override unit converts the raw slice value ONLY when it shares a dimension
12
- * with the source unit (`canConvertUnit`); on refusal the display falls back to
13
- * identity + the SOURCE unit so a unit label and its value math can never
14
- * disagree. Precision applies AFTER conversion (by construction — the caller
15
- * runs `formatNumeric(toDisplayValue(raw), precision)`).
2
+ * Shared resolution of a sensor's display string. The stored number is always
3
+ * the quantity's base unit (D944 §4). A display preference (default metric)
4
+ * or an operator override picks the label; the value is converted to match.
16
5
  */
17
- import type { DeviceDisplayOverride, RoleDisplayDefault } from "@camstack/types";
6
+ import type { DeviceDisplayOverride, ReadingQuantity, RoleDisplayDefault } from "@camstack/types";
7
+ import { type DisplayPreference } from "@camstack/types";
18
8
  export interface SensorDisplayInput {
19
9
  /** Per-device override from the row (`DeviceInfo.display`). */
20
10
  readonly display?: DeviceDisplayOverride;
@@ -22,20 +12,28 @@ export interface SensorDisplayInput {
22
12
  readonly capName?: string;
23
13
  /** Role default (`roleDisplayDefaults[device.role]`). */
24
14
  readonly roleDefault?: RoleDisplayDefault;
25
- /** Live slice unit (the unit the raw VALUE is actually in, for generic sensors). */
26
- readonly sliceUnit?: string;
27
- /** Live slice precision. */
28
- readonly slicePrecision?: number;
29
- /** ROLE_DESCRIPTOR canonical unit fallback (typed roles). */
30
- readonly canonicalUnit?: string;
15
+ /** Quantity of the stored number. `device` reads `deviceQuantity`. */
16
+ readonly quantity?: ReadingQuantity;
17
+ /** The device's chosen quantity when `quantity` is `device`. */
18
+ readonly deviceQuantity?: ReadingQuantity;
19
+ /** Precision declared on the reading, when the operator has not overridden it. */
20
+ readonly declarationPrecision?: number;
21
+ /** Read-time preference. Defaults to metric. */
22
+ readonly preference?: DisplayPreference;
31
23
  }
32
24
  export interface ResolvedSensorDisplay {
33
- /** Display unit — `''` when none resolves anywhere. */
25
+ /** Display unit — `''` when the quantity has none. */
34
26
  readonly unit: string;
35
27
  /** Display precision (int 0-10) or undefined for auto-format. */
36
28
  readonly precision: number | undefined;
37
- /** Convert a raw slice value into the display unit. Identity unless an
38
- * override unit differs from the source unit AND both share a dimension. */
29
+ /** Convert a base-unit value into the display unit. */
39
30
  readonly toDisplayValue: (raw: number) => number;
31
+ /** Convert a display-unit value back into the stored base. */
32
+ readonly fromDisplayValue: (shown: number) => number;
33
+ /** Text and unit for one base-unit sample. */
34
+ readonly format: (raw: number) => {
35
+ readonly text: string;
36
+ readonly unit: string;
37
+ };
40
38
  }
41
39
  export declare function resolveSensorDisplay(input: SensorDisplayInput): ResolvedSensorDisplay;
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@camstack/ui-library",
3
- "version": "1.2.324",
3
+ "version": "1.2.326",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/camstack/server.git",
7
+ "directory": "packages/ui-library"
8
+ },
9
+ "homepage": "https://camstack-docs.zentik.app",
10
+ "bugs": {
11
+ "url": "https://github.com/camstack/server/issues"
12
+ },
4
13
  "type": "module",
5
14
  "main": "dist/index.cjs",
6
15
  "module": "dist/index.js",