@glasshome/widget-sdk 1.3.0 → 1.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/dist/deprecations.d.ts +34 -0
- package/dist/deprecations.js +65 -0
- package/dist/framework/config/index.d.ts +96 -0
- package/dist/framework/fields.d.ts +22 -8
- package/dist/framework/index.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +434 -326
- package/package.json +9 -3
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { clsx as
|
|
9
|
-
import { twMerge as
|
|
1
|
+
import { deprecate as e, deprecations as t, formatDeprecation as n } from "./deprecations.js";
|
|
2
|
+
import { WidgetManifestSchema as r, formatSchemaError as i } from "./schemas.js";
|
|
3
|
+
import { z as a, z as o } from "zod";
|
|
4
|
+
import { getForecasts as s, getStream as c, getWebRtcClientConfig as l, hassMediaUrl as u, sendWebRtcCandidate as d, startWebRtcSession as f, state as p, trackEntityHistory as m, untrackEntityHistory as h } from "@glasshome/sync-layer";
|
|
5
|
+
import { byDomain as g, useArea as _, useCamera as v, useConnection as ee, useCurrency as y, useEntities as b, useEntity as te, useEntityHistory as x, useEntityStatistics as ne, useForecast as re, useHassConfig as ie, useLocale as S, useService as ae, useStore as oe, useTemperatureUnit as se, useToggle as ce, useTurnOff as le, useTurnOn as ue, useUnitSystem as de } from "@glasshome/sync-layer/solid";
|
|
6
|
+
import { Show as C, createContext as fe, createEffect as w, createMemo as T, createSignal as E, on as pe, onCleanup as D, onMount as me, splitProps as he, useContext as O } from "solid-js";
|
|
7
|
+
import { addEventListener as k, className as A, createComponent as j, delegateEvents as ge, effect as M, insert as N, memo as P, setStyleProperty as F, style as I, template as L, use as _e } from "solid-js/web";
|
|
8
|
+
import { clsx as ve } from "clsx";
|
|
9
|
+
import { twMerge as ye } from "tailwind-merge";
|
|
10
10
|
//#region src/framework/to-form-schema.ts
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
let t =
|
|
11
|
+
function be(e) {
|
|
12
|
+
return o.toJSONSchema(e, { override: (e) => {
|
|
13
|
+
let t = o.globalRegistry.get(e.zodSchema);
|
|
14
14
|
return t && typeof t == "object" && Object.keys(t).length > 0 ? {
|
|
15
15
|
...e.jsonSchema,
|
|
16
16
|
...t
|
|
17
17
|
} : e.jsonSchema;
|
|
18
18
|
} });
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function xe(e) {
|
|
21
21
|
try {
|
|
22
22
|
return e.parse({});
|
|
23
23
|
} catch {
|
|
@@ -26,82 +26,82 @@ function _e(e) {
|
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/define-widget.ts
|
|
29
|
-
function
|
|
30
|
-
return e.configSchema && (e.manifest.schema || (e.manifest.schema =
|
|
29
|
+
function Se(e) {
|
|
30
|
+
return e.configSchema && (e.manifest.schema || (e.manifest.schema = be(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = xe(e.configSchema))), e;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/framework/hooks/use-widget-context.ts
|
|
34
|
-
var
|
|
35
|
-
function
|
|
36
|
-
let e =
|
|
34
|
+
var R = fe();
|
|
35
|
+
function Ce() {
|
|
36
|
+
let e = O(R);
|
|
37
37
|
if (!e) throw Error("useWidgetContext must be used within a Widget component");
|
|
38
38
|
return e;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/framework/hooks/use-service.ts
|
|
42
|
-
function
|
|
42
|
+
function we(e) {
|
|
43
43
|
let t = Array.isArray(e) ? e[0] : e, n = t?.split(".")[0];
|
|
44
44
|
if (!n) throw Error(`Invalid entity ID: ${String(t)}`);
|
|
45
45
|
return n;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return (n, r = {}) => e(
|
|
47
|
+
function z(e, t) {
|
|
48
|
+
return (n, r = {}) => e(we(n), t, r, { entity_id: n });
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
let e =
|
|
50
|
+
function Te() {
|
|
51
|
+
let e = O(R)?.callService;
|
|
52
52
|
return e ? {
|
|
53
53
|
callService: e,
|
|
54
|
-
turnOn:
|
|
55
|
-
turnOff:
|
|
56
|
-
toggle:
|
|
57
|
-
} :
|
|
54
|
+
turnOn: z(e, "turn_on"),
|
|
55
|
+
turnOff: z(e, "turn_off"),
|
|
56
|
+
toggle: z(e, "toggle")
|
|
57
|
+
} : ae();
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
let e =
|
|
61
|
-
return e ?
|
|
59
|
+
function Ee() {
|
|
60
|
+
let e = O(R)?.callService;
|
|
61
|
+
return e ? z(e, "turn_on") : ue();
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
let e =
|
|
65
|
-
return e ?
|
|
63
|
+
function De() {
|
|
64
|
+
let e = O(R)?.callService;
|
|
65
|
+
return e ? z(e, "turn_off") : le();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
let e =
|
|
69
|
-
return e ?
|
|
67
|
+
function Oe() {
|
|
68
|
+
let e = O(R)?.callService;
|
|
69
|
+
return e ? z(e, "toggle") : ce();
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/framework/design-system/z-index.ts
|
|
73
|
-
var
|
|
73
|
+
var B = {
|
|
74
74
|
BACKGROUND: 0,
|
|
75
75
|
CONTENT: 10,
|
|
76
76
|
OVERLAY: 20,
|
|
77
77
|
ACTIONS: 30
|
|
78
|
-
},
|
|
79
|
-
function
|
|
80
|
-
return
|
|
78
|
+
}, ke = "/* Authoritative SDK CSS contract. Injected once on first Widget mount\n * via framework/theming/tokens.ts.\n *\n * All widget-internal visual scale is driven from CSS custom properties +\n * container queries on the `.glasshome-widget` shell (`container-type: size`).\n * No JS classifier, no size tier enum.\n */\n\n:root {\n --tone-success: oklch(0.70 0.18 145);\n --tone-warning: oklch(0.80 0.17 75);\n --tone-danger: oklch(0.64 0.22 27);\n --tone-info: oklch(0.66 0.20 245);\n --tone-neutral: oklch(0.65 0.02 250);\n --tone-accent: oklch(0.74 0.18 60);\n\n --widget-grad-strength: 1;\n --widget-glow-default: 0.4;\n --widget-border-highlight: oklch(0.98 0 0 / 0.4);\n}\n\n.dark {\n --tone-success: oklch(0.74 0.18 145);\n --tone-warning: oklch(0.82 0.17 75);\n --tone-danger: oklch(0.68 0.22 27);\n --tone-info: oklch(0.70 0.20 245);\n --tone-neutral: oklch(0.69 0.02 250);\n --tone-accent: oklch(0.78 0.18 60);\n\n --widget-grad-strength: 1.1;\n --widget-glow-default: 0.5;\n --widget-border-highlight: oklch(1 0 0 / 0.08);\n}\n\n@property --widget-color {\n syntax: \"<color>\";\n inherits: true;\n initial-value: oklch(0.65 0.02 250);\n}\n\n/* === Widget shell ===\n * Fluid scale tokens — tied to the shell's own container box (cqmin/cqi/cqb).\n * Same input box → same output, so two widgets at the same grid cell match\n * exactly. Tune multipliers / clamps to adjust density. */\n.glasshome-widget {\n --widget-color: var(--tone-neutral);\n --widget-glow-strength: var(--widget-glow-default);\n\n --widget-icon-box: clamp(28px, 22cqmin, 64px);\n --widget-icon-glyph: clamp(16px, 13cqmin, 36px);\n --widget-pad: clamp(8px, 4cqmin, 24px);\n --widget-gap: clamp(6px, 2cqmin, 16px);\n --widget-title-size: clamp(12px, 2cqi, 18px);\n --widget-subtitle: clamp(12px, 2.5cqi, 20px);\n --widget-status-size: clamp(14px, 5cqi, 36px);\n --widget-value-size: clamp(18px, 7cqi, 48px);\n --widget-badge-size: clamp(11px, 1.6cqi, 14px);\n}\n\n.glasshome-widget {\n background: var(--widget-gradient,\n linear-gradient(135deg,\n color-mix(in oklch, var(--widget-color) calc(22% * var(--widget-grad-strength)), transparent),\n color-mix(in oklch, var(--widget-color-to, var(--widget-color)) calc(11% * var(--widget-grad-strength)), transparent)\n )\n );\n box-shadow: inset 0 1px 0 var(--widget-border-highlight);\n}\n\n/* === Slot: content layout === */\n/* Default: column. Flip to row only on wide-and-short widgets (matches the\n * old contentLayout heuristic: aspect > 1 AND height < 150px). */\n.glasshome-widget-content {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n height: 100%;\n padding: var(--widget-pad);\n gap: var(--widget-gap);\n overflow: hidden;\n}\n@container widget (min-aspect-ratio: 1) and (max-height: 149px) {\n .glasshome-widget-content {\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n }\n}\n.glasshome-widget-content [class*=\"ml-auto\"] {\n position: relative;\n z-index: 30;\n}\n\n/* === Slot: icon === */\n.glasshome-widget-icon {\n width: var(--widget-icon-box);\n height: var(--widget-icon-box);\n border-radius: var(--radius-sm, 12px);\n background: var(--widget-icon-color, var(--widget-color));\n box-shadow: 0 0 calc(var(--widget-glow-strength) * 30px)\n color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 50%, transparent);\n color: oklch(from var(--widget-icon-color, var(--widget-color)) calc(0.52 + sign(0.5 - l) * 0.43) calc(c * 0.2) h);\n}\n.glasshome-widget-icon-glyph {\n font-size: var(--widget-icon-glyph);\n line-height: 1;\n}\n.glasshome-widget-icon-stack {\n position: absolute;\n width: 102%;\n height: 102%;\n border-radius: var(--radius-sm, 12px);\n}\n.glasshome-widget-icon-stack-2 { bottom: -14%; right: -10%; opacity: 0.45; z-index: -2; }\n.glasshome-widget-icon-stack-3 { bottom: -28%; right: -20%; opacity: 0.20; z-index: -3; }\n\n/* === Slot: text === */\n.glasshome-widget-title {\n font-size: var(--widget-title-size);\n line-height: 1.2;\n color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.glasshome-widget-subtitle {\n font-size: var(--widget-subtitle);\n color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);\n}\n.glasshome-widget-status {\n font-size: var(--widget-status-size);\n font-weight: 700;\n color: var(--color-foreground, currentColor);\n line-height: 1.1;\n}\n.glasshome-widget-value {\n font-size: var(--widget-value-size);\n font-weight: 700;\n color: var(--color-foreground, currentColor);\n line-height: 1.05;\n}\n.glasshome-widget-badge {\n font-size: var(--widget-badge-size);\n font-weight: 500;\n padding: 0.125rem 0.5rem;\n border-radius: 9999px;\n background: color-mix(in oklch, var(--color-foreground, currentColor) 20%, transparent);\n color: var(--color-foreground, currentColor);\n}\n\n.glasshome-widget-loading {\n background: color-mix(in oklch, var(--widget-color) 20%, transparent);\n}\n\n/* === Slider fill ===\n * Value flows in via --widget-fill-value (0-100). Vertical orientation auto-\n * detected via container query. */\n.glasshome-widget-slider-fill {\n --widget-fill-value: 0;\n background: color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 30%, transparent);\n box-shadow: 0 0 calc(var(--widget-glow-strength) * 40px)\n color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 40%, transparent);\n clip-path: inset(0 calc((100 - var(--widget-fill-value)) * 1%) 0 0);\n}\n@container widget (max-aspect-ratio: 1) {\n .glasshome-widget-slider-fill {\n clip-path: inset(calc((100 - var(--widget-fill-value)) * 1%) 0 0 0);\n }\n}\n", Ae = !1, V, je = /* @__PURE__ */ new WeakSet();
|
|
79
|
+
function Me() {
|
|
80
|
+
return V || (V = new CSSStyleSheet(), V.replaceSync(ke.replace(/:root\b/g, ":host").replace(/^\.dark\b/gm, ":host(.dark)"))), V;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function Ne(e) {
|
|
83
83
|
if (typeof ShadowRoot < "u" && e instanceof ShadowRoot) {
|
|
84
|
-
if (
|
|
85
|
-
let t =
|
|
86
|
-
e.adoptedStyleSheets.includes(t) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, t]),
|
|
84
|
+
if (je.has(e)) return;
|
|
85
|
+
let t = Me();
|
|
86
|
+
e.adoptedStyleSheets.includes(t) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, t]), je.add(e);
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
89
|
+
if (Ae) return;
|
|
90
90
|
let t = e ?? (typeof document > "u" ? void 0 : document);
|
|
91
91
|
if (!t) return;
|
|
92
92
|
if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
|
|
93
|
-
|
|
93
|
+
Ae = !0;
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
let n = t.createElement("style");
|
|
97
|
-
n.setAttribute("data-glasshome-tokens", ""), n.textContent =
|
|
97
|
+
n.setAttribute("data-glasshome-tokens", ""), n.textContent = ke, t.head.appendChild(n), Ae = !0;
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/framework/utils/cn.ts
|
|
101
|
-
function
|
|
102
|
-
return
|
|
101
|
+
function H(...e) {
|
|
102
|
+
return ye(ve(e));
|
|
103
103
|
}
|
|
104
|
-
var
|
|
104
|
+
var Pe = {
|
|
105
105
|
"classic-glass": {
|
|
106
106
|
id: "classic-glass",
|
|
107
107
|
name: "Classic Glass",
|
|
@@ -187,22 +187,22 @@ var Ae = {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
function
|
|
191
|
-
return
|
|
190
|
+
function Fe(e) {
|
|
191
|
+
return Pe[e];
|
|
192
192
|
}
|
|
193
193
|
//#endregion
|
|
194
194
|
//#region src/framework/backgrounds/WidgetSliderFill.tsx
|
|
195
|
-
var
|
|
196
|
-
function
|
|
195
|
+
var Ie = /*#__PURE__*/ L("<div>");
|
|
196
|
+
function Le(e) {
|
|
197
197
|
return (() => {
|
|
198
|
-
var t =
|
|
199
|
-
return
|
|
200
|
-
var r =
|
|
198
|
+
var t = Ie();
|
|
199
|
+
return M((n) => {
|
|
200
|
+
var r = H("glasshome-widget-slider-fill pointer-events-none absolute inset-0", e.isDragging ? "duration-0" : "transition-all duration-300 ease-out", e.class), i = {
|
|
201
201
|
"--widget-fill-value": e.value,
|
|
202
|
-
"z-index":
|
|
202
|
+
"z-index": B.BACKGROUND,
|
|
203
203
|
...e.color ? { "--widget-icon-color": e.color } : {}
|
|
204
204
|
};
|
|
205
|
-
return r !== n.e &&
|
|
205
|
+
return r !== n.e && A(t, n.e = r), n.t = I(t, i, n.t), n;
|
|
206
206
|
}, {
|
|
207
207
|
e: void 0,
|
|
208
208
|
t: void 0
|
|
@@ -211,37 +211,37 @@ function Ne(e) {
|
|
|
211
211
|
}
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region src/framework/components/WidgetContent.tsx
|
|
214
|
-
var
|
|
215
|
-
function
|
|
214
|
+
var Re = /*#__PURE__*/ L("<div>");
|
|
215
|
+
function ze(e) {
|
|
216
216
|
return (() => {
|
|
217
|
-
var t =
|
|
218
|
-
return
|
|
217
|
+
var t = Re();
|
|
218
|
+
return N(t, () => e.children), M(() => A(t, H("glasshome-widget-content", e.class))), t;
|
|
219
219
|
})();
|
|
220
220
|
}
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/framework/components/WidgetIcon.tsx
|
|
223
|
-
var
|
|
224
|
-
function
|
|
223
|
+
var Be = /*#__PURE__*/ L("<div class=\"glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2\">"), Ve = /*#__PURE__*/ L("<div class=\"glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3\">"), He = /*#__PURE__*/ L("<div><div class=\"glasshome-widget-icon-glyph flex items-center justify-center\">");
|
|
224
|
+
function Ue(e) {
|
|
225
225
|
let t = () => e.entityCount ?? 1;
|
|
226
226
|
return (() => {
|
|
227
|
-
var n =
|
|
228
|
-
return
|
|
227
|
+
var n = He(), r = n.firstChild;
|
|
228
|
+
return N(n, j(C, {
|
|
229
229
|
get when() {
|
|
230
230
|
return t() >= 2;
|
|
231
231
|
},
|
|
232
232
|
get children() {
|
|
233
|
-
return
|
|
233
|
+
return Be();
|
|
234
234
|
}
|
|
235
|
-
}), r),
|
|
235
|
+
}), r), N(n, j(C, {
|
|
236
236
|
get when() {
|
|
237
237
|
return t() >= 3;
|
|
238
238
|
},
|
|
239
239
|
get children() {
|
|
240
|
-
return
|
|
240
|
+
return Ve();
|
|
241
241
|
}
|
|
242
|
-
}), r),
|
|
243
|
-
var r =
|
|
244
|
-
return r !== t.e &&
|
|
242
|
+
}), r), N(r, () => e.icon), M((t) => {
|
|
243
|
+
var r = H("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center pointer-events-none transition-all", e.dimmed && "opacity-50", e.class), i = e.color ? { "--widget-icon-color": e.color } : void 0;
|
|
244
|
+
return r !== t.e && A(n, t.e = r), t.t = I(n, i, t.t), t;
|
|
245
245
|
}, {
|
|
246
246
|
e: void 0,
|
|
247
247
|
t: void 0
|
|
@@ -250,16 +250,16 @@ function ze(e) {
|
|
|
250
250
|
}
|
|
251
251
|
//#endregion
|
|
252
252
|
//#region src/framework/components/WidgetStatus.tsx
|
|
253
|
-
var
|
|
254
|
-
function
|
|
253
|
+
var We = /*#__PURE__*/ L("<p>");
|
|
254
|
+
function Ge(e) {
|
|
255
255
|
return (() => {
|
|
256
|
-
var t =
|
|
257
|
-
return
|
|
258
|
-
var t =
|
|
256
|
+
var t = We();
|
|
257
|
+
return N(t, (() => {
|
|
258
|
+
var t = P(() => !!e.isUnavailable);
|
|
259
259
|
return () => t() ? "Unavailable" : e.children;
|
|
260
|
-
})()),
|
|
261
|
-
var r =
|
|
262
|
-
return r !== n.e &&
|
|
260
|
+
})()), M((n) => {
|
|
261
|
+
var r = H("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), i = B.ACTIONS;
|
|
262
|
+
return r !== n.e && A(t, n.e = r), i !== n.t && F(t, "z-index", n.t = i), n;
|
|
263
263
|
}, {
|
|
264
264
|
e: void 0,
|
|
265
265
|
t: void 0
|
|
@@ -268,21 +268,21 @@ function Ve(e) {
|
|
|
268
268
|
}
|
|
269
269
|
//#endregion
|
|
270
270
|
//#region src/framework/components/WidgetTitle.tsx
|
|
271
|
-
var
|
|
272
|
-
function
|
|
271
|
+
var Ke = /*#__PURE__*/ L("<span class=\"glasshome-widget-badge shrink-0\">"), qe = /*#__PURE__*/ L("<div><h3 class=glasshome-widget-title>");
|
|
272
|
+
function Je(e) {
|
|
273
273
|
return (() => {
|
|
274
|
-
var t =
|
|
275
|
-
return
|
|
274
|
+
var t = qe(), n = t.firstChild;
|
|
275
|
+
return N(n, () => e.children), N(t, j(C, {
|
|
276
276
|
get when() {
|
|
277
|
-
return
|
|
277
|
+
return P(() => e.badge !== void 0)() && e.badge > 0;
|
|
278
278
|
},
|
|
279
279
|
get children() {
|
|
280
|
-
var t =
|
|
281
|
-
return
|
|
280
|
+
var t = Ke();
|
|
281
|
+
return N(t, () => e.badge), t;
|
|
282
282
|
}
|
|
283
|
-
}), null),
|
|
284
|
-
var r =
|
|
285
|
-
return r !== n.e &&
|
|
283
|
+
}), null), M((n) => {
|
|
284
|
+
var r = H("relative flex items-center gap-2", e.class), i = B.ACTIONS;
|
|
285
|
+
return r !== n.e && A(t, n.e = r), i !== n.t && F(t, "z-index", n.t = i), n;
|
|
286
286
|
}, {
|
|
287
287
|
e: void 0,
|
|
288
288
|
t: void 0
|
|
@@ -291,7 +291,7 @@ function We(e) {
|
|
|
291
291
|
}
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/framework/utils/entity-aggregation.ts
|
|
294
|
-
function
|
|
294
|
+
function Ye(e, t = !1) {
|
|
295
295
|
if (e.length === 0) return {
|
|
296
296
|
isGroup: !1,
|
|
297
297
|
state: "unknown",
|
|
@@ -314,7 +314,7 @@ function Ge(e, t = !1) {
|
|
|
314
314
|
isUnavailable: t.state === "unavailable",
|
|
315
315
|
brightness: r,
|
|
316
316
|
brightnessPercent: i,
|
|
317
|
-
color:
|
|
317
|
+
color: Ze(t),
|
|
318
318
|
onCount: +!!n,
|
|
319
319
|
totalCount: 1,
|
|
320
320
|
description: n ? "On" : "Off"
|
|
@@ -337,26 +337,26 @@ function Ge(e, t = !1) {
|
|
|
337
337
|
}
|
|
338
338
|
let u = e.length, d = o === u, f = a + o === u, p = r > 0, m = r === u, h = i === u, g, _;
|
|
339
339
|
t ? d ? (g = "unavailable", _ = !1) : a > 0 || o > 0 ? (g = "unknown", _ = !1) : i > 0 ? (g = "off", _ = !1) : (g = "on", _ = !0) : d ? (g = "unavailable", _ = !1) : f ? (g = "unknown", _ = !1) : p ? (g = "on", _ = !0) : (g = "off", _ = !1);
|
|
340
|
-
let v = c > 0 ? Math.round(s / c) : 0,
|
|
340
|
+
let v = c > 0 ? Math.round(s / c) : 0, ee = Math.round(v / 255 * 100), y;
|
|
341
341
|
if (l.length > 0) {
|
|
342
342
|
let e = Math.round(l.reduce((e, t) => e + t[0], 0) / l.length), t = Math.round(l.reduce((e, t) => e + t[1], 0) / l.length), n = Math.round(l.reduce((e, t) => e + t[2], 0) / l.length), r = v / 255;
|
|
343
|
-
|
|
344
|
-
} else
|
|
345
|
-
let
|
|
346
|
-
return
|
|
343
|
+
y = `rgb(${Math.round(e * r)}, ${Math.round(t * r)}, ${Math.round(n * r)})`;
|
|
344
|
+
} else y = Ze(e[0]);
|
|
345
|
+
let b;
|
|
346
|
+
return b = m ? "All on" : h ? "All off" : r > 0 ? `${r} of ${u} on` : "Off", {
|
|
347
347
|
isGroup: n,
|
|
348
348
|
state: g,
|
|
349
349
|
isOn: _,
|
|
350
350
|
isUnavailable: g === "unavailable",
|
|
351
351
|
brightness: v,
|
|
352
|
-
brightnessPercent:
|
|
353
|
-
color:
|
|
352
|
+
brightnessPercent: ee,
|
|
353
|
+
color: y,
|
|
354
354
|
onCount: r,
|
|
355
355
|
totalCount: u,
|
|
356
|
-
description:
|
|
356
|
+
description: b
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Xe(e, t = "mean", n = !0) {
|
|
360
360
|
if (e.length === 0) return {
|
|
361
361
|
isGroup: !1,
|
|
362
362
|
state: "unknown",
|
|
@@ -452,7 +452,7 @@ function Ke(e, t = "mean", n = !0) {
|
|
|
452
452
|
memberValues: a
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function Ze(e) {
|
|
456
456
|
if (e.state !== "on") return "rgb(100, 100, 100)";
|
|
457
457
|
let t = (e.attributes?.brightness ?? 255) / 255;
|
|
458
458
|
if (e.attributes?.rgb_color) {
|
|
@@ -467,7 +467,7 @@ function qe(e) {
|
|
|
467
467
|
}
|
|
468
468
|
//#endregion
|
|
469
469
|
//#region src/framework/utils/entity-state.ts
|
|
470
|
-
function
|
|
470
|
+
function Qe(e) {
|
|
471
471
|
if (!e) return !1;
|
|
472
472
|
if ([
|
|
473
473
|
"on",
|
|
@@ -483,15 +483,15 @@ function Je(e) {
|
|
|
483
483
|
}
|
|
484
484
|
return !1;
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function $e(e, t, n) {
|
|
487
487
|
return e?.attributes ? e.attributes[t] ?? n : n;
|
|
488
488
|
}
|
|
489
|
-
function
|
|
490
|
-
return e.filter(
|
|
489
|
+
function et(e) {
|
|
490
|
+
return e.filter(Qe).length;
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/framework/utils/format-value.ts
|
|
494
|
-
function
|
|
494
|
+
function tt(e, t, n) {
|
|
495
495
|
let { decimals: r, scale: i = !0 } = n || {};
|
|
496
496
|
if (typeof e == "string") return t ? `${e}${t}` : e;
|
|
497
497
|
if (e == null || Number.isNaN(e)) return t ? `--${t}` : "--";
|
|
@@ -502,76 +502,91 @@ function Ze(e, t, n) {
|
|
|
502
502
|
}
|
|
503
503
|
//#endregion
|
|
504
504
|
//#region src/framework/utils/interpret-value.ts
|
|
505
|
-
function
|
|
505
|
+
function nt(e, t) {
|
|
506
506
|
return e == null || isNaN(e) ? null : t === "°C" ? e < 10 ? "Cold" : e < 18 ? "Cool" : e < 24 ? "Comfortable" : e < 28 ? "Warm" : "Hot" : t === "°F" ? e < 50 ? "Cold" : e < 64 ? "Cool" : e < 75 ? "Comfortable" : e < 82 ? "Warm" : "Hot" : t === "%" ? e < 20 ? "Very Low" : e < 40 ? "Low" : e < 60 ? "Medium" : e < 80 ? "High" : "Very High" : t === "ppm" ? e < 400 ? "Excellent" : e < 600 ? "Good" : e < 1e3 ? "Acceptable" : e < 1500 ? "Mediocre" : "Poor" : t === "lx" ? e < 50 ? "Dark" : e < 200 ? "Dim" : e < 500 ? "Moderate" : e < 1e3 ? "Bright" : "Very Bright" : t === "AQI" ? e <= 50 ? "Good" : e <= 100 ? "Moderate" : e <= 150 ? "Unhealthy for Sensitive" : e <= 200 ? "Unhealthy" : e <= 300 ? "Very Unhealthy" : "Hazardous" : t === "dB" ? e < 30 ? "Very Quiet" : e < 50 ? "Quiet" : e < 70 ? "Moderate" : e < 85 ? "Loud" : "Very Loud" : null;
|
|
507
507
|
}
|
|
508
508
|
//#endregion
|
|
509
509
|
//#region src/framework/components/WidgetValue.tsx
|
|
510
|
-
var
|
|
511
|
-
function
|
|
510
|
+
var rt = /*#__PURE__*/ L("<div class=glasshome-widget-subtitle>"), it = /*#__PURE__*/ L("<div><div class=glasshome-widget-value>");
|
|
511
|
+
function at(e) {
|
|
512
512
|
return (() => {
|
|
513
|
-
var t =
|
|
514
|
-
return
|
|
513
|
+
var t = it(), n = t.firstChild;
|
|
514
|
+
return N(n, () => tt(e.value, e.unit)), N(t, j(C, {
|
|
515
515
|
get when() {
|
|
516
|
-
return
|
|
516
|
+
return P(() => !!e.interpret)() && typeof e.value == "number";
|
|
517
517
|
},
|
|
518
518
|
get children() {
|
|
519
|
-
var t =
|
|
520
|
-
return
|
|
519
|
+
var t = rt();
|
|
520
|
+
return N(t, () => nt(e.value, e.unit)), t;
|
|
521
521
|
}
|
|
522
|
-
}), null),
|
|
522
|
+
}), null), M(() => A(t, H("flex flex-col", e.class))), t;
|
|
523
523
|
})();
|
|
524
524
|
}
|
|
525
525
|
//#endregion
|
|
526
526
|
//#region src/framework/core/Widget.tsx
|
|
527
|
-
var
|
|
528
|
-
function
|
|
529
|
-
let t =
|
|
530
|
-
|
|
527
|
+
var ot = /*#__PURE__*/ L("<div><div class=\"relative h-full w-full\">"), st = /*#__PURE__*/ L("<div class=\"glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse\">"), ct = /*#__PURE__*/ L("<div class=\"flex h-full w-full flex-col items-center justify-center gap-2 text-center\">"), lt = /*#__PURE__*/ L("<div class=\"flex items-center justify-center text-white/30\">"), ut = /*#__PURE__*/ L("<h3 class=\"font-semibold text-sm text-white/60\">"), dt = /*#__PURE__*/ L("<p class=\"text-white/50 text-xs\">");
|
|
528
|
+
function ft(e) {
|
|
529
|
+
let t = O(R), [n, r] = E(), [i, a] = E({
|
|
530
|
+
width: 0,
|
|
531
|
+
height: 0
|
|
532
|
+
});
|
|
533
|
+
w(() => {
|
|
534
|
+
let e = n();
|
|
535
|
+
if (!e) return;
|
|
536
|
+
let t = new ResizeObserver(([e]) => {
|
|
537
|
+
if (!e) return;
|
|
538
|
+
let t = e.borderBoxSize?.[0];
|
|
539
|
+
a(t ? {
|
|
540
|
+
width: t.inlineSize,
|
|
541
|
+
height: t.blockSize
|
|
542
|
+
} : {
|
|
543
|
+
width: e.contentRect.width,
|
|
544
|
+
height: e.contentRect.height
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
t.observe(e), D(() => t.disconnect());
|
|
548
|
+
}), me(() => {
|
|
531
549
|
let e = n()?.getRootNode();
|
|
532
|
-
|
|
550
|
+
Ne(typeof ShadowRoot < "u" && e instanceof ShadowRoot || typeof Document < "u" && e instanceof Document ? e : void 0);
|
|
533
551
|
});
|
|
534
|
-
let
|
|
552
|
+
let o = {
|
|
535
553
|
isEditMode: () => e.isEditMode ?? !1,
|
|
536
554
|
updateConfig: t?.updateConfig ?? (() => {}),
|
|
537
555
|
registerDialogOpener: t?.registerDialogOpener,
|
|
538
556
|
callService: t?.callService,
|
|
539
|
-
dimensions: () => (
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}, o = E(() => {
|
|
544
|
-
if (e.variant) return typeof e.variant == "string" ? je(e.variant) : e.variant;
|
|
545
|
-
}), s = E(() => ({
|
|
557
|
+
dimensions: () => i()
|
|
558
|
+
}, s = T(() => {
|
|
559
|
+
if (e.variant) return typeof e.variant == "string" ? Fe(e.variant) : e.variant;
|
|
560
|
+
}), c = T(() => ({
|
|
546
561
|
"container-type": "size",
|
|
547
562
|
"container-name": "widget",
|
|
548
563
|
"touch-action": e.gestures && !e.isEditMode ? e.gestures.touchAction() : void 0,
|
|
549
|
-
...
|
|
550
|
-
...
|
|
564
|
+
...s()?.styles?.container,
|
|
565
|
+
...s()?.styles?.cssVars || {},
|
|
551
566
|
...e.tone ? { "--widget-color": `var(--tone-${e.tone})` } : {},
|
|
552
567
|
...e.color ? { "--widget-color": e.color } : {},
|
|
553
568
|
...e.colorTo ? { "--widget-color-to": e.colorTo } : {},
|
|
554
569
|
...e.gradient ? { "--widget-gradient": e.gradient } : {}
|
|
555
|
-
})),
|
|
556
|
-
|
|
557
|
-
}, u = (t) => {
|
|
558
|
-
c() && e.gestures?.onPointerDown(t);
|
|
570
|
+
})), l = () => !!e.gestures && !e.isEditMode, u = (t) => {
|
|
571
|
+
l() && e.gestures?.onPointerEnter(t);
|
|
559
572
|
}, d = (t) => {
|
|
560
|
-
|
|
573
|
+
l() && e.gestures?.onPointerDown(t);
|
|
561
574
|
}, f = (t) => {
|
|
562
|
-
|
|
575
|
+
l() && e.gestures?.onPointerMove(t);
|
|
563
576
|
}, p = (t) => {
|
|
564
|
-
|
|
577
|
+
l() && e.gestures?.onPointerUp(t);
|
|
578
|
+
}, m = (t) => {
|
|
579
|
+
l() && e.gestures?.onPointerCancel(t);
|
|
565
580
|
};
|
|
566
|
-
return
|
|
567
|
-
value:
|
|
581
|
+
return j(R.Provider, {
|
|
582
|
+
value: o,
|
|
568
583
|
get children() {
|
|
569
|
-
var t =
|
|
570
|
-
return
|
|
584
|
+
var t = ot(), n = t.firstChild;
|
|
585
|
+
return k(t, "pointercancel", m), k(t, "pointerup", p), k(t, "pointermove", f), k(t, "pointerdown", d), k(t, "pointerenter", u), _e((t) => {
|
|
571
586
|
r(t), e.gestures?.bindElement(t);
|
|
572
|
-
}, t),
|
|
573
|
-
var t =
|
|
574
|
-
return () => t() ?
|
|
587
|
+
}, t), N(n, (() => {
|
|
588
|
+
var t = P(() => !!e.emptyState);
|
|
589
|
+
return () => t() ? j(pt, {
|
|
575
590
|
get icon() {
|
|
576
591
|
return e.emptyState.icon;
|
|
577
592
|
},
|
|
@@ -582,15 +597,15 @@ function ct(e) {
|
|
|
582
597
|
return e.emptyState.message;
|
|
583
598
|
}
|
|
584
599
|
}) : e.children;
|
|
585
|
-
})()),
|
|
586
|
-
var t =
|
|
600
|
+
})()), N(t, (() => {
|
|
601
|
+
var t = P(() => !!e.loading);
|
|
587
602
|
return () => t() && (() => {
|
|
588
|
-
var e =
|
|
589
|
-
return
|
|
603
|
+
var e = st();
|
|
604
|
+
return M((t) => F(e, "z-index", B.OVERLAY)), e;
|
|
590
605
|
})();
|
|
591
|
-
})(), null),
|
|
592
|
-
var i =
|
|
593
|
-
return i !== r.e &&
|
|
606
|
+
})(), null), M((r) => {
|
|
607
|
+
var i = H("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", s()?.styles?.class, e.class), a = c(), o = B.CONTENT;
|
|
608
|
+
return i !== r.e && A(t, r.e = i), r.t = I(t, a, r.t), o !== r.a && F(n, "z-index", r.a = o), r;
|
|
594
609
|
}, {
|
|
595
610
|
e: void 0,
|
|
596
611
|
t: void 0,
|
|
@@ -599,61 +614,61 @@ function ct(e) {
|
|
|
599
614
|
}
|
|
600
615
|
});
|
|
601
616
|
}
|
|
602
|
-
function
|
|
617
|
+
function pt(e) {
|
|
603
618
|
return (() => {
|
|
604
|
-
var t =
|
|
605
|
-
return
|
|
606
|
-
var t =
|
|
619
|
+
var t = ct();
|
|
620
|
+
return N(t, (() => {
|
|
621
|
+
var t = P(() => !!e.icon);
|
|
607
622
|
return () => t() && (() => {
|
|
608
|
-
var t =
|
|
609
|
-
return
|
|
623
|
+
var t = lt();
|
|
624
|
+
return N(t, () => e.icon), t;
|
|
610
625
|
})();
|
|
611
|
-
})(), null),
|
|
612
|
-
var t =
|
|
626
|
+
})(), null), N(t, (() => {
|
|
627
|
+
var t = P(() => !!e.title);
|
|
613
628
|
return () => t() && (() => {
|
|
614
|
-
var t =
|
|
615
|
-
return
|
|
629
|
+
var t = ut();
|
|
630
|
+
return N(t, () => e.title), t;
|
|
616
631
|
})();
|
|
617
|
-
})(), null),
|
|
618
|
-
var t =
|
|
632
|
+
})(), null), N(t, (() => {
|
|
633
|
+
var t = P(() => !!e.message);
|
|
619
634
|
return () => t() && (() => {
|
|
620
|
-
var t =
|
|
621
|
-
return
|
|
635
|
+
var t = dt();
|
|
636
|
+
return N(t, () => e.message), t;
|
|
622
637
|
})();
|
|
623
638
|
})(), null), t;
|
|
624
639
|
})();
|
|
625
640
|
}
|
|
626
|
-
var
|
|
627
|
-
|
|
641
|
+
var U = ft;
|
|
642
|
+
U.Content = ze, U.Icon = Ue, U.Title = Je, U.Status = Ge, U.Value = at, U.SliderFill = Le;
|
|
628
643
|
//#endregion
|
|
629
644
|
//#region src/framework/dialogs/WidgetDialog.tsx
|
|
630
|
-
var
|
|
631
|
-
function
|
|
645
|
+
var mt = /*#__PURE__*/ L("<span class=\"inline-flex size-3.5 shrink-0 items-center\">"), ht = /*#__PURE__*/ L("<button type=button>"), gt = /*#__PURE__*/ L("<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox=\"0 0 24 24\"stroke=currentColor stroke-width=2><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"></path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\">"), _t = /*#__PURE__*/ L("<div class=\"rounded-lg bg-muted/30 p-2 text-center md:p-6\"><p class=\"text-muted-foreground text-sm\">No edit options available"), vt = /*#__PURE__*/ L("<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox=\"0 0 24 24\"stroke=currentColor stroke-width=2><line x1=4 y1=21 x2=4 y2=14></line><line x1=4 y1=10 x2=4 y2=3></line><line x1=12 y1=21 x2=12 y2=12></line><line x1=12 y1=8 x2=12 y2=3></line><line x1=20 y1=21 x2=20 y2=16></line><line x1=20 y1=12 x2=20 y2=3></line><line x1=1 y1=14 x2=7 y2=14></line><line x1=9 y1=8 x2=15 y2=8></line><line x1=17 y1=16 x2=23 y2=16>"), yt = /*#__PURE__*/ L("<div class=\"rounded-lg bg-muted/30 p-2 text-center md:p-6\"><p class=\"text-muted-foreground text-sm\">No additional controls"), bt = /*#__PURE__*/ L("<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox=\"0 0 24 24\"stroke=currentColor stroke-width=2><path d=\"m8 2 1.88 1.88\"></path><path d=\"M14.12 3.88 16 2\"></path><path d=\"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1\"></path><path d=\"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6\"></path><path d=\"M12 20v-9\"></path><path d=\"M6.53 9C4.6 8.8 3 7.1 3 5\"></path><path d=\"M6 13H2\"></path><path d=\"M3 21c0-2.1 1.7-3.9 3.8-4\"></path><path d=\"M20.97 5c0 2.1-1.6 3.8-3.5 4\"></path><path d=\"M22 13h-4\"></path><path d=\"M17.2 17c2.1.1 3.8 1.9 3.8 4\">"), xt = /*#__PURE__*/ L("<div class=\"rounded-lg bg-muted/30 p-2 text-center md:p-6\"><p class=\"text-muted-foreground text-sm\">No debug information available"), St = /*#__PURE__*/ L("<div class=\"min-w-0 shrink-0\">"), Ct = /*#__PURE__*/ L("<div class=\"flex items-center gap-2\"><div class=\"flex h-8 items-center rounded-lg border border-border/50 bg-muted/30 p-0.5\">"), wt = /*#__PURE__*/ L("<div class=\"min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]\">"), Tt = /*#__PURE__*/ L("<div class=\"flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3\">");
|
|
646
|
+
function Et(e) {
|
|
632
647
|
return (() => {
|
|
633
|
-
var t =
|
|
634
|
-
return t.$$click = () => e.onClick(),
|
|
648
|
+
var t = ht();
|
|
649
|
+
return t.$$click = () => e.onClick(), N(t, j(C, {
|
|
635
650
|
get when() {
|
|
636
651
|
return e.isActive;
|
|
637
652
|
},
|
|
638
653
|
get children() {
|
|
639
|
-
var t =
|
|
640
|
-
return
|
|
654
|
+
var t = mt();
|
|
655
|
+
return N(t, () => e.icon), t;
|
|
641
656
|
}
|
|
642
|
-
}), null),
|
|
657
|
+
}), null), N(t, () => e.label, null), M(() => A(t, H("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
|
|
643
658
|
})();
|
|
644
659
|
}
|
|
645
|
-
function
|
|
646
|
-
let [t] =
|
|
647
|
-
|
|
660
|
+
function Dt(e) {
|
|
661
|
+
let [t] = he(e, /* @__PURE__ */ "open.onOpenChange.title.onSave.hasUnsavedChanges.onDelete.editContent.controlsContent.debugContent.debugData.tabs.class.maxWidth.defaultTab.activeTab.onActiveTabChange.headerActions.configSchema.config.onConfigSave.ResponsiveDialog.ResponsiveDialogContent.ResponsiveDialogHeader.ResponsiveDialogTitle.ResponsiveDialogDescription.Button.SchemaForm".split(".")), n = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [r, i] = E({}), [a, o] = E(null);
|
|
662
|
+
w(pe(() => t.config, (e) => {
|
|
648
663
|
e && i({ ...e });
|
|
649
|
-
})),
|
|
650
|
-
e && o(
|
|
664
|
+
})), w(pe(() => t.configSchema, (e) => {
|
|
665
|
+
e && o(be(e));
|
|
651
666
|
}));
|
|
652
667
|
let s = () => n() && JSON.stringify(r()) !== JSON.stringify(t.config), c = (e) => {
|
|
653
668
|
!e && t.config && i({ ...t.config }), t.onOpenChange(e);
|
|
654
669
|
}, l = () => {
|
|
655
670
|
t.onConfigSave?.(r());
|
|
656
|
-
}, [u, d] =
|
|
671
|
+
}, [u, d] = E(t.defaultTab ?? "controls"), f = () => t.activeTab ?? u(), p = (e) => {
|
|
657
672
|
t.onActiveTabChange ? t.onActiveTabChange(e) : d(e);
|
|
658
673
|
}, m = () => ({
|
|
659
674
|
sm: "max-w-sm",
|
|
@@ -669,8 +684,8 @@ function Ct(e) {
|
|
|
669
684
|
return e.push({
|
|
670
685
|
id: "edit",
|
|
671
686
|
label: "Edit",
|
|
672
|
-
icon:
|
|
673
|
-
content: t.editContent ?? (n() && a() ?
|
|
687
|
+
icon: gt(),
|
|
688
|
+
content: t.editContent ?? (n() && a() ? j(ne, {
|
|
674
689
|
get schema() {
|
|
675
690
|
return a();
|
|
676
691
|
},
|
|
@@ -678,17 +693,17 @@ function Ct(e) {
|
|
|
678
693
|
return r();
|
|
679
694
|
},
|
|
680
695
|
onChange: i
|
|
681
|
-
}) :
|
|
696
|
+
}) : _t())
|
|
682
697
|
}), e.push({
|
|
683
698
|
id: "controls",
|
|
684
699
|
label: "Controls",
|
|
685
|
-
icon:
|
|
686
|
-
content: t.controlsContent ??
|
|
700
|
+
icon: vt(),
|
|
701
|
+
content: t.controlsContent ?? yt()
|
|
687
702
|
}), e.push({
|
|
688
703
|
id: "debug",
|
|
689
704
|
label: "Debug",
|
|
690
|
-
icon:
|
|
691
|
-
content: t.debugContent ??
|
|
705
|
+
icon: bt(),
|
|
706
|
+
content: t.debugContent ?? xt()
|
|
692
707
|
}), e;
|
|
693
708
|
}, g = async () => {
|
|
694
709
|
if (t.debugData !== void 0) try {
|
|
@@ -698,36 +713,36 @@ function Ct(e) {
|
|
|
698
713
|
}, _ = () => {
|
|
699
714
|
let e = h();
|
|
700
715
|
return e.find((e) => e.id === f())?.content ?? e[0]?.content;
|
|
701
|
-
}, v = t.ResponsiveDialog,
|
|
702
|
-
return
|
|
716
|
+
}, v = t.ResponsiveDialog, ee = t.ResponsiveDialogContent, y = t.ResponsiveDialogHeader, b = t.ResponsiveDialogTitle, te = t.ResponsiveDialogDescription, x = t.Button, ne = t.SchemaForm, re = (e) => n() ? c(e) : t.onOpenChange(e), ie = () => n() ? s() : t.hasUnsavedChanges, S = () => n() ? l : t.onSave;
|
|
717
|
+
return j(v, {
|
|
703
718
|
get open() {
|
|
704
719
|
return t.open;
|
|
705
720
|
},
|
|
706
|
-
onOpenChange: (e) =>
|
|
721
|
+
onOpenChange: (e) => re(e),
|
|
707
722
|
get children() {
|
|
708
|
-
return
|
|
723
|
+
return j(ee, {
|
|
709
724
|
get class() {
|
|
710
|
-
return
|
|
725
|
+
return H(m(), t.class);
|
|
711
726
|
},
|
|
712
727
|
get children() {
|
|
713
728
|
return [
|
|
714
|
-
|
|
729
|
+
j(y, {
|
|
715
730
|
class: "flex flex-row items-center justify-between gap-3",
|
|
716
731
|
get children() {
|
|
717
732
|
return [(() => {
|
|
718
|
-
var e =
|
|
719
|
-
return
|
|
733
|
+
var e = St();
|
|
734
|
+
return N(e, j(b, {
|
|
720
735
|
class: "truncate leading-tight",
|
|
721
736
|
get children() {
|
|
722
737
|
return t.title;
|
|
723
738
|
}
|
|
724
|
-
}), null),
|
|
739
|
+
}), null), N(e, j(te, {
|
|
725
740
|
class: "sr-only",
|
|
726
741
|
children: "Widget configuration dialog"
|
|
727
742
|
}), null), e;
|
|
728
743
|
})(), (() => {
|
|
729
|
-
var e =
|
|
730
|
-
return
|
|
744
|
+
var e = Ct(), n = e.firstChild;
|
|
745
|
+
return N(n, () => h().map((e) => j(Et, {
|
|
731
746
|
get icon() {
|
|
732
747
|
return e.icon;
|
|
733
748
|
},
|
|
@@ -738,7 +753,7 @@ function Ct(e) {
|
|
|
738
753
|
return f() === e.id;
|
|
739
754
|
},
|
|
740
755
|
onClick: () => p(e.id)
|
|
741
|
-
}))),
|
|
756
|
+
}))), N(e, j(C, {
|
|
742
757
|
get when() {
|
|
743
758
|
return t.headerActions;
|
|
744
759
|
},
|
|
@@ -750,47 +765,47 @@ function Ct(e) {
|
|
|
750
765
|
}
|
|
751
766
|
}),
|
|
752
767
|
(() => {
|
|
753
|
-
var e =
|
|
754
|
-
return
|
|
768
|
+
var e = wt();
|
|
769
|
+
return N(e, _), e;
|
|
755
770
|
})(),
|
|
756
|
-
|
|
771
|
+
j(C, {
|
|
757
772
|
get when() {
|
|
758
|
-
return
|
|
773
|
+
return P(() => f() === "edit")() && (S() || t.onDelete) || f() === "debug" && t.debugData !== void 0;
|
|
759
774
|
},
|
|
760
775
|
get children() {
|
|
761
|
-
var e =
|
|
762
|
-
return
|
|
776
|
+
var e = Tt();
|
|
777
|
+
return N(e, j(C, {
|
|
763
778
|
get when() {
|
|
764
|
-
return
|
|
779
|
+
return P(() => f() === "edit")() && t.onDelete;
|
|
765
780
|
},
|
|
766
781
|
get children() {
|
|
767
|
-
return
|
|
782
|
+
return j(x, {
|
|
768
783
|
size: "sm",
|
|
769
784
|
variant: "destructive",
|
|
770
785
|
onClick: () => t.onDelete?.(),
|
|
771
786
|
children: "Delete"
|
|
772
787
|
});
|
|
773
788
|
}
|
|
774
|
-
}), null),
|
|
789
|
+
}), null), N(e, j(C, {
|
|
775
790
|
get when() {
|
|
776
|
-
return
|
|
791
|
+
return P(() => f() === "edit")() && S();
|
|
777
792
|
},
|
|
778
793
|
get children() {
|
|
779
|
-
return
|
|
794
|
+
return j(x, {
|
|
780
795
|
size: "sm",
|
|
781
796
|
get disabled() {
|
|
782
|
-
return !
|
|
797
|
+
return !ie();
|
|
783
798
|
},
|
|
784
|
-
onClick: () =>
|
|
799
|
+
onClick: () => S()?.(),
|
|
785
800
|
children: "Save"
|
|
786
801
|
});
|
|
787
802
|
}
|
|
788
|
-
}), null),
|
|
803
|
+
}), null), N(e, j(C, {
|
|
789
804
|
get when() {
|
|
790
|
-
return
|
|
805
|
+
return P(() => f() === "debug")() && t.debugData !== void 0;
|
|
791
806
|
},
|
|
792
807
|
get children() {
|
|
793
|
-
return
|
|
808
|
+
return j(x, {
|
|
794
809
|
size: "sm",
|
|
795
810
|
variant: "outline",
|
|
796
811
|
onClick: g,
|
|
@@ -806,34 +821,34 @@ function Ct(e) {
|
|
|
806
821
|
}
|
|
807
822
|
});
|
|
808
823
|
}
|
|
809
|
-
|
|
824
|
+
ge(["click"]);
|
|
810
825
|
//#endregion
|
|
811
826
|
//#region src/framework/hooks/use-intersection-pause.ts
|
|
812
|
-
function
|
|
827
|
+
function Ot(e) {
|
|
813
828
|
if (typeof IntersectionObserver > "u") return () => !1;
|
|
814
|
-
let [t, n] =
|
|
829
|
+
let [t, n] = E(!1), r = new IntersectionObserver((e) => {
|
|
815
830
|
let t = e[0];
|
|
816
831
|
t && n(!t.isIntersecting);
|
|
817
832
|
});
|
|
818
|
-
return
|
|
833
|
+
return w(() => {
|
|
819
834
|
let t = e();
|
|
820
835
|
r.disconnect(), t && r.observe(t);
|
|
821
|
-
}),
|
|
836
|
+
}), D(() => r.disconnect()), t;
|
|
822
837
|
}
|
|
823
838
|
//#endregion
|
|
824
839
|
//#region src/framework/hooks/use-reduced-motion.ts
|
|
825
|
-
function
|
|
840
|
+
function kt() {
|
|
826
841
|
if (typeof window > "u" || typeof window.matchMedia != "function") return () => !1;
|
|
827
|
-
let e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, n] =
|
|
828
|
-
return e.addEventListener("change", r),
|
|
842
|
+
let e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, n] = E(e.matches), r = (e) => n(e.matches);
|
|
843
|
+
return e.addEventListener("change", r), D(() => e.removeEventListener("change", r)), t;
|
|
829
844
|
}
|
|
830
845
|
//#endregion
|
|
831
846
|
//#region src/framework/hooks/use-widget-dialog.ts
|
|
832
|
-
function
|
|
833
|
-
let [t, n] =
|
|
847
|
+
function At(e = "controls") {
|
|
848
|
+
let [t, n] = E(!1), [r, i] = E(e), a = (t) => {
|
|
834
849
|
i(t ?? e), n(!0);
|
|
835
|
-
}, o =
|
|
836
|
-
return o?.registerDialogOpener?.(a),
|
|
850
|
+
}, o = O(R);
|
|
851
|
+
return o?.registerDialogOpener?.(a), D(() => o?.registerDialogOpener?.(null)), {
|
|
837
852
|
showDialog: t,
|
|
838
853
|
setShowDialog: n,
|
|
839
854
|
openDialog: a,
|
|
@@ -854,15 +869,15 @@ function Et(e = "controls") {
|
|
|
854
869
|
}
|
|
855
870
|
//#endregion
|
|
856
871
|
//#region src/framework/hooks/use-widget-entity-group.ts
|
|
857
|
-
function
|
|
858
|
-
let t = e.minEntities ?? 1, n =
|
|
872
|
+
function jt(e) {
|
|
873
|
+
let t = e.minEntities ?? 1, n = T(() => e.entities().length), r = T(() => n() >= t), i = T(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), a = T(() => {
|
|
859
874
|
if (!r()) return;
|
|
860
875
|
let t = e.aggregationMode?.();
|
|
861
876
|
if (!t || t === "none") return;
|
|
862
877
|
let n = e.entities();
|
|
863
|
-
if (t === "light" || t === "binary-sensor" || t === "switch") return
|
|
864
|
-
if (t === "sensor") return
|
|
865
|
-
}), o =
|
|
878
|
+
if (t === "light" || t === "binary-sensor" || t === "switch") return Ye(n, e.allEntitiesMode);
|
|
879
|
+
if (t === "sensor") return Xe(n, e.sensorGroupType?.() ?? "mean", !0);
|
|
880
|
+
}), o = T(() => r() ? void 0 : e.emptyStateConfig);
|
|
866
881
|
return {
|
|
867
882
|
entities: e.entities,
|
|
868
883
|
groupData: i,
|
|
@@ -874,142 +889,142 @@ function Dt(e) {
|
|
|
874
889
|
}
|
|
875
890
|
//#endregion
|
|
876
891
|
//#region src/framework/gestures/cursors.ts
|
|
877
|
-
var
|
|
878
|
-
function
|
|
892
|
+
var W = 32, G = W / 2, K = "white", q = "rgba(0,0,0,0.4)", J = 2, Y = 3;
|
|
893
|
+
function Mt(e) {
|
|
879
894
|
return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
|
|
880
895
|
}
|
|
881
|
-
function
|
|
882
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
896
|
+
function X(e) {
|
|
897
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${W}" viewBox="0 0 ${W} ${W}">${e}</svg>`;
|
|
883
898
|
}
|
|
884
|
-
var
|
|
899
|
+
var Nt = X(`
|
|
885
900
|
<g transform="translate(6, 2)">
|
|
886
901
|
<!-- shadow -->
|
|
887
|
-
<g stroke="${
|
|
902
|
+
<g stroke="${q}" stroke-width="${Y}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
888
903
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
889
904
|
</g>
|
|
890
905
|
<!-- main -->
|
|
891
|
-
<g stroke="${
|
|
906
|
+
<g stroke="${K}" stroke-width="${J}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
892
907
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
893
908
|
</g>
|
|
894
909
|
</g>
|
|
895
|
-
`),
|
|
910
|
+
`), Pt = X(`
|
|
896
911
|
<g>
|
|
897
|
-
<circle cx="${
|
|
898
|
-
<circle cx="${
|
|
899
|
-
<circle cx="${
|
|
912
|
+
<circle cx="${G}" cy="${G}" r="8" stroke="${q}" stroke-width="${Y}" fill="none"/>
|
|
913
|
+
<circle cx="${G}" cy="${G}" r="8" stroke="${K}" stroke-width="1.5" fill="none"/>
|
|
914
|
+
<circle cx="${G}" cy="${G}" r="1.5" fill="${K}"/>
|
|
900
915
|
</g>
|
|
901
|
-
`),
|
|
916
|
+
`), Ft = X(`
|
|
902
917
|
<g>
|
|
903
918
|
<!-- shadow -->
|
|
904
|
-
<g stroke="${
|
|
905
|
-
<line x1="6" y1="${
|
|
906
|
-
<polyline points="10,${
|
|
907
|
-
<polyline points="22,${
|
|
919
|
+
<g stroke="${q}" stroke-width="${Y}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
920
|
+
<line x1="6" y1="${G}" x2="26" y2="${G}"/>
|
|
921
|
+
<polyline points="10,${G - 4} 6,${G} 10,20"/>
|
|
922
|
+
<polyline points="22,${G - 4} 26,${G} 22,20"/>
|
|
908
923
|
</g>
|
|
909
924
|
<!-- main -->
|
|
910
|
-
<g stroke="${
|
|
911
|
-
<line x1="6" y1="${
|
|
912
|
-
<polyline points="10,${
|
|
913
|
-
<polyline points="22,${
|
|
925
|
+
<g stroke="${K}" stroke-width="${J}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
926
|
+
<line x1="6" y1="${G}" x2="26" y2="${G}"/>
|
|
927
|
+
<polyline points="10,${G - 4} 6,${G} 10,20"/>
|
|
928
|
+
<polyline points="22,${G - 4} 26,${G} 22,20"/>
|
|
914
929
|
</g>
|
|
915
930
|
<!-- center grip dots -->
|
|
916
|
-
<circle cx="${
|
|
917
|
-
<circle cx="${
|
|
918
|
-
<circle cx="21" cy="${
|
|
931
|
+
<circle cx="${G}" cy="${G}" r="1.5" fill="${K}"/>
|
|
932
|
+
<circle cx="${G - 5}" cy="${G}" r="1" fill="${K}" opacity="0.6"/>
|
|
933
|
+
<circle cx="21" cy="${G}" r="1" fill="${K}" opacity="0.6"/>
|
|
919
934
|
</g>
|
|
920
|
-
`),
|
|
935
|
+
`), It = X(`
|
|
921
936
|
<g>
|
|
922
937
|
<!-- shadow -->
|
|
923
|
-
<g stroke="${
|
|
924
|
-
<line x1="${
|
|
925
|
-
<polyline points="${
|
|
926
|
-
<polyline points="${
|
|
938
|
+
<g stroke="${q}" stroke-width="${Y}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
939
|
+
<line x1="${G}" y1="6" x2="${G}" y2="26"/>
|
|
940
|
+
<polyline points="${G - 4},10 ${G},6 20,10"/>
|
|
941
|
+
<polyline points="${G - 4},22 ${G},26 20,22"/>
|
|
927
942
|
</g>
|
|
928
943
|
<!-- main -->
|
|
929
|
-
<g stroke="${
|
|
930
|
-
<line x1="${
|
|
931
|
-
<polyline points="${
|
|
932
|
-
<polyline points="${
|
|
944
|
+
<g stroke="${K}" stroke-width="${J}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
945
|
+
<line x1="${G}" y1="6" x2="${G}" y2="26"/>
|
|
946
|
+
<polyline points="${G - 4},10 ${G},6 20,10"/>
|
|
947
|
+
<polyline points="${G - 4},22 ${G},26 20,22"/>
|
|
933
948
|
</g>
|
|
934
949
|
<!-- center grip dots -->
|
|
935
|
-
<circle cx="${
|
|
936
|
-
<circle cx="${
|
|
937
|
-
<circle cx="${
|
|
950
|
+
<circle cx="${G}" cy="${G}" r="1.5" fill="${K}"/>
|
|
951
|
+
<circle cx="${G}" cy="${G - 5}" r="1" fill="${K}" opacity="0.6"/>
|
|
952
|
+
<circle cx="${G}" cy="21" r="1" fill="${K}" opacity="0.6"/>
|
|
938
953
|
</g>
|
|
939
|
-
`),
|
|
954
|
+
`), Lt = X(`
|
|
940
955
|
<g>
|
|
941
956
|
<!-- shadow -->
|
|
942
|
-
<g stroke="${
|
|
943
|
-
<line x1="7" y1="${
|
|
944
|
-
<line x1="${
|
|
945
|
-
<polyline points="11,${
|
|
946
|
-
<polyline points="21,${
|
|
947
|
-
<polyline points="${
|
|
948
|
-
<polyline points="${
|
|
957
|
+
<g stroke="${q}" stroke-width="${Y}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
958
|
+
<line x1="7" y1="${G}" x2="25" y2="${G}"/>
|
|
959
|
+
<line x1="${G}" y1="7" x2="${G}" y2="25"/>
|
|
960
|
+
<polyline points="11,${G - 3} 7,${G} 11,19"/>
|
|
961
|
+
<polyline points="21,${G - 3} 25,${G} 21,19"/>
|
|
962
|
+
<polyline points="${G - 3},11 ${G},7 19,11"/>
|
|
963
|
+
<polyline points="${G - 3},21 ${G},25 19,21"/>
|
|
949
964
|
</g>
|
|
950
965
|
<!-- main -->
|
|
951
|
-
<g stroke="${
|
|
952
|
-
<line x1="7" y1="${
|
|
953
|
-
<line x1="${
|
|
954
|
-
<polyline points="11,${
|
|
955
|
-
<polyline points="21,${
|
|
956
|
-
<polyline points="${
|
|
957
|
-
<polyline points="${
|
|
966
|
+
<g stroke="${K}" stroke-width="${J}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
967
|
+
<line x1="7" y1="${G}" x2="25" y2="${G}"/>
|
|
968
|
+
<line x1="${G}" y1="7" x2="${G}" y2="25"/>
|
|
969
|
+
<polyline points="11,${G - 3} 7,${G} 11,19"/>
|
|
970
|
+
<polyline points="21,${G - 3} 25,${G} 21,19"/>
|
|
971
|
+
<polyline points="${G - 3},11 ${G},7 19,11"/>
|
|
972
|
+
<polyline points="${G - 3},21 ${G},25 19,21"/>
|
|
958
973
|
</g>
|
|
959
974
|
<!-- center dot -->
|
|
960
|
-
<circle cx="${
|
|
975
|
+
<circle cx="${G}" cy="${G}" r="2" fill="${K}"/>
|
|
961
976
|
</g>
|
|
962
977
|
`);
|
|
963
|
-
function
|
|
978
|
+
function Z(e, t, n) {
|
|
964
979
|
return {
|
|
965
|
-
css: `${
|
|
980
|
+
css: `${Mt(e)} ${t} ${n}, auto`,
|
|
966
981
|
hotspotX: t,
|
|
967
982
|
hotspotY: n
|
|
968
983
|
};
|
|
969
984
|
}
|
|
970
|
-
var
|
|
971
|
-
tap:
|
|
972
|
-
hold:
|
|
973
|
-
slideHorizontal:
|
|
974
|
-
slideVertical:
|
|
975
|
-
slideAuto:
|
|
985
|
+
var Q = {
|
|
986
|
+
tap: Z(Nt, 12, 4),
|
|
987
|
+
hold: Z(Pt, 16, 16),
|
|
988
|
+
slideHorizontal: Z(Ft, G, G),
|
|
989
|
+
slideVertical: Z(It, G, G),
|
|
990
|
+
slideAuto: Z(Lt, G, G)
|
|
976
991
|
};
|
|
977
992
|
//#endregion
|
|
978
993
|
//#region src/framework/gestures/haptics.ts
|
|
979
|
-
function
|
|
994
|
+
function Rt() {
|
|
980
995
|
if (typeof window > "u") return null;
|
|
981
996
|
let e = window;
|
|
982
997
|
return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
|
|
983
998
|
}
|
|
984
|
-
function
|
|
999
|
+
function zt(e) {
|
|
985
1000
|
if (!(typeof navigator > "u" || typeof navigator.vibrate != "function")) try {
|
|
986
1001
|
navigator.vibrate(e);
|
|
987
1002
|
} catch {}
|
|
988
1003
|
}
|
|
989
|
-
var
|
|
1004
|
+
var Bt = {
|
|
990
1005
|
tick() {
|
|
991
|
-
let e =
|
|
1006
|
+
let e = Rt();
|
|
992
1007
|
if (e) {
|
|
993
1008
|
e.impact({ style: "Light" }).catch(() => {});
|
|
994
1009
|
return;
|
|
995
1010
|
}
|
|
996
|
-
|
|
1011
|
+
zt(8);
|
|
997
1012
|
},
|
|
998
1013
|
bump() {
|
|
999
|
-
let e =
|
|
1014
|
+
let e = Rt();
|
|
1000
1015
|
if (e) {
|
|
1001
1016
|
e.impact({ style: "Medium" }).catch(() => {});
|
|
1002
1017
|
return;
|
|
1003
1018
|
}
|
|
1004
|
-
|
|
1019
|
+
zt(20);
|
|
1005
1020
|
},
|
|
1006
1021
|
pulse() {
|
|
1007
|
-
let e =
|
|
1022
|
+
let e = Rt();
|
|
1008
1023
|
if (e) {
|
|
1009
1024
|
e.impact({ style: "Heavy" }).catch(() => {});
|
|
1010
1025
|
return;
|
|
1011
1026
|
}
|
|
1012
|
-
|
|
1027
|
+
zt([
|
|
1013
1028
|
0,
|
|
1014
1029
|
15,
|
|
1015
1030
|
40,
|
|
@@ -1019,7 +1034,7 @@ var It = {
|
|
|
1019
1034
|
};
|
|
1020
1035
|
//#endregion
|
|
1021
1036
|
//#region src/framework/gestures/use-widget-gestures.ts
|
|
1022
|
-
function
|
|
1037
|
+
function Vt(e, t) {
|
|
1023
1038
|
let n = {
|
|
1024
1039
|
isDown: !1,
|
|
1025
1040
|
isTouch: !1,
|
|
@@ -1030,7 +1045,7 @@ function Lt(e, t) {
|
|
|
1030
1045
|
sliding: !1,
|
|
1031
1046
|
holdTimer: null,
|
|
1032
1047
|
element: null
|
|
1033
|
-
}, r = null, i = null, a = null, [o, s] =
|
|
1048
|
+
}, r = null, i = null, a = null, [o, s] = E(null);
|
|
1034
1049
|
function c(e) {
|
|
1035
1050
|
e !== i && (a && a.disconnect(), a = new ResizeObserver((e) => {
|
|
1036
1051
|
let t = e[0];
|
|
@@ -1062,7 +1077,7 @@ function Lt(e, t) {
|
|
|
1062
1077
|
if (n.isDown = !0, n.isTouch = t.pointerType === "touch", n.element = t.currentTarget, c(n.element), n.startX = t.clientX, n.startY = t.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, r.hold) {
|
|
1063
1078
|
let e = r.hold.delay ?? 300;
|
|
1064
1079
|
n.holdTimer = setTimeout(() => {
|
|
1065
|
-
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (
|
|
1080
|
+
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Bt.bump(), r.hold?.action(), n.isDown = !1);
|
|
1066
1081
|
}, e);
|
|
1067
1082
|
}
|
|
1068
1083
|
if (!n.isTouch && r.slide) try {
|
|
@@ -1099,9 +1114,9 @@ function Lt(e, t) {
|
|
|
1099
1114
|
let n = e();
|
|
1100
1115
|
if (n.slide) {
|
|
1101
1116
|
let e = n.slide.orientation;
|
|
1102
|
-
return e === "horizontal" ?
|
|
1117
|
+
return e === "horizontal" ? Q.slideHorizontal.css : e === "vertical" ? Q.slideVertical.css : (r || c(t), r && r.height > r.width ? Q.slideVertical.css : Q.slideHorizontal.css);
|
|
1103
1118
|
}
|
|
1104
|
-
return n.tap ?
|
|
1119
|
+
return n.tap ? Q.tap.css : n.hold ? Q.hold.css : "";
|
|
1105
1120
|
};
|
|
1106
1121
|
return {
|
|
1107
1122
|
onPointerDown: f,
|
|
@@ -1130,7 +1145,7 @@ function Lt(e, t) {
|
|
|
1130
1145
|
}
|
|
1131
1146
|
//#endregion
|
|
1132
1147
|
//#region src/framework/theming/svg-colors.ts
|
|
1133
|
-
var
|
|
1148
|
+
var Ht = {
|
|
1134
1149
|
solar: "oklch(0.74 0.18 60)",
|
|
1135
1150
|
grid: "oklch(0.62 0.12 245)",
|
|
1136
1151
|
battery: "oklch(0.70 0.18 145)",
|
|
@@ -1139,44 +1154,131 @@ var Rt = {
|
|
|
1139
1154
|
positive: "oklch(0.70 0.14 160)",
|
|
1140
1155
|
negative: "oklch(0.64 0.22 27)"
|
|
1141
1156
|
};
|
|
1142
|
-
function
|
|
1157
|
+
function Ut(e) {
|
|
1143
1158
|
return {
|
|
1144
1159
|
fill: `color-mix(in oklch, ${e} 20%, transparent)`,
|
|
1145
1160
|
stroke: e,
|
|
1146
1161
|
solid: e
|
|
1147
1162
|
};
|
|
1148
1163
|
}
|
|
1149
|
-
var
|
|
1164
|
+
var Wt = Object.fromEntries(Object.entries(Ht).map(([e, t]) => [e, Ut(t)])), Gt = o.enum([
|
|
1150
1165
|
"success",
|
|
1151
1166
|
"warning",
|
|
1152
1167
|
"danger",
|
|
1153
1168
|
"info",
|
|
1154
1169
|
"neutral",
|
|
1155
1170
|
"accent"
|
|
1156
|
-
]),
|
|
1157
|
-
title: () =>
|
|
1171
|
+
]), Kt = {
|
|
1172
|
+
title: e(() => o.string().optional().meta({
|
|
1158
1173
|
title: "Title",
|
|
1159
1174
|
description: "Optional display name override"
|
|
1160
|
-
}),
|
|
1161
|
-
entityIds: (e, t) =>
|
|
1175
|
+
}), "widgetFields.title"),
|
|
1176
|
+
entityIds: e((e, t) => o.array(o.string()).default([]).meta({
|
|
1162
1177
|
domain: e,
|
|
1163
1178
|
title: "Entities",
|
|
1164
1179
|
...t?.deviceClass ? { deviceClass: t.deviceClass } : {}
|
|
1165
|
-
}),
|
|
1166
|
-
singleEntity: (e, t) =>
|
|
1180
|
+
}), "widgetFields.entityIds"),
|
|
1181
|
+
singleEntity: e((e, t) => o.array(o.string()).default([]).meta({
|
|
1167
1182
|
domain: e,
|
|
1168
1183
|
title: "Entity",
|
|
1169
1184
|
singleSelect: !0,
|
|
1170
1185
|
...t?.deviceClass ? { deviceClass: t.deviceClass } : {}
|
|
1171
|
-
}),
|
|
1172
|
-
areaId: () =>
|
|
1186
|
+
}), "widgetFields.singleEntity"),
|
|
1187
|
+
areaId: e(() => o.string().optional().meta({
|
|
1173
1188
|
formType: "area-picker",
|
|
1174
1189
|
title: "Area"
|
|
1175
|
-
})
|
|
1190
|
+
}), "widgetFields.areaId")
|
|
1176
1191
|
};
|
|
1177
1192
|
//#endregion
|
|
1193
|
+
//#region src/framework/config/index.ts
|
|
1194
|
+
function $(e) {
|
|
1195
|
+
let t = {};
|
|
1196
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = r);
|
|
1197
|
+
return t;
|
|
1198
|
+
}
|
|
1199
|
+
function qt() {
|
|
1200
|
+
return o.string().optional().meta({
|
|
1201
|
+
title: "Title",
|
|
1202
|
+
description: "Optional display name override"
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
function Jt(e) {
|
|
1206
|
+
return (e.default === void 0 ? o.string().optional() : o.string().default(e.default)).meta($({
|
|
1207
|
+
title: e.title,
|
|
1208
|
+
description: e.description
|
|
1209
|
+
}));
|
|
1210
|
+
}
|
|
1211
|
+
function Yt(e) {
|
|
1212
|
+
let t = o.number();
|
|
1213
|
+
return e.min !== void 0 && (t = t.min(e.min)), e.max !== void 0 && (t = t.max(e.max)), (e.default === void 0 ? t.optional() : t.default(e.default)).meta($({
|
|
1214
|
+
title: e.title,
|
|
1215
|
+
description: e.description
|
|
1216
|
+
}));
|
|
1217
|
+
}
|
|
1218
|
+
function Xt(e) {
|
|
1219
|
+
return o.boolean().default(e.default ?? !1).meta($({
|
|
1220
|
+
title: e.title,
|
|
1221
|
+
description: e.description
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
function Zt(e, t) {
|
|
1225
|
+
let n = o.enum(e);
|
|
1226
|
+
return (t.default === void 0 ? n.optional() : n.default(t.default)).meta($({
|
|
1227
|
+
title: t.title,
|
|
1228
|
+
description: t.description
|
|
1229
|
+
}));
|
|
1230
|
+
}
|
|
1231
|
+
function Qt(e, t) {
|
|
1232
|
+
return o.array(o.string()).default([]).meta($({
|
|
1233
|
+
domain: e,
|
|
1234
|
+
title: t?.title ?? "Entities",
|
|
1235
|
+
description: t?.description,
|
|
1236
|
+
deviceClass: t?.deviceClass
|
|
1237
|
+
}));
|
|
1238
|
+
}
|
|
1239
|
+
function $t(e, t) {
|
|
1240
|
+
return o.array(o.string()).default([]).meta($({
|
|
1241
|
+
domain: e,
|
|
1242
|
+
title: t?.title ?? "Entity",
|
|
1243
|
+
description: t?.description,
|
|
1244
|
+
deviceClass: t?.deviceClass,
|
|
1245
|
+
singleSelect: !0
|
|
1246
|
+
}));
|
|
1247
|
+
}
|
|
1248
|
+
function en(e) {
|
|
1249
|
+
return o.string().optional().meta({
|
|
1250
|
+
formType: "area-picker",
|
|
1251
|
+
title: e?.title ?? "Area"
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
function tn(e) {
|
|
1255
|
+
return o.array(o.string()).default([]).meta($({
|
|
1256
|
+
title: e.title,
|
|
1257
|
+
description: e.description
|
|
1258
|
+
}));
|
|
1259
|
+
}
|
|
1260
|
+
function nn(e, t) {
|
|
1261
|
+
let n = o.object(e);
|
|
1262
|
+
return n.default(xe(n)).meta({ title: t.title });
|
|
1263
|
+
}
|
|
1264
|
+
var rn = {
|
|
1265
|
+
title: qt,
|
|
1266
|
+
text: Jt,
|
|
1267
|
+
number: Yt,
|
|
1268
|
+
toggle: Xt,
|
|
1269
|
+
choice: Zt,
|
|
1270
|
+
entities: Qt,
|
|
1271
|
+
entity: $t,
|
|
1272
|
+
area: en,
|
|
1273
|
+
stringList: tn,
|
|
1274
|
+
group: nn
|
|
1275
|
+
};
|
|
1276
|
+
function an(e) {
|
|
1277
|
+
return o.object(e);
|
|
1278
|
+
}
|
|
1279
|
+
//#endregion
|
|
1178
1280
|
//#region src/shared/spline.ts
|
|
1179
|
-
function
|
|
1281
|
+
function on(e) {
|
|
1180
1282
|
if (e.length < 2) return "";
|
|
1181
1283
|
let t = e[0], n = e[1];
|
|
1182
1284
|
if (!t || !n) return "";
|
|
@@ -1203,14 +1305,14 @@ function Ut(e) {
|
|
|
1203
1305
|
}
|
|
1204
1306
|
//#endregion
|
|
1205
1307
|
//#region src/theme.ts
|
|
1206
|
-
function
|
|
1308
|
+
function sn() {
|
|
1207
1309
|
return document.documentElement.classList.contains("dark");
|
|
1208
1310
|
}
|
|
1209
1311
|
//#endregion
|
|
1210
1312
|
//#region src/version.ts
|
|
1211
|
-
var
|
|
1313
|
+
var cn = {
|
|
1212
1314
|
name: "@glasshome/widget-sdk",
|
|
1213
|
-
version: "1.
|
|
1315
|
+
version: "1.4.1",
|
|
1214
1316
|
description: "SDK for building GlassHome dashboard widgets with SolidJS",
|
|
1215
1317
|
keywords: [
|
|
1216
1318
|
"glasshome",
|
|
@@ -1237,6 +1339,11 @@ var Gt = {
|
|
|
1237
1339
|
types: "./dist/schemas.d.ts",
|
|
1238
1340
|
import: "./dist/schemas.js"
|
|
1239
1341
|
},
|
|
1342
|
+
"./deprecations": {
|
|
1343
|
+
"@glasshome/source": "./src/deprecations.ts",
|
|
1344
|
+
types: "./dist/deprecations.d.ts",
|
|
1345
|
+
import: "./dist/deprecations.js"
|
|
1346
|
+
},
|
|
1240
1347
|
"./vite": {
|
|
1241
1348
|
"@glasshome/source": "./src/vite/index.ts",
|
|
1242
1349
|
types: "./dist/vite/index.d.ts",
|
|
@@ -1252,7 +1359,9 @@ var Gt = {
|
|
|
1252
1359
|
],
|
|
1253
1360
|
scripts: {
|
|
1254
1361
|
build: "vite build && tsc",
|
|
1255
|
-
dev: "vite build --watch"
|
|
1362
|
+
dev: "vite build --watch",
|
|
1363
|
+
test: "bun test",
|
|
1364
|
+
"typecheck:test": "tsc --noEmit -p tsconfig.test.json"
|
|
1256
1365
|
},
|
|
1257
1366
|
peerDependencies: {
|
|
1258
1367
|
"@glasshome/sync-layer": "0.3.0",
|
|
@@ -1261,7 +1370,6 @@ var Gt = {
|
|
|
1261
1370
|
dependencies: {
|
|
1262
1371
|
"@glasshome/widget-contract": "0.1.0",
|
|
1263
1372
|
"@modular-forms/solid": "^0.25.1",
|
|
1264
|
-
"@solid-primitives/resize-observer": "^2.1.5",
|
|
1265
1373
|
clsx: "^2.1.1",
|
|
1266
1374
|
"tailwind-merge": "^3.5.0",
|
|
1267
1375
|
zod: "^4.1.13",
|
|
@@ -1287,4 +1395,4 @@ var Gt = {
|
|
|
1287
1395
|
engines: { node: ">=18" }
|
|
1288
1396
|
}.version;
|
|
1289
1397
|
//#endregion
|
|
1290
|
-
export {
|
|
1398
|
+
export { cn as SDK_VERSION, Gt as ToneSchema, U as Widget, ze as WidgetContent, R as WidgetCtx, Dt as WidgetDialog, Ue as WidgetIcon, r as WidgetManifestSchema, Le as WidgetSliderFill, Ge as WidgetStatus, Je as WidgetTitle, at as WidgetValue, g as byDomain, Ye as calculateLightGroup, Xe as calculateSensorGroup, et as countActiveEntities, an as defineConfig, Se as defineWidget, t as deprecations, rn as field, n as formatDeprecation, i as formatSchemaError, $e as getEntityAttribute, s as getForecasts, c as getStream, l as getWebRtcClientConfig, u as hassMediaUrl, Ne as injectTokens, sn as isDark, Qe as isEntityActive, on as monotoneCubicPath, d as sendWebRtcCandidate, f as startWebRtcSession, p as state, Wt as svgColors, m as trackEntityHistory, h as untrackEntityHistory, _ as useArea, v as useCamera, ee as useConnection, y as useCurrency, b as useEntities, te as useEntity, x as useEntityHistory, ne as useEntityStatistics, re as useForecast, ie as useHassConfig, Ot as useIntersectionPause, S as useLocale, kt as useReducedMotion, Te as useService, oe as useStore, se as useTemperatureUnit, Oe as useToggle, De as useTurnOff, Ee as useTurnOn, de as useUnitSystem, Ce as useWidgetContext, At as useWidgetDialog, jt as useWidgetEntityGroup, Vt as useWidgetGestures, Kt as widgetFields, a as z };
|