ngx-lift 0.5.0 → 1.1.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.
@@ -0,0 +1,4 @@
1
+ export declare function createNotifier(): {
2
+ notify: () => void;
3
+ listen: import("@angular/core").Signal<number>;
4
+ };
@@ -0,0 +1,5 @@
1
+ export * from './combine-from';
2
+ export * from './computed-async';
3
+ export * from './create-notifier';
4
+ export * from './inject-params';
5
+ export * from './inject-query-params';
@@ -0,0 +1,18 @@
1
+ import { type Signal } from '@angular/core';
2
+ import { type Params } from '@angular/router';
3
+ /**
4
+ * Injects the params from the current route.
5
+ * If a key is provided, returns the value of that key.
6
+ * If a transform function is provided, returns the result of the function.
7
+ * Otherwise, returns the entire params object.
8
+ *
9
+ * @example
10
+ * const userId = injectParams('id'); // Returns the value of the 'id' param
11
+ * const userId = injectParams(p => p['id'] as string); // Returns the 'id' param using a custom transform function
12
+ * const params = injectParams(); // Returns the entire params object
13
+ *
14
+ * @param keyOrTransform OPTIONAL The key of the param to return, or a transform function to apply to the params object
15
+ */
16
+ export declare function injectParams(): Signal<Params>;
17
+ export declare function injectParams(key: string): Signal<string | null>;
18
+ export declare function injectParams<T>(transform: (params: Params) => T): Signal<T>;
@@ -0,0 +1,71 @@
1
+ import { type Signal } from '@angular/core';
2
+ import { type Params } from '@angular/router';
3
+ type QueryParamsTransformFn<Output> = (params: Params) => Output;
4
+ /**
5
+ * The `InputOptions` interface defines options for configuring the behavior of the `injectQueryParams` function.
6
+ *
7
+ * @template Output - The expected type of the read value.
8
+ */
9
+ export interface QueryParamsOptions<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 query parameter is not present or undefined.
19
+ */
20
+ initialValue?: Output;
21
+ }
22
+ /**
23
+ * The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
24
+ *
25
+ * @returns A `Signal` that emits the entire query parameters object.
26
+ */
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
+ /**
60
+ * The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
61
+ * It retrieves the value of a query parameter based on a custom transform function applied to the query parameters object.
62
+ *
63
+ * @template Output - The expected type of the read value.
64
+ * @param {QueryParamsTransformFn<Output>} fn - A transform function that takes the query parameters object (`params: Params`) and returns the desired value.
65
+ * @returns {Signal} A `Signal` that emits the transformed value based on the provided custom transform function.
66
+ *
67
+ * @example
68
+ * const searchValue = injectQueryParams((params) => params['search'] as string);
69
+ */
70
+ export declare function injectQueryParams<Output>(fn: QueryParamsTransformFn<Output>): Signal<Output>;
71
+ export {};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "ngx-lift",
3
- "version": "0.5.0",
3
+ "version": "1.1.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": {
7
- "@angular/common": ">=15.0.0",
8
- "@angular/core": ">=15.0.0",
7
+ "@angular/common": ">=17.0.0",
8
+ "@angular/core": ">=17.0.0",
9
9
  "rxjs": ">=7.8.0"
10
10
  },
11
11
  "dependencies": {
package/public-api.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './lib/models';
2
2
  export * from './lib/operators';
3
3
  export * from './lib/pipes';
4
+ export * from './lib/signals';
4
5
  export * from './lib/utils';
5
6
  export * from './lib/validators';