@smallpearl/ngx-helper 0.33.50 → 20.0.3

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.
Files changed (119) hide show
  1. package/core/index.d.ts +3 -1
  2. package/entities/index.d.ts +313 -2
  3. package/entity-field/index.d.ts +101 -2
  4. package/fesm2022/smallpearl-ngx-helper-entities.mjs +18 -18
  5. package/fesm2022/smallpearl-ngx-helper-entities.mjs.map +1 -1
  6. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +5 -4
  7. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -1
  8. package/fesm2022/smallpearl-ngx-helper-forms.mjs.map +1 -1
  9. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs +6 -6
  10. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs.map +1 -1
  11. package/fesm2022/smallpearl-ngx-helper-locale.mjs +6 -6
  12. package/fesm2022/smallpearl-ngx-helper-locale.mjs.map +1 -1
  13. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs +57 -31
  14. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs.map +1 -1
  15. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +15 -15
  16. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -1
  17. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +346 -334
  18. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -1
  19. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +152 -146
  20. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -1
  21. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs +5 -5
  22. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs.map +1 -1
  23. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs +19 -19
  24. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs.map +1 -1
  25. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +25 -26
  26. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -1
  27. package/fesm2022/smallpearl-ngx-helper-mat-select-infinite-scroll.mjs +7 -7
  28. package/fesm2022/smallpearl-ngx-helper-mat-select-infinite-scroll.mjs.map +1 -1
  29. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs +24 -24
  30. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs.map +1 -1
  31. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs +8 -9
  32. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs.map +1 -1
  33. package/fesm2022/smallpearl-ngx-helper-sideload.mjs.map +1 -1
  34. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +35 -35
  35. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -1
  36. package/forms/index.d.ts +55 -1
  37. package/hover-dropdown/index.d.ts +44 -1
  38. package/index.d.ts +4 -5
  39. package/locale/index.d.ts +55 -5
  40. package/mat-busy-wheel/index.d.ts +165 -4
  41. package/mat-context-menu/index.d.ts +65 -1
  42. package/mat-entity-crud/index.d.ts +1075 -6
  43. package/mat-entity-list/index.d.ts +394 -3
  44. package/mat-file-input/index.d.ts +61 -1
  45. package/mat-form-error/index.d.ts +184 -6
  46. package/mat-select-entity/index.d.ts +194 -1
  47. package/mat-select-infinite-scroll/index.d.ts +45 -2
  48. package/mat-side-menu-layout/index.d.ts +180 -6
  49. package/mat-tel-input/index.d.ts +169 -2
  50. package/package.json +18 -13
  51. package/sideload/index.d.ts +20 -1
  52. package/stationary-with-line-items/index.d.ts +78 -1
  53. package/core/src/version.d.ts +0 -1
  54. package/entities/src/paged-loader.d.ts +0 -219
  55. package/entities/src/paginator.d.ts +0 -87
  56. package/entity-field/src/entity-field.d.ts +0 -70
  57. package/entity-field/src/provider.d.ts +0 -27
  58. package/forms/src/validation-error-handler.d.ts +0 -52
  59. package/hover-dropdown/src/hover-dropdown.directive.d.ts +0 -41
  60. package/locale/src/currency.pipe.d.ts +0 -14
  61. package/locale/src/date.pipe.d.ts +0 -14
  62. package/locale/src/format-currency.d.ts +0 -1
  63. package/locale/src/format-date.d.ts +0 -2
  64. package/locale/src/is-empty.d.ts +0 -1
  65. package/locale/src/providers.d.ts +0 -20
  66. package/mat-busy-wheel/src/busy-wheel-op.d.ts +0 -65
  67. package/mat-busy-wheel/src/busy-wheel.component.d.ts +0 -12
  68. package/mat-busy-wheel/src/busy-wheel.service.d.ts +0 -42
  69. package/mat-busy-wheel/src/host-busy-wheel.directive.d.ts +0 -35
  70. package/mat-context-menu/src/mat-context-menu.component.d.ts +0 -61
  71. package/mat-entity-crud/src/convert-context-input-to-http-context.d.ts +0 -11
  72. package/mat-entity-crud/src/default-config.d.ts +0 -9
  73. package/mat-entity-crud/src/form-view-host.component.d.ts +0 -41
  74. package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +0 -277
  75. package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +0 -131
  76. package/mat-entity-crud/src/mat-entity-crud-item-action.d.ts +0 -68
  77. package/mat-entity-crud/src/mat-entity-crud-types.d.ts +0 -149
  78. package/mat-entity-crud/src/mat-entity-crud.component.d.ts +0 -366
  79. package/mat-entity-crud/src/preview-host.component.d.ts +0 -21
  80. package/mat-entity-crud/src/preview-pane.component.d.ts +0 -31
  81. package/mat-entity-crud/src/providers.d.ts +0 -3
  82. package/mat-entity-list/src/config.d.ts +0 -6
  83. package/mat-entity-list/src/mat-entity-list-types.d.ts +0 -128
  84. package/mat-entity-list/src/mat-entity-list.component.d.ts +0 -259
  85. package/mat-entity-list/src/providers.d.ts +0 -3
  86. package/mat-file-input/src/mat-file-input.component.d.ts +0 -58
  87. package/mat-form-error/src/locales/en.d.ts +0 -4
  88. package/mat-form-error/src/locales/hu.d.ts +0 -4
  89. package/mat-form-error/src/locales/index.d.ts +0 -5
  90. package/mat-form-error/src/locales/pt-br.d.ts +0 -4
  91. package/mat-form-error/src/locales/zh-hans.d.ts +0 -4
  92. package/mat-form-error/src/locales/zh-hant.d.ts +0 -4
  93. package/mat-form-error/src/ngx-error-list.component.d.ts +0 -9
  94. package/mat-form-error/src/ngx-mat-error-control.d.ts +0 -17
  95. package/mat-form-error/src/ngx-mat-error-def.directive.d.ts +0 -30
  96. package/mat-form-error/src/ngx-mat-errors-for-date-range-picker.directive.d.ts +0 -8
  97. package/mat-form-error/src/ngx-mat-errors.component.d.ts +0 -44
  98. package/mat-form-error/src/types.d.ts +0 -68
  99. package/mat-form-error/src/utils/coerce-to-observable.d.ts +0 -3
  100. package/mat-form-error/src/utils/distinct-until-error-changed.d.ts +0 -2
  101. package/mat-form-error/src/utils/find-error-for-control.d.ts +0 -9
  102. package/mat-form-error/src/utils/get-abstract-controls.d.ts +0 -3
  103. package/mat-form-error/src/utils/get-control-with-error.d.ts +0 -3
  104. package/mat-select-entity/src/mat-select-entity.component.d.ts +0 -190
  105. package/mat-select-infinite-scroll/src/mat-select-infinite-scroll.directive.d.ts +0 -19
  106. package/mat-select-infinite-scroll/src/mat-select-infinite-scroll.service.d.ts +0 -25
  107. package/mat-side-menu-layout/src/layout.service.d.ts +0 -23
  108. package/mat-side-menu-layout/src/mat-menu-layout.component.d.ts +0 -39
  109. package/mat-side-menu-layout/src/mat-menu-layout.module.d.ts +0 -18
  110. package/mat-side-menu-layout/src/mat-menu-list-item.component.d.ts +0 -36
  111. package/mat-side-menu-layout/src/mat-menu-pane.component.d.ts +0 -66
  112. package/mat-side-menu-layout/src/nav-item.d.ts +0 -10
  113. package/mat-tel-input/src/country-codes.d.ts +0 -5
  114. package/mat-tel-input/src/mat-telephone.component.d.ts +0 -129
  115. package/mat-tel-input/src/providers.d.ts +0 -38
  116. package/ngx-helper.d.ts +0 -2
  117. package/public-api.d.ts +0 -1
  118. package/sideload/src/sideload.d.ts +0 -18
  119. package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +0 -74
package/core/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export * from './src/version';
1
+ declare const NGX_HELPER_VERSION = "0.1.0";
2
+
3
+ export { NGX_HELPER_VERSION };
@@ -1,2 +1,313 @@
1
- export * from './src/paged-loader';
2
- export * from './src/paginator';
1
+ import * as _ngneat_elf from '@ngneat/elf';
2
+ import * as _ngneat_elf_pagination from '@ngneat/elf-pagination';
3
+ import * as _smallpearl_ngx_helper_mat_entity_list from '@smallpearl/ngx-helper/mat-entity-list';
4
+ import { SPMatEntityListPaginator } from '@smallpearl/ngx-helper/mat-entity-list';
5
+ import * as _angular_core from '@angular/core';
6
+ import { HttpContextToken, HttpContext, HttpParams, HttpClient } from '@angular/common/http';
7
+ import { Observable, Subject, Subscription } from 'rxjs';
8
+
9
+ /**
10
+ * A type representing an entity loader function that takes page number,
11
+ * page size, and an optional search value and returns an Observable of
12
+ * the response. This is similar the http.get() method of HttpClient but
13
+ * with pagination parameters. The return value is deliberately kept generic
14
+ * (Observable<any>) to allow flexibility in the response type. This reponse
15
+ * will be parsed by the provided paginator's parseRequestResponse() method.
16
+ * So as long as the function return type and paginator are compatible,
17
+ * any response type can be handled.
18
+ *
19
+ * Ideally the response should contain the total number of entities available
20
+ * at the remote and the array of entities for the requested page.
21
+ */
22
+ type SPEntityLoaderFn = (page: number, pageSize: number, searchValue: string | undefined) => Observable<any>;
23
+ /**
24
+ * Represents a request to load entities from the remote. This is used to
25
+ * compare two requests to determine if they are equal. This is useful to
26
+ * prevent duplicate requests being sent to the remote.
27
+ */
28
+ declare class LoadRequest {
29
+ endpoint: string | SPEntityLoaderFn;
30
+ pageNumber: number;
31
+ searchStr: string | undefined;
32
+ force: boolean;
33
+ constructor(endpoint: string | SPEntityLoaderFn, pageNumber: number, searchStr: string | undefined, force?: boolean);
34
+ isEqualToAndNotForced(prev: LoadRequest): boolean;
35
+ }
36
+ type StateProps = {
37
+ allEntitiesLoaded: boolean;
38
+ loading: boolean;
39
+ loaded: boolean;
40
+ };
41
+ /**
42
+ * An abstract class that you can use wherever you would like to load entities
43
+ * from a remote endpoint in a paged manner. Entities can be loaded in one of
44
+ * two ways:
45
+ *
46
+ * 1. By providing an entityLoaderFn that takes an endpoint and HttpParams
47
+ * and returns a Observable of entities.
48
+ * 2. Or by providing a URL and using the default loader that uses HttpClient
49
+ * to load entities.
50
+ * This class uses RxJS to manage the loading of entities and provides
51
+ * signals to track the loading state, entity count, page index, page size,
52
+ * and whether more entities are available to load.
53
+ *
54
+ * How to use this class:
55
+ *
56
+ * 1. Dervice your component from SPPagedEntityLoader.
57
+ * 2. After your component is initialized, call the startLoader() method to
58
+ * get the component going. This sets up the necessary subscriptions to
59
+ * listen for load requests. Load requests are triggered by calling the
60
+ * loadPage() or loadNextPage() methods.
61
+ * 3. If your component supports infinite scrolling, call loadMoreEntities()
62
+ * method to load the next page of entities when it detects a scroll event.
63
+ * 4. If you component needs to load a specific page (via a pagination control),
64
+ * call the loadPage(pageNumber) method to load the specified page.
65
+ * 5. Entities are stored in an internal entities store which is an @ngneat/elf
66
+ * store. You can subscribe to the store's query to get the list of entities.
67
+ * 6. When your component is destroyed, call the stopLoader() method to clean up
68
+ * internal subscriptions.
69
+ *
70
+ * The class is decorated with Angular's @Directive decorator so that we can
71
+ * use signals for the input properties and dependency injection for HttpClient.
72
+ * There are no abstract methods as such, but the class is meant to be extended
73
+ * by your component to provide the necessary configuration via input properties.
74
+ * This is why it is declared as abstract.
75
+ */
76
+ declare abstract class SPPagedEntityLoader<TEntity extends {
77
+ [P in IdKey]: PropertyKey;
78
+ }, IdKey extends string = 'id'> {
79
+ static _entitiesCache: Map<string, {
80
+ refCount: number;
81
+ resp: any;
82
+ }>;
83
+ cacheKeys: Set<string>;
84
+ searchParamValue: string | undefined;
85
+ /**
86
+ * Entity name, that is used to form the "New { item }" menu item if
87
+ * inlineNew=true. This is also used as the key of the object in GET response
88
+ * if the reponse JSON is an object (sideloaded response), where the values
89
+ * are stored indexed by the server model name. For eg:-
90
+ *
91
+ * {
92
+ * 'customers': [
93
+ * {...},
94
+ * {...},
95
+ * {...},
96
+ * ]
97
+ * }
98
+ */
99
+ entityName: _angular_core.InputSignal<string>;
100
+ url: _angular_core.InputSignal<string | SPEntityLoaderFn>;
101
+ pageSize: _angular_core.InputSignal<number>;
102
+ paginator: _angular_core.InputSignal<SPMatEntityListPaginator | undefined>;
103
+ searchParamName: _angular_core.InputSignal<string>;
104
+ idKey: _angular_core.InputSignal<string>;
105
+ pluralEntityName: _angular_core.InputSignal<string | undefined>;
106
+ httpReqContext: _angular_core.InputSignal<[HttpContextToken<any>, any] | [[HttpContextToken<any>, any]] | HttpContext | undefined>;
107
+ httpParams: _angular_core.InputSignal<HttpParams | undefined>;
108
+ protected loadRequest$: Subject<LoadRequest>;
109
+ protected sub$: Subscription | undefined;
110
+ protected _pageSize: _angular_core.Signal<number>;
111
+ protected _pluralEntityName: _angular_core.Signal<string>;
112
+ protected _capitalizedEntityName: _angular_core.Signal<string>;
113
+ protected _httpReqContext: _angular_core.Signal<HttpContext>;
114
+ entityListConfig: _smallpearl_ngx_helper_mat_entity_list.SPMatEntityListConfig | null;
115
+ protected _paginator: _angular_core.Signal<SPMatEntityListPaginator>;
116
+ protected store: _ngneat_elf.Store<{
117
+ name: string;
118
+ state: {
119
+ entities: Record<TEntity[IdKey], TEntity>;
120
+ ids: TEntity[IdKey][];
121
+ } & StateProps & _ngneat_elf_pagination.PaginationState<0>;
122
+ config: never;
123
+ }, {
124
+ entities: Record<TEntity[IdKey], TEntity>;
125
+ ids: TEntity[IdKey][];
126
+ } & StateProps & _ngneat_elf_pagination.PaginationState<0>>;
127
+ protected http: HttpClient;
128
+ constructor();
129
+ /**
130
+ * Starts listening for load requests and processes them. Call this from your
131
+ * component's ngOnInit() or ngAfterViewInit() method.
132
+ */
133
+ startLoader(): void;
134
+ /**
135
+ * Stops listening for load requests and cleans up subscriptions.
136
+ */
137
+ stopLoader(): void;
138
+ hasStarted(): boolean;
139
+ /**
140
+ * Returns a boolean indicating whether all entities at the remote have been
141
+ * loaded. All entities are considered loaded when there are no more entities
142
+ * to load from the remote (that is all pages have been loaded without
143
+ * a search filter).
144
+ * @returns
145
+ */
146
+ allEntitiesLoaded(): boolean;
147
+ /**
148
+ * Returns the total number of entities at the remote as reported by the
149
+ * server (or load fn) during each load.
150
+ * @returns
151
+ */
152
+ totalEntitiesAtRemote(): number;
153
+ /**
154
+ * Returns number of entities currently stored in the internal store.
155
+ * @returns
156
+ */
157
+ totalEntitiesCount(): number;
158
+ /**
159
+ * Returns true if there are more entities to load from the remote.
160
+ * This is computed based on the total entities count and the number of
161
+ * entities loaded so far. For this method to work correctly, an initial
162
+ * load must have been performed to get the total count from the remote.
163
+ * @returns
164
+ */
165
+ hasMore(): boolean;
166
+ /**
167
+ * Returns true if a load operation is in progress. The load async operation
168
+ * method turns the loading state to true when a load operation starts and
169
+ * turns it to false when the operation completes.
170
+ * @returns
171
+ */
172
+ loading(): boolean;
173
+ /**
174
+ * Returns the loading state as an Observable that emits when the state changes.
175
+ * @returns
176
+ */
177
+ get loading$(): Observable<boolean>;
178
+ /**
179
+ * Boolean indicates whether the loader has completed at least one load
180
+ * operation.
181
+ */
182
+ loaded(): boolean;
183
+ /**
184
+ * Returns the endpoint URL if the loader was created with an endpoint.
185
+ * If the loader was created with a loader function, an empty string is
186
+ * returned.
187
+ * @returns
188
+ */
189
+ endpoint(): string;
190
+ /**
191
+ * Loads the specified page number of entities from the remote.
192
+ * @param pageNumber
193
+ */
194
+ loadPage(pageNumber: number): void;
195
+ /**
196
+ * Returns the total number of pages available at the remote.
197
+ * @returns
198
+ */
199
+ totalPages(): number;
200
+ /**
201
+ * Loads the next page of entities from the remote.
202
+ *
203
+ * @param searchParamValue Optional search parameter value. If specified
204
+ * and is different from the current search parameter value, the internal
205
+ * store is reset and entities are loaded from page 0 with the new search
206
+ * parameter value. Otherwise, the next page of entities is loaded.
207
+ */
208
+ loadNextPage(): void;
209
+ setSearchParamValue(searchStr: string): void;
210
+ setEntities(entities: TEntity[]): void;
211
+ getEntities(): TEntity[];
212
+ getEntity(id: TEntity[IdKey]): TEntity | undefined;
213
+ protected addAddlContextTokens(context: HttpContext): void;
214
+ protected doActualLoad(lr: LoadRequest): Observable<any>;
215
+ private existsInCache;
216
+ private getCacheKey;
217
+ private getFromCache;
218
+ addToCache(cacheKey: string, resp: any): void;
219
+ private removeFromCache;
220
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SPPagedEntityLoader<any, any>, never>;
221
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<SPPagedEntityLoader<any, any>, "**spPagedEntityLoader**", never, { "entityName": { "alias": "entityName"; "required": true; "isSignal": true; }; "url": { "alias": "url"; "required": true; "isSignal": true; }; "pageSize": { "alias": "pageSize"; "required": false; "isSignal": true; }; "paginator": { "alias": "paginator"; "required": false; "isSignal": true; }; "searchParamName": { "alias": "searchParamName"; "required": false; "isSignal": true; }; "idKey": { "alias": "idKey"; "required": false; "isSignal": true; }; "pluralEntityName": { "alias": "pluralEntityName"; "required": false; "isSignal": true; }; "httpReqContext": { "alias": "httpReqContext"; "required": false; "isSignal": true; }; "httpParams": { "alias": "httpParams"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
222
+ }
223
+
224
+ /**
225
+ * Pagination HTTP request params. Actually copied from Angular's HttpParams
226
+ * declaration. The ReadonlyArray<string|number|boolean> is a bit of an
227
+ * overkill for pagination params, but what the heck. When you copy-paste,
228
+ * do it in full!
229
+ */
230
+ type SPPageParams = {
231
+ [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
232
+ };
233
+ /**
234
+ * An interface that the clients should provide, either via a global config
235
+ * (see above), that handles parsing the GET response and returns the entities
236
+ * stored therein. This class will allow the entity-list component to be
237
+ * used across different pagination response types as long as the appropriate
238
+ * SPEntityListPaginator class is provided to the component.
239
+ */
240
+ interface SPEntityListPaginator {
241
+ /**
242
+ * Return the HTTP request params for the given page index and page size as
243
+ * an object. For example, for a REST API that supports 'skip' and 'top' params,
244
+ * the implementation would be:
245
+ *
246
+ * ```typescript
247
+ * getRequestPageParams(endpoint: string, pageIndex: number, pageSize: number): SPPageParams {
248
+ * return {
249
+ * skip: pageIndex * pageSize,
250
+ * top: pageSize
251
+ * };
252
+ * }
253
+ * ```
254
+ * @param endpoint
255
+ * @param pageIndex
256
+ * @param pageSize
257
+ * @returns
258
+ */
259
+ getRequestPageParams: (endpoint: string, pageIndex: number, pageSize: number) => SPPageParams;
260
+ /**
261
+ * Parse the HTTP response received from the GET request and return an object
262
+ * containing the total number of entities available and the array of entities
263
+ * for the current page. For example, for the pure DRF paginated response
264
+ * like below:
265
+ * ```json
266
+ * {
267
+ * "count": 102,
268
+ * "next": "http://api.example.org/entities/?page=3",
269
+ * "previous": "http://api.example.org/entities/?page=1",
270
+ * "results": [
271
+ * {
272
+ * "id": 1,
273
+ * "name": "Entity 1"
274
+ * },
275
+ * {
276
+ * "id": 2,
277
+ * "name": "Entity 2"
278
+ * }
279
+ * ]
280
+ * }
281
+ * ```
282
+ * The implementation would be:
283
+ * ```typescript
284
+ * parseRequestResponse<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'>(
285
+ * entityName: string,
286
+ * entityNamePlural: string,
287
+ * endpoint: string,
288
+ * params: SPPageParams,
289
+ * resp: any
290
+ * ): { total: number; entities: TEntity[] } {
291
+ * return {
292
+ * total: resp.count,
293
+ * entities: resp.results
294
+ * };
295
+ * }
296
+ * ```
297
+ * @param entityName
298
+ * @param entityNamePlural
299
+ * @param endpoint
300
+ * @param params
301
+ * @param resp
302
+ * @returns
303
+ */
304
+ parseRequestResponse: <TEntity extends {
305
+ [P in IdKey]: PropertyKey;
306
+ }, IdKey extends string = 'id'>(entityName: string, entityNamePlural: string, endpoint: string, params: SPPageParams, resp: any) => {
307
+ total: number;
308
+ entities: TEntity[];
309
+ };
310
+ }
311
+
312
+ export { SPPagedEntityLoader };
313
+ export type { SPEntityListPaginator, SPEntityLoaderFn, SPPageParams };
@@ -1,2 +1,101 @@
1
- export * from './src/entity-field';
2
- export * from './src/provider';
1
+ import * as _smallpearl_ngx_helper_locale from '@smallpearl/ngx-helper/locale';
2
+ import { SPIntlDateFormat } from '@smallpearl/ngx-helper/locale';
3
+ import { Observable } from 'rxjs';
4
+ import { InjectionToken } from '@angular/core';
5
+
6
+ type FieldValueTypes = string | number | Date | boolean;
7
+ /**
8
+ * This structure defines the data formatting details for a field of the
9
+ * entity. All entity fields need not necessarily be actual entity object's
10
+ * properties. Fields can also be computed fields, in which case the valueFn
11
+ * should be initialized with a valid function to provide the field's value.
12
+ */
13
+ type SPEntityFieldSpec<TEntity extends {
14
+ [P in IdKey]: PropertyKey;
15
+ }, IdKey extends string = 'id'> = {
16
+ name: string;
17
+ label?: string | Observable<string>;
18
+ valueOptions?: {
19
+ dateTimeFormat?: SPIntlDateFormat;
20
+ isCurrency?: boolean;
21
+ currency?: string;
22
+ class?: string;
23
+ alignment?: 'start' | 'center' | 'end';
24
+ routerLink?: ((e: TEntity) => string[]) | [string];
25
+ };
26
+ valueFn?: (item: TEntity) => FieldValueTypes | Observable<FieldValueTypes>;
27
+ };
28
+
29
+ type FIELD_VALUE_FN = (entity: any, fieldName: string) => string | number | Date | boolean;
30
+ /**
31
+ * Global config for SPEntityField component.
32
+ */
33
+ interface SPEntityFieldConfig {
34
+ /**
35
+ * These are global field value functions.
36
+ *
37
+ * If a value function for a field is not explicitly specified, this map is
38
+ * looked up with the field name. If an entry exists in this table, it will
39
+ * be used to render the field's value.
40
+ *
41
+ * This is useful for formatting certain fields which tend to have the
42
+ * same name across the app. For instance fields such as 'amount', 'total'
43
+ * or 'balance'. Or 'date', 'timestamp', etc.
44
+ */
45
+ fieldValueFns?: Map<string, FIELD_VALUE_FN>;
46
+ /**
47
+ * Similar to above, but allows setting the options for certain fields
48
+ * globally. As in the case of `fieldValueFns`, the per field specification,
49
+ * if one exists, takes precedence over the global setting.
50
+ */
51
+ fieldValueOptions?: Map<string, SPEntityFieldSpec<any>['valueOptions']>;
52
+ }
53
+ declare const SP_ENTITY_FIELD_CONFIG: InjectionToken<SPEntityFieldConfig>;
54
+
55
+ /**
56
+ * A class that represents a SPEntityFieldSpec<>. This is typically used
57
+ * by the library to evaluate a SPEntityFieldSpec<> object.
58
+ */
59
+ declare class SPEntityField<TEntity extends {
60
+ [P in IdKey]: PropertyKey;
61
+ }, IdKey extends string = 'id'> {
62
+ fieldConfig?: SPEntityFieldConfig | undefined;
63
+ _fieldSpec: SPEntityFieldSpec<TEntity, IdKey>;
64
+ constructor(spec: SPEntityFieldSpec<TEntity, IdKey> | string, fieldConfig?: SPEntityFieldConfig | undefined);
65
+ get spec(): SPEntityFieldSpec<TEntity, IdKey>;
66
+ /**
67
+ * Returns the effective fieldValueOptions by merging the global field
68
+ * options (if one has been spefified) with the local field value options.
69
+ * @returns SPEntityFieldSpec<any>['valueOptions']
70
+ */
71
+ get options(): {
72
+ dateTimeFormat?: _smallpearl_ngx_helper_locale.SPIntlDateFormat;
73
+ isCurrency?: boolean;
74
+ currency?: string;
75
+ class?: string;
76
+ alignment?: "start" | "center" | "end";
77
+ routerLink?: [string] | ((e: TEntity) => string[]) | undefined;
78
+ };
79
+ /**
80
+ * @returns the label for the field.
81
+ */
82
+ label(): Observable<string>;
83
+ /**
84
+ * Given an entity, returns the value of the field matching the
85
+ * SPEntityFieldSpec<> in fieldSpec.
86
+ * @param entity TEntity instance which will be evaluated for
87
+ * SPEntityFieldSpec<>.
88
+ * @returns
89
+ */
90
+ value(entity: TEntity): any;
91
+ /**
92
+ * If specified, will be added to the CSS classes of the field's wrapper
93
+ * element.
94
+ */
95
+ get class(): string;
96
+ hasRouterLink(entity: TEntity): boolean;
97
+ getRouterLink(entity: TEntity): string[];
98
+ }
99
+
100
+ export { SPEntityField, SP_ENTITY_FIELD_CONFIG };
101
+ export type { FIELD_VALUE_FN, SPEntityFieldConfig, SPEntityFieldSpec };
@@ -173,43 +173,43 @@ class SPPagedEntityLoader {
173
173
  * ]
174
174
  * }
175
175
  */
176
- entityName = input.required();
177
- url = input.required();
176
+ entityName = input.required(...(ngDevMode ? [{ debugName: "entityName" }] : []));
177
+ url = input.required(...(ngDevMode ? [{ debugName: "url" }] : []));
178
178
  //** OPTIONAL ATTRIBUTES **//
179
179
  // Number of entities to be loaded per page from the server. This will be
180
180
  // passed to PagedEntityLoader to load entities in pages. Defaults to 50.
181
181
  // Adjust this accordingly based on the average size of your entities to
182
182
  // optimize server round-trips and memory usage.
183
- pageSize = input(50);
183
+ pageSize = input(50, ...(ngDevMode ? [{ debugName: "pageSize" }] : []));
184
184
  // Paginator for the remote entity list. This is used to determine the
185
185
  // pagination parameters for the API request. If not specified, the global
186
186
  // paginator specified in SPMatEntityListConfig will be used. If that too is
187
187
  // not specified, a default paginator will be used. Default paginator can
188
188
  // handle DRF native PageNumberPagination and dynamic-rest style pagination.
189
- paginator = input();
189
+ paginator = input(...(ngDevMode ? [undefined, { debugName: "paginator" }] : []));
190
190
  // Search parameter name to be used in the HTTP request.
191
191
  // Defaults to 'search'. That is when a search string is specified and
192
192
  // the entire entity list has not been fetched, a fresh HTTP request is made
193
193
  // to the remote server with `?<searchParamName>=<search string>` parameter.
194
- searchParamName = input('search');
194
+ searchParamName = input('search', ...(ngDevMode ? [{ debugName: "searchParamName" }] : []));
195
195
  // Entity idKey, if idKey is different from the default 'id'.
196
- idKey = input('id');
196
+ idKey = input('id', ...(ngDevMode ? [{ debugName: "idKey" }] : []));
197
197
  // Plural entity name, used when grouping options. If not specified, it is
198
198
  // derived by pluralizing the entityName.
199
- pluralEntityName = input(undefined); // defaults to pluralized entityName
200
- httpReqContext = input(undefined); // defaults to empty context
199
+ pluralEntityName = input(undefined, ...(ngDevMode ? [{ debugName: "pluralEntityName" }] : [])); // defaults to pluralized entityName
200
+ httpReqContext = input(undefined, ...(ngDevMode ? [{ debugName: "httpReqContext" }] : [])); // defaults to empty context
201
201
  // Parameters to be added to the HTTP request to retrieve data from
202
202
  // remote. This won't be used if `loadFromRemoteFn` is specified.
203
- httpParams = input(undefined); // defaults to empty params
203
+ httpParams = input(undefined, ...(ngDevMode ? [{ debugName: "httpParams" }] : [])); // defaults to empty params
204
204
  // Mechanism to default pageSize to last entities length.
205
205
  loadRequest$ = new Subject();
206
206
  sub$;
207
- _pageSize = computed(() => this.pageSize() ? this.pageSize() : 50);
207
+ _pageSize = computed(() => this.pageSize() ? this.pageSize() : 50, ...(ngDevMode ? [{ debugName: "_pageSize" }] : []));
208
208
  _pluralEntityName = computed(() => {
209
209
  const pluralEntityName = this.pluralEntityName();
210
210
  return pluralEntityName ? pluralEntityName : plural(this.entityName());
211
- });
212
- _capitalizedEntityName = computed(() => capitalize(this.entityName()));
211
+ }, ...(ngDevMode ? [{ debugName: "_pluralEntityName" }] : []));
212
+ _capitalizedEntityName = computed(() => capitalize(this.entityName()), ...(ngDevMode ? [{ debugName: "_capitalizedEntityName" }] : []));
213
213
  _httpReqContext = computed(() => {
214
214
  let reqContext = this.httpReqContext();
215
215
  const context = new HttpContext();
@@ -234,7 +234,7 @@ class SPPagedEntityLoader {
234
234
  // Give subclasses a chance to add their own context tokens.
235
235
  this.addAddlContextTokens(context);
236
236
  return context;
237
- });
237
+ }, ...(ngDevMode ? [{ debugName: "_httpReqContext" }] : []));
238
238
  entityListConfig = inject(SP_MAT_ENTITY_LIST_CONFIG, {
239
239
  optional: true,
240
240
  });
@@ -248,7 +248,7 @@ class SPPagedEntityLoader {
248
248
  : entityListConfigPaginator
249
249
  ? entityListConfigPaginator
250
250
  : new DefaultPaginator();
251
- });
251
+ }, ...(ngDevMode ? [{ debugName: "_paginator" }] : []));
252
252
  // We create it here so that store member variable will have the correct
253
253
  // type. Unfortunately elf doesn't have a simple generic type that we can
254
254
  // use to declare the type of the store and then initialize it later.
@@ -562,15 +562,15 @@ class SPPagedEntityLoader {
562
562
  }
563
563
  }
564
564
  }
565
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPPagedEntityLoader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
566
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: SPPagedEntityLoader, isStandalone: true, selector: "**spPagedEntityLoader**", inputs: { entityName: { classPropertyName: "entityName", publicName: "entityName", isSignal: true, isRequired: true, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: true, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, paginator: { classPropertyName: "paginator", publicName: "paginator", isSignal: true, isRequired: false, transformFunction: null }, searchParamName: { classPropertyName: "searchParamName", publicName: "searchParamName", isSignal: true, isRequired: false, transformFunction: null }, idKey: { classPropertyName: "idKey", publicName: "idKey", isSignal: true, isRequired: false, transformFunction: null }, pluralEntityName: { classPropertyName: "pluralEntityName", publicName: "pluralEntityName", isSignal: true, isRequired: false, transformFunction: null }, httpReqContext: { classPropertyName: "httpReqContext", publicName: "httpReqContext", isSignal: true, isRequired: false, transformFunction: null }, httpParams: { classPropertyName: "httpParams", publicName: "httpParams", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
565
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: SPPagedEntityLoader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
566
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.16", type: SPPagedEntityLoader, isStandalone: true, selector: "**spPagedEntityLoader**", inputs: { entityName: { classPropertyName: "entityName", publicName: "entityName", isSignal: true, isRequired: true, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: true, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, paginator: { classPropertyName: "paginator", publicName: "paginator", isSignal: true, isRequired: false, transformFunction: null }, searchParamName: { classPropertyName: "searchParamName", publicName: "searchParamName", isSignal: true, isRequired: false, transformFunction: null }, idKey: { classPropertyName: "idKey", publicName: "idKey", isSignal: true, isRequired: false, transformFunction: null }, pluralEntityName: { classPropertyName: "pluralEntityName", publicName: "pluralEntityName", isSignal: true, isRequired: false, transformFunction: null }, httpReqContext: { classPropertyName: "httpReqContext", publicName: "httpReqContext", isSignal: true, isRequired: false, transformFunction: null }, httpParams: { classPropertyName: "httpParams", publicName: "httpParams", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
567
567
  }
568
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPPagedEntityLoader, decorators: [{
568
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: SPPagedEntityLoader, decorators: [{
569
569
  type: Directive,
570
570
  args: [{
571
571
  selector: '**spPagedEntityLoader**',
572
572
  }]
573
- }], ctorParameters: () => [] });
573
+ }], ctorParameters: () => [], propDecorators: { entityName: [{ type: i0.Input, args: [{ isSignal: true, alias: "entityName", required: true }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: true }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }], paginator: [{ type: i0.Input, args: [{ isSignal: true, alias: "paginator", required: false }] }], searchParamName: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchParamName", required: false }] }], idKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "idKey", required: false }] }], pluralEntityName: [{ type: i0.Input, args: [{ isSignal: true, alias: "pluralEntityName", required: false }] }], httpReqContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "httpReqContext", required: false }] }], httpParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "httpParams", required: false }] }] } });
574
574
 
575
575
  /**
576
576
  * Generated bundle index. Do not edit.