@dotglitch/ngx-common 1.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.
- package/README.md +24 -0
- package/components/dynamic-html/dynamic-html.component.d.ts +15 -0
- package/components/dynamic-html/dynamic-html.module.d.ts +10 -0
- package/components/dynamic-html/dynamic-html.service.d.ts +18 -0
- package/components/dynamic-html/types.d.ts +12 -0
- package/components/lazy-loader/lazy-loader.component.d.ts +146 -0
- package/components/lazy-loader/lazy-loader.module.d.ts +10 -0
- package/components/lazy-loader/lazy-loader.service.d.ts +71 -0
- package/components/lazy-loader/types.d.ts +142 -0
- package/components/menu/menu.component.d.ts +52 -0
- package/components/tooltip/tooltip.component.d.ts +35 -0
- package/directives/menu.directive.d.ts +27 -0
- package/directives/tooltip.directive.d.ts +26 -0
- package/directives/utils.d.ts +8 -0
- package/esm2020/components/dynamic-html/dynamic-html.component.mjs +43 -0
- package/esm2020/components/dynamic-html/dynamic-html.module.mjs +27 -0
- package/esm2020/components/dynamic-html/dynamic-html.service.mjs +66 -0
- package/esm2020/components/dynamic-html/types.mjs +7 -0
- package/esm2020/components/lazy-loader/lazy-loader.component.mjs +360 -0
- package/esm2020/components/lazy-loader/lazy-loader.module.mjs +29 -0
- package/esm2020/components/lazy-loader/lazy-loader.service.mjs +215 -0
- package/esm2020/components/lazy-loader/types.mjs +26 -0
- package/esm2020/components/menu/menu.component.mjs +316 -0
- package/esm2020/components/tooltip/tooltip.component.mjs +135 -0
- package/esm2020/directives/menu.directive.mjs +112 -0
- package/esm2020/directives/tooltip.directive.mjs +92 -0
- package/esm2020/directives/utils.mjs +120 -0
- package/esm2020/dotglitch-ngx-common.mjs +5 -0
- package/esm2020/pipes/html-bypass.pipe.mjs +27 -0
- package/esm2020/pipes/resource-bypass.pipe.mjs +27 -0
- package/esm2020/pipes/script-bypass.pipe.mjs +27 -0
- package/esm2020/pipes/style-bypass.pipe.mjs +27 -0
- package/esm2020/pipes/url-bypass.pipe.mjs +27 -0
- package/esm2020/public-api.mjs +39 -0
- package/esm2020/services/dependency.service.mjs +55 -0
- package/esm2020/services/dialog.service.mjs +66 -0
- package/esm2020/services/fetch.service.mjs +71 -0
- package/esm2020/services/keyboard.service.mjs +128 -0
- package/esm2020/types/menu.mjs +2 -0
- package/esm2020/types/popup.mjs +2 -0
- package/esm2020/utils/index.mjs +39 -0
- package/fesm2015/dotglitch-ngx-common.mjs +1997 -0
- package/fesm2015/dotglitch-ngx-common.mjs.map +1 -0
- package/fesm2020/dotglitch-ngx-common.mjs +1977 -0
- package/fesm2020/dotglitch-ngx-common.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/package.json +60 -0
- package/pipes/html-bypass.pipe.d.ts +16 -0
- package/pipes/resource-bypass.pipe.d.ts +16 -0
- package/pipes/script-bypass.pipe.d.ts +16 -0
- package/pipes/style-bypass.pipe.d.ts +16 -0
- package/pipes/url-bypass.pipe.d.ts +16 -0
- package/public-api.d.ts +34 -0
- package/services/dependency.service.d.ts +19 -0
- package/services/dialog.service.d.ts +41 -0
- package/services/fetch.service.d.ts +28 -0
- package/services/keyboard.service.d.ts +79 -0
- package/types/menu.d.ts +90 -0
- package/types/popup.d.ts +27 -0
- package/utils/index.d.ts +19 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
|
|
2
|
+
import { LazyLoaderService } from '../public-api';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export type DialogOptions = Partial<Omit<MatDialogConfig<any>, 'data'> & {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
group: string;
|
|
9
|
+
/**
|
|
10
|
+
* List of properties to be provided to @Input() injectors
|
|
11
|
+
*/
|
|
12
|
+
inputs: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* List of properties to be provided to @Input() injectors
|
|
17
|
+
*/
|
|
18
|
+
outputs: {
|
|
19
|
+
[key: string]: Function;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Context in which to execute callbacks from the `outputs` property via
|
|
23
|
+
* @Output() event Emitters
|
|
24
|
+
*/
|
|
25
|
+
parent: any;
|
|
26
|
+
}>;
|
|
27
|
+
export declare class DialogService {
|
|
28
|
+
private dialog;
|
|
29
|
+
private lazyLoader;
|
|
30
|
+
private dialogs;
|
|
31
|
+
constructor(dialog: MatDialog, lazyLoader: LazyLoaderService);
|
|
32
|
+
open(name: string, opts?: DialogOptions): Promise<any>;
|
|
33
|
+
close(name: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Method to close _all_ dialogs.
|
|
36
|
+
* Should be used sparingly.
|
|
37
|
+
*/
|
|
38
|
+
clearDialog(): void;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DialogService, never>;
|
|
40
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DialogService>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HttpClient, HttpContext, HttpHeaders, HttpParams } from "@angular/common/http";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type FetchOptions = {
|
|
4
|
+
headers?: HttpHeaders | {
|
|
5
|
+
[header: string]: string | string[];
|
|
6
|
+
};
|
|
7
|
+
context?: HttpContext;
|
|
8
|
+
params?: HttpParams | {
|
|
9
|
+
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
10
|
+
};
|
|
11
|
+
body?: any;
|
|
12
|
+
observe?: 'body' | 'events' | 'response';
|
|
13
|
+
reportProgress?: boolean;
|
|
14
|
+
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
|
15
|
+
withCredentials?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare class Fetch {
|
|
18
|
+
private http;
|
|
19
|
+
constructor(http: HttpClient);
|
|
20
|
+
get<T>(url: string, options?: FetchOptions, returnError?: boolean): Promise<T>;
|
|
21
|
+
put<T>(url: string, body: any, options?: FetchOptions, returnError?: boolean): Promise<T>;
|
|
22
|
+
post<T>(url: string, body: any, options?: FetchOptions, returnError?: boolean): Promise<T>;
|
|
23
|
+
patch<T>(url: string, body: any, options?: FetchOptions, returnError?: boolean): Promise<T>;
|
|
24
|
+
delete<T>(url: string, options?: FetchOptions, returnError?: boolean): Promise<T>;
|
|
25
|
+
private request;
|
|
26
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Fetch, never>;
|
|
27
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<Fetch>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type KeyCommand = {
|
|
4
|
+
/**
|
|
5
|
+
* The non-modifier key(s) that must be pressed for the event to fire.
|
|
6
|
+
*/
|
|
7
|
+
key: string | string[];
|
|
8
|
+
label: string;
|
|
9
|
+
ctrl?: boolean;
|
|
10
|
+
alt?: boolean;
|
|
11
|
+
shift?: boolean;
|
|
12
|
+
super?: boolean;
|
|
13
|
+
tab?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Should the handler interrupt default event handling
|
|
16
|
+
*/
|
|
17
|
+
interrupt?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Service that listens for global keyboard events
|
|
21
|
+
*/
|
|
22
|
+
export declare class KeyboardService {
|
|
23
|
+
private heldKeys;
|
|
24
|
+
keyCommands: {
|
|
25
|
+
ctrl?: boolean;
|
|
26
|
+
alt?: boolean;
|
|
27
|
+
shift?: boolean;
|
|
28
|
+
super?: boolean;
|
|
29
|
+
interrupt?: boolean;
|
|
30
|
+
label: string;
|
|
31
|
+
keys: string[];
|
|
32
|
+
sub: Subject<KeyboardEvent>;
|
|
33
|
+
}[];
|
|
34
|
+
constructor();
|
|
35
|
+
private onKeyDown;
|
|
36
|
+
private onKeyUp;
|
|
37
|
+
private onKeyPress;
|
|
38
|
+
/**
|
|
39
|
+
* Use this to subscribe to keyboard events throughout
|
|
40
|
+
* the application. This is a passive listener and will
|
|
41
|
+
* **NOT** interrupt the event chain.
|
|
42
|
+
*/
|
|
43
|
+
onKeyCommand(key: KeyCommand): {
|
|
44
|
+
subscribe: {
|
|
45
|
+
(observerOrNext?: Partial<import("rxjs").Observer<KeyboardEvent>> | ((value: KeyboardEvent) => void)): import("rxjs").Subscription;
|
|
46
|
+
(next?: (value: KeyboardEvent) => void, error?: (error: any) => void, complete?: () => void): import("rxjs").Subscription;
|
|
47
|
+
};
|
|
48
|
+
closed: boolean;
|
|
49
|
+
observers: import("rxjs").Observer<KeyboardEvent>[];
|
|
50
|
+
isStopped: boolean;
|
|
51
|
+
hasError: boolean;
|
|
52
|
+
thrownError: any;
|
|
53
|
+
source: import("rxjs").Observable<any>;
|
|
54
|
+
operator: import("rxjs").Operator<any, KeyboardEvent>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Return `true` if shift is currently pressed.
|
|
58
|
+
*/
|
|
59
|
+
get isShiftPressed(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Return `true` if ctrl is currently pressed.
|
|
62
|
+
*/
|
|
63
|
+
get isCtrlPressed(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Return `true` if alt is currently pressed.
|
|
66
|
+
*/
|
|
67
|
+
get isAltPressed(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Return `true` if super (mac/linux) or the windows key is currently pressed.
|
|
70
|
+
*/
|
|
71
|
+
get isSuperPressed(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Return `true` if tab is currently pressed.
|
|
74
|
+
*/
|
|
75
|
+
get isTabPressed(): boolean;
|
|
76
|
+
clearKeys(): void;
|
|
77
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KeyboardService, never>;
|
|
78
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<KeyboardService>;
|
|
79
|
+
}
|
package/types/menu.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TemplateRef, Type } from '@angular/core';
|
|
2
|
+
import { PopupOptions } from './popup';
|
|
3
|
+
type MenuTrigger = "click" | "dblclick" | "hover" | "contextmenu";
|
|
4
|
+
export type MenuOptions = Partial<PopupOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Which event should trigger the app menu.
|
|
7
|
+
*/
|
|
8
|
+
trigger: MenuTrigger | MenuTrigger[];
|
|
9
|
+
}>;
|
|
10
|
+
type BaseMenuItem<T = any> = {
|
|
11
|
+
/**
|
|
12
|
+
* Label for the menu-item
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom angular template to use for the label
|
|
17
|
+
* Alternatively accepts a lambda function
|
|
18
|
+
*/
|
|
19
|
+
labelTemplate?: TemplateRef<any> | ((data: T) => string);
|
|
20
|
+
/**
|
|
21
|
+
* Callback method that is called when a user activates
|
|
22
|
+
* a context-menu item.
|
|
23
|
+
* Use the `contextMenuData` decorator for passing data.
|
|
24
|
+
*/
|
|
25
|
+
action?: (data: T) => any;
|
|
26
|
+
/**
|
|
27
|
+
* Instead of an action, this item can be a hyperlink pointing to this URL
|
|
28
|
+
* www.example.com/foo/bar.zip
|
|
29
|
+
*/
|
|
30
|
+
link?: string;
|
|
31
|
+
/**
|
|
32
|
+
* When having a configured `link` property, this specifies the `target`
|
|
33
|
+
* attribute applied to the link
|
|
34
|
+
*/
|
|
35
|
+
linkTarget?: "_blank" | "_self" | "_parent" | "_top";
|
|
36
|
+
/**
|
|
37
|
+
* Custom template function for resolving a link when the context menu
|
|
38
|
+
* is opened
|
|
39
|
+
*/
|
|
40
|
+
linkTemplate?: ((data: T) => string);
|
|
41
|
+
/**
|
|
42
|
+
* Callback method that is called upon a context menu activation
|
|
43
|
+
* that when it returns true, will show the item as disabled.
|
|
44
|
+
*/
|
|
45
|
+
isDisabled?: (data: T) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Callback method that is called upon a context menu activation
|
|
48
|
+
* that when returning false, will hide the menu item.
|
|
49
|
+
*/
|
|
50
|
+
isVisible?: (data: T) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If a shortcut is set, the text-label.
|
|
53
|
+
*/
|
|
54
|
+
shortcutLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Keyboard shortcut to activate this item.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Icon to render on the left side of the item.
|
|
60
|
+
* Can be a URL/URI (must include extension)
|
|
61
|
+
* Or can be a material icon identifier.
|
|
62
|
+
*/
|
|
63
|
+
icon?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Optional child menu
|
|
66
|
+
*/
|
|
67
|
+
children?: MenuItem<T>[];
|
|
68
|
+
/**
|
|
69
|
+
* Optional resolver that dynamically loads the contents
|
|
70
|
+
* for the menu item.
|
|
71
|
+
* Can be used to dynamically determine the submenu contents
|
|
72
|
+
*/
|
|
73
|
+
childrenResolver?: (data: T) => Promise<MenuItem<T>[]>;
|
|
74
|
+
/**
|
|
75
|
+
* If `childrenResolver` is provided, disable caching of
|
|
76
|
+
* the resolved children.
|
|
77
|
+
*/
|
|
78
|
+
cacheResolvedChildren?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Instead of an array of children, render a template
|
|
81
|
+
*/
|
|
82
|
+
childTemplate?: TemplateRef<T> | Type<any>;
|
|
83
|
+
/**
|
|
84
|
+
* This item is a separator.
|
|
85
|
+
* Can be used with label to make a label separator.
|
|
86
|
+
*/
|
|
87
|
+
separator?: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type MenuItem<T = any> = BaseMenuItem<T> | "separator";
|
|
90
|
+
export {};
|
package/types/popup.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type PopupOptions = Partial<{
|
|
2
|
+
/**
|
|
3
|
+
* Position relative to the element the menu pops-up at
|
|
4
|
+
*/
|
|
5
|
+
position: "top" | "right" | "bottom" | "left";
|
|
6
|
+
/**
|
|
7
|
+
* How the popup is aligned relative to the element
|
|
8
|
+
*/
|
|
9
|
+
alignment: "center" | "beforestart" | "start" | "end" | "afterend";
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
* WIP:
|
|
13
|
+
* Show an error from the dialog pointing to the element
|
|
14
|
+
*/
|
|
15
|
+
showArrow: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
* WIP:
|
|
19
|
+
* Size of the arrow.
|
|
20
|
+
*/
|
|
21
|
+
arrowSize: number;
|
|
22
|
+
/**
|
|
23
|
+
* How much padding to add near the edges of the screen.
|
|
24
|
+
*/
|
|
25
|
+
edgePadding: number;
|
|
26
|
+
customClass: string[];
|
|
27
|
+
}>;
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const sleep: (ms: any) => Promise<unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Prompt the user to save a json file of the given object.
|
|
4
|
+
*/
|
|
5
|
+
export declare const saveObjectAsFile: (name: string, data: Object) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Formatted logger that will print a bit of context before the message.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const Logger: (context: string, contextColor: string, textColor?: string) => {
|
|
11
|
+
log: (message: any, ...args: any[]) => void;
|
|
12
|
+
warn: (message: any, ...args: any[]) => void;
|
|
13
|
+
err: (message: any, ...args: any[]) => void;
|
|
14
|
+
error: (message: any, ...args: any[]) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Convert a string `fooBAR baz_160054''"1]"` into a slug: `foobar-baz-1600541`
|
|
18
|
+
*/
|
|
19
|
+
export declare const stringToSlug: (text: string) => string;
|