@ardium-pl/devkit 8.3.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 +25 -0
- package/fesm2022/ardium-pl-devkit.mjs +3874 -0
- package/fesm2022/ardium-pl-devkit.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/click-outside/click-outside.directive.d.ts +14 -0
- package/lib/click-outside/click-outside.module.d.ts +8 -0
- package/lib/click-outside/index.d.ts +2 -0
- package/lib/coercion/array.d.ts +21 -0
- package/lib/coercion/boolean.d.ts +6 -0
- package/lib/coercion/date.d.ts +5 -0
- package/lib/coercion/index.d.ts +4 -0
- package/lib/coercion/number.d.ts +20 -0
- package/lib/dom-boxes/dom-boxes.d.ts +7 -0
- package/lib/dom-boxes/index.d.ts +1 -0
- package/lib/escape-html/escape-html.d.ts +1 -0
- package/lib/escape-html/escape-html.module.d.ts +8 -0
- package/lib/escape-html/escape-html.pipe.d.ts +7 -0
- package/lib/escape-html/index.d.ts +3 -0
- package/lib/file-pipes/file-pipes.defaults.d.ts +8 -0
- package/lib/file-pipes/file-pipes.module.d.ts +10 -0
- package/lib/file-pipes/fileext.pipe.d.ts +39 -0
- package/lib/file-pipes/filename.pipe.d.ts +38 -0
- package/lib/file-pipes/filesize.pipe.d.ts +50 -0
- package/lib/file-pipes/index.d.ts +5 -0
- package/lib/file-system/file-system.service.d.ts +69 -0
- package/lib/file-system/file-system.types.d.ts +186 -0
- package/lib/file-system/index.d.ts +2 -0
- package/lib/find-functions/find-suggestion.d.ts +3 -0
- package/lib/find-functions/index.d.ts +1 -0
- package/lib/forms/index.d.ts +1 -0
- package/lib/forms/track-form-control/index.d.ts +1 -0
- package/lib/forms/track-form-control/track-form-control.d.ts +83 -0
- package/lib/hold/hold.defaults.d.ts +9 -0
- package/lib/hold/hold.directive.d.ts +24 -0
- package/lib/hold/hold.module.d.ts +8 -0
- package/lib/hold/index.d.ts +3 -0
- package/lib/http-service/_types.d.ts +20 -0
- package/lib/http-service/_utils.d.ts +1 -0
- package/lib/http-service/http.service.d.ts +2574 -0
- package/lib/http-service/index.d.ts +1 -0
- package/lib/infinite-scroll/index.d.ts +3 -0
- package/lib/infinite-scroll/infinite-scroll.defaults.d.ts +8 -0
- package/lib/infinite-scroll/infinite-scroll.directive.d.ts +24 -0
- package/lib/infinite-scroll/infinite-scroll.module.d.ts +8 -0
- package/lib/keyboard/index.d.ts +2 -0
- package/lib/keyboard/keyboard.service.d.ts +60 -0
- package/lib/keyboard/keyboard.types.d.ts +13 -0
- package/lib/keyboard/types-internal.d.ts +20 -0
- package/lib/keyboard/utils.d.ts +3 -0
- package/lib/relative-pos/index.d.ts +1 -0
- package/lib/relative-pos/relative-pos.d.ts +24 -0
- package/lib/signals/array/array-signal.d.ts +123 -0
- package/lib/signals/array/index.d.ts +1 -0
- package/lib/signals/counter/counter-signal.d.ts +67 -0
- package/lib/signals/counter/index.d.ts +1 -0
- package/lib/signals/debounced/debounced-signal.d.ts +15 -0
- package/lib/signals/debounced/index.d.ts +1 -0
- package/lib/signals/map/index.d.ts +1 -0
- package/lib/signals/map/map-signal.d.ts +97 -0
- package/lib/signals/persistent/index.d.ts +1 -0
- package/lib/signals/persistent/persistent-signal.d.ts +106 -0
- package/lib/signals/query-param/index.d.ts +1 -0
- package/lib/signals/query-param/query-param-signal.d.ts +35 -0
- package/lib/signals/queue/index.d.ts +1 -0
- package/lib/signals/queue/queue-signal.d.ts +77 -0
- package/lib/signals/set/index.d.ts +1 -0
- package/lib/signals/set/set-signal.d.ts +76 -0
- package/lib/signals/stack/index.d.ts +1 -0
- package/lib/signals/stack/stack-signal.d.ts +77 -0
- package/lib/signals/throttled/index.d.ts +1 -0
- package/lib/signals/throttled/throttled-signal.d.ts +15 -0
- package/lib/signals/tuple/index.d.ts +1 -0
- package/lib/signals/tuple/tuple-signal.d.ts +60 -0
- package/lib/validators/index.d.ts +1 -0
- package/lib/validators/validators.d.ts +612 -0
- package/lib/viewport-observer/index.d.ts +3 -0
- package/lib/viewport-observer/utils.d.ts +15 -0
- package/lib/viewport-observer/viewport-observer-ref.d.ts +47 -0
- package/lib/viewport-observer/viewport-observer.defaults.d.ts +7 -0
- package/lib/viewport-observer/viewport-observer.service.d.ts +23 -0
- package/package.json +30 -0
- package/public-api.d.ts +26 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
Detects when the user clicks outside a given element.
|
|
4
|
+
|
|
5
|
+
@license
|
|
6
|
+
Shamelessly stolen from [Christian Liebel](https://github.com/chliebel/angular2-click-outside)
|
|
7
|
+
*/
|
|
8
|
+
export declare class ArdiumClickOutsideDirective {
|
|
9
|
+
private readonly _elementRef;
|
|
10
|
+
readonly ardClickOutside: import("@angular/core").OutputEmitterRef<MouseEvent>;
|
|
11
|
+
onClick(event: MouseEvent, target: HTMLElement): void;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumClickOutsideDirective, never>;
|
|
13
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ArdiumClickOutsideDirective, "[ardClickOutside]", never, {}, { "ardClickOutside": "ardClickOutside"; }, never, never, false, never>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./click-outside.directive";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class ArdiumClickOutsideModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumClickOutsideModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ArdiumClickOutsideModule, [typeof i1.ArdiumClickOutsideDirective], [typeof i2.CommonModule], [typeof i1.ArdiumClickOutsideDirective]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ArdiumClickOutsideModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type describing the allowed values for a number input
|
|
3
|
+
*/
|
|
4
|
+
export type ArrayLike = string | any[] | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Coerces a value to an array of trimmed non-empty strings.
|
|
7
|
+
* Any input that is not an array, `null` or `undefined` will be turned into a string
|
|
8
|
+
* using `String()` and split into an array with the given separator.
|
|
9
|
+
* `null`, `undefined`, and `""` will result in an empty array.
|
|
10
|
+
* This results in the following outcomes:
|
|
11
|
+
* - `null` -> `[]`
|
|
12
|
+
* - `[null]` -> `["null"]`
|
|
13
|
+
* - `["a", "b ", " "]` -> `["a", "b"]`
|
|
14
|
+
* - `[1, [2, 3]]` -> `["1", "2,3"]`
|
|
15
|
+
* - `"a,b , c"` -> `["a", "b", "c"]`
|
|
16
|
+
*
|
|
17
|
+
* Useful for defining CSS classes or table columns.
|
|
18
|
+
* @param value the value to coerce into an array of strings
|
|
19
|
+
* @param separator split-separator if value isn't an array. Defaults to the string `","`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function coerceArrayProperty(value: any, separator?: string | RegExp): string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type describing the allowed values for a boolean input.
|
|
3
|
+
*/
|
|
4
|
+
export type BooleanLike = string | boolean | null | undefined;
|
|
5
|
+
/** Coerces a data-bound value (typically a string) to a boolean. */
|
|
6
|
+
export declare function coerceBooleanProperty(value: any): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getUTCDate(): Date;
|
|
2
|
+
export declare function getUTCDate(year: number, monthIndex: number, day: number): Date;
|
|
3
|
+
export declare function getUTCDate(year: number, monthIndex: number, day: number, hour: number, minute: number, second: number, millisecond: number): Date;
|
|
4
|
+
export declare function coerceDateProperty<T>(v: any, fallback: T): Date | T;
|
|
5
|
+
export declare function coerceDateOnlyProperty<T>(v: any, fallback: T, asUTC?: boolean): Date | T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type describing the allowed values for a number input
|
|
3
|
+
*/
|
|
4
|
+
export type NumberLike = string | number | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
Coerces a data-bound value (typically a string) to a number.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Coerces a data-bound value (typically a string) to a number.
|
|
10
|
+
* @param value the value to be coerced.
|
|
11
|
+
* @returns the value coerced into a number, or undefined if cannot coerce.
|
|
12
|
+
*/
|
|
13
|
+
export declare function coerceNumberProperty(value: any): number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Coerces a data-bound value (typically a string) to a number.
|
|
16
|
+
* @param value the value to be coerced.
|
|
17
|
+
* @param fallback a value to be used if `value` cannot be coerced into a number.
|
|
18
|
+
* @returns the value coerced into a number, or `fallback` if cannot coerce.
|
|
19
|
+
*/
|
|
20
|
+
export declare function coerceNumberProperty<D>(value: any, fallback: D): number | D;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
export declare function getDomContentRect(el: HTMLElement): DOMRect;
|
|
3
|
+
export declare function getDomContentRect(el: ElementRef<HTMLElement>): DOMRect;
|
|
4
|
+
export declare function getDomContentRect(el: HTMLElement | ElementRef<HTMLElement>): DOMRect;
|
|
5
|
+
export declare function getDomPaddingRect(el: HTMLElement): DOMRect;
|
|
6
|
+
export declare function getDomPaddingRect(el: ElementRef<HTMLElement>): DOMRect;
|
|
7
|
+
export declare function getDomPaddingRect(el: HTMLElement | ElementRef<HTMLElement>): DOMRect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dom-boxes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeHTML(value: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./escape-html.pipe";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class ArdiumEscapeHTMLModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumEscapeHTMLModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ArdiumEscapeHTMLModule, [typeof i1.ArdiumEscapeHTMLPipe], [typeof i2.CommonModule], [typeof i1.ArdiumEscapeHTMLPipe]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ArdiumEscapeHTMLModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ArdiumEscapeHTMLPipe implements PipeTransform {
|
|
4
|
+
transform(value: string): string;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumEscapeHTMLPipe, never>;
|
|
6
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ArdiumEscapeHTMLPipe, "escapeHTML", false>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
export interface ArdFilePipesDefaults {
|
|
3
|
+
extensionWithDot: boolean;
|
|
4
|
+
sizePrecision: number;
|
|
5
|
+
sizeUseSpace: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const ARD_FILE_PIPES_DEFAULTS: InjectionToken<ArdFilePipesDefaults>;
|
|
8
|
+
export declare function provideFilePipesDefaults(config: Partial<ArdFilePipesDefaults>): Provider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./fileext.pipe";
|
|
3
|
+
import * as i2 from "./filename.pipe";
|
|
4
|
+
import * as i3 from "./filesize.pipe";
|
|
5
|
+
import * as i4 from "@angular/common";
|
|
6
|
+
export declare class ArdiumFilePipesModule {
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumFilePipesModule, never>;
|
|
8
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ArdiumFilePipesModule, [typeof i1.ArdiumFileExtensionPipe, typeof i2.ArdiumFileNamePipe, typeof i3.ArdiumFileSizePipe], [typeof i4.CommonModule], [typeof i1.ArdiumFileExtensionPipe, typeof i2.ArdiumFileNamePipe, typeof i3.ArdiumFileSizePipe]>;
|
|
9
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ArdiumFilePipesModule>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Formats a file extension from a string or File object.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | File | null | undefined} value - The file name or File object whose extension is to be extracted.
|
|
7
|
+
* @param {boolean} [withDot=false] - Whether to include a dot ('.') before the file extension.
|
|
8
|
+
* @returns {string | null} - The file extension, or null if no extension is found or if the input is invalid.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* formatFileExtension('image.png'); // -> 'png'
|
|
12
|
+
* formatFileExtension('image.png', true); // -> '.png'
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatFileExtension(value: string | File | null | undefined, withDot?: boolean): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Pipe that transforms a file or file name into its extension.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* {{ 'image.png' | fileext }} // -> 'png'
|
|
20
|
+
* {{ 'image.png' | fileext: true }} // -> '.png'
|
|
21
|
+
*/
|
|
22
|
+
export declare class ArdiumFileExtensionPipe implements PipeTransform {
|
|
23
|
+
protected readonly _DEFAULTS: import("@ardium-pl/devkit").ArdFilePipesDefaults;
|
|
24
|
+
/**
|
|
25
|
+
* Transforms the given value to its file extension.
|
|
26
|
+
*
|
|
27
|
+
* @param {string | File | null | undefined} value - The file name or File object to extract the extension from.
|
|
28
|
+
* @param {boolean} withDot - Whether to include a dot before the extension (defaults to config value).
|
|
29
|
+
* @returns {string | null} - The file extension or null if no extension is found.
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* {{ 'image.png' | fileext }} // -> 'png'
|
|
34
|
+
* {{ 'image.png' | fileext: true }} // -> '.png'
|
|
35
|
+
*/
|
|
36
|
+
transform(value: string | File | null | undefined, withDot?: boolean): string | null;
|
|
37
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumFileExtensionPipe, never>;
|
|
38
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ArdiumFileExtensionPipe, "fileext", false>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PipeTransform } from "@angular/core";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Formats a file name by removing its extension.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | File | null | undefined} value - The file name or File object to extract the name without extension from.
|
|
7
|
+
* @returns {string} - The file name without the extension, or the original input if no extension is found.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* formatFileName('image.png'); // -> 'image'
|
|
11
|
+
* formatFileName('document.pdf'); // -> 'document'
|
|
12
|
+
* formatFileName('my-component.component.ts'); // -> 'my-component.component'
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatFileName(value: string | File | null | undefined): string;
|
|
15
|
+
/**
|
|
16
|
+
* Pipe that transforms a file or file name into its name without the extension.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* {{ 'image.png' | filename }} // -> 'image'
|
|
20
|
+
* {{ 'document.pdf' | filename }} // -> 'document'
|
|
21
|
+
* {{ 'my-component.component.ts' | filename }} // -> 'my-component.component'
|
|
22
|
+
*/
|
|
23
|
+
export declare class ArdiumFileNamePipe implements PipeTransform {
|
|
24
|
+
/**
|
|
25
|
+
* Transforms the given value to its file name without the extension.
|
|
26
|
+
*
|
|
27
|
+
* @param {string | File | null | undefined} value - The file name or File object to extract the name without extension from.
|
|
28
|
+
* @returns {string} - The file name without the extension.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* {{ 'image.png' | filename }} // -> 'image'
|
|
32
|
+
* {{ 'document.pdf' | filename }} // -> 'document'
|
|
33
|
+
* {{ 'my-component.component.ts' | filename }} // -> 'my-component.component'
|
|
34
|
+
*/
|
|
35
|
+
transform(value: string | File | null | undefined): string;
|
|
36
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumFileNamePipe, never>;
|
|
37
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ArdiumFileNamePipe, "filename", false>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Formats a file size into a human-readable string with the appropriate unit.
|
|
5
|
+
*
|
|
6
|
+
* @param {number | File | null | undefined} value - The file size as a number or a File object whose size is to be extracted.
|
|
7
|
+
* @param {number} [precision=2] - The number of decimal places to round to. Default is 2.
|
|
8
|
+
* @param {boolean} [useSpace=true] - Whether to include a space between the number and the unit. Default is true.
|
|
9
|
+
* @returns {string} - The formatted file size with the unit (e.g., '1.5 MB', '10 kB').
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* formatFileSize(1024); // -> '1.00 kB'
|
|
13
|
+
* formatFileSize(1048576); // -> '1.00 MB'
|
|
14
|
+
* formatFileSize(1048576, 3); // -> '1.000 MB'
|
|
15
|
+
* formatFileSize(1048576, 3, false); // -> '1.000MB'
|
|
16
|
+
* formatFileSize(967680, 0); // -> '945 kB'
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatFileSize(value: number | File | null | undefined, precision?: number, useSpace?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Pipe that transforms a file or file size into a human-readable file size string.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* {{ 1024 | filesize }} // -> '1.00 kB'
|
|
24
|
+
* {{ 1048576 | filesize }} // -> '1.00 MB'
|
|
25
|
+
* {{ 1048576 | filesize:3 }} // -> '1.000 MB'
|
|
26
|
+
* {{ 1048576 | filesize:3:false }} // -> '1.000MB'
|
|
27
|
+
* {{ 967680 | filesize:0 }} // -> '945 kB'
|
|
28
|
+
*/
|
|
29
|
+
export declare class ArdiumFileSizePipe implements PipeTransform {
|
|
30
|
+
/** Default configuration for the pipe */
|
|
31
|
+
protected readonly _DEFAULTS: import("@ardium-pl/devkit").ArdFilePipesDefaults;
|
|
32
|
+
/**
|
|
33
|
+
* Transforms the given value to a human-readable file size string.
|
|
34
|
+
*
|
|
35
|
+
* @param {number | File | null | undefined} value - The file size as a number or File object whose size is to be extracted.
|
|
36
|
+
* @param {number} precision - The number of decimal places to round to (defaults to config value).
|
|
37
|
+
* @param {boolean} useSpace - Whether to include a space between the number and the unit (defaults to config value).
|
|
38
|
+
* @returns {string} - The formatted file size string (e.g., '1.5 MB', '10 kB').
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* {{ 1024 | filesize }} // -> '1.00 kB'
|
|
42
|
+
* {{ 1048576 | filesize }} // -> '1.00 MB'
|
|
43
|
+
* {{ 1048576 | filesize:3 }} // -> '1.000 MB'
|
|
44
|
+
* {{ 1048576 | filesize:3:false }} // -> '1.000MB'
|
|
45
|
+
* {{ 967680 | filesize:0 }} // -> '945 kB'
|
|
46
|
+
*/
|
|
47
|
+
transform(value: number | File | null | undefined, precision?: number, useSpace?: boolean): string;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArdiumFileSizePipe, never>;
|
|
49
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ArdiumFileSizePipe, "filesize", false>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FileSystemRequestOptions, FileSystemSaveOptions } from './file-system.types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Service for handling file system operations, including saving, uploading, and reading files.
|
|
5
|
+
*
|
|
6
|
+
* This service leverages the File System Access API when available and falls back to traditional
|
|
7
|
+
* methods when necessary. It provides methods to check for API support, save files, request file uploads,
|
|
8
|
+
* and read file contents.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
11
|
+
*/
|
|
12
|
+
export declare class FileSystemService {
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the File System Access API is supported for the specified method.
|
|
15
|
+
*
|
|
16
|
+
* @param method - The file system method to check ('showSaveFilePicker' or 'showOpenFilePicker').
|
|
17
|
+
* @returns True if the specified method is supported, otherwise false.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
20
|
+
*/
|
|
21
|
+
isFileSystemAPISupported(method: 'showSaveFilePicker' | 'showOpenFilePicker'): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Saves data as a file using the File System Access API or a fallback method.
|
|
24
|
+
*
|
|
25
|
+
* @param data - The data to be saved, either as a string or a Blob.
|
|
26
|
+
* @param options - Options for saving the file, such as file name and save method.
|
|
27
|
+
* @returns A promise that resolves to true if the file was saved successfully, otherwise false.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
30
|
+
*/
|
|
31
|
+
saveAs(data: string | Blob, options?: FileSystemSaveOptions): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Requests a file upload using the File System Access API or a fallback method.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Options for requesting the file upload, such as accepted file types and method.
|
|
36
|
+
* @returns A promise that resolves to the selected file or files, or null if the operation was canceled.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
39
|
+
*/
|
|
40
|
+
requestFileUpload(options?: FileSystemRequestOptions): Promise<File | File[] | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Reads the content of a file as a string with optional encoding.
|
|
43
|
+
*
|
|
44
|
+
* @param file - The file to read.
|
|
45
|
+
* @param readAs - The method to read the file (in this case - "text").
|
|
46
|
+
* @param encoding - The encoding to use when reading the file as text. Defaults to UTF-8.
|
|
47
|
+
* @returns A promise that resolves to the file content as a string or null.
|
|
48
|
+
*/
|
|
49
|
+
readFile(file: File, readAs?: 'text', encoding?: string): Promise<string | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Reads the content of a file as an ArrayBuffer.
|
|
52
|
+
*
|
|
53
|
+
* @param file - The file to read.
|
|
54
|
+
* @param readAs - The method to read the file (in this case - "binary").
|
|
55
|
+
* @returns A promise that resolves to the file content as an ArrayBuffer or null.
|
|
56
|
+
*/
|
|
57
|
+
readFile(file: File, readAs?: 'binary'): Promise<ArrayBuffer | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Reads the content of a file.
|
|
60
|
+
*
|
|
61
|
+
* @param file - The file to read.
|
|
62
|
+
* @param readAs - The method to read the file ("text" or "binary").
|
|
63
|
+
* @param encoding - The encoding to use when reading the file as text (default is 'UTF-8').
|
|
64
|
+
* @returns A promise that resolves to the file content as a string, ArrayBuffer, or null.
|
|
65
|
+
*/
|
|
66
|
+
readFile(file: File, readAs?: 'text' | 'binary', encoding?: string): Promise<string | ArrayBuffer | null>;
|
|
67
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FileSystemService, never>;
|
|
68
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<FileSystemService>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration of file system methods.
|
|
3
|
+
*/
|
|
4
|
+
export declare const FileSystemMethod: {
|
|
5
|
+
/**
|
|
6
|
+
* Prefer using the File System Access API, or if not supported, use a cross-browser compatible method.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
9
|
+
*/
|
|
10
|
+
readonly PreferFileSystem: "preferFileSystem";
|
|
11
|
+
/**
|
|
12
|
+
* Always use a cross-browser compatible method.
|
|
13
|
+
*/
|
|
14
|
+
readonly CrossBrowser: "crossBrowser";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Type representing file system methods.
|
|
18
|
+
*/
|
|
19
|
+
export type FileSystemMethod = (typeof FileSystemMethod)[keyof typeof FileSystemMethod];
|
|
20
|
+
/**
|
|
21
|
+
* Enumeration of file system start directories.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FileSystemStartDirectory: {
|
|
24
|
+
/**
|
|
25
|
+
* Always start in the Desktop directory.
|
|
26
|
+
*/
|
|
27
|
+
readonly Desktop: "desktop";
|
|
28
|
+
/**
|
|
29
|
+
* Always start in the Documents directory.
|
|
30
|
+
*/
|
|
31
|
+
readonly Documents: "documents";
|
|
32
|
+
/**
|
|
33
|
+
* Always start in the Downloads directory.
|
|
34
|
+
*/
|
|
35
|
+
readonly Downloads: "downloads";
|
|
36
|
+
/**
|
|
37
|
+
* Always start in the Music directory.
|
|
38
|
+
*/
|
|
39
|
+
readonly Music: "music";
|
|
40
|
+
/**
|
|
41
|
+
* Always start in the Pictures directory.
|
|
42
|
+
*/
|
|
43
|
+
readonly Pictures: "pictures";
|
|
44
|
+
/**
|
|
45
|
+
* Always start in the Videos directory.
|
|
46
|
+
*/
|
|
47
|
+
readonly Videos: "videos";
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Type representing file system start directories.
|
|
51
|
+
*/
|
|
52
|
+
export type FileSystemStartDirectory = (typeof FileSystemStartDirectory)[keyof typeof FileSystemStartDirectory];
|
|
53
|
+
/**
|
|
54
|
+
* Base type for file system save options.
|
|
55
|
+
*
|
|
56
|
+
* @property {string} [fileName] - The name of the file to be saved.
|
|
57
|
+
*/
|
|
58
|
+
type _FileSystemSaveOptionsBase = {
|
|
59
|
+
fileName?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Type representing file system save options
|
|
63
|
+
*/
|
|
64
|
+
export type FileSystemSaveOptions = _FileSystemSaveOptionsBase & ({
|
|
65
|
+
/**
|
|
66
|
+
* Prefer using the File System Access API, or if not supported, use a cross-browser compatible method.
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
69
|
+
*/
|
|
70
|
+
method: 'preferFileSystem';
|
|
71
|
+
/**
|
|
72
|
+
* By specifying an ID, the browser can remember different directories for different IDs. If the same ID is used for another picker, the picker opens in the same directory.
|
|
73
|
+
*/
|
|
74
|
+
directoryId?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The directory to open the dialog in. Leaving this undefined results in the dialog being opened in the last known directory.
|
|
77
|
+
*/
|
|
78
|
+
startDirectory?: FileSystemStartDirectory;
|
|
79
|
+
/**
|
|
80
|
+
* An array of allowed file types to save. Each item is an object with the following options:
|
|
81
|
+
* - `description?` - An optional desciption of the category of file types allowed. Default to be an empty string.
|
|
82
|
+
* - `accept` - An object with the keys set to the MIME type and the values an array of file extensions (see below for an example).
|
|
83
|
+
* ```ts
|
|
84
|
+
* const opts = {
|
|
85
|
+
* types: [
|
|
86
|
+
* {
|
|
87
|
+
* description: "Text file",
|
|
88
|
+
* accept: { "text/plain": [".txt"] },
|
|
89
|
+
* },
|
|
90
|
+
* ],
|
|
91
|
+
* };
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
types?: {
|
|
95
|
+
/**
|
|
96
|
+
* An optional desciption of the category of file types allowed. Default to be an empty string.
|
|
97
|
+
*/
|
|
98
|
+
description?: string;
|
|
99
|
+
/**
|
|
100
|
+
* An object with the keys set to the MIME type and the values an array of file extensions (see below for an example).
|
|
101
|
+
* ```ts
|
|
102
|
+
* const opts = {
|
|
103
|
+
* types: [
|
|
104
|
+
* {
|
|
105
|
+
* description: "Text file",
|
|
106
|
+
* accept: { "text/plain": [".txt"] },
|
|
107
|
+
* },
|
|
108
|
+
* ],
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
accept: Record<string, string[]>;
|
|
113
|
+
}[];
|
|
114
|
+
} | {
|
|
115
|
+
/**
|
|
116
|
+
* Always use a cross-browser compatible method.
|
|
117
|
+
*/
|
|
118
|
+
method?: 'crossBrowser';
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Base type for file system request options.
|
|
122
|
+
*/
|
|
123
|
+
type _FileSystemRequestOptionsBase = {
|
|
124
|
+
accept?: string | string[];
|
|
125
|
+
multiple?: boolean;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Type representing file system request options.
|
|
129
|
+
*/
|
|
130
|
+
export type FileSystemRequestOptions = _FileSystemRequestOptionsBase & ({
|
|
131
|
+
/**
|
|
132
|
+
* Prefer using the File System Access API, or if not supported, use a cross-browser compatible method.
|
|
133
|
+
*
|
|
134
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API File System Access API}
|
|
135
|
+
*/
|
|
136
|
+
method: 'preferFileSystem';
|
|
137
|
+
/**
|
|
138
|
+
* By specifying an ID, the browser can remember different directories for different IDs. If the same ID is used for another picker, the picker opens in the same directory.
|
|
139
|
+
*/
|
|
140
|
+
directoryId?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The directory to open the dialog in. Leaving this undefined results in the dialog being opened in the last known directory.
|
|
143
|
+
*/
|
|
144
|
+
startDirectory?: FileSystemStartDirectory;
|
|
145
|
+
/**
|
|
146
|
+
* An array of allowed file types to request. Each item is an object with the following options:
|
|
147
|
+
* - `description?` - An optional desciption of the category of file types allowed. Default to be an empty string.
|
|
148
|
+
* - `accept` - An object with the keys set to the MIME type and the values an array of file extensions (see below for an example).
|
|
149
|
+
* ```ts
|
|
150
|
+
* const opts = {
|
|
151
|
+
* types: [
|
|
152
|
+
* {
|
|
153
|
+
* description: "Text file",
|
|
154
|
+
* accept: { "text/plain": [".txt"] },
|
|
155
|
+
* },
|
|
156
|
+
* ],
|
|
157
|
+
* };
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
types?: {
|
|
161
|
+
/**
|
|
162
|
+
* An optional desciption of the category of file types allowed. Default to be an empty string.
|
|
163
|
+
*/
|
|
164
|
+
description?: string;
|
|
165
|
+
/**
|
|
166
|
+
* An object with the keys set to the MIME type and the values an array of file extensions (see below for an example).
|
|
167
|
+
* ```ts
|
|
168
|
+
* const opts = {
|
|
169
|
+
* types: [
|
|
170
|
+
* {
|
|
171
|
+
* description: "Text file",
|
|
172
|
+
* accept: { "text/plain": [".txt"] },
|
|
173
|
+
* },
|
|
174
|
+
* ],
|
|
175
|
+
* };
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
accept: Record<string, string[]>;
|
|
179
|
+
}[];
|
|
180
|
+
} | {
|
|
181
|
+
/**
|
|
182
|
+
* Always use a cross-browser compatible method.
|
|
183
|
+
*/
|
|
184
|
+
method?: 'crossBrowser';
|
|
185
|
+
});
|
|
186
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function findBestSuggestions<T extends string>(toMatch: string, suggestions: Readonly<T[]>): T[];
|
|
2
|
+
export declare function findBestSuggestions<T extends Exclude<any, string>>(toMatch: string, suggestions: Readonly<T[]>, mapFn: (v: T) => string): T[];
|
|
3
|
+
export declare function findBestAutocomplate(toMatch: string, autocompletes: string[]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './find-suggestion';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './track-form-control/';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './track-form-control';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Injector, Signal } from '@angular/core';
|
|
2
|
+
import { AbstractControl, AsyncValidatorFn, FormControlStatus, ValidationErrors, ValidatorFn } from '@angular/forms';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
export interface FormControlTrackerOptions {
|
|
5
|
+
injector?: Injector;
|
|
6
|
+
}
|
|
7
|
+
export interface BoundControlTrackerOptions extends FormControlTrackerOptions {
|
|
8
|
+
attachValueAccessor?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TrackedFormControl<T> {
|
|
11
|
+
readonly instance: AbstractControl<T>;
|
|
12
|
+
readonly value$: Observable<T>;
|
|
13
|
+
readonly value: Signal<T>;
|
|
14
|
+
readonly errors$: Observable<ValidationErrors | null>;
|
|
15
|
+
readonly errors: Signal<ValidationErrors | null>;
|
|
16
|
+
readonly touched$: Observable<boolean>;
|
|
17
|
+
readonly touched: Signal<boolean>;
|
|
18
|
+
readonly untouched$: Observable<boolean>;
|
|
19
|
+
readonly untouched: Signal<boolean>;
|
|
20
|
+
readonly pristine$: Observable<boolean>;
|
|
21
|
+
readonly pristine: Signal<boolean>;
|
|
22
|
+
readonly dirty$: Observable<boolean>;
|
|
23
|
+
readonly dirty: Signal<boolean>;
|
|
24
|
+
readonly status$: Observable<FormControlStatus>;
|
|
25
|
+
readonly status: Signal<FormControlStatus>;
|
|
26
|
+
readonly valid$: Observable<boolean>;
|
|
27
|
+
readonly valid: Signal<boolean>;
|
|
28
|
+
readonly invalid$: Observable<boolean>;
|
|
29
|
+
readonly invalid: Signal<boolean>;
|
|
30
|
+
readonly pending$: Observable<boolean>;
|
|
31
|
+
readonly pending: Signal<boolean>;
|
|
32
|
+
readonly disabled$: Observable<boolean>;
|
|
33
|
+
readonly disabled: Signal<boolean>;
|
|
34
|
+
readonly enabled$: Observable<boolean>;
|
|
35
|
+
readonly enabled: Signal<boolean>;
|
|
36
|
+
readonly touchedHasErrors: Signal<boolean>;
|
|
37
|
+
readonly validators$: Observable<ValidatorFn[] | null>;
|
|
38
|
+
readonly validators: Signal<ValidatorFn[] | null>;
|
|
39
|
+
readonly asyncValidators$: Observable<AsyncValidatorFn[] | null>;
|
|
40
|
+
readonly asyncValidators: Signal<AsyncValidatorFn[] | null>;
|
|
41
|
+
init(): void;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gives reactive access to the properties of the given form control.
|
|
46
|
+
*
|
|
47
|
+
* Call `destroy()` to dispose of form control tracker.
|
|
48
|
+
*
|
|
49
|
+
* @param formControl the form control to be tracked.
|
|
50
|
+
* @param options optional configuration for the form control tracker.
|
|
51
|
+
* @returns an object containing all standard form control getters as signals.
|
|
52
|
+
* @example
|
|
53
|
+
* ```
|
|
54
|
+
* readonly ageControl = new FormControl('John');
|
|
55
|
+
*
|
|
56
|
+
* readonly ageControlTracker = trackFormControl(this.ageControl);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function trackFormControl<T = any>(formControl: AbstractControl<T>, options?: FormControlTrackerOptions): TrackedFormControl<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Gives reactive access to the properties of the Form Control assigned to the component instance.
|
|
62
|
+
*
|
|
63
|
+
* Call the `init()` method inside `ngOnInit()` to start listening to the Form Control, call `destroy()` to dispose of the listener.
|
|
64
|
+
*
|
|
65
|
+
* @param thisObj the component instance.
|
|
66
|
+
* @param options optional configuration for the form control tracker.
|
|
67
|
+
* @returns an object containing all standard form control getters as signals.
|
|
68
|
+
* @example
|
|
69
|
+
* ```
|
|
70
|
+
* export class MyComponent implements ControlValueAccessor, OnInit, OnDestroy {
|
|
71
|
+
* readonly control = trackFormControl(this);
|
|
72
|
+
*
|
|
73
|
+
* ngOnInit(): void {
|
|
74
|
+
* this.control.init();
|
|
75
|
+
* }
|
|
76
|
+
* ngOnDestroy(): void {
|
|
77
|
+
* this.control.destroy();
|
|
78
|
+
* }
|
|
79
|
+
* // control value accessor implementation ...
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function trackBoundControl<T = any>(thisObj: any, options?: BoundControlTrackerOptions): TrackedFormControl<T>;
|