@angular-architects/ngrx-toolkit 0.4.0 → 18.0.0-rc.2.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/README.md +44 -1
- package/esm2022/lib/assertions/assertions.mjs +1 -1
- package/esm2022/lib/redux-connector/create-redux.mjs +1 -1
- package/esm2022/lib/redux-connector/rxjs-interop/redux-method.mjs +1 -1
- package/esm2022/lib/redux-connector/signal-redux-store.mjs +4 -4
- package/esm2022/lib/shared/empty.mjs +1 -1
- package/esm2022/lib/shared/prettify.mjs +2 -0
- package/esm2022/lib/shared/signal-store-models.mjs +2 -0
- package/esm2022/lib/with-call-state.mjs +5 -3
- package/esm2022/lib/with-data-service.mjs +73 -32
- package/esm2022/lib/with-devtools.mjs +3 -3
- package/esm2022/lib/with-pagination.mjs +70 -13
- package/esm2022/lib/with-redux.mjs +1 -1
- package/esm2022/lib/with-storage-sync.mjs +1 -1
- package/esm2022/lib/with-undo-redo.mjs +25 -11
- package/fesm2022/angular-architects-ngrx-toolkit.mjs +166 -52
- package/fesm2022/angular-architects-ngrx-toolkit.mjs.map +1 -1
- package/lib/redux-connector/signal-redux-store.d.ts +2 -2
- package/lib/shared/empty.d.ts +1 -1
- package/lib/shared/prettify.d.ts +3 -0
- package/lib/shared/signal-store-models.d.ts +36 -0
- package/lib/with-call-state.d.ts +11 -11
- package/lib/with-data-service.d.ts +16 -17
- package/lib/with-devtools.d.ts +5 -5
- package/lib/with-pagination.d.ts +51 -25
- package/lib/with-redux.d.ts +2 -3
- package/lib/with-storage-sync.d.ts +6 -8
- package/lib/with-undo-redo.d.ts +14 -15
- package/package.json +2 -2
package/lib/with-devtools.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { patchState as originalPatchState, SignalStoreFeature } from '@ngrx/signals';
|
|
2
|
-
import {
|
|
1
|
+
import { PartialStateUpdater, patchState as originalPatchState, SignalStoreFeature, StateSignal } from '@ngrx/signals';
|
|
2
|
+
import { Prettify } from './shared/prettify';
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
__REDUX_DEVTOOLS_EXTENSION__: {
|
|
@@ -13,7 +13,7 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
type EmptyFeatureResult = {
|
|
15
15
|
state: {};
|
|
16
|
-
|
|
16
|
+
computed: {};
|
|
17
17
|
methods: {};
|
|
18
18
|
};
|
|
19
19
|
export type Action = {
|
|
@@ -26,7 +26,7 @@ export declare function reset(): void;
|
|
|
26
26
|
/**
|
|
27
27
|
* @param name store's name as it should appear in the DevTools
|
|
28
28
|
*/
|
|
29
|
-
export declare function withDevtools<Input extends
|
|
29
|
+
export declare function withDevtools<Input extends EmptyFeatureResult>(name: string): SignalStoreFeature<Input, EmptyFeatureResult>;
|
|
30
30
|
type PatchFn = typeof originalPatchState extends (arg1: infer First, ...args: infer Rest) => infer Returner ? (state: First, action: string, ...rest: Rest) => Returner : never;
|
|
31
31
|
/**
|
|
32
32
|
* @deprecated Has been renamed to `updateState`
|
|
@@ -39,5 +39,5 @@ export declare const patchState: PatchFn;
|
|
|
39
39
|
* @param action name of action how it will show in DevTools
|
|
40
40
|
* @param updaters updater functions or objects
|
|
41
41
|
*/
|
|
42
|
-
export declare
|
|
42
|
+
export declare function updateState<State extends object>(state: StateSignal<State>, action: string, ...updaters: Array<Partial<Prettify<State>> | PartialStateUpdater<Prettify<State>>>): void;
|
|
43
43
|
export {};
|
package/lib/with-pagination.d.ts
CHANGED
|
@@ -7,14 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Signal } from '@angular/core';
|
|
9
9
|
import { SignalStoreFeature } from '@ngrx/signals';
|
|
10
|
-
import {
|
|
11
|
-
import { EntitySignals, EntityState, NamedEntitySignals } from '@ngrx/signals/entities/src/models';
|
|
12
|
-
import { Entity } from './with-data-service';
|
|
10
|
+
import { EntityComputed, EntityState, NamedEntityComputed } from './shared/signal-store-models';
|
|
13
11
|
export type Page = {
|
|
14
12
|
label: string | number;
|
|
15
13
|
value: number;
|
|
16
14
|
};
|
|
17
|
-
export type NamedPaginationServiceState<E
|
|
15
|
+
export type NamedPaginationServiceState<E, Collection extends string> = {
|
|
18
16
|
[K in Collection as `selectedPage${Capitalize<K>}Entities`]: Array<E>;
|
|
19
17
|
} & {
|
|
20
18
|
[K in Collection as `${Lowercase<K>}CurrentPage`]: number;
|
|
@@ -29,7 +27,7 @@ export type NamedPaginationServiceState<E extends Entity, Collection extends str
|
|
|
29
27
|
} & {
|
|
30
28
|
[K in Collection as `${Lowercase<K>}PageNavigationArrayMax`]: number;
|
|
31
29
|
};
|
|
32
|
-
export type NamedPaginationServiceSignals<E
|
|
30
|
+
export type NamedPaginationServiceSignals<E, Collection extends string> = {
|
|
33
31
|
[K in Collection as `selectedPage${Capitalize<K>}Entities`]: Signal<E[]>;
|
|
34
32
|
} & {
|
|
35
33
|
[K in Collection as `${Lowercase<K>}CurrentPage`]: Signal<number>;
|
|
@@ -43,8 +41,25 @@ export type NamedPaginationServiceSignals<E extends Entity, Collection extends s
|
|
|
43
41
|
[K in Collection as `${Lowercase<K>}PageNavigationArray`]: Signal<Page[]>;
|
|
44
42
|
} & {
|
|
45
43
|
[K in Collection as `${Lowercase<K>}PageNavigationArrayMax`]: Signal<number>;
|
|
44
|
+
} & {
|
|
45
|
+
[K in Collection as `hasNext${Capitalize<K>}Page`]: Signal<boolean>;
|
|
46
|
+
} & {
|
|
47
|
+
[K in Collection as `hasPrevious${Capitalize<K>}Page`]: Signal<boolean>;
|
|
46
48
|
};
|
|
47
|
-
export type
|
|
49
|
+
export type NamedPaginationServiceMethods<Collection extends string> = {
|
|
50
|
+
[K in Collection as `set${Capitalize<K>}PageSize`]: (size: number) => void;
|
|
51
|
+
} & {
|
|
52
|
+
[K in Collection as `next${Capitalize<K>}Page`]: () => void;
|
|
53
|
+
} & {
|
|
54
|
+
[K in Collection as `previous${Capitalize<K>}Page`]: () => void;
|
|
55
|
+
} & {
|
|
56
|
+
[K in Collection as `last${Capitalize<K>}Page`]: () => void;
|
|
57
|
+
} & {
|
|
58
|
+
[K in Collection as `first${Capitalize<K>}Page`]: () => void;
|
|
59
|
+
} & {
|
|
60
|
+
[K in Collection as `goto${Capitalize<K>}Page`]: (page: number) => void;
|
|
61
|
+
};
|
|
62
|
+
export type PaginationServiceState<E> = {
|
|
48
63
|
selectedPageEntities: Array<E>;
|
|
49
64
|
currentPage: number;
|
|
50
65
|
pageSize: number;
|
|
@@ -53,7 +68,7 @@ export type PaginationServiceState<E extends Entity> = {
|
|
|
53
68
|
pageNavigationArray: Page[];
|
|
54
69
|
pageNavigationArrayMax: number;
|
|
55
70
|
};
|
|
56
|
-
export type PaginationServiceSignals<E
|
|
71
|
+
export type PaginationServiceSignals<E> = {
|
|
57
72
|
selectedPageEntities: Signal<E[]>;
|
|
58
73
|
currentPage: Signal<number>;
|
|
59
74
|
pageSize: Signal<number>;
|
|
@@ -61,44 +76,55 @@ export type PaginationServiceSignals<E extends Entity> = {
|
|
|
61
76
|
pageCount: Signal<number>;
|
|
62
77
|
pageNavigationArray: Signal<Page[]>;
|
|
63
78
|
pageNavigationArrayMax: Signal<number>;
|
|
79
|
+
hasNextPage: Signal<boolean>;
|
|
80
|
+
hasPreviousPage: Signal<boolean>;
|
|
81
|
+
};
|
|
82
|
+
export type PaginationServiceMethods = {
|
|
83
|
+
setPageSize: (size: number) => void;
|
|
84
|
+
nextPageKey: () => void;
|
|
85
|
+
previousPage: () => void;
|
|
86
|
+
lastPage: () => void;
|
|
87
|
+
firstPage: () => void;
|
|
88
|
+
gotoPage: (page: number) => void;
|
|
64
89
|
};
|
|
65
|
-
export type SetPaginationState<E
|
|
66
|
-
export declare function withPagination<E
|
|
90
|
+
export type SetPaginationState<E, Collection extends string | undefined> = Collection extends string ? NamedPaginationServiceState<E, Collection> : PaginationServiceState<E>;
|
|
91
|
+
export declare function withPagination<E, Collection extends string>(options: {
|
|
92
|
+
entity: E;
|
|
67
93
|
collection: Collection;
|
|
68
94
|
}): SignalStoreFeature<{
|
|
69
|
-
state:
|
|
70
|
-
|
|
71
|
-
methods:
|
|
95
|
+
state: {};
|
|
96
|
+
computed: NamedEntityComputed<E, Collection>;
|
|
97
|
+
methods: {};
|
|
72
98
|
}, {
|
|
73
99
|
state: NamedPaginationServiceState<E, Collection>;
|
|
74
|
-
|
|
75
|
-
methods:
|
|
100
|
+
computed: NamedPaginationServiceSignals<E, Collection>;
|
|
101
|
+
methods: NamedPaginationServiceMethods<Collection>;
|
|
76
102
|
}>;
|
|
77
|
-
export declare function withPagination<E
|
|
103
|
+
export declare function withPagination<E>(): SignalStoreFeature<{
|
|
78
104
|
state: EntityState<E>;
|
|
79
|
-
|
|
80
|
-
methods:
|
|
105
|
+
computed: EntityComputed<E>;
|
|
106
|
+
methods: {};
|
|
81
107
|
}, {
|
|
82
108
|
state: PaginationServiceState<E>;
|
|
83
|
-
|
|
84
|
-
methods:
|
|
109
|
+
computed: PaginationServiceSignals<E>;
|
|
110
|
+
methods: PaginationServiceMethods;
|
|
85
111
|
}>;
|
|
86
|
-
export declare function gotoPage<E
|
|
112
|
+
export declare function gotoPage<E, Collection extends string>(page: number, options?: {
|
|
87
113
|
collection: Collection;
|
|
88
114
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
89
|
-
export declare function setPageSize<E
|
|
115
|
+
export declare function setPageSize<E, Collection extends string>(pageSize: number, options?: {
|
|
90
116
|
collection: Collection;
|
|
91
117
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
92
|
-
export declare function nextPage<E
|
|
118
|
+
export declare function nextPage<E, Collection extends string>(options?: {
|
|
93
119
|
collection: Collection;
|
|
94
120
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
95
|
-
export declare function previousPage<E
|
|
121
|
+
export declare function previousPage<E, Collection extends string>(options?: {
|
|
96
122
|
collection: Collection;
|
|
97
123
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
98
|
-
export declare function firstPage<E
|
|
124
|
+
export declare function firstPage<E, Collection extends string>(options?: {
|
|
99
125
|
collection: Collection;
|
|
100
126
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
101
|
-
export declare function setMaxPageNavigationArrayItems<E
|
|
127
|
+
export declare function setMaxPageNavigationArrayItems<E, Collection extends string>(maxPageNavigationArrayItems: number, options?: {
|
|
102
128
|
collection: Collection;
|
|
103
129
|
}): Partial<SetPaginationState<E, Collection>>;
|
|
104
130
|
export declare function createPageArray(currentPage: number, itemsPerPage: number, totalItems: number, paginationRange: number): Page[];
|
package/lib/with-redux.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { SignalStoreFeature } from '@ngrx/signals';
|
|
3
|
-
import { EmptyFeatureResult, SignalStoreFeatureResult } from '
|
|
4
|
-
import { StateSignal } from '@ngrx/signals/src/state-signal';
|
|
2
|
+
import { SignalStoreFeature, StateSignal } from '@ngrx/signals';
|
|
3
|
+
import { EmptyFeatureResult, SignalStoreFeatureResult } from './shared/signal-store-models';
|
|
5
4
|
/** Actions **/
|
|
6
5
|
type Payload = Record<string, unknown>;
|
|
7
6
|
type ActionFn<Type extends string = string, ActionPayload extends Payload = Payload> = ((payload: ActionPayload) => ActionPayload & {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SignalStoreFeature } from '@ngrx/signals';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
state: State;
|
|
5
|
-
};
|
|
2
|
+
import { Empty } from './shared/empty';
|
|
3
|
+
import { SignalStoreFeatureResult } from './shared/signal-store-models';
|
|
6
4
|
type WithStorageSyncFeatureResult = {
|
|
7
|
-
state:
|
|
8
|
-
|
|
5
|
+
state: Empty;
|
|
6
|
+
computed: Empty;
|
|
9
7
|
methods: {
|
|
10
8
|
clearStorage(): void;
|
|
11
9
|
readFromStorage(): void;
|
|
@@ -53,6 +51,6 @@ export type SyncConfig<State> = {
|
|
|
53
51
|
*
|
|
54
52
|
* Only works on browser platform.
|
|
55
53
|
*/
|
|
56
|
-
export declare function withStorageSync<State extends object, Input extends
|
|
57
|
-
export declare function withStorageSync<State extends object, Input extends
|
|
54
|
+
export declare function withStorageSync<State extends object, Input extends SignalStoreFeatureResult>(key: string): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
|
|
55
|
+
export declare function withStorageSync<State extends object, Input extends SignalStoreFeatureResult>(config: SyncConfig<Input['state']>): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
|
|
58
56
|
export {};
|
package/lib/with-undo-redo.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { SignalStoreFeature } from
|
|
2
|
-
import { EntityId, EntityMap, EntityState } from
|
|
3
|
-
import { Signal } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Emtpy } from "./shared/empty";
|
|
1
|
+
import { SignalStoreFeature } from '@ngrx/signals';
|
|
2
|
+
import { EntityId, EntityMap, EntityState } from '@ngrx/signals/entities';
|
|
3
|
+
import { Signal } from '@angular/core';
|
|
4
|
+
import { Entity } from './with-data-service';
|
|
5
|
+
import { EntityComputed, NamedEntityComputed } from './shared/signal-store-models';
|
|
7
6
|
export type StackItem = Record<string, unknown>;
|
|
8
7
|
export type NormalizedUndoRedoOptions = {
|
|
9
8
|
maxStackSize: number;
|
|
@@ -22,12 +21,12 @@ export declare function withUndoRedo<Collection extends string>(options?: {
|
|
|
22
21
|
maxStackSize?: number;
|
|
23
22
|
collections: Collection[];
|
|
24
23
|
}): SignalStoreFeature<{
|
|
25
|
-
state:
|
|
26
|
-
|
|
27
|
-
methods:
|
|
24
|
+
state: {};
|
|
25
|
+
computed: NamedEntityComputed<Entity, Collection>;
|
|
26
|
+
methods: {};
|
|
28
27
|
}, {
|
|
29
|
-
state:
|
|
30
|
-
|
|
28
|
+
state: {};
|
|
29
|
+
computed: {
|
|
31
30
|
canUndo: Signal<boolean>;
|
|
32
31
|
canRedo: Signal<boolean>;
|
|
33
32
|
};
|
|
@@ -40,11 +39,11 @@ export declare function withUndoRedo(options?: {
|
|
|
40
39
|
maxStackSize?: number;
|
|
41
40
|
}): SignalStoreFeature<{
|
|
42
41
|
state: EntityState<Entity>;
|
|
43
|
-
|
|
44
|
-
methods:
|
|
42
|
+
computed: EntityComputed<Entity>;
|
|
43
|
+
methods: {};
|
|
45
44
|
}, {
|
|
46
|
-
state:
|
|
47
|
-
|
|
45
|
+
state: {};
|
|
46
|
+
computed: {
|
|
48
47
|
canUndo: Signal<boolean>;
|
|
49
48
|
canRedo: Signal<boolean>;
|
|
50
49
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-architects/ngrx-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "18.0.0-rc.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "GitHub",
|
|
7
7
|
"url": "https://github.com/angular-architects/ngrx-toolkit"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@ngrx/signals": "
|
|
10
|
+
"@ngrx/signals": "18.0.0-rc.2"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"tslib": "^2.3.0"
|