@glasshome/widget-sdk 1.19.0 → 1.20.0
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.
|
@@ -26,6 +26,8 @@ export interface GestureHandlers {
|
|
|
26
26
|
dispose: () => void;
|
|
27
27
|
/** Where a hold is filling from, relative to the element; `fired` once it opened. */
|
|
28
28
|
hold?: () => HoldFlood | null;
|
|
29
|
+
/** True while a hold does something. */
|
|
30
|
+
holds?: () => boolean;
|
|
29
31
|
/** Keyboard door: Enter or Space taps, the context-menu key or Shift+F10 holds. */
|
|
30
32
|
onKeyDown?: (e: KeyboardEvent) => void;
|
|
31
33
|
}
|
|
@@ -50,6 +50,10 @@ export interface ReactiveWidgetContext {
|
|
|
50
50
|
developer?: () => boolean;
|
|
51
51
|
/** The tile's box on the page, so a held tile's sheet opens beside it. Absent: it opens centred. */
|
|
52
52
|
anchor?: () => HTMLElement | undefined;
|
|
53
|
+
/** Host hook: whether holding this widget opens anything. Absent on hosts that predate this field. */
|
|
54
|
+
onHoldable?: (holds: boolean) => void;
|
|
55
|
+
/** Host hook: a hold on this widget fired. Absent on hosts that predate this field. */
|
|
56
|
+
onHeld?: () => void;
|
|
53
57
|
}
|
|
54
58
|
export declare const WidgetCtx: import("solid-js").Context<ReactiveWidgetContext | undefined>;
|
|
55
59
|
export declare function useWidgetContext(): ReactiveWidgetContext;
|
package/dist/index.js
CHANGED
|
@@ -331,20 +331,20 @@ function xn(e, t) {
|
|
|
331
331
|
let t = i();
|
|
332
332
|
if (t.tap || t.hold || t.slide) {
|
|
333
333
|
if (a.isDown = !0, a.isTouch = e.pointerType === "touch", a.element = e.currentTarget, p(a.element), a.startX = e.clientX, a.startY = e.clientY, a.startTime = Date.now(), a.hasMoved = !1, a.sliding = !1, t.hold) {
|
|
334
|
-
let
|
|
334
|
+
let r = t.hold.delay ?? 550, i = a.element.getBoundingClientRect(), o = e.clientX - i.left, c = e.clientY - i.top, l = Math.hypot(Math.max(o, i.width - o), Math.max(c, i.height - c));
|
|
335
335
|
a.graceTimer = setTimeout(() => {
|
|
336
336
|
a.graceTimer = null, s({
|
|
337
|
-
x:
|
|
338
|
-
y:
|
|
339
|
-
r:
|
|
337
|
+
x: o,
|
|
338
|
+
y: c,
|
|
339
|
+
r: l,
|
|
340
340
|
fired: !1
|
|
341
341
|
});
|
|
342
|
-
}, Math.min(150,
|
|
342
|
+
}, Math.min(150, r)), a.holdTimer = setTimeout(() => {
|
|
343
343
|
a.holdTimer = null, a.isDown && !a.hasMoved && (s((e) => e && {
|
|
344
344
|
...e,
|
|
345
345
|
fired: !0
|
|
346
|
-
}), bn.bump(), a.element && h(a.element), t.hold?.action(), a.isDown = !1);
|
|
347
|
-
},
|
|
346
|
+
}), bn.bump(), a.element && h(a.element), t.hold?.action(), n?.onHeld?.(), a.isDown = !1);
|
|
347
|
+
}, r);
|
|
348
348
|
}
|
|
349
349
|
if (!a.isTouch && t.slide) try {
|
|
350
350
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
@@ -388,7 +388,7 @@ function xn(e, t) {
|
|
|
388
388
|
onKeyDown: (e) => {
|
|
389
389
|
if (e.target !== e.currentTarget) return;
|
|
390
390
|
let t = i();
|
|
391
|
-
(e.key === "Enter" || e.key === " ") && t.tap ? (e.preventDefault(), t.tap()) : (e.key === "ContextMenu" || e.shiftKey && e.key === "F10") && t.hold && (e.preventDefault(), t.hold.action());
|
|
391
|
+
(e.key === "Enter" || e.key === " ") && t.tap ? (e.preventDefault(), t.tap()) : (e.key === "ContextMenu" || e.shiftKey && e.key === "F10") && t.hold && (e.preventDefault(), t.hold.action(), n?.onHeld?.());
|
|
392
392
|
},
|
|
393
393
|
onPointerDown: v,
|
|
394
394
|
onPointerMove: y,
|
|
@@ -410,6 +410,7 @@ function xn(e, t) {
|
|
|
410
410
|
return e.tap || e.hold ? "manipulation" : "auto";
|
|
411
411
|
},
|
|
412
412
|
hold: o,
|
|
413
|
+
holds: () => !!i().hold,
|
|
413
414
|
dispose: () => {
|
|
414
415
|
m(), u &&= (u.disconnect(), null), l = null, c = null;
|
|
415
416
|
}
|
|
@@ -1120,7 +1121,7 @@ function Vr(t) {
|
|
|
1120
1121
|
let i = rn(n), a = xn(() => ({ hold: i?.hasSheet() ? { action: () => (q.get(n ?? {}) ?? q.get(d))?.() } : void 0 }));
|
|
1121
1122
|
k(a.dispose);
|
|
1122
1123
|
let o = () => t.emptyState && n ? r : t.gestures ?? (i?.hasSheet() ? a : void 0);
|
|
1123
|
-
E(() => i?.setTone(t.color ?? (t.tone ? `var(--tone-${t.tone})` : void 0)));
|
|
1124
|
+
n && !(tn in n) && (E(() => n?.onHoldable?.(!t.emptyState && !!o()?.holds?.())), k(() => n?.onHoldable?.(!1))), E(() => i?.setTone(t.color ?? (t.tone ? `var(--tone-${t.tone})` : void 0)));
|
|
1124
1125
|
let [s, c] = O(), [l, u] = O({
|
|
1125
1126
|
width: 0,
|
|
1126
1127
|
height: 0
|
|
@@ -1286,35 +1287,35 @@ Z.Content = fr, Z.Icon = kn, Z.Title = _r, Z.Status = mr, Z.Value = Nr, Z.Slider
|
|
|
1286
1287
|
//#region src/framework/panel/panel.tsx
|
|
1287
1288
|
var Ur = /*#__PURE__*/ B("<section class=glasshome-panel-section><h3 class=glasshome-panel-label>"), Wr = /*#__PURE__*/ B("<div class=glasshome-panel-rows>"), Gr = /*#__PURE__*/ B("<span class=\"glasshome-widget-slider-fill glasshome-panel-row-fill\">"), Kr = /*#__PURE__*/ B("<span class=\"glasshome-widget-icon glass glasshome-panel-row-icon\">"), qr = /*#__PURE__*/ B("<span class=glasshome-panel-row-state>"), Jr = /*#__PURE__*/ B("<span class=glasshome-panel-row-text><span class=glasshome-panel-row-name>"), Yr = /*#__PURE__*/ B("<span class=glasshome-panel-row-trailing>"), Xr = /*#__PURE__*/ B("<div class=glasshome-panel-row-wrap>"), Zr = /*#__PURE__*/ B("<div>"), Qr = /*#__PURE__*/ B("<div class=\"glasshome-panel-facts glass\">"), $r = /*#__PURE__*/ B("<div class=glasshome-panel-fact><span class=glasshome-panel-row-text><span class=glasshome-panel-fact-label></span><span class=glasshome-panel-fact-value>"), ei = 450, ti = 8, ni = (e, t, n) => Math.min(n, Math.max(t, e)), ri = "button, a, input, select, textarea, [role=\"slider\"], [role=\"radio\"], [role=\"switch\"]";
|
|
1288
1289
|
function ii(e) {
|
|
1289
|
-
let t, n = !1,
|
|
1290
|
+
let t = A(W), n, r = !1, i = !1, a, o = 0, s = (t, n) => {
|
|
1290
1291
|
let r = e.slide?.();
|
|
1291
1292
|
if (!r) return 0;
|
|
1292
1293
|
let i = t.getBoundingClientRect(), a = e.axis === "x" ? (n.clientX - i.left) / i.width : 1 - (n.clientY - i.top) / i.height, o = r.min ?? 0, s = r.max ?? 100;
|
|
1293
1294
|
return Math.round(ni(o + a * (s - o), o, s));
|
|
1294
|
-
},
|
|
1295
|
-
clearTimeout(
|
|
1295
|
+
}, c = () => {
|
|
1296
|
+
clearTimeout(a), n = void 0;
|
|
1296
1297
|
};
|
|
1297
|
-
return k(() => clearTimeout(
|
|
1298
|
-
onPointerDown: (
|
|
1299
|
-
if (
|
|
1300
|
-
let
|
|
1301
|
-
|
|
1302
|
-
x:
|
|
1303
|
-
y:
|
|
1304
|
-
id:
|
|
1305
|
-
},
|
|
1306
|
-
|
|
1298
|
+
return k(() => clearTimeout(a)), {
|
|
1299
|
+
onPointerDown: (o) => {
|
|
1300
|
+
if (o.button !== 0 || n) return;
|
|
1301
|
+
let s = o.target instanceof Element ? o.target.closest(ri) : null;
|
|
1302
|
+
s && s !== o.currentTarget || (n = {
|
|
1303
|
+
x: o.clientX,
|
|
1304
|
+
y: o.clientY,
|
|
1305
|
+
id: o.pointerId
|
|
1306
|
+
}, o.currentTarget.setPointerCapture?.(o.pointerId), r = !1, i = !1, e.onHold && (a = setTimeout(() => {
|
|
1307
|
+
i = !0, e.onHold?.(), t?.onHeld?.();
|
|
1307
1308
|
}, ei)));
|
|
1308
1309
|
},
|
|
1309
|
-
onPointerMove: (
|
|
1310
|
-
if (!
|
|
1311
|
-
let c =
|
|
1312
|
-
!
|
|
1310
|
+
onPointerMove: (t) => {
|
|
1311
|
+
if (!n || t.pointerId !== n.id || i) return;
|
|
1312
|
+
let c = t.currentTarget, l = e.axis === "x" ? Math.abs(t.clientX - n.x) : Math.abs(t.clientY - n.y);
|
|
1313
|
+
!r && e.slide?.() && l > ti && (r = !0, clearTimeout(a)), r ? (o = s(c, t), e.slide?.()?.onChange(o)) : Math.hypot(t.clientX - n.x, t.clientY - n.y) > ti && clearTimeout(a);
|
|
1313
1314
|
},
|
|
1314
|
-
onPointerUp: (
|
|
1315
|
-
|
|
1315
|
+
onPointerUp: (t) => {
|
|
1316
|
+
n && t.pointerId === n.id && (r ? e.slide?.()?.onCommit?.(o) : i || e.onTap?.(), c());
|
|
1316
1317
|
},
|
|
1317
|
-
onPointerCancel:
|
|
1318
|
+
onPointerCancel: c
|
|
1318
1319
|
};
|
|
1319
1320
|
}
|
|
1320
1321
|
function ai(e) {
|
|
@@ -2778,7 +2779,7 @@ function Qa() {
|
|
|
2778
2779
|
//#region src/version.ts
|
|
2779
2780
|
var $a = {
|
|
2780
2781
|
name: "@glasshome/widget-sdk",
|
|
2781
|
-
version: "1.
|
|
2782
|
+
version: "1.20.0",
|
|
2782
2783
|
description: "SDK for building GlassHome dashboard widgets with SolidJS",
|
|
2783
2784
|
keywords: [
|
|
2784
2785
|
"dashboard",
|