@skyux/forms 5.9.4 → 6.0.0-beta.10

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 (168) hide show
  1. package/documentation.json +693 -693
  2. package/esm2020/index.mjs +43 -0
  3. package/esm2020/lib/modules/character-counter/character-counter-indicator.component.mjs +32 -0
  4. package/esm2020/lib/modules/character-counter/character-counter.directive.mjs +84 -0
  5. package/esm2020/lib/modules/character-counter/character-counter.module.mjs +46 -0
  6. package/esm2020/lib/modules/checkbox/checkbox-change.mjs +6 -0
  7. package/esm2020/lib/modules/checkbox/checkbox-label.component.mjs +14 -0
  8. package/esm2020/lib/modules/checkbox/checkbox-required-validator.directive.mjs +30 -0
  9. package/esm2020/lib/modules/checkbox/checkbox.component.mjs +237 -0
  10. package/esm2020/lib/modules/checkbox/checkbox.module.mjs +34 -0
  11. package/esm2020/lib/modules/file-attachment/file-attachment-label.component.mjs +14 -0
  12. package/esm2020/lib/modules/file-attachment/file-attachment.component.mjs +326 -0
  13. package/esm2020/lib/modules/file-attachment/file-attachment.service.mjs +94 -0
  14. package/esm2020/lib/modules/file-attachment/file-attachments.module.mjs +68 -0
  15. package/esm2020/lib/modules/file-attachment/file-drop.component.mjs +216 -0
  16. package/esm2020/lib/modules/file-attachment/file-item-error-type.mjs +2 -0
  17. package/esm2020/lib/modules/file-attachment/file-item.component.mjs +112 -0
  18. package/esm2020/lib/modules/file-attachment/file-item.mjs +2 -0
  19. package/esm2020/lib/modules/file-attachment/file-item.service.mjs +70 -0
  20. package/esm2020/lib/modules/file-attachment/file-link.mjs +2 -0
  21. package/esm2020/lib/modules/file-attachment/file-size.pipe.mjs +58 -0
  22. package/esm2020/lib/modules/file-attachment/types/file-attachment-change.mjs +2 -0
  23. package/esm2020/lib/modules/file-attachment/types/file-attachment-click.mjs +2 -0
  24. package/esm2020/lib/modules/file-attachment/types/file-drop-change.mjs +2 -0
  25. package/esm2020/lib/modules/input-box/input-box-adapter.service.mjs +35 -0
  26. package/esm2020/lib/modules/input-box/input-box-host.service.mjs +19 -0
  27. package/esm2020/lib/modules/input-box/input-box-populate-args.mjs +2 -0
  28. package/esm2020/lib/modules/input-box/input-box.component.mjs +89 -0
  29. package/esm2020/lib/modules/input-box/input-box.module.mjs +19 -0
  30. package/esm2020/lib/modules/radio/radio-group.component.mjs +220 -0
  31. package/esm2020/lib/modules/radio/radio-label.component.mjs +23 -0
  32. package/esm2020/lib/modules/radio/radio.component.mjs +254 -0
  33. package/esm2020/lib/modules/radio/radio.module.mjs +28 -0
  34. package/esm2020/lib/modules/radio/types/radio-change.mjs +2 -0
  35. package/esm2020/lib/modules/selection-box/selection-box-adapter.service.mjs +123 -0
  36. package/esm2020/lib/modules/selection-box/selection-box-description.component.mjs +14 -0
  37. package/esm2020/lib/modules/selection-box/selection-box-grid.component.mjs +128 -0
  38. package/esm2020/lib/modules/selection-box/selection-box-header.component.mjs +14 -0
  39. package/esm2020/lib/modules/selection-box/selection-box.component.mjs +101 -0
  40. package/esm2020/lib/modules/selection-box/selection-box.module.mjs +40 -0
  41. package/esm2020/lib/modules/selection-box/types/selection-box-grid-align-items-type.mjs +2 -0
  42. package/esm2020/lib/modules/selection-box/types/selection-box-grid-align-items.mjs +2 -0
  43. package/esm2020/lib/modules/shared/forms-utility.mjs +26 -0
  44. package/esm2020/lib/modules/shared/sky-forms-resources.module.mjs +89 -0
  45. package/esm2020/lib/modules/toggle-switch/toggle-switch-label.component.mjs +14 -0
  46. package/esm2020/lib/modules/toggle-switch/toggle-switch.component.mjs +151 -0
  47. package/esm2020/lib/modules/toggle-switch/toggle-switch.module.mjs +20 -0
  48. package/esm2020/lib/modules/toggle-switch/types/toggle-switch-change.mjs +2 -0
  49. package/esm2020/skyux-forms.mjs +5 -0
  50. package/esm2020/testing/checkbox-fixture.mjs +88 -0
  51. package/esm2020/testing/public-api.mjs +2 -0
  52. package/esm2020/testing/skyux-forms-testing.mjs +5 -0
  53. package/fesm2015/{skyux-forms-testing.js → skyux-forms-testing.mjs} +1 -1
  54. package/fesm2015/skyux-forms-testing.mjs.map +1 -0
  55. package/fesm2015/skyux-forms.mjs +2684 -0
  56. package/fesm2015/skyux-forms.mjs.map +1 -0
  57. package/{esm2015/testing/checkbox-fixture.js → fesm2020/skyux-forms-testing.mjs} +9 -2
  58. package/fesm2020/skyux-forms-testing.mjs.map +1 -0
  59. package/fesm2020/skyux-forms.mjs +2676 -0
  60. package/fesm2020/skyux-forms.mjs.map +1 -0
  61. package/package.json +39 -15
  62. package/testing/package.json +5 -5
  63. package/bundles/skyux-forms-testing.umd.js +0 -123
  64. package/bundles/skyux-forms.umd.js +0 -3430
  65. package/esm2015/index.js +0 -43
  66. package/esm2015/index.js.map +0 -1
  67. package/esm2015/lib/modules/character-counter/character-counter-indicator.component.js +0 -37
  68. package/esm2015/lib/modules/character-counter/character-counter-indicator.component.js.map +0 -1
  69. package/esm2015/lib/modules/character-counter/character-counter.directive.js +0 -84
  70. package/esm2015/lib/modules/character-counter/character-counter.directive.js.map +0 -1
  71. package/esm2015/lib/modules/character-counter/character-counter.module.js +0 -46
  72. package/esm2015/lib/modules/character-counter/character-counter.module.js.map +0 -1
  73. package/esm2015/lib/modules/checkbox/checkbox-change.js +0 -6
  74. package/esm2015/lib/modules/checkbox/checkbox-change.js.map +0 -1
  75. package/esm2015/lib/modules/checkbox/checkbox-label.component.js +0 -17
  76. package/esm2015/lib/modules/checkbox/checkbox-label.component.js.map +0 -1
  77. package/esm2015/lib/modules/checkbox/checkbox-required-validator.directive.js +0 -32
  78. package/esm2015/lib/modules/checkbox/checkbox-required-validator.directive.js.map +0 -1
  79. package/esm2015/lib/modules/checkbox/checkbox.component.js +0 -241
  80. package/esm2015/lib/modules/checkbox/checkbox.component.js.map +0 -1
  81. package/esm2015/lib/modules/checkbox/checkbox.module.js +0 -34
  82. package/esm2015/lib/modules/checkbox/checkbox.module.js.map +0 -1
  83. package/esm2015/lib/modules/file-attachment/file-attachment-label.component.js +0 -19
  84. package/esm2015/lib/modules/file-attachment/file-attachment-label.component.js.map +0 -1
  85. package/esm2015/lib/modules/file-attachment/file-attachment.component.js +0 -335
  86. package/esm2015/lib/modules/file-attachment/file-attachment.component.js.map +0 -1
  87. package/esm2015/lib/modules/file-attachment/file-attachment.service.js +0 -94
  88. package/esm2015/lib/modules/file-attachment/file-attachment.service.js.map +0 -1
  89. package/esm2015/lib/modules/file-attachment/file-attachments.module.js +0 -68
  90. package/esm2015/lib/modules/file-attachment/file-attachments.module.js.map +0 -1
  91. package/esm2015/lib/modules/file-attachment/file-drop.component.js +0 -222
  92. package/esm2015/lib/modules/file-attachment/file-drop.component.js.map +0 -1
  93. package/esm2015/lib/modules/file-attachment/file-item-error-type.js +0 -2
  94. package/esm2015/lib/modules/file-attachment/file-item-error-type.js.map +0 -1
  95. package/esm2015/lib/modules/file-attachment/file-item.component.js +0 -116
  96. package/esm2015/lib/modules/file-attachment/file-item.component.js.map +0 -1
  97. package/esm2015/lib/modules/file-attachment/file-item.js +0 -2
  98. package/esm2015/lib/modules/file-attachment/file-item.js.map +0 -1
  99. package/esm2015/lib/modules/file-attachment/file-item.service.js +0 -72
  100. package/esm2015/lib/modules/file-attachment/file-item.service.js.map +0 -1
  101. package/esm2015/lib/modules/file-attachment/file-link.js +0 -2
  102. package/esm2015/lib/modules/file-attachment/file-link.js.map +0 -1
  103. package/esm2015/lib/modules/file-attachment/file-size.pipe.js +0 -60
  104. package/esm2015/lib/modules/file-attachment/file-size.pipe.js.map +0 -1
  105. package/esm2015/lib/modules/file-attachment/types/file-attachment-change.js +0 -2
  106. package/esm2015/lib/modules/file-attachment/types/file-attachment-change.js.map +0 -1
  107. package/esm2015/lib/modules/file-attachment/types/file-attachment-click.js +0 -2
  108. package/esm2015/lib/modules/file-attachment/types/file-attachment-click.js.map +0 -1
  109. package/esm2015/lib/modules/file-attachment/types/file-drop-change.js +0 -2
  110. package/esm2015/lib/modules/file-attachment/types/file-drop-change.js.map +0 -1
  111. package/esm2015/lib/modules/input-box/input-box-adapter.service.js +0 -35
  112. package/esm2015/lib/modules/input-box/input-box-adapter.service.js.map +0 -1
  113. package/esm2015/lib/modules/input-box/input-box-host.service.js +0 -19
  114. package/esm2015/lib/modules/input-box/input-box-host.service.js.map +0 -1
  115. package/esm2015/lib/modules/input-box/input-box-populate-args.js +0 -2
  116. package/esm2015/lib/modules/input-box/input-box-populate-args.js.map +0 -1
  117. package/esm2015/lib/modules/input-box/input-box.component.js +0 -97
  118. package/esm2015/lib/modules/input-box/input-box.component.js.map +0 -1
  119. package/esm2015/lib/modules/input-box/input-box.module.js +0 -19
  120. package/esm2015/lib/modules/input-box/input-box.module.js.map +0 -1
  121. package/esm2015/lib/modules/radio/radio-group.component.js +0 -223
  122. package/esm2015/lib/modules/radio/radio-group.component.js.map +0 -1
  123. package/esm2015/lib/modules/radio/radio-label.component.js +0 -26
  124. package/esm2015/lib/modules/radio/radio-label.component.js.map +0 -1
  125. package/esm2015/lib/modules/radio/radio.component.js +0 -262
  126. package/esm2015/lib/modules/radio/radio.component.js.map +0 -1
  127. package/esm2015/lib/modules/radio/radio.module.js +0 -28
  128. package/esm2015/lib/modules/radio/radio.module.js.map +0 -1
  129. package/esm2015/lib/modules/radio/types/radio-change.js +0 -2
  130. package/esm2015/lib/modules/radio/types/radio-change.js.map +0 -1
  131. package/esm2015/lib/modules/selection-box/selection-box-adapter.service.js +0 -124
  132. package/esm2015/lib/modules/selection-box/selection-box-adapter.service.js.map +0 -1
  133. package/esm2015/lib/modules/selection-box/selection-box-description.component.js +0 -17
  134. package/esm2015/lib/modules/selection-box/selection-box-description.component.js.map +0 -1
  135. package/esm2015/lib/modules/selection-box/selection-box-grid.component.js +0 -134
  136. package/esm2015/lib/modules/selection-box/selection-box-grid.component.js.map +0 -1
  137. package/esm2015/lib/modules/selection-box/selection-box-header.component.js +0 -17
  138. package/esm2015/lib/modules/selection-box/selection-box-header.component.js.map +0 -1
  139. package/esm2015/lib/modules/selection-box/selection-box.component.js +0 -107
  140. package/esm2015/lib/modules/selection-box/selection-box.component.js.map +0 -1
  141. package/esm2015/lib/modules/selection-box/selection-box.module.js +0 -40
  142. package/esm2015/lib/modules/selection-box/selection-box.module.js.map +0 -1
  143. package/esm2015/lib/modules/selection-box/types/selection-box-grid-align-items-type.js +0 -2
  144. package/esm2015/lib/modules/selection-box/types/selection-box-grid-align-items-type.js.map +0 -1
  145. package/esm2015/lib/modules/selection-box/types/selection-box-grid-align-items.js +0 -2
  146. package/esm2015/lib/modules/selection-box/types/selection-box-grid-align-items.js.map +0 -1
  147. package/esm2015/lib/modules/shared/forms-utility.js +0 -26
  148. package/esm2015/lib/modules/shared/forms-utility.js.map +0 -1
  149. package/esm2015/lib/modules/shared/sky-forms-resources.module.js +0 -89
  150. package/esm2015/lib/modules/shared/sky-forms-resources.module.js.map +0 -1
  151. package/esm2015/lib/modules/toggle-switch/toggle-switch-label.component.js +0 -18
  152. package/esm2015/lib/modules/toggle-switch/toggle-switch-label.component.js.map +0 -1
  153. package/esm2015/lib/modules/toggle-switch/toggle-switch.component.js +0 -159
  154. package/esm2015/lib/modules/toggle-switch/toggle-switch.component.js.map +0 -1
  155. package/esm2015/lib/modules/toggle-switch/toggle-switch.module.js +0 -20
  156. package/esm2015/lib/modules/toggle-switch/toggle-switch.module.js.map +0 -1
  157. package/esm2015/lib/modules/toggle-switch/types/toggle-switch-change.js +0 -2
  158. package/esm2015/lib/modules/toggle-switch/types/toggle-switch-change.js.map +0 -1
  159. package/esm2015/skyux-forms.js +0 -5
  160. package/esm2015/skyux-forms.js.map +0 -1
  161. package/esm2015/testing/checkbox-fixture.js.map +0 -1
  162. package/esm2015/testing/public-api.js +0 -2
  163. package/esm2015/testing/public-api.js.map +0 -1
  164. package/esm2015/testing/skyux-forms-testing.js +0 -5
  165. package/esm2015/testing/skyux-forms-testing.js.map +0 -1
  166. package/fesm2015/skyux-forms-testing.js.map +0 -1
  167. package/fesm2015/skyux-forms.js +0 -2771
  168. package/fesm2015/skyux-forms.js.map +0 -1
@@ -1,34 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { FormsModule } from '@angular/forms';
4
- import { SkyIconModule } from '@skyux/indicators';
5
- import { SkyCheckboxLabelComponent } from './checkbox-label.component';
6
- import { SkyCheckboxRequiredValidatorDirective } from './checkbox-required-validator.directive';
7
- import { SkyCheckboxComponent } from './checkbox.component';
8
- import * as i0 from "@angular/core";
9
- export class SkyCheckboxModule {
10
- }
11
- SkyCheckboxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
12
- SkyCheckboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCheckboxModule, declarations: [SkyCheckboxComponent,
13
- SkyCheckboxLabelComponent,
14
- SkyCheckboxRequiredValidatorDirective], imports: [CommonModule, FormsModule, SkyIconModule], exports: [SkyCheckboxComponent,
15
- SkyCheckboxLabelComponent,
16
- SkyCheckboxRequiredValidatorDirective] });
17
- SkyCheckboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCheckboxModule, imports: [[CommonModule, FormsModule, SkyIconModule]] });
18
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCheckboxModule, decorators: [{
19
- type: NgModule,
20
- args: [{
21
- declarations: [
22
- SkyCheckboxComponent,
23
- SkyCheckboxLabelComponent,
24
- SkyCheckboxRequiredValidatorDirective,
25
- ],
26
- imports: [CommonModule, FormsModule, SkyIconModule],
27
- exports: [
28
- SkyCheckboxComponent,
29
- SkyCheckboxLabelComponent,
30
- SkyCheckboxRequiredValidatorDirective,
31
- ],
32
- }]
33
- }] });
34
- //# sourceMappingURL=checkbox.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkbox.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/checkbox/checkbox.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;;AAe5D,MAAM,OAAO,iBAAiB;;+GAAjB,iBAAiB;gHAAjB,iBAAiB,iBAX1B,oBAAoB;QACpB,yBAAyB;QACzB,qCAAqC,aAE7B,YAAY,EAAE,WAAW,EAAE,aAAa,aAEhD,oBAAoB;QACpB,yBAAyB;QACzB,qCAAqC;gHAG5B,iBAAiB,YAPnB,CAAC,YAAY,EAAE,WAAW,EAAE,aAAa,CAAC;4FAOxC,iBAAiB;kBAb7B,QAAQ;mBAAC;oBACR,YAAY,EAAE;wBACZ,oBAAoB;wBACpB,yBAAyB;wBACzB,qCAAqC;qBACtC;oBACD,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,aAAa,CAAC;oBACnD,OAAO,EAAE;wBACP,oBAAoB;wBACpB,yBAAyB;wBACzB,qCAAqC;qBACtC;iBACF","sourcesContent":["import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { SkyIconModule } from '@skyux/indicators';\n\nimport { SkyCheckboxLabelComponent } from './checkbox-label.component';\nimport { SkyCheckboxRequiredValidatorDirective } from './checkbox-required-validator.directive';\nimport { SkyCheckboxComponent } from './checkbox.component';\n\n@NgModule({\n declarations: [\n SkyCheckboxComponent,\n SkyCheckboxLabelComponent,\n SkyCheckboxRequiredValidatorDirective,\n ],\n imports: [CommonModule, FormsModule, SkyIconModule],\n exports: [\n SkyCheckboxComponent,\n SkyCheckboxLabelComponent,\n SkyCheckboxRequiredValidatorDirective,\n ],\n})\nexport class SkyCheckboxModule {}\n"]}
@@ -1,19 +0,0 @@
1
- import { ChangeDetectionStrategy, Component } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * Displays a label above the file attachment element.
5
- */
6
- export class SkyFileAttachmentLabelComponent {
7
- }
8
- SkyFileAttachmentLabelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
9
- SkyFileAttachmentLabelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyFileAttachmentLabelComponent, selector: "sky-file-attachment-label", ngImport: i0, template: "<span class=\"sky-control-label\">\n <ng-content></ng-content>\n</span>\n", styles: [":host-context(.sky-theme-modern) .sky-control-label{color:#686c73;font-size:13px}.sky-theme-modern .sky-control-label{color:#686c73;font-size:13px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
10
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentLabelComponent, decorators: [{
11
- type: Component,
12
- args: [{
13
- selector: 'sky-file-attachment-label',
14
- templateUrl: './file-attachment-label.component.html',
15
- styleUrls: ['file-attachment-label.component.scss'],
16
- changeDetection: ChangeDetectionStrategy.OnPush,
17
- }]
18
- }] });
19
- //# sourceMappingURL=file-attachment-label.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-attachment-label.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-attachment-label.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-attachment-label.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;AAEnE;;GAEG;AAOH,MAAM,OAAO,+BAA+B;;6HAA/B,+BAA+B;iHAA/B,+BAA+B,iECX5C,4EAGA;4FDQa,+BAA+B;kBAN3C,SAAS;mBAAC;oBACT,QAAQ,EAAE,2BAA2B;oBACrC,WAAW,EAAE,wCAAwC;oBACrD,SAAS,EAAE,CAAC,sCAAsC,CAAC;oBACnD,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD","sourcesContent":["import { ChangeDetectionStrategy, Component } from '@angular/core';\n\n/**\n * Displays a label above the file attachment element.\n */\n@Component({\n selector: 'sky-file-attachment-label',\n templateUrl: './file-attachment-label.component.html',\n styleUrls: ['file-attachment-label.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SkyFileAttachmentLabelComponent {}\n","<span class=\"sky-control-label\">\n <ng-content></ng-content>\n</span>\n"]}
@@ -1,335 +0,0 @@
1
- import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, Input, Optional, Output, QueryList, Self, ViewChild, } from '@angular/core';
2
- import { NgControl } from '@angular/forms';
3
- import { SkyThemeService } from '@skyux/theme';
4
- import { Subject } from 'rxjs';
5
- import { takeUntil } from 'rxjs/operators';
6
- import { SkyFormsUtility } from '../shared/forms-utility';
7
- import { SkyFileAttachmentLabelComponent } from './file-attachment-label.component';
8
- import { SkyFileAttachmentService } from './file-attachment.service';
9
- import { SkyFileItemService } from './file-item.service';
10
- import * as i0 from "@angular/core";
11
- import * as i1 from "./file-attachment.service";
12
- import * as i2 from "./file-item.service";
13
- import * as i3 from "@angular/forms";
14
- import * as i4 from "@skyux/theme";
15
- import * as i5 from "@skyux/indicators";
16
- import * as i6 from "@angular/common";
17
- import * as i7 from "@skyux/i18n";
18
- let uniqueId = 0;
19
- /**
20
- * Provides an element to attach a single local file.
21
- */
22
- export class SkyFileAttachmentComponent {
23
- constructor(changeDetector, fileAttachmentService, fileItemService, ngControl, themeSvc) {
24
- this.changeDetector = changeDetector;
25
- this.fileAttachmentService = fileAttachmentService;
26
- this.fileItemService = fileItemService;
27
- this.ngControl = ngControl;
28
- this.themeSvc = themeSvc;
29
- /**
30
- * Specifies the maximum size in bytes for valid files.
31
- */
32
- this.maxFileSize = 500000;
33
- /**
34
- * Specifies the minimum size in bytes for valid files.
35
- */
36
- this.minFileSize = 0;
37
- /**
38
- * Fires when users add or remove files.
39
- */
40
- this.fileChange = new EventEmitter();
41
- /**
42
- * Fires when users select the file name link. Make sure to bind the event.
43
- * If you do not, the file name link will be a dead link.
44
- */
45
- this.fileClick = new EventEmitter();
46
- this.acceptedOver = false;
47
- this.rejectedOver = false;
48
- /**
49
- * Indicates whether the input is required for form validation.
50
- * When you set this property to `true`, the component adds `aria-required` and `required`
51
- * attributes to the input element so that forms display an invalid state until the input element
52
- * is complete.
53
- */
54
- this.required = false;
55
- this.fileAttachmentId = uniqueId++;
56
- this.ngUnsubscribe = new Subject();
57
- this._disabled = false;
58
- // eslint-disable-next-line @typescript-eslint/no-empty-function
59
- this._onChange = (_) => { };
60
- // eslint-disable-next-line @typescript-eslint/no-empty-function
61
- this._onTouched = () => { };
62
- this.labelElementId = `sky-file-attachment-label-${this.fileAttachmentId}`;
63
- this.fileDropDescriptionElementId = `sky-file-attachment-drop-description-${this.fileAttachmentId}`;
64
- if (this.ngControl) {
65
- this.ngControl.valueAccessor = this;
66
- }
67
- }
68
- /**
69
- * Indicates whether to disable the input.
70
- * @default false
71
- */
72
- set disabled(value) {
73
- const newDisabledState = SkyFormsUtility.coerceBooleanProperty(value);
74
- if (this._disabled !== newDisabledState) {
75
- this._disabled = newDisabledState;
76
- }
77
- }
78
- get disabled() {
79
- return this._disabled;
80
- }
81
- get hasLabelComponent() {
82
- return this.labelComponents.length > 0;
83
- }
84
- set value(value) {
85
- // The null check is needed to address a bug in Angular 4.
86
- // writeValue is being called twice, first time with a phantom null value
87
- // See: https://github.com/angular/angular/issues/14988
88
- // tslint:disable-next-line:no-null-keyword
89
- const isNewValue = value !== this.value && value !== null;
90
- if (isNewValue) {
91
- this._value = value;
92
- this._onChange(value);
93
- this.updateFileAttachmentButton();
94
- }
95
- }
96
- get value() {
97
- return this._value;
98
- }
99
- ngOnInit() {
100
- if (this.themeSvc) {
101
- this.themeSvc.settingsChange
102
- .pipe(takeUntil(this.ngUnsubscribe))
103
- .subscribe((themeSettings) => {
104
- this.currentThemeName = themeSettings.currentSettings.theme.name;
105
- this.updateFileAttachmentButton();
106
- });
107
- }
108
- }
109
- ngAfterViewInit() {
110
- // This is needed to address a bug in Angular 7.
111
- // When a control value is set intially, its value is not represented on the view.
112
- // See: https://github.com/angular/angular/issues/13792
113
- // Of note is the parent check which allows us to determine if the form is reactive.
114
- // Without this check there is a changed before checked error
115
- /* istanbul ignore else */
116
- if (this.ngControl) {
117
- setTimeout(() => {
118
- this.ngControl.control.setValue(this.value, {
119
- emitEvent: false,
120
- });
121
- this.changeDetector.markForCheck();
122
- });
123
- // Backwards compatibility support for anyone still using Validators.Required.
124
- this.required =
125
- this.required || SkyFormsUtility.hasRequiredValidation(this.ngControl);
126
- }
127
- }
128
- ngAfterContentInit() {
129
- // Handles updating classes when label changes
130
- this.labelComponents.changes
131
- .pipe(takeUntil(this.ngUnsubscribe))
132
- .subscribe(() => {
133
- this.changeDetector.detectChanges();
134
- });
135
- }
136
- isImage() {
137
- return this.fileItemService.isImage(this.value);
138
- }
139
- onDropClicked() {
140
- this._onTouched();
141
- this.inputEl.nativeElement.click();
142
- }
143
- fileChangeEvent(fileChangeEvent) {
144
- this.handleFiles(fileChangeEvent.target.files);
145
- }
146
- fileDragEnter(dragEnterEvent) {
147
- // Save this target to know when the drag event leaves
148
- this.enterEventTarget = dragEnterEvent.target;
149
- dragEnterEvent.stopPropagation();
150
- dragEnterEvent.preventDefault();
151
- }
152
- fileDragOver(dragOverEvent) {
153
- const transfer = dragOverEvent.dataTransfer;
154
- dragOverEvent.stopPropagation();
155
- dragOverEvent.preventDefault();
156
- if (transfer) {
157
- if (transfer.items) {
158
- const files = transfer.items;
159
- for (let index = 0; index < files.length; index++) {
160
- const file = files[index];
161
- if (file.type &&
162
- this.fileAttachmentService.fileTypeRejected(file.type, this.acceptedTypes)) {
163
- this.rejectedOver = true;
164
- this.acceptedOver = false;
165
- return;
166
- }
167
- }
168
- if (files.length > 0 && !this.acceptedOver) {
169
- this.rejectedOver = false;
170
- this.acceptedOver = true;
171
- }
172
- }
173
- else if (transfer.files) {
174
- // If the browser does not support DataTransfer.items,
175
- // defer file-type checking to drop handler.
176
- // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items#Browser_compatibility
177
- this.rejectedOver = false;
178
- this.acceptedOver = true;
179
- }
180
- }
181
- }
182
- fileDrop(dropEvent) {
183
- dropEvent.stopPropagation();
184
- dropEvent.preventDefault();
185
- this.enterEventTarget = undefined;
186
- this.rejectedOver = false;
187
- this.acceptedOver = false;
188
- if (dropEvent.dataTransfer && dropEvent.dataTransfer.files) {
189
- if (dropEvent.dataTransfer.files.length > 1) {
190
- return;
191
- }
192
- if (this.fileAttachmentService.hasDirectory(dropEvent.dataTransfer.files)) {
193
- return;
194
- }
195
- this.handleFiles(dropEvent.dataTransfer.files);
196
- }
197
- }
198
- fileDragLeave(dragLeaveEvent) {
199
- if (this.enterEventTarget === dragLeaveEvent.target) {
200
- this.rejectedOver = false;
201
- this.acceptedOver = false;
202
- }
203
- }
204
- deleteFileAttachment() {
205
- this.value = undefined;
206
- this.changeDetector.markForCheck();
207
- this.emitFileChangeEvent(this.value);
208
- }
209
- getFileName(truncate = true) {
210
- if (this.value) {
211
- // tslint:disable-next-line: max-line-length
212
- const dropName = this.fileItemService.isFile(this.value) && this.value.file.name
213
- ? this.value.file.name
214
- : this.value.url;
215
- if (truncate && dropName.length > 26) {
216
- return dropName.slice(0, 26) + '...';
217
- }
218
- else {
219
- return dropName;
220
- }
221
- }
222
- else {
223
- return undefined;
224
- }
225
- }
226
- ngOnDestroy() {
227
- this.fileChange.complete();
228
- this.ngUnsubscribe.next();
229
- this.ngUnsubscribe.complete();
230
- }
231
- registerOnChange(fn) {
232
- this._onChange = fn;
233
- }
234
- registerOnTouched(fn) {
235
- this._onTouched = fn;
236
- }
237
- writeValue(value) {
238
- this.value = value;
239
- this.changeDetector.markForCheck();
240
- }
241
- /**
242
- * @internal
243
- * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
244
- * @param isDisabled Whether the control should be disabled.
245
- */
246
- setDisabledState(isDisabled) {
247
- this.disabled = isDisabled;
248
- this.changeDetector.markForCheck();
249
- }
250
- emitClick() {
251
- this.fileClick.emit({
252
- file: this.value,
253
- });
254
- }
255
- emitFileChangeEvent(currentFile) {
256
- if (currentFile && !currentFile.errorType) {
257
- this.writeValue(currentFile);
258
- }
259
- this.fileChange.emit({
260
- file: currentFile,
261
- });
262
- this.inputEl.nativeElement.value = '';
263
- }
264
- loadFile(file) {
265
- const reader = new FileReader();
266
- reader.addEventListener('load', (event) => {
267
- file.url = event.target.result;
268
- this.emitFileChangeEvent(file);
269
- });
270
- reader.addEventListener('error', (event) => {
271
- this.emitFileChangeEvent(file);
272
- });
273
- reader.addEventListener('abort', (event) => {
274
- this.emitFileChangeEvent(file);
275
- });
276
- reader.readAsDataURL(file.file);
277
- }
278
- handleFiles(files) {
279
- // tslint:disable-next-line: max-line-length
280
- const processedFiles = this.fileAttachmentService.checkFiles(files, this.minFileSize, this.maxFileSize, this.acceptedTypes, this.validateFn);
281
- for (const file of processedFiles) {
282
- if (file.errorType) {
283
- this.emitFileChangeEvent(file);
284
- }
285
- else {
286
- this.loadFile(file);
287
- }
288
- }
289
- }
290
- updateFileAttachmentButton() {
291
- this.showFileAttachmentButton = !(this.value && this.currentThemeName === 'modern');
292
- this.changeDetector.markForCheck();
293
- }
294
- }
295
- SkyFileAttachmentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.SkyFileAttachmentService }, { token: i2.SkyFileItemService }, { token: i3.NgControl, optional: true, self: true }, { token: i4.SkyThemeService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
296
- SkyFileAttachmentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyFileAttachmentComponent, selector: "sky-file-attachment", inputs: { acceptedTypes: "acceptedTypes", disabled: "disabled", maxFileSize: "maxFileSize", minFileSize: "minFileSize", validateFn: "validateFn", required: "required" }, outputs: { fileChange: "fileChange", fileClick: "fileClick" }, providers: [SkyFileAttachmentService], queries: [{ propertyName: "labelComponents", predicate: SkyFileAttachmentLabelComponent }], viewQueries: [{ propertyName: "inputEl", first: true, predicate: ["fileInput"], descendants: true }], ngImport: i0, template: "<div class=\"sky-file-attachment-wrapper\">\n <div\n class=\"sky-file-attachment-label-wrapper\"\n [attr.aria-required]=\"required ? true : null\"\n [attr.id]=\"labelElementId\"\n [ngClass]=\"{ 'sky-control-label-required': required && hasLabelComponent }\"\n >\n <ng-container *ngTemplateOutlet=\"labelContent\"></ng-container>\n </div>\n <div\n class=\"\n sky-file-attachment-upload sky-file-attachment sky-file-attachment-target\n \"\n [ngClass]=\"{\n 'sky-file-attachment-accept': acceptedOver,\n 'sky-file-attachment-reject': rejectedOver\n }\"\n (dragenter)=\"fileDragEnter($event)\"\n (dragover)=\"fileDragOver($event)\"\n (dragleave)=\"fileDragLeave($event)\"\n (drop)=\"fileDrop($event)\"\n >\n <div\n aria-hidden=\"true\"\n class=\"sky-file-attachment-drop-description\"\n role=\"tooltip\"\n [attr.id]=\"fileDropDescriptionElementId\"\n >\n {{ 'skyux_file_attachment_file_upload_drag_or_click' | skyLibResources }}\n </div>\n <input\n hidden\n tabindex=\"-1\"\n type=\"file\"\n [attr.accept]=\"acceptedTypes || null\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n (change)=\"fileChangeEvent($event)\"\n #fileInput\n />\n <button\n *ngIf=\"showFileAttachmentButton\"\n class=\"sky-file-attachment-btn sky-btn sky-btn-default\"\n type=\"button\"\n [attr.aria-describedby]=\"fileDropDescriptionElementId\"\n [disabled]=\"disabled\"\n (click)=\"onDropClicked()\"\n >\n <sky-icon icon=\"folder-open-o\"></sky-icon>\n {{\n value\n ? ('skyux_file_attachment_button_label_replace_file'\n | skyLibResources)\n : ('skyux_file_attachment_button_label_choose_file' | skyLibResources)\n }}\n </button>\n <sky-icon\n *ngIf=\"value && !isImage() && currentThemeName === 'modern'\"\n class=\"sky-file-attachment-icon sky-deemphasized\"\n icon=\"file-o\"\n size=\"2x\"\n >\n </sky-icon>\n <span\n *ngIf=\"value || currentThemeName === 'default'\"\n class=\"sky-file-attachment-name\"\n >\n <a\n *ngIf=\"value; else noFile\"\n [attr.title]=\"getFileName(false)\"\n (click)=\"emitClick()\"\n >\n {{ getFileName() }}\n </a>\n </span>\n <ng-template #noFile>\n <span class=\"sky-file-attachment-none sky-deemphasized\">\n {{ 'skyux_file_attachment_label_no_file_chosen' | skyLibResources }}\n </span>\n </ng-template>\n <button\n *ngIf=\"value\"\n class=\"sky-btn sky-btn-borderless sky-file-attachment-delete\"\n type=\"button\"\n [attr.aria-label]=\"\n 'skyux_file_attachment_file_item_delete' | skyLibResources\n \"\n [disabled]=\"disabled\"\n [skyThemeClass]=\"{\n 'sky-btn-icon-borderless': 'modern'\n }\"\n (click)=\"deleteFileAttachment()\"\n >\n <sky-icon icon=\"trash-o\" size=\"md\"> </sky-icon>\n </button>\n </div>\n\n <img\n *ngIf=\"value && isImage()\"\n class=\"sky-file-attachment-preview-img\"\n [alt]=\"\n 'skyux_file_attachment_file_upload_image_preview_alt_text'\n | skyLibResources\n \"\n [src]=\"value.url\"\n />\n</div>\n\n<ng-template #labelContent>\n <ng-content select=\"sky-file-attachment-label\"></ng-content>\n</ng-template>\n", styles: [".sky-file-attachment-wrapper{display:inline-block}.sky-file-attachment-upload{padding-right:8px;display:block;border:1px solid transparent}.sky-file-attachment-accept{border-color:#72bf44;border-style:dashed;border-width:1px;border-radius:5px;color:#212327}.sky-file-attachment-reject{border-color:#ef4044;border-style:dashed;border-width:1px;border-radius:5px;color:#212327}:host(.ng-invalid.ng-dirty) .sky-file-attachment-btn{box-shadow:0 0 8px #ef404499;border:1px solid #ef4044}.sky-file-attachment-name{padding:0 5px}.sky-file-attachment-name a{cursor:pointer}.sky-file-attachment-delete{border:none;color:#cdcfd2;cursor:pointer;padding:0}.sky-file-attachment-delete:hover{color:#979ba2;transition:color .15s}.sky-file-attachment-preview-img{max-width:25%;height:auto;box-shadow:0 0 5px #666;margin:10px}.sky-file-attachment-drop-description{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}:host-context(.sky-theme-modern) .sky-file-attachment-none{font-size:13px}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper{display:flex;flex-wrap:wrap}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-label-wrapper{width:100%}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-preview-img{border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;box-shadow:none;margin:0 10px 0 0;width:100px;flex:0;order:1}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-btn{margin:0 10px 0 0}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-icon{margin:5px 10px 5px 5px}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-upload{flex:1;order:2;display:flex;align-items:flex-start}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-upload .sky-file-attachment-name{margin:10px 10px 0 0;padding:0}:host-context(.sky-theme-modern) .sky-file-attachment-wrapper .sky-file-attachment-delete{width:40px;height:40px;color:#686c73!important}.sky-theme-modern .sky-file-attachment-none{font-size:13px}.sky-theme-modern .sky-file-attachment-wrapper{display:flex;flex-wrap:wrap}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-label-wrapper{width:100%}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-preview-img{border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;box-shadow:none;margin:0 10px 0 0;width:100px;flex:0;order:1}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-btn{margin:0 10px 0 0}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-icon{margin:5px 10px 5px 5px}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-upload{flex:1;order:2;display:flex;align-items:flex-start}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-upload .sky-file-attachment-name{margin:10px 10px 0 0;padding:0}.sky-theme-modern .sky-file-attachment-wrapper .sky-file-attachment-delete{width:40px;height:40px;color:#686c73!important}\n"], components: [{ type: i5.λ4, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }], directives: [{ type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }], pipes: { "skyLibResources": i7.SkyLibResourcesPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
297
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentComponent, decorators: [{
298
- type: Component,
299
- args: [{
300
- selector: 'sky-file-attachment',
301
- templateUrl: './file-attachment.component.html',
302
- styleUrls: ['./file-attachment.component.scss'],
303
- providers: [SkyFileAttachmentService],
304
- changeDetection: ChangeDetectionStrategy.OnPush,
305
- }]
306
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1.SkyFileAttachmentService }, { type: i2.SkyFileItemService }, { type: i3.NgControl, decorators: [{
307
- type: Self
308
- }, {
309
- type: Optional
310
- }] }, { type: i4.SkyThemeService, decorators: [{
311
- type: Optional
312
- }] }]; }, propDecorators: { acceptedTypes: [{
313
- type: Input
314
- }], disabled: [{
315
- type: Input
316
- }], maxFileSize: [{
317
- type: Input
318
- }], minFileSize: [{
319
- type: Input
320
- }], validateFn: [{
321
- type: Input
322
- }], fileChange: [{
323
- type: Output
324
- }], fileClick: [{
325
- type: Output
326
- }], required: [{
327
- type: Input
328
- }], inputEl: [{
329
- type: ViewChild,
330
- args: ['fileInput']
331
- }], labelComponents: [{
332
- type: ContentChildren,
333
- args: [SkyFileAttachmentLabelComponent]
334
- }] } });
335
- //# sourceMappingURL=file-attachment.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-attachment.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-attachment.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-attachment.component.html"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EACvB,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,IAAI,EACJ,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC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B;kBAPtC,SAAS;mBAAC;oBACT,QAAQ,EAAE,qBAAqB;oBAC/B,WAAW,EAAE,kCAAkC;oBAC/C,SAAS,EAAE,CAAC,kCAAkC,CAAC;oBAC/C,SAAS,EAAE,CAAC,wBAAwB,CAAC;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;;0BA2HI,IAAI;;0BAAI,QAAQ;;0BAChB,QAAQ;4CAlHJ,aAAa;sBADnB,KAAK;gBAQK,QAAQ;sBADlB,KAAK;gBAgBC,WAAW;sBADjB,KAAK;gBAOC,WAAW;sBADjB,KAAK;gBAQC,UAAU;sBADhB,KAAK;gBAOC,UAAU;sBADhB,MAAM;gBAQA,SAAS;sBADf,MAAM;gBAsBA,QAAQ;sBADd,KAAK;gBA0BE,OAAO;sBADd,SAAS;uBAAC,WAAW;gBAId,eAAe;sBADtB,eAAe;uBAAC,+BAA+B","sourcesContent":["import {\n AfterContentInit,\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ContentChildren,\n ElementRef,\n EventEmitter,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n Output,\n QueryList,\n Self,\n ViewChild,\n} from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { SkyThemeService } from '@skyux/theme';\n\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyFormsUtility } from '../shared/forms-utility';\n\nimport { SkyFileAttachmentLabelComponent } from './file-attachment-label.component';\nimport { SkyFileAttachmentService } from './file-attachment.service';\nimport { SkyFileItem } from './file-item';\nimport { SkyFileItemService } from './file-item.service';\nimport { SkyFileAttachmentChange } from './types/file-attachment-change';\nimport { SkyFileAttachmentClick } from './types/file-attachment-click';\n\nlet uniqueId = 0;\n\n/**\n * Provides an element to attach a single local file.\n */\n@Component({\n selector: 'sky-file-attachment',\n templateUrl: './file-attachment.component.html',\n styleUrls: ['./file-attachment.component.scss'],\n providers: [SkyFileAttachmentService],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SkyFileAttachmentComponent\n implements AfterViewInit, AfterContentInit, OnInit, OnDestroy\n{\n /**\n * Specifies a comma-delimited string literal of MIME types that users can attach.\n * By default, all file types are allowed.\n * @required\n */\n @Input()\n public acceptedTypes: string;\n\n /**\n * Indicates whether to disable the input.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n const newDisabledState = SkyFormsUtility.coerceBooleanProperty(value);\n if (this._disabled !== newDisabledState) {\n this._disabled = newDisabledState;\n }\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Specifies the maximum size in bytes for valid files.\n */\n @Input()\n public maxFileSize = 500000;\n\n /**\n * Specifies the minimum size in bytes for valid files.\n */\n @Input()\n public minFileSize = 0;\n\n /**\n * Specifies a custom validation function. This validation runs alongside the internal\n * file validation. This function takes a `SkyFileItem` object as a parameter.\n */\n @Input()\n public validateFn: Function;\n\n /**\n * Fires when users add or remove files.\n */\n @Output()\n public fileChange = new EventEmitter<SkyFileAttachmentChange>();\n\n /**\n * Fires when users select the file name link. Make sure to bind the event.\n * If you do not, the file name link will be a dead link.\n */\n @Output()\n public fileClick = new EventEmitter<SkyFileAttachmentClick>();\n\n public acceptedOver = false;\n\n public get hasLabelComponent(): boolean {\n return this.labelComponents.length > 0;\n }\n\n public fileDropDescriptionElementId: string;\n\n public labelElementId: string;\n\n public rejectedOver = false;\n\n /**\n * Indicates whether the input is required for form validation.\n * When you set this property to `true`, the component adds `aria-required` and `required`\n * attributes to the input element so that forms display an invalid state until the input element\n * is complete.\n */\n @Input()\n public required = false;\n\n public set value(value: SkyFileItem) {\n // The null check is needed to address a bug in Angular 4.\n // writeValue is being called twice, first time with a phantom null value\n // See: https://github.com/angular/angular/issues/14988\n // tslint:disable-next-line:no-null-keyword\n const isNewValue = value !== this.value && value !== null;\n\n if (isNewValue) {\n this._value = value;\n this._onChange(value);\n this.updateFileAttachmentButton();\n }\n }\n\n public get value(): SkyFileItem {\n return this._value;\n }\n\n public currentThemeName: string;\n\n public showFileAttachmentButton: boolean;\n\n @ViewChild('fileInput')\n private inputEl: ElementRef;\n\n @ContentChildren(SkyFileAttachmentLabelComponent)\n private labelComponents: QueryList<SkyFileAttachmentLabelComponent>;\n\n private enterEventTarget: any;\n\n private fileAttachmentId = uniqueId++;\n\n private ngUnsubscribe = new Subject<void>();\n\n private _disabled = false;\n\n private _value: any;\n\n constructor(\n private changeDetector: ChangeDetectorRef,\n private fileAttachmentService: SkyFileAttachmentService,\n private fileItemService: SkyFileItemService,\n @Self() @Optional() private ngControl?: NgControl,\n @Optional() private themeSvc?: SkyThemeService\n ) {\n this.labelElementId = `sky-file-attachment-label-${this.fileAttachmentId}`;\n this.fileDropDescriptionElementId = `sky-file-attachment-drop-description-${this.fileAttachmentId}`;\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n public ngOnInit(): void {\n if (this.themeSvc) {\n this.themeSvc.settingsChange\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((themeSettings) => {\n this.currentThemeName = themeSettings.currentSettings.theme.name;\n this.updateFileAttachmentButton();\n });\n }\n }\n\n public ngAfterViewInit(): void {\n // This is needed to address a bug in Angular 7.\n // When a control value is set intially, its value is not represented on the view.\n // See: https://github.com/angular/angular/issues/13792\n // Of note is the parent check which allows us to determine if the form is reactive.\n // Without this check there is a changed before checked error\n /* istanbul ignore else */\n if (this.ngControl) {\n setTimeout(() => {\n this.ngControl.control.setValue(this.value, {\n emitEvent: false,\n });\n this.changeDetector.markForCheck();\n });\n\n // Backwards compatibility support for anyone still using Validators.Required.\n this.required =\n this.required || SkyFormsUtility.hasRequiredValidation(this.ngControl);\n }\n }\n\n public ngAfterContentInit(): void {\n // Handles updating classes when label changes\n this.labelComponents.changes\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n this.changeDetector.detectChanges();\n });\n }\n\n public isImage(): boolean {\n return this.fileItemService.isImage(this.value);\n }\n\n public onDropClicked(): void {\n this._onTouched();\n this.inputEl.nativeElement.click();\n }\n\n public fileChangeEvent(fileChangeEvent: any): void {\n this.handleFiles(fileChangeEvent.target.files);\n }\n\n public fileDragEnter(dragEnterEvent: any): void {\n // Save this target to know when the drag event leaves\n this.enterEventTarget = dragEnterEvent.target;\n dragEnterEvent.stopPropagation();\n dragEnterEvent.preventDefault();\n }\n\n public fileDragOver(dragOverEvent: any): void {\n const transfer = dragOverEvent.dataTransfer;\n\n dragOverEvent.stopPropagation();\n dragOverEvent.preventDefault();\n\n if (transfer) {\n if (transfer.items) {\n const files = transfer.items;\n\n for (let index = 0; index < files.length; index++) {\n const file: any = files[index];\n\n if (\n file.type &&\n this.fileAttachmentService.fileTypeRejected(\n file.type,\n this.acceptedTypes\n )\n ) {\n this.rejectedOver = true;\n this.acceptedOver = false;\n return;\n }\n }\n\n if (files.length > 0 && !this.acceptedOver) {\n this.rejectedOver = false;\n this.acceptedOver = true;\n }\n } else if (transfer.files) {\n // If the browser does not support DataTransfer.items,\n // defer file-type checking to drop handler.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items#Browser_compatibility\n this.rejectedOver = false;\n this.acceptedOver = true;\n }\n }\n }\n\n public fileDrop(dropEvent: DragEvent): void {\n dropEvent.stopPropagation();\n dropEvent.preventDefault();\n\n this.enterEventTarget = undefined;\n this.rejectedOver = false;\n this.acceptedOver = false;\n\n if (dropEvent.dataTransfer && dropEvent.dataTransfer.files) {\n if (dropEvent.dataTransfer.files.length > 1) {\n return;\n }\n\n if (\n this.fileAttachmentService.hasDirectory(dropEvent.dataTransfer.files)\n ) {\n return;\n }\n\n this.handleFiles(dropEvent.dataTransfer.files);\n }\n }\n\n public fileDragLeave(dragLeaveEvent: any): void {\n if (this.enterEventTarget === dragLeaveEvent.target) {\n this.rejectedOver = false;\n this.acceptedOver = false;\n }\n }\n\n public deleteFileAttachment(): void {\n this.value = undefined;\n this.changeDetector.markForCheck();\n this.emitFileChangeEvent(this.value);\n }\n\n public getFileName(truncate = true): string | undefined {\n if (this.value) {\n // tslint:disable-next-line: max-line-length\n const dropName =\n this.fileItemService.isFile(this.value) && this.value.file.name\n ? this.value.file.name\n : this.value.url;\n\n if (truncate && dropName.length > 26) {\n return dropName.slice(0, 26) + '...';\n } else {\n return dropName;\n }\n } else {\n return undefined;\n }\n }\n\n public ngOnDestroy(): void {\n this.fileChange.complete();\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n public registerOnChange(fn: (value: any) => any): void {\n this._onChange = fn;\n }\n public registerOnTouched(fn: () => any): void {\n this._onTouched = fn;\n }\n\n public writeValue(value: any): void {\n this.value = value;\n this.changeDetector.markForCheck();\n }\n\n /**\n * @internal\n * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.\n * @param isDisabled Whether the control should be disabled.\n */\n public setDisabledState(isDisabled: boolean) {\n this.disabled = isDisabled;\n this.changeDetector.markForCheck();\n }\n\n public emitClick(): void {\n this.fileClick.emit({\n file: this.value,\n });\n }\n\n private emitFileChangeEvent(currentFile: SkyFileItem): void {\n if (currentFile && !currentFile.errorType) {\n this.writeValue(currentFile);\n }\n this.fileChange.emit({\n file: currentFile,\n } as SkyFileAttachmentChange);\n\n this.inputEl.nativeElement.value = '';\n }\n\n private loadFile(file: SkyFileItem): void {\n const reader = new FileReader();\n\n reader.addEventListener('load', (event: any): void => {\n file.url = event.target.result;\n this.emitFileChangeEvent(file);\n });\n\n reader.addEventListener('error', (event: any): void => {\n this.emitFileChangeEvent(file);\n });\n\n reader.addEventListener('abort', (event: any): void => {\n this.emitFileChangeEvent(file);\n });\n\n reader.readAsDataURL(file.file);\n }\n\n private handleFiles(files: FileList): void {\n // tslint:disable-next-line: max-line-length\n const processedFiles = this.fileAttachmentService.checkFiles(\n files,\n this.minFileSize,\n this.maxFileSize,\n this.acceptedTypes,\n this.validateFn\n );\n\n for (const file of processedFiles) {\n if (file.errorType) {\n this.emitFileChangeEvent(file);\n } else {\n this.loadFile(file);\n }\n }\n }\n\n private updateFileAttachmentButton(): void {\n this.showFileAttachmentButton = !(\n this.value && this.currentThemeName === 'modern'\n );\n this.changeDetector.markForCheck();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private _onChange = (_: any) => {};\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private _onTouched = () => {};\n}\n","<div class=\"sky-file-attachment-wrapper\">\n <div\n class=\"sky-file-attachment-label-wrapper\"\n [attr.aria-required]=\"required ? true : null\"\n [attr.id]=\"labelElementId\"\n [ngClass]=\"{ 'sky-control-label-required': required && hasLabelComponent }\"\n >\n <ng-container *ngTemplateOutlet=\"labelContent\"></ng-container>\n </div>\n <div\n class=\"\n sky-file-attachment-upload sky-file-attachment sky-file-attachment-target\n \"\n [ngClass]=\"{\n 'sky-file-attachment-accept': acceptedOver,\n 'sky-file-attachment-reject': rejectedOver\n }\"\n (dragenter)=\"fileDragEnter($event)\"\n (dragover)=\"fileDragOver($event)\"\n (dragleave)=\"fileDragLeave($event)\"\n (drop)=\"fileDrop($event)\"\n >\n <div\n aria-hidden=\"true\"\n class=\"sky-file-attachment-drop-description\"\n role=\"tooltip\"\n [attr.id]=\"fileDropDescriptionElementId\"\n >\n {{ 'skyux_file_attachment_file_upload_drag_or_click' | skyLibResources }}\n </div>\n <input\n hidden\n tabindex=\"-1\"\n type=\"file\"\n [attr.accept]=\"acceptedTypes || null\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n (change)=\"fileChangeEvent($event)\"\n #fileInput\n />\n <button\n *ngIf=\"showFileAttachmentButton\"\n class=\"sky-file-attachment-btn sky-btn sky-btn-default\"\n type=\"button\"\n [attr.aria-describedby]=\"fileDropDescriptionElementId\"\n [disabled]=\"disabled\"\n (click)=\"onDropClicked()\"\n >\n <sky-icon icon=\"folder-open-o\"></sky-icon>\n {{\n value\n ? ('skyux_file_attachment_button_label_replace_file'\n | skyLibResources)\n : ('skyux_file_attachment_button_label_choose_file' | skyLibResources)\n }}\n </button>\n <sky-icon\n *ngIf=\"value && !isImage() && currentThemeName === 'modern'\"\n class=\"sky-file-attachment-icon sky-deemphasized\"\n icon=\"file-o\"\n size=\"2x\"\n >\n </sky-icon>\n <span\n *ngIf=\"value || currentThemeName === 'default'\"\n class=\"sky-file-attachment-name\"\n >\n <a\n *ngIf=\"value; else noFile\"\n [attr.title]=\"getFileName(false)\"\n (click)=\"emitClick()\"\n >\n {{ getFileName() }}\n </a>\n </span>\n <ng-template #noFile>\n <span class=\"sky-file-attachment-none sky-deemphasized\">\n {{ 'skyux_file_attachment_label_no_file_chosen' | skyLibResources }}\n </span>\n </ng-template>\n <button\n *ngIf=\"value\"\n class=\"sky-btn sky-btn-borderless sky-file-attachment-delete\"\n type=\"button\"\n [attr.aria-label]=\"\n 'skyux_file_attachment_file_item_delete' | skyLibResources\n \"\n [disabled]=\"disabled\"\n [skyThemeClass]=\"{\n 'sky-btn-icon-borderless': 'modern'\n }\"\n (click)=\"deleteFileAttachment()\"\n >\n <sky-icon icon=\"trash-o\" size=\"md\"> </sky-icon>\n </button>\n </div>\n\n <img\n *ngIf=\"value && isImage()\"\n class=\"sky-file-attachment-preview-img\"\n [alt]=\"\n 'skyux_file_attachment_file_upload_image_preview_alt_text'\n | skyLibResources\n \"\n [src]=\"value.url\"\n />\n</div>\n\n<ng-template #labelContent>\n <ng-content select=\"sky-file-attachment-label\"></ng-content>\n</ng-template>\n"]}
@@ -1,94 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * @internal
5
- */
6
- export class SkyFileAttachmentService {
7
- checkFiles(files, minFileSize, maxFileSize, acceptedTypes, validateFn) {
8
- const fileResults = [];
9
- for (let index = 0; index < files.length; index++) {
10
- const fileItem = {
11
- file: files.item(index),
12
- };
13
- if (fileItem.file.size < minFileSize) {
14
- fileItem.errorType = 'minFileSize';
15
- fileItem.errorParam = minFileSize.toString();
16
- fileResults.push(fileItem);
17
- }
18
- else if (fileItem.file.size > maxFileSize) {
19
- fileItem.errorType = 'maxFileSize';
20
- fileItem.errorParam = maxFileSize.toString();
21
- fileResults.push(fileItem);
22
- }
23
- else if (this.fileTypeRejected(fileItem.file.type, acceptedTypes)) {
24
- fileItem.errorType = 'fileType';
25
- fileItem.errorParam = acceptedTypes;
26
- fileResults.push(fileItem);
27
- }
28
- else if (validateFn) {
29
- const errorParam = validateFn(fileItem);
30
- if (errorParam) {
31
- fileItem.errorType = 'validate';
32
- fileItem.errorParam = errorParam;
33
- }
34
- fileResults.push(fileItem);
35
- }
36
- else {
37
- fileResults.push(fileItem);
38
- }
39
- }
40
- return fileResults;
41
- }
42
- /**
43
- * Returns `true` if a directory is found in the provided `files` parameter.
44
- */
45
- hasDirectory(files) {
46
- for (let index = 0; index < files.length; index++) {
47
- const file = files.item(index);
48
- if (file.webkitGetAsEntry &&
49
- file.webkitGetAsEntry() &&
50
- file.webkitGetAsEntry().isDirectory) {
51
- return true;
52
- }
53
- }
54
- return false;
55
- }
56
- fileTypeRejected(fileType, acceptedTypes) {
57
- if (!acceptedTypes) {
58
- return false;
59
- }
60
- if (!fileType) {
61
- return true;
62
- }
63
- const acceptedTypesUpper = acceptedTypes.toUpperCase();
64
- const typeArray = acceptedTypesUpper.split(',');
65
- return !this.fileTypeInArray(typeArray, fileType.toUpperCase());
66
- }
67
- fileTypeInArray(typeArray, fileType) {
68
- if (typeArray.indexOf(fileType) !== -1) {
69
- return true;
70
- }
71
- for (let index = 0; index < typeArray.length; index++) {
72
- const type = typeArray[index];
73
- const validSubtype = this.getMimeSubtype(type);
74
- if (validSubtype === '*') {
75
- if (this.getMimeMainType(type) === this.getMimeMainType(fileType)) {
76
- return true;
77
- }
78
- }
79
- }
80
- return false;
81
- }
82
- getMimeSubtype(type) {
83
- return type.substr(type.indexOf('/') + 1, type.length);
84
- }
85
- getMimeMainType(type) {
86
- return type.substr(0, type.indexOf('/'));
87
- }
88
- }
89
- SkyFileAttachmentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
90
- SkyFileAttachmentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentService });
91
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFileAttachmentService, decorators: [{
92
- type: Injectable
93
- }] });
94
- //# sourceMappingURL=file-attachment.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-attachment.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-attachment.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAI3C;;GAEG;AAEH,MAAM,OAAO,wBAAwB;IAC5B,UAAU,CACf,KAAe,EACf,WAAmB,EACnB,WAAmB,EACnB,aAAqB,EACrB,UAAoB;QAEpB,MAAM,WAAW,GAAkB,EAAE,CAAC;QAEtC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;aACT,CAAC;YAEjB,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE;gBACpC,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;gBACnC,QAAQ,CAAC,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC7C,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC5B;iBAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE;gBAC3C,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;gBACnC,QAAQ,CAAC,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC7C,WAAW,CAAC,IAAI,CAAC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D,MAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEhD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,CAAC;IAEO,eAAe,CAAC,SAAmB,EAAE,QAAgB;QAC3D,IAAI,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;YACtC,OAAO,IAAI,CAAC;SACb;QAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACrD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAE/C,IAAI,YAAY,KAAK,GAAG,EAAE;gBACxB,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;oBACjE,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,IAAY;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;;sHApGU,wBAAwB;0HAAxB,wBAAwB;4FAAxB,wBAAwB;kBADpC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { SkyFileItem } from './file-item';\n\n/**\n * @internal\n */\n@Injectable()\nexport class SkyFileAttachmentService {\n public checkFiles(\n files: FileList,\n minFileSize: number,\n maxFileSize: number,\n acceptedTypes: string,\n validateFn: Function\n ): SkyFileItem[] {\n const fileResults: SkyFileItem[] = [];\n\n for (let index = 0; index < files.length; index++) {\n const fileItem = {\n file: files.item(index),\n } as SkyFileItem;\n\n if (fileItem.file.size < minFileSize) {\n fileItem.errorType = 'minFileSize';\n fileItem.errorParam = minFileSize.toString();\n fileResults.push(fileItem);\n } else if (fileItem.file.size > maxFileSize) {\n fileItem.errorType = 'maxFileSize';\n fileItem.errorParam = maxFileSize.toString();\n fileResults.push(fileItem);\n } else if (this.fileTypeRejected(fileItem.file.type, acceptedTypes)) {\n fileItem.errorType = 'fileType';\n fileItem.errorParam = acceptedTypes;\n fileResults.push(fileItem);\n } else if (validateFn) {\n const errorParam = validateFn(fileItem);\n\n if (errorParam) {\n fileItem.errorType = 'validate';\n fileItem.errorParam = errorParam;\n }\n fileResults.push(fileItem);\n } else {\n fileResults.push(fileItem);\n }\n }\n return fileResults;\n }\n\n /**\n * Returns `true` if a directory is found in the provided `files` parameter.\n */\n public hasDirectory(files: FileList): boolean {\n for (let index = 0; index < files.length; index++) {\n const file: any = files.item(index);\n if (\n file.webkitGetAsEntry &&\n file.webkitGetAsEntry() &&\n file.webkitGetAsEntry().isDirectory\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n public fileTypeRejected(fileType: string, acceptedTypes: string): boolean {\n if (!acceptedTypes) {\n return false;\n }\n\n if (!fileType) {\n return true;\n }\n\n const acceptedTypesUpper = acceptedTypes.toUpperCase();\n const typeArray = acceptedTypesUpper.split(',');\n\n return !this.fileTypeInArray(typeArray, fileType.toUpperCase());\n }\n\n private fileTypeInArray(typeArray: string[], fileType: string): boolean {\n if (typeArray.indexOf(fileType) !== -1) {\n return true;\n }\n\n for (let index = 0; index < typeArray.length; index++) {\n const type = typeArray[index];\n const validSubtype = this.getMimeSubtype(type);\n\n if (validSubtype === '*') {\n if (this.getMimeMainType(type) === this.getMimeMainType(fileType)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private getMimeSubtype(type: string): string {\n return type.substr(type.indexOf('/') + 1, type.length);\n }\n\n private getMimeMainType(type: string): string {\n return type.substr(0, type.indexOf('/'));\n }\n}\n"]}