@smallpearl/ngx-helper 0.29.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +230 -0
- package/core/index.d.ts +2 -0
- package/core/src/ngx-helper.d.ts +7 -0
- package/core/src/version.d.ts +1 -0
- package/entity-field/index.d.ts +2 -0
- package/entity-field/src/entity-field-spec.d.ts +69 -0
- package/entity-field/src/provider.d.ts +27 -0
- package/fesm2022/smallpearl-ngx-helper-core.mjs +23 -0
- package/fesm2022/smallpearl-ngx-helper-core.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +112 -0
- package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-forms.mjs +112 -0
- package/fesm2022/smallpearl-ngx-helper-forms.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs +108 -0
- package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-locale.mjs +296 -0
- package/fesm2022/smallpearl-ngx-helper-locale.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs +504 -0
- package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +184 -0
- package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +1486 -0
- package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +800 -0
- package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs +328 -0
- package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs +468 -0
- package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +854 -0
- package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs +930 -0
- package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs +926 -0
- package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-sideload.mjs +111 -0
- package/fesm2022/smallpearl-ngx-helper-sideload.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +384 -0
- package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -0
- package/fesm2022/smallpearl-ngx-helper.mjs +13 -0
- package/fesm2022/smallpearl-ngx-helper.mjs.map +1 -0
- package/forms/index.d.ts +1 -0
- package/forms/src/validation-error-handler.d.ts +52 -0
- package/hover-dropdown/index.d.ts +1 -0
- package/hover-dropdown/src/hover-dropdown.directive.d.ts +41 -0
- package/index.d.ts +5 -0
- package/locale/index.d.ts +5 -0
- package/locale/src/currency.pipe.d.ts +14 -0
- package/locale/src/date.pipe.d.ts +14 -0
- package/locale/src/format-currency.d.ts +1 -0
- package/locale/src/format-date.d.ts +2 -0
- package/locale/src/is-empty.d.ts +1 -0
- package/locale/src/providers.d.ts +20 -0
- package/mat-busy-wheel/index.d.ts +4 -0
- package/mat-busy-wheel/src/busy-wheel-op.d.ts +65 -0
- package/mat-busy-wheel/src/busy-wheel.component.d.ts +12 -0
- package/mat-busy-wheel/src/busy-wheel.service.d.ts +42 -0
- package/mat-busy-wheel/src/host-busy-wheel.directive.d.ts +35 -0
- package/mat-context-menu/index.d.ts +1 -0
- package/mat-context-menu/src/mat-context-menu.component.d.ts +54 -0
- package/mat-entity-crud/index.d.ts +5 -0
- package/mat-entity-crud/src/default-config.d.ts +9 -0
- package/mat-entity-crud/src/form-view-host.component.d.ts +34 -0
- package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +95 -0
- package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +66 -0
- package/mat-entity-crud/src/mat-entity-crud-types.d.ts +141 -0
- package/mat-entity-crud/src/mat-entity-crud.component.d.ts +267 -0
- package/mat-entity-crud/src/preview-host.component.d.ts +19 -0
- package/mat-entity-crud/src/preview-pane.component.d.ts +27 -0
- package/mat-entity-crud/src/providers.d.ts +3 -0
- package/mat-entity-list/index.d.ts +3 -0
- package/mat-entity-list/src/config.d.ts +6 -0
- package/mat-entity-list/src/mat-entity-list-types.d.ts +53 -0
- package/mat-entity-list/src/mat-entity-list.component.d.ts +209 -0
- package/mat-entity-list/src/providers.d.ts +3 -0
- package/mat-file-input/README.md +63 -0
- package/mat-file-input/index.d.ts +1 -0
- package/mat-file-input/src/mat-file-input.component.d.ts +58 -0
- package/mat-form-error/README.md +306 -0
- package/mat-form-error/index.d.ts +6 -0
- package/mat-form-error/src/locales/en.d.ts +4 -0
- package/mat-form-error/src/locales/hu.d.ts +4 -0
- package/mat-form-error/src/locales/index.d.ts +3 -0
- package/mat-form-error/src/locales/pt-br.d.ts +4 -0
- package/mat-form-error/src/ngx-error-list.component.d.ts +9 -0
- package/mat-form-error/src/ngx-mat-error-control.d.ts +17 -0
- package/mat-form-error/src/ngx-mat-error-def.directive.d.ts +30 -0
- package/mat-form-error/src/ngx-mat-errors-for-date-range-picker.directive.d.ts +8 -0
- package/mat-form-error/src/ngx-mat-errors.component.d.ts +23 -0
- package/mat-form-error/src/types.d.ts +68 -0
- package/mat-form-error/src/utils/coerce-to-observable.d.ts +3 -0
- package/mat-form-error/src/utils/distinct-until-error-changed.d.ts +2 -0
- package/mat-form-error/src/utils/find-error-for-control.d.ts +9 -0
- package/mat-form-error/src/utils/get-abstract-controls.d.ts +3 -0
- package/mat-form-error/src/utils/get-control-with-error.d.ts +3 -0
- package/mat-select-entity/index.d.ts +2 -0
- package/mat-select-entity/src/mat-select-entity.component.d.ts +207 -0
- package/mat-select-entity/src/providers.d.ts +9 -0
- package/mat-side-menu-layout/index.d.ts +6 -0
- package/mat-side-menu-layout/src/layout.service.d.ts +23 -0
- package/mat-side-menu-layout/src/mat-menu-layout.component.d.ts +39 -0
- package/mat-side-menu-layout/src/mat-menu-layout.module.d.ts +18 -0
- package/mat-side-menu-layout/src/mat-menu-list-item.component.d.ts +36 -0
- package/mat-side-menu-layout/src/mat-menu-pane.component.d.ts +66 -0
- package/mat-side-menu-layout/src/nav-item.d.ts +10 -0
- package/mat-tel-input/README.md +18 -0
- package/mat-tel-input/index.d.ts +2 -0
- package/mat-tel-input/src/country-codes.d.ts +5 -0
- package/mat-tel-input/src/mat-telephone.component.d.ts +129 -0
- package/mat-tel-input/src/providers.d.ts +38 -0
- package/ngx-helper.d.ts +2 -0
- package/package.json +114 -0
- package/public-api.d.ts +1 -0
- package/sideload/index.d.ts +1 -0
- package/sideload/src/sideload.d.ts +17 -0
- package/stationary-with-line-items/index.d.ts +1 -0
- package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +74 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an rxjs operator that would track an http request status
|
|
4
|
+
* and would use the request status to hide the global busy wheel. The wheel
|
|
5
|
+
* would be hidden when the request completes or errors.
|
|
6
|
+
*
|
|
7
|
+
* Use it like below:
|
|
8
|
+
*
|
|
9
|
+
* this.http.get<User>('https://google.com/..').pipe(
|
|
10
|
+
* trackBusyWheelStatus(),
|
|
11
|
+
* tap(user => this.user = user)
|
|
12
|
+
* ).subscribe();
|
|
13
|
+
*
|
|
14
|
+
* Note that the function internally uses a timer to delay showing the busy
|
|
15
|
+
* wheel. This helps avoid needless screen flicker that can occur when quickly
|
|
16
|
+
* showing & hiding the wheel when the network connection and server response
|
|
17
|
+
* are so good that it can exceed natural user reaction time. We set this
|
|
18
|
+
* delay to 150 milliseconds for now.
|
|
19
|
+
*
|
|
20
|
+
* @param id A string value that uniquely identities the the busy wheel host
|
|
21
|
+
* container within the page. This allows multiple busy wheels to be hosted
|
|
22
|
+
* within a page, each for a distinct network (or time-consuming) operation.
|
|
23
|
+
* This is optional and if not specified, will create a busy wheel that
|
|
24
|
+
* covers the entire app viewport.
|
|
25
|
+
* @param show A boolean value that says whether to show the wheel as
|
|
26
|
+
* part of the operator setup. If set to false, the caller is expected
|
|
27
|
+
* to have displayed the busy wheel explicitly.
|
|
28
|
+
* @param showImmediate A boolean value that decides whether to show the
|
|
29
|
+
* busy wheel immediately. If set to false (default), the busy wheel will
|
|
30
|
+
* only be shown when the HTTP request has not completed within 200ms.
|
|
31
|
+
* @param hideOnNthEmit Number of emits upon which the busy wheel is to
|
|
32
|
+
* be hidden. A value of 0 for this means the wheel is hidden only when
|
|
33
|
+
* the observable completes (errorneously or otherwise).
|
|
34
|
+
* @returns An rxjs op that can be added to the pipe() arg list.
|
|
35
|
+
*/
|
|
36
|
+
export declare function trackBusyWheelStatus(id?: string, show?: boolean, showImmediate?: boolean, hideOnNthEmit?: number): <T>(source: Observable<T>) => Observable<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Show a busy wheel until the observable is complete. Busy wheel is shown is either viewport global
|
|
39
|
+
* or localized to the element with the the given id.
|
|
40
|
+
*
|
|
41
|
+
* An example use case for this operator are HTTP requests which will complete no matter
|
|
42
|
+
* what. Either successfully or with an error. Either case will mark the observer as completed.
|
|
43
|
+
*
|
|
44
|
+
* See trackBusyWheelStatus() for explanations on arguments
|
|
45
|
+
*
|
|
46
|
+
* @param id
|
|
47
|
+
* @param showImmediate
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
export declare function showBusyWheelUntilComplete(id?: string, showImmediate?: boolean): <T>(source: Observable<T>) => Observable<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Show a busy wheel until the observable emits n number of values. Busy wheel is shown is
|
|
53
|
+
* either viewport global or localized to the element with the the given id.
|
|
54
|
+
*
|
|
55
|
+
* An example use case for this operator are observables that emit but which do not necessarily
|
|
56
|
+
* complete.
|
|
57
|
+
*
|
|
58
|
+
* See trackBusyWheelStatus() for explanations on arguments
|
|
59
|
+
*
|
|
60
|
+
* @param numEmits
|
|
61
|
+
* @param id
|
|
62
|
+
* @param showImmediate
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
export declare function showBusyWheelUntilEmits(numEmits: number, id?: string, showImmediate?: boolean): <T>(source: Observable<T>) => Observable<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class SPMatBusyWheelComponent implements OnInit, OnDestroy {
|
|
4
|
+
elRef: ElementRef;
|
|
5
|
+
wheelId: import("@angular/core").InputSignal<string>;
|
|
6
|
+
viewport: import("@angular/core").InputSignal<boolean>;
|
|
7
|
+
constructor(elRef: ElementRef);
|
|
8
|
+
ngOnInit(): void;
|
|
9
|
+
ngOnDestroy(): void;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SPMatBusyWheelComponent, never>;
|
|
11
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SPMatBusyWheelComponent, "sp-mat-busy-wheel", never, { "wheelId": { "alias": "wheelId"; "required": false; "isSignal": true; }; "viewport": { "alias": "viewport"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SPMatHostBusyWheelDirective } from './host-busy-wheel.directive';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class BusyWheelService {
|
|
4
|
+
private defaultBusyWheelDir;
|
|
5
|
+
private namedBusyWheelDirs;
|
|
6
|
+
private wheelComponents;
|
|
7
|
+
static s_instance: BusyWheelService;
|
|
8
|
+
constructor();
|
|
9
|
+
static getInstance(): BusyWheelService;
|
|
10
|
+
show(id?: string): void;
|
|
11
|
+
hide(id?: string): void;
|
|
12
|
+
registerBusyWheelHost(busyWheelDir: SPMatHostBusyWheelDirective): void;
|
|
13
|
+
deregisterBusyWheelHost(busyWheelDir: SPMatHostBusyWheelDirective): void;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a div fragment that hosts the busy wheel. The fragment has the following
|
|
16
|
+
* structure:
|
|
17
|
+
*
|
|
18
|
+
* <div id="id_busy-wheel_{id}">
|
|
19
|
+
* <div class="{containerClass}">
|
|
20
|
+
* <!-- <div class="busy-wheel"></div> -->
|
|
21
|
+
* <mat-spinner></mat-spinner>
|
|
22
|
+
* </div>
|
|
23
|
+
* </div>
|
|
24
|
+
* @param containerClass
|
|
25
|
+
* @param id
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
private createViewportBusyWheel;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a backdrop overlay, of the same size as the container that it
|
|
31
|
+
* covers, on which the busy wheel will be positioned.
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
private createBackdrop;
|
|
35
|
+
private removeViewportBusyWheel;
|
|
36
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BusyWheelService, never>;
|
|
37
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<BusyWheelService>;
|
|
38
|
+
}
|
|
39
|
+
export declare function registerBusyWheelHost(busyWheelDir: SPMatHostBusyWheelDirective): void;
|
|
40
|
+
export declare function deregisterBusyWheelHost(busyWheelDir: SPMatHostBusyWheelDirective): void;
|
|
41
|
+
export declare function showBusyWheel(id?: string): void;
|
|
42
|
+
export declare function hideBusyWheel(id?: string): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OnDestroy, OnInit, Renderer2, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Use this directive with a unique value assigned to it to display a busy
|
|
5
|
+
* wheel over it. This can be used as:-
|
|
6
|
+
*
|
|
7
|
+
* import {showBusyWheelUntilComplete} from '@smallpearl/ngx-helper/mat-busy-wheel';
|
|
8
|
+
*
|
|
9
|
+
* <div spHostBusyWheel='myDivBusyWheel'>
|
|
10
|
+
* ..content
|
|
11
|
+
* </div>
|
|
12
|
+
*
|
|
13
|
+
* Then in your code:
|
|
14
|
+
*
|
|
15
|
+
* obs.pipe(
|
|
16
|
+
* showBusyWheelUntilComplete('myDivBusyWheel'),
|
|
17
|
+
* tap((resp) => {
|
|
18
|
+
* ...
|
|
19
|
+
* })
|
|
20
|
+
* ).subscribe();
|
|
21
|
+
*
|
|
22
|
+
* This will cover the 'div' above when the obs is waiting to be completed.
|
|
23
|
+
* (or error). Note that you can also use the trackBusyWheelStatus() function
|
|
24
|
+
* if you want more control over the busy wheel.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SPMatHostBusyWheelDirective implements OnInit, OnDestroy {
|
|
27
|
+
viewContainerRef: ViewContainerRef;
|
|
28
|
+
renderer2: Renderer2;
|
|
29
|
+
spHostBusyWheel: import("@angular/core").InputSignal<string | undefined>;
|
|
30
|
+
constructor(viewContainerRef: ViewContainerRef, renderer2: Renderer2);
|
|
31
|
+
ngOnInit(): void;
|
|
32
|
+
ngOnDestroy(): void;
|
|
33
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SPMatHostBusyWheelDirective, never>;
|
|
34
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<SPMatHostBusyWheelDirective, "[spHostBusyWheel]", never, { "spHostBusyWheel": { "alias": "spHostBusyWheel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/mat-context-menu.component';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Describes each item in the context menu.
|
|
5
|
+
*/
|
|
6
|
+
export interface SPContextMenuItem {
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
route?: string | string[];
|
|
10
|
+
role?: string;
|
|
11
|
+
disable?: (arg: any) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class SPMatContextMenuComponent implements OnInit {
|
|
14
|
+
/**
|
|
15
|
+
* The menu items to display. Refer to ContextMenuItem doc for details
|
|
16
|
+
* on the menu items.
|
|
17
|
+
*/
|
|
18
|
+
menuItems: import("@angular/core").InputSignal<SPContextMenuItem[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Label to display for the context menu. If omitted will just show the
|
|
21
|
+
* menuIcon.
|
|
22
|
+
*/
|
|
23
|
+
label: import("@angular/core").InputSignal<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Button icon. defaults to more_vert.
|
|
26
|
+
*/
|
|
27
|
+
menuIconName: import("@angular/core").InputSignal<string>;
|
|
28
|
+
/**
|
|
29
|
+
* By default the context menu is activated whenever the mouse cursor hovers
|
|
30
|
+
* over the button. Set this to 'true' to disable this feature.
|
|
31
|
+
*/
|
|
32
|
+
enableHover: import("@angular/core").InputSignal<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Context data for menu item disabled callback
|
|
35
|
+
*/
|
|
36
|
+
contextData: import("@angular/core").InputSignal<any>;
|
|
37
|
+
/**
|
|
38
|
+
* enable menu backdrop
|
|
39
|
+
*/
|
|
40
|
+
hasBackdrop: import("@angular/core").InputSignal<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Event generated when use selects an item in the context menu. This event
|
|
43
|
+
* is generated only if the context menu item does not specify a route to
|
|
44
|
+
* activate. The string event parameter is ContextMenuItem.role property
|
|
45
|
+
* value.
|
|
46
|
+
*/
|
|
47
|
+
selected: EventEmitter<string>;
|
|
48
|
+
constructor();
|
|
49
|
+
ngOnInit(): void;
|
|
50
|
+
onSelectMenuItem(item: SPContextMenuItem): void;
|
|
51
|
+
itemDisabled(menuItem: SPContextMenuItem): boolean | undefined;
|
|
52
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SPMatContextMenuComponent, never>;
|
|
53
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SPMatContextMenuComponent, "sp-mat-context-menu", never, { "menuItems": { "alias": "menuItems"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "menuIconName": { "alias": "menuIconName"; "required": false; "isSignal": true; }; "enableHover": { "alias": "enableHover"; "required": false; "isSignal": true; }; "contextData": { "alias": "contextData"; "required": false; "isSignal": true; }; "hasBackdrop": { "alias": "hasBackdrop"; "required": false; "isSignal": true; }; }, { "selected": "selected"; }, never, never, true, never>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SPMatEntityCrudConfig } from "./mat-entity-crud-types";
|
|
2
|
+
export declare const DefaultSPMatEntityCrudConfig: SPMatEntityCrudConfig;
|
|
3
|
+
/**
|
|
4
|
+
* To be called from an object constructor as it internally calls Angular's
|
|
5
|
+
* inject() API.
|
|
6
|
+
* @param userConfig
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEntityCrudConfig(): SPMatEntityCrudConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EmbeddedViewRef, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { Subscription } from 'rxjs';
|
|
3
|
+
import { SPMatEntityCrudComponentBase } from './mat-entity-crud-internal-types';
|
|
4
|
+
import { SPMatEntityCrudConfig, SPMatEntityCrudCreateEditBridge } from './mat-entity-crud-types';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class FormViewHostComponent<TEntity> implements SPMatEntityCrudCreateEditBridge, OnInit, OnDestroy {
|
|
7
|
+
entityCrudComponentBase: import("@angular/core").InputSignal<SPMatEntityCrudComponentBase<TEntity>>;
|
|
8
|
+
clientViewTemplate: import("@angular/core").InputSignal<TemplateRef<any> | null>;
|
|
9
|
+
itemLabel: import("@angular/core").InputSignal<string>;
|
|
10
|
+
itemLabelPlural: import("@angular/core").InputSignal<string>;
|
|
11
|
+
entity: import("@angular/core").WritableSignal<TEntity | undefined>;
|
|
12
|
+
title: import("@angular/core").WritableSignal<string>;
|
|
13
|
+
params: import("@angular/core").WritableSignal<any>;
|
|
14
|
+
clientFormView: EmbeddedViewRef<any> | null;
|
|
15
|
+
vc: import("@angular/core").Signal<ViewContainerRef | undefined>;
|
|
16
|
+
config: SPMatEntityCrudConfig;
|
|
17
|
+
sub$: Subscription;
|
|
18
|
+
constructor();
|
|
19
|
+
ngOnInit(): void;
|
|
20
|
+
ngOnDestroy(): void;
|
|
21
|
+
show(entity: TEntity | undefined, params?: any): void;
|
|
22
|
+
close(cancel: boolean): void;
|
|
23
|
+
registerCanCancelEditCallback(callback: () => boolean): void;
|
|
24
|
+
create(entityValue: any): import("rxjs").Observable<any>;
|
|
25
|
+
update(id: any, entityValue: any): import("rxjs").Observable<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates the client view provided via template
|
|
28
|
+
*/
|
|
29
|
+
createClientView(): void;
|
|
30
|
+
destroyClientView(): void;
|
|
31
|
+
onClose(): void;
|
|
32
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormViewHostComponent<any>, never>;
|
|
33
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FormViewHostComponent<any>, "sp-create-edit-entity-host", never, { "entityCrudComponentBase": { "alias": "entityCrudComponentBase"; "required": true; "isSignal": true; }; "clientViewTemplate": { "alias": "clientViewTemplate"; "required": false; "isSignal": true; }; "itemLabel": { "alias": "itemLabel"; "required": true; "isSignal": true; }; "itemLabelPlural": { "alias": "itemLabelPlural"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { AbstractControl } from '@angular/forms';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
4
|
+
import { SPMatEntityCrudCreateEditBridge } from './mat-entity-crud-types';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* This is a convenience base class that clients can derive from to implement
|
|
8
|
+
* their CRUD form component. Particularly this class registers the change
|
|
9
|
+
* detection hook which will be called when the user attempts to close the
|
|
10
|
+
* form's parent container pane via the Close button on the top right.
|
|
11
|
+
*
|
|
12
|
+
* This button behaves like a Cancel button in a desktop app and therefore if
|
|
13
|
+
* the user has entered any data in the form's controls, (determined by
|
|
14
|
+
* checking form.touched), then a 'Lose Changes' prompt is displayed allowing
|
|
15
|
+
* the user to cancel the closure.
|
|
16
|
+
*
|
|
17
|
+
* The @Component is fake just to keep the VSCode angular linter quiet.
|
|
18
|
+
*
|
|
19
|
+
* To use this class:-
|
|
20
|
+
*
|
|
21
|
+
* 1. Declare a FormGroup<> type as
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* type MyForm = FormGroup<{
|
|
25
|
+
* name: FormControl<string>;
|
|
26
|
+
* type: FormControl<string>;
|
|
27
|
+
* notes: FormControl<string>;
|
|
28
|
+
* }>;
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* 2. Derive your form's component class from this and implement the
|
|
32
|
+
* createForm() method returing the FormGroup<> instance that matches
|
|
33
|
+
* the FormGroup concrete type above.
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
* class MyFormComponent extends SPMatEntityCrudFormBase<MyForm, MyEntity> {
|
|
37
|
+
* constructor() {
|
|
38
|
+
* super()
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* createForm() {
|
|
42
|
+
* return new FormGroup([...])
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* 3. If you form's value requires manipulation before being sent to the
|
|
48
|
+
* server, override getFormValue() method and do it there before returning
|
|
49
|
+
* the modified values.
|
|
50
|
+
*
|
|
51
|
+
* 4. Wire up the form in the template as:
|
|
52
|
+
*
|
|
53
|
+
* ```
|
|
54
|
+
* <form [formGroup]='form'.. (ngSubmit)="onSubmit()">
|
|
55
|
+
* <button type="submit">Submit</button>
|
|
56
|
+
* </form>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare abstract class SPMatEntityCrudFormBase<TFormGroup extends AbstractControl, TEntity extends {
|
|
60
|
+
[P in IdKey]: PropertyKey;
|
|
61
|
+
}, IdKey extends string = 'id'> implements OnInit, OnDestroy {
|
|
62
|
+
_form: import("@angular/core").WritableSignal<TFormGroup | undefined>;
|
|
63
|
+
entity: import("@angular/core").InputSignal<TEntity>;
|
|
64
|
+
bridge: import("@angular/core").InputSignal<SPMatEntityCrudCreateEditBridge>;
|
|
65
|
+
params: import("@angular/core").InputSignal<any>;
|
|
66
|
+
sub$: Subscription;
|
|
67
|
+
form: import("@angular/core").Signal<TFormGroup | undefined>;
|
|
68
|
+
crudConfig: import("./mat-entity-crud-types").SPMatEntityCrudConfig;
|
|
69
|
+
cdr: ChangeDetectorRef;
|
|
70
|
+
canCancelEdit: () => boolean;
|
|
71
|
+
_canCancelEdit(): boolean;
|
|
72
|
+
ngOnInit(): void;
|
|
73
|
+
ngOnDestroy(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Create the TFormGroup FormGroup class that will be used for the reactive
|
|
76
|
+
* form.
|
|
77
|
+
* @param entity
|
|
78
|
+
*/
|
|
79
|
+
abstract createForm(entity: TEntity | undefined): TFormGroup;
|
|
80
|
+
/**
|
|
81
|
+
* Override to customize the id key name if it's not 'id'
|
|
82
|
+
* @returns The name of the unique identifier key that will be used to
|
|
83
|
+
* extract the entity's id for UPDATE operation.
|
|
84
|
+
*/
|
|
85
|
+
getIdKey(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Return the form's value to be sent to server as Create/Update CRUD
|
|
88
|
+
* operation data.
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
getFormValue(): any;
|
|
92
|
+
onSubmit(): void;
|
|
93
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SPMatEntityCrudFormBase<any, any, any>, never>;
|
|
94
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SPMatEntityCrudFormBase<any, any, any>, "_#_sp-mat-entity-crud-form-base_#_", never, { "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "bridge": { "alias": "bridge"; "required": true; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; }, {}, never, never, false, never>;
|
|
95
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* SPMatEntityCrudCreateEditBridge implementer uses this interface to
|
|
4
|
+
* communicate with the parent SPMatEntityCreateComponent. The bridge
|
|
5
|
+
* component would use the hideCreateEdit() to close itself, when user cancels
|
|
6
|
+
* the create/edit operation.
|
|
7
|
+
*/
|
|
8
|
+
export interface SPMatEntityCrudComponentBase<TEntity> {
|
|
9
|
+
/**
|
|
10
|
+
* FormViewHostComponent will call this to close the Create/Edit pane.
|
|
11
|
+
* SPMatEntityCrudComponentBase implementor will destroy the client form
|
|
12
|
+
* view and hide the Create/Edit form view pane and show the hidden
|
|
13
|
+
* entity list view.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
closeCreateEdit: (cancelled: boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Used internally by FormViewHostComponent to determine if the client form
|
|
19
|
+
* view wants to intercept user's cancel the create/edit operation. Perhaps
|
|
20
|
+
* with the Yes/No prompt 'Lose changes?'
|
|
21
|
+
* @returns boolean indicating it's okay to cancel the create/edit operation.
|
|
22
|
+
*/
|
|
23
|
+
canCancelEdit: () => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Client form view can register a callback that will be invoked by the
|
|
26
|
+
* framework when user cancels the create/edit operation by clicking on the
|
|
27
|
+
* close button on the top right.
|
|
28
|
+
* @param callback
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
registerCanCancelEditCallback: (callback: () => boolean) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Initiates update on the given entity.
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
triggerEntityUpdate: (entity: TEntity) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Initiates entity delete.
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
triggerEntityDelete: (entity: TEntity) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Called by client form-view host component to close a new entity.
|
|
44
|
+
* @param entityValue The ReactiveForm.value object that the server expects
|
|
45
|
+
* to create a new object.
|
|
46
|
+
* @returns The new Entity object returned by the server. For typical REST
|
|
47
|
+
* API, this would be of the same shape as the objects returned by the
|
|
48
|
+
* REST's GET request.
|
|
49
|
+
*/
|
|
50
|
+
create: (entityValue: any) => Observable<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Called by client form-view host component to close a new entity.
|
|
53
|
+
* @param id The id of the entity being edited.
|
|
54
|
+
* @param entityValue The ReactiveForm.value object that the server expects
|
|
55
|
+
* to update the new object.
|
|
56
|
+
* @returns The new Entity object returned by the server. For typical REST
|
|
57
|
+
* API, this would be of the same shape as the objects returned by the
|
|
58
|
+
* REST's GET request.
|
|
59
|
+
*/
|
|
60
|
+
update: (id: any, entityValue: any) => Observable<any>;
|
|
61
|
+
/**
|
|
62
|
+
* Close the preview pane.
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
closePreview: () => void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { HttpContextToken } from "@angular/common/http";
|
|
2
|
+
import { SPContextMenuItem } from "@smallpearl/ngx-helper/mat-context-menu";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
/**
|
|
5
|
+
* Prototype of the function to parse the CRUD action response.
|
|
6
|
+
*/
|
|
7
|
+
export type SPMatEntityCrudResponseParser = (entityName: string, idKey: string, method: 'create' | 'retrieve' | 'update' | 'delete', resp: any) => any | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Global config for SPMatEntityList component.
|
|
10
|
+
*/
|
|
11
|
+
export interface SPMatEntityCrudConfig {
|
|
12
|
+
i18n: {
|
|
13
|
+
newItemLabel: (itemLabel: string) => string;
|
|
14
|
+
editItemLabel: (itemLabel: string) => string;
|
|
15
|
+
edit: string;
|
|
16
|
+
delete: string;
|
|
17
|
+
deleteItemHeader: (itemLabel: string) => string;
|
|
18
|
+
deleteItemMessage: (itemLabel: string) => string;
|
|
19
|
+
itemDeletedNotification: (itemLabel: string) => string;
|
|
20
|
+
createdItemNotification: (itemLabel: string) => string;
|
|
21
|
+
updatedItemNotification: (itemLabel: string) => string;
|
|
22
|
+
loseChangesPrompt: string;
|
|
23
|
+
};
|
|
24
|
+
defaultItemActions?: SPContextMenuItem[];
|
|
25
|
+
listPaneWrapperClass?: string;
|
|
26
|
+
previewPaneWrapperClass?: string;
|
|
27
|
+
previewPaneContentClass?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Global crud response parser.
|
|
30
|
+
*/
|
|
31
|
+
crudOpResponseParser?: SPMatEntityCrudResponseParser;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This is the interface through which the client provided CRUD form component
|
|
35
|
+
* interacts with the 'host' SPMatEntityCrudComponent. When the form wants to
|
|
36
|
+
* submit an entity to the server (for create or update), it should call the
|
|
37
|
+
* one of the create or update methods. The interface also other methods for
|
|
38
|
+
* the form component to interact with SPMatEntityCrudComponent such as
|
|
39
|
+
* refresh its entities list, close the form pane, etc.
|
|
40
|
+
*
|
|
41
|
+
* The interface name has a 'Bridge' as the interface acts as a bridge between
|
|
42
|
+
* the client provided form handler component and the host
|
|
43
|
+
* SPMatEntityCrudComponent.
|
|
44
|
+
*/
|
|
45
|
+
export interface SPMatEntityCrudCreateEditBridge {
|
|
46
|
+
/**
|
|
47
|
+
* Close the edit/update form pane. This WON'T call the 'cancelEditCallback'
|
|
48
|
+
* even if one is registered.
|
|
49
|
+
*/
|
|
50
|
+
close: (cancel: boolean) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Client form view can register a callback that will be invoked by the
|
|
53
|
+
* framework when user cancels the create/edit operation by clicking on the
|
|
54
|
+
* close button on the top right.
|
|
55
|
+
* @param callback
|
|
56
|
+
* @returns None
|
|
57
|
+
*/
|
|
58
|
+
registerCanCancelEditCallback: (callback: () => boolean) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new instance of TEntity, by sending a POST request to remote.
|
|
61
|
+
* @param entityValue This is the typically the output of Reactive form's
|
|
62
|
+
* form.value. Since this value's shape may be different from TEntity and is
|
|
63
|
+
* known only to client form, we use 'any'.
|
|
64
|
+
* @returns None
|
|
65
|
+
* @inner Implementation will show a busy wheel centered on the form
|
|
66
|
+
* view while the async function to update the object remains active.
|
|
67
|
+
*/
|
|
68
|
+
create: (entityValue: any) => Observable<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Update the entity with id `id` with new values in entityValue.
|
|
71
|
+
* @param id TEntity id
|
|
72
|
+
* @param entityValue Entity values to be updated.
|
|
73
|
+
* @returns None
|
|
74
|
+
* @inner Implementation will show a busy wheel centered on the form
|
|
75
|
+
* view while the async function to update the object remains active.
|
|
76
|
+
*/
|
|
77
|
+
update: (id: any, entityValue: any) => Observable<any>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Prototype of the function that will be used instead of HttpClient for
|
|
81
|
+
* CRUD operations.
|
|
82
|
+
* @param op - the CRUD operation being requested
|
|
83
|
+
* @param entityValue - The entity or entity value upon which the operation
|
|
84
|
+
* is being requested. for 'create' & 'update' this will be the value
|
|
85
|
+
* of the reactive form. This is typically form.value or the 2nd arg to create
|
|
86
|
+
* & update methods of SPMatEntityCrudCreateEditBridge.
|
|
87
|
+
*/
|
|
88
|
+
export type CRUD_OP_FN<TEntity extends {
|
|
89
|
+
[P in IdKey]: PropertyKey;
|
|
90
|
+
}, IdKey extends string = 'id'> = (op: 'get' | 'create' | 'update' | 'delete', id: TEntity[IdKey] | undefined, // valid only for 'get', 'update' & 'delete'
|
|
91
|
+
entityValue: any, // valid only for 'create' & 'update'
|
|
92
|
+
entityCrudComponent: any) => Observable<TEntity | null>;
|
|
93
|
+
export type ALLOW_ITEM_ACTION_FN<TEntity> = (entity: TEntity, action: string) => boolean;
|
|
94
|
+
/**
|
|
95
|
+
* This interface is used to define sub types for the "New {{item}}" button on
|
|
96
|
+
* top of the CRUD UI. An array of these is provided as the value to the
|
|
97
|
+
* component property 'newItemSubTypes'.
|
|
98
|
+
*/
|
|
99
|
+
export interface NewItemSubType {
|
|
100
|
+
/**
|
|
101
|
+
* A role string that will be passed as argument to the (action) event
|
|
102
|
+
* handler. This string allows the event handler to distinguish the selected
|
|
103
|
+
* sub-type.
|
|
104
|
+
*
|
|
105
|
+
* The special keyword '_new_' can be used to activate the
|
|
106
|
+
* `createEditTemplate` template if one is provided. In this case the params
|
|
107
|
+
* element value (see below) can be used in the template to distinguish
|
|
108
|
+
* between different menu items.
|
|
109
|
+
*/
|
|
110
|
+
role: string;
|
|
111
|
+
/**
|
|
112
|
+
* Label displayed in the menu representing this role.
|
|
113
|
+
*/
|
|
114
|
+
label: string;
|
|
115
|
+
/**
|
|
116
|
+
* Arbitrary value that will be passed to the 'createEditTemplate' in the
|
|
117
|
+
* $implicit template context as 'params'. You can access this in the
|
|
118
|
+
* template like below (see `data.params`):-
|
|
119
|
+
```
|
|
120
|
+
<ng-template #createEdit let-data>
|
|
121
|
+
<app-create-edit-entity-demo
|
|
122
|
+
[bridge]="data.bridge"
|
|
123
|
+
[entity]="data.entity"
|
|
124
|
+
[params]="data.params"
|
|
125
|
+
></app-create-edit-entity-demo>
|
|
126
|
+
</ng-template>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
If params is an object and it includes the key 'title', its value will be
|
|
130
|
+
used as the title for the edit form.
|
|
131
|
+
*/
|
|
132
|
+
params?: any;
|
|
133
|
+
}
|
|
134
|
+
export type CrudOp = 'create' | 'retrieve' | 'update' | 'delete' | undefined;
|
|
135
|
+
export interface SPMatEntityCrudHttpContext {
|
|
136
|
+
entityName: string;
|
|
137
|
+
entityNamePlural: string;
|
|
138
|
+
endpoint: string;
|
|
139
|
+
op: CrudOp;
|
|
140
|
+
}
|
|
141
|
+
export declare const SP_MAT_ENTITY_CRUD_HTTP_CONTEXT: HttpContextToken<SPMatEntityCrudHttpContext>;
|