@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.
@@ -1,5 +1,5 @@
1
- import { patchState as originalPatchState, SignalStoreFeature } from '@ngrx/signals';
2
- import { SignalStoreFeatureResult } from '@ngrx/signals/src/signal-store-models';
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
- signals: {};
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 SignalStoreFeatureResult>(name: string): SignalStoreFeature<Input, EmptyFeatureResult>;
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 const updateState: PatchFn;
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 {};
@@ -7,14 +7,12 @@
7
7
  */
8
8
  import { Signal } from '@angular/core';
9
9
  import { SignalStoreFeature } from '@ngrx/signals';
10
- import { Emtpy } from './shared/empty';
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 extends Entity, Collection extends string> = {
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 extends Entity, Collection extends string> = {
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 PaginationServiceState<E extends Entity> = {
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 extends Entity> = {
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 extends Entity, Collection extends string | undefined> = Collection extends string ? NamedPaginationServiceState<E, Collection> : PaginationServiceState<E>;
66
- export declare function withPagination<E extends Entity, Collection extends string>(options: {
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: Emtpy;
70
- signals: NamedEntitySignals<E, Collection>;
71
- methods: Emtpy;
95
+ state: {};
96
+ computed: NamedEntityComputed<E, Collection>;
97
+ methods: {};
72
98
  }, {
73
99
  state: NamedPaginationServiceState<E, Collection>;
74
- signals: NamedPaginationServiceSignals<E, Collection>;
75
- methods: Emtpy;
100
+ computed: NamedPaginationServiceSignals<E, Collection>;
101
+ methods: NamedPaginationServiceMethods<Collection>;
76
102
  }>;
77
- export declare function withPagination<E extends Entity>(): SignalStoreFeature<{
103
+ export declare function withPagination<E>(): SignalStoreFeature<{
78
104
  state: EntityState<E>;
79
- signals: EntitySignals<E>;
80
- methods: Emtpy;
105
+ computed: EntityComputed<E>;
106
+ methods: {};
81
107
  }, {
82
108
  state: PaginationServiceState<E>;
83
- signals: PaginationServiceSignals<E>;
84
- methods: Emtpy;
109
+ computed: PaginationServiceSignals<E>;
110
+ methods: PaginationServiceMethods;
85
111
  }>;
86
- export declare function gotoPage<E extends Entity, Collection extends string>(page: number, options?: {
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 extends Entity, Collection extends string>(pageSize: number, options?: {
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 extends Entity, Collection extends string>(options?: {
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 extends Entity, Collection extends string>(options?: {
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 extends Entity, Collection extends string>(options?: {
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 extends Entity, Collection extends string>(maxPageNavigationArrayItems: number, options?: {
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[];
@@ -1,7 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
- import { SignalStoreFeature } from '@ngrx/signals';
3
- import { EmptyFeatureResult, SignalStoreFeatureResult } from '@ngrx/signals/src/signal-store-models';
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 { Emtpy } from './shared/empty';
3
- type SignalStoreFeatureInput<State> = Pick<Parameters<SignalStoreFeature>[0], 'signals' | 'methods'> & {
4
- state: State;
5
- };
2
+ import { Empty } from './shared/empty';
3
+ import { SignalStoreFeatureResult } from './shared/signal-store-models';
6
4
  type WithStorageSyncFeatureResult = {
7
- state: Emtpy;
8
- signals: Emtpy;
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 SignalStoreFeatureInput<State>>(key: string): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
57
- export declare function withStorageSync<State extends object, Input extends SignalStoreFeatureInput<State>>(config: SyncConfig<Input['state']>): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
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 {};
@@ -1,9 +1,8 @@
1
- import { SignalStoreFeature } from "@ngrx/signals";
2
- import { EntityId, EntityMap, EntityState } from "@ngrx/signals/entities";
3
- import { Signal } from "@angular/core";
4
- import { EntitySignals, NamedEntitySignals } from "@ngrx/signals/entities/src/models";
5
- import { Entity } from "./with-data-service";
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: Emtpy;
26
- signals: NamedEntitySignals<Entity, Collection>;
27
- methods: Emtpy;
24
+ state: {};
25
+ computed: NamedEntityComputed<Entity, Collection>;
26
+ methods: {};
28
27
  }, {
29
- state: Emtpy;
30
- signals: {
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
- signals: EntitySignals<Entity>;
44
- methods: Emtpy;
42
+ computed: EntityComputed<Entity>;
43
+ methods: {};
45
44
  }, {
46
- state: Emtpy;
47
- signals: {
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.4.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": "^17.2.0"
10
+ "@ngrx/signals": "18.0.0-rc.2"
11
11
  },
12
12
  "dependencies": {
13
13
  "tslib": "^2.3.0"