@anglr/common 21.3.0-beta.20241115051814 → 21.3.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.
Files changed (75) hide show
  1. package/changelog.md +86 -1
  2. package/es2022/src/index.js +2 -1
  3. package/es2022/src/index.js.map +1 -1
  4. package/es2022/src/modules/file/components/file/file.component.js +119 -0
  5. package/es2022/src/modules/file/components/file/file.component.js.map +1 -0
  6. package/es2022/src/modules/file/components/fileInput/fileInput.component.js +62 -0
  7. package/es2022/src/modules/file/components/fileInput/fileInput.component.js.map +1 -0
  8. package/es2022/src/modules/file/components/index.js +4 -0
  9. package/es2022/src/modules/file/components/index.js.map +1 -0
  10. package/es2022/src/modules/file/components/uploadButton/uploadButton.component.js +59 -0
  11. package/es2022/src/modules/file/components/uploadButton/uploadButton.component.js.map +1 -0
  12. package/es2022/src/modules/file/directive/fileInput/fileInput.directive.js +154 -0
  13. package/es2022/src/modules/file/directive/fileInput/fileInput.directive.js.map +1 -0
  14. package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.context.js +2 -0
  15. package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.context.js.map +1 -0
  16. package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.directive.js +24 -0
  17. package/es2022/src/modules/file/directive/fileTemplate/fileTemplate.directive.js.map +1 -0
  18. package/es2022/src/modules/file/directive/index.js +4 -0
  19. package/es2022/src/modules/file/directive/index.js.map +1 -0
  20. package/es2022/src/modules/file/index.js +6 -0
  21. package/es2022/src/modules/file/index.js.map +1 -0
  22. package/es2022/src/modules/file/interfaces/fileVisual/fileVisual.interface.js +2 -0
  23. package/es2022/src/modules/file/interfaces/fileVisual/fileVisual.interface.js.map +1 -0
  24. package/es2022/src/modules/file/interfaces/index.js +2 -0
  25. package/es2022/src/modules/file/interfaces/index.js.map +1 -0
  26. package/es2022/src/modules/file/misc/tokens.js +6 -0
  27. package/es2022/src/modules/file/misc/tokens.js.map +1 -0
  28. package/es2022/src/modules/file/modules/file.module.js +40 -0
  29. package/es2022/src/modules/file/modules/file.module.js.map +1 -0
  30. package/es2022/src/modules/file/modules/index.js +2 -0
  31. package/es2022/src/modules/file/modules/index.js.map +1 -0
  32. package/es2022/src/pipes/firstUppercase/firstUppercase.pipe.js.map +1 -1
  33. package/es2022/src/pipes/firstUppercaseLocalize/firstUppercaseLocalize.pipe.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/index.d.ts +2 -1
  36. package/src/index.d.ts.map +1 -1
  37. package/src/modules/file/components/file/file.component.css +16 -0
  38. package/src/modules/file/components/file/file.component.d.ts +85 -0
  39. package/src/modules/file/components/file/file.component.d.ts.map +1 -0
  40. package/src/modules/file/components/file/file.component.html +14 -0
  41. package/src/modules/file/components/fileInput/fileInput.component.css +27 -0
  42. package/src/modules/file/components/fileInput/fileInput.component.d.ts +37 -0
  43. package/src/modules/file/components/fileInput/fileInput.component.d.ts.map +1 -0
  44. package/src/modules/file/components/fileInput/fileInput.component.html +7 -0
  45. package/src/modules/file/components/index.d.ts +4 -0
  46. package/src/modules/file/components/index.d.ts.map +1 -0
  47. package/src/modules/file/components/uploadButton/uploadButton.component.css +52 -0
  48. package/src/modules/file/components/uploadButton/uploadButton.component.d.ts +36 -0
  49. package/src/modules/file/components/uploadButton/uploadButton.component.d.ts.map +1 -0
  50. package/src/modules/file/components/uploadButton/uploadButton.component.html +16 -0
  51. package/src/modules/file/directive/fileInput/fileInput.directive.d.ts +69 -0
  52. package/src/modules/file/directive/fileInput/fileInput.directive.d.ts.map +1 -0
  53. package/src/modules/file/directive/fileTemplate/fileTemplate.context.d.ts +30 -0
  54. package/src/modules/file/directive/fileTemplate/fileTemplate.context.d.ts.map +1 -0
  55. package/src/modules/file/directive/fileTemplate/fileTemplate.directive.d.ts +14 -0
  56. package/src/modules/file/directive/fileTemplate/fileTemplate.directive.d.ts.map +1 -0
  57. package/src/modules/file/directive/index.d.ts +4 -0
  58. package/src/modules/file/directive/index.d.ts.map +1 -0
  59. package/src/modules/file/index.d.ts +6 -0
  60. package/src/modules/file/index.d.ts.map +1 -0
  61. package/src/modules/file/interfaces/fileVisual/fileVisual.interface.d.ts +12 -0
  62. package/src/modules/file/interfaces/fileVisual/fileVisual.interface.d.ts.map +1 -0
  63. package/src/modules/file/interfaces/index.d.ts +2 -0
  64. package/src/modules/file/interfaces/index.d.ts.map +1 -0
  65. package/src/modules/file/misc/tokens.d.ts +7 -0
  66. package/src/modules/file/misc/tokens.d.ts.map +1 -0
  67. package/src/modules/file/modules/file.module.d.ts +15 -0
  68. package/src/modules/file/modules/file.module.d.ts.map +1 -0
  69. package/src/modules/file/modules/index.d.ts +2 -0
  70. package/src/modules/file/modules/index.d.ts.map +1 -0
  71. package/src/pipes/firstUppercase/firstUppercase.pipe.d.ts +1 -1
  72. package/src/pipes/firstUppercase/firstUppercase.pipe.d.ts.map +1 -1
  73. package/src/pipes/firstUppercaseLocalize/firstUppercaseLocalize.pipe.d.ts +1 -1
  74. package/src/pipes/firstUppercaseLocalize/firstUppercaseLocalize.pipe.d.ts.map +1 -1
  75. package/version.bak +1 -1
package/changelog.md CHANGED
@@ -1,5 +1,90 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 21.3.0 (2024-11-15)
4
+
5
+ ### Bug Fixes
6
+
7
+ - fixed `FirstUppercaseSAPipe` typings, result cant be `undefined` or `null` if parameter is not `undefined` or `null`
8
+ - fixed `FirstUppercaseLocalizeSAPipe` typings, result cant be `undefined` or `null`
9
+
10
+ ### Features
11
+
12
+ - new `FileComponent` component, used for obtaining file contents from disk
13
+ - standalone
14
+ - **content child**
15
+ - `FileTemplateDirective` template to be displayed as file input
16
+ - `FILE_VISUAL` instance of file visual implementation if available
17
+ - **inputs**
18
+ - `multiple` indication whether is multiple files selection enabled
19
+ - `readContent` indication whether read file content, working only when `multiple` is not set (for single file)
20
+ - `binaryContent` indication whether content of file is binary and it will be read as ArrayBuffer instead of string
21
+ - `textEncoding` text encoding of read string file content
22
+ - **outputs**
23
+ - `stringContentChange` occurs when file changes and `binaryContent` is not set and `readContent` is set
24
+ - `arrayBufferContentChange` occurs when file changes and `binaryContent` is set and `readContent` is set
25
+ - `fileChange` occurs when selected file changes, occurs only when `multiple` is not set
26
+ - `filesChange` occurs when selected files changes, occurs only when `multiple` is set
27
+ - `fileName` occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file
28
+ - `filesNames` occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files
29
+ - new `FileInputComponent` component, that represents file input template
30
+ - standalone
31
+ - **provides**
32
+ - `FILE_VISUAL` as itself
33
+ - **implements**
34
+ - `FileVisual`
35
+ - **inputs**
36
+ - `buttonText` text to be displayed for file button
37
+ - `buttonClass` css classes applied to file button
38
+ - `textClass` css classes applied to file text, text displaying selected files
39
+ - `selectedText` text to be displayed as selected
40
+ - new `UploadButtonComponent` component, that represents upload button file template
41
+ - standalone
42
+ - **provides**
43
+ - `FILE_VISUAL` as itself
44
+ - **implements**
45
+ - `FileVisual`
46
+ - **inputs**
47
+ - `uploadIconClass` css classes applied tu button icon
48
+ - `uploadText` text to be displayed as button text
49
+ - `uploadTextClass` css classes for displayed text for button
50
+ - `cssClass` css class applied to button
51
+ - `progress` current progress to be displayed
52
+ - new `FileInputDirective` directive, that allows better communication with input file
53
+ - standalone
54
+ - **export as** `file`
55
+ - **implements**
56
+ - `OnDestroy`
57
+ - **inputs**
58
+ - `multiple` indication whether is multiple files selection enabled
59
+ - `readContent` indication whether read file content, working only when `multiple` is not set (for single file)
60
+ - `binaryContent` indication whether content of file is binary and it will be read as ArrayBuffer instead of string
61
+ - `textEncoding` text encoding of read string file content
62
+ - **outputs**
63
+ - `stringContentChange` occurs when file changes and `binaryContent` is not set and `readContent` is set
64
+ - `arrayBufferContentChange` occurs when file changes and `binaryContent` is set and `readContent` is set
65
+ - `fileChange` occurs when selected file changes, occurs only when `multiple` is not set
66
+ - `filesChange` occurs when selected files changes, occurs only when `multiple` is set
67
+ - `fileName` occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file
68
+ - `filesNames` occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files
69
+ - **methods**
70
+ - `clearFile` clears selection of file/files
71
+ - new `FileTemplateDirective` directive, that is used for obtaining file component visual template
72
+ - standalone
73
+ - new `FileTemplateContext` interface
74
+ - **properties**
75
+ - `file` instance of selected file or null if none is selected
76
+ - `fileName` name of selected file
77
+ - `files` instance of selected array of files or null if none is selected
78
+ - `filesNames` array of names of selected files
79
+ - `multiple` indication whether multiple files selection is enabled
80
+ - **methods**
81
+ - `clearFile` clears selected file
82
+ - new `FileVisual` interface
83
+ - **properties**
84
+ - `fileTemplateContext` instance of file template context passed to file visual to display info about selected files
85
+ - new `FILE_VISUAL` injection token, used for obtaining implementation of file visual component
86
+ - new `FileModule` module, used for grouping File components and directives
87
+
3
88
  ## Version 21.2.1 (2024-10-08)
4
89
 
5
90
  ### Bug Fixes
@@ -51,7 +136,7 @@
51
136
  - updated `RequiredClassDirective` directive
52
137
  - is now `standalone`
53
138
  - all `private`s are now `protected`
54
- - new **inputs**
139
+ - new **inputs**
55
140
  - `requiredClass` name of required css class that should be applied
56
141
  - updated `HasErrorDirective` directive
57
142
  - is now `standalone`
@@ -11,8 +11,9 @@ export { MultiButtonModule } from './modules/multiButton/modules/multiButton.mod
11
11
  export * from './components';
12
12
  export * from './decorators';
13
13
  export * from './modules/castPipes';
14
- export * from './modules/progressIndicator';
14
+ export * from './modules/file';
15
15
  export * from './modules/logger';
16
+ export * from './modules/progressIndicator';
16
17
  export * from './modules/tooltip';
17
18
  export * from './pipes';
18
19
  export * from './types/host';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACr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G,OAAO,EAAC,qBAAqB,EAAE,2BAA2B,EAAE,YAAY,EAAE,oBAAoB,EAAiB,oBAAoB,EAAuF,MAAM,0BAA0B,CAAC;AAC3P,cAAc,qBAAqB,CAAC;AAEpC,sBAAsB;AACtB,0BAA0B","sourcesContent":["export {GlobalizationService} from './services/globalization/globalization.service';\nexport {CommonDynamicModule} from './modules/commonDynamic.module';\nexport {CommonLocalizeModule} from './modules/commonLocalize.module';\nexport {CommonUtilsModule} from './modules/commonUtils.module';\nexport {DebugDataModule} from './modules/debugData/modules/debugData.module';\nexport {DebugDataComponent} from './modules/debugData/components/debugData/debugData.component';\nexport {DebugDataEnabledService} from './modules/debugData/services/debugDataEnabled/debugDataEnabled.service';\nexport {MultiButtonComponent} from './modules/multiButton/components/multiButton/multiButton.component';\nexport {MultiButtonCssClasses} from './modules/multiButton/components/multiButton/multiButton.interface';\nexport {MULTI_BUTTON_CSS_CLASSES} from './modules/multiButton/misc/tokens';\nexport {MultiButtonModule} from './modules/multiButton/modules/multiButton.module';\nexport * from './components';\nexport * from './decorators';\nexport * from './modules/castPipes';\nexport * from './modules/progressIndicator';\nexport * from './modules/logger';\nexport * from './modules/tooltip';\nexport * from './pipes';\nexport * from './types/host';\nexport * from './types/styles';\nexport * from './types/tokens';\nexport * from './types/providers';\nexport * from './utils';\nexport {CookieService} from './services/cookies/cookies.service';\nexport {StatusCodeService} from './services/statusCode/statusCode.service';\nexport {PermanentStorage, CookiePermanentStorage} from './services/permanentStorage';\nexport {MemoryTemporaryStorage, TemporaryStorage} from './services/temporaryStorage';\nexport {NoStringLocalization, StringLocalization} from './services/stringLocalization';\nexport * from './directives/bodyRender/bodyRender.directive';\nexport * from './directives/clickOutside/clickOutside.directive';\nexport * from './directives/ellipsisTooltip/ellipsisTooltip.directive';\nexport * from './directives/goBack/goBack.directive';\nexport * from './directives/positionTo/positionTo.directive';\nexport {NgComponentOutletEx} from './directives/ngComponentOutletEx/ngComponentOutletEx.directive';\nexport {APP_STABLE, extractAppStableResolve, runWhenModuleStable, runWhenAppStable} from './utils';\nexport {DEFAULT_NOTIFICATIONS, DefaultNotificationsService, Notification, NotificationSeverity, Notifications, NotificationsOptions, NotificationsProvider, NotificationsScopeProvider, NotificationsScopeProviderFactory} from './services/notifications';\nexport * from './services/position';\n\n//TODO: any to unknown\n//TODO: strict null checks"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAC,kBAAkB,EAAC,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAAC,uBAAuB,EAAC,MAAM,wEAAwE,CAAC;AAC/G,OAAO,EAAC,oBAAoB,EAAC,MAAM,oEAAoE,CAAC;AAExG,OAAO,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,iBAAiB,EAAC,MAAM,kDAAkD,CAAC;AACnF,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAmB,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAC,sBAAsB,EAAmB,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAC,oBAAoB,EAAqB,MAAM,+BAA+B,CAAC;AACvF,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,sCAAsC,CAAC;AACrD,cAAc,8CAA8C,CAAC;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,gEAAgE,CAAC;AACnG,OAAO,EAAC,UAAU,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,SAAS,CAAC;AACnG,OAAO,EAAC,qBAAqB,EAAE,2BAA2B,EAAE,YAAY,EAAE,oBAAoB,EAAiB,oBAAoB,EAAuF,MAAM,0BAA0B,CAAC;AAC3P,cAAc,qBAAqB,CAAC;AAEpC,sBAAsB;AACtB,0BAA0B","sourcesContent":["export {GlobalizationService} from './services/globalization/globalization.service';\nexport {CommonDynamicModule} from './modules/commonDynamic.module';\nexport {CommonLocalizeModule} from './modules/commonLocalize.module';\nexport {CommonUtilsModule} from './modules/commonUtils.module';\nexport {DebugDataModule} from './modules/debugData/modules/debugData.module';\nexport {DebugDataComponent} from './modules/debugData/components/debugData/debugData.component';\nexport {DebugDataEnabledService} from './modules/debugData/services/debugDataEnabled/debugDataEnabled.service';\nexport {MultiButtonComponent} from './modules/multiButton/components/multiButton/multiButton.component';\nexport {MultiButtonCssClasses} from './modules/multiButton/components/multiButton/multiButton.interface';\nexport {MULTI_BUTTON_CSS_CLASSES} from './modules/multiButton/misc/tokens';\nexport {MultiButtonModule} from './modules/multiButton/modules/multiButton.module';\nexport * from './components';\nexport * from './decorators';\nexport * from './modules/castPipes';\nexport * from './modules/file';\nexport * from './modules/logger';\nexport * from './modules/progressIndicator';\nexport * from './modules/tooltip';\nexport * from './pipes';\nexport * from './types/host';\nexport * from './types/styles';\nexport * from './types/tokens';\nexport * from './types/providers';\nexport * from './utils';\nexport {CookieService} from './services/cookies/cookies.service';\nexport {StatusCodeService} from './services/statusCode/statusCode.service';\nexport {PermanentStorage, CookiePermanentStorage} from './services/permanentStorage';\nexport {MemoryTemporaryStorage, TemporaryStorage} from './services/temporaryStorage';\nexport {NoStringLocalization, StringLocalization} from './services/stringLocalization';\nexport * from './directives/bodyRender/bodyRender.directive';\nexport * from './directives/clickOutside/clickOutside.directive';\nexport * from './directives/ellipsisTooltip/ellipsisTooltip.directive';\nexport * from './directives/goBack/goBack.directive';\nexport * from './directives/positionTo/positionTo.directive';\nexport {NgComponentOutletEx} from './directives/ngComponentOutletEx/ngComponentOutletEx.directive';\nexport {APP_STABLE, extractAppStableResolve, runWhenModuleStable, runWhenAppStable} from './utils';\nexport {DEFAULT_NOTIFICATIONS, DefaultNotificationsService, Notification, NotificationSeverity, Notifications, NotificationsOptions, NotificationsProvider, NotificationsScopeProvider, NotificationsScopeProviderFactory} from './services/notifications';\nexport * from './services/position';\n\n//TODO: any to unknown\n//TODO: strict null checks"]}
@@ -0,0 +1,119 @@
1
+ import { Component, ChangeDetectionStrategy, contentChild, TemplateRef, viewChild, computed, signal, input, booleanAttribute, output, effect } from '@angular/core';
2
+ import { NgTemplateOutlet } from '@angular/common';
3
+ import { FileInputDirective, FileTemplateDirective } from '../../directive';
4
+ import { FILE_VISUAL } from '../../misc/tokens';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Component used for obtaining file contents from disk
8
+ */
9
+ export class FileComponent {
10
+ //######################### constructor #########################
11
+ constructor() {
12
+ /**
13
+ * Holds current value of file for file input
14
+ */
15
+ this.file = signal(null);
16
+ /**
17
+ * Holds current value of files for file input
18
+ */
19
+ this.files = signal(null);
20
+ /**
21
+ * Holds current value of file name for file input
22
+ */
23
+ this.name = signal(null);
24
+ /**
25
+ * Holds current value of files names for file input
26
+ */
27
+ this.names = signal(null);
28
+ //######################### protected properties - children #########################
29
+ /**
30
+ * Instance template to be displayed as file input
31
+ */
32
+ this.fileTemplate = contentChild.required(FileTemplateDirective, { read: (TemplateRef) });
33
+ /**
34
+ * Contains file input directive instance
35
+ */
36
+ this.fileInput = viewChild.required(FileInputDirective);
37
+ /**
38
+ * Instance of file visual implementation if available
39
+ */
40
+ this.fileVisual = contentChild(FILE_VISUAL);
41
+ //######################### public properties - inputs #########################
42
+ /**
43
+ * Indication whether is multiple files selection enabled
44
+ */
45
+ this.multiple = input(false, { transform: booleanAttribute });
46
+ /**
47
+ * Indication whether read file content, working only when `multiple` is not set (for single file)
48
+ */
49
+ this.readContent = input(false, { transform: booleanAttribute });
50
+ /**
51
+ * Indication whether content of file is binary and it will be read as ArrayBuffer instead of string
52
+ */
53
+ this.binaryContent = input(false, { transform: booleanAttribute });
54
+ /**
55
+ * Text encoding of read string file content
56
+ */
57
+ this.textEncoding = input();
58
+ //######################### public properties - outputs #########################
59
+ /**
60
+ * Occurs when file changes and `binaryContent` is not set and `readContent` is set
61
+ */
62
+ this.stringContentChange = output();
63
+ /**
64
+ * Occurs when file changes and `binaryContent` is set and `readContent` is set
65
+ */
66
+ this.arrayBufferContentChange = output();
67
+ /**
68
+ * Occurs when selected file changes, occurs only when `multiple` is not set
69
+ */
70
+ this.fileChange = output();
71
+ /**
72
+ * Occurs when selected files changes, occurs only when `multiple` is set
73
+ */
74
+ this.filesChange = output();
75
+ /**
76
+ * Occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file
77
+ */
78
+ this.fileName = output();
79
+ /**
80
+ * Occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files
81
+ */
82
+ this.filesNames = output();
83
+ effect(() => {
84
+ const fileVisual = this.fileVisual();
85
+ if (fileVisual) {
86
+ const fileInput = this.fileInput();
87
+ fileVisual.fileTemplateContext.set({
88
+ file: this.file(),
89
+ files: this.files(),
90
+ clearFile: fileInput.clearFile,
91
+ fileName: this.name(),
92
+ filesNames: this.names(),
93
+ multiple: this.multiple(),
94
+ });
95
+ }
96
+ }, { allowSignalWrites: true });
97
+ this.templateContext = computed(() => {
98
+ const fileInput = this.fileInput();
99
+ return {
100
+ file: this.file(),
101
+ files: this.files(),
102
+ clearFile: fileInput.clearFile,
103
+ fileName: this.name(),
104
+ filesNames: this.names(),
105
+ multiple: this.multiple(),
106
+ };
107
+ });
108
+ }
109
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
110
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.0.1", 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\" \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}"], 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
+ }
112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileComponent, decorators: [{
113
+ type: Component,
114
+ args: [{ selector: 'file', standalone: true, imports: [
115
+ NgTemplateOutlet,
116
+ FileInputDirective,
117
+ ], 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}"] }]
118
+ }], ctorParameters: () => [] });
119
+ //# sourceMappingURL=file.component.js.map
@@ -0,0 +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;AAcH,MAAM,OAAO,aAAa;IAoGtB,iEAAiE;IACjE;QA5FA;;WAEG;QACO,SAAI,GAAwC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEnE;;WAEG;QACO,UAAK,GAA0C,MAAM,CAAC,IAAI,CAAC,CAAC;QAEtE;;WAEG;QACO,SAAI,GAA0C,MAAM,CAAC,IAAI,CAAC,CAAC;QAErE;;WAEG;QACO,UAAK,GAA4C,MAAM,CAAC,IAAI,CAAC,CAAC;QAExE,qFAAqF;QAErF;;WAEG;QACO,iBAAY,GAA6C,YAAY,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAAC,IAAI,EAAE,CAAA,WAAgC,CAAA,EAAC,CAAC,CAAC;QAE1J;;WAEG;QACO,cAAS,GAA+B,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEzF;;WAEG;QACO,eAAU,GAAsC,YAAY,CAAC,WAAW,CAAC,CAAC;QAEpF,gFAAgF;QAEhF;;WAEG;QACI,aAAQ,GAAsD,KAAK,CAA0B,KAAK,EAAE,EAAC,SAAS,EAAE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,EAAE;YAEjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAEnC,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;gBACnB,SAAS,EAAE,SAAS,CAAC,SAAS;gBAC9B,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE;gBACrB,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE;gBACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;aAC5B,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;8GAxIQ,aAAa;kGAAb,aAAa,m3BAkCmE,qBAAqB,2BAAS,WAAW,0EAU3D,WAAW,2GALb,kBAAkB,gEC9D3F,qsBAauC,wQDK/B,gBAAgB,oJAChB,kBAAkB;;2FAIb,aAAa;kBAbzB,SAAS;+BAEI,MAAM,cAGJ,IAAI,WAEhB;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 standalone: true,\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 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 fileName: this.name(),\n filesNames: this.names(),\n multiple: this.multiple(),\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()\">"]}
@@ -0,0 +1,62 @@
1
+ import { Component, ChangeDetectionStrategy, forwardRef, signal, input, computed } from '@angular/core';
2
+ import { NgClass } from '@angular/common';
3
+ import { FirstUppercaseLocalizeSAPipe, } from '@anglr/common';
4
+ import { FILE_VISUAL } from '../../misc/tokens';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Component that represents file input template
8
+ */
9
+ export class FileInputComponent {
10
+ //######################### constructor #########################
11
+ constructor() {
12
+ //######################### public properties - implementation of FileVisual #########################
13
+ /**
14
+ * @inheritdoc
15
+ */
16
+ this.fileTemplateContext = signal(null);
17
+ //######################### public properties - inputs #########################
18
+ /**
19
+ * Text to be displayed for file button
20
+ */
21
+ this.buttonText = input('browse');
22
+ /**
23
+ * Css classes applied to file button
24
+ */
25
+ this.buttonClass = input('btn btn-primary');
26
+ /**
27
+ * Css classes applied to file text, text displaying selected files
28
+ */
29
+ this.textClass = input('form-control');
30
+ /**
31
+ * Text to be displayed as selected
32
+ */
33
+ this.selectedText = input();
34
+ this.selectedTextValue = computed(() => {
35
+ const context = this.fileTemplateContext();
36
+ if (context?.multiple) {
37
+ return this.selectedText() ?? context.filesNames?.join(', ');
38
+ }
39
+ return this.selectedText() ?? context?.fileName;
40
+ });
41
+ }
42
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
43
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.0.1", type: FileInputComponent, isStandalone: true, selector: "file-input", inputs: { buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null }, buttonClass: { classPropertyName: "buttonClass", publicName: "buttonClass", isSignal: true, isRequired: false, transformFunction: null }, textClass: { classPropertyName: "textClass", publicName: "textClass", isSignal: true, isRequired: false, transformFunction: null }, selectedText: { classPropertyName: "selectedText", publicName: "selectedText", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
44
+ {
45
+ provide: FILE_VISUAL,
46
+ useExisting: forwardRef(() => FileInputComponent),
47
+ }
48
+ ], ngImport: i0, template: "<div class=\"file-input\">\n <div [ngClass]=\"buttonClass()\">\n <span>{{buttonText() | firstUppercaseLocalize}}</span>\n </div>\n\n <div [ngClass]=\"textClass()\">{{selectedTextValue()}}</div>\n</div>\n", styles: [":host\n{\n display: block;\n}\n\n.file-input\n{\n display: grid;\n\n grid-template-areas: 'button filename';\n grid-template-rows: auto;\n grid-template-columns: auto 1fr;\n\n :nth-child(1),\n :nth-child(1):before\n {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n\n :nth-child(2),\n :nth-child(2):before\n {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
49
+ }
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileInputComponent, decorators: [{
51
+ type: Component,
52
+ args: [{ selector: 'file-input', standalone: true, imports: [
53
+ NgClass,
54
+ FirstUppercaseLocalizeSAPipe,
55
+ ], providers: [
56
+ {
57
+ provide: FILE_VISUAL,
58
+ useExisting: forwardRef(() => FileInputComponent),
59
+ }
60
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"file-input\">\n <div [ngClass]=\"buttonClass()\">\n <span>{{buttonText() | firstUppercaseLocalize}}</span>\n </div>\n\n <div [ngClass]=\"textClass()\">{{selectedTextValue()}}</div>\n</div>\n", styles: [":host\n{\n display: block;\n}\n\n.file-input\n{\n display: grid;\n\n grid-template-areas: 'button filename';\n grid-template-rows: auto;\n grid-template-columns: auto 1fr;\n\n :nth-child(1),\n :nth-child(1):before\n {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n\n :nth-child(2),\n :nth-child(2):before\n {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n}\n"] }]
61
+ }], ctorParameters: () => [] });
62
+ //# sourceMappingURL=fileInput.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileInput.component.js","sourceRoot":"","sources":["../../../../../../src/modules/file/components/fileInput/fileInput.component.ts","../../../../../../src/modules/file/components/fileInput/fileInput.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAoB,UAAU,EAAkB,MAAM,EAAE,KAAK,EAAuB,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC7J,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,4BAA4B,GAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;;AAI9C;;GAEG;AAsBH,MAAM,OAAO,kBAAkB;IAsC3B,iEAAiE;IACjE;QA9BA,sGAAsG;QAEtG;;WAEG;QACI,wBAAmB,GAAuD,MAAM,CAAqC,IAAI,CAAC,CAAC;QAElI,gFAAgF;QAEhF;;WAEG;QACI,eAAU,GAAwB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEzD;;WAEG;QACI,gBAAW,GAAwB,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEnE;;WAEG;QACI,cAAS,GAAwB,KAAK,CAAC,cAAc,CAAC,CAAC;QAE9D;;WAEG;QACI,iBAAY,GAAuC,KAAK,EAAE,CAAC;QAK9D,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAC,GAAG,EAAE;YAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAE3C,IAAG,OAAO,EAAE,QAAQ,EACpB,CAAC;gBACG,OAAO,IAAI,CAAC,YAAY,EAAE,IAAI,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACjE,CAAC;YAED,OAAO,IAAI,CAAC,YAAY,EAAE,IAAI,OAAO,EAAE,QAAQ,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC;8GApDQ,kBAAkB;kGAAlB,kBAAkB,umBAT3B;YAEI;gBACI,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;aACpD;SACJ,0BC7BL,6NAOA,6gBDYQ,OAAO,+EACP,4BAA4B;;2FAYvB,kBAAkB;kBArB9B,SAAS;+BAEI,YAAY,cAGV,IAAI,WAEhB;wBACI,OAAO;wBACP,4BAA4B;qBAC/B,aAED;wBAEI;4BACI,OAAO,EAAE,WAAW;4BACpB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,mBAAmB,CAAC;yBACpD;qBACJ,mBACgB,uBAAuB,CAAC,MAAM","sourcesContent":["import {Component, ChangeDetectionStrategy, ExistingProvider, forwardRef, WritableSignal, signal, input, InputSignal, Signal, computed} from '@angular/core';\nimport {NgClass} from '@angular/common';\nimport {FirstUppercaseLocalizeSAPipe,} from '@anglr/common';\n\nimport {FILE_VISUAL} from '../../misc/tokens';\nimport {FileVisual} from '../../interfaces';\nimport {FileTemplateContext} from '../../directive';\n\n/**\n * Component that represents file input template\n */\n@Component(\n{\n selector: 'file-input',\n templateUrl: 'fileInput.component.html',\n styleUrl: 'fileInput.component.css',\n standalone: true,\n imports:\n [\n NgClass,\n FirstUppercaseLocalizeSAPipe,\n ],\n providers:\n [\n <ExistingProvider>\n {\n provide: FILE_VISUAL,\n useExisting: forwardRef(() => FileInputComponent),\n }\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class FileInputComponent implements FileVisual\n{\n //######################### protected properties - template bindings #########################\n\n /**\n * Selected text value based on file template context or selected text input\n */\n protected selectedTextValue: Signal<string|undefined|null>;\n \n //######################### public properties - implementation of FileVisual #########################\n\n /**\n * @inheritdoc\n */\n public fileTemplateContext: WritableSignal<FileTemplateContext|undefined|null> = signal<FileTemplateContext|undefined|null>(null);\n\n //######################### public properties - inputs #########################\n\n /**\n * Text to be displayed for file button\n */\n public buttonText: InputSignal<string> = input('browse');\n\n /**\n * Css classes applied to file button\n */\n public buttonClass: InputSignal<string> = input('btn btn-primary');\n\n /**\n * Css classes applied to file text, text displaying selected files\n */\n public textClass: InputSignal<string> = input('form-control');\n\n /**\n * Text to be displayed as selected\n */\n public selectedText: InputSignal<string|undefined|null> = input();\n\n //######################### constructor #########################\n constructor()\n {\n this.selectedTextValue = computed(() =>\n {\n const context = this.fileTemplateContext();\n\n if(context?.multiple)\n {\n return this.selectedText() ?? context.filesNames?.join(', ');\n }\n\n return this.selectedText() ?? context?.fileName;\n });\n }\n}","<div class=\"file-input\">\n <div [ngClass]=\"buttonClass()\">\n <span>{{buttonText() | firstUppercaseLocalize}}</span>\n </div>\n\n <div [ngClass]=\"textClass()\">{{selectedTextValue()}}</div>\n</div>\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './file/file.component';
2
+ export * from './fileInput/fileInput.component';
3
+ export * from './uploadButton/uploadButton.component';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/file/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC","sourcesContent":["export * from './file/file.component';\nexport * from './fileInput/fileInput.component';\nexport * from './uploadButton/uploadButton.component';\n"]}
@@ -0,0 +1,59 @@
1
+ import { Component, ChangeDetectionStrategy, forwardRef, signal, input, numberAttribute } from '@angular/core';
2
+ import { NgClass } from '@angular/common';
3
+ import { IsPresentPipe, LocalizeSAPipe } from '@anglr/common';
4
+ import { FILE_VISUAL } from '../../misc/tokens';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Component that represents upload button file template
8
+ */
9
+ export class UploadButtonComponent {
10
+ constructor() {
11
+ //######################### public properties - implementation of FileVisual #########################
12
+ /**
13
+ * @inheritdoc
14
+ */
15
+ this.fileTemplateContext = signal(null);
16
+ //######################### public properties - inputs #########################
17
+ /**
18
+ * Css classes applied tu button icon
19
+ */
20
+ this.uploadIconClass = input('fas fa-file-upload');
21
+ /**
22
+ * Text to be displayed as button text
23
+ */
24
+ this.uploadText = input('');
25
+ /**
26
+ * Css classes for displayed text for button
27
+ */
28
+ this.uploadTextClass = input('first-letter-uppercase');
29
+ /**
30
+ * Css class applied to button
31
+ */
32
+ this.cssClass = input('btn btn-icon', { alias: 'class' });
33
+ /**
34
+ * Current progress to be displayed
35
+ */
36
+ this.progress = input(null, { transform: numberAttribute });
37
+ }
38
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: UploadButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.0.1", type: UploadButtonComponent, isStandalone: true, selector: "upload-button", inputs: { uploadIconClass: { classPropertyName: "uploadIconClass", publicName: "uploadIconClass", isSignal: true, isRequired: false, transformFunction: null }, uploadText: { classPropertyName: "uploadText", publicName: "uploadText", isSignal: true, isRequired: false, transformFunction: null }, uploadTextClass: { classPropertyName: "uploadTextClass", publicName: "uploadTextClass", isSignal: true, isRequired: false, transformFunction: null }, cssClass: { classPropertyName: "cssClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, progress: { classPropertyName: "progress", publicName: "progress", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
40
+ {
41
+ provide: FILE_VISUAL,
42
+ useExisting: forwardRef(() => UploadButtonComponent),
43
+ }
44
+ ], ngImport: i0, template: "@if(progress() | isPresent)\n{\n <div class=\"progress\">\n <span class=\"progress-value\">{{progress()}}%</span>\n <div class=\"progress-indicator\"></div>\n </div>\n}\n\n<button [ngClass]=\"cssClass()\" type=\"button\">\n <span [ngClass]=\"uploadIconClass()\"></span>\n \n @if(uploadText())\n {\n <span [ngClass]=\"uploadTextClass()\">{{uploadText() | localize}}</span>\n }\n</button>", styles: [":host\n{\n display: flex;\n flex-direction: row;\n}\n\n.progress\n{\n font-size: 0.75em;\n position: relative;\n width: 33px;\n height: 33px;\n text-align: center;\n margin-right: 4px;\n display: flex;\n justify-content: center;\n}\n\n.progress-value\n{\n align-self: center;\n}\n\n.progress-indicator\n{\n position: absolute;\n width: 33px;\n height: 16.5px;\n top: 0;\n left: 0;\n border: 2px solid #009dd6;\n border-bottom: none;\n border-top-left-radius: 100px;\n border-top-right-radius: 100px;\n animation-name: rotate-progress;\n animation-duration: 550ms;\n animation-iteration-count: infinite;\n animation-timing-function: linear;\n transform-origin: calc(50%) calc(50% + 8.25px);\n}\n\n@keyframes rotate-progress\n{\n from\n {\n transform: rotate(0deg);\n }\n to\n {\n transform: rotate(360deg);\n }\n}"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: IsPresentPipe, name: "isPresent" }, { kind: "pipe", type: LocalizeSAPipe, name: "localize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
45
+ }
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: UploadButtonComponent, decorators: [{
47
+ type: Component,
48
+ args: [{ selector: 'upload-button', standalone: true, imports: [
49
+ NgClass,
50
+ IsPresentPipe,
51
+ LocalizeSAPipe,
52
+ ], providers: [
53
+ {
54
+ provide: FILE_VISUAL,
55
+ useExisting: forwardRef(() => UploadButtonComponent),
56
+ }
57
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if(progress() | isPresent)\n{\n <div class=\"progress\">\n <span class=\"progress-value\">{{progress()}}%</span>\n <div class=\"progress-indicator\"></div>\n </div>\n}\n\n<button [ngClass]=\"cssClass()\" type=\"button\">\n <span [ngClass]=\"uploadIconClass()\"></span>\n \n @if(uploadText())\n {\n <span [ngClass]=\"uploadTextClass()\">{{uploadText() | localize}}</span>\n }\n</button>", styles: [":host\n{\n display: flex;\n flex-direction: row;\n}\n\n.progress\n{\n font-size: 0.75em;\n position: relative;\n width: 33px;\n height: 33px;\n text-align: center;\n margin-right: 4px;\n display: flex;\n justify-content: center;\n}\n\n.progress-value\n{\n align-self: center;\n}\n\n.progress-indicator\n{\n position: absolute;\n width: 33px;\n height: 16.5px;\n top: 0;\n left: 0;\n border: 2px solid #009dd6;\n border-bottom: none;\n border-top-left-radius: 100px;\n border-top-right-radius: 100px;\n animation-name: rotate-progress;\n animation-duration: 550ms;\n animation-iteration-count: infinite;\n animation-timing-function: linear;\n transform-origin: calc(50%) calc(50% + 8.25px);\n}\n\n@keyframes rotate-progress\n{\n from\n {\n transform: rotate(0deg);\n }\n to\n {\n transform: rotate(360deg);\n }\n}"] }]
58
+ }] });
59
+ //# sourceMappingURL=uploadButton.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadButton.component.js","sourceRoot":"","sources":["../../../../../../src/modules/file/components/uploadButton/uploadButton.component.ts","../../../../../../src/modules/file/components/uploadButton/uploadButton.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAoB,UAAU,EAAkB,MAAM,EAAe,KAAK,EAAE,eAAe,EAA2B,MAAM,eAAe,CAAC;AACtL,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;;AAI9C;;GAEG;AAuBH,MAAM,OAAO,qBAAqB;IAtBlC;QAwBI,sGAAsG;QAEtG;;WAEG;QACI,wBAAmB,GAAuD,MAAM,CAAqC,IAAI,CAAC,CAAC;QAElI,gFAAgF;QAEhF;;WAEG;QACI,oBAAe,GAAwB,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAE1E;;WAEG;QACI,eAAU,GAAwB,KAAK,CAAC,EAAE,CAAC,CAAC;QAEnD;;WAEG;QACI,oBAAe,GAAwB,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE9E;;WAEG;QACI,aAAQ,GAAwB,KAAK,CAAC,cAAc,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC,CAAC;QAE/E;;WAEG;QACI,aAAQ,GAAkF,KAAK,CAAsD,IAAI,EAAE,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC,CAAC;KACnM;8GAnCY,qBAAqB;kGAArB,qBAAqB,0vBAT9B;YAEI;gBACI,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC;aACvD;SACJ,0BC9BL,8aAeS,i9BDID,OAAO,+EACP,aAAa,6CACb,cAAc;;2FAYT,qBAAqB;kBAtBjC,SAAS;+BAEI,eAAe,cAGb,IAAI,WAEhB;wBACI,OAAO;wBACP,aAAa;wBACb,cAAc;qBACjB,aAED;wBAEI;4BACI,OAAO,EAAE,WAAW;4BACpB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,sBAAsB,CAAC;yBACvD;qBACJ,mBACgB,uBAAuB,CAAC,MAAM","sourcesContent":["import {Component, ChangeDetectionStrategy, ExistingProvider, forwardRef, WritableSignal, signal, InputSignal, input, numberAttribute, InputSignalWithTransform} from '@angular/core';\nimport {NgClass} from '@angular/common';\nimport {IsPresentPipe, LocalizeSAPipe} from '@anglr/common';\n\nimport {FILE_VISUAL} from '../../misc/tokens';\nimport {FileVisual} from '../../interfaces';\nimport {FileTemplateContext} from '../../directive';\n\n/**\n * Component that represents upload button file template\n */\n@Component(\n{\n selector: 'upload-button',\n templateUrl: 'uploadButton.component.html',\n styleUrl: 'uploadButton.component.css',\n standalone: true,\n imports:\n [\n NgClass,\n IsPresentPipe,\n LocalizeSAPipe,\n ],\n providers:\n [\n <ExistingProvider>\n {\n provide: FILE_VISUAL,\n useExisting: forwardRef(() => UploadButtonComponent),\n }\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class UploadButtonComponent implements FileVisual\n{\n //######################### public properties - implementation of FileVisual #########################\n\n /**\n * @inheritdoc\n */\n public fileTemplateContext: WritableSignal<FileTemplateContext|undefined|null> = signal<FileTemplateContext|undefined|null>(null);\n\n //######################### public properties - inputs #########################\n\n /**\n * Css classes applied tu button icon\n */\n public uploadIconClass: InputSignal<string> = input('fas fa-file-upload');\n\n /**\n * Text to be displayed as button text\n */\n public uploadText: InputSignal<string> = input('');\n\n /**\n * Css classes for displayed text for button\n */\n public uploadTextClass: InputSignal<string> = input('first-letter-uppercase');\n\n /**\n * Css class applied to button\n */\n public cssClass: InputSignal<string> = input('btn btn-icon', {alias: 'class'});\n\n /**\n * Current progress to be displayed\n */\n public progress: InputSignalWithTransform<number|undefined|null, number|string|undefined|null> = input<number|undefined|null, number|string|undefined|null>(null, {transform: numberAttribute});\n}","@if(progress() | isPresent)\n{\n <div class=\"progress\">\n <span class=\"progress-value\">{{progress()}}%</span>\n <div class=\"progress-indicator\"></div>\n </div>\n}\n\n<button [ngClass]=\"cssClass()\" type=\"button\">\n <span [ngClass]=\"uploadIconClass()\"></span>\n \n @if(uploadText())\n {\n <span [ngClass]=\"uploadTextClass()\">{{uploadText() | localize}}</span>\n }\n</button>"]}
@@ -0,0 +1,154 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { booleanAttribute, Directive, effect, ElementRef, input, output, Renderer2 } from '@angular/core';
3
+ import { BindThis, isString } from '@jscrpt/common';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Directive that allows better communication with input file
7
+ */
8
+ export class FileInputDirective {
9
+ //######################### constructors #########################
10
+ constructor(element, renderer) {
11
+ this.element = element;
12
+ //######################### public properties - inputs #########################
13
+ /**
14
+ * Indication whether is multiple files selection enabled
15
+ */
16
+ this.multiple = input(false, { transform: booleanAttribute });
17
+ /**
18
+ * Indication whether read file content, working only when `multiple` is not set (for single file)
19
+ */
20
+ this.readContent = input(false, { transform: booleanAttribute });
21
+ /**
22
+ * Indication whether content of file is binary and it will be read as ArrayBuffer instead of string
23
+ */
24
+ this.binaryContent = input(false, { transform: booleanAttribute });
25
+ /**
26
+ * Text encoding of read string file content
27
+ */
28
+ this.textEncoding = input();
29
+ //######################### public properties - outputs #########################
30
+ /**
31
+ * Occurs when file changes and `binaryContent` is not set and `readContent` is set
32
+ */
33
+ this.stringContentChange = output();
34
+ /**
35
+ * Occurs when file changes and `binaryContent` is set and `readContent` is set
36
+ */
37
+ this.arrayBufferContentChange = output();
38
+ /**
39
+ * Occurs when selected file changes, occurs only when `multiple` is not set
40
+ */
41
+ this.fileChange = output();
42
+ /**
43
+ * Occurs when selected files changes, occurs only when `multiple` is set
44
+ */
45
+ this.filesChange = output();
46
+ /**
47
+ * Occurs when selected file changes, occurs only when `multiple` is not set, contains name of selected file
48
+ */
49
+ this.fileName = output();
50
+ /**
51
+ * Occurs when selected files changes, occurs only when `multiple` is set, contains names of selected files
52
+ */
53
+ this.filesNames = output();
54
+ this.changeListenerUnlisten = renderer.listen(element.nativeElement, 'change', this.handleFileChange);
55
+ effect(() => renderer.setProperty(element.nativeElement, 'multiple', this.multiple()));
56
+ }
57
+ //######################### public methods - implementation of OnDestroy #########################
58
+ /**
59
+ * @inheritdoc
60
+ */
61
+ ngOnDestroy() {
62
+ this.changeListenerUnlisten();
63
+ }
64
+ //######################### public methods #########################
65
+ /**
66
+ * Clears selection of file/files
67
+ */
68
+ clearFile() {
69
+ this.element.nativeElement.value = '';
70
+ this.fileChange.emit(null);
71
+ this.fileName.emit(null);
72
+ this.filesChange.emit(null);
73
+ this.filesNames.emit(null);
74
+ this.arrayBufferContentChange.emit(null);
75
+ this.stringContentChange.emit(null);
76
+ }
77
+ //######################### protected methods #########################
78
+ /**
79
+ * Handles changes in file input
80
+ */
81
+ handleFileChange(event) {
82
+ if (!event.target) {
83
+ throw new Error('FileOutputDirective: missing input file target!');
84
+ }
85
+ if (this.multiple()) {
86
+ const files = event.target.files;
87
+ const filesArray = [];
88
+ if (files) {
89
+ for (let x = 0; x < files.length; x++) {
90
+ filesArray.push(files[x]);
91
+ }
92
+ }
93
+ this.filesChange.emit(filesArray);
94
+ this.filesNames.emit(filesArray.map(itm => itm.name));
95
+ }
96
+ else {
97
+ const file = event.target.files?.[0];
98
+ this.fileChange.emit(file);
99
+ this.fileName.emit(file?.name);
100
+ }
101
+ //read file contents
102
+ if (!this.multiple() && this.readContent()) {
103
+ const file = event.target.files?.[0];
104
+ //no file selected
105
+ if (!file) {
106
+ return;
107
+ }
108
+ const fileReader = new FileReader();
109
+ fileReader.onloadend = () => {
110
+ const result = fileReader.result;
111
+ if (!result) {
112
+ this.stringContentChange.emit(null);
113
+ this.arrayBufferContentChange.emit(null);
114
+ return;
115
+ }
116
+ if (isString(result)) {
117
+ this.stringContentChange.emit(result);
118
+ }
119
+ else {
120
+ this.arrayBufferContentChange.emit(result);
121
+ }
122
+ };
123
+ if (this.binaryContent()) {
124
+ fileReader.readAsArrayBuffer(file);
125
+ }
126
+ else {
127
+ fileReader.readAsText(file, this.textEncoding());
128
+ }
129
+ }
130
+ }
131
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileInputDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
132
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.1", 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
+ }
134
+ __decorate([
135
+ BindThis,
136
+ __metadata("design:type", Function),
137
+ __metadata("design:paramtypes", []),
138
+ __metadata("design:returntype", void 0)
139
+ ], FileInputDirective.prototype, "clearFile", null);
140
+ __decorate([
141
+ BindThis,
142
+ __metadata("design:type", Function),
143
+ __metadata("design:paramtypes", [MouseEvent]),
144
+ __metadata("design:returntype", void 0)
145
+ ], FileInputDirective.prototype, "handleFileChange", null);
146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: FileInputDirective, decorators: [{
147
+ type: Directive,
148
+ args: [{
149
+ selector: 'input[type=file]',
150
+ exportAs: 'file',
151
+ standalone: true,
152
+ }]
153
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { clearFile: [], handleFileChange: [] } });
154
+ //# sourceMappingURL=fileInput.directive.js.map
@@ -0,0 +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,EAAC,QAAQ,EAAE,QAAQ,EAAa,MAAM,gBAAgB,CAAC;;AAE9D;;GAEG;AAOH,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;Q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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;8GApLQ,kBAAkB;kGAAlB,kBAAkB;;AAwFpB;IADN,QAAQ;;;;mDAUR;AAQS;IADT,QAAQ;;qCACyB,UAAU;;0DA2E3C;2FApLQ,kBAAkB;kBAN9B,SAAS;mBACV;oBACI,QAAQ,EAAE,kBAAkB;oBAC5B,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,IAAI;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 standalone: true,\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}"]}