@elderbyte/ngx-starter 18.2.0-beta3 → 18.2.0

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.
@@ -0,0 +1,59 @@
1
+ import { FileEntry } from './listing/file-entry';
2
+ import { ElementRef, Renderer2 } from '@angular/core';
3
+ import { BooleanInput } from '@angular/cdk/coercion';
4
+ import { Observable } from 'rxjs';
5
+ export declare class ElderFileSelectInput {
6
+ private renderer;
7
+ private el;
8
+ /***************************************************************************
9
+ * *
10
+ * Fields *
11
+ * *
12
+ **************************************************************************/
13
+ private readonly logger;
14
+ private _fileInput;
15
+ private _unlisten;
16
+ private _multiple;
17
+ private _directory;
18
+ private _accept;
19
+ private readonly _filesSelected;
20
+ /***************************************************************************
21
+ * *
22
+ * Constructor *
23
+ * *
24
+ **************************************************************************/
25
+ constructor(renderer: Renderer2, el: ElementRef);
26
+ /***************************************************************************
27
+ * *
28
+ * Properties *
29
+ * *
30
+ **************************************************************************/
31
+ get filesSelected(): Observable<FileEntry[]>;
32
+ set elderFileSelect(value: string);
33
+ set elderFileSelectMultiple(value: BooleanInput);
34
+ set elderFileSelectDirectory(value: BooleanInput);
35
+ /***************************************************************************
36
+ * *
37
+ * Public API *
38
+ * *
39
+ **************************************************************************/
40
+ /**
41
+ * <input type="file"
42
+ * hidden #fileInput
43
+ * [multiple]="multiple"
44
+ * [accept]="accept"
45
+ * (change)="fileInputChanged()"
46
+ * />
47
+ */
48
+ createFileSelect(): void;
49
+ removeFileSelect(): void;
50
+ openFileSelectDialog(): void;
51
+ /***************************************************************************
52
+ * *
53
+ * Private methods *
54
+ * *
55
+ **************************************************************************/
56
+ private fileInputChanged;
57
+ private clearFileList;
58
+ private toFileEntries;
59
+ }
@@ -1,29 +1,31 @@
1
- import { ElementRef, EventEmitter, OnDestroy, OnInit, Renderer2 } from '@angular/core';
1
+ import { DestroyRef, ElementRef, EventEmitter, OnDestroy, OnInit, Renderer2 } from '@angular/core';
2
2
  import { BooleanInput } from '@angular/cdk/coercion';
3
3
  import { FileEntry } from './listing/file-entry';
4
+ import { FileSystemDirectoryPickerOptions, FileSystemFilePickerOptions } from './file-system-api';
5
+ import { Observable } from 'rxjs';
4
6
  import * as i0 from "@angular/core";
5
7
  export declare class ElderFileSelectDirective implements OnInit, OnDestroy {
6
- private el;
7
8
  private renderer;
9
+ private el;
10
+ private destroyRef;
8
11
  /***************************************************************************
9
12
  * *
10
13
  * Fields *
11
14
  * *
12
15
  **************************************************************************/
13
16
  private readonly logger;
14
- private _fileInput;
15
- private _unlisten;
16
17
  readonly elderFileSelectChange: EventEmitter<FileEntry[]>;
17
18
  readonly elderSingleFileSelectChange: EventEmitter<File>;
18
- private _multiple;
19
- private _directory;
20
- private _accept;
19
+ private _legacyInput;
20
+ private _filePickerOptions;
21
+ private _directoryPickerOptions;
22
+ private _useDirectoryPicker;
21
23
  /***************************************************************************
22
24
  * *
23
25
  * Constructor *
24
26
  * *
25
27
  **************************************************************************/
26
- constructor(el: ElementRef, renderer: Renderer2);
28
+ constructor(renderer: Renderer2, el: ElementRef, destroyRef: DestroyRef);
27
29
  /***************************************************************************
28
30
  * *
29
31
  * Life Cycle *
@@ -37,6 +39,9 @@ export declare class ElderFileSelectDirective implements OnInit, OnDestroy {
37
39
  * *
38
40
  **************************************************************************/
39
41
  set elderFileSelect(value: string);
42
+ private buildTypeOption;
43
+ private isFileExtension;
44
+ private isMimeType;
40
45
  set elderFileSelectMultiple(value: BooleanInput);
41
46
  /**
42
47
  * Allow the user to select a directory. All files that are recursively contained are selected.
@@ -50,26 +55,14 @@ export declare class ElderFileSelectDirective implements OnInit, OnDestroy {
50
55
  * *
51
56
  **************************************************************************/
52
57
  onClick(event: any): void;
53
- openFileSelectDialog(): void;
54
58
  /***************************************************************************
55
59
  * *
56
60
  * Private methods *
57
61
  * *
58
62
  **************************************************************************/
59
- /**
60
- * <input type="file"
61
- * hidden #fileInput
62
- * [multiple]="multiple"
63
- * [accept]="accept"
64
- * (change)="fileInputChanged()"
65
- * />
66
- */
67
- private createFileSelect;
68
- private removeFileSelect;
69
- private fileInputChanged;
70
- private clearFileList;
71
- private emitFileList;
72
- private toFileEntries;
63
+ private pushFileChanges;
64
+ openFilePicker(pickerOpts: FileSystemFilePickerOptions): Observable<FileEntry[]>;
65
+ openDirectoryPicker(pickerOpts: FileSystemDirectoryPickerOptions): Observable<FileEntry[]>;
73
66
  static ɵfac: i0.ɵɵFactoryDeclaration<ElderFileSelectDirective, never>;
74
67
  static ɵdir: i0.ɵɵDirectiveDeclaration<ElderFileSelectDirective, "[elderFileSelect]", never, { "elderFileSelect": { "alias": "elderFileSelect"; "required": false; }; "elderFileSelectMultiple": { "alias": "elderFileSelectMultiple"; "required": false; }; "elderFileSelectDirectory": { "alias": "elderFileSelectDirectory"; "required": false; }; }, { "elderFileSelectChange": "elderFileSelectChange"; "elderSingleFileSelectChange": "elderSingleFileSelectChange"; }, never, never, true, never>;
75
68
  }
@@ -0,0 +1,86 @@
1
+ import { Observable } from 'rxjs';
2
+ /***************************************************************************
3
+ * *
4
+ * File Picker Options *
5
+ * *
6
+ **************************************************************************/
7
+ export interface FileSystemFilePickerOptions {
8
+ /**
9
+ *
10
+ * ```
11
+ * types: [
12
+ * {
13
+ * description: "Images",
14
+ * accept: {
15
+ * "image/*": [".png", ".gif", ".jpeg", ".jpg"],
16
+ * },
17
+ * },
18
+ * ],
19
+ * excludeAcceptAllOption: true,
20
+ * multiple: false,
21
+ * ```
22
+ */
23
+ excludeAcceptAllOptions?: boolean;
24
+ id?: string;
25
+ multiple?: boolean;
26
+ startIn?: FileSystemHandle | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
27
+ types?: FileSystemFilePickerTypeOptions[];
28
+ }
29
+ export interface FileSystemFilePickerTypeOptions {
30
+ accept: Record<string, string[]>;
31
+ description?: string;
32
+ }
33
+ /***************************************************************************
34
+ * *
35
+ * Directory Picker Options *
36
+ * *
37
+ **************************************************************************/
38
+ export interface FileSystemDirectoryPickerOptions {
39
+ id?: string;
40
+ mode?: string;
41
+ startIn?: FileSystemHandle | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
42
+ }
43
+ /***************************************************************************
44
+ * *
45
+ * FileSystem API *
46
+ * *
47
+ **************************************************************************/
48
+ /**
49
+ * Holds experimental features of the browser `File System API`. No typescript lint checks
50
+ * are performed here!
51
+ */
52
+ export declare class FileSystemApi {
53
+ /***************************************************************************
54
+ * *
55
+ * DataTransferItem *
56
+ * *
57
+ **************************************************************************/
58
+ static isGetAsFileSystemHandleSupported(transferItem: DataTransferItem): boolean;
59
+ /**
60
+ * Returns an FileSystemHandle Observable of the given DataTransferItem. The FileSystemHandle can only be accessed in the `dragstart`
61
+ * or `drop` event. Otherwise, it will return null!
62
+ */
63
+ static getAsFileSystemHandle(transferItem: DataTransferItem): Observable<FileSystemHandle | null>;
64
+ /***************************************************************************
65
+ * *
66
+ * File Picker *
67
+ * *
68
+ **************************************************************************/
69
+ static isFileSystemSupported(): boolean;
70
+ static openFilePicker(pickerOpts: FileSystemFilePickerOptions): Observable<FileSystemFileHandle[]>;
71
+ /***************************************************************************
72
+ * *
73
+ * Directory Picker *
74
+ * *
75
+ **************************************************************************/
76
+ static isDirectoryPickerSupported(): boolean;
77
+ static openDirectoryPicker(pickerOpts: FileSystemDirectoryPickerOptions): Observable<FileSystemDirectoryHandle>;
78
+ /***************************************************************************
79
+ * *
80
+ * FileSystemDirectoryHandle *
81
+ * *
82
+ **************************************************************************/
83
+ static getHandlesFromDirectory(dirHandle: FileSystemDirectoryHandle): Observable<FileSystemHandle[]>;
84
+ static buildRelativeParent(fileOrDirHandle: FileSystemHandle, rootDirectory?: FileSystemDirectoryHandle): Observable<string | undefined>;
85
+ private static getHandlesFromDirectoryAsync;
86
+ }
@@ -1,3 +1,4 @@
1
+ import { Observable } from 'rxjs';
1
2
  /**
2
3
  * Represents a file and the relative path where the user has selected it.
3
4
  * This is useful if the user has selected a folder and files
@@ -10,6 +11,7 @@ export declare class FileEntry {
10
11
  * to this file. Only relevant if the user has selected a folder.
11
12
  */
12
13
  readonly relativeParent: string | null;
14
+ readonly fileHandle?: FileSystemFileHandle;
13
15
  /**
14
16
  * Creates a file Entry without an explicit relative parent.
15
17
  *
@@ -18,10 +20,16 @@ export declare class FileEntry {
18
20
  * which is also supported by this method.
19
21
  */
20
22
  static ofFile(file: File): FileEntry;
23
+ /**
24
+ * Creates an Observable of a File Entry by resolving its FileSystemFileHandle.
25
+ * @param fileHandle
26
+ * @param rootDirectory is needed to build a relative parent
27
+ */
28
+ static ofFileHandle(fileHandle: FileSystemFileHandle, rootDirectory?: FileSystemDirectoryHandle): Observable<FileEntry>;
21
29
  /**
22
30
  * Creates a file Entry with a relative parent path
23
31
  */
24
- static relativeFile(file: File, relativeParent: string | null): FileEntry;
32
+ static relativeFile(file: File, relativeParent: string | null, fileHandle?: FileSystemFileHandle): FileEntry;
25
33
  static toFileMap(entries: FileEntry[]): Map<File, FileEntry>;
26
34
  static toFileArray(entries: FileEntry[]): File[];
27
35
  /***************************************************************************
@@ -48,4 +56,5 @@ export declare class FileEntry {
48
56
  * Returns a string which specifies the file's path relative to the directory selected by the user.
49
57
  */
50
58
  private static buildRelativePath;
59
+ private static buildRelativeParent;
51
60
  }
@@ -9,15 +9,12 @@ export declare class FileListingRx {
9
9
  * *
10
10
  **************************************************************************/
11
11
  toFileList(transferItemList: DataTransferItemList): Observable<FileEntry[]>;
12
- listFilesRecursive(entry: FileSystemEntry): Observable<FileEntry[]>;
13
12
  /***************************************************************************
14
13
  * *
15
14
  * Private methods *
16
15
  * *
17
16
  **************************************************************************/
18
- private listFilesRecursiveAsync;
19
- private observableFile;
20
- private trimStaringSlash;
21
- private readEntries;
22
- private consumeReaderToCompletion;
17
+ private resolveTransferItem;
18
+ private legacyFileListing;
19
+ private fallbackFileListing;
23
20
  }
@@ -0,0 +1,21 @@
1
+ import { Observable } from 'rxjs';
2
+ import { FileEntry } from './file-entry';
3
+ export declare class FileListingSystemHandle {
4
+ /***************************************************************************
5
+ * *
6
+ * Public methods *
7
+ * *
8
+ **************************************************************************/
9
+ /**
10
+ * Creates a File Entry Array Observable by resolving its FileSystemHandle.
11
+ * @returns An `Observable<FileEntry[]>` with the FileSystemFileHandle included
12
+ */
13
+ static listFiles(handle: FileSystemHandle, rootDirectory?: FileSystemDirectoryHandle): Observable<FileEntry[]>;
14
+ /***************************************************************************
15
+ * *
16
+ * Private methods *
17
+ * *
18
+ **************************************************************************/
19
+ private static listFilesRecursive;
20
+ private static listFilesOfEach;
21
+ }
@@ -0,0 +1,26 @@
1
+ import { Observable } from 'rxjs';
2
+ import { FileEntry } from './file-entry';
3
+ export declare class FileListingWebkit {
4
+ /***************************************************************************
5
+ * *
6
+ * Constructor *
7
+ * *
8
+ **************************************************************************/
9
+ constructor();
10
+ /***************************************************************************
11
+ * *
12
+ * Public methods *
13
+ * *
14
+ **************************************************************************/
15
+ static listFilesRecursive(entry: FileSystemEntry): Observable<FileEntry[]>;
16
+ /***************************************************************************
17
+ * *
18
+ * Private methods *
19
+ * *
20
+ **************************************************************************/
21
+ private static listFilesRecursiveAsync;
22
+ private static observableFile;
23
+ private static trimStaringSlash;
24
+ private static readEntries;
25
+ private static consumeReaderToCompletion;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elderbyte/ngx-starter",
3
- "version": "18.2.0-beta3",
3
+ "version": "18.2.0",
4
4
  "peerDependencies": {
5
5
  "@angular/core": "^17.0.0 || ^18.0.0",
6
6
  "@angular/common": "^17.0.0 || ^18.0.0",