@glasshome/widget-sdk 0.3.5 → 0.3.7
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Haptic feedback for gesture transitions.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order at runtime:
|
|
5
|
+
* 1. Capacitor Haptics plugin (Android/iOS native) — richer patterns
|
|
6
|
+
* 2. `navigator.vibrate` (Android Chrome/WebView)
|
|
7
|
+
* 3. silent (desktop, iOS Safari)
|
|
8
|
+
*
|
|
9
|
+
* No build-time dependency on @capacitor/haptics — the host app installs the
|
|
10
|
+
* plugin; we probe `window.Capacitor.Plugins.Haptics` at call time.
|
|
11
|
+
*/
|
|
12
|
+
export declare const haptics: {
|
|
13
|
+
/** Light confirmation — fires when slide gesture arms after user holds still. */
|
|
14
|
+
tick(): void;
|
|
15
|
+
/** Medium bump — fires when hold gesture commits (detail opening). */
|
|
16
|
+
bump(): void;
|
|
17
|
+
/** Stronger pulse — reserved for edit-mode pickup (future use). */
|
|
18
|
+
pulse(): void;
|
|
19
|
+
};
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Widget Gestures Hook
|
|
2
|
+
* Widget Gestures Hook — Mobile-aware
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Ported from React reference, adapted for SolidJS:
|
|
6
|
-
* - Uses mutable state object instead of useRef (imperative gesture tracking)
|
|
7
|
-
* - Accepts config/orientation as accessors for reactivity
|
|
8
|
-
* - Returns native PointerEvent handlers (not React.PointerEvent)
|
|
9
|
-
* - Callers bind via on:pointerdown={handlers.onPointerDown}
|
|
4
|
+
* Two grammars by pointer type:
|
|
10
5
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* value: brightness(),
|
|
19
|
-
* onChange: setBrightness,
|
|
20
|
-
* min: 0,
|
|
21
|
-
* max: 100,
|
|
22
|
-
* orientation: "auto",
|
|
23
|
-
* },
|
|
24
|
-
* }),
|
|
25
|
-
* () => ctx.orientation(),
|
|
26
|
-
* );
|
|
6
|
+
* TOUCH (phone, tablet):
|
|
7
|
+
* - tap → primary action
|
|
8
|
+
* - hold → detail dialog (with haptic bump)
|
|
9
|
+
* - slide → DISABLED. Fine control lives in the detail dialog instead.
|
|
10
|
+
* This eliminates the slide-vs-page-scroll conflict that makes mobile
|
|
11
|
+
* gestures fragile. `touch-action: manipulation` ensures the browser
|
|
12
|
+
* handles scroll natively without our interference.
|
|
27
13
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
14
|
+
* MOUSE / PEN (desktop, hybrid devices):
|
|
15
|
+
* - tap, hold, slide all active. Slide arms immediately on pointerdown —
|
|
16
|
+
* no scroll conflict to worry about (mouse uses wheel for scroll).
|
|
17
|
+
*
|
|
18
|
+
* Pointer type is decided per press at pointerdown. A hybrid device (tablet
|
|
19
|
+
* + bluetooth mouse) gets the right grammar based on which input fired.
|
|
30
20
|
*/
|
|
31
21
|
import type { GestureConfig, WidgetOrientation } from "../types";
|
|
32
22
|
export interface GestureHandlers {
|
|
@@ -42,18 +32,13 @@ export interface GestureHandlers {
|
|
|
42
32
|
* receives the pointer handlers.
|
|
43
33
|
*/
|
|
44
34
|
bindElement: (el: HTMLElement) => void;
|
|
45
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* CSS `touch-action` for the gesture root. Always `manipulation` when any
|
|
37
|
+
* gesture is configured — mobile slide is intentionally dropped, so the
|
|
38
|
+
* browser owns scroll completely on touch surfaces.
|
|
39
|
+
*/
|
|
40
|
+
touchAction: () => string;
|
|
41
|
+
/** Cancel any pending hold timer. Call on component unmount via onCleanup. */
|
|
46
42
|
dispose: () => void;
|
|
47
43
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Widget gestures hook with conflict resolution
|
|
50
|
-
*
|
|
51
|
-
* Features:
|
|
52
|
-
* - Axis locking: Once slide direction is detected, locks to that axis
|
|
53
|
-
* - Scroll prevention: Blocks page scroll when sliding along widget axis
|
|
54
|
-
* - Tap/hold/slide gesture support with automatic conflict resolution
|
|
55
|
-
*
|
|
56
|
-
* @param config - Accessor returning gesture configuration
|
|
57
|
-
* @param orientation - Accessor returning widget orientation (for auto slide orientation)
|
|
58
|
-
*/
|
|
59
44
|
export declare function useWidgetGestures(config: () => GestureConfig, orientation?: () => WidgetOrientation): GestureHandlers;
|