ngx-lift 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/pipes/byte-converter.pipe.mjs +6 -9
- package/esm2022/lib/signals/combine-from.mjs +3 -3
- package/esm2022/lib/signals/create-trigger.mjs +11 -0
- package/esm2022/lib/signals/index.mjs +3 -2
- package/esm2022/lib/signals/inject-params.mjs +27 -7
- package/esm2022/lib/signals/inject-query-params.mjs +8 -5
- package/esm2022/lib/signals/merge-from.mjs +71 -0
- package/fesm2022/ngx-lift.mjs +112 -24
- package/fesm2022/ngx-lift.mjs.map +1 -1
- package/lib/pipes/byte-converter.pipe.d.ts +0 -1
- package/lib/signals/combine-from.d.ts +17 -7
- package/lib/signals/create-trigger.d.ts +4 -0
- package/lib/signals/index.d.ts +2 -1
- package/lib/signals/inject-params.d.ts +48 -3
- package/lib/signals/inject-query-params.d.ts +31 -31
- package/lib/signals/merge-from.d.ts +13 -0
- package/package.json +1 -1
- package/esm2022/lib/signals/create-notifier.mjs +0 -11
- package/lib/signals/create-notifier.d.ts +0 -4
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { Injector, Signal } from '@angular/core';
|
|
2
2
|
import { ObservableInput, OperatorFunction } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
export type CombineFromOptions<T> = {
|
|
5
|
-
readonly injector?: Injector;
|
|
6
|
-
readonly initialValue?: T | null;
|
|
7
|
-
};
|
|
3
|
+
type ObservableSignalInput<T> = ObservableInput<T> | Signal<T>;
|
|
8
4
|
type ObservableSignalInputTuple<T> = {
|
|
9
5
|
[K in keyof T]: ObservableSignalInput<T[K]> | (() => T[K]);
|
|
10
6
|
};
|
|
7
|
+
export type CombineFromOptions<IValue> = {
|
|
8
|
+
readonly injector?: Injector;
|
|
9
|
+
readonly initialValue?: IValue;
|
|
10
|
+
};
|
|
11
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>]): Signal<Output>;
|
|
12
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
13
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
11
14
|
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
12
|
-
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: CombineFromOptions<
|
|
15
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
16
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
17
|
+
export declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: CombineFromOptions<Output>): Signal<Output>;
|
|
18
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>): Signal<Output>;
|
|
19
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
20
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
13
21
|
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
14
|
-
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, options?: CombineFromOptions<
|
|
22
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
23
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
24
|
+
export declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple<Input>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
15
25
|
export {};
|
package/lib/signals/index.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { type Signal } from '@angular/core';
|
|
2
2
|
import { type Params } from '@angular/router';
|
|
3
|
+
type ParamsTransformFn<Output> = (params: Params) => Output;
|
|
4
|
+
/**
|
|
5
|
+
* The `InputOptions` interface defines options for configuring the behavior of the `injectParams` function.
|
|
6
|
+
*
|
|
7
|
+
* @template Output - The expected type of the read value.
|
|
8
|
+
*/
|
|
9
|
+
export interface ParamsOptions<Output> {
|
|
10
|
+
/**
|
|
11
|
+
* A transformation function to convert the written value to the expected read value.
|
|
12
|
+
*
|
|
13
|
+
* @param v - The value to transform.
|
|
14
|
+
* @returns The transformed value.
|
|
15
|
+
*/
|
|
16
|
+
transform?: (v: string) => Output;
|
|
17
|
+
/**
|
|
18
|
+
* The initial value to use if the parameter is not present or undefined.
|
|
19
|
+
*/
|
|
20
|
+
initialValue?: Output;
|
|
21
|
+
}
|
|
3
22
|
/**
|
|
4
23
|
* Injects the params from the current route.
|
|
5
24
|
* If a key is provided, returns the value of that key.
|
|
@@ -7,12 +26,38 @@ import { type Params } from '@angular/router';
|
|
|
7
26
|
* Otherwise, returns the entire params object.
|
|
8
27
|
*
|
|
9
28
|
* @example
|
|
29
|
+
* const params = injectParams(); // Returns the entire params object
|
|
10
30
|
* const userId = injectParams('id'); // Returns the value of the 'id' param
|
|
11
31
|
* const userId = injectParams(p => p['id'] as string); // Returns the 'id' param using a custom transform function
|
|
12
|
-
* const
|
|
32
|
+
* const userId = injectParams('id', { transform: numberAttribute, initialValue: 1 });
|
|
13
33
|
*
|
|
14
|
-
* @param
|
|
34
|
+
* @param keyOrParamsTransform OPTIONAL The key of the param to return, or a transform function to apply to the params object
|
|
15
35
|
*/
|
|
16
36
|
export declare function injectParams(): Signal<Params>;
|
|
37
|
+
export declare function injectParams<Output>(fn: ParamsTransformFn<Output>): Signal<Output>;
|
|
17
38
|
export declare function injectParams(key: string): Signal<string | null>;
|
|
18
|
-
export declare function injectParams
|
|
39
|
+
export declare function injectParams(key: string, options: {
|
|
40
|
+
transform: (v: string) => boolean;
|
|
41
|
+
initialValue: boolean;
|
|
42
|
+
}): Signal<boolean>;
|
|
43
|
+
export declare function injectParams(key: string, options: {
|
|
44
|
+
transform: (v: string) => number;
|
|
45
|
+
initialValue: number;
|
|
46
|
+
}): Signal<number>;
|
|
47
|
+
export declare function injectParams(key: string, options: {
|
|
48
|
+
transform?: (v: string) => string;
|
|
49
|
+
initialValue: string;
|
|
50
|
+
}): Signal<string>;
|
|
51
|
+
export declare function injectParams(key: string, options: {
|
|
52
|
+
transform: (v: string) => boolean;
|
|
53
|
+
initialValue?: undefined;
|
|
54
|
+
}): Signal<boolean | null>;
|
|
55
|
+
export declare function injectParams(key: string, options: {
|
|
56
|
+
transform: (v: string) => number;
|
|
57
|
+
initialValue?: undefined;
|
|
58
|
+
}): Signal<number | null>;
|
|
59
|
+
export declare function injectParams(key: string, options: {
|
|
60
|
+
transform: (v: string) => string;
|
|
61
|
+
initialValue?: undefined;
|
|
62
|
+
}): Signal<string | null>;
|
|
63
|
+
export {};
|
|
@@ -25,37 +25,6 @@ export interface QueryParamsOptions<Output> {
|
|
|
25
25
|
* @returns A `Signal` that emits the entire query parameters object.
|
|
26
26
|
*/
|
|
27
27
|
export declare function injectQueryParams(): Signal<Params>;
|
|
28
|
-
/**
|
|
29
|
-
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
30
|
-
*
|
|
31
|
-
* @param {string} key - The name of the query parameter to retrieve.
|
|
32
|
-
* @returns {Signal} A `Signal` that emits the value of the specified query parameter, or `null` if it's not present.
|
|
33
|
-
*/
|
|
34
|
-
export declare function injectQueryParams(key: string): Signal<string | null>;
|
|
35
|
-
/**
|
|
36
|
-
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
37
|
-
*
|
|
38
|
-
* @param {string} key - The name of the query parameter to retrieve.
|
|
39
|
-
* @param {QueryParamsOptions} options - Optional configuration options for the query parameter.
|
|
40
|
-
* @returns {Signal} A `Signal` that emits the transformed value of the specified query parameter, or `null` if it's not present.
|
|
41
|
-
*/
|
|
42
|
-
export declare function injectQueryParams(key?: string, options?: QueryParamsOptions<boolean>): Signal<boolean | null>;
|
|
43
|
-
/**
|
|
44
|
-
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} key - The name of the query parameter to retrieve.
|
|
47
|
-
* @param {QueryParamsOptions} options - Optional configuration options for the query parameter.
|
|
48
|
-
* @returns {Signal} A `Signal` that emits the transformed value of the specified query parameter, or `null` if it's not present.
|
|
49
|
-
*/
|
|
50
|
-
export declare function injectQueryParams(key?: string, options?: QueryParamsOptions<number>): Signal<number | null>;
|
|
51
|
-
/**
|
|
52
|
-
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} key - The name of the query parameter to retrieve.
|
|
55
|
-
* @param {QueryParamsOptions} options - Optional configuration options for the query parameter.
|
|
56
|
-
* @returns {Signal} A `Signal` that emits the transformed value of the specified query parameter, or `null` if it's not present.
|
|
57
|
-
*/
|
|
58
|
-
export declare function injectQueryParams(key?: string, options?: QueryParamsOptions<string>): Signal<string | null>;
|
|
59
28
|
/**
|
|
60
29
|
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
61
30
|
* It retrieves the value of a query parameter based on a custom transform function applied to the query parameters object.
|
|
@@ -68,4 +37,35 @@ export declare function injectQueryParams(key?: string, options?: QueryParamsOpt
|
|
|
68
37
|
* const searchValue = injectQueryParams((params) => params['search'] as string);
|
|
69
38
|
*/
|
|
70
39
|
export declare function injectQueryParams<Output>(fn: QueryParamsTransformFn<Output>): Signal<Output>;
|
|
40
|
+
/**
|
|
41
|
+
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} key - The name of the query parameter to retrieve.
|
|
44
|
+
* @returns {Signal} A `Signal` that emits the value of the specified query parameter, or `null` if it's not present.
|
|
45
|
+
*/
|
|
46
|
+
export declare function injectQueryParams(key: string): Signal<string | null>;
|
|
47
|
+
export declare function injectQueryParams(key: string, options: {
|
|
48
|
+
transform: (v: string) => boolean;
|
|
49
|
+
initialValue: boolean;
|
|
50
|
+
}): Signal<boolean>;
|
|
51
|
+
export declare function injectQueryParams(key: string, options: {
|
|
52
|
+
transform: (v: string) => number;
|
|
53
|
+
initialValue: number;
|
|
54
|
+
}): Signal<number>;
|
|
55
|
+
export declare function injectQueryParams(key: string, options: {
|
|
56
|
+
transform?: (v: string) => string;
|
|
57
|
+
initialValue: string;
|
|
58
|
+
}): Signal<string>;
|
|
59
|
+
export declare function injectQueryParams(key: string, options: {
|
|
60
|
+
transform: (v: string) => boolean;
|
|
61
|
+
initialValue?: undefined;
|
|
62
|
+
}): Signal<boolean | null>;
|
|
63
|
+
export declare function injectQueryParams(key: string, options: {
|
|
64
|
+
transform: (v: string) => number;
|
|
65
|
+
initialValue?: undefined;
|
|
66
|
+
}): Signal<number | null>;
|
|
67
|
+
export declare function injectQueryParams(key: string, options: {
|
|
68
|
+
transform: (v: string) => string;
|
|
69
|
+
initialValue?: undefined;
|
|
70
|
+
}): Signal<string | null>;
|
|
71
71
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Injector, Signal } from '@angular/core';
|
|
2
|
+
import { ObservableInput, OperatorFunction } from 'rxjs';
|
|
3
|
+
type ObservableSignalInput<T> = ObservableInput<T> | Signal<T>;
|
|
4
|
+
type ObservableSignalInputTuple<T> = {
|
|
5
|
+
[K in keyof T]: ObservableSignalInput<T[K]>;
|
|
6
|
+
};
|
|
7
|
+
export type MergeFromOptions<T> = {
|
|
8
|
+
readonly injector?: Injector;
|
|
9
|
+
readonly initialValue?: T | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function mergeFrom<Input extends readonly unknown[], Output = Input[number]>(sources: readonly [...ObservableSignalInputTuple<Input>], operator?: OperatorFunction<Input[number], Output>, options?: MergeFromOptions<Output>): Signal<Output>;
|
|
12
|
+
export declare function mergeFrom<Input extends readonly unknown[], Output = Input[number]>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: MergeFromOptions<Output>): Signal<Output>;
|
|
13
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-lift",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A project has been crafted with the goal of enhancing and simplifying your Angular development experience.",
|
|
5
5
|
"author": "Guanghui Wang <guanghui-wang@foxmail.com>",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { signal } from '@angular/core';
|
|
2
|
-
export function createNotifier() {
|
|
3
|
-
const sourceSignal = signal(0);
|
|
4
|
-
return {
|
|
5
|
-
notify: () => {
|
|
6
|
-
sourceSignal.update((v) => v + 1);
|
|
7
|
-
},
|
|
8
|
-
listen: sourceSignal.asReadonly(),
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLW5vdGlmaWVyLmpzIiwic291cmNlUm9vdCI6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