angular-toolbox 0.0.7 → 0.0.8

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.
@@ -1,3 +1,4 @@
1
1
  export * from './subscription/subscription.service';
2
2
  export * from './ui/dark-mode.service';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9hbmd1bGFyLXRvb2xib3gvc3JjL2xpYi9zZXJ2aWNlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMscUNBQXFDLENBQUM7QUFDcEQsY0FBYyx3QkFBd0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vc3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbi5zZXJ2aWNlJztcclxuZXhwb3J0ICogZnJvbSAnLi91aS9kYXJrLW1vZGUuc2VydmljZSc7Il19
3
+ export * from './ui/scroll.service';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9hbmd1bGFyLXRvb2xib3gvc3JjL2xpYi9zZXJ2aWNlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMscUNBQXFDLENBQUM7QUFDcEQsY0FBYyx3QkFBd0IsQ0FBQztBQUN2QyxjQUFjLHFCQUFxQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9zdWJzY3JpcHRpb24vc3Vic2NyaXB0aW9uLnNlcnZpY2UnO1xyXG5leHBvcnQgKiBmcm9tICcuL3VpL2RhcmstbW9kZS5zZXJ2aWNlJztcclxuZXhwb3J0ICogZnJvbSAnLi91aS9zY3JvbGwuc2VydmljZSc7Il19
@@ -0,0 +1,79 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import { EventEmitter, Inject, Injectable } from '@angular/core';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * A lightweight service that provides scrolling capabilities to your Angular application.
6
+ */
7
+ export class ScrollService {
8
+ /**
9
+ * Creates a new ScrollService instance.
10
+ * @param _document the reference to the Document singleton.
11
+ */
12
+ constructor(_document) {
13
+ this._document = _document;
14
+ /**
15
+ * The callback function that is triggered when a scroll operation is performed.
16
+ * @typeParam EventEmitter<Event> the reference to the original scroll event.
17
+ */
18
+ this.onScroll = new EventEmitter();
19
+ window.addEventListener("scroll", (e) => {
20
+ this.onScroll.next(e);
21
+ });
22
+ }
23
+ /**
24
+ * Scrolls the ancestor containers of the element with the specified selector such that
25
+ * this element is visible to the user.
26
+ * @param selector the selector of the target element.
27
+ * @param arg a boolean value:
28
+ * If true, the top of the element will be aligned to the top of the visible area of the
29
+ * scrollable ancestor.
30
+ * If false, the bottom of the element will be aligned to the bottom of the visible area
31
+ * of the scrollable ancestor.
32
+ * @param arg a dictionary containing the scroll parameters.
33
+ */
34
+ scrollIntoView(selector, arg) {
35
+ const elm = this._document.querySelector(selector);
36
+ if (elm)
37
+ elm.scrollIntoView(arg);
38
+ }
39
+ /**
40
+ * Scrolls the app viewport to the top of the browser window.
41
+ * @param behavior Specifies whether the scrolling should animate smoothly (smooth),
42
+ * happen instantly in a single jump (instant), or let the browser
43
+ * choose (auto, default).
44
+ */
45
+ gotoTop(behavior = 'smooth') {
46
+ const options = {
47
+ top: 0,
48
+ behavior: behavior
49
+ };
50
+ this.scroll(options);
51
+ }
52
+ /**
53
+ * Scrolls the app viewport according to the specified options, into the browser window.
54
+ * @param options A dictionary containing the scroll parameters.
55
+ */
56
+ scroll(options) {
57
+ window.scroll(options);
58
+ }
59
+ /**
60
+ * Scrolls the app viewport to the specified x/y coordinates, into the browser window.
61
+ * @param x the horizontal pixel value that you want to scroll by.
62
+ * @param y the vertical pixel value that you want to scroll by.
63
+ */
64
+ scrollTo(x, y) {
65
+ window.scrollBy(x, y);
66
+ }
67
+ }
68
+ ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
69
+ ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, providedIn: 'root' });
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, decorators: [{
71
+ type: Injectable,
72
+ args: [{
73
+ providedIn: 'root'
74
+ }]
75
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
76
+ type: Inject,
77
+ args: [DOCUMENT]
78
+ }] }]; } });
79
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9hbmd1bGFyLXRvb2xib3gvc3JjL2xpYi9zZXJ2aWNlL3VpL3Njcm9sbC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzQyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBVWpFOztHQUVHO0FBQ0gsTUFBTSxPQUFPLGFBQWE7SUFRdEI7OztPQUdHO0lBQ0wsWUFBc0MsU0FBbUI7UUFBbkIsY0FBUyxHQUFULFNBQVMsQ0FBVTtRQVZ2RDs7O1dBR0c7UUFDVyx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gd2luZG93LlxuICAgKiBAcGFyYW0gb3B0aW9ucyBBIGRpY3Rpb25hcnkgY29udGFpbmluZyB0aGUgc2Nyb2xsIHBhcmFtZXRlcnMuXG4gICAqL1xuICBwdWJsaWMgc2Nyb2xsKG9wdGlvbnM/OiBTY3JvbGxUb09wdGlvbnMpOiB2b2lkIHtcbiAgICB3aW5kb3cuc2Nyb2xsKG9wdGlvbnMpO1xuICB9XG4gIFxuICAvKipcbiAgICogU2Nyb2xscyB0aGUgYXBwIHZpZXdwb3J0IHRvIHRoZSBzcGVjaWZpZWQgeC95IGNvb3JkaW5hdGVzLCBpbnRvIHRoZSBicm93c2VyIHdpbmRvdy5cbiAgICogQHBhcmFtIHggdGhlIGhvcml6b250YWwgcGl4ZWwgdmFsdWUgdGhhdCB5b3Ugd2FudCB0byBzY3JvbGwgYnkuXG4gICAqIEBwYXJhbSB5IHRoZSB2ZXJ0aWNhbCAgcGl4ZWwgdmFsdWUgdGhhdCB5b3Ugd2FudCB0byBzY3JvbGwgYnkuXG4gICAqL1xuICBwdWJsaWMgc2Nyb2xsVG8oeDogbnVtYmVyLCB5OiBudW1iZXIpOiB2b2lkIHtcbiAgICB3aW5kb3cuc2Nyb2xsQnkoeCwgeSk7XG4gIH1cbn1cbiJdfQ==
@@ -266,6 +266,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
266
266
  }]
267
267
  }] });
268
268
 
269
+ /**
270
+ * A lightweight service that provides scrolling capabilities to your Angular application.
271
+ */
272
+ class ScrollService {
273
+ /**
274
+ * Creates a new ScrollService instance.
275
+ * @param _document the reference to the Document singleton.
276
+ */
277
+ constructor(_document) {
278
+ this._document = _document;
279
+ /**
280
+ * The callback function that is triggered when a scroll operation is performed.
281
+ * @typeParam EventEmitter<Event> the reference to the original scroll event.
282
+ */
283
+ this.onScroll = new EventEmitter();
284
+ window.addEventListener("scroll", (e) => {
285
+ this.onScroll.next(e);
286
+ });
287
+ }
288
+ /**
289
+ * Scrolls the ancestor containers of the element with the specified selector such that
290
+ * this element is visible to the user.
291
+ * @param selector the selector of the target element.
292
+ * @param arg a boolean value:
293
+ * If true, the top of the element will be aligned to the top of the visible area of the
294
+ * scrollable ancestor.
295
+ * If false, the bottom of the element will be aligned to the bottom of the visible area
296
+ * of the scrollable ancestor.
297
+ * @param arg a dictionary containing the scroll parameters.
298
+ */
299
+ scrollIntoView(selector, arg) {
300
+ const elm = this._document.querySelector(selector);
301
+ if (elm)
302
+ elm.scrollIntoView(arg);
303
+ }
304
+ /**
305
+ * Scrolls the app viewport to the top of the browser window.
306
+ * @param behavior Specifies whether the scrolling should animate smoothly (smooth),
307
+ * happen instantly in a single jump (instant), or let the browser
308
+ * choose (auto, default).
309
+ */
310
+ gotoTop(behavior = 'smooth') {
311
+ const options = {
312
+ top: 0,
313
+ behavior: behavior
314
+ };
315
+ this.scroll(options);
316
+ }
317
+ /**
318
+ * Scrolls the app viewport according to the specified options, into the browser window.
319
+ * @param options A dictionary containing the scroll parameters.
320
+ */
321
+ scroll(options) {
322
+ window.scroll(options);
323
+ }
324
+ /**
325
+ * Scrolls the app viewport to the specified x/y coordinates, into the browser window.
326
+ * @param x the horizontal pixel value that you want to scroll by.
327
+ * @param y the vertical pixel value that you want to scroll by.
328
+ */
329
+ scrollTo(x, y) {
330
+ window.scrollBy(x, y);
331
+ }
332
+ }
333
+ ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
334
+ ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, providedIn: 'root' });
335
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, decorators: [{
336
+ type: Injectable,
337
+ args: [{
338
+ providedIn: 'root'
339
+ }]
340
+ }], ctorParameters: function () {
341
+ return [{ type: Document, decorators: [{
342
+ type: Inject,
343
+ args: [DOCUMENT]
344
+ }] }];
345
+ } });
346
+
269
347
  /*
270
348
  * Public API Surface of angular-toolbox
271
349
  */
@@ -274,5 +352,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
274
352
  * Generated bundle index. Do not edit.
275
353
  */
276
354
 
277
- export { AngularToolboxModule, DARK_MODE_CONFIG, DarkModeService, SafeHtmlPipe, SubscriptionService };
355
+ export { AngularToolboxModule, DARK_MODE_CONFIG, DarkModeService, SafeHtmlPipe, ScrollService, SubscriptionService };
278
356
  //# sourceMappingURL=angular-toolbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-toolbox.mjs","sources":["../../../projects/angular-toolbox/src/lib/pipe/safe/safe-html.pipe.ts","../../../projects/angular-toolbox/src/lib/service/ui/dark-mode.service.ts","../../../projects/angular-toolbox/src/lib/angular-toolbox.module.ts","../../../projects/angular-toolbox/src/lib/service/subscription/subscription.service.ts","../../../projects/angular-toolbox/src/public-api.ts","../../../projects/angular-toolbox/src/angular-toolbox.ts"],"sourcesContent":["import { DomSanitizer, SafeHtml } from '@angular/platform-browser'\r\nimport { PipeTransform, Pipe } from \"@angular/core\";\r\n\r\n@Pipe({ name: 'safeHtml'})\r\nexport class SafeHtmlPipe implements PipeTransform {\r\n\r\n constructor(private _sanitizer: DomSanitizer) {}\r\n\r\n public transform(value: string): SafeHtml {\r\n return this._sanitizer.bypassSecurityTrustHtml(value);\r\n }\r\n}","import { Inject, Injectable, EventEmitter } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n// --> Internal constants\nconst STORAGE_KEY: string = \"dark-mode-key\";\nconst CSS_PROP: string = \"dark-mode\";\nconst ADD_ACTION: string = \"add\";\nconst REMOVE_ACTION: string = \"remove\";\n\n/**\n * Defines properties for the DarkModeService configuration.\n */\nexport interface DarkModeConfig {\n\n /**\n * Indicates whether the dark mode is activated by default (true), or not (false).\n */\n darkModeEnabled?: boolean;\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * When true, this property overrides the darkModeEnabled property.\n */\n detectBrowserSettings?: boolean;\n\n /**\n * CSS property name used to set the dark mode look and feel.\n */\n cssProperty?: string;\n\n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n */\n storageKey?: string;\n}\n\n/**\n * The default provider for the DarkModeService configuration. You typically define\n * the custom properties in the main NgModule declaration to initialize the app dark mode:\n * \n * @NgModule({\n * ...\n * providers: [\n * { provide: DARK_MODE_CONFIG, useValue: { enableDarkMode: true} }\n * ],\n * ...\n * s);\n */\nexport const DARK_MODE_CONFIG: DarkModeConfig = {\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n darkModeEnabled: false,\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n detectBrowserSettings: false,\n \n /**\n * CSS property name used to set the dark mode look and feel.\n * Default value is 'dark-mode'.\n */\n cssProperty: CSS_PROP,\n \n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n * Default value is 'dark-mode-key'.\n */\n storageKey: STORAGE_KEY\n};\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides Dark Mode implementation for your Angular application.\n */\nexport class DarkModeService {\n\n // --> Private properties\n private _darkModeEnabled: boolean = false;\n private _cssProperty: string = CSS_PROP;\n private _storageKey: string = STORAGE_KEY;\n\n /**\n * The callback function that is triggered when the dark mode changes.\n * @typeParam EventEmitter<boolean> the value returned by the darkModeEnabled() property.\n */\n public readonly change: EventEmitter<boolean> = new EventEmitter<boolean>(true);\n\n /**\n * Creates a new DarkModeService instance.\n * @param _document the reference to the Document singleton.\n * @param config the reference to the DarkModeConfig provider.\n */\n constructor(@Inject(DOCUMENT) private _document: Document, @Inject(DARK_MODE_CONFIG) config: DarkModeConfig) {\n this.initDarkMode(config);\n }\n\n /**\n * Toogles the dark mode state.\n */\n public toggleDarkMode(): void {\n this._darkModeEnabled ? this.disableDarkMode() : this.enableDarkMode();\n }\n\n /**\n * Sets the dark mode state to active.\n */\n public enableDarkMode(): void {\n this.setDarkMode(ADD_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Sets the dark mode state to inactive.\n */\n public disableDarkMode(): void {\n this.setDarkMode(REMOVE_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Returns a boolean value that indicates the dark mode state is active (true), or not (false).\n * @returns true whether the dark mode state is active; false otherwise.\n */\n public darkModeEnabled(): boolean {\n return this._darkModeEnabled;\n }\n\n /**\n * Returns the value of the CSS property as defined by the config provider.\n * @returns the value of the CSS property.\n */\n public getCssProperty(): string {\n return this._cssProperty;\n }\n\n /**\n * Returns the value of the storage key as defined by the config provider.\n * @returns the value of the storage key.\n */\n public getStorageKey(): string {\n return this._storageKey;\n }\n \n /**\n * Removes the dark mode information from local storage.\n */\n public invalidateStorage(): void {\n localStorage.removeItem(this._storageKey);\n }\n\n // --> Private methods\n private initDarkMode(config: DarkModeConfig): void {\n this._darkModeEnabled = config.darkModeEnabled || false;\n this._cssProperty = config.cssProperty || CSS_PROP;\n this._storageKey = config.storageKey || STORAGE_KEY;\n if (this._darkModeEnabled) {\n this.enableDarkMode();\n } else {\n this.initStoredDarkMode();\n }\n if (config.detectBrowserSettings) this.initBrowserMode();\n }\n \n private initStoredDarkMode(): void {\n const result: string | null = localStorage.getItem(this._storageKey);\n if (result === \"true\") this.enableDarkMode();\n }\n\n private setStoredDarkMode(): void {\n const data: string = String(this._darkModeEnabled);\n localStorage.setItem(this._storageKey, data);\n }\n\n private setDarkMode(action: string): void {\n const classList: DOMTokenList = this._document.body.classList;\n if (action === ADD_ACTION) {\n classList.add(this._cssProperty);\n this._darkModeEnabled = true;\n } else if (action === REMOVE_ACTION) {\n classList.remove(this._cssProperty);\n this._darkModeEnabled = false;\n }\n this.change.emit(this._darkModeEnabled);\n }\n\n private initBrowserMode(): void {\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n this.enableDarkMode();\n }\n }\n}\n\n","import { NgModule } from '@angular/core';\r\nimport { SafeHtmlPipe } from './pipe/safe/safe-html.pipe';\r\nimport { DARK_MODE_CONFIG } from './service/ui/dark-mode.service';\r\n\r\n@NgModule({\r\n declarations: [\r\n SafeHtmlPipe\r\n ],\r\n providers: [\r\n { provide: DARK_MODE_CONFIG, useValue: DARK_MODE_CONFIG }\r\n ],\r\n exports: [\r\n SafeHtmlPipe\r\n ]\r\n})\r\nexport class AngularToolboxModule { }","import { Injectable } from '@angular/core';\nimport { Subscription } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that helps to manage unregistration issues of Angular subscriptions.\n */\nexport class SubscriptionService {\n\n /**\n * The internal Subscription instances storage.\n */\n private _subMap: Map<String, Array<Subscription>> = new Map<String, Array<Subscription>>();\n\n /**\n * Stores a new Subscription instance associated with the specified reference.\n * \n * @param ref the reference for which to store a new Subscription instance.\n * @param subscription the Subscription instance to register.\n * @returns a reference to this SubscriptionService instance.\n */\n public register(ref: String, subscription: Subscription): SubscriptionService {\n if (!this._subMap.has(ref)) this._subMap.set(ref, []);\n this._subMap.get(ref)?.push(subscription);\n return this;\n }\n \n /**\n * Unsubscribes and removes all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove all Subscription instances.\n * @returns true whether the specified reference exists; false otherwise.\n */\n public clearAll(ref: String): boolean {\n let result: boolean = false;\n if (this._subMap.has(ref)) {\n this._subMap.get(ref)?.forEach(subscription => subscription.unsubscribe());\n this._subMap.delete(ref);\n result = true;\n }\n return result;\n }\n\n /**\n * Returns all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove get Subscription instances.\n * @returns all Subscription instances associated with the specified reference, or whether\n * the specified reference does not exists.\n */\n public get(ref: String): Array<Subscription> | null {\n return this._subMap.get(ref) || null;\n }\n}\n","/*\n * Public API Surface of angular-toolbox\n */\n\nexport * from './lib/angular-toolbox.module';\nexport * from './lib/pipe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A,GAAG,CAAC,GAAW,EAAA;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;KACxC;;gHA7CQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAnB,mBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cALhB,MAAM,EAAA,CAAA,CAAA;2FAKT,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAN/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;iBACrB,CAAA;;;ACLD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"angular-toolbox.mjs","sources":["../../../projects/angular-toolbox/src/lib/pipe/safe/safe-html.pipe.ts","../../../projects/angular-toolbox/src/lib/service/ui/dark-mode.service.ts","../../../projects/angular-toolbox/src/lib/angular-toolbox.module.ts","../../../projects/angular-toolbox/src/lib/service/subscription/subscription.service.ts","../../../projects/angular-toolbox/src/lib/service/ui/scroll.service.ts","../../../projects/angular-toolbox/src/public-api.ts","../../../projects/angular-toolbox/src/angular-toolbox.ts"],"sourcesContent":["import { DomSanitizer, SafeHtml } from '@angular/platform-browser'\r\nimport { PipeTransform, Pipe } from \"@angular/core\";\r\n\r\n@Pipe({ name: 'safeHtml'})\r\nexport class SafeHtmlPipe implements PipeTransform {\r\n\r\n constructor(private _sanitizer: DomSanitizer) {}\r\n\r\n public transform(value: string): SafeHtml {\r\n return this._sanitizer.bypassSecurityTrustHtml(value);\r\n }\r\n}","import { Inject, Injectable, EventEmitter } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n// --> Internal constants\nconst STORAGE_KEY: string = \"dark-mode-key\";\nconst CSS_PROP: string = \"dark-mode\";\nconst ADD_ACTION: string = \"add\";\nconst REMOVE_ACTION: string = \"remove\";\n\n/**\n * Defines properties for the DarkModeService configuration.\n */\nexport interface DarkModeConfig {\n\n /**\n * Indicates whether the dark mode is activated by default (true), or not (false).\n */\n darkModeEnabled?: boolean;\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * When true, this property overrides the darkModeEnabled property.\n */\n detectBrowserSettings?: boolean;\n\n /**\n * CSS property name used to set the dark mode look and feel.\n */\n cssProperty?: string;\n\n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n */\n storageKey?: string;\n}\n\n/**\n * The default provider for the DarkModeService configuration. You typically define\n * the custom properties in the main NgModule declaration to initialize the app dark mode:\n * \n * @NgModule({\n * ...\n * providers: [\n * { provide: DARK_MODE_CONFIG, useValue: { enableDarkMode: true} }\n * ],\n * ...\n * s);\n */\nexport const DARK_MODE_CONFIG: DarkModeConfig = {\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n darkModeEnabled: false,\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n detectBrowserSettings: false,\n \n /**\n * CSS property name used to set the dark mode look and feel.\n * Default value is 'dark-mode'.\n */\n cssProperty: CSS_PROP,\n \n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n * Default value is 'dark-mode-key'.\n */\n storageKey: STORAGE_KEY\n};\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides Dark Mode implementation for your Angular application.\n */\nexport class DarkModeService {\n\n // --> Private properties\n private _darkModeEnabled: boolean = false;\n private _cssProperty: string = CSS_PROP;\n private _storageKey: string = STORAGE_KEY;\n\n /**\n * The callback function that is triggered when the dark mode changes.\n * @typeParam EventEmitter<boolean> the value returned by the darkModeEnabled() property.\n */\n public readonly change: EventEmitter<boolean> = new EventEmitter<boolean>(true);\n\n /**\n * Creates a new DarkModeService instance.\n * @param _document the reference to the Document singleton.\n * @param config the reference to the DarkModeConfig provider.\n */\n constructor(@Inject(DOCUMENT) private _document: Document, @Inject(DARK_MODE_CONFIG) config: DarkModeConfig) {\n this.initDarkMode(config);\n }\n\n /**\n * Toogles the dark mode state.\n */\n public toggleDarkMode(): void {\n this._darkModeEnabled ? this.disableDarkMode() : this.enableDarkMode();\n }\n\n /**\n * Sets the dark mode state to active.\n */\n public enableDarkMode(): void {\n this.setDarkMode(ADD_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Sets the dark mode state to inactive.\n */\n public disableDarkMode(): void {\n this.setDarkMode(REMOVE_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Returns a boolean value that indicates the dark mode state is active (true), or not (false).\n * @returns true whether the dark mode state is active; false otherwise.\n */\n public darkModeEnabled(): boolean {\n return this._darkModeEnabled;\n }\n\n /**\n * Returns the value of the CSS property as defined by the config provider.\n * @returns the value of the CSS property.\n */\n public getCssProperty(): string {\n return this._cssProperty;\n }\n\n /**\n * Returns the value of the storage key as defined by the config provider.\n * @returns the value of the storage key.\n */\n public getStorageKey(): string {\n return this._storageKey;\n }\n \n /**\n * Removes the dark mode information from local storage.\n */\n public invalidateStorage(): void {\n localStorage.removeItem(this._storageKey);\n }\n\n // --> Private methods\n private initDarkMode(config: DarkModeConfig): void {\n this._darkModeEnabled = config.darkModeEnabled || false;\n this._cssProperty = config.cssProperty || CSS_PROP;\n this._storageKey = config.storageKey || STORAGE_KEY;\n if (this._darkModeEnabled) {\n this.enableDarkMode();\n } else {\n this.initStoredDarkMode();\n }\n if (config.detectBrowserSettings) this.initBrowserMode();\n }\n \n private initStoredDarkMode(): void {\n const result: string | null = localStorage.getItem(this._storageKey);\n if (result === \"true\") this.enableDarkMode();\n }\n\n private setStoredDarkMode(): void {\n const data: string = String(this._darkModeEnabled);\n localStorage.setItem(this._storageKey, data);\n }\n\n private setDarkMode(action: string): void {\n const classList: DOMTokenList = this._document.body.classList;\n if (action === ADD_ACTION) {\n classList.add(this._cssProperty);\n this._darkModeEnabled = true;\n } else if (action === REMOVE_ACTION) {\n classList.remove(this._cssProperty);\n this._darkModeEnabled = false;\n }\n this.change.emit(this._darkModeEnabled);\n }\n\n private initBrowserMode(): void {\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n this.enableDarkMode();\n }\n }\n}\n\n","import { NgModule } from '@angular/core';\r\nimport { SafeHtmlPipe } from './pipe/safe/safe-html.pipe';\r\nimport { DARK_MODE_CONFIG } from './service/ui/dark-mode.service';\r\n\r\n@NgModule({\r\n declarations: [\r\n SafeHtmlPipe\r\n ],\r\n providers: [\r\n { provide: DARK_MODE_CONFIG, useValue: DARK_MODE_CONFIG }\r\n ],\r\n exports: [\r\n SafeHtmlPipe\r\n ]\r\n})\r\nexport class AngularToolboxModule { }","import { Injectable } from '@angular/core';\nimport { Subscription } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that helps to manage unregistration issues of Angular subscriptions.\n */\nexport class SubscriptionService {\n\n /**\n * The internal Subscription instances storage.\n */\n private _subMap: Map<String, Array<Subscription>> = new Map<String, Array<Subscription>>();\n\n /**\n * Stores a new Subscription instance associated with the specified reference.\n * \n * @param ref the reference for which to store a new Subscription instance.\n * @param subscription the Subscription instance to register.\n * @returns a reference to this SubscriptionService instance.\n */\n public register(ref: String, subscription: Subscription): SubscriptionService {\n if (!this._subMap.has(ref)) this._subMap.set(ref, []);\n this._subMap.get(ref)?.push(subscription);\n return this;\n }\n \n /**\n * Unsubscribes and removes all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove all Subscription instances.\n * @returns true whether the specified reference exists; false otherwise.\n */\n public clearAll(ref: String): boolean {\n let result: boolean = false;\n if (this._subMap.has(ref)) {\n this._subMap.get(ref)?.forEach(subscription => subscription.unsubscribe());\n this._subMap.delete(ref);\n result = true;\n }\n return result;\n }\n\n /**\n * Returns all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove get Subscription instances.\n * @returns all Subscription instances associated with the specified reference, or whether\n * the specified reference does not exists.\n */\n public get(ref: String): Array<Subscription> | null {\n return this._subMap.get(ref) || null;\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { EventEmitter, Inject, Injectable } from '@angular/core';\n\n/**\n * Workaround for the typescript ScrollBehavior declaration.\n */\ndeclare type ScrollBehavior = \"auto\" | \"instant\" | \"smooth\";\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides scrolling capabilities to your Angular application.\n */\nexport class ScrollService {\n\n /**\n * The callback function that is triggered when a scroll operation is performed.\n * @typeParam EventEmitter<Event> the reference to the original scroll event.\n */\n public readonly onScroll: EventEmitter<Event> = new EventEmitter<Event>();\n\n /**\n * Creates a new ScrollService instance.\n * @param _document the reference to the Document singleton.\n */\n constructor(@Inject(DOCUMENT) private _document: Document) {\n window.addEventListener(\"scroll\", (e: Event) => {\n this.onScroll.next(e);\n });\n }\n\n /**\n * Scrolls the ancestor containers of the element with the specified selector such that \n * this element is visible to the user.\n * @param selector the selector of the target element.\n * @param arg a boolean value:\n * If true, the top of the element will be aligned to the top of the visible area of the\n * scrollable ancestor.\n * If false, the bottom of the element will be aligned to the bottom of the visible area\n * of the scrollable ancestor. \n * @param arg a dictionary containing the scroll parameters.\n */\n public scrollIntoView(selector: string, arg?: boolean | ScrollIntoViewOptions | undefined): void {\n const elm: Element | null = this._document.querySelector(selector);\n if (elm) elm.scrollIntoView(arg);\n }\n\n /**\n * Scrolls the app viewport to the top of the browser window.\n * @param behavior Specifies whether the scrolling should animate smoothly (smooth),\n * happen instantly in a single jump (instant), or let the browser\n * choose (auto, default).\n */\n public gotoTop(behavior: ScrollBehavior = 'smooth'): void {\n const options: ScrollToOptions = {\n top: 0,\n behavior: behavior as any\n };\n this.scroll(options);\n }\n\n /**\n * Scrolls the app viewport according to the specified options, into the browser window.\n * @param options A dictionary containing the scroll parameters.\n */\n public scroll(options?: ScrollToOptions): void {\n window.scroll(options);\n }\n \n /**\n * Scrolls the app viewport to the specified x/y coordinates, into the browser window.\n * @param x the horizontal pixel value that you want to scroll by.\n * @param y the vertical pixel value that you want to scroll by.\n */\n public scrollTo(x: number, y: number): void {\n window.scrollBy(x, y);\n }\n}\n","/*\n * Public API Surface of angular-toolbox\n */\n\nexport * from './lib/angular-toolbox.module';\nexport * from './lib/pipe';\nexport * from './lib/service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAIa,YAAY,CAAA;AAEvB,IAAA,WAAA,CAAoB,UAAwB,EAAA;AAAxB,QAAA,IAAU,CAAA,UAAA,GAAV,UAAU,CAAc;KAAI;AAEzC,IAAA,SAAS,CAAC,KAAa,EAAA;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;KACvD;;yGANU,YAAY,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;uGAAZ,YAAY,EAAA,IAAA,EAAA,UAAA,EAAA,CAAA,CAAA;2FAAZ,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,IAAI;mBAAC,EAAE,IAAI,EAAE,UAAU,EAAC,CAAA;;;ACAzB;AACA,MAAM,WAAW,GAAW,eAAe,CAAC;AAC5C,MAAM,QAAQ,GAAW,WAAW,CAAC;AACrC,MAAM,UAAU,GAAW,KAAK,CAAC;AACjC,MAAM,aAAa,GAAW,QAAQ,CAAC;AA6BvC;;;;;;;;;;;AAWG;AACU,MAAA,gBAAgB,GAAmB;AAE5C;;;AAGG;AACH,IAAA,eAAe,EAAE,KAAK;AAEtB;;;AAGG;AACH,IAAA,qBAAqB,EAAE,KAAK;AAE5B;;;AAGG;AACH,IAAA,WAAW,EAAE,QAAQ;AAErB;;;AAGG;AACH,IAAA,UAAU,EAAE,WAAW;EACzB;AAKF;;AAEG;M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ɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
262
262
  }]
263
263
  }] });
264
264
 
265
+ /**
266
+ * A lightweight service that provides scrolling capabilities to your Angular application.
267
+ */
268
+ class ScrollService {
269
+ /**
270
+ * Creates a new ScrollService instance.
271
+ * @param _document the reference to the Document singleton.
272
+ */
273
+ constructor(_document) {
274
+ this._document = _document;
275
+ /**
276
+ * The callback function that is triggered when a scroll operation is performed.
277
+ * @typeParam EventEmitter<Event> the reference to the original scroll event.
278
+ */
279
+ this.onScroll = new EventEmitter();
280
+ window.addEventListener("scroll", (e) => {
281
+ this.onScroll.next(e);
282
+ });
283
+ }
284
+ /**
285
+ * Scrolls the ancestor containers of the element with the specified selector such that
286
+ * this element is visible to the user.
287
+ * @param selector the selector of the target element.
288
+ * @param arg a boolean value:
289
+ * If true, the top of the element will be aligned to the top of the visible area of the
290
+ * scrollable ancestor.
291
+ * If false, the bottom of the element will be aligned to the bottom of the visible area
292
+ * of the scrollable ancestor.
293
+ * @param arg a dictionary containing the scroll parameters.
294
+ */
295
+ scrollIntoView(selector, arg) {
296
+ const elm = this._document.querySelector(selector);
297
+ if (elm)
298
+ elm.scrollIntoView(arg);
299
+ }
300
+ /**
301
+ * Scrolls the app viewport to the top of the browser window.
302
+ * @param behavior Specifies whether the scrolling should animate smoothly (smooth),
303
+ * happen instantly in a single jump (instant), or let the browser
304
+ * choose (auto, default).
305
+ */
306
+ gotoTop(behavior = 'smooth') {
307
+ const options = {
308
+ top: 0,
309
+ behavior: behavior
310
+ };
311
+ this.scroll(options);
312
+ }
313
+ /**
314
+ * Scrolls the app viewport according to the specified options, into the browser window.
315
+ * @param options A dictionary containing the scroll parameters.
316
+ */
317
+ scroll(options) {
318
+ window.scroll(options);
319
+ }
320
+ /**
321
+ * Scrolls the app viewport to the specified x/y coordinates, into the browser window.
322
+ * @param x the horizontal pixel value that you want to scroll by.
323
+ * @param y the vertical pixel value that you want to scroll by.
324
+ */
325
+ scrollTo(x, y) {
326
+ window.scrollBy(x, y);
327
+ }
328
+ }
329
+ ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
330
+ ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, providedIn: 'root' });
331
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, decorators: [{
332
+ type: Injectable,
333
+ args: [{
334
+ providedIn: 'root'
335
+ }]
336
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
337
+ type: Inject,
338
+ args: [DOCUMENT]
339
+ }] }]; } });
340
+
265
341
  /*
266
342
  * Public API Surface of angular-toolbox
267
343
  */
@@ -270,5 +346,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
270
346
  * Generated bundle index. Do not edit.
271
347
  */
272
348
 
273
- export { AngularToolboxModule, DARK_MODE_CONFIG, DarkModeService, SafeHtmlPipe, SubscriptionService };
349
+ export { AngularToolboxModule, DARK_MODE_CONFIG, DarkModeService, SafeHtmlPipe, ScrollService, SubscriptionService };
274
350
  //# sourceMappingURL=angular-toolbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-toolbox.mjs","sources":["../../../projects/angular-toolbox/src/lib/pipe/safe/safe-html.pipe.ts","../../../projects/angular-toolbox/src/lib/service/ui/dark-mode.service.ts","../../../projects/angular-toolbox/src/lib/angular-toolbox.module.ts","../../../projects/angular-toolbox/src/lib/service/subscription/subscription.service.ts","../../../projects/angular-toolbox/src/public-api.ts","../../../projects/angular-toolbox/src/angular-toolbox.ts"],"sourcesContent":["import { DomSanitizer, SafeHtml } from '@angular/platform-browser'\r\nimport { PipeTransform, Pipe } from \"@angular/core\";\r\n\r\n@Pipe({ name: 'safeHtml'})\r\nexport class SafeHtmlPipe implements PipeTransform {\r\n\r\n constructor(private _sanitizer: DomSanitizer) {}\r\n\r\n public transform(value: string): SafeHtml {\r\n return this._sanitizer.bypassSecurityTrustHtml(value);\r\n }\r\n}","import { Inject, Injectable, EventEmitter } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n// --> Internal constants\nconst STORAGE_KEY: string = \"dark-mode-key\";\nconst CSS_PROP: string = \"dark-mode\";\nconst ADD_ACTION: string = \"add\";\nconst REMOVE_ACTION: string = \"remove\";\n\n/**\n * Defines properties for the DarkModeService configuration.\n */\nexport interface DarkModeConfig {\n\n /**\n * Indicates whether the dark mode is activated by default (true), or not (false).\n */\n darkModeEnabled?: boolean;\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * When true, this property overrides the darkModeEnabled property.\n */\n detectBrowserSettings?: boolean;\n\n /**\n * CSS property name used to set the dark mode look and feel.\n */\n cssProperty?: string;\n\n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n */\n storageKey?: string;\n}\n\n/**\n * The default provider for the DarkModeService configuration. You typically define\n * the custom properties in the main NgModule declaration to initialize the app dark mode:\n * \n * @NgModule({\n * ...\n * providers: [\n * { provide: DARK_MODE_CONFIG, useValue: { enableDarkMode: true} }\n * ],\n * ...\n * s);\n */\nexport const DARK_MODE_CONFIG: DarkModeConfig = {\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n darkModeEnabled: false,\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n detectBrowserSettings: false,\n \n /**\n * CSS property name used to set the dark mode look and feel.\n * Default value is 'dark-mode'.\n */\n cssProperty: CSS_PROP,\n \n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n * Default value is 'dark-mode-key'.\n */\n storageKey: STORAGE_KEY\n};\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides Dark Mode implementation for your Angular application.\n */\nexport class DarkModeService {\n\n // --> Private properties\n private _darkModeEnabled: boolean = false;\n private _cssProperty: string = CSS_PROP;\n private _storageKey: string = STORAGE_KEY;\n\n /**\n * The callback function that is triggered when the dark mode changes.\n * @typeParam EventEmitter<boolean> the value returned by the darkModeEnabled() property.\n */\n public readonly change: EventEmitter<boolean> = new EventEmitter<boolean>(true);\n\n /**\n * Creates a new DarkModeService instance.\n * @param _document the reference to the Document singleton.\n * @param config the reference to the DarkModeConfig provider.\n */\n constructor(@Inject(DOCUMENT) private _document: Document, @Inject(DARK_MODE_CONFIG) config: DarkModeConfig) {\n this.initDarkMode(config);\n }\n\n /**\n * Toogles the dark mode state.\n */\n public toggleDarkMode(): void {\n this._darkModeEnabled ? this.disableDarkMode() : this.enableDarkMode();\n }\n\n /**\n * Sets the dark mode state to active.\n */\n public enableDarkMode(): void {\n this.setDarkMode(ADD_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Sets the dark mode state to inactive.\n */\n public disableDarkMode(): void {\n this.setDarkMode(REMOVE_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Returns a boolean value that indicates the dark mode state is active (true), or not (false).\n * @returns true whether the dark mode state is active; false otherwise.\n */\n public darkModeEnabled(): boolean {\n return this._darkModeEnabled;\n }\n\n /**\n * Returns the value of the CSS property as defined by the config provider.\n * @returns the value of the CSS property.\n */\n public getCssProperty(): string {\n return this._cssProperty;\n }\n\n /**\n * Returns the value of the storage key as defined by the config provider.\n * @returns the value of the storage key.\n */\n public getStorageKey(): string {\n return this._storageKey;\n }\n \n /**\n * Removes the dark mode information from local storage.\n */\n public invalidateStorage(): void {\n localStorage.removeItem(this._storageKey);\n }\n\n // --> Private methods\n private initDarkMode(config: DarkModeConfig): void {\n this._darkModeEnabled = config.darkModeEnabled || false;\n this._cssProperty = config.cssProperty || CSS_PROP;\n this._storageKey = config.storageKey || STORAGE_KEY;\n if (this._darkModeEnabled) {\n this.enableDarkMode();\n } else {\n this.initStoredDarkMode();\n }\n if (config.detectBrowserSettings) this.initBrowserMode();\n }\n \n private initStoredDarkMode(): void {\n const result: string | null = localStorage.getItem(this._storageKey);\n if (result === \"true\") this.enableDarkMode();\n }\n\n private setStoredDarkMode(): void {\n const data: string = String(this._darkModeEnabled);\n localStorage.setItem(this._storageKey, data);\n }\n\n private setDarkMode(action: string): void {\n const classList: DOMTokenList = this._document.body.classList;\n if (action === ADD_ACTION) {\n classList.add(this._cssProperty);\n this._darkModeEnabled = true;\n } else if (action === REMOVE_ACTION) {\n classList.remove(this._cssProperty);\n this._darkModeEnabled = false;\n }\n this.change.emit(this._darkModeEnabled);\n }\n\n private initBrowserMode(): void {\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n this.enableDarkMode();\n }\n }\n}\n\n","import { NgModule } from '@angular/core';\r\nimport { SafeHtmlPipe } from './pipe/safe/safe-html.pipe';\r\nimport { DARK_MODE_CONFIG } from './service/ui/dark-mode.service';\r\n\r\n@NgModule({\r\n declarations: [\r\n SafeHtmlPipe\r\n ],\r\n providers: [\r\n { provide: DARK_MODE_CONFIG, useValue: DARK_MODE_CONFIG }\r\n ],\r\n exports: [\r\n SafeHtmlPipe\r\n ]\r\n})\r\nexport class AngularToolboxModule { }","import { Injectable } from '@angular/core';\nimport { Subscription } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that helps to manage unregistration issues of Angular subscriptions.\n */\nexport class SubscriptionService {\n\n /**\n * The internal Subscription instances storage.\n */\n private _subMap: Map<String, Array<Subscription>> = new Map<String, Array<Subscription>>();\n\n /**\n * Stores a new Subscription instance associated with the specified reference.\n * \n * @param ref the reference for which to store a new Subscription instance.\n * @param subscription the Subscription instance to register.\n * @returns a reference to this SubscriptionService instance.\n */\n public register(ref: String, subscription: Subscription): SubscriptionService {\n if (!this._subMap.has(ref)) this._subMap.set(ref, []);\n this._subMap.get(ref)?.push(subscription);\n return this;\n }\n \n /**\n * Unsubscribes and removes all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove all Subscription instances.\n * @returns true whether the specified reference exists; false otherwise.\n */\n public clearAll(ref: String): boolean {\n let result: boolean = false;\n if (this._subMap.has(ref)) {\n this._subMap.get(ref)?.forEach(subscription => subscription.unsubscribe());\n this._subMap.delete(ref);\n result = true;\n }\n return result;\n }\n\n /**\n * Returns all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove get Subscription instances.\n * @returns all Subscription instances associated with the specified reference, or whether\n * the specified reference does not exists.\n */\n public get(ref: String): Array<Subscription> | null {\n return this._subMap.get(ref) || null;\n }\n}\n","/*\n * Public API Surface of angular-toolbox\n */\n\nexport * from './lib/angular-toolbox.module';\nexport * from './lib/pipe';\nexport * from './lib/service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAIa,YAAY,CAAA;AAEvB,IAAA,WAAA,CAAoB,UAAwB,EAAA;QAAxB,IAAU,CAAA,UAAA,GAAV,UAAU,CAAc;KAAI;AAEzC,IAAA,SAAS,CAAC,KAAa,EAAA;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;KACvD;;yGANU,YAAY,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;uGAAZ,YAAY,EAAA,IAAA,EAAA,UAAA,EAAA,CAAA,CAAA;2FAAZ,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,IAAI;mBAAC,EAAE,IAAI,EAAE,UAAU,EAAC,CAAA;;;ACAzB;AACA,MAAM,WAAW,GAAW,eAAe,CAAC;AAC5C,MAAM,QAAQ,GAAW,WAAW,CAAC;AACrC,MAAM,UAAU,GAAW,KAAK,CAAC;AACjC,MAAM,aAAa,GAAW,QAAQ,CAAC;AA6BvC;;;;;;;;;;;AAWG;AACU,MAAA,gBAAgB,GAAmB;AAE5C;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AAC,YAAY,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,YAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,MAAM,GAAG,IAAI,CAAC;AACjB,SAAA;AACD,QAAA,OAAO,MAAM,CAAC;KACjB;AAED;;;;;;AAMG;AACI,IAAA,GAAG,CAAC,GAAW,EAAA;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;KACxC;;gHA7CQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAnB,mBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cALhB,MAAM,EAAA,CAAA,CAAA;2FAKT,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAN/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;AACrB,iBAAA,CAAA;;;ACLD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"angular-toolbox.mjs","sources":["../../../projects/angular-toolbox/src/lib/pipe/safe/safe-html.pipe.ts","../../../projects/angular-toolbox/src/lib/service/ui/dark-mode.service.ts","../../../projects/angular-toolbox/src/lib/angular-toolbox.module.ts","../../../projects/angular-toolbox/src/lib/service/subscription/subscription.service.ts","../../../projects/angular-toolbox/src/lib/service/ui/scroll.service.ts","../../../projects/angular-toolbox/src/public-api.ts","../../../projects/angular-toolbox/src/angular-toolbox.ts"],"sourcesContent":["import { DomSanitizer, SafeHtml } from '@angular/platform-browser'\r\nimport { PipeTransform, Pipe } from \"@angular/core\";\r\n\r\n@Pipe({ name: 'safeHtml'})\r\nexport class SafeHtmlPipe implements PipeTransform {\r\n\r\n constructor(private _sanitizer: DomSanitizer) {}\r\n\r\n public transform(value: string): SafeHtml {\r\n return this._sanitizer.bypassSecurityTrustHtml(value);\r\n }\r\n}","import { Inject, Injectable, EventEmitter } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n// --> Internal constants\nconst STORAGE_KEY: string = \"dark-mode-key\";\nconst CSS_PROP: string = \"dark-mode\";\nconst ADD_ACTION: string = \"add\";\nconst REMOVE_ACTION: string = \"remove\";\n\n/**\n * Defines properties for the DarkModeService configuration.\n */\nexport interface DarkModeConfig {\n\n /**\n * Indicates whether the dark mode is activated by default (true), or not (false).\n */\n darkModeEnabled?: boolean;\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * When true, this property overrides the darkModeEnabled property.\n */\n detectBrowserSettings?: boolean;\n\n /**\n * CSS property name used to set the dark mode look and feel.\n */\n cssProperty?: string;\n\n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n */\n storageKey?: string;\n}\n\n/**\n * The default provider for the DarkModeService configuration. You typically define\n * the custom properties in the main NgModule declaration to initialize the app dark mode:\n * \n * @NgModule({\n * ...\n * providers: [\n * { provide: DARK_MODE_CONFIG, useValue: { enableDarkMode: true} }\n * ],\n * ...\n * s);\n */\nexport const DARK_MODE_CONFIG: DarkModeConfig = {\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n darkModeEnabled: false,\n \n /**\n * Indicates whether the dark mode uses browser settings (true), or not (false).\n * Default value is false.\n */\n detectBrowserSettings: false,\n \n /**\n * CSS property name used to set the dark mode look and feel.\n * Default value is 'dark-mode'.\n */\n cssProperty: CSS_PROP,\n \n /**\n * Reference to the key value used to persist the dark mode state to local storage.\n * Default value is 'dark-mode-key'.\n */\n storageKey: STORAGE_KEY\n};\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides Dark Mode implementation for your Angular application.\n */\nexport class DarkModeService {\n\n // --> Private properties\n private _darkModeEnabled: boolean = false;\n private _cssProperty: string = CSS_PROP;\n private _storageKey: string = STORAGE_KEY;\n\n /**\n * The callback function that is triggered when the dark mode changes.\n * @typeParam EventEmitter<boolean> the value returned by the darkModeEnabled() property.\n */\n public readonly change: EventEmitter<boolean> = new EventEmitter<boolean>(true);\n\n /**\n * Creates a new DarkModeService instance.\n * @param _document the reference to the Document singleton.\n * @param config the reference to the DarkModeConfig provider.\n */\n constructor(@Inject(DOCUMENT) private _document: Document, @Inject(DARK_MODE_CONFIG) config: DarkModeConfig) {\n this.initDarkMode(config);\n }\n\n /**\n * Toogles the dark mode state.\n */\n public toggleDarkMode(): void {\n this._darkModeEnabled ? this.disableDarkMode() : this.enableDarkMode();\n }\n\n /**\n * Sets the dark mode state to active.\n */\n public enableDarkMode(): void {\n this.setDarkMode(ADD_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Sets the dark mode state to inactive.\n */\n public disableDarkMode(): void {\n this.setDarkMode(REMOVE_ACTION);\n this.setStoredDarkMode();\n }\n\n /**\n * Returns a boolean value that indicates the dark mode state is active (true), or not (false).\n * @returns true whether the dark mode state is active; false otherwise.\n */\n public darkModeEnabled(): boolean {\n return this._darkModeEnabled;\n }\n\n /**\n * Returns the value of the CSS property as defined by the config provider.\n * @returns the value of the CSS property.\n */\n public getCssProperty(): string {\n return this._cssProperty;\n }\n\n /**\n * Returns the value of the storage key as defined by the config provider.\n * @returns the value of the storage key.\n */\n public getStorageKey(): string {\n return this._storageKey;\n }\n \n /**\n * Removes the dark mode information from local storage.\n */\n public invalidateStorage(): void {\n localStorage.removeItem(this._storageKey);\n }\n\n // --> Private methods\n private initDarkMode(config: DarkModeConfig): void {\n this._darkModeEnabled = config.darkModeEnabled || false;\n this._cssProperty = config.cssProperty || CSS_PROP;\n this._storageKey = config.storageKey || STORAGE_KEY;\n if (this._darkModeEnabled) {\n this.enableDarkMode();\n } else {\n this.initStoredDarkMode();\n }\n if (config.detectBrowserSettings) this.initBrowserMode();\n }\n \n private initStoredDarkMode(): void {\n const result: string | null = localStorage.getItem(this._storageKey);\n if (result === \"true\") this.enableDarkMode();\n }\n\n private setStoredDarkMode(): void {\n const data: string = String(this._darkModeEnabled);\n localStorage.setItem(this._storageKey, data);\n }\n\n private setDarkMode(action: string): void {\n const classList: DOMTokenList = this._document.body.classList;\n if (action === ADD_ACTION) {\n classList.add(this._cssProperty);\n this._darkModeEnabled = true;\n } else if (action === REMOVE_ACTION) {\n classList.remove(this._cssProperty);\n this._darkModeEnabled = false;\n }\n this.change.emit(this._darkModeEnabled);\n }\n\n private initBrowserMode(): void {\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n this.enableDarkMode();\n }\n }\n}\n\n","import { NgModule } from '@angular/core';\r\nimport { SafeHtmlPipe } from './pipe/safe/safe-html.pipe';\r\nimport { DARK_MODE_CONFIG } from './service/ui/dark-mode.service';\r\n\r\n@NgModule({\r\n declarations: [\r\n SafeHtmlPipe\r\n ],\r\n providers: [\r\n { provide: DARK_MODE_CONFIG, useValue: DARK_MODE_CONFIG }\r\n ],\r\n exports: [\r\n SafeHtmlPipe\r\n ]\r\n})\r\nexport class AngularToolboxModule { }","import { Injectable } from '@angular/core';\nimport { Subscription } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that helps to manage unregistration issues of Angular subscriptions.\n */\nexport class SubscriptionService {\n\n /**\n * The internal Subscription instances storage.\n */\n private _subMap: Map<String, Array<Subscription>> = new Map<String, Array<Subscription>>();\n\n /**\n * Stores a new Subscription instance associated with the specified reference.\n * \n * @param ref the reference for which to store a new Subscription instance.\n * @param subscription the Subscription instance to register.\n * @returns a reference to this SubscriptionService instance.\n */\n public register(ref: String, subscription: Subscription): SubscriptionService {\n if (!this._subMap.has(ref)) this._subMap.set(ref, []);\n this._subMap.get(ref)?.push(subscription);\n return this;\n }\n \n /**\n * Unsubscribes and removes all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove all Subscription instances.\n * @returns true whether the specified reference exists; false otherwise.\n */\n public clearAll(ref: String): boolean {\n let result: boolean = false;\n if (this._subMap.has(ref)) {\n this._subMap.get(ref)?.forEach(subscription => subscription.unsubscribe());\n this._subMap.delete(ref);\n result = true;\n }\n return result;\n }\n\n /**\n * Returns all Subscription instances associated with the specified reference.\n * \n * @param ref the reference for which to remove get Subscription instances.\n * @returns all Subscription instances associated with the specified reference, or whether\n * the specified reference does not exists.\n */\n public get(ref: String): Array<Subscription> | null {\n return this._subMap.get(ref) || null;\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { EventEmitter, Inject, Injectable } from '@angular/core';\n\n/**\n * Workaround for the typescript ScrollBehavior declaration.\n */\ndeclare type ScrollBehavior = \"auto\" | \"instant\" | \"smooth\";\n\n@Injectable({\n providedIn: 'root'\n})\n/**\n * A lightweight service that provides scrolling capabilities to your Angular application.\n */\nexport class ScrollService {\n\n /**\n * The callback function that is triggered when a scroll operation is performed.\n * @typeParam EventEmitter<Event> the reference to the original scroll event.\n */\n public readonly onScroll: EventEmitter<Event> = new EventEmitter<Event>();\n\n /**\n * Creates a new ScrollService instance.\n * @param _document the reference to the Document singleton.\n */\n constructor(@Inject(DOCUMENT) private _document: Document) {\n window.addEventListener(\"scroll\", (e: Event) => {\n this.onScroll.next(e);\n });\n }\n\n /**\n * Scrolls the ancestor containers of the element with the specified selector such that \n * this element is visible to the user.\n * @param selector the selector of the target element.\n * @param arg a boolean value:\n * If true, the top of the element will be aligned to the top of the visible area of the\n * scrollable ancestor.\n * If false, the bottom of the element will be aligned to the bottom of the visible area\n * of the scrollable ancestor. \n * @param arg a dictionary containing the scroll parameters.\n */\n public scrollIntoView(selector: string, arg?: boolean | ScrollIntoViewOptions | undefined): void {\n const elm: Element | null = this._document.querySelector(selector);\n if (elm) elm.scrollIntoView(arg);\n }\n\n /**\n * Scrolls the app viewport to the top of the browser window.\n * @param behavior Specifies whether the scrolling should animate smoothly (smooth),\n * happen instantly in a single jump (instant), or let the browser\n * choose (auto, default).\n */\n public gotoTop(behavior: ScrollBehavior = 'smooth'): void {\n const options: ScrollToOptions = {\n top: 0,\n behavior: behavior as any\n };\n this.scroll(options);\n }\n\n /**\n * Scrolls the app viewport according to the specified options, into the browser window.\n * @param options A dictionary containing the scroll parameters.\n */\n public scroll(options?: ScrollToOptions): void {\n window.scroll(options);\n }\n \n /**\n * Scrolls the app viewport to the specified x/y coordinates, into the browser window.\n * @param x the horizontal pixel value that you want to scroll by.\n * @param y the vertical pixel value that you want to scroll by.\n */\n public scrollTo(x: number, y: number): void {\n window.scrollBy(x, y);\n }\n}\n","/*\n * Public API Surface of angular-toolbox\n */\n\nexport * from './lib/angular-toolbox.module';\nexport * from './lib/pipe';\nexport * from './lib/service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAIa,YAAY,CAAA;AAEvB,IAAA,WAAA,CAAoB,UAAwB,EAAA;QAAxB,IAAU,CAAA,UAAA,GAAV,UAAU,CAAc;KAAI;AAEzC,IAAA,SAAS,CAAC,KAAa,EAAA;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;KACvD;;yGANU,YAAY,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;uGAAZ,YAAY,EAAA,IAAA,EAAA,UAAA,EAAA,CAAA,CAAA;2FAAZ,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,IAAI;mBAAC,EAAE,IAAI,EAAE,UAAU,EAAC,CAAA;;;ACAzB;AACA,MAAM,WAAW,GAAW,eAAe,CAAC;AAC5C,MAAM,QAAQ,GAAW,WAAW,CAAC;AACrC,MAAM,UAAU,GAAW,KAAK,CAAC;AACjC,MAAM,aAAa,GAAW,QAAQ,CAAC;AA6BvC;;;;;;;;;;;AAWG;AACU,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;ACFH;;AAEG;;;;"}
@@ -1,2 +1,3 @@
1
1
  export * from './subscription/subscription.service';
2
2
  export * from './ui/dark-mode.service';
3
+ export * from './ui/scroll.service';
@@ -0,0 +1,52 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Workaround for the typescript ScrollBehavior declaration.
5
+ */
6
+ declare type ScrollBehavior = "auto" | "instant" | "smooth";
7
+ export declare class ScrollService {
8
+ private _document;
9
+ /**
10
+ * The callback function that is triggered when a scroll operation is performed.
11
+ * @typeParam EventEmitter<Event> the reference to the original scroll event.
12
+ */
13
+ readonly onScroll: EventEmitter<Event>;
14
+ /**
15
+ * Creates a new ScrollService instance.
16
+ * @param _document the reference to the Document singleton.
17
+ */
18
+ constructor(_document: Document);
19
+ /**
20
+ * Scrolls the ancestor containers of the element with the specified selector such that
21
+ * this element is visible to the user.
22
+ * @param selector the selector of the target element.
23
+ * @param arg a boolean value:
24
+ * If true, the top of the element will be aligned to the top of the visible area of the
25
+ * scrollable ancestor.
26
+ * If false, the bottom of the element will be aligned to the bottom of the visible area
27
+ * of the scrollable ancestor.
28
+ * @param arg a dictionary containing the scroll parameters.
29
+ */
30
+ scrollIntoView(selector: string, arg?: boolean | ScrollIntoViewOptions | undefined): void;
31
+ /**
32
+ * Scrolls the app viewport to the top of the browser window.
33
+ * @param behavior Specifies whether the scrolling should animate smoothly (smooth),
34
+ * happen instantly in a single jump (instant), or let the browser
35
+ * choose (auto, default).
36
+ */
37
+ gotoTop(behavior?: ScrollBehavior): void;
38
+ /**
39
+ * Scrolls the app viewport according to the specified options, into the browser window.
40
+ * @param options A dictionary containing the scroll parameters.
41
+ */
42
+ scroll(options?: ScrollToOptions): void;
43
+ /**
44
+ * Scrolls the app viewport to the specified x/y coordinates, into the browser window.
45
+ * @param x the horizontal pixel value that you want to scroll by.
46
+ * @param y the vertical pixel value that you want to scroll by.
47
+ */
48
+ scrollTo(x: number, y: number): void;
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScrollService, never>;
50
+ static ɵprov: i0.ɵɵInjectableDeclaration<ScrollService>;
51
+ }
52
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-toolbox",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^15.1.0",
6
6
  "@angular/core": "^15.1.0"