@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
@@ -1 +1,20 @@
1
- export * from './src/sideload';
1
+ /**
2
+ * A function to merge sideloaded content into the main object thereby returning
3
+ * a composite object.
4
+ *
5
+ * @param resp - the JSON response object, typically received from remote for
6
+ * an HTTP request.
7
+ * @param targetObjKey - the key name of the target object into which the
8
+ * sideloaded data are to be merged.
9
+ * @param idKey - idKey. Function assumes that all the objects use the same
10
+ * key name as the unique object identifier.
11
+ * @param sideloadDataMap: An array of [string, string], where the first
12
+ * element specifies the property name of the target object and the second
13
+ * element the sideload data element's key. This is useful when the the
14
+ * target objet's property name that is to be merged with sideload data do not
15
+ * match.
16
+ * @returns Object with sideloaded data merged into the target object.
17
+ */
18
+ declare function sideloadToComposite(resp: any, targetObjKey: string, idKey?: string, mergeStrategy?: 'inplace' | 'append', appendObjSuffix?: string, sideloadDataMap?: Array<[string, string, string?]>): any;
19
+
20
+ export { sideloadToComposite };
@@ -1 +1,78 @@
1
- export * from './src/stationary-with-line-items.component';
1
+ import * as _smallpearl_ngx_helper_entity_field from '@smallpearl/ngx-helper/entity-field';
2
+ import { SPEntityField, SPEntityFieldSpec } from '@smallpearl/ngx-helper/entity-field';
3
+ import * as _angular_core from '@angular/core';
4
+ import { OnInit, ChangeDetectorRef, TemplateRef } from '@angular/core';
5
+ import { Observable } from 'rxjs';
6
+
7
+ declare class FieldsRendererComponent<TEntity extends {
8
+ [P in IdKey]: PropertyKey;
9
+ }, IdKey extends string = 'id'> implements OnInit {
10
+ cdr: ChangeDetectorRef;
11
+ entity: _angular_core.InputSignal<TEntity>;
12
+ fields: _angular_core.InputSignal<SPEntityField<TEntity, IdKey>[]>;
13
+ isString: _angular_core.Signal<boolean>;
14
+ stringValue: _angular_core.Signal<any>;
15
+ constructor(cdr: ChangeDetectorRef);
16
+ ngOnInit(): void;
17
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FieldsRendererComponent<any, any>, never>;
18
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FieldsRendererComponent<any, any>, "sp-fields-renderer", never, { "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "fields": { "alias": "fields"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
19
+ }
20
+ /**
21
+ * A component that renders a stationary with line items, such as invoice,
22
+ * payment receipt, bill, bill payment record, journal entry, etc. All these
23
+ * documents have a uniform format and this component abstracts out the
24
+ * information displayed in this type of document as properties that the client
25
+ * can provide while it takes care of the rendering.
26
+ *
27
+ * Ideally we would declare this as a wrapper class with the actual rendering
28
+ * to be performed by an inner replaceable component. This way the app will be
29
+ * able to support multiple stationary designs, which eventually can be
30
+ * chosen by the user. Perhaps even providing them a feature to design the
31
+ * stationary.
32
+ *
33
+ * This is the first towards that long path ahead.
34
+ */
35
+ declare class StationaryWithLineItemsComponent<TEntity extends {
36
+ [P in IdKey]: PropertyKey;
37
+ }, TEntityLineItem extends {
38
+ [P in IdKey]: PropertyKey;
39
+ }, IdKey extends string = 'id'> implements OnInit {
40
+ entity: _angular_core.InputSignal<TEntity>;
41
+ title: _angular_core.InputSignal<string>;
42
+ number: _angular_core.InputSignal<string | number | undefined>;
43
+ leftHeader: _angular_core.InputSignal<string | (string | SPEntityFieldSpec<TEntity, IdKey>)[] | undefined>;
44
+ _leftHeaderFields: _angular_core.Signal<SPEntityField<TEntity, IdKey>[]>;
45
+ leftHeaderTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
46
+ rightHeader: _angular_core.InputSignal<string | (string | SPEntityFieldSpec<TEntity, IdKey>)[] | undefined>;
47
+ _rightHeaderFields: _angular_core.Signal<SPEntityField<TEntity, IdKey>[]>;
48
+ rightHeaderTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
49
+ items: _angular_core.InputSignal<{
50
+ [key: string]: string;
51
+ }[] | undefined>;
52
+ leftFooter: _angular_core.InputSignal<string | (string | SPEntityFieldSpec<TEntity, IdKey>)[] | undefined>;
53
+ _leftFooterFields: _angular_core.Signal<SPEntityField<TEntity, IdKey>[]>;
54
+ leftFooterTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
55
+ rightFooter: _angular_core.InputSignal<string | (string | SPEntityFieldSpec<TEntity, IdKey>)[] | undefined>;
56
+ _rightFooterFields: _angular_core.Signal<SPEntityField<TEntity, IdKey>[]>;
57
+ rightFooterTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
58
+ itemFieldName: _angular_core.InputSignal<string>;
59
+ itemColumnFields: _angular_core.InputSignal<(string | SPEntityFieldSpec<TEntity, IdKey>)[] | undefined>;
60
+ _itemColumnFields: _angular_core.Signal<SPEntityField<TEntity, IdKey>[]>;
61
+ _items: _angular_core.Signal<any>;
62
+ ngxEntityFieldConfig: _smallpearl_ngx_helper_entity_field.SPEntityFieldConfig;
63
+ constructor();
64
+ ngOnInit(): void;
65
+ isString(value: any): value is string;
66
+ /**
67
+ * Make the method a generic as we'll be using it for both TEntity and its
68
+ * child TEntityLineItem objects.
69
+ * @param fieldSpecs
70
+ * @returns
71
+ */
72
+ getSPEntityFields<T>(fieldSpecs: Array<SPEntityFieldSpec<TEntity, IdKey> | string> | string | undefined): Array<SPEntityField<TEntity, IdKey>>;
73
+ fieldLabel(field: SPEntityField<TEntity, IdKey>): Observable<string>;
74
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<StationaryWithLineItemsComponent<any, any, any>, never>;
75
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<StationaryWithLineItemsComponent<any, any, any>, "sp-stationary-with-line-items", never, { "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": true; "isSignal": true; }; "number": { "alias": "number"; "required": false; "isSignal": true; }; "leftHeader": { "alias": "leftHeader"; "required": false; "isSignal": true; }; "leftHeaderTemplate": { "alias": "leftHeaderTemplate"; "required": false; "isSignal": true; }; "rightHeader": { "alias": "rightHeader"; "required": false; "isSignal": true; }; "rightHeaderTemplate": { "alias": "rightHeaderTemplate"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "leftFooter": { "alias": "leftFooter"; "required": false; "isSignal": true; }; "leftFooterTemplate": { "alias": "leftFooterTemplate"; "required": false; "isSignal": true; }; "rightFooter": { "alias": "rightFooter"; "required": false; "isSignal": true; }; "rightFooterTemplate": { "alias": "rightFooterTemplate"; "required": false; "isSignal": true; }; "itemFieldName": { "alias": "itemFieldName"; "required": false; "isSignal": true; }; "itemColumnFields": { "alias": "itemColumnFields"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
76
+ }
77
+
78
+ export { FieldsRendererComponent, StationaryWithLineItemsComponent };
@@ -1 +0,0 @@
1
- export declare const NGX_HELPER_VERSION = "0.1.0";
@@ -1,219 +0,0 @@
1
- import { HttpClient, HttpContext, HttpContextToken, HttpParams } from '@angular/common/http';
2
- import { SPMatEntityListPaginator } from '@smallpearl/ngx-helper/mat-entity-list';
3
- import { Observable, Subject, Subscription } from 'rxjs';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * A type representing an entity loader function that takes page number,
7
- * page size, and an optional search value and returns an Observable of
8
- * the response. This is similar the http.get() method of HttpClient but
9
- * with pagination parameters. The return value is deliberately kept generic
10
- * (Observable<any>) to allow flexibility in the response type. This reponse
11
- * will be parsed by the provided paginator's parseRequestResponse() method.
12
- * So as long as the function return type and paginator are compatible,
13
- * any response type can be handled.
14
- *
15
- * Ideally the response should contain the total number of entities available
16
- * at the remote and the array of entities for the requested page.
17
- */
18
- export type SPEntityLoaderFn = (page: number, pageSize: number, searchValue: string | undefined) => Observable<any>;
19
- /**
20
- * Represents a request to load entities from the remote. This is used to
21
- * compare two requests to determine if they are equal. This is useful to
22
- * prevent duplicate requests being sent to the remote.
23
- */
24
- declare class LoadRequest {
25
- endpoint: string | SPEntityLoaderFn;
26
- pageNumber: number;
27
- searchStr: string | undefined;
28
- force: boolean;
29
- constructor(endpoint: string | SPEntityLoaderFn, pageNumber: number, searchStr: string | undefined, force?: boolean);
30
- isEqualToAndNotForced(prev: LoadRequest): boolean;
31
- }
32
- type StateProps = {
33
- allEntitiesLoaded: boolean;
34
- loading: boolean;
35
- loaded: boolean;
36
- };
37
- /**
38
- * An abstract class that you can use wherever you would like to load entities
39
- * from a remote endpoint in a paged manner. Entities can be loaded in one of
40
- * two ways:
41
- *
42
- * 1. By providing an entityLoaderFn that takes an endpoint and HttpParams
43
- * and returns a Observable of entities.
44
- * 2. Or by providing a URL and using the default loader that uses HttpClient
45
- * to load entities.
46
- * This class uses RxJS to manage the loading of entities and provides
47
- * signals to track the loading state, entity count, page index, page size,
48
- * and whether more entities are available to load.
49
- *
50
- * How to use this class:
51
- *
52
- * 1. Dervice your component from SPPagedEntityLoader.
53
- * 2. After your component is initialized, call the startLoader() method to
54
- * get the component going. This sets up the necessary subscriptions to
55
- * listen for load requests. Load requests are triggered by calling the
56
- * loadPage() or loadNextPage() methods.
57
- * 3. If your component supports infinite scrolling, call loadMoreEntities()
58
- * method to load the next page of entities when it detects a scroll event.
59
- * 4. If you component needs to load a specific page (via a pagination control),
60
- * call the loadPage(pageNumber) method to load the specified page.
61
- * 5. Entities are stored in an internal entities store which is an @ngneat/elf
62
- * store. You can subscribe to the store's query to get the list of entities.
63
- * 6. When your component is destroyed, call the stopLoader() method to clean up
64
- * internal subscriptions.
65
- *
66
- * The class is decorated with Angular's @Directive decorator so that we can
67
- * use signals for the input properties and dependency injection for HttpClient.
68
- * There are no abstract methods as such, but the class is meant to be extended
69
- * by your component to provide the necessary configuration via input properties.
70
- * This is why it is declared as abstract.
71
- */
72
- export declare abstract class SPPagedEntityLoader<TEntity extends {
73
- [P in IdKey]: PropertyKey;
74
- }, IdKey extends string = 'id'> {
75
- static _entitiesCache: Map<string, {
76
- refCount: number;
77
- resp: any;
78
- }>;
79
- cacheKeys: Set<string>;
80
- searchParamValue: string | undefined;
81
- /**
82
- * Entity name, that is used to form the "New { item }" menu item if
83
- * inlineNew=true. This is also used as the key of the object in GET response
84
- * if the reponse JSON is an object (sideloaded response), where the values
85
- * are stored indexed by the server model name. For eg:-
86
- *
87
- * {
88
- * 'customers': [
89
- * {...},
90
- * {...},
91
- * {...},
92
- * ]
93
- * }
94
- */
95
- entityName: import("@angular/core").InputSignal<string>;
96
- url: import("@angular/core").InputSignal<string | SPEntityLoaderFn>;
97
- pageSize: import("@angular/core").InputSignal<number>;
98
- paginator: import("@angular/core").InputSignal<SPMatEntityListPaginator | undefined>;
99
- searchParamName: import("@angular/core").InputSignal<string>;
100
- idKey: import("@angular/core").InputSignal<string>;
101
- pluralEntityName: import("@angular/core").InputSignal<string | undefined>;
102
- httpReqContext: import("@angular/core").InputSignal<[HttpContextToken<any>, any] | [[HttpContextToken<any>, any]] | HttpContext | undefined>;
103
- httpParams: import("@angular/core").InputSignal<HttpParams | undefined>;
104
- protected loadRequest$: Subject<LoadRequest>;
105
- protected sub$: Subscription | undefined;
106
- protected _pageSize: import("@angular/core").Signal<number>;
107
- protected _pluralEntityName: import("@angular/core").Signal<string>;
108
- protected _capitalizedEntityName: import("@angular/core").Signal<string>;
109
- protected _httpReqContext: import("@angular/core").Signal<HttpContext>;
110
- entityListConfig: import("@smallpearl/ngx-helper/mat-entity-list").SPMatEntityListConfig | null;
111
- protected _paginator: import("@angular/core").Signal<SPMatEntityListPaginator>;
112
- protected store: import("@ngneat/elf").Store<{
113
- name: string;
114
- state: {
115
- entities: Record<TEntity[IdKey], TEntity>;
116
- ids: TEntity[IdKey][];
117
- } & StateProps & import("@ngneat/elf-pagination").PaginationState<0>;
118
- config: never;
119
- }, {
120
- entities: Record<TEntity[IdKey], TEntity>;
121
- ids: TEntity[IdKey][];
122
- } & StateProps & import("@ngneat/elf-pagination").PaginationState<0>>;
123
- protected http: HttpClient;
124
- constructor();
125
- /**
126
- * Starts listening for load requests and processes them. Call this from your
127
- * component's ngOnInit() or ngAfterViewInit() method.
128
- */
129
- startLoader(): void;
130
- /**
131
- * Stops listening for load requests and cleans up subscriptions.
132
- */
133
- stopLoader(): void;
134
- hasStarted(): boolean;
135
- /**
136
- * Returns a boolean indicating whether all entities at the remote have been
137
- * loaded. All entities are considered loaded when there are no more entities
138
- * to load from the remote (that is all pages have been loaded without
139
- * a search filter).
140
- * @returns
141
- */
142
- allEntitiesLoaded(): boolean;
143
- /**
144
- * Returns the total number of entities at the remote as reported by the
145
- * server (or load fn) during each load.
146
- * @returns
147
- */
148
- totalEntitiesAtRemote(): number;
149
- /**
150
- * Returns number of entities currently stored in the internal store.
151
- * @returns
152
- */
153
- totalEntitiesCount(): number;
154
- /**
155
- * Returns true if there are more entities to load from the remote.
156
- * This is computed based on the total entities count and the number of
157
- * entities loaded so far. For this method to work correctly, an initial
158
- * load must have been performed to get the total count from the remote.
159
- * @returns
160
- */
161
- hasMore(): boolean;
162
- /**
163
- * Returns true if a load operation is in progress. The load async operation
164
- * method turns the loading state to true when a load operation starts and
165
- * turns it to false when the operation completes.
166
- * @returns
167
- */
168
- loading(): boolean;
169
- /**
170
- * Returns the loading state as an Observable that emits when the state changes.
171
- * @returns
172
- */
173
- get loading$(): Observable<boolean>;
174
- /**
175
- * Boolean indicates whether the loader has completed at least one load
176
- * operation.
177
- */
178
- loaded(): boolean;
179
- /**
180
- * Returns the endpoint URL if the loader was created with an endpoint.
181
- * If the loader was created with a loader function, an empty string is
182
- * returned.
183
- * @returns
184
- */
185
- endpoint(): string;
186
- /**
187
- * Loads the specified page number of entities from the remote.
188
- * @param pageNumber
189
- */
190
- loadPage(pageNumber: number): void;
191
- /**
192
- * Returns the total number of pages available at the remote.
193
- * @returns
194
- */
195
- totalPages(): number;
196
- /**
197
- * Loads the next page of entities from the remote.
198
- *
199
- * @param searchParamValue Optional search parameter value. If specified
200
- * and is different from the current search parameter value, the internal
201
- * store is reset and entities are loaded from page 0 with the new search
202
- * parameter value. Otherwise, the next page of entities is loaded.
203
- */
204
- loadNextPage(): void;
205
- setSearchParamValue(searchStr: string): void;
206
- setEntities(entities: TEntity[]): void;
207
- getEntities(): TEntity[];
208
- getEntity(id: TEntity[IdKey]): TEntity | undefined;
209
- protected addAddlContextTokens(context: HttpContext): void;
210
- protected doActualLoad(lr: LoadRequest): Observable<any>;
211
- private existsInCache;
212
- private getCacheKey;
213
- private getFromCache;
214
- addToCache(cacheKey: string, resp: any): void;
215
- private removeFromCache;
216
- static ɵfac: i0.ɵɵFactoryDeclaration<SPPagedEntityLoader<any, any>, never>;
217
- static ɵdir: i0.ɵɵ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>;
218
- }
219
- export {};
@@ -1,87 +0,0 @@
1
- /**
2
- * Pagination HTTP request params. Actually copied from Angular's HttpParams
3
- * declaration. The ReadonlyArray<string|number|boolean> is a bit of an
4
- * overkill for pagination params, but what the heck. When you copy-paste,
5
- * do it in full!
6
- */
7
- export type SPPageParams = {
8
- [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
9
- };
10
- /**
11
- * An interface that the clients should provide, either via a global config
12
- * (see above), that handles parsing the GET response and returns the entities
13
- * stored therein. This class will allow the entity-list component to be
14
- * used across different pagination response types as long as the appropriate
15
- * SPEntityListPaginator class is provided to the component.
16
- */
17
- export interface SPEntityListPaginator {
18
- /**
19
- * Return the HTTP request params for the given page index and page size as
20
- * an object. For example, for a REST API that supports 'skip' and 'top' params,
21
- * the implementation would be:
22
- *
23
- * ```typescript
24
- * getRequestPageParams(endpoint: string, pageIndex: number, pageSize: number): SPPageParams {
25
- * return {
26
- * skip: pageIndex * pageSize,
27
- * top: pageSize
28
- * };
29
- * }
30
- * ```
31
- * @param endpoint
32
- * @param pageIndex
33
- * @param pageSize
34
- * @returns
35
- */
36
- getRequestPageParams: (endpoint: string, pageIndex: number, pageSize: number) => SPPageParams;
37
- /**
38
- * Parse the HTTP response received from the GET request and return an object
39
- * containing the total number of entities available and the array of entities
40
- * for the current page. For example, for the pure DRF paginated response
41
- * like below:
42
- * ```json
43
- * {
44
- * "count": 102,
45
- * "next": "http://api.example.org/entities/?page=3",
46
- * "previous": "http://api.example.org/entities/?page=1",
47
- * "results": [
48
- * {
49
- * "id": 1,
50
- * "name": "Entity 1"
51
- * },
52
- * {
53
- * "id": 2,
54
- * "name": "Entity 2"
55
- * }
56
- * ]
57
- * }
58
- * ```
59
- * The implementation would be:
60
- * ```typescript
61
- * parseRequestResponse<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'>(
62
- * entityName: string,
63
- * entityNamePlural: string,
64
- * endpoint: string,
65
- * params: SPPageParams,
66
- * resp: any
67
- * ): { total: number; entities: TEntity[] } {
68
- * return {
69
- * total: resp.count,
70
- * entities: resp.results
71
- * };
72
- * }
73
- * ```
74
- * @param entityName
75
- * @param entityNamePlural
76
- * @param endpoint
77
- * @param params
78
- * @param resp
79
- * @returns
80
- */
81
- parseRequestResponse: <TEntity extends {
82
- [P in IdKey]: PropertyKey;
83
- }, IdKey extends string = 'id'>(entityName: string, entityNamePlural: string, endpoint: string, params: SPPageParams, resp: any) => {
84
- total: number;
85
- entities: TEntity[];
86
- };
87
- }
@@ -1,70 +0,0 @@
1
- import { SPIntlDateFormat } from '@smallpearl/ngx-helper/locale';
2
- import { Observable } from 'rxjs';
3
- import { SPEntityFieldConfig } from './provider';
4
- type FieldValueTypes = string | number | Date | boolean;
5
- /**
6
- * This structure defines the data formatting details for a field of the
7
- * entity. All entity fields need not necessarily be actual entity object's
8
- * properties. Fields can also be computed fields, in which case the valueFn
9
- * should be initialized with a valid function to provide the field's value.
10
- */
11
- export type SPEntityFieldSpec<TEntity extends {
12
- [P in IdKey]: PropertyKey;
13
- }, IdKey extends string = 'id'> = {
14
- name: string;
15
- label?: string | Observable<string>;
16
- valueOptions?: {
17
- dateTimeFormat?: SPIntlDateFormat;
18
- isCurrency?: boolean;
19
- currency?: string;
20
- class?: string;
21
- alignment?: 'start' | 'center' | 'end';
22
- routerLink?: ((e: TEntity) => string[]) | [string];
23
- };
24
- valueFn?: (item: TEntity) => FieldValueTypes | Observable<FieldValueTypes>;
25
- };
26
- /**
27
- * A class that represents a SPEntityFieldSpec<>. This is typically used
28
- * by the library to evaluate a SPEntityFieldSpec<> object.
29
- */
30
- export declare class SPEntityField<TEntity extends {
31
- [P in IdKey]: PropertyKey;
32
- }, IdKey extends string = 'id'> {
33
- fieldConfig?: SPEntityFieldConfig | undefined;
34
- _fieldSpec: SPEntityFieldSpec<TEntity, IdKey>;
35
- constructor(spec: SPEntityFieldSpec<TEntity, IdKey> | string, fieldConfig?: SPEntityFieldConfig | undefined);
36
- get spec(): SPEntityFieldSpec<TEntity, IdKey>;
37
- /**
38
- * Returns the effective fieldValueOptions by merging the global field
39
- * options (if one has been spefified) with the local field value options.
40
- * @returns SPEntityFieldSpec<any>['valueOptions']
41
- */
42
- get options(): {
43
- dateTimeFormat?: SPIntlDateFormat;
44
- isCurrency?: boolean;
45
- currency?: string;
46
- class?: string;
47
- alignment?: "start" | "center" | "end";
48
- routerLink?: [string] | ((e: TEntity) => string[]) | undefined;
49
- };
50
- /**
51
- * @returns the label for the field.
52
- */
53
- label(): Observable<string>;
54
- /**
55
- * Given an entity, returns the value of the field matching the
56
- * SPEntityFieldSpec<> in fieldSpec.
57
- * @param entity TEntity instance which will be evaluated for
58
- * SPEntityFieldSpec<>.
59
- * @returns
60
- */
61
- value(entity: TEntity): any;
62
- /**
63
- * If specified, will be added to the CSS classes of the field's wrapper
64
- * element.
65
- */
66
- get class(): string;
67
- hasRouterLink(entity: TEntity): boolean;
68
- getRouterLink(entity: TEntity): string[];
69
- }
70
- export {};
@@ -1,27 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { SPEntityFieldSpec } from './entity-field';
3
- export type FIELD_VALUE_FN = (entity: any, fieldName: string) => string | number | Date | boolean;
4
- /**
5
- * Global config for SPEntityField component.
6
- */
7
- export interface SPEntityFieldConfig {
8
- /**
9
- * These are global field value functions.
10
- *
11
- * If a value function for a field is not explicitly specified, this map is
12
- * looked up with the field name. If an entry exists in this table, it will
13
- * be used to render the field's value.
14
- *
15
- * This is useful for formatting certain fields which tend to have the
16
- * same name across the app. For instance fields such as 'amount', 'total'
17
- * or 'balance'. Or 'date', 'timestamp', etc.
18
- */
19
- fieldValueFns?: Map<string, FIELD_VALUE_FN>;
20
- /**
21
- * Similar to above, but allows setting the options for certain fields
22
- * globally. As in the case of `fieldValueFns`, the per field specification,
23
- * if one exists, takes precedence over the global setting.
24
- */
25
- fieldValueOptions?: Map<string, SPEntityFieldSpec<any>['valueOptions']>;
26
- }
27
- export declare const SP_ENTITY_FIELD_CONFIG: InjectionToken<SPEntityFieldConfig>;
@@ -1,52 +0,0 @@
1
- import { HttpErrorResponse } from '@angular/common/http';
2
- import { ChangeDetectorRef } from '@angular/core';
3
- import { UntypedFormGroup } from '@angular/forms';
4
- import { Observable } from 'rxjs';
5
- /**
6
- * Handle's form validation errors sent from the server by setting the returned
7
- * error code in the respective control. Errors not associated with any control
8
- * in the form are attached to the form itself.
9
- *
10
- * These errors can then be rendered using error-tailor. All that needs to be
11
- * done is to import errorTailorImports in the respective page's module and set
12
- * the 'errorTailor' directive on the <form..> element.
13
- *
14
- * @param form FormGroup instance
15
- * @param error error object
16
- */
17
- export declare function handleValidationErrors(form: UntypedFormGroup, error: HttpErrorResponse, cdr?: ChangeDetectorRef): Observable<any>;
18
- /**
19
- * Returns an rxjs operator that would track an http request's error
20
- * state and if the return code is 400, would enumerate the error codes
21
- * set in the response body and set the error state of corresponding
22
- * form controls.
23
- *
24
- * Use it like below:
25
- *
26
- * this.http.get<User>('https://google.com/..').pipe(
27
- * setServerErrorsAsFormErrors(form),
28
- * tap(user => {
29
- * if (user) { // if user = null, it means there was a server validation
30
- * // error.
31
- * this.user = user;
32
- * }
33
- * })
34
- * ).subscribe();
35
- *
36
- * Note that setServerErrorsAsFormErrors() is the last operator in
37
- * the operators list. This is important because if a server validation
38
- * error is encountered, setServerErrorsAsFormErrors(), would place
39
- * the error on the respective form control and in the end would
40
- * return Observable<null>. Any subsequent opeators that are added
41
- * to the list after this should check for this null value in its
42
- * handler.
43
- *
44
- * @param form The FormGroup instance where the controls corresponding
45
- * to the errors are looked up and its control.error is set to the
46
- * returned error code.
47
- * @param cdr ChangeDetectorRef instance. If provided, it would be
48
- * used to detect changes after the error codes are set on the form
49
- * controls.
50
- * @returns An rxjs op that can be added to the pipe() arg list.
51
- */
52
- export declare function setServerErrorsAsFormErrors(form: UntypedFormGroup, cdr?: ChangeDetectorRef): <T>(source: Observable<T>) => Observable<T>;
@@ -1,41 +0,0 @@
1
- import { ElementRef, OnInit } from '@angular/core';
2
- import { MatMenuTrigger } from '@angular/material/menu';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * A directive to make a button triggered mat-menu open during mouse hover.
6
- * Use it like this:
7
-
8
- <button #menuTrigger="matMenuTrigger"
9
- mat-icon-button
10
- [matMenuTriggerFor]="children"
11
- hoverDropDown
12
- [menu]="children"
13
- [hoverTrigger]="menuTrigger">
14
- <mat-icon>menu</mat-icon>
15
- </button>
16
- <mat-menu #children="matMenu" hasBackdrop="false">
17
- <button mat-menu-item (click)="onEdit()">Edit</button>
18
- <button mat-menu-item (click)="onDelete()">Delete</button>
19
- </mat-menu>
20
-
21
- Note how hoverDropDown and [hoverTrigger] are used to wire up the button
22
- and the associated mat-menu to the directive. Once setup like this, the
23
- mat-menu will be opened whenever the mouse cursor hovers over the menu
24
- trigger button.
25
-
26
- Copied from:
27
- https://stackoverflow.com/questions/54301126/how-to-show-the-angular-material-drop-down-on-mouse-over
28
- */
29
- export declare class HoverDropDownDirective implements OnInit {
30
- private el;
31
- static _menuClicked: boolean;
32
- isInHoverBlock: boolean;
33
- constructor(el: ElementRef);
34
- hoverTrigger: import("@angular/core").InputSignal<MatMenuTrigger | null | undefined>;
35
- menu: import("@angular/core").InputSignal<any>;
36
- ngOnInit(): void;
37
- private setHoverState;
38
- private checkHover;
39
- static ɵfac: i0.ɵɵFactoryDeclaration<HoverDropDownDirective, never>;
40
- static ɵdir: i0.ɵɵDirectiveDeclaration<HoverDropDownDirective, "[hoverDropDown]", never, { "hoverTrigger": { "alias": "hoverTrigger"; "required": false; "isSignal": true; }; "menu": { "alias": "menu"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
41
- }
@@ -1,14 +0,0 @@
1
- import { PipeTransform } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * This is a replacement for Angular's native currency pipe. This uses
5
- * web standardized Intl.NumberFormat() API to format currency. The advantage
6
- * of this over Angular's version is that this pipe allows the locale and
7
- * currency parameters to be dynamically changed during runtime.
8
- */
9
- export declare class SPCurrencyPipe implements PipeTransform {
10
- constructor();
11
- transform(value: number | bigint | string, currency?: string): string | null;
12
- static ɵfac: i0.ɵɵFactoryDeclaration<SPCurrencyPipe, never>;
13
- static ɵpipe: i0.ɵɵPipeDeclaration<SPCurrencyPipe, "spCurrency", true>;
14
- }
@@ -1,14 +0,0 @@
1
- import { PipeTransform } from '@angular/core';
2
- import { SPIntlDateFormat } from './providers';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * An alternative to the Angular built-in `DatePipe` based on the native `Intl.DateTimeFormat` API.
6
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
7
- * https://angular.io/api/common/DatePipe
8
- */
9
- export declare class SPDatePipe implements PipeTransform {
10
- #private;
11
- transform(value: Date | number | string, format?: SPIntlDateFormat, timeZone?: string): string | null;
12
- static ɵfac: i0.ɵɵFactoryDeclaration<SPDatePipe, never>;
13
- static ɵpipe: i0.ɵɵPipeDeclaration<SPDatePipe, "spDate", true>;
14
- }
@@ -1 +0,0 @@
1
- export declare function spFormatCurrency(value: number | bigint | string, currency?: string): string | null;
@@ -1,2 +0,0 @@
1
- import { SPIntlDateFormat } from "./providers";
2
- export declare function spFormatDate(value: Date | number | string, format?: SPIntlDateFormat, timeZone?: string): string;
@@ -1 +0,0 @@
1
- export declare const isEmpty: (value: any) => boolean;