@smallpearl/ngx-helper 0.33.50 → 20.0.2

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 +8 -8
  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,6 +1,1075 @@
1
- export * from './src/convert-context-input-to-http-context';
2
- export * from './src/mat-entity-crud-form-base';
3
- export * from './src/mat-entity-crud-types';
4
- export * from './src/mat-entity-crud.component';
5
- export * from './src/preview-pane.component';
6
- export * from './src/providers';
1
+ import * as _angular_core from '@angular/core';
2
+ import { InjectionToken, OnInit, OnDestroy, ChangeDetectorRef, InputSignal, TemplateRef, EmbeddedViewRef, ViewContainerRef, QueryList, EventEmitter, Injector } from '@angular/core';
3
+ import { HttpContextToken, HttpContext, HttpParams, HttpClient } from '@angular/common/http';
4
+ import { SPContextMenuItem } from '@smallpearl/ngx-helper/mat-context-menu';
5
+ import { Observable, Subscription } from 'rxjs';
6
+ import { AbstractControl } from '@angular/forms';
7
+ import { TranslocoService } from '@jsverse/transloco';
8
+ import * as _smallpearl_ngx_helper_entity_field from '@smallpearl/ngx-helper/entity-field';
9
+ import { MatSnackBar } from '@angular/material/snack-bar';
10
+ import { MatColumnDef } from '@angular/material/table';
11
+ import { DomSanitizer } from '@angular/platform-browser';
12
+ import { SPMatEntityListComponent } from '@smallpearl/ngx-helper/mat-entity-list';
13
+
14
+ /**
15
+ * Prototype of the function to parse the CRUD action response.
16
+ */
17
+ type SPMatEntityCrudResponseParser = (entityName: string, idKey: string, method: string, // 'create' | 'retrieve' | 'update' | 'delete',
18
+ resp: any) => any | undefined;
19
+ /**
20
+ * Global config for SPMatEntityList component.
21
+ */
22
+ interface SPMatEntityCrudConfig {
23
+ /**
24
+ * The item actions that will be shown for each item in the list.
25
+ * This defaults to 'Update' & 'Delete' actions, but can be customized
26
+ * by this property. Note the item actions can be set for individual
27
+ * <sp-mat-entity-crud> component through its itemActions property.
28
+ */
29
+ defaultItemActions?: SPContextMenuItem[];
30
+ /**
31
+ * Global crud response parser.
32
+ */
33
+ crudOpResponseParser?: SPMatEntityCrudResponseParser;
34
+ }
35
+ /**
36
+ * This is the interface through which the client provided CRUD form component
37
+ * interacts with the 'host' SPMatEntityCrudComponent. When the form wants to
38
+ * submit an entity to the server (for create or update), it should call the
39
+ * one of the create or update methods. The interface also provides other
40
+ * methods for the form component to interact with SPMatEntityCrudComponent
41
+ * such as refresh its entities list, close the form pane, etc.
42
+ *
43
+ * The interface name has a 'Bridge' as the interface acts as a bridge between
44
+ * the client provided form handler component and the host
45
+ * SPMatEntityCrudComponent.
46
+ */
47
+ interface SPMatEntityCrudCreateEditBridge {
48
+ /**
49
+ * Returns the entity name as provided to the host SPMatEntityCrudComponent.
50
+ * @returns The entity name string.
51
+ */
52
+ getEntityName(): string;
53
+ /**
54
+ * Returns the entity id key as provided to the host SPMatEntityCrudComponent.
55
+ * @returns The entity id key string.
56
+ */
57
+ getIdKey(): string;
58
+ /**
59
+ * Get Entity url
60
+ * @param cancel
61
+ * @returns
62
+ */
63
+ getEntityUrl(entityId: any): string;
64
+ /**
65
+ * Close the edit/update form pane. This WON'T call the 'cancelEditCallback'
66
+ * even if one is registered.
67
+ */
68
+ close: (cancel: boolean) => void;
69
+ /**
70
+ * Client form view can register a callback that will be invoked by the
71
+ * framework when user cancels the create/edit operation by clicking on the
72
+ * close button on the top right.
73
+ * @param callback
74
+ * @returns None
75
+ */
76
+ registerCanCancelEditCallback: (callback: () => boolean) => void;
77
+ /**
78
+ * Create a new instance of TEntity, by sending a POST request to remote.
79
+ * @param entityValue This is the typically the output of Reactive form's
80
+ * form.value. Since this value's shape may be different from TEntity and is
81
+ * known only to client form, we use 'any'.
82
+ * @returns None
83
+ * @inner Implementation will show a busy wheel centered on the form
84
+ * view while the async function to update the object remains active.
85
+ */
86
+ create: (entityValue: any) => Observable<any>;
87
+ /**
88
+ * Update the entity with id `id` with new values in entityValue.
89
+ * @param id TEntity id
90
+ * @param entityValue Entity values to be updated.
91
+ * @returns None
92
+ * @inner Implementation will show a busy wheel centered on the form
93
+ * view while the async function to update the object remains active.
94
+ */
95
+ update: (id: any, entityValue: any) => Observable<any>;
96
+ }
97
+ /**
98
+ * Prototype of the function that will be used instead of HttpClient for
99
+ * CRUD operations.
100
+ * @param op - the CRUD operation being requested
101
+ * @param entityValue - The entity or entity value upon which the operation
102
+ * is being requested. for 'create' & 'update' this will be the value
103
+ * of the reactive form. This is typically form.value or the 2nd arg to create
104
+ * & update methods of SPMatEntityCrudCreateEditBridge.
105
+ */
106
+ type CRUD_OP_FN<TEntity extends {
107
+ [P in IdKey]: PropertyKey;
108
+ }, IdKey extends string = 'id'> = (op: string, id: TEntity[IdKey] | undefined, // valid only for 'get', 'update' & 'delete'
109
+ entityValue: any, // valid only for 'create' & 'update'
110
+ entityCrudComponent: any) => Observable<TEntity | null>;
111
+ type ALLOW_ITEM_ACTION_FN<TEntity> = (entity: TEntity, action: string) => boolean;
112
+ /**
113
+ * This interface is used to define sub types for the "New {{item}}" button on
114
+ * top of the CRUD UI. An array of these is provided as the value to the
115
+ * component property 'newItemSubTypes'.
116
+ */
117
+ interface NewItemSubType {
118
+ /**
119
+ * A role string that will be passed as argument to the (action) event
120
+ * handler. This string allows the event handler to distinguish the selected
121
+ * sub-type.
122
+ *
123
+ * The special keyword '_new_' can be used to activate the
124
+ * `createEditTemplate` template if one is provided. In this case the params
125
+ * element value (see below) can be used in the template to distinguish
126
+ * between different menu items.
127
+ */
128
+ role: string;
129
+ /**
130
+ * Label displayed in the menu representing this role.
131
+ */
132
+ label: string;
133
+ /**
134
+ * Arbitrary value that will be passed to the 'createEditTemplate' in the
135
+ * $implicit template context as 'params'. You can access this in the
136
+ * template like below (see `data.params`):-
137
+ ```
138
+ <ng-template #createEdit let-data>
139
+ <app-create-edit-entity-demo
140
+ [bridge]="data.bridge"
141
+ [entity]="data.entity"
142
+ [params]="data.params"
143
+ ></app-create-edit-entity-demo>
144
+ </ng-template>
145
+ ```
146
+
147
+ If params is an object and it includes the key 'title', its value will be
148
+ used as the title for the edit form.
149
+ */
150
+ params?: any;
151
+ }
152
+ type CrudOp = 'create' | 'retrieve' | 'update' | 'delete' | undefined;
153
+ interface SPMatEntityCrudHttpContext {
154
+ entityName: string;
155
+ entityNamePlural: string;
156
+ endpoint: string;
157
+ op: CrudOp;
158
+ }
159
+ declare const SP_MAT_ENTITY_CRUD_HTTP_CONTEXT: HttpContextToken<SPMatEntityCrudHttpContext>;
160
+
161
+ declare const SP_MAT_ENTITY_CRUD_CONFIG: InjectionToken<SPMatEntityCrudConfig>;
162
+
163
+ type HttpContextInput = [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext;
164
+ /**
165
+ * Converts array of HttpContextToken key, value pairs to HttpContext
166
+ * object in argument 'context'.
167
+ * @param context HTTP context to which the key, value pairs are added
168
+ * @param reqContext HttpContextToken key, value pairs array
169
+ * @returns HttpContext object, with the key, value pairs added. This is
170
+ * the same object as the 'context' argument.
171
+ */
172
+ declare function convertHttpContextInputToHttpContext(context: HttpContext, reqContext: HttpContextInput): HttpContext;
173
+
174
+ /**
175
+ * Describes an action on an item in the MatEntityCrud component. Actions are
176
+ * shown in the context menu for each entity in the MatEntityCrud component.
177
+ * The action is triggered when the user selects the corresponding menu item.
178
+ * There are two ways to handle the action when it is triggered (user selects
179
+ * the corresponding menu item):
180
+ *
181
+ * 1. If the action's 'role' property is one of the predefined roles
182
+ * ('_edit_', '_view_', '_delete_'), the MatEntityCrud component handles
183
+ * the action internally by opening the corresponding dialog (edit/view)
184
+ * or performing the delete operation.
185
+ * 2. If the action maps to a HTTP REST API endpoint on the item at the server,
186
+ * the MatEntityCrud component can perform the HTTP request. To enable this,
187
+ * the application must set the action's 'behavior' property to 'http' and
188
+ * if the REST request differs from the default POST to the entity's base URL
189
+ * with the action's 'role' appended as the URL path, provide the necessary
190
+ * HTTP request parameters in the 'httpRequestParameters' property.
191
+ * 3. For all other actions, the MatEntityCrud component emits an 'action'
192
+ * event with the action's 'role' and the entity as arguments. The
193
+ * application can listen to this event and handle the action as needed.
194
+ *
195
+ * @template TEntity The type of the entity on which the action is performed.
196
+ */
197
+ interface MatEntityCrudItemAction<TEntity extends {
198
+ [P in IdKey]: PropertyKey;
199
+ }, IdKey extends string = 'id'> extends SPContextMenuItem {
200
+ /**
201
+ * Optional confirmation prompt message to be shown to the user
202
+ * before performing the action. If specified, the user must confirm
203
+ * the action before it is executed.
204
+ */
205
+ confirmPrompt?: string;
206
+ /**
207
+ * Optional message to be shown to the user after the action is
208
+ * successfully performed.
209
+ */
210
+ successMessage?: string;
211
+ /**
212
+ * Optional error message to be shown to the user if the action fails.
213
+ */
214
+ errorMessage?: string;
215
+ /**
216
+ * HTTP request parameters for actions that map to HTTP REST API
217
+ * endpoints on the item at the server. This property is used when
218
+ * 'actionBehavior' is set to 'http'.
219
+ *
220
+ * If not specified, and behavior is set to 'http', a POST request is
221
+ * made to the entity's base URL with the action's 'role' appended
222
+ * as the URL path.
223
+ */
224
+ httpRequestParameters?: {
225
+ method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
226
+ urlPath?: string;
227
+ params?: HttpParams;
228
+ body?: any;
229
+ };
230
+ /**
231
+ * Custom handler function to be called when the action is triggered.
232
+ * If provided, this function is called instead of the default handling
233
+ * by the MatEntityCrud component. This property takes precedence over
234
+ * `httpRequestParameters`.
235
+ *
236
+ * @param entity The entity on which the action is performed.
237
+ */
238
+ action?: (entity: TEntity) => void;
239
+ }
240
+
241
+ /**
242
+ * This is a convenience base class that clients can derive from to implement
243
+ * their CRUD form component. Particularly this class registers the change
244
+ * detection hook which will be called when the user attempts to close the
245
+ * form's parent container pane via the Close button on the top right.
246
+ *
247
+ * This button behaves like a Cancel button in a desktop app and therefore if
248
+ * the user has entered any data in the form's controls, (determined by
249
+ * checking form.touched), then a 'Lose Changes' prompt is displayed allowing
250
+ * the user to cancel the closure.
251
+ *
252
+ * The `@Component` decorator is fake to keep the VSCode angular linter quiet.
253
+ *
254
+ * This class can be used in two modes:
255
+ *
256
+ * I. SPMatEntityCrudComponent mode
257
+ * This mode relies on a bridge interface that implements the
258
+ * SPMatEntityCrudCreateEditBridge interface to perform the entity
259
+ * load/create/update operations. This is the intended mode when the
260
+ * component is used as a part of the SPMatEntityCrudComponent to
261
+ * create/update an entity. This mode requires the following properties
262
+ * to be set:
263
+ * - entity: TEntity | TEntity[IdKey] | undefined (for create)
264
+ * - bridge: SPMatEntityCrudCreateEditBridge
265
+ *
266
+ * II. Standalone mode
267
+ * This mode does not rely on the bridge interface and the component
268
+ * itself performs the entity load/create/update operations. However, if
269
+ * the `bridge` input is set, then it will be used to close the create/edit
270
+ * form pane when create/update is successful.
271
+ *
272
+ * This mode requires the following properties to be set:
273
+ * - entity: TEntity | TEntity[IdKey] | undefined (for create)
274
+ * - baseUrl: string - Base URL for CRUD operations. This URL does not
275
+ * include the entity id. The entity id will be appended to this URL
276
+ * for entity load and update operations. For create operation, this
277
+ * URL is used as is.
278
+ * - entityName: string - Name of the entity, used to parse sideloaded
279
+ * entity responses.
280
+ * - httpReqContext?: HttpContextInput - Optional HTTP context to be
281
+ * passed to the HTTP requests. For instance, if your app has a HTTP
282
+ * interceptor that adds authentication tokens to the requests based
283
+ * on a HttpContextToken, then you can pass that token here.
284
+ *
285
+ * I. SPMatEntityCrudComponent mode:
286
+ *
287
+ * 1. Declare a FormGroup<> type as
288
+ *
289
+ * ```
290
+ * type MyForm = FormGroup<{
291
+ * name: FormControl<string>;
292
+ * type: FormControl<string>;
293
+ * notes: FormControl<string>;
294
+ * }>;
295
+ * ```
296
+ *
297
+ * 2. Derive your form's component class from this and implement the
298
+ * createForm() method returing the FormGroup<> instance that matches
299
+ * the FormGroup concrete type above.
300
+ *
301
+ * ```
302
+ * class MyFormComponent extends SPMatEntityCrudFormBase<MyForm, MyEntity> {
303
+ * constructor() {
304
+ * super()
305
+ * }
306
+ * createForm() {
307
+ * return new FormGroup([...])
308
+ * }
309
+ * }
310
+ * ```
311
+ *
312
+ * 3. If your form's value requires manipulation before being sent to the
313
+ * server, override `getFormValue()` method and do it there before returning
314
+ * the modified values.
315
+ *
316
+ * 4. Wire up the form in the template as below
317
+ *
318
+ * ```html
319
+ * @if (loadEntity$ | async) {
320
+ * <form [formGroup]='form'.. (ngSubmit)="onSubmit()">
321
+ * <button type="submit">Submit</button>
322
+ * </form>
323
+ * } @else {
324
+ * <div>Loading...</div>
325
+ * }
326
+ * ```
327
+ *
328
+ * Here `loadEntity$` is an Observable<boolean> that upon emission of `true`
329
+ * indicates that the entity has been loaded from server (in case of edit)
330
+ * and the form is ready to be displayed. Note that if the full entity was
331
+ * passed in the `entity` input property, then no server load is necessary
332
+ * and the form will be created immediately.
333
+ *
334
+ * 5. In the parent component that hosts the SPMatEntityCrudComponent, set
335
+ * the `entity` and `bridge` input properties of this component to
336
+ * appropriate values. For instance, if your form component has the
337
+ * selector `app-my-entity-form`, then the parent component's template
338
+ * will have:
339
+ *
340
+ * ```html
341
+ * <sp-mat-entity-crud
342
+ * ...
343
+ * createEditFormTemplate="entityFormTemplate"
344
+ * ></sp-mat-entity-crud>
345
+ * <ng-template #entityFormTemplate let-data="data">
346
+ * <app-my-entity-form
347
+ * [entity]="data.entity"
348
+ * [bridge]="data.bridge"
349
+ * ></app-my-entity-form>
350
+ * </ng-template>
351
+ * ```
352
+ *
353
+ * II. Standalone mode
354
+ *
355
+ * 1..4. Same as above, except set the required `bridge` input to `undefined`.
356
+ * 5. Initialize the component's inputs `baseUrl` and `entityName` with the
357
+ * appropriate values. If you would like to pass additional HTTP context to
358
+ * the HTTP requests, then set the `httpReqContext` input as well.
359
+ * If the entity uses an id key other than 'id', then set the `idKey` input
360
+ * to the appropriate id key name.
361
+ * 6. If you want to retrieve the created/updated entity after the create/update
362
+ * operation, override the `onPostCreate()` and/or `onPostUpdate()` methods
363
+ * respectively.
364
+ */
365
+ declare abstract class SPMatEntityCrudFormBase<TFormGroup extends AbstractControl, TEntity extends {
366
+ [P in IdKey]: PropertyKey;
367
+ }, IdKey extends string = 'id'> implements OnInit, OnDestroy {
368
+ entity: _angular_core.InputSignal<TEntity | TEntity[IdKey] | undefined>;
369
+ bridge: _angular_core.InputSignal<SPMatEntityCrudCreateEditBridge | undefined>;
370
+ params: _angular_core.InputSignal<any>;
371
+ entityName: _angular_core.InputSignal<string | undefined>;
372
+ baseUrl: _angular_core.InputSignal<string | undefined>;
373
+ httpReqContext: _angular_core.InputSignal<HttpContextInput | undefined>;
374
+ idKey: _angular_core.InputSignal<string>;
375
+ loadEntity$: Observable<boolean>;
376
+ loadResponse: _angular_core.WritableSignal<any>;
377
+ _entity: _angular_core.WritableSignal<TEntity | undefined>;
378
+ sub$: Subscription;
379
+ _form: _angular_core.WritableSignal<TFormGroup | undefined>;
380
+ form: _angular_core.Signal<TFormGroup>;
381
+ transloco: TranslocoService;
382
+ cdr: ChangeDetectorRef;
383
+ http: HttpClient;
384
+ canCancelEdit: () => boolean;
385
+ _canCancelEdit(): boolean;
386
+ ngOnInit(): void;
387
+ ngOnDestroy(): void;
388
+ /**
389
+ * Additional parameters for loading the entity, in case this.entity() value
390
+ * is of type TEntity[IdKey].
391
+ * @returns
392
+ */
393
+ getLoadEntityParams(): string | HttpParams;
394
+ /**
395
+ * Returns true if the entity needs to be loaded from server. The default
396
+ * implementation returns true if the `entity` parameter is not an object,
397
+ * indicating that it's of type 'TEntity[IdKey]' or is undefined. Derived
398
+ * classes can override this method to provide custom logic.
399
+ * @param entityOrId
400
+ * @returns Whether the entity needs to be loaded from server.
401
+ */
402
+ loadEntityRequired(entityOrId: TEntity | TEntity[IdKey] | undefined): boolean | undefined;
403
+ /**
404
+ * Return the TEntity object from the response returned by the
405
+ * load() method. Typically entity load returns the actual
406
+ * entity object itself. In some cases, where response is sideloaded, the
407
+ * default implementation here uses the `sideloadToComposite()` utility to
408
+ * extract the entity from the response after merging (inplace) the
409
+ * sideloaded data into a composite.
410
+ *
411
+ * If you have a different response shape, or if your sideloaded object
412
+ * response requires custom custom `sideloadDataMap`, override this method
413
+ * and implement your custom logic to extract the TEntity object from the
414
+ * response.
415
+ * @param resp
416
+ * @returns
417
+ */
418
+ getEntityFromLoadResponse(resp: any): TEntity | undefined;
419
+ /**
420
+ * Create the TFormGroup FormGroup class that will be used for the reactive
421
+ * form.
422
+ * @param entity
423
+ */
424
+ abstract createForm(entity: TEntity | undefined): TFormGroup;
425
+ /**
426
+ * Override to customize the id key name if it's not 'id'
427
+ * @returns The name of the unique identifier key that will be used to
428
+ * extract the entity's id for UPDATE operation.
429
+ */
430
+ getIdKey(): string;
431
+ getBusyWheelName(): string;
432
+ /**
433
+ * Return the form's value to be sent to server as Create/Update CRUD
434
+ * operation data.
435
+ * @returns
436
+ */
437
+ getFormValue(): any;
438
+ onSubmit(): void;
439
+ /**
440
+ * Reset the form to its initial state. This is a generic implementation
441
+ * that recursively resets all FormGroup and FormArray controls.
442
+ */
443
+ onReset(): void;
444
+ onPostCreate(entity: TEntity): void;
445
+ onPostUpdate(entity: TEntity): void;
446
+ /**
447
+ * Loads the entity if `this.entity()` is of type TEntity[IdKey]. If `bridge`
448
+ * input is defined, then it's `loadEntity()` method is used to load the
449
+ * entity. Otherwise, then this method attempts to load the entity using
450
+ * HTTP GET from the URL derived from `baseUrl` input.
451
+ * @param entityOrId Can be full entity or just the entity id.
452
+ * @returns
453
+ */
454
+ load(entityOrId: any): Observable<TEntity>;
455
+ /**
456
+ * Loads the entity using HTTP GET from the URL derived from `baseUrl` input.
457
+ */
458
+ protected loadEntity(entityId: any): Observable<TEntity>;
459
+ /**
460
+ * Create a new entity using the bridge if defined, otherwise using HTTP
461
+ * POST to the `baseUrl`.
462
+ * @param values
463
+ * @returns
464
+ */
465
+ protected create(values: any): Observable<TEntity>;
466
+ protected createEntity(values: any): Observable<TEntity>;
467
+ /**
468
+ * Update an existing entity using the bridge if defined, otherwise using HTTP
469
+ * PATCH to the URL derived from `baseUrl` and the entity id.
470
+ * @param id
471
+ * @param values
472
+ * @returns
473
+ */
474
+ protected update(id: any, values: any): Observable<TEntity>;
475
+ protected updateEntity(id: any, values: any): Observable<TEntity>;
476
+ /**
477
+ * Override to get the standalone mode indicator. Standalone mode is
478
+ * when both `baseUrl` and `entityName` inputs are defined. This is indication
479
+ * that the component should perform the CRUD operations itself instead
480
+ * of relying on the `bridge` input.
481
+ * @returns
482
+ */
483
+ protected getStandaloneMode(): boolean;
484
+ /**
485
+ * Wrapper around entityName input to get the entity name. If `bridge` input
486
+ * is defined, then its `getEntityName()` method is used. This allows
487
+ * derived classes to override this method to provide custom logic to
488
+ * determine the entity name.
489
+ * @returns
490
+ */
491
+ protected getEntityName(): string | undefined;
492
+ /**
493
+ * Returns the baseUrl. Derived classes can override this to provide custom
494
+ * logic to determine the baseUrl.
495
+ * @returns
496
+ */
497
+ protected getBaseUrl(): string | undefined;
498
+ /**
499
+ * Returns the entity URL for the given entity id. If `bridge` input is
500
+ * defined, then its `getEntityUrl()` method is used. Otherwise, the URL is
501
+ * derived from `baseUrl` input.
502
+ * @param entityId
503
+ * @returns
504
+ */
505
+ protected getEntityUrl(entityId: any): string;
506
+ protected getRequestContext(): HttpContext;
507
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SPMatEntityCrudFormBase<any, any, any>, never>;
508
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SPMatEntityCrudFormBase<any, any, any>, "_#_sp-mat-entity-crud-form-base_#_", never, { "entity": { "alias": "entity"; "required": false; "isSignal": true; }; "bridge": { "alias": "bridge"; "required": false; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; "entityName": { "alias": "entityName"; "required": false; "isSignal": true; }; "baseUrl": { "alias": "baseUrl"; "required": false; "isSignal": true; }; "httpReqContext": { "alias": "httpReqContext"; "required": false; "isSignal": true; }; "idKey": { "alias": "idKey"; "required": false; "isSignal": true; }; }, {}, never, never, false, never>;
509
+ }
510
+
511
+ /**
512
+ * SPMatEntityCrudCreateEditBridge implementer uses this interface to
513
+ * communicate with the parent SPMatEntityCreateComponent. The bridge
514
+ * component would use the hideCreateEdit() to close itself, when user cancels
515
+ * the create/edit operation.
516
+ */
517
+ interface SPMatEntityCrudComponentBase<TEntity extends {
518
+ [P in IdKey]: PropertyKey;
519
+ }, IdKey extends string = 'id'> {
520
+ /**
521
+ * Wrappers around entityName & entityNamePlural properties.
522
+ */
523
+ getEntityName(): string;
524
+ getEntityNamePlural(): string;
525
+ /**
526
+ * Wrapper around idKey property.
527
+ */
528
+ getIdKey(): string;
529
+ /**
530
+ * This method should return the entity URL for the given entity id.
531
+ * The entity URL should include any additional query parameters that were
532
+ * passed to the SPMatEntityCrudComponentBase component's `url` property.
533
+ * @param id
534
+ */
535
+ getEntityUrl(id: TEntity[IdKey] | undefined): string;
536
+ /**
537
+ * FormViewHostComponent will call this to close the Create/Edit pane.
538
+ * SPMatEntityCrudComponentBase implementor will destroy the client form
539
+ * view and hide the Create/Edit form view pane and show the hidden
540
+ * entity list view.
541
+ * @returns
542
+ */
543
+ closeCreateEdit: (cancelled: boolean) => void;
544
+ /**
545
+ * Used internally by FormViewHostComponent to determine if the client form
546
+ * view wants to intercept user's cancel the create/edit operation. Perhaps
547
+ * with the Yes/No prompt 'Lose changes?'
548
+ * @returns boolean indicating it's okay to cancel the create/edit operation.
549
+ */
550
+ canCancelEdit: () => boolean;
551
+ /**
552
+ * Client form view can register a callback that will be invoked by the
553
+ * framework when user cancels the create/edit operation by clicking on the
554
+ * close button on the top right.
555
+ * @param callback
556
+ * @returns
557
+ */
558
+ registerCanCancelEditCallback: (callback: () => boolean) => void;
559
+ /**
560
+ * Initiates update on the given entity.
561
+ * @returns
562
+ */
563
+ triggerEntityUpdate: (entity: TEntity) => void;
564
+ /**
565
+ * Initiates entity delete.
566
+ * @returns
567
+ */
568
+ triggerEntityDelete: (entity: TEntity) => void;
569
+ /**
570
+ * Called by client form-view host component to close a new entity.
571
+ * @param entityValue The ReactiveForm.value object that the server expects
572
+ * to create a new object.
573
+ * @returns The new Entity object returned by the server. For typical REST
574
+ * API, this would be of the same shape as the objects returned by the
575
+ * REST's GET request.
576
+ */
577
+ create: (entityValue: any) => Observable<any>;
578
+ /**
579
+ * Called by client form-view host component to close a new entity.
580
+ * @param id The id of the entity being edited.
581
+ * @param entityValue The ReactiveForm.value object that the server expects
582
+ * to update the new object.
583
+ * @returns The new Entity object returned by the server. For typical REST
584
+ * API, this would be of the same shape as the objects returned by the
585
+ * REST's GET request.
586
+ */
587
+ update: (id: any, entityValue: any) => Observable<any>;
588
+ /**
589
+ * Close the preview pane.
590
+ * @returns
591
+ */
592
+ closePreview: () => void;
593
+ /**
594
+ * Returns the context menu items for the entity. This can be used to build
595
+ * the context menu for an entity in its preview pane toolbar.
596
+ * @returns
597
+ */
598
+ getItemActions(entity?: TEntity): SPContextMenuItem[];
599
+ /**
600
+ * Returns the class to be used for the preview pane content. This interface
601
+ * is provided to allow the PreviewPaneComponent to access the client
602
+ * configured class for the preview pane content.
603
+ */
604
+ getPreviewPaneContentClass(): string;
605
+ getFormPaneWrapperClass(): string;
606
+ getFormPaneContentClass(): string;
607
+ getItemLabel(): string | Observable<string>;
608
+ getItemLabelPlural(): string | Observable<string>;
609
+ removeEntity(id: TEntity[IdKey]): void;
610
+ /**
611
+ * Update the entity with the given id in the list of entities.
612
+ * This is typically called by the client when it has performed an update
613
+ * on the entity itself and want to reflect the resulting changed
614
+ * entity in the list view.
615
+ *
616
+ * @param id The id of the entity to update.
617
+ * @param data The updated entity.
618
+ */
619
+ updateEntity(id: TEntity[IdKey], data: TEntity): void;
620
+ /**
621
+ * Perform a custom action on the entity endpoint. The action is specified
622
+ * by the verb argument, which will be used to derive the final URL. This
623
+ * is keeping in line with DRF specification where viewsets can define
624
+ * custom action methods, which translate into endpoints with the same name
625
+ * ast he action method.
626
+ * @param id id of the entity to perform the action on.
627
+ * @param verb The action verb, which will be appended to the entity URL to
628
+ * derive the final URL for the POST request.
629
+ * @param addlParams additional query parameters to include in the request.
630
+ * Called `additional` as these are in addition to the query params specified
631
+ * in the CRUD's endpoint.
632
+ * @param data the data to send with the request for the POST
633
+ * @returns Observable<TEntity>
634
+ */
635
+ doEntityAction(id: TEntity[IdKey], verb: string, addlParams: HttpParams, data: any, busyWheelName: string): Observable<any>;
636
+ }
637
+
638
+ /**
639
+ * A preview pane container to provide a consistent UX for all preview panes.
640
+ * It consits of a toolbar on the top and a container div below that takes up
641
+ * the rest of the preview pane area.
642
+ */
643
+ declare class SPMatEntityCrudPreviewPaneComponent<TEntity extends {
644
+ [P in IdKey]: PropertyKey;
645
+ }, IdKey extends string = 'id'> implements OnInit, OnDestroy {
646
+ entity: InputSignal<TEntity>;
647
+ entityCrudComponent: InputSignal<SPMatEntityCrudComponentBase<TEntity, IdKey>>;
648
+ title: InputSignal<string | undefined>;
649
+ disableUpdate: InputSignal<boolean>;
650
+ hideUpdate: InputSignal<boolean>;
651
+ disableDelete: InputSignal<boolean>;
652
+ hideDelete: InputSignal<boolean>;
653
+ itemActions: SPContextMenuItem[];
654
+ _disableActionFactory: (role: string, signal?: InputSignal<boolean>) => _angular_core.Signal<boolean>;
655
+ _disableUpdate: _angular_core.Signal<boolean>;
656
+ _disableDelete: _angular_core.Signal<boolean>;
657
+ ngOnInit(): void;
658
+ ngOnDestroy(): void;
659
+ onEdit(): void;
660
+ onDelete(): void;
661
+ onClose(): void;
662
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SPMatEntityCrudPreviewPaneComponent<any, any>, never>;
663
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SPMatEntityCrudPreviewPaneComponent<any, any>, "sp-mat-entity-crud-preview-pane", never, { "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "entityCrudComponent": { "alias": "entityCrudComponent"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "disableUpdate": { "alias": "disableUpdate"; "required": false; "isSignal": true; }; "hideUpdate": { "alias": "hideUpdate"; "required": false; "isSignal": true; }; "disableDelete": { "alias": "disableDelete"; "required": false; "isSignal": true; }; "hideDelete": { "alias": "hideDelete"; "required": false; "isSignal": true; }; }, {}, never, ["[previewToolbarContent]", "[previewContent]"], true, never>;
664
+ }
665
+
666
+ declare class FormViewHostComponent<TEntity extends {
667
+ [P in IdKey]: PropertyKey;
668
+ }, IdKey extends string = 'id'> implements SPMatEntityCrudCreateEditBridge, OnInit, OnDestroy {
669
+ entityCrudComponentBase: _angular_core.InputSignal<SPMatEntityCrudComponentBase<TEntity, IdKey>>;
670
+ clientViewTemplate: _angular_core.InputSignal<TemplateRef<any> | null>;
671
+ _itemLabel: _angular_core.Signal<Observable<string>>;
672
+ _itemLabelPlural: _angular_core.Signal<Observable<string>>;
673
+ entity: _angular_core.WritableSignal<TEntity | undefined>;
674
+ title: _angular_core.WritableSignal<Observable<string> | undefined>;
675
+ params: _angular_core.WritableSignal<any>;
676
+ clientFormView: EmbeddedViewRef<any> | null;
677
+ vc: _angular_core.Signal<ViewContainerRef | undefined>;
678
+ config: SPMatEntityCrudConfig;
679
+ sub$: Subscription;
680
+ transloco: TranslocoService;
681
+ constructor();
682
+ ngOnInit(): void;
683
+ ngOnDestroy(): void;
684
+ show(entity: TEntity | undefined, params?: any): void;
685
+ getEntityName(): string;
686
+ getIdKey(): string;
687
+ getEntityUrl(entityId: any): string;
688
+ close(cancel: boolean): void;
689
+ registerCanCancelEditCallback(callback: () => boolean): void;
690
+ create(entityValue: any): Observable<any>;
691
+ update(id: any, entityValue: any): Observable<any>;
692
+ /**
693
+ * Creates the client view provided via template
694
+ */
695
+ createClientView(): void;
696
+ destroyClientView(): void;
697
+ onClose(): void;
698
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormViewHostComponent<any, any>, never>;
699
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormViewHostComponent<any, any>, "sp-create-edit-entity-host", never, { "entityCrudComponentBase": { "alias": "entityCrudComponentBase"; "required": true; "isSignal": true; }; "clientViewTemplate": { "alias": "clientViewTemplate"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
700
+ }
701
+
702
+ declare class PreviewHostComponent<TEntity extends {
703
+ [P in IdKey]: PropertyKey;
704
+ }, IdKey extends string = 'id'> implements OnInit, OnDestroy {
705
+ vc: _angular_core.Signal<ViewContainerRef | undefined>;
706
+ entityCrudComponentBase: _angular_core.InputSignal<SPMatEntityCrudComponentBase<TEntity, IdKey>>;
707
+ clientViewTemplate: _angular_core.InputSignal<TemplateRef<any> | null>;
708
+ entity: _angular_core.WritableSignal<TEntity | undefined>;
709
+ clientView: EmbeddedViewRef<any> | null;
710
+ constructor();
711
+ ngOnInit(): void;
712
+ ngOnDestroy(): void;
713
+ show(entity: TEntity | undefined, params?: any): void;
714
+ close(): void;
715
+ private createClientView;
716
+ destroyClientView(): void;
717
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<PreviewHostComponent<any, any>, never>;
718
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PreviewHostComponent<any, any>, "sp-entity-crud-preview-host", never, { "entityCrudComponentBase": { "alias": "entityCrudComponentBase"; "required": true; "isSignal": true; }; "clientViewTemplate": { "alias": "clientViewTemplate"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
719
+ }
720
+
721
+ declare class SPMatEntityCrudComponent<TEntity extends {
722
+ [P in IdKey]: PropertyKey;
723
+ }, IdKey extends string = 'id'> extends SPMatEntityListComponent<TEntity, IdKey> implements SPMatEntityCrudComponentBase<TEntity, IdKey> {
724
+ private snackBar;
725
+ itemLabel: _angular_core.InputSignal<string | Observable<string> | undefined>;
726
+ itemLabelPlural: _angular_core.InputSignal<string | Observable<string> | undefined>;
727
+ /**
728
+ * Title string displayed above the component. If not specified, will use
729
+ * itemLabelPlural() as the title.
730
+ */
731
+ title: _angular_core.InputSignal<string | Observable<string> | undefined>;
732
+ /**
733
+ *
734
+ */
735
+ itemActions: _angular_core.InputSignal<MatEntityCrudItemAction<TEntity, IdKey>[]>;
736
+ /**
737
+ * Specify the list of router paths that will be set as the value for
738
+ * [routerLink] for the 'New {{ item }}' button. If not specified,
739
+ * if createEditTemplate is specified, it will be shown. If not, `action`
740
+ * out event will be raised with `{ role: '_new_' }`.
741
+ */
742
+ newItemLink: _angular_core.InputSignal<string | string[] | undefined>;
743
+ /**
744
+ * If not specified, will default to 'New <itemLabel()>'.
745
+ */
746
+ newItemLabel: _angular_core.InputSignal<string | string[] | undefined>;
747
+ /**
748
+ * Text for the Edit <item> pane title
749
+ */
750
+ editItemTitle: _angular_core.InputSignal<string | undefined>;
751
+ /**
752
+ * If you want "New {{item}}" button to support multiple entity types,
753
+ * you can set this to `NewItemSubType[]`, where each element stands for for
754
+ * a dropdown menu item. Refer to `NewItemSubType` for details on this
755
+ * interface.
756
+ */
757
+ newItemSubTypes: _angular_core.InputSignal<NewItemSubType[] | undefined>;
758
+ /**
759
+ * If you want to take control of the network operations for the CRUD
760
+ * operations (GET/CREATE/UPDATE/DELETE), provide a value for this property.
761
+ */
762
+ crudOpFn: _angular_core.InputSignal<CRUD_OP_FN<TEntity, IdKey> | undefined>;
763
+ /**
764
+ * Item preview template.
765
+ */
766
+ previewTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
767
+ /**
768
+ * Whether to allow a context menu action or not. Return false to disable
769
+ * the action.
770
+ */
771
+ allowEntityActionFn: _angular_core.InputSignal<ALLOW_ITEM_ACTION_FN<TEntity> | undefined>;
772
+ /**
773
+ * A template that allows the header to be replaced. Usage:-
774
+ *
775
+ * ```
776
+ * <sp-map-entity-crud
777
+ * [headerTemplate]="myCrudViewHeader"
778
+ * ></sp-map-entity-crud>
779
+ * <ng-template #myCrudViewHeader>...</ng-template>
780
+ * ```
781
+ */
782
+ headerTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
783
+ /**
784
+ * Set this to the custom template identifier that will replace the
785
+ * "New {{Item}}" button portion. This template will expand towards the
786
+ * title which will be placed to its left (right in rtl).
787
+ *
788
+ * ```
789
+ * <sp-map-entity-crud
790
+ * [actionsTemplate]="myCrudActions"
791
+ * ></sp-map-entity-crud>
792
+ * <ng-template #myCrudActions>...</ng-template>
793
+ * ```
794
+ */
795
+ actionsTemplate: _angular_core.InputSignal<TemplateRef<any> | undefined>;
796
+ /**
797
+ * CRUD action response parser. This will be called with the response
798
+ * from CREATE & UPDATE operations to parse the response JSON and return
799
+ * the created/updated TEntity.
800
+ */
801
+ crudResponseParser: _angular_core.InputSignal<SPMatEntityCrudResponseParser | undefined>;
802
+ /**
803
+ * An ng-template name that contains the component which provides the
804
+ * create/edit CRUD action.
805
+ *
806
+ * ```
807
+ * <ng-template #createEdit let-data>
808
+ * <app-create-edit-entity-demo [bridge]="data.bridge" [entity]="data.entity"></app-create-edit-entity-demo>
809
+ * </ng-template>
810
+ * ```
811
+ * Note how [bridge] & [entity] properties are set deriving them from the
812
+ * implicit template context. [entity] will be undefined for Create
813
+ * opreation and will be the valid entity for an Update.
814
+ * (app-create-edit-entity-demo here is the client code that implements the
815
+ * Create/Edit form)
816
+ */
817
+ createEditFormTemplate: _angular_core.InputSignal<TemplateRef<any> | null>;
818
+ /**
819
+ * Disables the per item actions column, preventing 'Edit' & 'Delete'
820
+ * (and other user defined) item operations.
821
+ */
822
+ disableItemActions: _angular_core.InputSignal<boolean>;
823
+ /**
824
+ * Disables the Create function.
825
+ */
826
+ disableCreate: _angular_core.InputSignal<boolean>;
827
+ /**
828
+ * View refresh policy after a CREATE/UPDATE operation. Values
829
+ * 'none' - Objects are not refreshed after an edit operation. The return
830
+ * value of the edit operation is used as the object to
831
+ * add/update the component's internal store. This is the default.
832
+ * 'object' - Refresh just the object that was returned from the
833
+ * CREATE/UPDATE operation. Use this if the JSON object returned
834
+ * after a successful CREATE/UPDATE op differs from the JSON
835
+ * object returned for the GET request.
836
+ * 'all' - Refresh the entire list after a CREATE/UPDATE operation. This
837
+ * mimics the behaviour of legacy HTML apps with pure server
838
+ * defined UI.
839
+ */
840
+ refreshAfterEdit: _angular_core.InputSignal<"object" | "none" | "all">;
841
+ /**
842
+ * HttpContext for crud requests - `create`, `retrieve`, `update` & `delete`.
843
+ * Note that HttpContext for `list` operation should be set using the
844
+ * `httpReqContext` property inherited from SPMatEntityListComponent.
845
+ * The value of the property is an object where the key names reflect the CRUD
846
+ * operation with each of these keys expected to have a value of type
847
+ * `[[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext`.
848
+ *
849
+ * Alternatively the property value can be set to
850
+ * `[[HttpContextToken<any>, any]] | [HttpContextToken<any>, any] | HttpContext`,
851
+ * in which case the same context would be used for all HTTP requests.
852
+ */
853
+ crudHttpReqContext: _angular_core.InputSignal<[HttpContextToken<any>, any] | [[HttpContextToken<any>, any]] | {
854
+ create?: [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any];
855
+ retrieve?: [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any];
856
+ update?: [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any];
857
+ delete?: [[HttpContextToken<any>, any]] | [HttpContextToken<any>, any];
858
+ } | undefined>;
859
+ /**
860
+ * Width of the edit pane as a percentange of the overall <as-split> width.
861
+ */
862
+ editPaneWidth: _angular_core.InputSignal<number>;
863
+ /**
864
+ * Width of the preview pane as a percentange of the overall <as-split> width.
865
+ */
866
+ previewPaneWidth: _angular_core.InputSignal<number>;
867
+ /**
868
+ * The class class that will be applied to the list pane wrapper.
869
+ */
870
+ listPaneWrapperClass: _angular_core.InputSignal<string>;
871
+ /**
872
+ * The class class that will be applied to the preview pane wrapper.
873
+ * Inside this wrapper, another div element with class='previewPaneContentClass()'
874
+ * will be created to host the preview content. The client supplied preview
875
+ * template will be rendered inside this div.
876
+ *
877
+ * +----------------------------------------+
878
+ * | previewPaneWrapperClass |
879
+ * |----------------------------------------|
880
+ * | preview toolbar |
881
+ * |----------------------------------------|
882
+ * | +------------------------------------+ |
883
+ * | | div class=previewPaneContentClass()| |
884
+ * | |------------------------------------| |
885
+ * | | client supplied preview template | |
886
+ * | +------------------------------------+ |
887
+ * +----------------------------------------+
888
+ */
889
+ previewPaneWrapperClass: _angular_core.InputSignal<string>;
890
+ /**
891
+ * The class class that will be applied to the preview pane content.
892
+ */
893
+ previewPaneContentClass: _angular_core.InputSignal<string>;
894
+ /**
895
+ * The class class that will be applied to the form pane wrapper. Inside this
896
+ * wrapper, another div element with class='formPaneContentClass()' will be
897
+ * created to host the form content. The client supplied form template will
898
+ * be rendered inside this div.
899
+ *
900
+ * +----------------------------------------+
901
+ * | formPaneWrapperClass |
902
+ * | +------------------------------------+ |
903
+ * | | div class=formPaneContentClass() | |
904
+ * | |------------------------------------| |
905
+ * | | form title + close button | |
906
+ * | |------------------------------------| |
907
+ * | | client supplied form template | |
908
+ * | +------------------------------------+ |
909
+ * +----------------------------------------+
910
+ */
911
+ formPaneWrapperClass: _angular_core.InputSignal<string>;
912
+ /**
913
+ * The CSS class that will be applied to the form pane content.
914
+ */
915
+ formPaneContentClass: _angular_core.InputSignal<string>;
916
+ private getLabel;
917
+ _itemLabel: _angular_core.Signal<Observable<string>>;
918
+ _itemLabelPlural: _angular_core.Signal<Observable<string>>;
919
+ _title: _angular_core.Signal<Observable<string | undefined>>;
920
+ _endpointSansParams: _angular_core.Signal<string>;
921
+ _endpointParams: _angular_core.Signal<void>;
922
+ componentColumns: _angular_core.Signal<readonly MatColumnDef[]>;
923
+ _clientColumnDefs: QueryList<MatColumnDef>;
924
+ /**
925
+ * Event raised for user selecting an item action. It's also raised
926
+ * for 'New <Item>' action, if 'newItemLink' property is not set.
927
+ */
928
+ action: EventEmitter<{
929
+ role: string;
930
+ entity?: TEntity;
931
+ }>;
932
+ /**
933
+ * Event raised when create Create/Edit pane is activated & deactivated.
934
+ * Event contains two flags:-
935
+ * activated - whether the createEdit form view was activated or
936
+ * deactivated.
937
+ * cancelled - whether the form view was cancelled by user. False for this
938
+ * indicates that the form view was closed after a successful
939
+ * edit operation.
940
+ */
941
+ entityViewPaneActivated: EventEmitter<{
942
+ activated: boolean;
943
+ cancelled: boolean | undefined;
944
+ mode: "edit" | "preview";
945
+ }>;
946
+ busyWheelId: string;
947
+ sub$: Subscription;
948
+ spEntitiesList: _angular_core.Signal<SPMatEntityListComponent<TEntity, IdKey> | undefined>;
949
+ spEntitiesListInited: _angular_core.EffectRef;
950
+ crudConfig: SPMatEntityCrudConfig;
951
+ createEditHostComponent: _angular_core.Signal<FormViewHostComponent<{
952
+ [x: string]: PropertyKey;
953
+ }, string> | undefined>;
954
+ createEditViewActive: _angular_core.WritableSignal<boolean>;
955
+ canCancelEditCallback: () => boolean;
956
+ previewHostComponent: _angular_core.Signal<PreviewHostComponent<{
957
+ [x: string]: PropertyKey;
958
+ }, string> | undefined>;
959
+ previewActive: _angular_core.Signal<boolean>;
960
+ previewedEntity: _angular_core.WritableSignal<TEntity | undefined>;
961
+ entityPaneActive: _angular_core.Signal<boolean>;
962
+ entityPaneWidth: _angular_core.Signal<number>;
963
+ entitiesPaneWidth: _angular_core.Signal<number>;
964
+ entitiesPaneHidden: _angular_core.Signal<boolean>;
965
+ defaultItemCrudActions: _angular_core.WritableSignal<MatEntityCrudItemAction<TEntity, IdKey>[]>;
966
+ columnsWithAction: _angular_core.Signal<(string | _smallpearl_ngx_helper_entity_field.SPEntityFieldSpec<TEntity, IdKey>)[]>;
967
+ _itemActions: (entity: TEntity) => MatEntityCrudItemAction<TEntity, IdKey>[];
968
+ visibleColumns: _angular_core.Signal<string[]>;
969
+ transloco: TranslocoService;
970
+ constructor(http: HttpClient, snackBar: MatSnackBar, sanitizer: DomSanitizer, injector: Injector);
971
+ ngOnInit(): void;
972
+ ngOnDestroy(): void;
973
+ /**
974
+ * Override so that we can suppress default action in SPMatEntityListComponent
975
+ */
976
+ ngAfterViewInit(): void;
977
+ /**
978
+ * If the create/edit entity form is active, it calls its registered
979
+ * canCancelEdit callback to determine if it's okay to cancel the edit.
980
+ * You can use this method from the host component's router guard to
981
+ * ensure that any changes made to the form are not accidentally lost by
982
+ * navigating away from the CRUD page.
983
+ *
984
+ * If your CRUD page has multiple sp-mat-entity-crud components, you have to
985
+ * implement the logic to call this method on the appropriate component.
986
+ *
987
+ * If the the create/edit form is not active, this method returns true.
988
+ * @returns
989
+ */
990
+ canDeactivate(): boolean;
991
+ refresh(force?: boolean): void;
992
+ getEntityName(): string;
993
+ getEntityNamePlural(): string;
994
+ getIdKey(): string;
995
+ closeCreateEdit(cancelled: boolean): void;
996
+ canCancelEdit(): boolean;
997
+ registerCanCancelEditCallback(callback: () => boolean): void;
998
+ triggerEntityUpdate(entity: TEntity): void;
999
+ triggerEntityDelete(entity: TEntity): void;
1000
+ create(entityValue: any): Observable<any>;
1001
+ update(id: TEntity[IdKey], entityValue: any): Observable<any>;
1002
+ /**
1003
+ * Thunk these methods to the internal <sp-mat-entity-list> component.
1004
+ */
1005
+ addEntity(entity: TEntity): void;
1006
+ removeEntity(id: TEntity[IdKey]): void;
1007
+ updateEntity(id: TEntity[IdKey], entity: TEntity): void;
1008
+ /**
1009
+ * Refresh the entity list, after a CRUD CREATE or UPDATE operation.
1010
+ * @param resp This is the response from the CRUD operation (CREATE/UPDATE).
1011
+ * @param method The CRUD operation post which REFRESH is requested.
1012
+ * @returns Observable<TEntity|null>
1013
+ */
1014
+ doRefreshAfterEdit(resp: any, method: 'create' | 'update'): Observable<any>;
1015
+ getCrudOpResponseParser(): SPMatEntityCrudResponseParser;
1016
+ closePreview(): void;
1017
+ private closePreviewImpl;
1018
+ onItemAction(role: string, entity: TEntity): void;
1019
+ onCreate(event: Event): void;
1020
+ onUpdate(entity: TEntity): void;
1021
+ /**
1022
+ * Show the create/edit component. This is deliberately made public so as to
1023
+ * be callable from the client. This allows the client to dynamically
1024
+ * set the form edit template and then show the edit pane by calling this
1025
+ * method.
1026
+ * @param entity
1027
+ * @param params
1028
+ */
1029
+ showCreateEditView(entity?: TEntity | undefined, params?: any): void;
1030
+ showPreviewView(entity?: TEntity, params?: any): void;
1031
+ hidePreviewView(): void;
1032
+ onDelete(entity: TEntity): Promise<void>;
1033
+ getUrl(endpoint: string): string;
1034
+ getEntityUrl(entityId: TEntity[IdKey]): string;
1035
+ getEntityActionUrl(entityId: TEntity[IdKey], action: string): string;
1036
+ handleSelectEntity(entity: TEntity | undefined): void;
1037
+ handleNewItemSubType(subtype: NewItemSubType): void;
1038
+ private getCrudReqHttpContext;
1039
+ isItemActionAllowed(action: string, entity: TEntity): boolean;
1040
+ /**
1041
+ * Returns the list of item actions. Calls 'allowItemActionFn' for each action
1042
+ * to determine if the action is allowed for the given entity.
1043
+ * @returns
1044
+ */
1045
+ getItemActions(entity: TEntity): MatEntityCrudItemAction<TEntity, IdKey>[];
1046
+ getPreviewPaneContentClass(): string;
1047
+ getFormPaneWrapperClass(): string;
1048
+ getFormPaneContentClass(): string;
1049
+ getItemLabel(): string | Observable<string>;
1050
+ getItemLabelPlural(): string | Observable<string>;
1051
+ /**
1052
+ * Perform an action on the entity with the given id. The endpoint for the
1053
+ * action is derived from the `verb` argument which is appended to the
1054
+ * entity URL. This is following DRF specification where ViewSets can be
1055
+ * extended with custom actions that are not part of the standard
1056
+ * CRUD operations. Such methods will have a URL like
1057
+ * `/api/v1/entity/<id>/<verb>/` where `<verb>` is the custom action verb.
1058
+ * @param id
1059
+ * @param verb
1060
+ * @param addlParams
1061
+ * @param data
1062
+ */
1063
+ doEntityAction(id: TEntity[IdKey], verb: string, addlParams: HttpParams, data: any, busyWheelName?: string): Observable<any>;
1064
+ /**
1065
+ * Initialize the columns for the mat-entities-list component. This is
1066
+ * called when the <sp-mat-entities-list> component has been properly
1067
+ * initialized.
1068
+ */
1069
+ private _initEntitiesList;
1070
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SPMatEntityCrudComponent<any, any>, never>;
1071
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SPMatEntityCrudComponent<any, any>, "sp-mat-entity-crud", never, { "itemLabel": { "alias": "itemLabel"; "required": false; "isSignal": true; }; "itemLabelPlural": { "alias": "itemLabelPlural"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "itemActions": { "alias": "itemActions"; "required": false; "isSignal": true; }; "newItemLink": { "alias": "newItemLink"; "required": false; "isSignal": true; }; "newItemLabel": { "alias": "newItemLabel"; "required": false; "isSignal": true; }; "editItemTitle": { "alias": "editItemTitle"; "required": false; "isSignal": true; }; "newItemSubTypes": { "alias": "newItemSubTypes"; "required": false; "isSignal": true; }; "crudOpFn": { "alias": "crudOpFn"; "required": false; "isSignal": true; }; "previewTemplate": { "alias": "previewTemplate"; "required": false; "isSignal": true; }; "allowEntityActionFn": { "alias": "allowEntityActionFn"; "required": false; "isSignal": true; }; "headerTemplate": { "alias": "headerTemplate"; "required": false; "isSignal": true; }; "actionsTemplate": { "alias": "actionsTemplate"; "required": false; "isSignal": true; }; "crudResponseParser": { "alias": "crudResponseParser"; "required": false; "isSignal": true; }; "createEditFormTemplate": { "alias": "createEditFormTemplate"; "required": false; "isSignal": true; }; "disableItemActions": { "alias": "disableItemActions"; "required": false; "isSignal": true; }; "disableCreate": { "alias": "disableCreate"; "required": false; "isSignal": true; }; "refreshAfterEdit": { "alias": "refreshAfterEdit"; "required": false; "isSignal": true; }; "crudHttpReqContext": { "alias": "crudHttpReqContext"; "required": false; "isSignal": true; }; "editPaneWidth": { "alias": "editPaneWidth"; "required": false; "isSignal": true; }; "previewPaneWidth": { "alias": "previewPaneWidth"; "required": false; "isSignal": true; }; "listPaneWrapperClass": { "alias": "listPaneWrapperClass"; "required": false; "isSignal": true; }; "previewPaneWrapperClass": { "alias": "previewPaneWrapperClass"; "required": false; "isSignal": true; }; "previewPaneContentClass": { "alias": "previewPaneContentClass"; "required": false; "isSignal": true; }; "formPaneWrapperClass": { "alias": "formPaneWrapperClass"; "required": false; "isSignal": true; }; "formPaneContentClass": { "alias": "formPaneContentClass"; "required": false; "isSignal": true; }; }, { "action": "action"; "entityViewPaneActivated": "entityViewPaneActivated"; }, ["_clientColumnDefs"], ["[breadCrumbs]"], true, never>;
1072
+ }
1073
+
1074
+ export { SPMatEntityCrudComponent, SPMatEntityCrudFormBase, SPMatEntityCrudPreviewPaneComponent, SP_MAT_ENTITY_CRUD_CONFIG, SP_MAT_ENTITY_CRUD_HTTP_CONTEXT, convertHttpContextInputToHttpContext };
1075
+ export type { ALLOW_ITEM_ACTION_FN, CRUD_OP_FN, CrudOp, HttpContextInput, MatEntityCrudItemAction, NewItemSubType, SPMatEntityCrudConfig, SPMatEntityCrudCreateEditBridge, SPMatEntityCrudHttpContext, SPMatEntityCrudResponseParser };