@glasshome/widget-sdk 1.17.1 → 1.18.1

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.
@@ -87,6 +87,13 @@ var e = "https://glasshome.app/docs/widget-sdk/config", t = [
87
87
  replacement: "the Widget's tone or color; the fill follows the card",
88
88
  docsUrl: "https://glasshome.app/docs/widget-sdk/widget",
89
89
  sourcePattern: "<WidgetSliderFill[^>]*\\scolor="
90
+ },
91
+ {
92
+ id: "WidgetVariantConfig.layout",
93
+ since: "1.18.0",
94
+ removeIn: "2.0.0",
95
+ replacement: "WidgetVariantConfig.styles (container, class, cssVars)",
96
+ docsUrl: "https://glasshome.app/docs/widgets/widget-sdk#variants"
90
97
  }
91
98
  ];
92
99
  function n(e) {
@@ -52,7 +52,7 @@ export declare function WidgetAction(props: {
52
52
  /** Visible label; without one the action is a square icon control named by `aria-label`. */
53
53
  children?: JSX.Element;
54
54
  "aria-label"?: string;
55
- run: () => Promise<unknown> | unknown;
55
+ run: () => unknown;
56
56
  confirm?: Confirm;
57
57
  /** Key within a shared `confirm`; defaults to the label or icon. */
58
58
  id?: string;
@@ -20,4 +20,3 @@ export declare const WIDGET_Z: {
20
20
  /** Action layer (buttons, edit controls) */
21
21
  readonly ACTIONS: 30;
22
22
  };
23
- export type WidgetZIndex = (typeof WIDGET_Z)[keyof typeof WIDGET_Z];
@@ -29,7 +29,7 @@ export interface GestureHandlers {
29
29
  /** Keyboard door: Enter or Space taps, the context-menu key or Shift+F10 holds. */
30
30
  onKeyDown?: (e: KeyboardEvent) => void;
31
31
  }
32
- export interface HoldFlood {
32
+ interface HoldFlood {
33
33
  x: number;
34
34
  y: number;
35
35
  /** Radius that reaches the farthest corner, so the fill ends as the hold fires. */
@@ -4,7 +4,7 @@ export interface Confirm {
4
4
  /** Whether anything ran a moment ago. */
5
5
  any: () => boolean;
6
6
  /** Runs the action; resolves whether it succeeded. */
7
- run: (keys: string[], action: () => Promise<unknown> | unknown) => Promise<boolean>;
7
+ run: (keys: string[], action: () => unknown) => Promise<boolean>;
8
8
  }
9
9
  /**
10
10
  * For actions that leave no state to show (a scene, a button press, a stop): the keys that just ran,
@@ -38,9 +38,9 @@ export { isPanelControllable, PanelEntityRow } from "./panel/panel-entity";
38
38
  export { buildDebugData, WidgetDebugTab, type WidgetDebugData, type WidgetDebugEntity, WidgetDebugView, WidgetDialog, type SheetTile, type WidgetDialogProps, type WidgetDialogTab, } from "./dialogs";
39
39
  export { type AggregationPreset, type ReactiveWidgetContext, type ServiceCallFn, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, type Daylight, type DaylightPhase, useDaylight, useIntersectionPause, useReducedMotion, useWidgetContext, useWidgetDashboard, useWidgetViewer, useWidgetDialog, useWidgetDimensions, useWidgetEntityGroup, WidgetCtx, type WidgetDashboard, type WidgetViewer, type WidgetDialogReturn, type WidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./hooks";
40
40
  export { type GestureHandlers, useWidgetGestures } from "./gestures/use-widget-gestures";
41
- export { injectTokens, type SvgColorKey, svgColors, type Tone, ToneSchema, } from "./theming";
41
+ export { injectTokens, type SvgColorKey, svgColors, type Tone, ToneSchema } from "./theming";
42
42
  export { widgetFields } from "./fields";
43
43
  export { type ConfigShape, defineConfig, field, type Field, type ImagePresetSource, type Infer, } from "./config";
44
44
  export { imageSrc } from "./image-src";
45
45
  export { calculateLightGroup, calculateSensorGroup, type CopyState, copyText, countActiveEntities, getEntityAttribute, isEntityActive, type LightGroupResult, type SensorGroupResult, type SensorGroupType, useCopyText, } from "./utils";
46
- export type { EntityView, WidgetStyles, WidgetVariantConfig, } from "./types";
46
+ export type { EntityView, WidgetStyles, WidgetVariantConfig } from "./types";
@@ -1,7 +1,7 @@
1
1
  /** Core type definitions for the Widget Framework. */
2
2
  import type { JSX } from "solid-js";
3
3
  /** Slide gesture configuration */
4
- export interface SlideGestureConfig {
4
+ interface SlideGestureConfig {
5
5
  /** Current value */
6
6
  value: number;
7
7
  /** Value change handler */
@@ -18,7 +18,7 @@ export interface SlideGestureConfig {
18
18
  /**
19
19
  * Hold gesture configuration
20
20
  */
21
- export interface HoldGestureConfig {
21
+ interface HoldGestureConfig {
22
22
  /** Action to perform on hold */
23
23
  action: () => void;
24
24
  /** Hold delay in ms (default: 300) */
@@ -35,21 +35,15 @@ export interface GestureConfig {
35
35
  /** Slide gesture configuration */
36
36
  slide?: SlideGestureConfig;
37
37
  }
38
- /**
39
- * CSS variable-based styling configuration
40
- */
38
+ /** Look applied to the widget shell: inline style, utility classes and CSS custom properties. */
41
39
  export interface WidgetStyles {
42
- /** Inline CSS properties applied to widget container */
43
40
  container?: JSX.CSSProperties;
44
- /** Tailwind utility classes (for simple styling) */
45
41
  class?: string;
46
- /** CSS custom properties for themeable values */
47
42
  cssVars?: Record<`--widget-${string}` | `--glass-${string}`, string | number>;
48
43
  }
49
- /**
50
- * Flex layout strategy with type-safe configuration
51
- */
52
- export interface FlexLayoutStrategy {
44
+ type WidgetElement = "icon" | "title" | "subtitle" | "status" | "value" | "metrics" | "content" | "background" | "overlay" | "decorations";
45
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
46
+ type LayoutStrategy = {
53
47
  type: "flex";
54
48
  direction: "row" | "column" | "row-reverse" | "column-reverse";
55
49
  align: "start" | "center" | "end" | "stretch";
@@ -57,106 +51,69 @@ export interface FlexLayoutStrategy {
57
51
  wrap?: boolean;
58
52
  gap?: string;
59
53
  order?: Partial<Record<WidgetElement, number>>;
60
- }
61
- /**
62
- * Grid layout strategy with type-safe configuration
63
- */
64
- export interface GridLayoutStrategy {
54
+ } | {
65
55
  type: "grid";
66
56
  areas: string;
67
57
  columns?: string;
68
58
  rows?: string;
69
59
  gap?: string;
70
60
  elementAreas: Partial<Record<WidgetElement, string>>;
71
- }
72
- /**
73
- * Absolute positioning strategy with type-safe configuration
74
- */
75
- export interface AbsoluteLayoutStrategy {
61
+ } | {
76
62
  type: "absolute";
77
- positions: Partial<Record<WidgetElement, PositionConfig>>;
78
- }
79
- /**
80
- * Custom layout strategy (escape hatch)
81
- */
82
- export interface CustomLayoutStrategy {
63
+ positions: Partial<Record<WidgetElement, {
64
+ top?: string;
65
+ right?: string;
66
+ bottom?: string;
67
+ left?: string;
68
+ transform?: string;
69
+ }>>;
70
+ } | {
83
71
  type: "custom";
84
72
  renderer: string;
85
- }
86
- /**
87
- * Discriminated union of all layout strategies
88
- */
89
- export type LayoutStrategy = FlexLayoutStrategy | GridLayoutStrategy | AbsoluteLayoutStrategy | CustomLayoutStrategy;
90
- /**
91
- * Position configuration for absolute layout
92
- */
93
- export interface PositionConfig {
94
- top?: string;
95
- right?: string;
96
- bottom?: string;
97
- left?: string;
98
- transform?: string;
99
- }
100
- /**
101
- * Widget element identifiers for layout configuration
102
- */
103
- export type WidgetElement = "icon" | "title" | "subtitle" | "status" | "value" | "metrics" | "content" | "background" | "overlay" | "decorations";
104
- /**
105
- * Element-specific configuration
106
- */
107
- export interface ElementConfig {
108
- visible?: Partial<Record<WidgetElement, boolean>>;
109
- styles?: Partial<Record<WidgetElement, JSX.CSSProperties>>;
110
- classNames?: Partial<Record<WidgetElement, string>>;
111
- }
112
- /**
113
- * Plugin system configuration (serializable)
114
- */
115
- export interface VariantPlugins {
116
- background?: string;
117
- overlay?: string;
118
- decorations?: string[];
119
- }
120
- /**
121
- * Interaction configuration
122
- */
123
- export interface InteractionConfig {
124
- hover?: boolean;
125
- active?: boolean;
126
- focus?: boolean;
127
- hoverScale?: number;
128
- activeScale?: number;
129
- }
130
- /**
131
- * Complete variant configuration
132
- */
73
+ };
74
+ /** A custom shell look; only `styles` is applied. */
133
75
  export interface WidgetVariantConfig {
134
76
  id: string;
135
77
  name: string;
136
78
  description?: string;
137
79
  styles?: WidgetStyles;
80
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
138
81
  layout?: LayoutStrategy;
139
- elements?: ElementConfig;
140
- plugins?: VariantPlugins;
141
- interactions?: InteractionConfig;
82
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
83
+ elements?: {
84
+ visible?: Partial<Record<WidgetElement, boolean>>;
85
+ styles?: Partial<Record<WidgetElement, JSX.CSSProperties>>;
86
+ classNames?: Partial<Record<WidgetElement, string>>;
87
+ };
88
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
89
+ plugins?: {
90
+ background?: string;
91
+ overlay?: string;
92
+ decorations?: string[];
93
+ };
94
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
95
+ interactions?: {
96
+ hover?: boolean;
97
+ active?: boolean;
98
+ focus?: boolean;
99
+ hoverScale?: number;
100
+ activeScale?: number;
101
+ };
102
+ /** @deprecated Never read by the shell. Removed in 2.0.0. */
142
103
  extends?: string;
143
104
  }
144
- /**
145
- * Variant registry type
146
- */
147
- export type VariantRegistry = Record<string, WidgetVariantConfig>;
148
105
  /** Unique entity identifier (e.g., "light.living_room") */
149
- export type EntityId = string;
106
+ type EntityId = string;
150
107
  /** Entity domain (e.g., "light", "sensor", "switch") */
151
- export type EntityDomain = string;
108
+ type EntityDomain = string;
152
109
  /** Area identifier */
153
- export type AreaId = string;
110
+ type AreaId = string;
154
111
  /** Device identifier */
155
- export type DeviceId = string;
112
+ type DeviceId = string;
156
113
  /** Label identifier */
157
- export type LabelId = string;
114
+ type LabelId = string;
158
115
  /** Entity category for filtering */
159
- export type EntityCategory = "config" | "diagnostic" | null;
116
+ type EntityCategory = "config" | "diagnostic" | null;
160
117
  /**
161
118
  * Full entity view interface representing a Home Assistant entity.
162
119
  * This is the canonical type used by SDK framework utils and widgets.
@@ -219,3 +176,4 @@ export interface EntityView {
219
176
  /** Bitmask of supported features */
220
177
  supportedFeatures?: number;
221
178
  }
179
+ export {};
@@ -1,49 +1,6 @@
1
- /**
2
- * Empty State Utilities
3
- *
4
- * Helper functions for creating consistent empty state configurations across widgets.
5
- */
6
1
  import type { JSX } from "solid-js";
7
- /**
8
- * Empty state configuration for a widget
9
- */
10
2
  export interface WidgetEmptyStateConfig {
11
- /** Icon to display */
12
3
  icon: JSX.Element;
13
- /** Main title/heading */
14
4
  title: string;
15
- /** Descriptive message */
16
5
  message: string;
17
6
  }
18
- export interface EmptyStateConfigOptions {
19
- /** Icon to display */
20
- icon: JSX.Element;
21
- /** Main title/heading */
22
- title: string;
23
- /** Descriptive message (optional - uses default template if not provided) */
24
- message?: string;
25
- /** Entity type for default message template (e.g., "a light", "a lock") */
26
- entityType?: string;
27
- }
28
- /**
29
- * Creates a consistent empty state configuration for widgets
30
- *
31
- * @example
32
- * ```typescript
33
- * // Custom message
34
- * const config = createEmptyStateConfig({
35
- * icon: <Thermometer />,
36
- * title: "No climate entity",
37
- * message: "Configure this widget to add a climate device",
38
- * });
39
- *
40
- * // Default message template
41
- * const config = createEmptyStateConfig({
42
- * icon: <Lock />,
43
- * title: "No lock entity",
44
- * entityType: "a lock",
45
- * });
46
- * // Result: message = "Configure this widget to add a lock"
47
- * ```
48
- */
49
- export declare function createEmptyStateConfig(options: EmptyStateConfigOptions): WidgetEmptyStateConfig;
@@ -5,9 +5,8 @@
5
5
  * in this directory are still consumed internally even when not part of the
6
6
  * public re-export surface.
7
7
  */
8
- export { cn } from "./cn";
9
8
  export { copyText, type CopyState, useCopyText } from "./clipboard";
10
9
  export { calculateLightGroup, calculateSensorGroup, type LightGroupResult, type SensorGroupResult, type SensorGroupType, } from "./entity-aggregation";
11
- export { countActiveEntities, getEntityAttribute, isEntityActive, } from "./entity-state";
10
+ export { countActiveEntities, getEntityAttribute, isEntityActive } from "./entity-state";
12
11
  export { formatValue } from "./format-value";
13
12
  export { interpretValue } from "./interpret-value";
@@ -1,39 +1,2 @@
1
- /**
2
- * Built-in Widget Variants
3
- *
4
- * Simplified set of pre-built variant definitions that ship with the framework.
5
- * These variants can be used as-is or extended/composed.
6
- *
7
- * Includes 3 core variants (classic-glass, minimal, compact-horizontal).
8
- * Additional variants can be added later or created by widget authors
9
- * using the variant composition utilities.
10
- */
11
- import type { VariantRegistry, WidgetVariantConfig } from "../types";
12
- export declare const classicGlass: WidgetVariantConfig;
13
- export declare const minimal: WidgetVariantConfig;
14
- export declare const compactHorizontal: WidgetVariantConfig;
15
- /**
16
- * Built-in variant registry
17
- * Maps variant IDs to their configurations
18
- */
19
- export declare const builtInVariants: VariantRegistry;
20
- /**
21
- * Get a variant by ID from the built-in registry
22
- *
23
- * @param id Variant ID
24
- * @returns Variant configuration or undefined if not found
25
- */
26
- export declare function getBuiltInVariant(id: string): WidgetVariantConfig | undefined;
27
- /**
28
- * Check if a variant ID is a built-in variant
29
- *
30
- * @param id Variant ID to check
31
- * @returns True if the variant is built-in
32
- */
33
- export declare function isBuiltInVariant(id: string): boolean;
34
- /**
35
- * Get all built-in variant IDs
36
- *
37
- * @returns Array of built-in variant IDs
38
- */
39
- export declare function getBuiltInVariantIds(): string[];
1
+ import type { WidgetStyles } from "../types";
2
+ export declare function getBuiltInVariantStyles(id: string): WidgetStyles | undefined;