@signality/core 0.0.1-alpha.2 → 0.0.1-alpha.4
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 +51 -47
- package/browser/battery/index.d.ts +27 -2
- package/browser/bluetooth/index.d.ts +40 -13
- package/browser/breakpoints/index.d.ts +22 -9
- package/browser/broadcast-channel/index.d.ts +1 -1
- package/browser/browser-language/index.d.ts +1 -1
- package/browser/clipboard/index.d.ts +22 -6
- package/browser/device-posture/index.d.ts +23 -2
- package/browser/display-media/index.d.ts +34 -22
- package/browser/eye-dropper/index.d.ts +22 -6
- package/browser/favicon/index.d.ts +29 -2
- package/browser/file-dialog/index.d.ts +97 -0
- package/browser/fps/index.d.ts +1 -1
- package/browser/fullscreen/index.d.ts +78 -0
- package/browser/gamepad/index.d.ts +39 -9
- package/browser/geolocation/index.d.ts +44 -13
- package/browser/index.d.ts +8 -2
- package/browser/input-modality/index.d.ts +1 -1
- package/browser/listener/index.d.ts +1 -1
- package/browser/media-query/index.d.ts +1 -1
- package/browser/network/index.d.ts +37 -9
- package/browser/online/index.d.ts +1 -1
- package/browser/page-visibility/index.d.ts +1 -1
- package/browser/permission-state/index.d.ts +23 -0
- package/browser/picture-in-picture/index.d.ts +24 -6
- package/browser/screen-orientation/index.d.ts +1 -1
- package/browser/speech-recognition/index.d.ts +51 -13
- package/browser/speech-synthesis/index.d.ts +82 -42
- package/browser/storage/index.d.ts +1 -1
- package/browser/text-direction/index.d.ts +2 -5
- package/{elements → browser}/text-selection/index.d.ts +1 -1
- package/browser/vibration/index.d.ts +38 -9
- package/browser/web-notification/index.d.ts +35 -9
- package/browser/web-share/index.d.ts +19 -5
- package/browser/web-worker/index.d.ts +35 -11
- package/browser/window-focus/index.d.ts +27 -0
- package/{elements → browser}/window-size/index.d.ts +6 -7
- package/elements/active-element/index.d.ts +1 -1
- package/elements/dropzone/index.d.ts +60 -10
- package/elements/element-focus/index.d.ts +1 -1
- package/elements/element-focus-within/index.d.ts +1 -1
- package/elements/element-hover/index.d.ts +1 -1
- package/elements/element-size/index.d.ts +8 -5
- package/elements/element-visibility/index.d.ts +25 -7
- package/elements/index.d.ts +0 -2
- package/elements/mouse-position/index.d.ts +27 -7
- package/elements/on-click-outside/index.d.ts +1 -1
- package/elements/on-disconnect/index.d.ts +1 -1
- package/elements/on-long-press/index.d.ts +1 -1
- package/elements/pointer-swipe/index.d.ts +1 -1
- package/elements/scroll-position/index.d.ts +2 -2
- package/elements/swipe/index.d.ts +1 -1
- package/fesm2022/signality-core-browser-battery.mjs +1 -1
- package/fesm2022/signality-core-browser-battery.mjs.map +1 -1
- package/fesm2022/signality-core-browser-bluetooth.mjs +28 -27
- package/fesm2022/signality-core-browser-bluetooth.mjs.map +1 -1
- package/fesm2022/signality-core-browser-breakpoints.mjs +19 -10
- package/fesm2022/signality-core-browser-breakpoints.mjs.map +1 -1
- package/fesm2022/signality-core-browser-broadcast-channel.mjs +1 -1
- package/fesm2022/signality-core-browser-broadcast-channel.mjs.map +1 -1
- package/fesm2022/signality-core-browser-browser-language.mjs +1 -1
- package/fesm2022/signality-core-browser-browser-language.mjs.map +1 -1
- package/fesm2022/signality-core-browser-clipboard.mjs +1 -1
- package/fesm2022/signality-core-browser-clipboard.mjs.map +1 -1
- package/fesm2022/signality-core-browser-device-posture.mjs +13 -0
- package/fesm2022/signality-core-browser-device-posture.mjs.map +1 -1
- package/fesm2022/signality-core-browser-display-media.mjs +4 -17
- package/fesm2022/signality-core-browser-display-media.mjs.map +1 -1
- package/fesm2022/signality-core-browser-eye-dropper.mjs +1 -1
- package/fesm2022/signality-core-browser-eye-dropper.mjs.map +1 -1
- package/fesm2022/signality-core-browser-favicon.mjs +2 -2
- package/fesm2022/signality-core-browser-favicon.mjs.map +1 -1
- package/fesm2022/signality-core-browser-file-dialog.mjs +109 -0
- package/fesm2022/signality-core-browser-file-dialog.mjs.map +1 -0
- package/fesm2022/signality-core-browser-fps.mjs +1 -1
- package/fesm2022/signality-core-browser-fps.mjs.map +1 -1
- package/fesm2022/signality-core-browser-fullscreen.mjs +113 -0
- package/fesm2022/signality-core-browser-fullscreen.mjs.map +1 -0
- package/fesm2022/signality-core-browser-gamepad.mjs +14 -4
- package/fesm2022/signality-core-browser-gamepad.mjs.map +1 -1
- package/fesm2022/signality-core-browser-geolocation.mjs +8 -19
- package/fesm2022/signality-core-browser-geolocation.mjs.map +1 -1
- package/fesm2022/signality-core-browser-input-modality.mjs +1 -1
- package/fesm2022/signality-core-browser-input-modality.mjs.map +1 -1
- package/fesm2022/signality-core-browser-listener.mjs +18 -6
- package/fesm2022/signality-core-browser-listener.mjs.map +1 -1
- package/fesm2022/signality-core-browser-media-query.mjs +1 -1
- package/fesm2022/signality-core-browser-media-query.mjs.map +1 -1
- package/fesm2022/signality-core-browser-network.mjs +2 -2
- package/fesm2022/signality-core-browser-network.mjs.map +1 -1
- package/fesm2022/signality-core-browser-online.mjs +1 -1
- package/fesm2022/signality-core-browser-online.mjs.map +1 -1
- package/fesm2022/signality-core-browser-page-visibility.mjs +1 -1
- package/fesm2022/signality-core-browser-page-visibility.mjs.map +1 -1
- package/fesm2022/signality-core-browser-permission-state.mjs +57 -0
- package/fesm2022/signality-core-browser-permission-state.mjs.map +1 -0
- package/fesm2022/signality-core-browser-picture-in-picture.mjs +30 -13
- package/fesm2022/signality-core-browser-picture-in-picture.mjs.map +1 -1
- package/fesm2022/signality-core-browser-screen-orientation.mjs +1 -1
- package/fesm2022/signality-core-browser-screen-orientation.mjs.map +1 -1
- package/fesm2022/signality-core-browser-speech-recognition.mjs +6 -18
- package/fesm2022/signality-core-browser-speech-recognition.mjs.map +1 -1
- package/fesm2022/signality-core-browser-speech-synthesis.mjs +14 -16
- package/fesm2022/signality-core-browser-speech-synthesis.mjs.map +1 -1
- package/fesm2022/signality-core-browser-storage.mjs +1 -1
- package/fesm2022/signality-core-browser-storage.mjs.map +1 -1
- package/fesm2022/signality-core-browser-text-direction.mjs +1 -4
- package/fesm2022/signality-core-browser-text-direction.mjs.map +1 -1
- package/fesm2022/{signality-core-elements-text-selection.mjs → signality-core-browser-text-selection.mjs} +2 -2
- package/fesm2022/signality-core-browser-text-selection.mjs.map +1 -0
- package/fesm2022/signality-core-browser-vibration.mjs +14 -5
- package/fesm2022/signality-core-browser-vibration.mjs.map +1 -1
- package/fesm2022/signality-core-browser-web-notification.mjs +5 -7
- package/fesm2022/signality-core-browser-web-notification.mjs.map +1 -1
- package/fesm2022/signality-core-browser-web-share.mjs +3 -5
- package/fesm2022/signality-core-browser-web-share.mjs.map +1 -1
- package/fesm2022/signality-core-browser-web-worker.mjs +6 -3
- package/fesm2022/signality-core-browser-web-worker.mjs.map +1 -1
- package/fesm2022/signality-core-browser-window-focus.mjs +48 -0
- package/fesm2022/signality-core-browser-window-focus.mjs.map +1 -0
- package/fesm2022/{signality-core-elements-window-size.mjs → signality-core-browser-window-size.mjs} +4 -24
- package/fesm2022/signality-core-browser-window-size.mjs.map +1 -0
- package/fesm2022/signality-core-browser.mjs +8 -2
- package/fesm2022/signality-core-browser.mjs.map +1 -1
- package/fesm2022/signality-core-elements-active-element.mjs +1 -1
- package/fesm2022/signality-core-elements-active-element.mjs.map +1 -1
- package/fesm2022/signality-core-elements-dropzone.mjs +28 -29
- package/fesm2022/signality-core-elements-dropzone.mjs.map +1 -1
- package/fesm2022/signality-core-elements-element-focus-within.mjs +1 -1
- package/fesm2022/signality-core-elements-element-focus-within.mjs.map +1 -1
- package/fesm2022/signality-core-elements-element-focus.mjs +1 -1
- package/fesm2022/signality-core-elements-element-focus.mjs.map +1 -1
- package/fesm2022/signality-core-elements-element-hover.mjs +1 -1
- package/fesm2022/signality-core-elements-element-hover.mjs.map +1 -1
- package/fesm2022/signality-core-elements-element-size.mjs +19 -24
- package/fesm2022/signality-core-elements-element-size.mjs.map +1 -1
- package/fesm2022/signality-core-elements-element-visibility.mjs +2 -2
- package/fesm2022/signality-core-elements-element-visibility.mjs.map +1 -1
- package/fesm2022/signality-core-elements-mouse-position.mjs +3 -3
- package/fesm2022/signality-core-elements-mouse-position.mjs.map +1 -1
- package/fesm2022/signality-core-elements-on-click-outside.mjs +1 -1
- package/fesm2022/signality-core-elements-on-click-outside.mjs.map +1 -1
- package/fesm2022/signality-core-elements-on-disconnect.mjs +1 -1
- package/fesm2022/signality-core-elements-on-disconnect.mjs.map +1 -1
- package/fesm2022/signality-core-elements-on-long-press.mjs +1 -1
- package/fesm2022/signality-core-elements-on-long-press.mjs.map +1 -1
- package/fesm2022/signality-core-elements-pointer-swipe.mjs +1 -1
- package/fesm2022/signality-core-elements-pointer-swipe.mjs.map +1 -1
- package/fesm2022/signality-core-elements-scroll-position.mjs +2 -2
- package/fesm2022/signality-core-elements-scroll-position.mjs.map +1 -1
- package/fesm2022/signality-core-elements-swipe.mjs +1 -1
- package/fesm2022/signality-core-elements-swipe.mjs.map +1 -1
- package/fesm2022/signality-core-elements.mjs +0 -2
- package/fesm2022/signality-core-elements.mjs.map +1 -1
- package/fesm2022/signality-core-internal.mjs +54 -7
- package/fesm2022/signality-core-internal.mjs.map +1 -1
- package/fesm2022/signality-core-observers-intersection-observer.mjs +3 -2
- package/fesm2022/signality-core-observers-intersection-observer.mjs.map +1 -1
- package/fesm2022/signality-core-observers-mutation-observer.mjs +3 -2
- package/fesm2022/signality-core-observers-mutation-observer.mjs.map +1 -1
- package/fesm2022/signality-core-observers-resize-observer.mjs +3 -2
- package/fesm2022/signality-core-observers-resize-observer.mjs.map +1 -1
- package/fesm2022/signality-core-observers.mjs +0 -1
- package/fesm2022/signality-core-observers.mjs.map +1 -1
- package/fesm2022/signality-core-reactivity-debounced.mjs.map +1 -1
- package/fesm2022/signality-core-reactivity-throttled.mjs.map +1 -1
- package/fesm2022/signality-core-reactivity-watcher.mjs.map +1 -1
- package/fesm2022/signality-core-router-fragment.mjs +1 -1
- package/fesm2022/signality-core-router-fragment.mjs.map +1 -1
- package/fesm2022/signality-core-router-params.mjs +1 -1
- package/fesm2022/signality-core-router-params.mjs.map +1 -1
- package/fesm2022/signality-core-router-query-params.mjs.map +1 -1
- package/fesm2022/signality-core-router-route-data.mjs +1 -1
- package/fesm2022/signality-core-router-route-data.mjs.map +1 -1
- package/fesm2022/signality-core-router-router-listener.mjs.map +1 -1
- package/fesm2022/signality-core-router-title.mjs +1 -1
- package/fesm2022/signality-core-router-title.mjs.map +1 -1
- package/fesm2022/signality-core-router-url.mjs +1 -1
- package/fesm2022/signality-core-router-url.mjs.map +1 -1
- package/fesm2022/signality-core-scheduling-debounce-callback.mjs +1 -1
- package/fesm2022/signality-core-scheduling-debounce-callback.mjs.map +1 -1
- package/fesm2022/signality-core-scheduling-interval.mjs +29 -72
- package/fesm2022/signality-core-scheduling-interval.mjs.map +1 -1
- package/internal/utils/assert.d.ts +2 -0
- package/internal/utils/dom/index.d.ts +1 -0
- package/internal/utils/dom/is-element.d.ts +1 -1
- package/internal/utils/dom/is-event-target.d.ts +1 -0
- package/internal/utils/files/index.d.ts +1 -0
- package/internal/utils/files/is-accepted-file.d.ts +11 -0
- package/internal/utils/index.d.ts +3 -0
- package/internal/utils/to-element.d.ts +1 -1
- package/internal/utils/unref-element.d.ts +2 -0
- package/observers/index.d.ts +0 -1
- package/observers/intersection-observer/index.d.ts +22 -1
- package/observers/mutation-observer/index.d.ts +43 -1
- package/observers/resize-observer/index.d.ts +13 -1
- package/package.json +30 -26
- package/reactivity/debounced/index.d.ts +2 -2
- package/reactivity/throttled/index.d.ts +2 -2
- package/reactivity/watcher/index.d.ts +2 -2
- package/router/fragment/index.d.ts +1 -1
- package/router/params/index.d.ts +1 -1
- package/router/query-params/index.d.ts +5 -3
- package/router/route-data/index.d.ts +1 -1
- package/router/router-listener/index.d.ts +1 -1
- package/router/title/index.d.ts +1 -1
- package/router/url/index.d.ts +1 -1
- package/scheduling/debounce-callback/index.d.ts +1 -1
- package/scheduling/interval/index.d.ts +19 -27
- package/browser/pointer-lock-element/index.d.ts +0 -22
- package/browser/wake-lock/index.d.ts +0 -37
- package/fesm2022/signality-core-browser-pointer-lock-element.mjs +0 -43
- package/fesm2022/signality-core-browser-pointer-lock-element.mjs.map +0 -1
- package/fesm2022/signality-core-browser-wake-lock.mjs +0 -149
- package/fesm2022/signality-core-browser-wake-lock.mjs.map +0 -1
- package/fesm2022/signality-core-elements-text-selection.mjs.map +0 -1
- package/fesm2022/signality-core-elements-window-size.mjs.map +0 -1
- package/fesm2022/signality-core-observers-performance-observer.mjs +0 -84
- package/fesm2022/signality-core-observers-performance-observer.mjs.map +0 -1
- package/observers/performance-observer/index.d.ts +0 -58
package/README.md
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
1
|
# @signality/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A collection of atomic utilities for building reactive compositions in [Angular](https://angular.dev).
|
|
4
|
+
|
|
5
|
+
## Key Benefits
|
|
6
|
+
|
|
7
|
+
- **Signal-first design** — built on top of Angular [Signals](https://angular.dev/guide/signals), abstracting away from RxJS
|
|
8
|
+
- **Automatic cleanup** — utilities manage resource lifecycles automatically
|
|
9
|
+
- **SSR-compatible** — browser APIs are guarded with safe defaults on the server
|
|
10
|
+
- **Reactive inputs** — seamlessly handles static and reactive values
|
|
11
|
+
- **Tree-Shakable** — only the code you use ends up in your bundle
|
|
12
|
+
|
|
13
|
+
## Quick Example
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Component, effect } from '@angular/core';
|
|
17
|
+
import { storage, speechSynthesis, favicon } from '@signality/core';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
template: `
|
|
21
|
+
<input [(ngModel)]="value" />
|
|
22
|
+
<button (click)="synthesis.speak(value())">Speak</button>
|
|
23
|
+
`,
|
|
24
|
+
})
|
|
25
|
+
export class Demo {
|
|
26
|
+
readonly value = storage('key', ''); // Web Storage API
|
|
27
|
+
readonly synthesis = speechSynthesis(); // Web Speech API
|
|
28
|
+
readonly fav = favicon(); // Dynamic Favicon
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
effect(() => {
|
|
32
|
+
if (this.synthesis.isSpeaking()) {
|
|
33
|
+
this.fav.setEmoji('🔊');
|
|
34
|
+
} else {
|
|
35
|
+
this.fav.reset();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Framework Compatibility
|
|
43
|
+
|
|
44
|
+
| Tool | Minimum Version |
|
|
45
|
+
|-------------|-----------------|
|
|
46
|
+
| **Angular** | `v20.0.0` |
|
|
4
47
|
|
|
5
48
|
## Installation
|
|
6
49
|
|
|
7
50
|
```bash
|
|
8
|
-
|
|
51
|
+
pnpm add @signality/core
|
|
9
52
|
```
|
|
10
53
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **`pageVisibility()`** — Reactive page visibility state
|
|
18
|
-
- **`storage()`** — Reactive localStorage/sessionStorage with sync
|
|
19
|
-
- **`network()`** — Reactive network connection status
|
|
20
|
-
- **`fullscreen()`** — Reactive fullscreen API
|
|
21
|
-
- And [many more...](https://signality.dev/browser/battery)
|
|
22
|
-
|
|
23
|
-
### Element Utilities
|
|
24
|
-
- **`elementSize()`** — Reactive element dimensions
|
|
25
|
-
- **`elementVisibility()`** — Reactive Intersection Observer
|
|
26
|
-
- **`dropzone()`** — Reactive drag & drop zone
|
|
27
|
-
- **`windowSize()`** — Reactive window dimensions
|
|
28
|
-
- **`scrollPosition()`** — Reactive scroll position
|
|
29
|
-
- And [many more...](https://signality.dev/elements/active-element)
|
|
30
|
-
|
|
31
|
-
### Utils
|
|
32
|
-
- **`debounced()`** — Debounced writable signal
|
|
33
|
-
- **`throttled()`** — Throttled writable signal
|
|
34
|
-
|
|
35
|
-
## Usage
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { battery, clipboard, elementSize, debounced } from '@signality/core';
|
|
39
|
-
|
|
40
|
-
// Battery status
|
|
41
|
-
const batteryStatus = battery();
|
|
42
|
-
// batteryStatus.level(), batteryStatus.charging()
|
|
43
|
-
|
|
44
|
-
// Clipboard operations
|
|
45
|
-
const clipboard = clipboard();
|
|
46
|
-
await clipboard.copy('Hello');
|
|
47
|
-
const text = await clipboard.paste();
|
|
48
|
-
|
|
49
|
-
// Element size tracking
|
|
50
|
-
const element = viewChild<ElementRef<HTMLDivElement>>('myElement');
|
|
51
|
-
const size = elementSize(element);
|
|
52
|
-
// size.width(), size.height()
|
|
53
|
-
|
|
54
|
-
// Debounced signal
|
|
55
|
-
const searchQuery = debounced('', 300);
|
|
54
|
+
Or with npm/yarn:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install @signality/core
|
|
58
|
+
# or
|
|
59
|
+
yarn add @signality/core
|
|
56
60
|
```
|
|
57
61
|
|
|
58
62
|
## Documentation
|
|
@@ -2,11 +2,36 @@ import { type Signal } from '@angular/core';
|
|
|
2
2
|
import type { WithInjector } from '@signality/core/types';
|
|
3
3
|
export type BatteryOptions = WithInjector;
|
|
4
4
|
export interface BatteryRef {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the Battery Status API is supported in the current browser.
|
|
7
|
+
*
|
|
8
|
+
* @see [Battery Status API browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API#browser_compatibility)
|
|
9
|
+
*/
|
|
10
|
+
readonly isSupported: Signal<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the battery is currently charging.
|
|
13
|
+
*
|
|
14
|
+
* @see [BatteryManager: charging on MDN](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/charging)
|
|
15
|
+
*/
|
|
5
16
|
readonly charging: Signal<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Time in seconds until the battery is fully charged. `Infinity` if not charging.
|
|
19
|
+
*
|
|
20
|
+
* @see [BatteryManager: chargingTime on MDN](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/chargingTime)
|
|
21
|
+
*/
|
|
6
22
|
readonly chargingTime: Signal<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Time in seconds until the battery is fully discharged. `Infinity` if charging.
|
|
25
|
+
*
|
|
26
|
+
* @see [BatteryManager: dischargingTime on MDN](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/dischargingTime)
|
|
27
|
+
*/
|
|
7
28
|
readonly dischargingTime: Signal<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Battery level as a value between `0.0` and `1.0`.
|
|
31
|
+
*
|
|
32
|
+
* @see [BatteryManager: level on MDN](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/level)
|
|
33
|
+
*/
|
|
8
34
|
readonly level: Signal<number>;
|
|
9
|
-
readonly isSupported: Signal<boolean>;
|
|
10
35
|
}
|
|
11
36
|
/**
|
|
12
37
|
* Signal-based wrapper around the [Battery Status API](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API).
|
|
@@ -26,7 +51,7 @@ export interface BatteryRef {
|
|
|
26
51
|
* }
|
|
27
52
|
* `
|
|
28
53
|
* })
|
|
29
|
-
* class
|
|
54
|
+
* export class BatteryDemo {
|
|
30
55
|
* readonly batteryStatus = battery();
|
|
31
56
|
* }
|
|
32
57
|
* ```
|
|
@@ -2,34 +2,61 @@ import { type Signal } from '@angular/core';
|
|
|
2
2
|
import type { WithInjector } from '@signality/core/types';
|
|
3
3
|
export interface BluetoothOptions extends WithInjector {
|
|
4
4
|
/**
|
|
5
|
-
* Accept any Bluetooth device.
|
|
5
|
+
* Accept any Bluetooth device without filtering.
|
|
6
|
+
*
|
|
7
|
+
* @default true
|
|
8
|
+
* @see [requestDevice: acceptAllDevices on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#acceptalldevices)
|
|
6
9
|
*/
|
|
7
10
|
readonly acceptAllDevices?: boolean;
|
|
8
11
|
/**
|
|
9
|
-
* Filters for device selection.
|
|
12
|
+
* Filters for device selection. Mutually exclusive with `acceptAllDevices`.
|
|
13
|
+
*
|
|
14
|
+
* @default undefined
|
|
15
|
+
* @see [requestDevice: filters on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#filters)
|
|
10
16
|
*/
|
|
11
17
|
readonly filters?: BluetoothLEScanFilter[];
|
|
12
18
|
/**
|
|
13
|
-
* Optional services to access.
|
|
19
|
+
* Optional GATT services to access on the connected device.
|
|
20
|
+
*
|
|
21
|
+
* @default []
|
|
22
|
+
* @see [requestDevice: optionalServices on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#optionalservices)
|
|
14
23
|
*/
|
|
15
24
|
readonly optionalServices?: BluetoothServiceUUID[];
|
|
16
25
|
}
|
|
17
26
|
export interface BluetoothRef {
|
|
18
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Whether Web Bluetooth API is supported in the current browser.
|
|
29
|
+
*
|
|
30
|
+
* @see [Web Bluetooth API browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API#browser_compatibility)
|
|
31
|
+
*/
|
|
19
32
|
readonly isSupported: Signal<boolean>;
|
|
20
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Whether a device is currently connected.
|
|
35
|
+
*/
|
|
21
36
|
readonly isConnected: Signal<boolean>;
|
|
22
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Whether a connection is in progress.
|
|
39
|
+
*/
|
|
23
40
|
readonly isConnecting: Signal<boolean>;
|
|
24
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Connected Bluetooth device.
|
|
43
|
+
*/
|
|
25
44
|
readonly device: Signal<BluetoothDevice | null>;
|
|
26
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* GATT server of a connected device.
|
|
47
|
+
*/
|
|
27
48
|
readonly server: Signal<BluetoothRemoteGATTServer | null>;
|
|
28
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The last error that occurred.
|
|
51
|
+
*/
|
|
29
52
|
readonly error: Signal<Error | null>;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Request device connection.
|
|
55
|
+
*/
|
|
56
|
+
readonly request: () => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Disconnect from a device.
|
|
59
|
+
*/
|
|
33
60
|
readonly disconnect: () => void;
|
|
34
61
|
}
|
|
35
62
|
/**
|
|
@@ -48,7 +75,7 @@ export interface BluetoothRef {
|
|
|
48
75
|
* }
|
|
49
76
|
* `
|
|
50
77
|
* })
|
|
51
|
-
* class
|
|
78
|
+
* export class BluetoothDemo {
|
|
52
79
|
* readonly bt = bluetooth();
|
|
53
80
|
* }
|
|
54
81
|
* ```
|
|
@@ -9,24 +9,37 @@ export interface BreakpointsOptions<T extends Record<string, string>> extends Wi
|
|
|
9
9
|
export type BreakpointsRef<T extends Record<string, string>> = {
|
|
10
10
|
readonly [K in keyof T]: Signal<boolean>;
|
|
11
11
|
} & {
|
|
12
|
+
/**
|
|
13
|
+
* List of currently active breakpoint keys — keys whose media query matches at the moment.
|
|
14
|
+
* Updated reactively whenever any breakpoint changes.
|
|
15
|
+
*/
|
|
12
16
|
readonly current: Signal<(keyof T)[]>;
|
|
13
17
|
};
|
|
14
18
|
/**
|
|
15
|
-
* Reactive breakpoint matching using matchMedia.
|
|
16
|
-
* Track responsive breakpoints with Angular signals.
|
|
19
|
+
* Reactive breakpoint matching using [matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia).
|
|
17
20
|
*
|
|
18
21
|
* @param map - Object mapping breakpoint names to media queries
|
|
19
22
|
* @param options - Optional configuration
|
|
20
|
-
* @returns An object with signals for each breakpoint
|
|
23
|
+
* @returns An object with signals for each breakpoint and a `current` signal with active breakpoint keys
|
|
21
24
|
*
|
|
22
25
|
* @example
|
|
23
26
|
* ```typescript
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* @Component({
|
|
28
|
+
* template: `
|
|
29
|
+
* @if (bp.mobile()) {
|
|
30
|
+
* <p>Mobile layout</p>
|
|
31
|
+
* } @else {
|
|
32
|
+
* <p>Desktop layout</p>
|
|
33
|
+
* }
|
|
34
|
+
* <p>Active: {{ bp.current() }}</p>
|
|
35
|
+
* `
|
|
36
|
+
* })
|
|
37
|
+
* export class Layout {
|
|
38
|
+
* readonly bp = breakpoints({
|
|
39
|
+
* mobile: '(max-width: 767px)',
|
|
40
|
+
* desktop: '(min-width: 768px)',
|
|
41
|
+
* });
|
|
42
|
+
* }
|
|
30
43
|
* ```
|
|
31
44
|
*/
|
|
32
45
|
export declare function breakpoints<T extends Record<string, string>>(map: T, options?: BreakpointsOptions<T>): BreakpointsRef<T>;
|
|
@@ -30,7 +30,7 @@ export interface BroadcastChannelRef<T> {
|
|
|
30
30
|
* <button (click)="sendMessage()">Send Message</button>
|
|
31
31
|
* `
|
|
32
32
|
* })
|
|
33
|
-
* class
|
|
33
|
+
* export class ChatDemo {
|
|
34
34
|
* readonly channel = broadcastChannel<string>('my-channel');
|
|
35
35
|
*
|
|
36
36
|
* sendMessage() {
|
|
@@ -8,15 +8,31 @@ export interface ClipboardOptions extends WithInjector {
|
|
|
8
8
|
readonly copiedDuration?: MaybeSignal<number>;
|
|
9
9
|
}
|
|
10
10
|
export interface ClipboardRef {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Whether the Clipboard API is supported in the current browser.
|
|
13
|
+
*
|
|
14
|
+
* @see [Clipboard API browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#browser_compatibility)
|
|
15
|
+
*/
|
|
12
16
|
readonly isSupported: Signal<boolean>;
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The most recently copied or pasted text.
|
|
19
|
+
*/
|
|
14
20
|
readonly text: Signal<string>;
|
|
15
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Whether the text was recently copied. Resets to `false` after `copiedDuration` ms.
|
|
23
|
+
*/
|
|
16
24
|
readonly copied: Signal<boolean>;
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Write text to the clipboard.
|
|
27
|
+
*
|
|
28
|
+
* @see [Clipboard: writeText() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)
|
|
29
|
+
*/
|
|
18
30
|
readonly copy: (text: string) => Promise<void>;
|
|
19
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Read text from the clipboard.
|
|
33
|
+
*
|
|
34
|
+
* @see [Clipboard: readText() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText)
|
|
35
|
+
*/
|
|
20
36
|
readonly paste: () => Promise<string>;
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
@@ -36,7 +52,7 @@ export interface ClipboardRef {
|
|
|
36
52
|
* }
|
|
37
53
|
* `
|
|
38
54
|
* })
|
|
39
|
-
* class
|
|
55
|
+
* export class ClipboardDemo {
|
|
40
56
|
* readonly cb = clipboard();
|
|
41
57
|
*
|
|
42
58
|
* async copyText(text: string) {
|
|
@@ -2,9 +2,17 @@ import { type Signal } from '@angular/core';
|
|
|
2
2
|
import type { WithInjector } from '@signality/core/types';
|
|
3
3
|
export type DevicePostureType = 'continuous' | 'folded';
|
|
4
4
|
export interface DevicePostureRef {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Whether the Device Posture API is supported in the current browser.
|
|
7
|
+
*
|
|
8
|
+
* @see [Device Posture API browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Device_Posture_API#browser_compatibility)
|
|
9
|
+
*/
|
|
6
10
|
readonly isSupported: Signal<boolean>;
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Current posture of the device. `'continuous'` for flat screens, `'folded'` for foldable devices.
|
|
13
|
+
*
|
|
14
|
+
* @see [DevicePosture: type on MDN](https://developer.mozilla.org/en-US/docs/Web/API/DevicePosture/type)
|
|
15
|
+
*/
|
|
8
16
|
readonly type: Signal<DevicePostureType>;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
@@ -14,5 +22,18 @@ export interface DevicePostureRef {
|
|
|
14
22
|
* @param options - Optional configuration including injector
|
|
15
23
|
* @returns A DevicePostureRef with type signal
|
|
16
24
|
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* @Component({
|
|
28
|
+
* template: `
|
|
29
|
+
* @if (posture.isSupported()) {
|
|
30
|
+
* <p>Device posture: {{ posture.type() }}</p>
|
|
31
|
+
* }
|
|
32
|
+
* `
|
|
33
|
+
* })
|
|
34
|
+
* export class PostureDemo {
|
|
35
|
+
* readonly posture = devicePosture();
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
17
38
|
*/
|
|
18
39
|
export declare function devicePosture(options?: WithInjector): DevicePostureRef;
|
|
@@ -2,28 +2,52 @@ import { type Signal } from '@angular/core';
|
|
|
2
2
|
import type { WithInjector } from '@signality/core/types';
|
|
3
3
|
export interface DisplayMediaOptions extends WithInjector {
|
|
4
4
|
/**
|
|
5
|
-
* Video constraints.
|
|
5
|
+
* Video track constraints for the captured stream.
|
|
6
|
+
*
|
|
6
7
|
* @default true
|
|
8
|
+
* @see [MediaTrackConstraints on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints)
|
|
7
9
|
*/
|
|
8
10
|
readonly video?: boolean | MediaTrackConstraints;
|
|
9
11
|
/**
|
|
10
|
-
* Audio constraints.
|
|
12
|
+
* Audio track constraints for the captured stream.
|
|
13
|
+
*
|
|
11
14
|
* @default false
|
|
15
|
+
* @see [MediaTrackConstraints on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints)
|
|
12
16
|
*/
|
|
13
17
|
readonly audio?: boolean | MediaTrackConstraints;
|
|
14
18
|
}
|
|
15
19
|
export interface DisplayMediaRef {
|
|
16
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Whether the Screen Capture API is supported in the current browser.
|
|
22
|
+
*
|
|
23
|
+
* @see [Screen Capture API browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API#browser_compatibility)
|
|
24
|
+
*/
|
|
17
25
|
readonly isSupported: Signal<boolean>;
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Whether screen capture is currently active.
|
|
28
|
+
*/
|
|
19
29
|
readonly isActive: Signal<boolean>;
|
|
20
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The active media stream, or `null` if capture is not active.
|
|
32
|
+
*
|
|
33
|
+
* @see [MediaStream on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream)
|
|
34
|
+
*/
|
|
21
35
|
readonly stream: Signal<MediaStream | null>;
|
|
22
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The last error that occurred, or `null` if no error.
|
|
38
|
+
*/
|
|
23
39
|
readonly error: Signal<Error | null>;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Start screen capture. Opens the browser's display picker.
|
|
42
|
+
*
|
|
43
|
+
* @see [MediaDevices: getDisplayMedia() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia)
|
|
44
|
+
*/
|
|
45
|
+
readonly start: () => Promise<MediaStream | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Stop all active capture tracks and clear the stream.
|
|
48
|
+
*
|
|
49
|
+
* @see [MediaStreamTrack: stop() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/stop)
|
|
50
|
+
*/
|
|
27
51
|
readonly stop: () => void;
|
|
28
52
|
}
|
|
29
53
|
/**
|
|
@@ -52,7 +76,7 @@ export interface DisplayMediaRef {
|
|
|
52
76
|
* }
|
|
53
77
|
* `
|
|
54
78
|
* })
|
|
55
|
-
* class
|
|
79
|
+
* export class ScreenCaptureDemo {
|
|
56
80
|
* readonly screen = displayMedia();
|
|
57
81
|
*
|
|
58
82
|
* async toggleCapture() {
|
|
@@ -64,17 +88,5 @@ export interface DisplayMediaRef {
|
|
|
64
88
|
* }
|
|
65
89
|
* }
|
|
66
90
|
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // With custom constraints
|
|
71
|
-
* const screen = displayMedia({
|
|
72
|
-
* video: {
|
|
73
|
-
* width: { ideal: 1920 },
|
|
74
|
-
* height: { ideal: 1080 },
|
|
75
|
-
* },
|
|
76
|
-
* audio: true,
|
|
77
|
-
* });
|
|
78
|
-
* ```
|
|
79
91
|
*/
|
|
80
92
|
export declare function displayMedia(options?: DisplayMediaOptions): DisplayMediaRef;
|
|
@@ -8,13 +8,29 @@ export interface EyeDropperOptions extends WithInjector {
|
|
|
8
8
|
readonly initialValue?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface EyeDropperRef {
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Whether the EyeDropper API is supported in the current browser.
|
|
13
|
+
*
|
|
14
|
+
* @see [EyeDropper browser compatibility on MDN](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper#browser_compatibility)
|
|
15
|
+
*/
|
|
14
16
|
readonly isSupported: Signal<boolean>;
|
|
15
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The most recently selected color in sRGB hex format (e.g. `#ff0000`).
|
|
19
|
+
*
|
|
20
|
+
* @see [EyeDropper: open() return value on MDN](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper/open#return_value)
|
|
21
|
+
*/
|
|
22
|
+
readonly sRGBHex: Signal<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Open the eyedropper tool and wait for the user to select a color.
|
|
25
|
+
*
|
|
26
|
+
* @see [EyeDropper: open() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper/open)
|
|
27
|
+
*/
|
|
16
28
|
readonly open: () => Promise<void>;
|
|
17
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Cancel the active eyedropper operation via `AbortController`.
|
|
31
|
+
*
|
|
32
|
+
* @see [AbortController: abort() on MDN](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort)
|
|
33
|
+
*/
|
|
18
34
|
readonly close: () => void;
|
|
19
35
|
}
|
|
20
36
|
/**
|
|
@@ -35,7 +51,7 @@ export interface EyeDropperRef {
|
|
|
35
51
|
* }
|
|
36
52
|
* `
|
|
37
53
|
* })
|
|
38
|
-
* class
|
|
54
|
+
* export class ColorPicker {
|
|
39
55
|
* readonly eyeDropper = eyeDropper();
|
|
40
56
|
*
|
|
41
57
|
* async pickColor() {
|
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import { type Signal } from '@angular/core';
|
|
2
2
|
import type { WithInjector } from '@signality/core/types';
|
|
3
3
|
export interface FaviconOptions extends WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Base URL prepended to all favicon paths passed to `set()`.
|
|
6
|
+
*
|
|
7
|
+
* Resolution priority:
|
|
8
|
+
* 1. Explicit `baseUrl` value
|
|
9
|
+
* 2. [`APP_BASE_HREF`](https://angular.dev/api/common/APP_BASE_HREF) token value (if configured)
|
|
10
|
+
* 3. Empty string `''`
|
|
11
|
+
*/
|
|
4
12
|
readonly baseUrl?: string;
|
|
5
13
|
}
|
|
6
14
|
export interface FaviconRef {
|
|
15
|
+
/**
|
|
16
|
+
* URL of the currently active favicon.
|
|
17
|
+
*/
|
|
7
18
|
readonly current: Signal<string>;
|
|
19
|
+
/**
|
|
20
|
+
* URL of the favicon at the time the utility was initialized.
|
|
21
|
+
*/
|
|
8
22
|
readonly original: Signal<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the favicon to the given URL.
|
|
25
|
+
*
|
|
26
|
+
* @see [HTMLLinkElement on MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement)
|
|
27
|
+
*/
|
|
9
28
|
readonly set: (url: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Render an emoji onto a canvas and use it as the favicon.
|
|
31
|
+
*
|
|
32
|
+
* @see [Canvas API on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
|
|
33
|
+
*/
|
|
10
34
|
readonly setEmoji: (emoji: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Reset the favicon to the original URL captured on initialization.
|
|
37
|
+
*/
|
|
11
38
|
readonly reset: () => void;
|
|
12
39
|
}
|
|
13
40
|
/**
|
|
14
|
-
* Reactive favicon manipulation.
|
|
41
|
+
* Reactive favicon manipulation using the [HTMLLinkElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement).
|
|
15
42
|
* Dynamically change the page favicon based on application state.
|
|
16
43
|
*
|
|
17
44
|
* @param options - Optional configuration
|
|
@@ -26,7 +53,7 @@ export interface FaviconRef {
|
|
|
26
53
|
* <p>Current: {{ fav.current() }}</p>
|
|
27
54
|
* `
|
|
28
55
|
* })
|
|
29
|
-
* class
|
|
56
|
+
* export class FaviconDemo {
|
|
30
57
|
* readonly fav = favicon();
|
|
31
58
|
*
|
|
32
59
|
* setNotification() {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type WritableSignal } from '@angular/core';
|
|
2
|
+
import type { MaybeSignal, WithInjector } from '@signality/core/types';
|
|
3
|
+
export interface FileDialogOptions extends WithInjector {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to allow selecting multiple files.
|
|
6
|
+
* When changed reactively, the current file list is re-filtered.
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
readonly multiple?: MaybeSignal<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Comma-separated list of accepted file types, matching the native HTML
|
|
12
|
+
* [`accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept) attribute format.
|
|
13
|
+
* Supports MIME types (`'image/png'`), wildcards (`'image/*'`), and file extensions (`'.pdf'`).
|
|
14
|
+
* When changed reactively, the current file list is re-filtered.
|
|
15
|
+
*
|
|
16
|
+
* @default '*'
|
|
17
|
+
* @see [accept attribute on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept)
|
|
18
|
+
*/
|
|
19
|
+
readonly accept?: MaybeSignal<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Capture source for mobile devices: `'user'` (front camera) or `'environment'` (rear camera).
|
|
22
|
+
* @see [capture attribute on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
23
|
+
*/
|
|
24
|
+
readonly capture?: MaybeSignal<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to select directories instead of files.
|
|
27
|
+
* Uses the non-standard `webkitdirectory` attribute.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
readonly directory?: MaybeSignal<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Custom validation predicate called for each selected file.
|
|
33
|
+
* Return `true` to keep the file, `false` to reject it.
|
|
34
|
+
*
|
|
35
|
+
* When provided, the `accept` option is ignored — the validator
|
|
36
|
+
* takes full responsibility for deciding which files are valid.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* fileDialog({
|
|
41
|
+
* validator: (file) => file.size <= 5 * 1024 * 1024, // max 5 MB
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
readonly validator?: (file: File) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Callback invoked with files that were rejected during selection.
|
|
48
|
+
* Useful for showing toast notifications or validation errors.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* fileDialog({
|
|
53
|
+
* accept: 'image/*',
|
|
54
|
+
* onReject: (rejected) => {
|
|
55
|
+
* rejected.forEach(f => toast.error(`${f.name} is not valid`));
|
|
56
|
+
* },
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
readonly onReject?: (files: File[]) => void;
|
|
61
|
+
}
|
|
62
|
+
export interface FileDialogRef {
|
|
63
|
+
/**
|
|
64
|
+
* List of files selected via the file dialog.
|
|
65
|
+
* A `WritableSignal` — can be reset externally (e.g. `files.set([])`).
|
|
66
|
+
* Re-filtered automatically when `accept` or `multiple` options change reactively.
|
|
67
|
+
*
|
|
68
|
+
* @see [File API on MDN](https://developer.mozilla.org/en-US/docs/Web/API/File)
|
|
69
|
+
*/
|
|
70
|
+
readonly files: WritableSignal<File[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Open the native file picker dialog.
|
|
73
|
+
*/
|
|
74
|
+
readonly open: () => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Signal-based utility for programmatically opening the native file picker dialog.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns A {@link FileDialogRef} with `files` signal and `open` method
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* @Component({
|
|
85
|
+
* template: `
|
|
86
|
+
* <button (click)="fd.open()">Select Files</button>
|
|
87
|
+
* @for (file of fd.files(); track file.name) {
|
|
88
|
+
* <p>{{ file.name }} ({{ file.size }} bytes)</p>
|
|
89
|
+
* }
|
|
90
|
+
* `
|
|
91
|
+
* })
|
|
92
|
+
* export class FileUpload {
|
|
93
|
+
* readonly fd = fileDialog({ accept: 'image/*' });
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function fileDialog(options?: FileDialogOptions): FileDialogRef;
|