@camstack/ui-library 1.2.321 → 1.2.323

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,14 +1,24 @@
1
1
  /**
2
- * Fixed colors for known detection classes — derived from the taxonomy
3
- * (every detection/motion kind) plus the UI-only face/plate classes. Kept as
4
- * a named export for back-compat with existing consumers.
2
+ * Detection class colours — the bundled display palette (D939).
3
+ *
4
+ * A mounted {@link DisplayPaletteProvider} paints the cluster's effective
5
+ * palette instead. There is no second hex table here.
6
+ */
7
+ import { type PaletteReady } from "@camstack/types";
8
+ /**
9
+ * Fixed colours for known classes, from the bundled CamStack preset.
10
+ * Kept for callers that read the map directly.
5
11
  */
6
12
  export declare const CLASS_COLORS: Readonly<Record<string, string>>;
7
- /** Primary/default color when nothing else matches */
13
+ /** Primary colour when nothing else matches — the first bundled fallback. */
8
14
  export declare const DEFAULT_COLOR: string;
15
+ export interface PalettePaintSource {
16
+ readonly swatches: PaletteReady["swatches"];
17
+ readonly fallbacks: PaletteReady["fallbacks"];
18
+ }
9
19
  /**
10
- * Get the color for a detection class name.
11
- * Resolves: custom override → taxonomy/UI-only fixed color → deterministic
12
- * hash-based color for unknown classes.
20
+ * Colour for a detection class. Custom overrides win, then the palette
21
+ * (the bundled preset when none is passed). Unknown classes hash into
22
+ * the palette's fallbacks.
13
23
  */
14
- export declare function getClassColor(className: string, customColors?: Readonly<Record<string, string>>): string;
24
+ export declare function getClassColor(className: string, customColors?: Readonly<Record<string, string>>, palette?: PalettePaintSource): string;
@@ -38,9 +38,11 @@
38
38
  */
39
39
  import { type JSX } from "react";
40
40
  import type { PickerFleetView } from "./device-fleet-view";
41
- import { type PickerGroup, type PickerId, type PickerItem } from "./device-picker-model";
41
+ import { type PickerGroup, type PickerGroupBy, type PickerId, type PickerItem } from "./device-picker-model";
42
42
  import { type DeviceListState } from "./device-selection";
43
43
  import { type PickerNoun } from "./device-selection-rows";
44
+ /** One device, or the checklist every rule editor uses. */
45
+ export type DevicePickerSelection = "single" | "multiple";
44
46
  export interface DevicePickerProps<Id extends PickerId = number> {
45
47
  /** The devices the list DRAWS — the caller's answered list, `[]` otherwise. */
46
48
  readonly devices: readonly PickerItem<Id>[];
@@ -50,6 +52,16 @@ export interface DevicePickerProps<Id extends PickerId = number> {
50
52
  readonly fleet?: PickerFleetView<Id>;
51
53
  readonly value: readonly Id[];
52
54
  readonly onChange: (next: Id[]) => void;
55
+ /**
56
+ * `single`: one radio, no All/Clear, no "N selected". Choosing a row
57
+ * replaces `value` with that id. Default is the checklist.
58
+ */
59
+ readonly selection?: DevicePickerSelection;
60
+ /**
61
+ * Group this list by zone, location or none. Absent uses the remembered
62
+ * choice. A value here does not change that choice.
63
+ */
64
+ readonly groupBy?: PickerGroupBy;
53
65
  /** Empty selection means EVERY device: say so, and warn when it widens. */
54
66
  readonly emptyMeansAll?: boolean;
55
67
  /** Whether the saved rule had devices — the widening warning survives a remount. */
@@ -79,4 +91,4 @@ export interface DevicePickerProps<Id extends PickerId = number> {
79
91
  /** The line under a locked device. Default "Already added". */
80
92
  readonly lockedNote?: string;
81
93
  }
82
- export declare function DevicePicker<Id extends PickerId = number>({ devices: devicesIn, listState, fleet, value, onChange, emptyMeansAll, savedHadDevices, noun, groupTitle: groupTitleProp, emptyLabel, annotate, disabled, testId, showAll, lockedIds, lockedNote: lockedNoteProp }: DevicePickerProps<Id>): JSX.Element;
94
+ export declare function DevicePicker<Id extends PickerId = number>({ devices: devicesIn, listState, fleet, value, onChange, selection, groupBy: pinnedGroupBy, emptyMeansAll, savedHadDevices, noun, groupTitle: groupTitleProp, emptyLabel, annotate, disabled, testId, showAll, lockedIds, lockedNote: lockedNoteProp }: DevicePickerProps<Id>): JSX.Element;
@@ -1,4 +1,4 @@
1
- export { DevicePicker, type DevicePickerProps } from "./DevicePicker.js";
1
+ export { DevicePicker, type DevicePickerProps, type DevicePickerSelection } from "./DevicePicker.js";
2
2
  export { DeviceFilterBar, typeLabel, type DeviceFilterBarGrouping, type DeviceFilterBarProps } from "./device-filter-bar.js";
3
3
  export { fleetViewOf, type DeviceFleetView, type PickerFleetView } from "./device-fleet-view.js";
4
4
  export { DEVICE_PICKER_GROUP_STORAGE_KEY, readStoredGroupBy, writeStoredGroupBy, useStoredGroupBy, usePickerSiteZones, type StoredGroupBy } from "./device-picker-grouping.js";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The cluster palette, when a host has read `display-palette` (D939).
3
+ * No provider, a pending read, or an unknown store all paint the bundled
4
+ * CamStack preset. Only `ready` replaces it. Callers that must say the
5
+ * store was unreadable read {@link useDisplayPaletteView}.
6
+ */
7
+ import { type ReactNode } from "react";
8
+ import { type PaletteReady } from "@camstack/types";
9
+ export type DisplayPaletteView = {
10
+ readonly status: "absent";
11
+ } | {
12
+ readonly status: "pending";
13
+ } | {
14
+ readonly status: "unknown";
15
+ readonly reason: string;
16
+ } | {
17
+ readonly status: "ready";
18
+ readonly palette: PaletteReady;
19
+ };
20
+ export interface DisplayPaletteProviderProps {
21
+ readonly value: DisplayPaletteView;
22
+ readonly children: ReactNode;
23
+ }
24
+ export declare function DisplayPaletteProvider({ value, children }: DisplayPaletteProviderProps): ReactNode;
25
+ export declare function useDisplayPaletteView(): DisplayPaletteView;
26
+ export declare function useClassPainter(): (className: string, customColors?: Readonly<Record<string, string>>) => string;
@@ -98,6 +98,7 @@ export { ariaSortForColumn, nextSortDirection, nextTableSort, sortRowsByColumn }
98
98
  export type { Detection, DetectionCanvasProps } from "./detection-canvas";
99
99
  export { DetectionCanvas } from "./detection-canvas";
100
100
  export { CLASS_COLORS, DEFAULT_COLOR, getClassColor } from "./detection-colors";
101
+ export { DisplayPaletteProvider, useClassPainter, useDisplayPaletteView, type DisplayPaletteProviderProps, type DisplayPaletteView } from "./display-palette-context";
101
102
  export type { DetectionOverlayProps } from "./detection-overlay";
102
103
  export { DetectionOverlay } from "./detection-overlay";
103
104
  export type { DetectionResultTreeProps } from "./detection-result-tree";
@@ -781,6 +781,12 @@ export declare const useDishwasherSetOption: typeof trpc.dishwasher.setOption.us
781
781
  export declare const useDishwasherGetOptions: typeof trpc.dishwasher.getOptions.useQuery;
782
782
  /** Generated alias around `trpc.dishwasher.getStatus.useQuery`. */
783
783
  export declare const useDishwasherGetStatus: typeof trpc.dishwasher.getStatus.useQuery;
784
+ /** Generated alias around `trpc.displayPalette.getPalette.useQuery`. */
785
+ export declare const useDisplayPaletteGetPalette: typeof trpc.displayPalette.getPalette.useQuery;
786
+ /** Generated alias around `trpc.displayPalette.listPresets.useQuery`. */
787
+ export declare const useDisplayPaletteListPresets: typeof trpc.displayPalette.listPresets.useQuery;
788
+ /** Generated alias around `trpc.displayPalette.setPalette.useMutation`. */
789
+ export declare const useDisplayPaletteSetPalette: typeof trpc.displayPalette.setPalette.useMutation;
784
790
  /** Generated alias around `trpc.doorbell.getStatus.useQuery`. */
785
791
  export declare const useDoorbellGetStatus: typeof trpc.doorbell.getStatus.useQuery;
786
792
  /** Generated alias around `trpc.enumSensor.getStatus.useQuery`. */