@glasshome/widget-sdk 0.3.7 → 0.4.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.
- package/README.md +18 -0
- package/dist/framework/backgrounds/WidgetSliderFill.d.ts +24 -13
- package/dist/framework/components/WidgetContent.d.ts +2 -1
- package/dist/framework/components/WidgetIcon.d.ts +22 -24
- package/dist/framework/components/WidgetStatus.d.ts +2 -1
- package/dist/framework/components/WidgetTitle.d.ts +2 -1
- package/dist/framework/components/WidgetValue.d.ts +2 -1
- package/dist/framework/core/Widget.d.ts +30 -31
- package/dist/framework/gestures/cursors.d.ts +2 -1
- package/dist/framework/hooks/index.d.ts +2 -9
- package/dist/framework/hooks/use-widget-context.d.ts +0 -5
- package/dist/framework/index.d.ts +4 -16
- package/dist/framework/theming/index.d.ts +4 -5
- package/dist/framework/theming/tokens.d.ts +24 -0
- package/dist/framework/theming/tone.d.ts +10 -0
- package/dist/framework/types.d.ts +0 -67
- package/dist/framework/utils/entity-state.d.ts +0 -62
- package/dist/framework/utils/index.d.ts +5 -5
- package/dist/index.d.ts +2 -4
- package/dist/index.js +820 -1479
- package/dist/theme.d.ts +0 -12
- package/package.json +1 -2
- package/dist/create-entity.d.ts +0 -22
- package/dist/framework/backgrounds/Glow.d.ts +0 -24
- package/dist/framework/components/WidgetEmptyState.d.ts +0 -34
- package/dist/framework/components/WidgetMetrics.d.ts +0 -47
- package/dist/framework/components/WidgetSubtitle.d.ts +0 -28
- package/dist/framework/design-system/index.d.ts +0 -8
- package/dist/framework/hooks/use-debug-data.d.ts +0 -46
- package/dist/framework/hooks/use-widget-config.d.ts +0 -48
- package/dist/framework/hooks/use-widget-entity.d.ts +0 -53
- package/dist/framework/hooks/use-widget-form.d.ts +0 -79
- package/dist/framework/hooks/use-widget-responsive.d.ts +0 -41
- package/dist/framework/layout/WidgetStack.d.ts +0 -28
- package/dist/framework/theming/adaptive-color.d.ts +0 -28
- package/dist/framework/theming/colors.d.ts +0 -59
package/README.md
CHANGED
|
@@ -68,6 +68,24 @@ Provides a `@source` directive for Tailwind v4 so the compiler scans widget SDK
|
|
|
68
68
|
@source "@glasshome/widget-sdk/tailwind-sources";
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Escape patterns, when widgets own their visual surface
|
|
72
|
+
|
|
73
|
+
Most widgets route through the channel API: `<Widget tone>` / `<Widget color colorTo>` / `<Widget.Icon color>`. A small number of widgets intentionally own their entire visual surface and bypass the channel. These are supported escape patterns, not anti-patterns.
|
|
74
|
+
|
|
75
|
+
### Weather, full-background scenes
|
|
76
|
+
|
|
77
|
+
The `weather` widget renders a `<WeatherBackground condition>` component that replaces the shell gradient entirely with an animated per-condition scene (sunny rays, rain droplets, snow particles). Channel vars do not apply to the shell; `Widget.Icon color` still receives a CSS string per condition for the icon badge.
|
|
78
|
+
|
|
79
|
+
### Media-player, vinyl gradient
|
|
80
|
+
|
|
81
|
+
The `media-player` widget composes a custom `<VinylRecord>` element with an album-art radial overlay. The visual identity is content-driven (album artwork) rather than tone-driven; the channel base color stays neutral underneath.
|
|
82
|
+
|
|
83
|
+
### Area, per-metric pill colors
|
|
84
|
+
|
|
85
|
+
The `area` widget renders quick-glance metric pills (CO2 traffic-light, humidity range, temperature) where each pill's color encodes the metric's *semantic state* (CO2 green/amber/red, humidity dry/comfortable/humid). These per-metric color rules are intentionally semantic-per-metric, not channel-driven, and live in the widget's own helpers.
|
|
86
|
+
|
|
87
|
+
If your widget needs full visual control (a chart, a video stream, a custom animated surface), follow these patterns: keep the `<Widget>` shell neutral (no `tone`/`color`), place your custom DOM inside `<Widget.Content>`, and document the choice in the widget's README.
|
|
88
|
+
|
|
71
89
|
## Peer Dependencies
|
|
72
90
|
|
|
73
91
|
| Package | Required | Notes |
|
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WidgetSliderFill Component
|
|
3
3
|
*
|
|
4
|
-
* Animated fill overlay that follows a slider value.
|
|
5
|
-
*
|
|
4
|
+
* Animated fill overlay that follows a slider value. Background and glow are
|
|
5
|
+
* rendered by the `.glasshome-widget-slider-fill` CSS rule in tokens.css via
|
|
6
|
+
* the channel vars (`--widget-icon-color` with fallback to `--widget-color`).
|
|
7
|
+
* The `color` prop is the optional per-fill override: when provided it is
|
|
8
|
+
* written inline as `--widget-icon-color`, mirroring `Widget.Icon.color`
|
|
9
|
+
* (Phase 26 VIS-A05). Orientation is inherited from the parent Widget context
|
|
10
|
+
* and drives the `clip-path` direction.
|
|
6
11
|
*
|
|
7
|
-
* @example
|
|
12
|
+
* @example Default, inherits parent Widget channel color
|
|
8
13
|
* ```tsx
|
|
9
|
-
* <Widget gestures={{ slide: { value, onChange } }}>
|
|
10
|
-
* <Widget.SliderFill value={
|
|
14
|
+
* <Widget tone="info" gestures={{ slide: { value, onChange } }}>
|
|
15
|
+
* <Widget.SliderFill value={position} />
|
|
11
16
|
* <Widget.Content>...</Widget.Content>
|
|
12
17
|
* </Widget>
|
|
13
18
|
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Per-fill override (sets --widget-icon-color, not background directly)
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <Widget.SliderFill value={brightness} color={bulbColor} />
|
|
23
|
+
* ```
|
|
14
24
|
*/
|
|
15
25
|
import type { JSX } from "solid-js";
|
|
16
|
-
|
|
26
|
+
interface WidgetSliderFillProps {
|
|
17
27
|
/** Current value (0-100) */
|
|
18
28
|
value: number;
|
|
19
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Optional channel override: sets `--widget-icon-color` inline on the fill
|
|
31
|
+
* root. When omitted the fill renders in the parent Widget's channel color
|
|
32
|
+
* (var(--widget-color)). Mirrors Widget.Icon.color (Phase 26 VIS-A05).
|
|
33
|
+
*/
|
|
20
34
|
color?: string;
|
|
21
|
-
/**
|
|
22
|
-
glow?: boolean;
|
|
23
|
-
/** Opacity of the fill (0-1) */
|
|
24
|
-
opacity?: number;
|
|
25
|
-
/** Whether slider is currently being dragged (disables transition) */
|
|
35
|
+
/** Whether the slider is currently being dragged (disables transition) */
|
|
26
36
|
isDragging?: boolean;
|
|
27
37
|
/** Additional CSS classes */
|
|
28
38
|
class?: string;
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
|
-
* Animated slider fill that adapts to widget orientation
|
|
41
|
+
* Animated slider fill that adapts to widget orientation.
|
|
32
42
|
*/
|
|
33
43
|
export declare function WidgetSliderFill(props: WidgetSliderFillProps): JSX.Element;
|
|
44
|
+
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
import type { JSX } from "solid-js";
|
|
19
|
-
|
|
19
|
+
interface WidgetContentProps {
|
|
20
20
|
/** Additional CSS classes */
|
|
21
21
|
class?: string;
|
|
22
22
|
/** Content children */
|
|
@@ -27,3 +27,4 @@ export interface WidgetContentProps {
|
|
|
27
27
|
* Ensures proper z-index layering for title, status, and controls
|
|
28
28
|
*/
|
|
29
29
|
export declare function WidgetContent(props: WidgetContentProps): JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -1,48 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WidgetIcon Component
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Channel-driven icon. Background and glow read from `--widget-icon-color`
|
|
5
|
+
* (with fallback to `--widget-color`) and `--widget-glow-strength` via the
|
|
6
|
+
* `.glasshome-widget-icon` CSS rule in tokens.css. The `color` prop is the
|
|
7
|
+
* optional per-icon override, pass any CSS color string (oklch, rgb, hex,
|
|
8
|
+
* hsl, var(...)).
|
|
6
9
|
*
|
|
7
|
-
* @example
|
|
10
|
+
* @example Default, inherits the parent Widget's channel color
|
|
8
11
|
* ```tsx
|
|
9
|
-
* <Widget
|
|
10
|
-
* icon={<Power />}
|
|
11
|
-
*
|
|
12
|
-
* glow="shadow-blue-500/50 dark:shadow-blue-400/50"
|
|
13
|
-
* />
|
|
12
|
+
* <Widget tone="info">
|
|
13
|
+
* <Widget.Icon icon={<Power />} />
|
|
14
|
+
* </Widget>
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
16
|
-
* @example
|
|
17
|
+
* @example Per-icon override (e.g. light bulb showing its actual rgb_color)
|
|
17
18
|
* ```tsx
|
|
18
|
-
* <Widget.Icon
|
|
19
|
-
* icon={<Lightbulb />}
|
|
20
|
-
* dynamicColor="hsl(320, 100%, 50%)"
|
|
21
|
-
* />
|
|
19
|
+
* <Widget.Icon icon={<Lightbulb />} color="oklch(0.85 0.2 60)" />
|
|
22
20
|
* ```
|
|
23
21
|
*/
|
|
24
22
|
import type { JSX } from "solid-js";
|
|
25
|
-
|
|
23
|
+
interface WidgetIconProps {
|
|
26
24
|
/** Icon component (JSX.Element) */
|
|
27
25
|
icon: JSX.Element;
|
|
28
|
-
/** Background color as Tailwind class (e.g. "bg-blue-500 dark:bg-blue-400") */
|
|
29
|
-
color?: string;
|
|
30
|
-
/** Glow/shadow effect as Tailwind class (e.g. "shadow-blue-500/50") */
|
|
31
|
-
glow?: string;
|
|
32
26
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
27
|
+
* Optional CSS color string (oklch, hsl, rgb, hex, var()).
|
|
28
|
+
* Sets `--widget-icon-color` inline on the icon root, overriding the
|
|
29
|
+
* channel base color for the icon only. When omitted the channel's
|
|
30
|
+
* `--widget-color` flows through via the tokens.css rule.
|
|
31
|
+
* BREAKING (Phase 26): previously accepted Tailwind class strings.
|
|
36
32
|
*/
|
|
37
|
-
|
|
33
|
+
color?: string;
|
|
38
34
|
/** Reduce opacity */
|
|
39
35
|
dimmed?: boolean;
|
|
40
|
-
/** Number of entities
|
|
36
|
+
/** Number of entities, creates stacked background effect (1 = single, 2+ = stacked backgrounds) */
|
|
41
37
|
entityCount?: number;
|
|
42
38
|
/** Additional CSS classes */
|
|
43
39
|
class?: string;
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
46
|
-
* Widget icon component with auto-responsive sizing
|
|
42
|
+
* Widget icon component with auto-responsive sizing.
|
|
43
|
+
* Background + glow rendered by the `.glasshome-widget-icon` CSS rule.
|
|
47
44
|
*/
|
|
48
45
|
export declare function WidgetIcon(props: WidgetIconProps): JSX.Element;
|
|
46
|
+
export {};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
11
|
import type { JSX } from "solid-js";
|
|
12
|
-
|
|
12
|
+
interface WidgetStatusProps {
|
|
13
13
|
/** Reduce opacity further */
|
|
14
14
|
dimmed?: boolean;
|
|
15
15
|
/** Additional CSS classes */
|
|
@@ -24,3 +24,4 @@ export interface WidgetStatusProps {
|
|
|
24
24
|
* Positioned above other content with proper z-index
|
|
25
25
|
*/
|
|
26
26
|
export declare function WidgetStatus(props: WidgetStatusProps): JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import type { JSX } from "solid-js";
|
|
17
|
-
|
|
17
|
+
interface WidgetTitleProps {
|
|
18
18
|
/** Optional badge count */
|
|
19
19
|
badge?: number;
|
|
20
20
|
/** Additional CSS classes */
|
|
@@ -27,3 +27,4 @@ export interface WidgetTitleProps {
|
|
|
27
27
|
* Positioned above other content with proper z-index
|
|
28
28
|
*/
|
|
29
29
|
export declare function WidgetTitle(props: WidgetTitleProps): JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
import type { JSX } from "solid-js";
|
|
18
|
-
|
|
18
|
+
interface WidgetValueProps {
|
|
19
19
|
/** The value to display */
|
|
20
20
|
value: number | string;
|
|
21
21
|
/** Unit of measurement */
|
|
@@ -29,3 +29,4 @@ export interface WidgetValueProps {
|
|
|
29
29
|
* Widget value component with auto-formatting and interpretation
|
|
30
30
|
*/
|
|
31
31
|
export declare function WidgetValue(props: WidgetValueProps): JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* </Widget>
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* @example With gradient and loading
|
|
15
|
+
* @example With CSS gradient and loading
|
|
16
16
|
* ```tsx
|
|
17
|
-
* <Widget gradient="
|
|
17
|
+
* <Widget gradient="linear-gradient(135deg, oklch(0.7 0.2 30), oklch(0.5 0.18 270))" loading={isLoading}>
|
|
18
18
|
* {children}
|
|
19
19
|
* </Widget>
|
|
20
20
|
* ```
|
|
@@ -22,16 +22,14 @@
|
|
|
22
22
|
import { type JSX } from "solid-js";
|
|
23
23
|
import type { WidgetSliderFill as WidgetSliderFillType } from "../backgrounds/WidgetSliderFill";
|
|
24
24
|
import type { WidgetContent as WidgetContentType } from "../components/WidgetContent";
|
|
25
|
-
import type { WidgetEmptyState as WidgetEmptyStateType } from "../components/WidgetEmptyState";
|
|
26
25
|
import type { WidgetIcon as WidgetIconType } from "../components/WidgetIcon";
|
|
27
|
-
import type { WidgetMetrics as WidgetMetricsType } from "../components/WidgetMetrics";
|
|
28
26
|
import type { WidgetStatus as WidgetStatusType } from "../components/WidgetStatus";
|
|
29
|
-
import type { WidgetSubtitle as WidgetSubtitleType } from "../components/WidgetSubtitle";
|
|
30
27
|
import type { WidgetTitle as WidgetTitleType } from "../components/WidgetTitle";
|
|
31
28
|
import type { WidgetValue as WidgetValueType } from "../components/WidgetValue";
|
|
32
29
|
import type { GestureHandlers } from "../gestures/use-widget-gestures";
|
|
33
|
-
import type {
|
|
34
|
-
|
|
30
|
+
import type { WidgetVariantConfig } from "../types";
|
|
31
|
+
import type { Tone } from "../theming/tone";
|
|
32
|
+
interface WidgetEmptyStateConfig {
|
|
35
33
|
/** Icon to display */
|
|
36
34
|
icon?: JSX.Element;
|
|
37
35
|
/** Main title/heading */
|
|
@@ -39,22 +37,40 @@ export interface WidgetEmptyStateConfig {
|
|
|
39
37
|
/** Descriptive message */
|
|
40
38
|
message?: string;
|
|
41
39
|
}
|
|
42
|
-
|
|
40
|
+
interface WidgetProps {
|
|
43
41
|
/** Widget variant (string ID or inline config) */
|
|
44
42
|
variant?: string | WidgetVariantConfig;
|
|
45
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Semantic tone (success, warning, danger, info, neutral, accent).
|
|
45
|
+
* Resolves to `--widget-color: var(--tone-{name})` inline on the widget root.
|
|
46
|
+
* Phase 26 channel API, preferred path for state-driven semantic widgets.
|
|
47
|
+
*/
|
|
48
|
+
tone?: Tone;
|
|
49
|
+
/**
|
|
50
|
+
* CSS color string (oklch, hsl, hex, rgb, var()).
|
|
51
|
+
* Sets `--widget-color` directly. Overrides `tone` when both supplied.
|
|
52
|
+
*/
|
|
53
|
+
color?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional second-stop CSS color string for two-stop gradient identity.
|
|
56
|
+
* Sets `--widget-color-to`. When omitted the shell formula falls back to `--widget-color`.
|
|
57
|
+
*/
|
|
58
|
+
colorTo?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Full CSS gradient string (e.g. `linear-gradient(135deg, oklch(...), oklch(...))`).
|
|
61
|
+
* Sets `--widget-gradient` and overrides the auto-derived shell gradient verbatim.
|
|
62
|
+
* BREAKING (Phase 26): previously accepted Tailwind class strings; now expects raw CSS.
|
|
63
|
+
*/
|
|
46
64
|
gradient?: string;
|
|
47
65
|
/** Show loading overlay */
|
|
48
66
|
loading?: boolean;
|
|
49
|
-
/** Background glow color (Tailwind color like "bg-blue-500") (runtime override) */
|
|
50
|
-
backgroundGlow?: string;
|
|
51
67
|
/** Additional CSS classes */
|
|
52
68
|
class?: string;
|
|
53
69
|
/** Is edit mode (disables gestures) */
|
|
54
70
|
isEditMode?: boolean;
|
|
55
71
|
/** Called when delete button is clicked (only shown in edit mode) */
|
|
56
72
|
onDelete?: () => void;
|
|
57
|
-
/** Empty state configuration
|
|
73
|
+
/** Empty state configuration, when provided shows empty state UI inside the shell */
|
|
58
74
|
emptyState?: WidgetEmptyStateConfig;
|
|
59
75
|
/**
|
|
60
76
|
* Gesture handlers from `useWidgetGestures`. When provided, Widget binds
|
|
@@ -65,31 +81,14 @@ export interface WidgetProps {
|
|
|
65
81
|
/** Child elements */
|
|
66
82
|
children?: JSX.Element;
|
|
67
83
|
}
|
|
68
|
-
|
|
84
|
+
interface WidgetComponent {
|
|
69
85
|
(props: WidgetProps): JSX.Element;
|
|
70
86
|
Content: typeof WidgetContentType;
|
|
71
87
|
Icon: typeof WidgetIconType;
|
|
72
88
|
Title: typeof WidgetTitleType;
|
|
73
|
-
Subtitle: typeof WidgetSubtitleType;
|
|
74
89
|
Status: typeof WidgetStatusType;
|
|
75
90
|
Value: typeof WidgetValueType;
|
|
76
|
-
Metrics: typeof WidgetMetricsType;
|
|
77
|
-
EmptyState: typeof WidgetEmptyStateType;
|
|
78
91
|
SliderFill: typeof WidgetSliderFillType;
|
|
79
92
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Classify widget size based on grid dimensions
|
|
82
|
-
*/
|
|
83
|
-
export declare function classifySize(gridWidth: number, gridHeight: number): WidgetSize;
|
|
84
|
-
/**
|
|
85
|
-
* Detect orientation from dimensions based on aspect ratio
|
|
86
|
-
* Used for gesture direction (slide horizontal vs vertical)
|
|
87
|
-
*/
|
|
88
|
-
export declare function detectOrientation(width: number, height: number): WidgetOrientation;
|
|
89
|
-
/**
|
|
90
|
-
* Detect content layout direction
|
|
91
|
-
* Used for UI arrangement (stack vertically vs horizontally)
|
|
92
|
-
* Considers height threshold - tall widgets benefit from vertical stacking
|
|
93
|
-
*/
|
|
94
|
-
export declare function detectContentLayout(width: number, height: number): WidgetOrientation;
|
|
95
93
|
export declare const Widget: WidgetComponent;
|
|
94
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Each cursor is a data URI embedded inline — no external files needed.
|
|
4
4
|
* Hotspot coordinates are included for proper click positioning.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
interface CursorDef {
|
|
7
7
|
css: string;
|
|
8
8
|
hotspotX: number;
|
|
9
9
|
hotspotY: number;
|
|
@@ -15,3 +15,4 @@ export declare const cursors: {
|
|
|
15
15
|
readonly slideVertical: CursorDef;
|
|
16
16
|
readonly slideAuto: CursorDef;
|
|
17
17
|
};
|
|
18
|
+
export {};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Framework Hooks - Barrel Export
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* config, entity, entity group, debug data, and gestures.
|
|
4
|
+
* Hooks for widget development: context, dialog, entity group.
|
|
6
5
|
*/
|
|
7
|
-
export { type
|
|
8
|
-
export { type UseDebugDataOptions, useDebugData } from "./use-debug-data";
|
|
9
|
-
export { type UseWidgetConfigOptions, type UseWidgetConfigReturn, useWidgetConfig, } from "./use-widget-config";
|
|
10
|
-
export { type BridgeableWidgetContext, type BridgeFns, type ReactiveWidgetContext, useWidgetContext, warnIfStub, WidgetCtx, } from "./use-widget-context";
|
|
6
|
+
export { type BridgeableWidgetContext, type BridgeFns, type ReactiveWidgetContext, useWidgetContext, WidgetCtx, } from "./use-widget-context";
|
|
11
7
|
export { useWidgetDialog, type WidgetDialogReturn } from "./use-widget-dialog";
|
|
12
|
-
export { type UseWidgetEntityOptions, type UseWidgetEntityResult, useWidgetEntity, } from "./use-widget-entity";
|
|
13
8
|
export { type AggregationPreset, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, useWidgetEntityGroup, } from "./use-widget-entity-group";
|
|
14
|
-
export { type UseWidgetFormOptions, type UseWidgetFormReturn, useWidgetForm, } from "./use-widget-form";
|
|
15
|
-
export { useWidgetResponsive, type WidgetResponsiveUtils } from "./use-widget-responsive";
|
|
@@ -57,11 +57,6 @@ export interface BridgeableWidgetContext extends ReactiveWidgetContext {
|
|
|
57
57
|
/** Setter functions called by Widget.tsx createEffect to push real values */
|
|
58
58
|
_bridge: BridgeFns;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Emit a one-time dev-mode console.warn when stub context values are read
|
|
62
|
-
* before Widget has mounted and bridged real measured values.
|
|
63
|
-
*/
|
|
64
|
-
export declare function warnIfStub(isStub: () => boolean): void;
|
|
65
60
|
/**
|
|
66
61
|
* Widget context
|
|
67
62
|
* Uses reactive accessor pattern for SolidJS
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
* Widget,
|
|
11
11
|
* useWidgetGestures,
|
|
12
12
|
* useWidgetDialog,
|
|
13
|
-
* spacing,
|
|
14
|
-
* cn,
|
|
15
13
|
* } from "@glasshome/widget-sdk";
|
|
16
14
|
*
|
|
17
15
|
* export function MyWidget(props) {
|
|
@@ -33,25 +31,15 @@
|
|
|
33
31
|
*/
|
|
34
32
|
export { Widget } from "./core/Widget";
|
|
35
33
|
export { WidgetContent } from "./components/WidgetContent";
|
|
36
|
-
export { WidgetEmptyState } from "./components/WidgetEmptyState";
|
|
37
34
|
export { WidgetIcon } from "./components/WidgetIcon";
|
|
38
|
-
export { WidgetMetrics } from "./components/WidgetMetrics";
|
|
39
35
|
export { WidgetStatus } from "./components/WidgetStatus";
|
|
40
|
-
export { WidgetSubtitle } from "./components/WidgetSubtitle";
|
|
41
36
|
export { WidgetTitle } from "./components/WidgetTitle";
|
|
42
37
|
export { WidgetValue } from "./components/WidgetValue";
|
|
43
|
-
export { Glow } from "./backgrounds/Glow";
|
|
44
38
|
export { WidgetSliderFill } from "./backgrounds/WidgetSliderFill";
|
|
45
|
-
export { WidgetStack } from "./layout/WidgetStack";
|
|
46
39
|
export { WidgetDialog, type WidgetDialogProps, type WidgetDialogTab } from "./dialogs";
|
|
47
|
-
export { type AggregationPreset, type BridgeableWidgetContext, type BridgeFns, type ReactiveWidgetContext, type
|
|
40
|
+
export { type AggregationPreset, type BridgeableWidgetContext, type BridgeFns, type ReactiveWidgetContext, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, useWidgetContext, useWidgetDialog, useWidgetEntityGroup, WidgetCtx, type WidgetDialogReturn, } from "./hooks";
|
|
48
41
|
export { type GestureHandlers, useWidgetGestures } from "./gestures/use-widget-gestures";
|
|
49
|
-
export {
|
|
50
|
-
export { typography } from "./design-system/typography";
|
|
51
|
-
export { WIDGET_Z, type WidgetZIndex } from "./design-system/z-index";
|
|
52
|
-
export { type AdaptiveIconColors, deriveAdaptiveIconColors, GRADIENT_NAMES, GRADIENT_PRESET_KEYS, GRADIENT_PRESETS, type GradientPreset, getGradient, getGradientFromString, gradientColorPresets, stateColors, type WidgetColorPreset, } from "./theming";
|
|
53
|
-
export { applyCssVars, applyLayout, builtInVariants, classicGlass, compactHorizontal, composeVariants, createFlexLayout, extendVariant, getBuiltInVariant, getBuiltInVariantIds, isBuiltInVariant, mergeVariants, minimal, } from "./variants";
|
|
42
|
+
export { injectTokens, type Tone, ToneSchema, } from "./theming";
|
|
54
43
|
export { widgetFields } from "./fields";
|
|
55
|
-
export {
|
|
56
|
-
export
|
|
57
|
-
export type { AbsoluteLayoutStrategy, BaseComponentProps, ColorVariant, CustomLayoutStrategy, ElementConfig, EntityView, FlexLayoutStrategy, GestureConfig, GradientConfig, GridLayoutStrategy, HoldGestureConfig, ImageOverlay, InteractionConfig, LayoutStrategy, PositionConfig, SlideGestureConfig, SpacingScale, VariantPlugins, VariantRegistry, WidgetContextValue, WidgetDimensions, WidgetElement, WidgetOrientation, WidgetSize, WidgetStyles, WidgetVariant, WidgetVariantConfig, } from "./types";
|
|
44
|
+
export { calculateLightGroup, calculateSensorGroup, countActiveEntities, getEntityAttribute, isEntityActive, type LightGroupResult, type SensorGroupResult, type SensorGroupType, } from "./utils";
|
|
45
|
+
export type { EntityView, WidgetContextValue, WidgetDimensions, WidgetOrientation, WidgetSize, WidgetStyles, WidgetVariantConfig, } from "./types";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Widget Theming
|
|
2
|
+
* Widget Theming
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Widgets can use these or define their own logic.
|
|
4
|
+
* Tone schema and token injection.
|
|
6
5
|
*/
|
|
7
|
-
export { type
|
|
8
|
-
export {
|
|
6
|
+
export { ToneSchema, type Tone } from "./tone";
|
|
7
|
+
export { injectTokens } from "./tokens";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal document-shape needed for token injection. Allows tests to pass
|
|
3
|
+
* a stub without a full DOM implementation.
|
|
4
|
+
*/
|
|
5
|
+
interface InjectTokensRoot {
|
|
6
|
+
head: {
|
|
7
|
+
appendChild: (node: unknown) => void;
|
|
8
|
+
querySelector?: (sel: string) => unknown;
|
|
9
|
+
};
|
|
10
|
+
createElement: (tag: string) => {
|
|
11
|
+
setAttribute: (name: string, value: string) => void;
|
|
12
|
+
textContent: string | null;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Inject the SDK tokens stylesheet into <head>. Idempotent across:
|
|
17
|
+
* - Repeated calls within the same module instance (boolean sentinel).
|
|
18
|
+
* - Multiple SDK module instances (DOM sentinel data-glasshome-tokens).
|
|
19
|
+
* - SSR / non-browser environments (no-op when document is undefined).
|
|
20
|
+
*/
|
|
21
|
+
export declare function injectTokens(doc?: InjectTokensRoot): void;
|
|
22
|
+
/** Test-only: reset the module-level sentinel. Not exported from the package root. */
|
|
23
|
+
export declare function __resetInjectedForTests(): void;
|
|
24
|
+
export {};
|
|
@@ -46,15 +46,6 @@ export interface WidgetContextValue {
|
|
|
46
46
|
/** Whether widget is in edit mode */
|
|
47
47
|
isEditMode: boolean;
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Gradient configuration
|
|
51
|
-
*/
|
|
52
|
-
export interface GradientConfig {
|
|
53
|
-
/** Tailwind gradient from class (e.g., "from-blue-500") */
|
|
54
|
-
from: string;
|
|
55
|
-
/** Tailwind gradient to class (e.g., "to-blue-700") */
|
|
56
|
-
to: string;
|
|
57
|
-
}
|
|
58
49
|
/**
|
|
59
50
|
* Slide gesture configuration
|
|
60
51
|
*/
|
|
@@ -96,26 +87,8 @@ export interface GestureConfig {
|
|
|
96
87
|
* Spacing scale
|
|
97
88
|
*/
|
|
98
89
|
export type SpacingScale = "S1" | "S2" | "S3" | "S4";
|
|
99
|
-
/**
|
|
100
|
-
* Color variants for common components
|
|
101
|
-
*/
|
|
102
|
-
export type ColorVariant = "blue" | "green" | "red" | "yellow" | "purple" | "gray" | string;
|
|
103
|
-
/**
|
|
104
|
-
* Image overlay types
|
|
105
|
-
*/
|
|
106
|
-
export type ImageOverlay = "gradient" | "dark" | "none";
|
|
107
|
-
/**
|
|
108
|
-
* Base props that all framework components accept
|
|
109
|
-
*/
|
|
110
|
-
export interface BaseComponentProps {
|
|
111
|
-
/** Additional CSS classes (SolidJS uses `class` instead of `className`) */
|
|
112
|
-
class?: string;
|
|
113
|
-
/** Child elements */
|
|
114
|
-
children?: JSX.Element;
|
|
115
|
-
}
|
|
116
90
|
/**
|
|
117
91
|
* CSS variable-based styling configuration
|
|
118
|
-
* Replaces brittle Tailwind class strings with type-safe CSS variables
|
|
119
92
|
*/
|
|
120
93
|
export interface WidgetStyles {
|
|
121
94
|
/** Inline CSS properties applied to widget container */
|
|
@@ -130,17 +103,11 @@ export interface WidgetStyles {
|
|
|
130
103
|
*/
|
|
131
104
|
export interface FlexLayoutStrategy {
|
|
132
105
|
type: "flex";
|
|
133
|
-
/** Flex direction */
|
|
134
106
|
direction: "row" | "column" | "row-reverse" | "column-reverse";
|
|
135
|
-
/** Align items */
|
|
136
107
|
align: "start" | "center" | "end" | "stretch";
|
|
137
|
-
/** Justify content */
|
|
138
108
|
justify: "start" | "center" | "end" | "between" | "around";
|
|
139
|
-
/** Flex wrap */
|
|
140
109
|
wrap?: boolean;
|
|
141
|
-
/** Gap between items (CSS value) */
|
|
142
110
|
gap?: string;
|
|
143
|
-
/** Custom order for specific elements */
|
|
144
111
|
order?: Partial<Record<WidgetElement, number>>;
|
|
145
112
|
}
|
|
146
113
|
/**
|
|
@@ -148,15 +115,10 @@ export interface FlexLayoutStrategy {
|
|
|
148
115
|
*/
|
|
149
116
|
export interface GridLayoutStrategy {
|
|
150
117
|
type: "grid";
|
|
151
|
-
/** Grid template areas string */
|
|
152
118
|
areas: string;
|
|
153
|
-
/** Grid template columns */
|
|
154
119
|
columns?: string;
|
|
155
|
-
/** Grid template rows */
|
|
156
120
|
rows?: string;
|
|
157
|
-
/** Gap between items (CSS value) */
|
|
158
121
|
gap?: string;
|
|
159
|
-
/** Grid area assignments for elements */
|
|
160
122
|
elementAreas: Partial<Record<WidgetElement, string>>;
|
|
161
123
|
}
|
|
162
124
|
/**
|
|
@@ -164,7 +126,6 @@ export interface GridLayoutStrategy {
|
|
|
164
126
|
*/
|
|
165
127
|
export interface AbsoluteLayoutStrategy {
|
|
166
128
|
type: "absolute";
|
|
167
|
-
/** Position configurations for specific elements */
|
|
168
129
|
positions: Partial<Record<WidgetElement, PositionConfig>>;
|
|
169
130
|
}
|
|
170
131
|
/**
|
|
@@ -172,12 +133,10 @@ export interface AbsoluteLayoutStrategy {
|
|
|
172
133
|
*/
|
|
173
134
|
export interface CustomLayoutStrategy {
|
|
174
135
|
type: "custom";
|
|
175
|
-
/** Custom render function or component */
|
|
176
136
|
renderer: string;
|
|
177
137
|
}
|
|
178
138
|
/**
|
|
179
139
|
* Discriminated union of all layout strategies
|
|
180
|
-
* Ensures type safety - can't use gridArea with flex, etc.
|
|
181
140
|
*/
|
|
182
141
|
export type LayoutStrategy = FlexLayoutStrategy | GridLayoutStrategy | AbsoluteLayoutStrategy | CustomLayoutStrategy;
|
|
183
142
|
/**
|
|
@@ -198,68 +157,42 @@ export type WidgetElement = "icon" | "title" | "subtitle" | "status" | "value" |
|
|
|
198
157
|
* Element-specific configuration
|
|
199
158
|
*/
|
|
200
159
|
export interface ElementConfig {
|
|
201
|
-
/** Show/hide specific elements */
|
|
202
160
|
visible?: Partial<Record<WidgetElement, boolean>>;
|
|
203
|
-
/** Element-specific styling */
|
|
204
161
|
styles?: Partial<Record<WidgetElement, JSX.CSSProperties>>;
|
|
205
|
-
/** Element-specific CSS classes */
|
|
206
162
|
classNames?: Partial<Record<WidgetElement, string>>;
|
|
207
163
|
}
|
|
208
164
|
/**
|
|
209
165
|
* Plugin system configuration (serializable)
|
|
210
|
-
* Uses string IDs instead of JSX.Element for serializability
|
|
211
166
|
*/
|
|
212
167
|
export interface VariantPlugins {
|
|
213
|
-
/** Background plugin ID */
|
|
214
168
|
background?: string;
|
|
215
|
-
/** Overlay plugin ID */
|
|
216
169
|
overlay?: string;
|
|
217
|
-
/** Decoration plugin IDs */
|
|
218
170
|
decorations?: string[];
|
|
219
171
|
}
|
|
220
172
|
/**
|
|
221
173
|
* Interaction configuration
|
|
222
174
|
*/
|
|
223
175
|
export interface InteractionConfig {
|
|
224
|
-
/** Enable hover effects */
|
|
225
176
|
hover?: boolean;
|
|
226
|
-
/** Enable active/pressed state */
|
|
227
177
|
active?: boolean;
|
|
228
|
-
/** Enable focus ring */
|
|
229
178
|
focus?: boolean;
|
|
230
|
-
/** Custom hover scale (e.g., 1.02) */
|
|
231
179
|
hoverScale?: number;
|
|
232
|
-
/** Custom active scale (e.g., 0.98) */
|
|
233
180
|
activeScale?: number;
|
|
234
181
|
}
|
|
235
182
|
/**
|
|
236
183
|
* Complete variant configuration
|
|
237
|
-
* This is the core of the variant system
|
|
238
184
|
*/
|
|
239
185
|
export interface WidgetVariantConfig {
|
|
240
|
-
/** Unique variant identifier */
|
|
241
186
|
id: string;
|
|
242
|
-
/** Human-readable name */
|
|
243
187
|
name: string;
|
|
244
|
-
/** Description of variant purpose/style */
|
|
245
188
|
description?: string;
|
|
246
|
-
/** Styling configuration */
|
|
247
189
|
styles?: WidgetStyles;
|
|
248
|
-
/** Layout strategy */
|
|
249
190
|
layout?: LayoutStrategy;
|
|
250
|
-
/** Element-specific configuration */
|
|
251
191
|
elements?: ElementConfig;
|
|
252
|
-
/** Plugin configurations */
|
|
253
192
|
plugins?: VariantPlugins;
|
|
254
|
-
/** Interaction behavior */
|
|
255
193
|
interactions?: InteractionConfig;
|
|
256
|
-
/** Base variant to extend (enables composition) */
|
|
257
194
|
extends?: string;
|
|
258
195
|
}
|
|
259
|
-
/**
|
|
260
|
-
* Variant type union (built-in + custom)
|
|
261
|
-
*/
|
|
262
|
-
export type WidgetVariant = "classic-glass" | "minimal" | "compact-horizontal" | (string & {});
|
|
263
196
|
/**
|
|
264
197
|
* Variant registry type
|
|
265
198
|
*/
|