@signality/core 0.0.1-alpha.2
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 +60 -0
- package/browser/battery/index.d.ts +34 -0
- package/browser/bluetooth/index.d.ts +56 -0
- package/browser/breakpoints/index.d.ts +32 -0
- package/browser/broadcast-channel/index.d.ts +42 -0
- package/browser/browser-language/index.d.ts +34 -0
- package/browser/clipboard/index.d.ts +48 -0
- package/browser/device-posture/index.d.ts +18 -0
- package/browser/display-media/index.d.ts +80 -0
- package/browser/eye-dropper/index.d.ts +47 -0
- package/browser/favicon/index.d.ts +39 -0
- package/browser/fps/index.d.ts +46 -0
- package/browser/gamepad/index.d.ts +28 -0
- package/browser/geolocation/index.d.ts +64 -0
- package/browser/index.d.ts +29 -0
- package/browser/input-modality/index.d.ts +26 -0
- package/browser/listener/index.d.ts +61 -0
- package/browser/media-query/index.d.ts +36 -0
- package/browser/network/index.d.ts +44 -0
- package/browser/online/index.d.ts +27 -0
- package/browser/page-visibility/index.d.ts +27 -0
- package/browser/picture-in-picture/index.d.ts +42 -0
- package/browser/pointer-lock-element/index.d.ts +22 -0
- package/browser/screen-orientation/index.d.ts +29 -0
- package/browser/speech-recognition/index.d.ts +77 -0
- package/browser/speech-synthesis/index.d.ts +76 -0
- package/browser/storage/index.d.ts +142 -0
- package/browser/text-direction/index.d.ts +43 -0
- package/browser/vibration/index.d.ts +37 -0
- package/browser/wake-lock/index.d.ts +37 -0
- package/browser/web-notification/index.d.ts +58 -0
- package/browser/web-share/index.d.ts +42 -0
- package/browser/web-worker/index.d.ts +52 -0
- package/elements/active-element/index.d.ts +27 -0
- package/elements/dropzone/index.d.ts +61 -0
- package/elements/element-focus/index.d.ts +38 -0
- package/elements/element-focus-within/index.d.ts +29 -0
- package/elements/element-hover/index.d.ts +27 -0
- package/elements/element-size/index.d.ts +40 -0
- package/elements/element-visibility/index.d.ts +53 -0
- package/elements/index.d.ts +16 -0
- package/elements/mouse-position/index.d.ts +64 -0
- package/elements/on-click-outside/index.d.ts +42 -0
- package/elements/on-disconnect/index.d.ts +45 -0
- package/elements/on-long-press/index.d.ts +44 -0
- package/elements/pointer-swipe/index.d.ts +58 -0
- package/elements/scroll-position/index.d.ts +96 -0
- package/elements/swipe/index.d.ts +49 -0
- package/elements/text-selection/index.d.ts +39 -0
- package/elements/window-size/index.d.ts +46 -0
- package/fesm2022/signality-core-browser-battery.mjs +80 -0
- package/fesm2022/signality-core-browser-battery.mjs.map +1 -0
- package/fesm2022/signality-core-browser-bluetooth.mjs +112 -0
- package/fesm2022/signality-core-browser-bluetooth.mjs.map +1 -0
- package/fesm2022/signality-core-browser-breakpoints.mjs +51 -0
- package/fesm2022/signality-core-browser-breakpoints.mjs.map +1 -0
- package/fesm2022/signality-core-browser-broadcast-channel.mjs +74 -0
- package/fesm2022/signality-core-browser-broadcast-channel.mjs.map +1 -0
- package/fesm2022/signality-core-browser-browser-language.mjs +48 -0
- package/fesm2022/signality-core-browser-browser-language.mjs.map +1 -0
- package/fesm2022/signality-core-browser-clipboard.mjs +102 -0
- package/fesm2022/signality-core-browser-clipboard.mjs.map +1 -0
- package/fesm2022/signality-core-browser-device-posture.mjs +40 -0
- package/fesm2022/signality-core-browser-device-posture.mjs.map +1 -0
- package/fesm2022/signality-core-browser-display-media.mjs +121 -0
- package/fesm2022/signality-core-browser-display-media.mjs.map +1 -0
- package/fesm2022/signality-core-browser-eye-dropper.mjs +82 -0
- package/fesm2022/signality-core-browser-eye-dropper.mjs.map +1 -0
- package/fesm2022/signality-core-browser-favicon.mjs +100 -0
- package/fesm2022/signality-core-browser-favicon.mjs.map +1 -0
- package/fesm2022/signality-core-browser-fps.mjs +103 -0
- package/fesm2022/signality-core-browser-fps.mjs.map +1 -0
- package/fesm2022/signality-core-browser-gamepad.mjs +93 -0
- package/fesm2022/signality-core-browser-gamepad.mjs.map +1 -0
- package/fesm2022/signality-core-browser-geolocation.mjs +120 -0
- package/fesm2022/signality-core-browser-geolocation.mjs.map +1 -0
- package/fesm2022/signality-core-browser-input-modality.mjs +64 -0
- package/fesm2022/signality-core-browser-input-modality.mjs.map +1 -0
- package/fesm2022/signality-core-browser-listener.mjs +132 -0
- package/fesm2022/signality-core-browser-listener.mjs.map +1 -0
- package/fesm2022/signality-core-browser-media-query.mjs +55 -0
- package/fesm2022/signality-core-browser-media-query.mjs.map +1 -0
- package/fesm2022/signality-core-browser-network.mjs +76 -0
- package/fesm2022/signality-core-browser-network.mjs.map +1 -0
- package/fesm2022/signality-core-browser-online.mjs +49 -0
- package/fesm2022/signality-core-browser-online.mjs.map +1 -0
- package/fesm2022/signality-core-browser-page-visibility.mjs +47 -0
- package/fesm2022/signality-core-browser-page-visibility.mjs.map +1 -0
- package/fesm2022/signality-core-browser-picture-in-picture.mjs +93 -0
- package/fesm2022/signality-core-browser-picture-in-picture.mjs.map +1 -0
- package/fesm2022/signality-core-browser-pointer-lock-element.mjs +43 -0
- package/fesm2022/signality-core-browser-pointer-lock-element.mjs.map +1 -0
- package/fesm2022/signality-core-browser-screen-orientation.mjs +43 -0
- package/fesm2022/signality-core-browser-screen-orientation.mjs.map +1 -0
- package/fesm2022/signality-core-browser-speech-recognition.mjs +171 -0
- package/fesm2022/signality-core-browser-speech-recognition.mjs.map +1 -0
- package/fesm2022/signality-core-browser-speech-synthesis.mjs +146 -0
- package/fesm2022/signality-core-browser-speech-synthesis.mjs.map +1 -0
- package/fesm2022/signality-core-browser-storage.mjs +261 -0
- package/fesm2022/signality-core-browser-storage.mjs.map +1 -0
- package/fesm2022/signality-core-browser-text-direction.mjs +62 -0
- package/fesm2022/signality-core-browser-text-direction.mjs.map +1 -0
- package/fesm2022/signality-core-browser-vibration.mjs +94 -0
- package/fesm2022/signality-core-browser-vibration.mjs.map +1 -0
- package/fesm2022/signality-core-browser-wake-lock.mjs +149 -0
- package/fesm2022/signality-core-browser-wake-lock.mjs.map +1 -0
- package/fesm2022/signality-core-browser-web-notification.mjs +137 -0
- package/fesm2022/signality-core-browser-web-notification.mjs.map +1 -0
- package/fesm2022/signality-core-browser-web-share.mjs +92 -0
- package/fesm2022/signality-core-browser-web-share.mjs.map +1 -0
- package/fesm2022/signality-core-browser-web-worker.mjs +105 -0
- package/fesm2022/signality-core-browser-web-worker.mjs.map +1 -0
- package/fesm2022/signality-core-browser.mjs +34 -0
- package/fesm2022/signality-core-browser.mjs.map +1 -0
- package/fesm2022/signality-core-elements-active-element.mjs +88 -0
- package/fesm2022/signality-core-elements-active-element.mjs.map +1 -0
- package/fesm2022/signality-core-elements-dropzone.mjs +158 -0
- package/fesm2022/signality-core-elements-dropzone.mjs.map +1 -0
- package/fesm2022/signality-core-elements-element-focus-within.mjs +56 -0
- package/fesm2022/signality-core-elements-element-focus-within.mjs.map +1 -0
- package/fesm2022/signality-core-elements-element-focus.mjs +54 -0
- package/fesm2022/signality-core-elements-element-focus.mjs.map +1 -0
- package/fesm2022/signality-core-elements-element-hover.mjs +48 -0
- package/fesm2022/signality-core-elements-element-hover.mjs.map +1 -0
- package/fesm2022/signality-core-elements-element-size.mjs +73 -0
- package/fesm2022/signality-core-elements-element-size.mjs.map +1 -0
- package/fesm2022/signality-core-elements-element-visibility.mjs +76 -0
- package/fesm2022/signality-core-elements-element-visibility.mjs.map +1 -0
- package/fesm2022/signality-core-elements-mouse-position.mjs +109 -0
- package/fesm2022/signality-core-elements-mouse-position.mjs.map +1 -0
- package/fesm2022/signality-core-elements-on-click-outside.mjs +97 -0
- package/fesm2022/signality-core-elements-on-click-outside.mjs.map +1 -0
- package/fesm2022/signality-core-elements-on-disconnect.mjs +99 -0
- package/fesm2022/signality-core-elements-on-disconnect.mjs.map +1 -0
- package/fesm2022/signality-core-elements-on-long-press.mjs +84 -0
- package/fesm2022/signality-core-elements-on-long-press.mjs.map +1 -0
- package/fesm2022/signality-core-elements-pointer-swipe.mjs +116 -0
- package/fesm2022/signality-core-elements-pointer-swipe.mjs.map +1 -0
- package/fesm2022/signality-core-elements-scroll-position.mjs +175 -0
- package/fesm2022/signality-core-elements-scroll-position.mjs.map +1 -0
- package/fesm2022/signality-core-elements-swipe.mjs +107 -0
- package/fesm2022/signality-core-elements-swipe.mjs.map +1 -0
- package/fesm2022/signality-core-elements-text-selection.mjs +70 -0
- package/fesm2022/signality-core-elements-text-selection.mjs.map +1 -0
- package/fesm2022/signality-core-elements-window-size.mjs +81 -0
- package/fesm2022/signality-core-elements-window-size.mjs.map +1 -0
- package/fesm2022/signality-core-elements.mjs +21 -0
- package/fesm2022/signality-core-elements.mjs.map +1 -0
- package/fesm2022/signality-core-forms-cva.mjs +140 -0
- package/fesm2022/signality-core-forms-cva.mjs.map +1 -0
- package/fesm2022/signality-core-forms.mjs +6 -0
- package/fesm2022/signality-core-forms.mjs.map +1 -0
- package/fesm2022/signality-core-internal.mjs +268 -0
- package/fesm2022/signality-core-internal.mjs.map +1 -0
- package/fesm2022/signality-core-observers-intersection-observer.mjs +70 -0
- package/fesm2022/signality-core-observers-intersection-observer.mjs.map +1 -0
- package/fesm2022/signality-core-observers-mutation-observer.mjs +77 -0
- package/fesm2022/signality-core-observers-mutation-observer.mjs.map +1 -0
- package/fesm2022/signality-core-observers-performance-observer.mjs +84 -0
- package/fesm2022/signality-core-observers-performance-observer.mjs.map +1 -0
- package/fesm2022/signality-core-observers-resize-observer.mjs +69 -0
- package/fesm2022/signality-core-observers-resize-observer.mjs.map +1 -0
- package/fesm2022/signality-core-observers.mjs +9 -0
- package/fesm2022/signality-core-observers.mjs.map +1 -0
- package/fesm2022/signality-core-reactivity-debounced.mjs +27 -0
- package/fesm2022/signality-core-reactivity-debounced.mjs.map +1 -0
- package/fesm2022/signality-core-reactivity-throttled.mjs +27 -0
- package/fesm2022/signality-core-reactivity-throttled.mjs.map +1 -0
- package/fesm2022/signality-core-reactivity-watcher.mjs +36 -0
- package/fesm2022/signality-core-reactivity-watcher.mjs.map +1 -0
- package/fesm2022/signality-core-reactivity.mjs +8 -0
- package/fesm2022/signality-core-reactivity.mjs.map +1 -0
- package/fesm2022/signality-core-router-fragment.mjs +41 -0
- package/fesm2022/signality-core-router-fragment.mjs.map +1 -0
- package/fesm2022/signality-core-router-params.mjs +45 -0
- package/fesm2022/signality-core-router-params.mjs.map +1 -0
- package/fesm2022/signality-core-router-query-params.mjs +67 -0
- package/fesm2022/signality-core-router-query-params.mjs.map +1 -0
- package/fesm2022/signality-core-router-route-data.mjs +46 -0
- package/fesm2022/signality-core-router-route-data.mjs.map +1 -0
- package/fesm2022/signality-core-router-router-listener.mjs +50 -0
- package/fesm2022/signality-core-router-router-listener.mjs.map +1 -0
- package/fesm2022/signality-core-router-title.mjs +54 -0
- package/fesm2022/signality-core-router-title.mjs.map +1 -0
- package/fesm2022/signality-core-router-url.mjs +53 -0
- package/fesm2022/signality-core-router-url.mjs.map +1 -0
- package/fesm2022/signality-core-router.mjs +12 -0
- package/fesm2022/signality-core-router.mjs.map +1 -0
- package/fesm2022/signality-core-scheduling-debounce-callback.mjs +59 -0
- package/fesm2022/signality-core-scheduling-debounce-callback.mjs.map +1 -0
- package/fesm2022/signality-core-scheduling-interval.mjs +110 -0
- package/fesm2022/signality-core-scheduling-interval.mjs.map +1 -0
- package/fesm2022/signality-core-scheduling-throttle-callback.mjs +66 -0
- package/fesm2022/signality-core-scheduling-throttle-callback.mjs.map +1 -0
- package/fesm2022/signality-core-scheduling.mjs +8 -0
- package/fesm2022/signality-core-scheduling.mjs.map +1 -0
- package/fesm2022/signality-core-types.mjs +4 -0
- package/fesm2022/signality-core-types.mjs.map +1 -0
- package/fesm2022/signality-core.mjs +13 -0
- package/fesm2022/signality-core.mjs.map +1 -0
- package/forms/cva/index.d.ts +60 -0
- package/forms/index.d.ts +1 -0
- package/index.d.ts +8 -0
- package/internal/constants/index.d.ts +2 -0
- package/internal/constants/mobile-regex.d.ts +1 -0
- package/internal/constants/stubs.d.ts +32 -0
- package/internal/index.d.ts +4 -0
- package/internal/providers/index.d.ts +3 -0
- package/internal/providers/is-browser.d.ts +2 -0
- package/internal/providers/is-mobile.d.ts +2 -0
- package/internal/providers/is-server.d.ts +2 -0
- package/internal/types/index.d.ts +2 -0
- package/internal/types/timer.d.ts +1 -0
- package/internal/types/union.d.ts +1 -0
- package/internal/utils/bom/index.d.ts +1 -0
- package/internal/utils/bom/is-window.d.ts +1 -0
- package/internal/utils/const-signal.d.ts +10 -0
- package/internal/utils/context.d.ts +18 -0
- package/internal/utils/create-token.d.ts +8 -0
- package/internal/utils/dom/get-active-element.d.ts +1 -0
- package/internal/utils/dom/get-event-target.d.ts +1 -0
- package/internal/utils/dom/get-pip-element.d.ts +1 -0
- package/internal/utils/dom/get-shadow-root.d.ts +1 -0
- package/internal/utils/dom/index.d.ts +6 -0
- package/internal/utils/dom/is-element.d.ts +1 -0
- package/internal/utils/dom/is-node-within.d.ts +1 -0
- package/internal/utils/index.d.ts +10 -0
- package/internal/utils/is-plain-object.d.ts +1 -0
- package/internal/utils/is-query-signal.d.ts +10 -0
- package/internal/utils/proxy-signal.d.ts +18 -0
- package/internal/utils/to-element.d.ts +12 -0
- package/internal/utils/to-value.d.ts +6 -0
- package/observers/index.d.ts +4 -0
- package/observers/intersection-observer/index.d.ts +42 -0
- package/observers/mutation-observer/index.d.ts +45 -0
- package/observers/performance-observer/index.d.ts +58 -0
- package/observers/resize-observer/index.d.ts +40 -0
- package/package.json +343 -0
- package/reactivity/debounced/index.d.ts +50 -0
- package/reactivity/index.d.ts +3 -0
- package/reactivity/throttled/index.d.ts +53 -0
- package/reactivity/watcher/index.d.ts +68 -0
- package/router/fragment/index.d.ts +26 -0
- package/router/index.d.ts +7 -0
- package/router/params/index.d.ts +28 -0
- package/router/query-params/index.d.ts +80 -0
- package/router/route-data/index.d.ts +28 -0
- package/router/router-listener/index.d.ts +83 -0
- package/router/title/index.d.ts +29 -0
- package/router/url/index.d.ts +32 -0
- package/scheduling/debounce-callback/index.d.ts +28 -0
- package/scheduling/index.d.ts +3 -0
- package/scheduling/interval/index.d.ts +51 -0
- package/scheduling/throttle-callback/index.d.ts +30 -0
- package/types/index.d.ts +6 -0
- package/types/maybe-element-signal.d.ts +2 -0
- package/types/maybe-signal.d.ts +2 -0
- package/types/signal-value.d.ts +2 -0
- package/types/signal-values.d.ts +5 -0
- package/types/unref-element.d.ts +2 -0
- package/types/with-injector.d.ts +8 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface VibrationOptions extends WithInjector {
|
|
4
|
+
readonly pattern?: MaybeSignal<number | number[]>;
|
|
5
|
+
}
|
|
6
|
+
export interface VibrationRef {
|
|
7
|
+
/** Whether Vibration API is supported */
|
|
8
|
+
readonly isSupported: Signal<boolean>;
|
|
9
|
+
/** Whether currently vibrating */
|
|
10
|
+
readonly isVibrating: Signal<boolean>;
|
|
11
|
+
/** Start vibration */
|
|
12
|
+
readonly vibrate: (pattern?: number | number[]) => void;
|
|
13
|
+
/** Stop vibration */
|
|
14
|
+
readonly stop: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Signal-based wrapper around the Vibration API.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Optional configuration including default pattern and injector
|
|
20
|
+
* @returns A VibrationRef with vibration control methods
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const vib = vibration();
|
|
25
|
+
*
|
|
26
|
+
* vib.vibrate(100); // Vibrate for 100ms
|
|
27
|
+
* vib.vibrate([100, 50, 100]); // Pattern: vibrate, pause, vibrate
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const vib = vibration({ pattern: 200 });
|
|
33
|
+
*
|
|
34
|
+
* vib.vibrate(); // Uses default 200ms pattern
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function vibration(options?: VibrationOptions): VibrationRef;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface WakeLockOptions extends WithInjector {
|
|
4
|
+
/** Whether to automatically reacquire wake lock when document becomes visible */
|
|
5
|
+
readonly autoReacquire?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface WakeLockRef {
|
|
8
|
+
/** Whether Screen Wake Lock API is supported */
|
|
9
|
+
readonly isSupported: Signal<boolean>;
|
|
10
|
+
/** Whether wake lock is currently active */
|
|
11
|
+
readonly isActive: Signal<boolean>;
|
|
12
|
+
/** Current wake lock sentinel */
|
|
13
|
+
readonly sentinel: Signal<WakeLockSentinel | null>;
|
|
14
|
+
/** Request a wake lock */
|
|
15
|
+
readonly request: () => Promise<void>;
|
|
16
|
+
/** Force request a wake lock (releases existing one first) */
|
|
17
|
+
readonly forceRequest: () => Promise<void>;
|
|
18
|
+
/** Release the wake lock */
|
|
19
|
+
readonly release: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Signal-based wrapper around the [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API).
|
|
23
|
+
*
|
|
24
|
+
* @param options - Optional configuration
|
|
25
|
+
* @returns A WakeLockRef with isSupported, isActive, sentinel signals and control methods
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const wakeLock = wakeLock();
|
|
30
|
+
*
|
|
31
|
+
* if (wakeLock.isSupported()) {
|
|
32
|
+
* await wakeLock.request();
|
|
33
|
+
* // Screen will stay awake
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function wakeLock(options?: WakeLockOptions): WakeLockRef;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface WebNotificationOptions extends NotificationOptions, WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Auto-close notification after specified milliseconds.
|
|
6
|
+
*/
|
|
7
|
+
readonly autoClose?: MaybeSignal<number>;
|
|
8
|
+
}
|
|
9
|
+
export interface WebNotificationRef {
|
|
10
|
+
/** Whether Notifications API is supported */
|
|
11
|
+
readonly isSupported: Signal<boolean>;
|
|
12
|
+
/** Current permission state */
|
|
13
|
+
readonly permission: Signal<NotificationPermission>;
|
|
14
|
+
/** Current active notification instance */
|
|
15
|
+
readonly notification: Signal<Notification | null>;
|
|
16
|
+
/** Request notification permission */
|
|
17
|
+
readonly requestPermission: () => Promise<NotificationPermission>;
|
|
18
|
+
/** Show a notification (auto-closes previous). Per-call options override defaults from constructor. */
|
|
19
|
+
readonly show: (title: string, options?: NotificationOptions) => Notification | undefined;
|
|
20
|
+
/** Close the current notification */
|
|
21
|
+
readonly close: () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Signal-based wrapper around the Notifications API.
|
|
25
|
+
*
|
|
26
|
+
* Tracks the current notification as a signal. Calling `show()` auto-closes
|
|
27
|
+
* the previous notification. Calling `close()` closes the current one.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Optional configuration and default notification options
|
|
30
|
+
* @returns A WebNotificationRef with notification state and control methods
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* @Component({
|
|
35
|
+
* template: `
|
|
36
|
+
* <button (click)="requestPermission()">Request Permission</button>
|
|
37
|
+
* <button (click)="showNotification()" [disabled]="notif.permission() !== 'granted'">
|
|
38
|
+
* Show Notification
|
|
39
|
+
* </button>
|
|
40
|
+
* @if (notif.notification()) {
|
|
41
|
+
* <button (click)="notif.close()">Close</button>
|
|
42
|
+
* }
|
|
43
|
+
* `
|
|
44
|
+
* })
|
|
45
|
+
* class NotificationComponent {
|
|
46
|
+
* readonly notif = webNotification({ icon: '/icon.png' });
|
|
47
|
+
*
|
|
48
|
+
* async requestPermission() {
|
|
49
|
+
* await this.notif.requestPermission();
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* showNotification() {
|
|
53
|
+
* this.notif.show('Hello!', { body: 'This is a notification' });
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function webNotification(options?: WebNotificationOptions): WebNotificationRef;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface WebShareRef {
|
|
4
|
+
/** Whether Web Share API is supported */
|
|
5
|
+
readonly isSupported: Signal<boolean>;
|
|
6
|
+
/** Whether the share dialog is currently open */
|
|
7
|
+
readonly isSharing: Signal<boolean>;
|
|
8
|
+
/** Open the native share dialog */
|
|
9
|
+
readonly share: (data: ShareData) => Promise<void>;
|
|
10
|
+
/** Check if data can be shared */
|
|
11
|
+
readonly canShare: (data?: ShareData) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Signal-based wrapper around the [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API).
|
|
15
|
+
*
|
|
16
|
+
* @param options - Optional injector for DI context
|
|
17
|
+
* @returns A WebShareRef with share methods and state signals
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* @Component({
|
|
22
|
+
* template: `
|
|
23
|
+
* @if (webShare.isSupported()) {
|
|
24
|
+
* <button (click)="shareContent()" [disabled]="webShare.isSharing()">
|
|
25
|
+
* Share This Page
|
|
26
|
+
* </button>
|
|
27
|
+
* }
|
|
28
|
+
* `
|
|
29
|
+
* })
|
|
30
|
+
* class WebShareComponent {
|
|
31
|
+
* readonly webShare = webShare();
|
|
32
|
+
*
|
|
33
|
+
* async shareContent() {
|
|
34
|
+
* await this.webShare.share({
|
|
35
|
+
* title: 'Check this out!',
|
|
36
|
+
* url: window.location.href,
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function webShare(options?: WithInjector): WebShareRef;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface WebWorkerOptions extends WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Worker type.
|
|
6
|
+
* @default 'classic'
|
|
7
|
+
*/
|
|
8
|
+
readonly type?: 'classic' | 'module';
|
|
9
|
+
/**
|
|
10
|
+
* Credentials mode.
|
|
11
|
+
*/
|
|
12
|
+
readonly credentials?: RequestCredentials;
|
|
13
|
+
/**
|
|
14
|
+
* Worker name for debugging.
|
|
15
|
+
*/
|
|
16
|
+
readonly name?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WebWorkerRef<I, O> {
|
|
19
|
+
/** Last message received from worker */
|
|
20
|
+
readonly data: Signal<O | undefined>;
|
|
21
|
+
/** Whether worker is ready */
|
|
22
|
+
readonly isReady: Signal<boolean>;
|
|
23
|
+
/** Last error from worker */
|
|
24
|
+
readonly error: Signal<Error | null>;
|
|
25
|
+
/** Send message to worker */
|
|
26
|
+
readonly post: (data: I) => void;
|
|
27
|
+
/** Terminate the worker */
|
|
28
|
+
readonly terminate: () => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Signal-based wrapper around the Web Workers API.
|
|
32
|
+
*
|
|
33
|
+
* @param url - Worker script URL
|
|
34
|
+
* @param options - Optional configuration
|
|
35
|
+
* @returns A WebWorkerRef with data signal and control methods
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* @Component({
|
|
40
|
+
* template: `
|
|
41
|
+
* <button (click)="worker.post(42)">Calculate</button>
|
|
42
|
+
* @if (worker.data()) {
|
|
43
|
+
* <p>Result: {{ worker.data() }}</p>
|
|
44
|
+
* }
|
|
45
|
+
* `
|
|
46
|
+
* })
|
|
47
|
+
* class WorkerComponent {
|
|
48
|
+
* readonly worker = webWorker<number, number>('/workers/calc.js');
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function webWorker<I, O>(url: MaybeSignal<string | URL>, options?: WebWorkerOptions): WebWorkerRef<I, O>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { WithInjector } from '@signality/core/types';
|
|
3
|
+
export type ActiveElementOptions = CreateSignalOptions<Element | null> & WithInjector;
|
|
4
|
+
/**
|
|
5
|
+
* Signal-based wrapper around the [document.activeElement](https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement) property.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Optional configuration including signal options and injector
|
|
8
|
+
* @returns A signal containing the currently active element, or null
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @Component({
|
|
13
|
+
* template: `
|
|
14
|
+
* @if (activeEl(); as el) {
|
|
15
|
+
* <p>Active element: {{ el.tagName }}</p>
|
|
16
|
+
* } @else {
|
|
17
|
+
* <p>No element is active</p>
|
|
18
|
+
* }
|
|
19
|
+
* `
|
|
20
|
+
* })
|
|
21
|
+
* class ActiveElementComponent {
|
|
22
|
+
* readonly activeEl = activeElement();
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function activeElement(options?: ActiveElementOptions): Signal<Element | null>;
|
|
27
|
+
export declare const ACTIVE_ELEMENT: import("@angular/core").ProviderToken<Signal<Element | null>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Signal, type WritableSignal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface DropzoneOptions extends WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Accepted MIME types.
|
|
6
|
+
* @default ['*']
|
|
7
|
+
*/
|
|
8
|
+
readonly accept?: MaybeSignal<string[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Allow multiple files.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
readonly multiple?: MaybeSignal<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Prevent drops outside the zone.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
readonly preventDocumentDrop?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DropzoneRef {
|
|
21
|
+
/** Dropped files */
|
|
22
|
+
readonly files: WritableSignal<File[]>;
|
|
23
|
+
/** Whether dragging over the zone */
|
|
24
|
+
readonly isOver: Signal<boolean>;
|
|
25
|
+
/** Whether any drag is in progress (document-wide) */
|
|
26
|
+
readonly isDragging: Signal<boolean>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Signal-based wrapper around the [HTML Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API).
|
|
30
|
+
*
|
|
31
|
+
* @param target - Drop zone element
|
|
32
|
+
* @param options - Optional configuration
|
|
33
|
+
* @returns An object with isOver, files, data, and isDragging signals
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* @Component({
|
|
38
|
+
* template: `
|
|
39
|
+
* <div
|
|
40
|
+
* #zone
|
|
41
|
+
* [class.over]="drop.isOver()"
|
|
42
|
+
* [class.dragging]="drop.isDragging()"
|
|
43
|
+
* >
|
|
44
|
+
* Drop files here
|
|
45
|
+
* @if (drop.files().length > 0) {
|
|
46
|
+
* <ul>
|
|
47
|
+
* @for (file of drop.files(); track file.name) {
|
|
48
|
+
* <li>{{ file.name }} ({{ file.size }} bytes)</li>
|
|
49
|
+
* }
|
|
50
|
+
* </ul>
|
|
51
|
+
* }
|
|
52
|
+
* </div>
|
|
53
|
+
* `
|
|
54
|
+
* })
|
|
55
|
+
* class DropzoneComponent {
|
|
56
|
+
* readonly zone = viewChild<ElementRef>('zone');
|
|
57
|
+
* readonly drop = dropzone(this.zone, { accept: ['image/*'], multiple: true });
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function dropzone(target: MaybeElementSignal<HTMLElement>, options?: DropzoneOptions): DropzoneRef;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface ElementFocusOptions extends CreateSignalOptions<boolean>, WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Track focus using the `:focus-visible` pseudo-class.
|
|
6
|
+
* The browser uses heuristics to determine when focus should be visually indicated
|
|
7
|
+
* (e.g., keyboard navigation, programmatic focus, or when the element requires user attention).
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:focus-visible MDN: :focus-visible}
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
readonly focusVisible?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Reactive tracking of focus state on an element.
|
|
16
|
+
* Detects when an element gains or loses focus.
|
|
17
|
+
*
|
|
18
|
+
* @param target - The element to track focus state on
|
|
19
|
+
* @param options - Optional configuration including focusVisible mode and injector
|
|
20
|
+
* @returns A signal that is `true` when the element has focus
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @Component({
|
|
25
|
+
* template: `
|
|
26
|
+
* <input #input [class.focused]="isFocused()" />
|
|
27
|
+
* @if (isFocused()) {
|
|
28
|
+
* <p>Input is focused</p>
|
|
29
|
+
* }
|
|
30
|
+
* `
|
|
31
|
+
* })
|
|
32
|
+
* class FocusComponent {
|
|
33
|
+
* readonly input = viewChild<ElementRef>('input');
|
|
34
|
+
* readonly isFocused = elementFocus(this.input);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function elementFocus(target: MaybeElementSignal<HTMLElement>, options?: ElementFocusOptions): Signal<boolean>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export type ElementFocusWithinOptions = CreateSignalOptions<boolean> & WithInjector;
|
|
4
|
+
/**
|
|
5
|
+
* Reactive tracking of focus-within state on an element.
|
|
6
|
+
* Detects when focus is inside an element or any of its descendants,
|
|
7
|
+
* analogous to the CSS `:focus-within` pseudo-class.
|
|
8
|
+
*
|
|
9
|
+
* @param target - The element to track focus-within state on
|
|
10
|
+
* @param options - Optional configuration including signal options and injector
|
|
11
|
+
* @returns A signal that is `true` when focus is within the element
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Component({
|
|
16
|
+
* template: `
|
|
17
|
+
* <div #container [class.focused]="isFocusedWithin()">
|
|
18
|
+
* <input placeholder="First" />
|
|
19
|
+
* <input placeholder="Second" />
|
|
20
|
+
* </div>
|
|
21
|
+
* `
|
|
22
|
+
* })
|
|
23
|
+
* class FocusWithinComponent {
|
|
24
|
+
* readonly container = viewChild<ElementRef>('container');
|
|
25
|
+
* readonly isFocusedWithin = elementFocusWithin(this.container);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function elementFocusWithin(target: MaybeElementSignal<HTMLElement>, options?: ElementFocusWithinOptions): Signal<boolean>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export type ElementHoverOptions = CreateSignalOptions<boolean> & WithInjector;
|
|
4
|
+
/**
|
|
5
|
+
* Reactive tracking of the hover state on an element.
|
|
6
|
+
* Detects when the mouse enters or leaves an element.
|
|
7
|
+
*
|
|
8
|
+
* @param target - The element to track hover state on
|
|
9
|
+
* @param options - Optional configuration including signal options and injector
|
|
10
|
+
* @returns A signal that is `true` when the element is being hovered
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @Component({
|
|
15
|
+
* template: `
|
|
16
|
+
* <div #box [class.hovered]="isHovered()">
|
|
17
|
+
* Hover over me!
|
|
18
|
+
* </div>
|
|
19
|
+
* `
|
|
20
|
+
* })
|
|
21
|
+
* class HoverComponent {
|
|
22
|
+
* readonly box = viewChild<ElementRef>('box');
|
|
23
|
+
* readonly isHovered = elementHover(this.box);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function elementHover(target: MaybeElementSignal<HTMLElement>, options?: ElementHoverOptions): Signal<boolean>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface ElementSizeValue {
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
readonly contentWidth: number;
|
|
7
|
+
readonly contentHeight: number;
|
|
8
|
+
readonly borderBoxWidth: number;
|
|
9
|
+
readonly borderBoxHeight: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ElementSizeOptions extends CreateSignalOptions<ElementSizeValue>, WithInjector {
|
|
12
|
+
/**
|
|
13
|
+
* Which box model to observe. Can be a reactive signal.
|
|
14
|
+
* @default 'border-box'
|
|
15
|
+
*/
|
|
16
|
+
readonly box?: MaybeSignal<ResizeObserverBoxOptions>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Signal-based wrapper around the [ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
|
|
20
|
+
*
|
|
21
|
+
* @param target - The element to observe
|
|
22
|
+
* @param options - Optional configuration including signal options (equal, debugName), box model, and injector
|
|
23
|
+
* @returns A signal containing the current element dimensions
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* @Component({
|
|
28
|
+
* template: `
|
|
29
|
+
* <div #box>
|
|
30
|
+
* Size: {{ size().width }} × {{ size().height }}px
|
|
31
|
+
* </div>
|
|
32
|
+
* `
|
|
33
|
+
* })
|
|
34
|
+
* class SizeComponent {
|
|
35
|
+
* readonly box = viewChild<ElementRef>('box');
|
|
36
|
+
* readonly size = elementSize(this.box);
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function elementSize(target: MaybeElementSignal<HTMLElement>, options?: ElementSizeOptions): Signal<ElementSizeValue>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CreateSignalOptions, type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface ElementVisibilityOptions extends CreateSignalOptions<ElementVisibilityValue>, WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Visibility threshold(s). A number between 0 and 1, or an array of thresholds.
|
|
6
|
+
* @default 0
|
|
7
|
+
*/
|
|
8
|
+
readonly threshold?: MaybeSignal<number | number[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Scrollable ancestor element (null = viewport).
|
|
11
|
+
* @default undefined
|
|
12
|
+
*/
|
|
13
|
+
readonly root?: MaybeElementSignal<Element> | Document;
|
|
14
|
+
/**
|
|
15
|
+
* Margin around the root element.
|
|
16
|
+
* @default '0px'
|
|
17
|
+
*/
|
|
18
|
+
readonly rootMargin?: MaybeSignal<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Initial value for SSR.
|
|
21
|
+
* @default { isVisible: true, ratio: 1 }
|
|
22
|
+
*/
|
|
23
|
+
readonly initialValue?: ElementVisibilityValue;
|
|
24
|
+
}
|
|
25
|
+
export interface ElementVisibilityValue {
|
|
26
|
+
/** Whether the element is visible in the viewport */
|
|
27
|
+
readonly isVisible: boolean;
|
|
28
|
+
/** Intersection ratio (0.0 to 1.0) */
|
|
29
|
+
readonly ratio: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Signal-based wrapper around the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
|
33
|
+
*
|
|
34
|
+
* @param target - The element to observe
|
|
35
|
+
* @param options - Optional configuration including signal options (equal, debugName), observer options (threshold, root, rootMargin, initialValue), and injector
|
|
36
|
+
* @returns A signal containing the current visibility state
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* @Component({
|
|
41
|
+
* template: `
|
|
42
|
+
* <div #section [class.visible]="visibility().isVisible">
|
|
43
|
+
* Visibility: {{ visibility().ratio * 100 }}%
|
|
44
|
+
* </div>
|
|
45
|
+
* `
|
|
46
|
+
* })
|
|
47
|
+
* class VisibilityComponent {
|
|
48
|
+
* readonly section = viewChild<ElementRef>('section');
|
|
49
|
+
* readonly visibility = elementVisibility(this.section);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function elementVisibility(target: MaybeElementSignal<HTMLElement>, options?: ElementVisibilityOptions): Signal<ElementVisibilityValue>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from '@signality/core/elements/active-element';
|
|
2
|
+
export * from '@signality/core/elements/dropzone';
|
|
3
|
+
export * from '@signality/core/elements/element-focus';
|
|
4
|
+
export * from '@signality/core/elements/element-focus-within';
|
|
5
|
+
export * from '@signality/core/elements/element-hover';
|
|
6
|
+
export * from '@signality/core/elements/element-size';
|
|
7
|
+
export * from '@signality/core/elements/element-visibility';
|
|
8
|
+
export * from '@signality/core/elements/on-click-outside';
|
|
9
|
+
export * from '@signality/core/elements/on-long-press';
|
|
10
|
+
export * from '@signality/core/elements/mouse-position';
|
|
11
|
+
export * from '@signality/core/elements/pointer-swipe';
|
|
12
|
+
export * from '@signality/core/elements/on-disconnect';
|
|
13
|
+
export * from '@signality/core/elements/scroll-position';
|
|
14
|
+
export * from '@signality/core/elements/swipe';
|
|
15
|
+
export * from '@signality/core/elements/text-selection';
|
|
16
|
+
export * from '@signality/core/elements/window-size';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import type { MaybeElementSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface MousePosition {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
}
|
|
7
|
+
export type MouseCoordinateType = 'page' | 'client' | 'screen';
|
|
8
|
+
export interface MousePositionOptions extends WithInjector {
|
|
9
|
+
/**
|
|
10
|
+
* Element or window to track mouse position on.
|
|
11
|
+
* @default window
|
|
12
|
+
*/
|
|
13
|
+
readonly target?: MaybeElementSignal<Element> | Window;
|
|
14
|
+
/**
|
|
15
|
+
* Coordinate type to use.
|
|
16
|
+
* @default 'page'
|
|
17
|
+
*/
|
|
18
|
+
readonly type?: MouseCoordinateType;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to track touch events as well.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
readonly touch?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Initial mouse position.
|
|
26
|
+
*/
|
|
27
|
+
readonly initialValue?: MousePosition;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reactive tracking of mouse position.
|
|
31
|
+
* Track cursor coordinates globally or relative to an element.
|
|
32
|
+
*
|
|
33
|
+
* @param options - Optional configuration
|
|
34
|
+
* @returns A signal containing the current mouse position
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* @Component({
|
|
39
|
+
* template: `
|
|
40
|
+
* <p>Mouse position: X={{ position().x }}, Y={{ position().y }}</p>
|
|
41
|
+
* `
|
|
42
|
+
* })
|
|
43
|
+
* class MouseTracker {
|
|
44
|
+
* readonly position = mousePosition();
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Track mouse position on a specific element
|
|
51
|
+
* @Component({
|
|
52
|
+
* template: `
|
|
53
|
+
* <div #box>
|
|
54
|
+
* <p>Position: X={{ position().x }}, Y={{ position().y }}</p>
|
|
55
|
+
* </div>
|
|
56
|
+
* `
|
|
57
|
+
* })
|
|
58
|
+
* class MouseElementTracker {
|
|
59
|
+
* readonly box = viewChild<ElementRef>('box');
|
|
60
|
+
* readonly position = mousePosition({ target: this.box });
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function mousePosition(options?: MousePositionOptions): Signal<MousePosition>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MaybeElementSignal, WithInjector } from '@signality/core/types';
|
|
2
|
+
export interface OnClickOutsideOptions extends WithInjector {
|
|
3
|
+
/**
|
|
4
|
+
* Elements that should not trigger the outside click handler.
|
|
5
|
+
*/
|
|
6
|
+
readonly ignore?: MaybeElementSignal<Element>[];
|
|
7
|
+
}
|
|
8
|
+
export interface OnClickOutsideRef {
|
|
9
|
+
/** Stops listening for outside clicks. */
|
|
10
|
+
readonly destroy: () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Detects clicks outside a target element and invokes a callback.
|
|
14
|
+
* Useful for closing dropdowns, modals, and popovers when the user clicks elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* @param target - Element to detect clicks outside of
|
|
17
|
+
* @param handler - Callback invoked when a click outside the target is detected
|
|
18
|
+
* @param options - Optional configuration including ignore list and injector
|
|
19
|
+
* @returns An OnClickOutsideRef with a destroy method to stop detection
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* @Component({
|
|
24
|
+
* template: `
|
|
25
|
+
* <div #dropdown class="dropdown">
|
|
26
|
+
* <p>Dropdown content</p>
|
|
27
|
+
* </div>
|
|
28
|
+
* `
|
|
29
|
+
* })
|
|
30
|
+
* class DropdownComponent {
|
|
31
|
+
* readonly dropdown = viewChild<ElementRef>('dropdown');
|
|
32
|
+
* readonly isOpen = signal(true);
|
|
33
|
+
*
|
|
34
|
+
* constructor() {
|
|
35
|
+
* onClickOutside(this.dropdown, () => {
|
|
36
|
+
* this.isOpen.set(false);
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function onClickOutside(target: MaybeElementSignal<HTMLElement>, handler: (event: PointerEvent | FocusEvent) => void, options?: OnClickOutsideOptions): OnClickOutsideRef;
|