@ardium-pl/devkit 8.3.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 +25 -0
- package/fesm2022/ardium-pl-devkit.mjs +3874 -0
- package/fesm2022/ardium-pl-devkit.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/click-outside/click-outside.directive.d.ts +14 -0
- package/lib/click-outside/click-outside.module.d.ts +8 -0
- package/lib/click-outside/index.d.ts +2 -0
- package/lib/coercion/array.d.ts +21 -0
- package/lib/coercion/boolean.d.ts +6 -0
- package/lib/coercion/date.d.ts +5 -0
- package/lib/coercion/index.d.ts +4 -0
- package/lib/coercion/number.d.ts +20 -0
- package/lib/dom-boxes/dom-boxes.d.ts +7 -0
- package/lib/dom-boxes/index.d.ts +1 -0
- package/lib/escape-html/escape-html.d.ts +1 -0
- package/lib/escape-html/escape-html.module.d.ts +8 -0
- package/lib/escape-html/escape-html.pipe.d.ts +7 -0
- package/lib/escape-html/index.d.ts +3 -0
- package/lib/file-pipes/file-pipes.defaults.d.ts +8 -0
- package/lib/file-pipes/file-pipes.module.d.ts +10 -0
- package/lib/file-pipes/fileext.pipe.d.ts +39 -0
- package/lib/file-pipes/filename.pipe.d.ts +38 -0
- package/lib/file-pipes/filesize.pipe.d.ts +50 -0
- package/lib/file-pipes/index.d.ts +5 -0
- package/lib/file-system/file-system.service.d.ts +69 -0
- package/lib/file-system/file-system.types.d.ts +186 -0
- package/lib/file-system/index.d.ts +2 -0
- package/lib/find-functions/find-suggestion.d.ts +3 -0
- package/lib/find-functions/index.d.ts +1 -0
- package/lib/forms/index.d.ts +1 -0
- package/lib/forms/track-form-control/index.d.ts +1 -0
- package/lib/forms/track-form-control/track-form-control.d.ts +83 -0
- package/lib/hold/hold.defaults.d.ts +9 -0
- package/lib/hold/hold.directive.d.ts +24 -0
- package/lib/hold/hold.module.d.ts +8 -0
- package/lib/hold/index.d.ts +3 -0
- package/lib/http-service/_types.d.ts +20 -0
- package/lib/http-service/_utils.d.ts +1 -0
- package/lib/http-service/http.service.d.ts +2574 -0
- package/lib/http-service/index.d.ts +1 -0
- package/lib/infinite-scroll/index.d.ts +3 -0
- package/lib/infinite-scroll/infinite-scroll.defaults.d.ts +8 -0
- package/lib/infinite-scroll/infinite-scroll.directive.d.ts +24 -0
- package/lib/infinite-scroll/infinite-scroll.module.d.ts +8 -0
- package/lib/keyboard/index.d.ts +2 -0
- package/lib/keyboard/keyboard.service.d.ts +60 -0
- package/lib/keyboard/keyboard.types.d.ts +13 -0
- package/lib/keyboard/types-internal.d.ts +20 -0
- package/lib/keyboard/utils.d.ts +3 -0
- package/lib/relative-pos/index.d.ts +1 -0
- package/lib/relative-pos/relative-pos.d.ts +24 -0
- package/lib/signals/array/array-signal.d.ts +123 -0
- package/lib/signals/array/index.d.ts +1 -0
- package/lib/signals/counter/counter-signal.d.ts +67 -0
- package/lib/signals/counter/index.d.ts +1 -0
- package/lib/signals/debounced/debounced-signal.d.ts +15 -0
- package/lib/signals/debounced/index.d.ts +1 -0
- package/lib/signals/map/index.d.ts +1 -0
- package/lib/signals/map/map-signal.d.ts +97 -0
- package/lib/signals/persistent/index.d.ts +1 -0
- package/lib/signals/persistent/persistent-signal.d.ts +106 -0
- package/lib/signals/query-param/index.d.ts +1 -0
- package/lib/signals/query-param/query-param-signal.d.ts +35 -0
- package/lib/signals/queue/index.d.ts +1 -0
- package/lib/signals/queue/queue-signal.d.ts +77 -0
- package/lib/signals/set/index.d.ts +1 -0
- package/lib/signals/set/set-signal.d.ts +76 -0
- package/lib/signals/stack/index.d.ts +1 -0
- package/lib/signals/stack/stack-signal.d.ts +77 -0
- package/lib/signals/throttled/index.d.ts +1 -0
- package/lib/signals/throttled/throttled-signal.d.ts +15 -0
- package/lib/signals/tuple/index.d.ts +1 -0
- package/lib/signals/tuple/tuple-signal.d.ts +60 -0
- package/lib/validators/index.d.ts +1 -0
- package/lib/validators/validators.d.ts +612 -0
- package/lib/viewport-observer/index.d.ts +3 -0
- package/lib/viewport-observer/utils.d.ts +15 -0
- package/lib/viewport-observer/viewport-observer-ref.d.ts +47 -0
- package/lib/viewport-observer/viewport-observer.defaults.d.ts +7 -0
- package/lib/viewport-observer/viewport-observer.service.d.ts +23 -0
- package/package.json +30 -0
- package/public-api.d.ts +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './http.service';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
import { ArdInfScrollTarget } from './infinite-scroll.directive';
|
|
3
|
+
export interface ArdInfiniteScrollDefaults {
|
|
4
|
+
threshold: number;
|
|
5
|
+
target: ArdInfScrollTarget;
|
|
6
|
+
}
|
|
7
|
+
export declare const ARD_INFINITE_SCROLL_DEFAULTS: InjectionToken<ArdInfiniteScrollDefaults>;
|
|
8
|
+
export declare function provideInfiniteScrollDefaults(config: Partial<ArdInfiniteScrollDefaults>): Provider;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare const ArdInfScrollTarget: {
|
|
3
|
+
readonly Host: "host";
|
|
4
|
+
readonly HTML: "html";
|
|
5
|
+
};
|
|
6
|
+
export type ArdInfScrollTarget = (typeof ArdInfScrollTarget)[keyof typeof ArdInfScrollTarget];
|
|
7
|
+
export declare class ArdiumInfiniteScrollDirective {
|
|
8
|
+
private readonly elementRef;
|
|
9
|
+
protected readonly _DEFAULTS: import("@ardium-pl/devkit").ArdInfiniteScrollDefaults;
|
|
10
|
+
readonly ardInfScrollReachThreshold: import("@angular/core").OutputEmitterRef<void>;
|
|
11
|
+
private _getElementRect;
|
|
12
|
+
private _getElementScrollTop;
|
|
13
|
+
private _getElementScrollHeight;
|
|
14
|
+
constructor();
|
|
15
|
+
readonly ardInfScrollThreshold: import("@angular/core").InputSignalWithTransform<number, any>;
|
|
16
|
+
readonly ardInfScrollActive: import("@angular/core").ModelSignal<boolean>;
|
|
17
|
+
readonly ardInfScrollTarget: import("@angular/core").InputSignal<ArdInfScrollTarget>;
|
|
18
|
+
onHostScroll(): void;
|
|
19
|
+
onWindowScroll(): void;
|
|
20
|
+
private _detectHostReachThreshold;
|
|
21
|
+
private _detectWindowReachThreshold;
|
|
22
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumInfiniteScrollDirective, never>;
|
|
23
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ArdiumInfiniteScrollDirective, "[ardInfScroll]", never, { "ardInfScrollThreshold": { "alias": "ardInfScrollThreshold"; "required": false; "isSignal": true; }; "ardInfScrollActive": { "alias": "ardInfScrollActive"; "required": false; "isSignal": true; }; "ardInfScrollTarget": { "alias": "ardInfScrollTarget"; "required": false; "isSignal": true; }; }, { "ardInfScrollReachThreshold": "ardInfScrollReachThreshold"; "ardInfScrollActive": "ardInfScrollActiveChange"; }, never, never, false, never>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./infinite-scroll.directive";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class ArdiumInfiniteScrollModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumInfiniteScrollModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ArdiumInfiniteScrollModule, [typeof i1.ArdiumInfiniteScrollDirective], [typeof i2.CommonModule], [typeof i1.ArdiumInfiniteScrollDirective]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ArdiumInfiniteScrollModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { ɵDomRendererFactory2 } from '@angular/platform-browser';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { KeyboardKey, KeyboardKeyState, KeyboardShortcut } from './keyboard.types';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class KeyboardService implements OnDestroy {
|
|
7
|
+
private renderer;
|
|
8
|
+
private removeListenFuncKeydown;
|
|
9
|
+
private removeListenFuncKeyup;
|
|
10
|
+
private removeListenFuncWindowblur;
|
|
11
|
+
constructor(rendererFactory: ɵDomRendererFactory2);
|
|
12
|
+
ngOnDestroy(): void;
|
|
13
|
+
private _resetAllKeys;
|
|
14
|
+
private readonly _isLeftCtrlHeld;
|
|
15
|
+
private readonly _isRightCtrlHeld;
|
|
16
|
+
readonly isLeftCtrlHeld: import("@angular/core").Signal<boolean>;
|
|
17
|
+
readonly isRightCtrlHeld: import("@angular/core").Signal<boolean>;
|
|
18
|
+
readonly isCtrlHeld: import("@angular/core").Signal<boolean>;
|
|
19
|
+
private readonly _isLeftAltHeld;
|
|
20
|
+
private readonly _isRightAltHeld;
|
|
21
|
+
readonly isAltHeld: import("@angular/core").Signal<boolean>;
|
|
22
|
+
readonly isAltGraphHeld: import("@angular/core").Signal<boolean>;
|
|
23
|
+
private readonly _isLeftShiftHeld;
|
|
24
|
+
private readonly _isRightShiftHeld;
|
|
25
|
+
readonly isLeftShiftHeld: import("@angular/core").Signal<boolean>;
|
|
26
|
+
readonly isRightShiftHeld: import("@angular/core").Signal<boolean>;
|
|
27
|
+
readonly isShiftHeld: import("@angular/core").Signal<boolean>;
|
|
28
|
+
private readonly _isLeftMetaHeld;
|
|
29
|
+
private readonly _isRightMetaHeld;
|
|
30
|
+
readonly isLeftMetaHeld: import("@angular/core").Signal<boolean>;
|
|
31
|
+
readonly isRightMetaHeld: import("@angular/core").Signal<boolean>;
|
|
32
|
+
readonly isMetaHeld: import("@angular/core").Signal<boolean>;
|
|
33
|
+
private readonly isAnyModifierKeyHeld;
|
|
34
|
+
private readonly _capsLockState;
|
|
35
|
+
readonly capsLockState: import("@angular/core").Signal<boolean | undefined>;
|
|
36
|
+
private readonly _numLockState;
|
|
37
|
+
readonly numLockState: import("@angular/core").Signal<boolean | undefined>;
|
|
38
|
+
private readonly _scrollLockState;
|
|
39
|
+
readonly scrollLockState: import("@angular/core").Signal<boolean | undefined>;
|
|
40
|
+
private readonly _shortcutSubject$;
|
|
41
|
+
readonly anyShortcut$: Observable<KeyboardShortcut>;
|
|
42
|
+
private readonly _keySubject$;
|
|
43
|
+
readonly anyKeyPress$: Observable<KeyboardKey>;
|
|
44
|
+
private readonly _keyStateSubject$;
|
|
45
|
+
readonly anyKeyState$: Observable<KeyboardKeyState>;
|
|
46
|
+
private _demapKeyCode;
|
|
47
|
+
private _emitShortcut;
|
|
48
|
+
private _emitKeydown;
|
|
49
|
+
private _emitKeyStateDown;
|
|
50
|
+
private _emitKeyStateUp;
|
|
51
|
+
listenToShortcut(toMatch: string[], treatAltGraphAsAltPlusCtrl?: boolean): Observable<KeyboardShortcut>;
|
|
52
|
+
listenToKey(code: string): Observable<KeyboardKey>;
|
|
53
|
+
listenToKeyState(code: string): Observable<KeyboardKeyState>;
|
|
54
|
+
private readonly _KEY_CODE_SIGNALS_MAP;
|
|
55
|
+
private _onKeydown;
|
|
56
|
+
private _updateLockKeyStates;
|
|
57
|
+
private _onKeyup;
|
|
58
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KeyboardService, never>;
|
|
59
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<KeyboardService>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type KeyboardShortcut = {
|
|
2
|
+
keys: string[];
|
|
3
|
+
event: KeyboardEvent;
|
|
4
|
+
};
|
|
5
|
+
export type KeyboardKey = {
|
|
6
|
+
key: string;
|
|
7
|
+
event: KeyboardEvent;
|
|
8
|
+
};
|
|
9
|
+
export type KeyboardKeyState = {
|
|
10
|
+
key: string;
|
|
11
|
+
isHeld: boolean;
|
|
12
|
+
event: KeyboardEvent;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { KeyboardShortcut } from "./keyboard.types";
|
|
2
|
+
export type _LeftRight = {
|
|
3
|
+
left: boolean;
|
|
4
|
+
right: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type _KeyboardShortcutInternal = {
|
|
7
|
+
ctrl: _LeftRight;
|
|
8
|
+
alt: _LeftRight;
|
|
9
|
+
shift: _LeftRight;
|
|
10
|
+
meta: _LeftRight;
|
|
11
|
+
key: string;
|
|
12
|
+
publicData: KeyboardShortcut;
|
|
13
|
+
};
|
|
14
|
+
export declare const _ExpectedModifierKeySide: {
|
|
15
|
+
readonly None: "none";
|
|
16
|
+
readonly Left: "left";
|
|
17
|
+
readonly Right: "right";
|
|
18
|
+
readonly Any: "any";
|
|
19
|
+
};
|
|
20
|
+
export type _ExpectedModifierKeySide = typeof _ExpectedModifierKeySide[keyof typeof _ExpectedModifierKeySide];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { _ExpectedModifierKeySide, _LeftRight } from './types-internal';
|
|
2
|
+
export declare function trySettingModifierKey(modifierKeyName: string, keyCode: string, rawKeyCode: string, previouslyFoundKeyCode: string | null, currentKeyState: _ExpectedModifierKeySide): [_ExpectedModifierKeySide, string | null, boolean];
|
|
3
|
+
export declare function isModifierKeyInWrongState(state: _LeftRight, expectedState: _ExpectedModifierKeySide): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './relative-pos';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
export declare class EventRelativePos<T extends HTMLElement> {
|
|
3
|
+
readonly target: T;
|
|
4
|
+
readonly top: number;
|
|
5
|
+
readonly right: number;
|
|
6
|
+
readonly bottom: number;
|
|
7
|
+
readonly left: number;
|
|
8
|
+
readonly overflowsTop: boolean;
|
|
9
|
+
readonly overflowsRight: boolean;
|
|
10
|
+
readonly overflowsBottom: boolean;
|
|
11
|
+
readonly overflowsLeft: boolean;
|
|
12
|
+
readonly overflows: boolean;
|
|
13
|
+
constructor(target: T, top: number, right: number, bottom: number, left: number);
|
|
14
|
+
valueOf(): {
|
|
15
|
+
top: number;
|
|
16
|
+
right: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
left: number;
|
|
19
|
+
};
|
|
20
|
+
toJSON(): string;
|
|
21
|
+
toString(): string;
|
|
22
|
+
static fromEvent<T extends HTMLElement>(event: MouseEvent | TouchEvent | Touch, el: T | ElementRef<T>): EventRelativePos<T>;
|
|
23
|
+
}
|
|
24
|
+
export declare function getEventRelativePos<T extends HTMLElement>(event: MouseEvent | TouchEvent | Touch, el: T | ElementRef<T>): EventRelativePos<T>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* A read-only array signal with non-mutating methods.
|
|
4
|
+
*/
|
|
5
|
+
export interface ArraySignal<T> extends Signal<T[]> {
|
|
6
|
+
/**
|
|
7
|
+
* A computed signal that returns `true` if the array is empty.
|
|
8
|
+
*/
|
|
9
|
+
readonly isEmpty: Signal<boolean>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A writable array signal with mutating and non-mutating methods.
|
|
13
|
+
*/
|
|
14
|
+
export interface WritableArraySignal<T> extends WritableSignal<T[]>, ArraySignal<T> {
|
|
15
|
+
/**
|
|
16
|
+
* Returns a read-only version of the array signal.
|
|
17
|
+
*/
|
|
18
|
+
asReadonly(): ArraySignal<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Fills all the elements of the array signal from a start index to an end index with a static value.
|
|
21
|
+
* @param value - The value to fill the array with.
|
|
22
|
+
* @param start - The start index (inclusive). Defaults to 0.
|
|
23
|
+
* @param end - The end index (exclusive). Defaults to array length.
|
|
24
|
+
*/
|
|
25
|
+
fill(value: T, start?: number, end?: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Filters the array based on a predicate function and updates the signal with the filtered result.
|
|
28
|
+
* @param predicate - Function to test each element of the array.
|
|
29
|
+
*/
|
|
30
|
+
filter(predicate: (value: T, index: number, array: T[]) => boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* Applies a mapping function to each element in the array and updates the signal with the result.
|
|
33
|
+
* @param mapFn - Function that produces an element of the new array.
|
|
34
|
+
*/
|
|
35
|
+
map(mapFn: (value: T, index: number, array: T[]) => T): void;
|
|
36
|
+
/**
|
|
37
|
+
* Removes the last element from the array and returns it.
|
|
38
|
+
* Updates the signal.
|
|
39
|
+
* @returns The removed element, or undefined if the array was empty.
|
|
40
|
+
*/
|
|
41
|
+
pop(): T | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Appends new elements to the end of the array and returns the new length.
|
|
44
|
+
* Updates the signal.
|
|
45
|
+
* @param items - The elements to add.
|
|
46
|
+
* @returns The new length of the array.
|
|
47
|
+
*/
|
|
48
|
+
push(...items: T[]): number;
|
|
49
|
+
/**
|
|
50
|
+
* Reverses the order of the elements in the array and updates the signal.
|
|
51
|
+
*/
|
|
52
|
+
reverse(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Replaces the entire array with a new array value.
|
|
55
|
+
* @param value - The new array value.
|
|
56
|
+
*/
|
|
57
|
+
set(value: T[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Replaces the item at the given index with the new item.
|
|
60
|
+
* @param index - The index where the item should be replaced.
|
|
61
|
+
* @param newItem - The new item to be set at the given index.
|
|
62
|
+
*/
|
|
63
|
+
setAt(index: number, newItem: T): void;
|
|
64
|
+
/**
|
|
65
|
+
* Removes the first element from the array and returns it.
|
|
66
|
+
* Updates the signal.
|
|
67
|
+
* @returns The removed element, or undefined if the array was empty.
|
|
68
|
+
*/
|
|
69
|
+
shift(): T | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Sorts the elements of the array in place and updates the signal.
|
|
72
|
+
* @param compareFn - Specifies a function that defines the sort order.
|
|
73
|
+
*/
|
|
74
|
+
sort(compareFn?: (a: T, b: T) => number): void;
|
|
75
|
+
/**
|
|
76
|
+
* Changes the contents of the array by removing or replacing existing elements and/or adding new elements.
|
|
77
|
+
* Updates the signal.
|
|
78
|
+
* @param start - The index at which to start changing the array.
|
|
79
|
+
* @param deleteCount - The number of elements to remove.
|
|
80
|
+
* @param items - Elements to add to the array.
|
|
81
|
+
* @returns An array containing the deleted elements.
|
|
82
|
+
*/
|
|
83
|
+
splice(start: number, deleteCount?: number, ...items: T[]): T[];
|
|
84
|
+
/**
|
|
85
|
+
* Adds one or more elements to the beginning of the array and returns the new length.
|
|
86
|
+
* Updates the signal.
|
|
87
|
+
* @param items - The elements to add.
|
|
88
|
+
* @returns The new length of the array.
|
|
89
|
+
*/
|
|
90
|
+
unshift(...items: T[]): number;
|
|
91
|
+
/**
|
|
92
|
+
* Updates the array signal based on a provided update function.
|
|
93
|
+
* @param updateFn - A function that receives the current array and returns the updated array.
|
|
94
|
+
*/
|
|
95
|
+
update(updateFn: (value: T[]) => T[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Updates the item at the given index by applying the update function.
|
|
98
|
+
* @param index - The index where the item should be updated.
|
|
99
|
+
* @param updateFn - The function that will update the current item at the given index.
|
|
100
|
+
*/
|
|
101
|
+
updateAt(index: number, updateFn: (current: T) => T): void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a writable, reactive array signal with convenient, immutable array manipulation methods.
|
|
105
|
+
*
|
|
106
|
+
* This helper returns a signal that wraps an array and exposes a full suite of mutating and non-mutating array methods,
|
|
107
|
+
* all of which will automatically trigger Angular reactivity.
|
|
108
|
+
*
|
|
109
|
+
* All mutator methods (such as `push`, `pop`, `splice`, `setAt`, `updateAt`, etc) return a new array value, preserving
|
|
110
|
+
* immutability for optimal signal reactivity. Do not depend on reference equality between updates.
|
|
111
|
+
*
|
|
112
|
+
* @template T The type of items stored in the array.
|
|
113
|
+
* @param {T[]} [initialValue=[]] Optional initial value for the array.
|
|
114
|
+
* @returns {WritableArraySignal<T>} A writable array signal with both native and array-specific helpers.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const numbers = arraySignal([1, 2, 3]);
|
|
118
|
+
* numbers.push(4); // [1, 2, 3, 4]
|
|
119
|
+
* numbers.pop(); // returns 4, numbers() === [1, 2, 3]
|
|
120
|
+
* numbers.setAt(1, 99); // [1, 99, 3]
|
|
121
|
+
* numbers.filter(x => x>1); // [99, 3]
|
|
122
|
+
*/
|
|
123
|
+
export declare function arraySignal<T>(initialValue?: T[]): WritableArraySignal<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './array-signal';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* A read-only counter signal with computed helpers.
|
|
4
|
+
*/
|
|
5
|
+
export interface CounterSignal extends Signal<number> {
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the counter's value was not changed after resetting.
|
|
8
|
+
*/
|
|
9
|
+
readonly isReset: Signal<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the current counter value (alias for signal()).
|
|
12
|
+
*/
|
|
13
|
+
value(): number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A writable counter signal with mutation helpers and computed queries.
|
|
17
|
+
*/
|
|
18
|
+
export interface WritableCounterSignal extends WritableSignal<number>, CounterSignal {
|
|
19
|
+
/**
|
|
20
|
+
* Returns a read-only version of the counter signal.
|
|
21
|
+
*/
|
|
22
|
+
asReadonly(): CounterSignal;
|
|
23
|
+
/**
|
|
24
|
+
* Increments the counter by a specified value (default: 1).
|
|
25
|
+
* @param amount The value to increment by. Default is 1.
|
|
26
|
+
*/
|
|
27
|
+
increment(amount?: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Decrements the counter by a specified value (default: 1).
|
|
30
|
+
* @param amount The value to decrement by. Default is 1.
|
|
31
|
+
*/
|
|
32
|
+
decrement(amount?: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the counter to a specific value.
|
|
35
|
+
* @param value The value to set the counter to.
|
|
36
|
+
*/
|
|
37
|
+
set(value: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Updates the counter using an updater function.
|
|
40
|
+
* @param updater A function that receives the current value and returns the new value.
|
|
41
|
+
*/
|
|
42
|
+
update(updater: (current: number) => number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Resets the counter to its base (initial) value.
|
|
45
|
+
*
|
|
46
|
+
* Base value is the initial value by default, and can be changed using {@link setBaseValue}.
|
|
47
|
+
*/
|
|
48
|
+
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the base value to be used when resetting the counter.
|
|
51
|
+
*/
|
|
52
|
+
setBaseValue(value: number): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a writable, reactive counter signal with convenient helpers and computed queries.
|
|
56
|
+
*
|
|
57
|
+
* @param {number} [initial=0] The initial value of the counter.
|
|
58
|
+
* @returns {WritableCounterSignal} A writable counter signal instance.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const count = counterSignal(10);
|
|
62
|
+
* count.inc(); // 11
|
|
63
|
+
* count.dec(2); // 9
|
|
64
|
+
* count.reset(); // 10
|
|
65
|
+
* count.isReset(); // true
|
|
66
|
+
*/
|
|
67
|
+
export declare function counterSignal(initial?: number): WritableCounterSignal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './counter-signal';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WritableSignal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* A DebouncedSignal interface that extends WritableSignal<T> and includes debouncing behavior.
|
|
4
|
+
*/
|
|
5
|
+
export interface DebouncedSignal<T> extends WritableSignal<T> {
|
|
6
|
+
readonly debounceTime: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a `WritableSignal` that delays updates to its value until there's a pause in updates, based on the debounce time specified.
|
|
10
|
+
*
|
|
11
|
+
* @param initialValue - The initial value of the signal.
|
|
12
|
+
* @param debounceTime - The delay in milliseconds after the last update before applying the signal update.
|
|
13
|
+
* @returns A `WritableSignal<T>` that debounces value updates based on the specified debounce time.
|
|
14
|
+
*/
|
|
15
|
+
export declare function debouncedSignal<T>(initialValue: T, debounceTime: number): DebouncedSignal<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './debounced-signal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './map-signal';
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* A read-only map signal with non-mutating methods.
|
|
4
|
+
*/
|
|
5
|
+
export interface MapSignal<K, V> extends Signal<Map<K, V>> {
|
|
6
|
+
/**
|
|
7
|
+
* Computed signal that returns `true` if the map is empty.
|
|
8
|
+
*/
|
|
9
|
+
readonly isEmpty: Signal<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Computed signal for map size.
|
|
12
|
+
*/
|
|
13
|
+
readonly size: Signal<number>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the value for a key, or undefined.
|
|
16
|
+
*/
|
|
17
|
+
get(key: K): V | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a key exists in the map.
|
|
20
|
+
*/
|
|
21
|
+
has(key: K): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Computed signal that returns an array of [key, value] entries.
|
|
24
|
+
*/
|
|
25
|
+
readonly entriesArray: Signal<[K, V][]>;
|
|
26
|
+
/**
|
|
27
|
+
* Computed signal that returns an array of keys.
|
|
28
|
+
*/
|
|
29
|
+
readonly keysArray: Signal<K[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Computed signal that returns an array of values.
|
|
32
|
+
*/
|
|
33
|
+
readonly valuesArray: Signal<V[]>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A writable map signal with mutating and non-mutating methods.
|
|
37
|
+
*/
|
|
38
|
+
export interface WritableMapSignal<K, V> extends WritableSignal<Map<K, V>>, MapSignal<K, V> {
|
|
39
|
+
/**
|
|
40
|
+
* Returns a read-only version of the map signal.
|
|
41
|
+
*/
|
|
42
|
+
asReadonly(): MapSignal<K, V>;
|
|
43
|
+
/**
|
|
44
|
+
* Sets a value for the key.
|
|
45
|
+
*/
|
|
46
|
+
setKey(key: K, value: V): void;
|
|
47
|
+
/**
|
|
48
|
+
* Deletes a key from the map.
|
|
49
|
+
* Returns true if a value was removed.
|
|
50
|
+
*/
|
|
51
|
+
delete(key: K): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Clears the map.
|
|
54
|
+
*/
|
|
55
|
+
clear(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Replaces the map with a new map.
|
|
58
|
+
*/
|
|
59
|
+
setMap(value: Map<K, V>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Replaces the map with a new map. Alias of the method `setMap()`.
|
|
62
|
+
*/
|
|
63
|
+
set(value: Map<K, V>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Updates the map using an update function.
|
|
66
|
+
*/
|
|
67
|
+
update(updateFn: (current: Map<K, V>) => Map<K, V>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Updates the value for a key using the provided update function if the key exists.
|
|
70
|
+
*/
|
|
71
|
+
updateAt(key: K, updateFn: (current: V) => V): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a writable, reactive Map signal with full Map-like API and helpers.
|
|
75
|
+
*
|
|
76
|
+
* This factory returns a signal wrapping a JavaScript `Map`, exposing both non-mutating and mutating methods
|
|
77
|
+
* for convenient and fully reactive manipulation of key-value pairs.
|
|
78
|
+
*
|
|
79
|
+
* All mutator methods (`setKey`, `delete`, `clear`, `setMap`, etc.) always replace the Map with a cloned version,
|
|
80
|
+
* ensuring immutability for predictable reactivity.
|
|
81
|
+
*
|
|
82
|
+
* The signal also provides computed signals for common queries (such as `isEmpty`, `size`, `entriesArray`, `keysArray`, `valuesArray`),
|
|
83
|
+
* and offers a type-safe, readonly view via `.asReadonly()`.
|
|
84
|
+
*
|
|
85
|
+
* @template K The type of keys.
|
|
86
|
+
* @template V The type of values.
|
|
87
|
+
* @param {Iterable<[K, V]>} [initialValue=[]] Optional initial map contents, as entries or another Map.
|
|
88
|
+
* @returns {WritableMapSignal<K, V>} A writable Map signal instance with both native and Map-specific helpers.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const map = mapSignal<string, number>([['a', 1], ['b', 2]]);
|
|
92
|
+
* map.setKey('c', 3); // Adds key 'c'
|
|
93
|
+
* map.delete('a'); // Removes key 'a'
|
|
94
|
+
* map.update(m => { m.set('d', 4); return m; });
|
|
95
|
+
* map.entriesArray(); // [['b', 2], ['c', 3], ['d', 4]]
|
|
96
|
+
*/
|
|
97
|
+
export declare function mapSignal<K, V>(initialValue?: Iterable<[K, V]>): WritableMapSignal<K, V>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './persistent-signal';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
export interface PersistentSignalNonNullable<T> extends Signal<T> {
|
|
3
|
+
readonly method: PersistentStorageMethod;
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly serialized: Signal<string | null>;
|
|
6
|
+
}
|
|
7
|
+
export interface PersistentSignal<T> extends PersistentSignalNonNullable<T | null> {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A `PersistentSignal` is a specialized type of `WritableSignal` that automatically persists its value using a specified storage method (localStorage, sessionStorage, or cookies). It extends the standard `WritableSignal` interface by including additional properties to define the persistence mechanism and key used for storage. The `PersistentSignal` ensures that any changes to its value are saved to the chosen storage method, and it initializes its value from storage if available when created.
|
|
11
|
+
*/
|
|
12
|
+
export interface WritablePersistentSignalNonNullable<T> extends WritableSignal<T>, PersistentSignalNonNullable<T> {
|
|
13
|
+
asReadonly(): PersistentSignalNonNullable<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface WritablePersistentSignal<T> extends WritablePersistentSignalNonNullable<T | null> {
|
|
16
|
+
clear(): void;
|
|
17
|
+
asReadonly(): PersistentSignal<T>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines the available persistent storage methods for the `persistentSignal`. Each method corresponds to a different browser storage mechanism:
|
|
21
|
+
* - `PersistentStorageMethod.LocalStorage`: Uses the browser's localStorage to persist the value across sessions.
|
|
22
|
+
* - `PersistentStorageMethod.SessionStorage`: Uses the browser's sessionStorage to persist the value for the duration of the page session.
|
|
23
|
+
* - `PersistentStorageMethod.Cookies`: Uses browser cookies to persist the value, allowing for additional options like expiration and path.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PersistentStorageMethod: {
|
|
26
|
+
readonly Cookies: "cookies";
|
|
27
|
+
readonly LocalStorage: "local-storage";
|
|
28
|
+
readonly SessionStorage: "session-storage";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Defines the available persistent storage methods for the `persistentSignal`. Each method corresponds to a different browser storage mechanism:
|
|
32
|
+
* - `PersistentStorageMethod.LocalStorage`: Uses the browser's localStorage to persist the value across sessions.
|
|
33
|
+
* - `PersistentStorageMethod.SessionStorage`: Uses the browser's sessionStorage to persist the value for the duration of the page session.
|
|
34
|
+
* - `PersistentStorageMethod.Cookies`: Uses browser cookies to persist the value, allowing for additional options like expiration and path.
|
|
35
|
+
*/
|
|
36
|
+
export type PersistentStorageMethod = (typeof PersistentStorageMethod)[keyof typeof PersistentStorageMethod];
|
|
37
|
+
interface _PersistentSignalOptionsBase<T> {
|
|
38
|
+
/**
|
|
39
|
+
* The persistent storage method to use for storing the signal value. Options include:
|
|
40
|
+
* - `PersistentStorageMethod.LocalStorage`: Uses the browser's localStorage to persist the value across sessions.
|
|
41
|
+
* - `PersistentStorageMethod.SessionStorage`: Uses the browser's sessionStorage to persist the value for the duration of the page session.
|
|
42
|
+
* - `PersistentStorageMethod.Cookies`: Uses browser cookies to persist the value, allowing for additional options like expiration and path.
|
|
43
|
+
*/
|
|
44
|
+
method: PersistentStorageMethod;
|
|
45
|
+
/**
|
|
46
|
+
* Cookie-specific option: Defines the expiration date of the cookie. Can be a `Date` object or a string in UTC format. If not specified, the cookie will be a session cookie and will expire when the browser is closed.
|
|
47
|
+
*/
|
|
48
|
+
expires?: Date | string;
|
|
49
|
+
/**
|
|
50
|
+
* Cookie-specific option: Defines the maximum age of the cookie in seconds. If both `expires` and `maxAge` are specified, `maxAge` takes precedence. If not specified, the cookie will be a session cookie and will expire when the browser is closed.
|
|
51
|
+
*/
|
|
52
|
+
maxAge?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Cookie-specific option: Defines the path for which the cookie is valid. Defaults to `'/'`, making the cookie accessible across the entire site. If set to a specific path, the cookie will only be sent to the server for requests matching that path.
|
|
55
|
+
*/
|
|
56
|
+
path?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Optional serialization function to convert the signal value into a string for storage. This is required if the signal value is not a string or if you want to customize the serialization format. The function should return a string representation of the value, or `null` if the value is `null`.
|
|
59
|
+
* @param value The value to serialize, which can be of type `T` or `null`.
|
|
60
|
+
* @returns A string representation of the value for storage, or `null` if the value is `null`.
|
|
61
|
+
*/
|
|
62
|
+
serialize?: (value: T | null) => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Optional deserialization function to convert the stored string value back into the original type `T`. This is required if a custom `serialize` function is provided, or if the initial value is not a string and serialization options are not defined. The function should return the deserialized value of type `T`, or `null` if the input value is `null`.
|
|
65
|
+
* @param value The string value retrieved from storage that needs to be deserialized back into the original type `T`. This function is required if a custom `serialize` function is provided, or if the initial value is not a string and serialization options are not defined. The function should return the deserialized value of type `T`, or `null` if the input value is `null`.
|
|
66
|
+
* @returns The deserialized value of type `T`, or `null` if the input value is `null`.
|
|
67
|
+
*/
|
|
68
|
+
deserialize?: (value: string) => T | null;
|
|
69
|
+
/**
|
|
70
|
+
* If true, creates a non-nullable persistent signal interface.
|
|
71
|
+
*/
|
|
72
|
+
nonNullable?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface _PersistentSignalOptionsDeprecated<T> extends _PersistentSignalOptionsBase<T> {
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `key` instead. The name/key used to store the signal value in the chosen storage method.
|
|
77
|
+
*/
|
|
78
|
+
name: string;
|
|
79
|
+
}
|
|
80
|
+
interface _PersistentSignalOptions<T> extends _PersistentSignalOptionsBase<T> {
|
|
81
|
+
/**
|
|
82
|
+
* The name/key used to store the signal value in the chosen storage method.
|
|
83
|
+
*/
|
|
84
|
+
key: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for persisting the signal value.
|
|
88
|
+
*/
|
|
89
|
+
export type PersistentSignalOptions<T> = _PersistentSignalOptionsDeprecated<T> | _PersistentSignalOptions<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a `WritableSignal` that persists its value using the specified storage method,
|
|
92
|
+
* with custom serialization and deserialization.
|
|
93
|
+
*
|
|
94
|
+
* @param initialValue - The initial value of the signal if no stored value is found.
|
|
95
|
+
* @param options - An object containing the storage method and custom serialization/deserialization functions.
|
|
96
|
+
* @param options.name - The key used to store the signal value.
|
|
97
|
+
* @param options.method - The persistent storage method (localStorage, sessionStorage, or cookies).
|
|
98
|
+
* @param options.serialize - A function to serialize the value into a string for storage.
|
|
99
|
+
* @param options.deserialize - A function to deserialize the stored string value back into the original type.
|
|
100
|
+
* @returns A `WritableSignal<T>` that persists its value using the specified storage method.
|
|
101
|
+
*/
|
|
102
|
+
export declare function persistentSignal<T>(initialValue: T, options: PersistentSignalOptions<T> & {
|
|
103
|
+
nonNullable: true;
|
|
104
|
+
}): WritablePersistentSignalNonNullable<T>;
|
|
105
|
+
export declare function persistentSignal<T>(initialValue: T | null, options: PersistentSignalOptions<T>): WritablePersistentSignal<T>;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query-param-signal';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
export interface QueryParamSignalNonNullable<T> extends Signal<T> {
|
|
3
|
+
readonly paramName: string;
|
|
4
|
+
readonly serialized: Signal<string | null>;
|
|
5
|
+
}
|
|
6
|
+
export interface QueryParamSignal<T> extends QueryParamSignalNonNullable<T | null> {
|
|
7
|
+
}
|
|
8
|
+
export interface WritableQueryParamSignalNonNullable<T> extends WritableSignal<T>, QueryParamSignalNonNullable<T> {
|
|
9
|
+
asReadonly(): QueryParamSignalNonNullable<T>;
|
|
10
|
+
}
|
|
11
|
+
export interface WritableQueryParamSignal<T> extends WritableQueryParamSignalNonNullable<T | null>, QueryParamSignal<T> {
|
|
12
|
+
clear(): void;
|
|
13
|
+
asReadonly(): QueryParamSignal<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface QueryParamSignalOptions<T> {
|
|
16
|
+
paramName: string;
|
|
17
|
+
serialize?: (value: T | null) => string | null;
|
|
18
|
+
deserialize?: (value: string) => T | null;
|
|
19
|
+
nonNullable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a `WritableSignal` that persists its value in a URL query parameter with both serialization and deserialization.
|
|
23
|
+
*
|
|
24
|
+
* @param initialValue - The initial value of the signal if no value is found in the query param.
|
|
25
|
+
* @param options - An object containing the query parameter name, and custom serialization/deserialization functions.
|
|
26
|
+
* @param options.paramName - The name of the query parameter used to store the signal value.
|
|
27
|
+
* @param options.serialize - A function to serialize the value into a string for the query parameter.
|
|
28
|
+
* @param options.deserialize - A function to deserialize the value from a string back to the original type.
|
|
29
|
+
* @param options.nonNullable - If true, returns a non-nullable signal interface.
|
|
30
|
+
* @returns A `WritableSignal<T | null>` that persists its value using the specified query parameter.
|
|
31
|
+
*/
|
|
32
|
+
export declare function queryParamSignal<T>(initialValue: T, options: QueryParamSignalOptions<T> & {
|
|
33
|
+
nonNullable: true;
|
|
34
|
+
}): WritableQueryParamSignalNonNullable<T>;
|
|
35
|
+
export declare function queryParamSignal<T>(initialValue: T | null, optionsOrParam: string | QueryParamSignalOptions<T>): WritableQueryParamSignal<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './queue-signal';
|