@anglr/common 22.1.0-beta.20250304115624 → 22.1.0-beta.20250304120019
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/changelog.md +15 -0
- package/es2022/src/modules/file/components/file/file.component.js +7 -3
- package/es2022/src/modules/file/components/file/file.component.js.map +1 -1
- package/es2022/src/modules/file/directive/fileInput/fileInput.directive.js +13 -1
- package/es2022/src/modules/file/directive/fileInput/fileInput.directive.js.map +1 -1
- package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.context.js.map +1 -1
- package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.directive.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/file/components/file/file.component.css +1 -0
- package/src/modules/file/components/file/file.component.d.ts.map +1 -1
- package/src/modules/file/components/file/file.component.html +1 -1
- package/src/modules/file/directive/fileInput/fileInput.directive.d.ts +4 -0
- package/src/modules/file/directive/fileInput/fileInput.directive.d.ts.map +1 -1
- package/src/modules/file/directive/fileTemplate/fileTemplate.context.d.ts +4 -0
- package/src/modules/file/directive/fileTemplate/fileTemplate.context.d.ts.map +1 -1
- package/version.bak +1 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 22.1.0 (2025-03-04)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- fixed `FileComponent`, now hover is passed to component displayed inside
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- updated `FileTemplateContext` interface
|
|
12
|
+
- **new properties**
|
|
13
|
+
- `openFileBrowser` opens file browser dialog
|
|
14
|
+
- updated `FileInputDirective` directive
|
|
15
|
+
- **new method**
|
|
16
|
+
- `openFileBrowser` opens file browser dialog
|
|
17
|
+
|
|
3
18
|
## Version 22.0.0 (2025-01-23)
|
|
4
19
|
|
|
5
20
|
### Features
|
|
@@ -88,6 +88,7 @@ export class FileComponent {
|
|
|
88
88
|
file: this.file(),
|
|
89
89
|
files: this.files(),
|
|
90
90
|
clearFile: fileInput.clearFile,
|
|
91
|
+
openFileBrowser: fileInput.openFileBrowser,
|
|
91
92
|
fileName: this.name(),
|
|
92
93
|
filesNames: this.names(),
|
|
93
94
|
multiple: this.multiple(),
|
|
@@ -100,6 +101,7 @@ export class FileComponent {
|
|
|
100
101
|
file: this.file(),
|
|
101
102
|
files: this.files(),
|
|
102
103
|
clearFile: fileInput.clearFile,
|
|
104
|
+
openFileBrowser: fileInput.openFileBrowser,
|
|
103
105
|
fileName: this.name(),
|
|
104
106
|
filesNames: this.names(),
|
|
105
107
|
multiple: this.multiple(),
|
|
@@ -107,13 +109,15 @@ export class FileComponent {
|
|
|
107
109
|
});
|
|
108
110
|
}
|
|
109
111
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: FileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
110
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.1.0", type: FileComponent, isStandalone: true, selector: "file", inputs: { multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, readContent: { classPropertyName: "readContent", publicName: "readContent", isSignal: true, isRequired: false, transformFunction: null }, binaryContent: { classPropertyName: "binaryContent", publicName: "binaryContent", isSignal: true, isRequired: false, transformFunction: null }, textEncoding: { classPropertyName: "textEncoding", publicName: "textEncoding", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stringContentChange: "stringContentChange", arrayBufferContentChange: "arrayBufferContentChange", fileChange: "fileChange", filesChange: "filesChange", fileName: "fileName", filesNames: "filesNames" }, queries: [{ propertyName: "fileTemplate", first: true, predicate: FileTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "fileVisual", first: true, predicate: FILE_VISUAL, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "fileInput", first: true, predicate: FileInputDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *ngTemplateOutlet=\"fileTemplate(); context: templateContext()\"/>\n\n<input type=\"file\"
|
|
112
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.1.0", type: FileComponent, isStandalone: true, selector: "file", inputs: { multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, readContent: { classPropertyName: "readContent", publicName: "readContent", isSignal: true, isRequired: false, transformFunction: null }, binaryContent: { classPropertyName: "binaryContent", publicName: "binaryContent", isSignal: true, isRequired: false, transformFunction: null }, textEncoding: { classPropertyName: "textEncoding", publicName: "textEncoding", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stringContentChange: "stringContentChange", arrayBufferContentChange: "arrayBufferContentChange", fileChange: "fileChange", filesChange: "filesChange", fileName: "fileName", filesNames: "filesNames" }, host: { listeners: { "click": "fileInput().openFileBrowser()" } }, queries: [{ propertyName: "fileTemplate", first: true, predicate: FileTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "fileVisual", first: true, predicate: FILE_VISUAL, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "fileInput", first: true, predicate: FileInputDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *ngTemplateOutlet=\"fileTemplate(); context: templateContext()\"/>\n\n<input type=\"file\"\n class=\"input-file\"\n (fileChange)=\"file.set($event); fileChange.emit($event)\"\n (filesChange)=\"files.set($event); filesChange.emit($event)\"\n (fileName)=\"name.set($event); fileName.emit($event)\"\n (filesNames)=\"names.set($event); filesNames.emit($event)\"\n (stringContentChange)=\"stringContentChange.emit($event)\"\n (arrayBufferContentChange)=\"arrayBufferContentChange.emit($event)\"\n [multiple]=\"multiple()\"\n [binaryContent]=\"binaryContent()\"\n [readContent]=\"readContent()\"\n [textEncoding]=\"textEncoding()\">", styles: [":host\n{\n display: block;\n position: relative;\n}\n\n.input-file\n{\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n cursor: pointer;\n opacity: 0;\n pointer-events: none;\n}"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: FileInputDirective, selector: "input[type=file]", inputs: ["multiple", "readContent", "binaryContent", "textEncoding"], outputs: ["stringContentChange", "arrayBufferContentChange", "fileChange", "filesChange", "fileName", "filesNames"], exportAs: ["file"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
111
113
|
}
|
|
112
114
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: FileComponent, decorators: [{
|
|
113
115
|
type: Component,
|
|
114
|
-
args: [{ selector: 'file',
|
|
116
|
+
args: [{ selector: 'file', host: {
|
|
117
|
+
'(click)': 'fileInput().openFileBrowser()',
|
|
118
|
+
}, imports: [
|
|
115
119
|
NgTemplateOutlet,
|
|
116
120
|
FileInputDirective,
|
|
117
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngTemplateOutlet=\"fileTemplate(); context: templateContext()\"/>\n\n<input type=\"file\"
|
|
121
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngTemplateOutlet=\"fileTemplate(); context: templateContext()\"/>\n\n<input type=\"file\"\n class=\"input-file\"\n (fileChange)=\"file.set($event); fileChange.emit($event)\"\n (filesChange)=\"files.set($event); filesChange.emit($event)\"\n (fileName)=\"name.set($event); fileName.emit($event)\"\n (filesNames)=\"names.set($event); filesNames.emit($event)\"\n (stringContentChange)=\"stringContentChange.emit($event)\"\n (arrayBufferContentChange)=\"arrayBufferContentChange.emit($event)\"\n [multiple]=\"multiple()\"\n [binaryContent]=\"binaryContent()\"\n [readContent]=\"readContent()\"\n [textEncoding]=\"textEncoding()\">", styles: [":host\n{\n display: block;\n position: relative;\n}\n\n.input-file\n{\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n cursor: pointer;\n opacity: 0;\n pointer-events: none;\n}"] }]
|
|
118
122
|
}], ctorParameters: () => [] });
|
|
119
123
|
//# sourceMappingURL=file.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.component.js","sourceRoot":"","sources":["../../../../../../src/modules/file/components/file/file.component.ts","../../../../../../src/modules/file/components/file/file.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,YAAY,EAAU,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,EAA4B,KAAK,EAAE,gBAAgB,EAAiC,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACnP,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAC,kBAAkB,EAAuB,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;;AAG9C;;GAEG;
|
|
1
|
+
{"version":3,"file":"file.component.js","sourceRoot":"","sources":["../../../../../../src/modules/file/components/file/file.component.ts","../../../../../../src/modules/file/components/file/file.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,YAAY,EAAU,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,EAA4B,KAAK,EAAE,gBAAgB,EAAiC,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACnP,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAC,kBAAkB,EAAuB,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;;AAG9C;;GAEG;AAiBH,MAAM,OAAO,aAAa;IAoGtB,iEAAiE;IACjE;QA5FA;;WAEG;QACO,SAAI,GAAwC,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AIhB;wBACI,SAAS,EAAE,+BAA+B;qBAC7C,WAED;wBACI,gBAAgB;wBAChB,kBAAkB;qBACrB,mBACgB,uBAAuB,CAAC,MAAM","sourcesContent":["import {Component, ChangeDetectionStrategy, contentChild, Signal, TemplateRef, viewChild, computed, WritableSignal, signal, InputSignalWithTransform, input, booleanAttribute, InputSignal, OutputEmitterRef, output, effect} from '@angular/core';\nimport {NgTemplateOutlet} from '@angular/common';\n\nimport {FileInputDirective, FileTemplateContext, FileTemplateDirective} from '../../directive';\nimport {FILE_VISUAL} from '../../misc/tokens';\nimport {FileVisual} from '../../interfaces';\n\n/**\n * Component used for obtaining file contents from disk\n */\n@Component(\n{\n selector: 'file',\n templateUrl: 'file.component.html',\n styleUrl: 'file.component.css',\n host:\n {\n '(click)': 'fileInput().openFileBrowser()',\n },\n imports:\n [\n NgTemplateOutlet,\n FileInputDirective,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class FileComponent\n{\n //######################### protected properties - template bindings #########################\n\n /**\n * Instance of context for file template\n */\n protected templateContext: Signal<FileTemplateContext>;\n\n /**\n * Holds current value of file for file input\n */\n protected file: WritableSignal<File|null|undefined> = signal(null);\n\n /**\n * Holds current value of files for file input\n */\n protected files: WritableSignal<File[]|null|undefined> = signal(null);\n\n /**\n * Holds current value of file name for file input\n */\n protected name: WritableSignal<string|null|undefined> = signal(null);\n\n /**\n * Holds current value of files names for file input\n */\n protected names: WritableSignal<string[]|null|undefined> = signal(null);\n\n //######################### protected properties - children #########################\n\n /**\n * Instance template to be displayed as file input\n */\n protected fileTemplate: Signal<TemplateRef<FileTemplateContext>> = contentChild.required(FileTemplateDirective, {read: TemplateRef<FileTemplateContext>});\n\n /**\n * Contains file input directive instance\n */\n protected fileInput: Signal<FileInputDirective> = viewChild.required(FileInputDirective);\n\n /**\n * Instance of file visual implementation if available\n */\n protected fileVisual: Signal<FileVisual|undefined|null> = contentChild(FILE_VISUAL);\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication whether is multiple files selection enabled\n */\n public multiple: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether read file content, working only when `multiple` is not set (for single file)\n */\n public readContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether content of file is binary and it will be read as ArrayBuffer instead of string\n */\n public binaryContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Text encoding of read string file content\n */\n public textEncoding: InputSignal<string|undefined> = input();\n\n //######################### public properties - outputs #########################\n\n /**\n * Occurs when file changes and `binaryContent` is not set and `readContent` is set\n */\n public stringContentChange: OutputEmitterRef<string|undefined|null> = output<string|undefined|null>();\n\n /**\n * Occurs when file changes and `binaryContent` is set and `readContent` is set\n */\n public arrayBufferContentChange: OutputEmitterRef<ArrayBuffer|undefined|null> = output<ArrayBuffer|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set\n */\n public fileChange: OutputEmitterRef<File|null|undefined> = output<File|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set\n */\n public filesChange: OutputEmitterRef<File[]|null|undefined> = output<File[]|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file\n */\n public fileName: OutputEmitterRef<string|null|undefined> = output<string|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files\n */\n public filesNames: OutputEmitterRef<string[]|null|undefined> = output<string[]|undefined|null>();\n\n //######################### constructor #########################\n constructor()\n {\n effect(() =>\n {\n const fileVisual = this.fileVisual();\n\n if(fileVisual)\n {\n const fileInput = this.fileInput();\n\n fileVisual.fileTemplateContext.set(\n {\n file: this.file(),\n files: this.files(),\n clearFile: fileInput.clearFile,\n openFileBrowser: fileInput.openFileBrowser,\n fileName: this.name(),\n filesNames: this.names(),\n multiple: this.multiple(),\n });\n }\n }, {allowSignalWrites: true});\n\n this.templateContext = computed(() =>\n {\n const fileInput = this.fileInput();\n\n return {\n file: this.file(),\n files: this.files(),\n clearFile: fileInput.clearFile,\n openFileBrowser: fileInput.openFileBrowser,\n fileName: this.name(),\n filesNames: this.names(),\n multiple: this.multiple(),\n };\n });\n }\n}\n","<ng-container *ngTemplateOutlet=\"fileTemplate(); context: templateContext()\"/>\n\n<input type=\"file\"\n class=\"input-file\"\n (fileChange)=\"file.set($event); fileChange.emit($event)\"\n (filesChange)=\"files.set($event); filesChange.emit($event)\"\n (fileName)=\"name.set($event); fileName.emit($event)\"\n (filesNames)=\"names.set($event); filesNames.emit($event)\"\n (stringContentChange)=\"stringContentChange.emit($event)\"\n (arrayBufferContentChange)=\"arrayBufferContentChange.emit($event)\"\n [multiple]=\"multiple()\"\n [binaryContent]=\"binaryContent()\"\n [readContent]=\"readContent()\"\n [textEncoding]=\"textEncoding()\">"]}
|
|
@@ -62,6 +62,12 @@ export class FileInputDirective {
|
|
|
62
62
|
this.changeListenerUnlisten();
|
|
63
63
|
}
|
|
64
64
|
//######################### public methods #########################
|
|
65
|
+
/**
|
|
66
|
+
* Opens file browser dialog
|
|
67
|
+
*/
|
|
68
|
+
openFileBrowser() {
|
|
69
|
+
this.element.nativeElement.click();
|
|
70
|
+
}
|
|
65
71
|
/**
|
|
66
72
|
* Clears selection of file/files
|
|
67
73
|
*/
|
|
@@ -131,6 +137,12 @@ export class FileInputDirective {
|
|
|
131
137
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0", ngImport: i0, type: FileInputDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
132
138
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.0", type: FileInputDirective, isStandalone: true, selector: "input[type=file]", inputs: { multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, readContent: { classPropertyName: "readContent", publicName: "readContent", isSignal: true, isRequired: false, transformFunction: null }, binaryContent: { classPropertyName: "binaryContent", publicName: "binaryContent", isSignal: true, isRequired: false, transformFunction: null }, textEncoding: { classPropertyName: "textEncoding", publicName: "textEncoding", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stringContentChange: "stringContentChange", arrayBufferContentChange: "arrayBufferContentChange", fileChange: "fileChange", filesChange: "filesChange", fileName: "fileName", filesNames: "filesNames" }, exportAs: ["file"], ngImport: i0 }); }
|
|
133
139
|
}
|
|
140
|
+
__decorate([
|
|
141
|
+
BindThis,
|
|
142
|
+
__metadata("design:type", Function),
|
|
143
|
+
__metadata("design:paramtypes", []),
|
|
144
|
+
__metadata("design:returntype", void 0)
|
|
145
|
+
], FileInputDirective.prototype, "openFileBrowser", null);
|
|
134
146
|
__decorate([
|
|
135
147
|
BindThis,
|
|
136
148
|
__metadata("design:type", Function),
|
|
@@ -149,5 +161,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0", ngImpor
|
|
|
149
161
|
selector: 'input[type=file]',
|
|
150
162
|
exportAs: 'file',
|
|
151
163
|
}]
|
|
152
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { clearFile: [], handleFileChange: [] } });
|
|
164
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { openFileBrowser: [], clearFile: [], handleFileChange: [] } });
|
|
153
165
|
//# sourceMappingURL=fileInput.directive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileInput/fileInput.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAoD,MAAM,EAAoB,SAAS,EAAC,MAAM,eAAe,CAAC;AAC5K,OAAO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IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;IACL,CAAC;8GApLQ,kBAAkB;kGAAlB,kBAAkB;;AAwFpB;IADN,QAAQ;;;;mDAUR;AAQS;IADT,QAAQ;;qCACyB,UAAU;;0DA2E3C;2FApLQ,kBAAkB;kBAL9B,SAAS;mBACV;oBACI,QAAQ,EAAE,kBAAkB;oBAC5B,QAAQ,EAAE,MAAM;iBACnB;uGAyFU,SAAS,MAiBN,gBAAgB","sourcesContent":["import {booleanAttribute, Directive, effect, ElementRef, input, InputSignal, InputSignalWithTransform, OnDestroy, output, OutputEmitterRef, Renderer2} from '@angular/core';\nimport {BindThis, isString, NoopAction} from '@jscrpt/common';\n\n/**\n * Directive that allows better communication with input file\n */\n@Directive(\n{\n selector: 'input[type=file]',\n exportAs: 'file',\n})\nexport class FileInputDirective implements OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Unlistener for input file change event\n */\n protected changeListenerUnlisten: NoopAction;\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication whether is multiple files selection enabled\n */\n public multiple: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether read file content, working only when `multiple` is not set (for single file)\n */\n public readContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether content of file is binary and it will be read as ArrayBuffer instead of string\n */\n public binaryContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Text encoding of read string file content\n */\n public textEncoding: InputSignal<string|undefined> = input();\n\n //######################### public properties - outputs #########################\n\n /**\n * Occurs when file changes and `binaryContent` is not set and `readContent` is set\n */\n public stringContentChange: OutputEmitterRef<string|undefined|null> = output<string|undefined|null>();\n\n /**\n * Occurs when file changes and `binaryContent` is set and `readContent` is set\n */\n public arrayBufferContentChange: OutputEmitterRef<ArrayBuffer|undefined|null> = output<ArrayBuffer|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set\n */\n public fileChange: OutputEmitterRef<File|null|undefined> = output<File|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set\n */\n public filesChange: OutputEmitterRef<File[]|null|undefined> = output<File[]|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file\n */\n public fileName: OutputEmitterRef<string|null|undefined> = output<string|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files\n */\n public filesNames: OutputEmitterRef<string[]|null|undefined> = output<string[]|undefined|null>();\n\n //######################### constructors #########################\n constructor(protected element: ElementRef<HTMLInputElement>,\n renderer: Renderer2,)\n {\n this.changeListenerUnlisten = renderer.listen(element.nativeElement, 'change', this.handleFileChange);\n\n effect(() => renderer.setProperty(element.nativeElement, 'multiple', this.multiple()));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * @inheritdoc\n */\n public ngOnDestroy(): void\n {\n this.changeListenerUnlisten();\n }\n\n //######################### public methods #########################\n\n /**\n * Clears selection of file/files\n */\n @BindThis\n public clearFile(): void\n {\n this.element.nativeElement.value = '';\n this.fileChange.emit(null);\n this.fileName.emit(null);\n this.filesChange.emit(null);\n this.filesNames.emit(null);\n this.arrayBufferContentChange.emit(null);\n this.stringContentChange.emit(null);\n }\n\n //######################### protected methods #########################\n\n /**\n * Handles changes in file input\n */\n @BindThis\n protected handleFileChange(event: MouseEvent): void\n {\n if(!event.target)\n {\n throw new Error('FileOutputDirective: missing input file target!');\n }\n\n if(this.multiple())\n {\n const files = (event.target as HTMLInputElement).files;\n const filesArray: File[] = [];\n\n if(files)\n {\n for(let x = 0; x < files.length; x++)\n {\n filesArray.push(files[x]);\n }\n }\n\n this.filesChange.emit(filesArray);\n this.filesNames.emit(filesArray.map(itm => itm.name));\n }\n else\n {\n const file = (event.target as HTMLInputElement).files?.[0];\n\n this.fileChange.emit(file);\n this.fileName.emit(file?.name);\n }\n\n //read file contents\n if(!this.multiple() && this.readContent())\n {\n const file = (event.target as HTMLInputElement).files?.[0];\n\n //no file selected\n if(!file)\n {\n return;\n }\n\n const fileReader = new FileReader();\n \n fileReader.onloadend = () =>\n {\n const result = fileReader.result;\n\n if(!result)\n {\n this.stringContentChange.emit(null);\n this.arrayBufferContentChange.emit(null);\n\n return;\n }\n\n if(isString(result))\n {\n this.stringContentChange.emit(result);\n }\n else\n {\n this.arrayBufferContentChange.emit(result);\n }\n };\n \n if(this.binaryContent())\n {\n fileReader.readAsArrayBuffer(file);\n }\n else\n {\n fileReader.readAsText(file, this.textEncoding());\n }\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"fileInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileInput/fileInput.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAoD,MAAM,EAAoB,SAAS,EAAC,MAAM,eAAe,CAAC;AAC5K,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAa,MAAM,gBAAgB,CAAC;;AAE9D;;GAEG;AAMH,MAAM,OAAO,kBAAkB;IA+D3B,kEAAkE;IAClE,YAAsB,OAAqC,EAC/C,QAAmB;QADT,YAAO,GAAP,OAAO,CAA8B;QAvD3D,gFAAgF;QAEhF;;WAEG;QACI,aAAQ,GAAsD,KAAK,CAA0B,KAAK,EAAE,EAAC,SAAS,EAAE,gBAAgB,EAAC,CAAC,CAAC;QAE1I;;WAEG;QACI,gBAAW,GAAsD,KAAK,CAA0B,KAAK,EAAE,EAAC,SAAS,EAAE,gBAAgB,EAAC,CAAC,CAAC;QAE7I;;WAEG;QACI,kBAAa,GAAsD,KAAK,CAA0B,KAAK,EAAE,EAAC,SAAS,EAAE,gBAAgB,EAAC,CAAC,CAAC;QAE/I;;WAEG;QACI,iBAAY,GAAkC,KAAK,EAAE,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AkB;YAClB,IAAG,CAAC,IAAI,EACR,CAAC;gBACG,OAAO;YACX,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;YAEpC,UAAU,CAAC,SAAS,GAAG,GAAG,EAAE;gBAExB,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;gBAEjC,IAAG,CAAC,MAAM,EACV,CAAC;oBACG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAEzC,OAAO;gBACX,CAAC;gBAED,IAAG,QAAQ,CAAC,MAAM,CAAC,EACnB,CAAC;oBACG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC1C,CAAC;qBAED,CAAC;oBACG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC/C,CAAC;YACL,CAAC,CAAC;YAEF,IAAG,IAAI,CAAC,aAAa,EAAE,EACvB,CAAC;gBACG,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;iBAED,CAAC;gBACG,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;IACL,CAAC;8GA7LQ,kBAAkB;kGAAlB,kBAAkB;;AAwFpB;IADN,QAAQ;;;;yDAIR;AAMM;IADN,QAAQ;;;;mDAUR;AAQS;IADT,QAAQ;;qCACyB,UAAU;;0DA2E3C;2FA7LQ,kBAAkB;kBAL9B,SAAS;mBACV;oBACI,QAAQ,EAAE,kBAAkB;oBAC5B,QAAQ,EAAE,MAAM;iBACnB;uGAyFU,eAAe,MASf,SAAS,MAiBN,gBAAgB","sourcesContent":["import {booleanAttribute, Directive, effect, ElementRef, input, InputSignal, InputSignalWithTransform, OnDestroy, output, OutputEmitterRef, Renderer2} from '@angular/core';\nimport {BindThis, isString, NoopAction} from '@jscrpt/common';\n\n/**\n * Directive that allows better communication with input file\n */\n@Directive(\n{\n selector: 'input[type=file]',\n exportAs: 'file',\n})\nexport class FileInputDirective implements OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Unlistener for input file change event\n */\n protected changeListenerUnlisten: NoopAction;\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication whether is multiple files selection enabled\n */\n public multiple: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether read file content, working only when `multiple` is not set (for single file)\n */\n public readContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Indication whether content of file is binary and it will be read as ArrayBuffer instead of string\n */\n public binaryContent: InputSignalWithTransform<boolean, string|boolean> = input<boolean, boolean|string>(false, {transform: booleanAttribute});\n\n /**\n * Text encoding of read string file content\n */\n public textEncoding: InputSignal<string|undefined> = input();\n\n //######################### public properties - outputs #########################\n\n /**\n * Occurs when file changes and `binaryContent` is not set and `readContent` is set\n */\n public stringContentChange: OutputEmitterRef<string|undefined|null> = output<string|undefined|null>();\n\n /**\n * Occurs when file changes and `binaryContent` is set and `readContent` is set\n */\n public arrayBufferContentChange: OutputEmitterRef<ArrayBuffer|undefined|null> = output<ArrayBuffer|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set\n */\n public fileChange: OutputEmitterRef<File|null|undefined> = output<File|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set\n */\n public filesChange: OutputEmitterRef<File[]|null|undefined> = output<File[]|undefined|null>();\n\n /**\n * Occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file\n */\n public fileName: OutputEmitterRef<string|null|undefined> = output<string|undefined|null>();\n\n /**\n * Occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files\n */\n public filesNames: OutputEmitterRef<string[]|null|undefined> = output<string[]|undefined|null>();\n\n //######################### constructors #########################\n constructor(protected element: ElementRef<HTMLInputElement>,\n renderer: Renderer2,)\n {\n this.changeListenerUnlisten = renderer.listen(element.nativeElement, 'change', this.handleFileChange);\n\n effect(() => renderer.setProperty(element.nativeElement, 'multiple', this.multiple()));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * @inheritdoc\n */\n public ngOnDestroy(): void\n {\n this.changeListenerUnlisten();\n }\n\n //######################### public methods #########################\n\n /**\n * Opens file browser dialog\n */\n @BindThis\n public openFileBrowser(): void\n {\n this.element.nativeElement.click();\n }\n\n /**\n * Clears selection of file/files\n */\n @BindThis\n public clearFile(): void\n {\n this.element.nativeElement.value = '';\n this.fileChange.emit(null);\n this.fileName.emit(null);\n this.filesChange.emit(null);\n this.filesNames.emit(null);\n this.arrayBufferContentChange.emit(null);\n this.stringContentChange.emit(null);\n }\n\n //######################### protected methods #########################\n\n /**\n * Handles changes in file input\n */\n @BindThis\n protected handleFileChange(event: MouseEvent): void\n {\n if(!event.target)\n {\n throw new Error('FileOutputDirective: missing input file target!');\n }\n\n if(this.multiple())\n {\n const files = (event.target as HTMLInputElement).files;\n const filesArray: File[] = [];\n\n if(files)\n {\n for(let x = 0; x < files.length; x++)\n {\n filesArray.push(files[x]);\n }\n }\n\n this.filesChange.emit(filesArray);\n this.filesNames.emit(filesArray.map(itm => itm.name));\n }\n else\n {\n const file = (event.target as HTMLInputElement).files?.[0];\n\n this.fileChange.emit(file);\n this.fileName.emit(file?.name);\n }\n\n //read file contents\n if(!this.multiple() && this.readContent())\n {\n const file = (event.target as HTMLInputElement).files?.[0];\n\n //no file selected\n if(!file)\n {\n return;\n }\n\n const fileReader = new FileReader();\n\n fileReader.onloadend = () =>\n {\n const result = fileReader.result;\n\n if(!result)\n {\n this.stringContentChange.emit(null);\n this.arrayBufferContentChange.emit(null);\n\n return;\n }\n\n if(isString(result))\n {\n this.stringContentChange.emit(result);\n }\n else\n {\n this.arrayBufferContentChange.emit(result);\n }\n };\n\n if(this.binaryContent())\n {\n fileReader.readAsArrayBuffer(file);\n }\n else\n {\n fileReader.readAsText(file, this.textEncoding());\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTemplate.context.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileTemplate/fileTemplate.context.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Context passed to file template\n */\nexport interface FileTemplateContext\n{\n /**\n * Instance of selected file or null if none is selected\n */\n file: File|undefined|null;\n\n /**\n * Name of selected file\n */\n fileName: string|undefined|null;\n\n /**\n * Instance of selected array of files or null if none is selected\n */\n files: File[]|undefined|null;\n\n /**\n * Array of names of selected files\n */\n filesNames: string[]|undefined|null;\n\n /**\n * Indication whether multiple files selection is enabled\n */\n multiple: boolean;\n\n /**\n * Clears selected file\n */\n clearFile(): void;\n}"]}
|
|
1
|
+
{"version":3,"file":"fileTemplate.context.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileTemplate/fileTemplate.context.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Context passed to file template\n */\nexport interface FileTemplateContext\n{\n /**\n * Instance of selected file or null if none is selected\n */\n file: File|undefined|null;\n\n /**\n * Name of selected file\n */\n fileName: string|undefined|null;\n\n /**\n * Instance of selected array of files or null if none is selected\n */\n files: File[]|undefined|null;\n\n /**\n * Array of names of selected files\n */\n filesNames: string[]|undefined|null;\n\n /**\n * Indication whether multiple files selection is enabled\n */\n multiple: boolean;\n\n /**\n * Clears selected file\n */\n clearFile(): void;\n\n /**\n * Opens file browser dialog\n */\n openFileBrowser(): void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTemplate.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileTemplate/fileTemplate.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;;AAIxC;;GAEG;AAKH,MAAM,OAAO,qBAAqB;IAE9B,wEAAwE;IAExE;;OAEG;IACH,MAAM,CAAC,sBAAsB,CAAC,IAA2B,EAAE,IAAa;QAEpE,OAAO,IAAI,CAAC;IAChB,CAAC;8GAVQ,qBAAqB;kGAArB,qBAAqB;;2FAArB,qBAAqB;kBAJjC,SAAS;mBACV;oBACI,QAAQ,EAAE,gBAAgB;iBAC7B","sourcesContent":["import {Directive} from '@angular/core';\n\nimport {FileTemplateContext} from './fileTemplate.context';\n\n/**\n * Directive used for obtaining file component visual template\n */\n@Directive(\n{\n selector: '[fileTemplate]',\n})\nexport class FileTemplateDirective\n{\n //######################### ng language server #########################\n
|
|
1
|
+
{"version":3,"file":"fileTemplate.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/file/directive/fileTemplate/fileTemplate.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;;AAIxC;;GAEG;AAKH,MAAM,OAAO,qBAAqB;IAE9B,wEAAwE;IAExE;;OAEG;IACH,MAAM,CAAC,sBAAsB,CAAC,IAA2B,EAAE,IAAa;QAEpE,OAAO,IAAI,CAAC;IAChB,CAAC;8GAVQ,qBAAqB;kGAArB,qBAAqB;;2FAArB,qBAAqB;kBAJjC,SAAS;mBACV;oBACI,QAAQ,EAAE,gBAAgB;iBAC7B","sourcesContent":["import {Directive} from '@angular/core';\n\nimport {FileTemplateContext} from './fileTemplate.context';\n\n/**\n * Directive used for obtaining file component visual template\n */\n@Directive(\n{\n selector: '[fileTemplate]',\n})\nexport class FileTemplateDirective\n{\n //######################### ng language server #########################\n\n /**\n * Allows typechecking for template\n */\n static ngTemplateContextGuard(_dir: FileTemplateDirective, _ctx: unknown): _ctx is FileTemplateContext\n {\n return true;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.component.d.ts","sourceRoot":"","sources":["file.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,MAAM,EAAE,WAAW,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C,CAAmC;IAE9F;;OAEG;IACI,QAAQ,EAAE,gBAAgB,CAAC,MAAM,GAAC,IAAI,GAAC,SAAS,CAAC,CAAmC;IAE3F;;OAEG;IACI,UAAU,EAAE,gBAAgB,CAAC,MAAM,EAAE,GAAC,IAAI,GAAC,SAAS,CAAC,CAAqC;gBAG3E,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC,EAC/C,QAAQ,EAAE,SAAS;IAS/B;;OAEG;IACI,WAAW,IAAI,IAAI;IAO1B;;OAEG;IAEI,eAAe,IAAI,IAAI;IAK9B;;OAEG;IAEI,SAAS,IAAI,IAAI;IAaxB;;OAEG;IAEH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;yCAlH1C,kBAAkB;2CAAlB,kBAAkB;CA8L9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTemplate.context.d.ts","sourceRoot":"","sources":["fileTemplate.context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAEhC;;OAEG;IACH,IAAI,EAAE,IAAI,GAAC,SAAS,GAAC,IAAI,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAC,SAAS,GAAC,IAAI,CAAC;IAEhC;;OAEG;IACH,KAAK,EAAE,IAAI,EAAE,GAAC,SAAS,GAAC,IAAI,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,GAAC,SAAS,GAAC,IAAI,CAAC;IAEpC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,SAAS,IAAI,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"fileTemplate.context.d.ts","sourceRoot":"","sources":["fileTemplate.context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAEhC;;OAEG;IACH,IAAI,EAAE,IAAI,GAAC,SAAS,GAAC,IAAI,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAC,SAAS,GAAC,IAAI,CAAC;IAEhC;;OAEG;IACH,KAAK,EAAE,IAAI,EAAE,GAAC,SAAS,GAAC,IAAI,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,GAAC,SAAS,GAAC,IAAI,CAAC;IAEpC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,SAAS,IAAI,IAAI,CAAC;IAElB;;OAEG;IACH,eAAe,IAAI,IAAI,CAAC;CAC3B"}
|
package/version.bak
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
22.1.0-beta.
|
|
1
|
+
22.1.0-beta.20250304120019
|