@skyux/forms 5.6.0 → 5.7.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 (31) hide show
  1. package/bundles/skyux-forms.umd.js +26 -23
  2. package/documentation.json +259 -599
  3. package/esm2015/lib/modules/character-counter/character-counter.directive.js +1 -0
  4. package/esm2015/lib/modules/character-counter/character-counter.directive.js.map +1 -1
  5. package/esm2015/lib/modules/checkbox/checkbox.component.js +3 -2
  6. package/esm2015/lib/modules/checkbox/checkbox.component.js.map +1 -1
  7. package/esm2015/lib/modules/file-attachment/file-attachment.component.js +3 -3
  8. package/esm2015/lib/modules/file-attachment/file-attachment.component.js.map +1 -1
  9. package/esm2015/lib/modules/file-attachment/file-drop.component.js +1 -2
  10. package/esm2015/lib/modules/file-attachment/file-drop.component.js.map +1 -1
  11. package/esm2015/lib/modules/file-attachment/file-item.component.js +3 -1
  12. package/esm2015/lib/modules/file-attachment/file-item.component.js.map +1 -1
  13. package/esm2015/lib/modules/file-attachment/file-item.service.js +2 -2
  14. package/esm2015/lib/modules/file-attachment/file-item.service.js.map +1 -1
  15. package/esm2015/lib/modules/file-attachment/file-size.pipe.js +4 -5
  16. package/esm2015/lib/modules/file-attachment/file-size.pipe.js.map +1 -1
  17. package/esm2015/lib/modules/radio/radio-group.component.js +3 -3
  18. package/esm2015/lib/modules/radio/radio-group.component.js.map +1 -1
  19. package/esm2015/lib/modules/radio/radio.component.js +3 -3
  20. package/esm2015/lib/modules/radio/radio.component.js.map +1 -1
  21. package/esm2015/lib/modules/shared/sky-forms-resources.module.js +1 -1
  22. package/esm2015/lib/modules/shared/sky-forms-resources.module.js.map +1 -1
  23. package/esm2015/lib/modules/toggle-switch/toggle-switch.component.js +2 -1
  24. package/esm2015/lib/modules/toggle-switch/toggle-switch.component.js.map +1 -1
  25. package/fesm2015/skyux-forms.js +26 -23
  26. package/fesm2015/skyux-forms.js.map +1 -1
  27. package/lib/modules/checkbox/checkbox.component.d.ts +1 -1
  28. package/lib/modules/file-attachment/file-attachment.component.d.ts +1 -1
  29. package/lib/modules/radio/radio-group.component.d.ts +1 -1
  30. package/lib/modules/shared/sky-forms-resources.module.d.ts +1 -1
  31. package/package.json +15 -12
@@ -10,6 +10,7 @@ import * as i0 from "@angular/core";
10
10
  */
11
11
  export class SkyCharacterCounterInputDirective {
12
12
  constructor() {
13
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
13
14
  this._validatorChange = () => { };
14
15
  }
15
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"character-counter.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/character-counter/character-counter.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAEL,aAAa,GAGd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;;AAEhG;;;;;GAKG;AAWH,MAAM,OAAO,iCAAiC;IAV9C;QA0EU,qBAAgB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;KACrC;IAxDC;;;;OAIG;IACH,IACW,wBAAwB,CAAC,KAAa;QAC/C,IAAI,CAAC,yBAAyB,GAAG,KAAK,CAAC;QACvC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,IAAW,wBAAwB;QACjC,OAAO,IAAI,CAAC,yBAAyB,IAAI,CAAC,CAAC;IAC7C,CAAC;IAIM,QAAQ,CAAC,OAAwB;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,IAAI,CAAC,oBAAoB,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAExD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO;SACR;QAED,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,wBAAwB,EAAE;YAChD,qEAAqE;YACrE,OAAO,CAAC,aAAa,EAAE,CAAC;YAExB,OAAO;gBACL,mBAAmB,EAAE;oBACnB,OAAO,EAAE,KAAK;iBACf;aACF,CAAC;SACH;IACH,CAAC;IAEM,yBAAyB,CAAC,EAAc;QAC7C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAEO,oBAAoB,CAAC,KAAa;QACxC,IAAI,IAAI,CAAC,4BAA4B,EAAE;YACrC,IAAI,CAAC,4BAA4B,CAAC,cAAc,GAAG,KAAK,CAAC;SAC1D;IACH,CAAC;IAEO,oBAAoB,CAAC,KAAa;QACxC,IAAI,IAAI,CAAC,4BAA4B,EAAE;YACrC,IAAI,CAAC,4BAA4B,CAAC,mBAAmB,GAAG,KAAK,CAAC;SAC/D;IACH,CAAC;;+HA9DU,iCAAiC;mHAAjC,iCAAiC,gLARjC;QACT;YACE,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,iCAAiC;YAC9C,KAAK,EAAE,IAAI;SACZ;KACF;4FAEU,iCAAiC;kBAV7C,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE;wBACT;4BACE,OAAO,EAAE,aAAa;4BACtB,WAAW,mCAAmC;4BAC9C,KAAK,EAAE,IAAI;yBACZ;qBACF;iBACF;8BAQQ,4BAA4B;sBADlC,KAAK;gBASK,wBAAwB;sBADlC,KAAK","sourcesContent":["import { Directive, Input } from '@angular/core';\nimport {\n AbstractControl,\n NG_VALIDATORS,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport { SkyCharacterCounterIndicatorComponent } from './character-counter-indicator.component';\n\n/**\n * Creates an input field that validates the number of characters. Place this directive on\n * an `input` or `textarea` element. If users enter more characters than allowed, then the\n * input field is invalid and the component displays an error indicator.\n * @required\n */\n@Directive({\n selector: '[skyCharacterCounter]',\n providers: [\n {\n provide: NG_VALIDATORS,\n useExisting: SkyCharacterCounterInputDirective,\n multi: true,\n },\n ],\n})\nexport class SkyCharacterCounterInputDirective implements Validator {\n /**\n * Specifies the character count indicator component that displays the character count,\n * character limit, and over-the-limit indicator. Place this directive on an `input` or\n * `textarea` element.\n */\n @Input()\n public skyCharacterCounterIndicator: SkyCharacterCounterIndicatorComponent;\n\n /**\n * Specifies the maximum number of characters allowed in the input field. Place this directive\n * on an `input` or `textarea` element. This property accepts `number` values.\n * @required\n */\n @Input()\n public set skyCharacterCounterLimit(value: number) {\n this._skyCharacterCounterLimit = value;\n this.updateIndicatorLimit(this.skyCharacterCounterLimit);\n this._validatorChange();\n }\n\n public get skyCharacterCounterLimit(): number {\n return this._skyCharacterCounterLimit || 0;\n }\n\n private _skyCharacterCounterLimit: number;\n\n public validate(control: AbstractControl): ValidationErrors {\n const value = control.value;\n\n this.updateIndicatorCount((value && value.length) || 0);\n\n if (!value) {\n return;\n }\n\n if (value.length > this.skyCharacterCounterLimit) {\n // This is needed to apply the appropriate error styles to the input.\n control.markAsTouched();\n\n return {\n skyCharacterCounter: {\n invalid: value,\n },\n };\n }\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this._validatorChange = fn;\n }\n\n private updateIndicatorCount(count: number): void {\n if (this.skyCharacterCounterIndicator) {\n this.skyCharacterCounterIndicator.characterCount = count;\n }\n }\n\n private updateIndicatorLimit(limit: number): void {\n if (this.skyCharacterCounterIndicator) {\n this.skyCharacterCounterIndicator.characterCountLimit = limit;\n }\n }\n\n private _validatorChange = () => {};\n}\n"]}
1
+ {"version":3,"file":"character-counter.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/character-counter/character-counter.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAEL,aAAa,GAGd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;;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iCAAiC,gLARjC;QACT;YACE,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,iCAAiC;YAC9C,KAAK,EAAE,IAAI;SACZ;KACF;4FAEU,iCAAiC;kBAV7C,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE;wBACT;4BACE,OAAO,EAAE,aAAa;4BACtB,WAAW,mCAAmC;4BAC9C,KAAK,EAAE,IAAI;yBACZ;qBACF;iBACF;8BAQQ,4BAA4B;sBADlC,KAAK;gBASK,wBAAwB;sBADlC,KAAK","sourcesContent":["import { Directive, Input } from '@angular/core';\nimport {\n AbstractControl,\n NG_VALIDATORS,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport { SkyCharacterCounterIndicatorComponent } from './character-counter-indicator.component';\n\n/**\n * Creates an input field that validates the number of characters. Place this directive on\n * an `input` or `textarea` element. If users enter more characters than allowed, then the\n * input field is invalid and the component displays an error indicator.\n * @required\n */\n@Directive({\n selector: '[skyCharacterCounter]',\n providers: [\n {\n provide: NG_VALIDATORS,\n useExisting: SkyCharacterCounterInputDirective,\n multi: true,\n },\n ],\n})\nexport class SkyCharacterCounterInputDirective implements Validator {\n /**\n * Specifies the character count indicator component that displays the character count,\n * character limit, and over-the-limit indicator. Place this directive on an `input` or\n * `textarea` element.\n */\n @Input()\n public skyCharacterCounterIndicator: SkyCharacterCounterIndicatorComponent;\n\n /**\n * Specifies the maximum number of characters allowed in the input field. Place this directive\n * on an `input` or `textarea` element. This property accepts `number` values.\n * @required\n */\n @Input()\n public set skyCharacterCounterLimit(value: number) {\n this._skyCharacterCounterLimit = value;\n this.updateIndicatorLimit(this.skyCharacterCounterLimit);\n this._validatorChange();\n }\n\n public get skyCharacterCounterLimit(): number {\n return this._skyCharacterCounterLimit || 0;\n }\n\n private _skyCharacterCounterLimit: number;\n\n public validate(control: AbstractControl): ValidationErrors {\n const value = control.value;\n\n this.updateIndicatorCount((value && value.length) || 0);\n\n if (!value) {\n return;\n }\n\n if (value.length > this.skyCharacterCounterLimit) {\n // This is needed to apply the appropriate error styles to the input.\n control.markAsTouched();\n\n return {\n skyCharacterCounter: {\n invalid: value,\n },\n };\n }\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this._validatorChange = fn;\n }\n\n private updateIndicatorCount(count: number): void {\n if (this.skyCharacterCounterIndicator) {\n this.skyCharacterCounterIndicator.characterCount = count;\n }\n }\n\n private updateIndicatorLimit(limit: number): void {\n if (this.skyCharacterCounterIndicator) {\n this.skyCharacterCounterIndicator.characterCountLimit = limit;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private _validatorChange = () => {};\n}\n"]}
@@ -44,8 +44,9 @@ export class SkyCheckboxComponent {
44
44
  this._disabledChange = new BehaviorSubject(this._disabled);
45
45
  this._required = false;
46
46
  /** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */
47
- /*istanbul ignore next */
47
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
48
48
  this.onTouched = () => { };
49
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
49
50
  this._controlValueAccessorChangeFn = (value) => { };
50
51
  if (this.ngControl) {
51
52
  this.ngControl.valueAccessor = this;
@@ -113,7 +114,7 @@ export class SkyCheckboxComponent {
113
114
  /**
114
115
  * Indicates whether the input is required for form validation.
115
116
  * When you set this property to `true`, the component adds `aria-required` and `required`
116
- * attributes to the input element so that forms display an invalid state until the input element
117
+ * attributes to the input element so that forms display an invalid state until the input element
117
118
  * is complete.
118
119
  * @default false
119
120
  */
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/checkbox/checkbox.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/checkbox/checkbox.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EAEL,QAAQ,EACR,MAAM,EACN,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwB,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KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QACpB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,OAAO;QACb,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;;kHA7PU,oBAAoB;sGAApB,oBAAoB,qWC/BjC,+sDA4DA;4FD7Ba,oBAAoB;kBALhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,cAAc;oBACxB,WAAW,EAAE,2BAA2B;oBACxC,SAAS,EAAE,CAAC,2BAA2B,CAAC;iBACzC;;0BA4Kc,IAAI;;0BAAI,QAAQ;4CAnKtB,KAAK;sBADX,KAAK;gBAUC,UAAU;sBADhB,KAAK;gBAQC,EAAE;sBADR,KAAK;gBAQK,QAAQ;sBADlB,KAAK;gBAqBC,QAAQ;sBADd,KAAK;gBAQC,IAAI;sBADV,KAAK;gBAQC,MAAM;sBAFZ,MAAM;gBAUA,IAAI;sBADV,KAAK;gBAYK,YAAY;sBADtB,KAAK;gBAoBK,OAAO;sBADjB,KAAK;gBA+BF,QAAQ;sBADX,KAAK;gBAaK,aAAa;sBADvB,MAAM;gBASI,cAAc;sBADxB,MAAM","sourcesContent":["import {\n Component,\n EventEmitter,\n Input,\n OnInit,\n Optional,\n Output,\n Self,\n} from '@angular/core';\nimport { ControlValueAccessor, NgControl } from '@angular/forms';\n\nimport { BehaviorSubject, Observable } from 'rxjs';\n\nimport { SkyFormsUtility } from '../shared/forms-utility';\n\nimport { SkyCheckboxChange } from './checkbox-change';\n\n/**\n * Monotonically increasing integer used to auto-generate unique ids for checkbox components.\n */\nlet nextId = 0;\n\n/**\n * Replaces the HTML input element with `type=\"checkbox\"`. When users select a checkbox, its value\n * is driven through an `ngModel` attribute that you specify on the `sky-checkbox` element.\n */\n@Component({\n selector: 'sky-checkbox',\n templateUrl: './checkbox.component.html',\n styleUrls: ['./checkbox.component.scss'],\n})\nexport class SkyCheckboxComponent implements ControlValueAccessor, OnInit {\n /**\n * Specifies an ARIA label for the checkbox. This sets the checkbox's `aria-label` attribute\n * [to support accessibility](https://developer.blackbaud.com/skyux/components/checkbox#accessibility)\n * when the checkbox does not include a visible label. You must set this property for icon\n * checkboxes. If the checkbox includes a visible label, use `labelledBy` instead.\n */\n @Input()\n public label: string;\n\n /**\n * Specifies the HTML element ID (without the leading `#`) of the element that labels the\n * checkbox. This sets the checkbox's `aria-labelledby` attribute\n * [to support accessibility](https://developer.blackbaud.com/skyux/components/checkbox#accessibility).\n * If the checkbox does not include a visible label, use `label` instead.\n */\n @Input()\n public labelledBy: string;\n\n /**\n * Specifies an ID for the checkbox.\n * @default a unique, auto-incrementing integer. For example: `sky-checkbox-1`\n */\n @Input()\n public id = `sky-checkbox-${++nextId}`;\n\n /**\n * Indicates whether to disable the checkbox.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);\n if (coercedValue !== this.disabled) {\n this._disabled = coercedValue;\n this._disabledChange.next(this._disabled);\n }\n }\n\n /**\n * Indicates whether the checkbox is disabled.\n */\n public get disabled() {\n return this._disabled;\n }\n\n /**\n * Specifies an index for the checkbox. If not defined, the index is set to the position of the\n * checkbox on load.\n */\n @Input()\n public tabindex = 0;\n\n /**\n * Specifies a name for a group of checkboxes.\n * @default a unique, auto-incrementing integer. For example: `sky-checkbox-1`\n */\n @Input()\n public name = `sky-checkbox-${++nextId}`;\n\n /**\n * Fires when the selected value changes.\n */\n @Output()\n // eslint-disable-next-line @angular-eslint/no-output-native\n public change = new EventEmitter<SkyCheckboxChange>();\n\n /**\n * Specifies an icon to display in place of the checkbox. To group icon checkboxes\n * like in the demo, place the `sky-switch-icon-group` class on the direct parent\n * element of the checkboxes.\n */\n @Input()\n public icon: string;\n\n /**\n * Specifies a type to set the background color after users select a checkbox where the\n * `icon` property displays an icon in place of the checkbox. The valid options correspond to\n * [the label component's](https://developer.blackbaud.com/skyux/components/label)\n * label types. `\"info\"` creates a blue background, `\"success\"` creates a green\n * background, `\"warning\"` creates an orange background, and `\"danger\"` creates a red background.\n * @default \"info\"\n */\n @Input()\n public set checkboxType(value: string) {\n if (value) {\n this._checkboxType = value.toLowerCase();\n }\n }\n\n public get checkboxType(): string {\n return this._checkboxType || 'info';\n }\n\n public get inputId(): string {\n return `input-${this.id}`;\n }\n\n /**\n * Indicates whether the checkbox is selected.\n * @default false\n */\n @Input()\n public set checked(checked: boolean) {\n if (checked !== this.checked) {\n this._checked = checked;\n this._controlValueAccessorChangeFn(checked);\n this._checkedChange.next(this._checked);\n\n // Do not mark the field as \"dirty\"\n // if the field has been initialized with a value.\n if (this.isFirstChange && this.ngControl && this.ngControl.control) {\n this.ngControl.control.markAsPristine();\n this.isFirstChange = false;\n }\n }\n }\n\n /**\n * Indicates whether the checkbox is selected.\n */\n public get checked() {\n return this._checked;\n }\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 * @default false\n */\n @Input()\n set required(value: boolean) {\n this._required = SkyFormsUtility.coerceBooleanProperty(value);\n }\n\n get required(): boolean {\n return this._required;\n }\n\n /**\n * Fires when users select or deselect the checkbox.\n */\n @Output()\n public get checkedChange(): Observable<boolean> {\n return this._checkedChange;\n }\n\n /**\n * Fires when the selected value changes.\n */\n @Output()\n public get disabledChange(): Observable<boolean> {\n return this._disabledChange;\n }\n\n private isFirstChange = true;\n\n private _checkboxType: string;\n\n private _checked = false;\n\n private _checkedChange = new BehaviorSubject<boolean>(this._checked);\n\n private _disabled = false;\n\n private _disabledChange = new BehaviorSubject<boolean>(this._disabled);\n\n private _required = false;\n\n constructor(@Self() @Optional() private ngControl: NgControl) {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n public ngOnInit(): void {\n if (this.ngControl) {\n // Backwards compatibility support for anyone still using Validators.Required.\n this.required =\n this.required || SkyFormsUtility.hasRequiredValidation(this.ngControl);\n }\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public writeValue(value: any) {\n this.checked = !!value;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnChange(fn: (value: any) => void) {\n this._controlValueAccessorChangeFn = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(isDisabled: boolean) {\n this.disabled = isDisabled;\n }\n\n /**\n * Event handler for checkbox input element.\n * Toggles checked state if element is not disabled.\n */\n public onInteractionEvent(event: Event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the `change` output.\n event.stopPropagation();\n\n if (!this.disabled) {\n this._toggle();\n this._emitChangeEvent();\n }\n }\n\n public onInputBlur() {\n this.onTouched();\n }\n\n /** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */\n /*istanbul ignore next */\n public onTouched: () => any = () => {};\n\n private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};\n\n private _emitChangeEvent() {\n const event = new SkyCheckboxChange();\n event.source = this;\n event.checked = this._checked;\n\n this._controlValueAccessorChangeFn(this._checked);\n this.change.emit(event);\n }\n\n /**\n * Toggles the `checked` value between true and false\n */\n private _toggle() {\n this.checked = !this.checked;\n }\n}\n","<label\n class=\"sky-checkbox-wrapper sky-switch\"\n [ngClass]=\"{\n 'sky-control-label-required': required,\n 'sky-switch-disabled': disabled\n }\"\n>\n <input\n class=\"sky-checkbox-input sky-switch-input\"\n type=\"checkbox\"\n [id]=\"inputId\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [name]=\"name\"\n [required]=\"required\"\n [tabIndex]=\"tabindex\"\n [attr.aria-label]=\"label\"\n [attr.aria-labelledby]=\"labelledBy\"\n [attr.aria-required]=\"required ? true : null\"\n (blur)=\"onInputBlur()\"\n (change)=\"onInteractionEvent($event)\"\n />\n <span\n class=\"sky-switch-control sky-rounded-corners\"\n [ngClass]=\"{\n 'sky-switch-control-icon': icon,\n 'sky-switch-control-info': checkboxType === 'info',\n 'sky-switch-control-success': checkboxType === 'success',\n 'sky-switch-control-warning': checkboxType === 'warning',\n 'sky-switch-control-danger': checkboxType === 'danger'\n }\"\n >\n <sky-icon\n *ngIf=\"icon || checked\"\n class=\"sky-checkbox-icon-default\"\n fixedWidth=\"true\"\n [icon]=\"icon || 'check'\"\n >\n </sky-icon>\n <div class=\"sky-checkbox-icon-modern\">\n <sky-icon\n *ngIf=\"icon; else checkedTemplate\"\n fixedWidth=\"true\"\n [icon]=\"icon\"\n >\n </sky-icon>\n <ng-template #checkedTemplate>\n <sky-icon\n *ngIf=\"checked\"\n class=\"sky-checkbox-icon-modern-checked\"\n fixedWidth=\"true\"\n icon=\"check\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </ng-template>\n </div>\n </span>\n <ng-content select=\"sky-checkbox-label\"> </ng-content>\n</label>\n"]}
1
+ {"version":3,"file":"checkbox.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/checkbox/checkbox.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/checkbox/checkbox.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EAEL,QAAQ,EACR,MAAM,EACN,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;;;;;AAEtD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,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,OAAO;QACb,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;;kHA9PU,oBAAoB;sGAApB,oBAAoB,qWC/BjC,+sDA4DA;4FD7Ba,oBAAoB;kBALhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,cAAc;oBACxB,WAAW,EAAE,2BAA2B;oBACxC,SAAS,EAAE,CAAC,2BAA2B,CAAC;iBACzC;;0BA4Kc,IAAI;;0BAAI,QAAQ;4CAnKtB,KAAK;sBADX,KAAK;gBAUC,UAAU;sBADhB,KAAK;gBAQC,EAAE;sBADR,KAAK;gBAQK,QAAQ;sBADlB,KAAK;gBAqBC,QAAQ;sBADd,KAAK;gBAQC,IAAI;sBADV,KAAK;gBAQC,MAAM;sBAFZ,MAAM;gBAUA,IAAI;sBADV,KAAK;gBAYK,YAAY;sBADtB,KAAK;gBAoBK,OAAO;sBADjB,KAAK;gBA+BF,QAAQ;sBADX,KAAK;gBAaK,aAAa;sBADvB,MAAM;gBASI,cAAc;sBADxB,MAAM","sourcesContent":["import {\n Component,\n EventEmitter,\n Input,\n OnInit,\n Optional,\n Output,\n Self,\n} from '@angular/core';\nimport { ControlValueAccessor, NgControl } from '@angular/forms';\n\nimport { BehaviorSubject, Observable } from 'rxjs';\n\nimport { SkyFormsUtility } from '../shared/forms-utility';\n\nimport { SkyCheckboxChange } from './checkbox-change';\n\n/**\n * Monotonically increasing integer used to auto-generate unique ids for checkbox components.\n */\nlet nextId = 0;\n\n/**\n * Replaces the HTML input element with `type=\"checkbox\"`. When users select a checkbox, its value\n * is driven through an `ngModel` attribute that you specify on the `sky-checkbox` element.\n */\n@Component({\n selector: 'sky-checkbox',\n templateUrl: './checkbox.component.html',\n styleUrls: ['./checkbox.component.scss'],\n})\nexport class SkyCheckboxComponent implements ControlValueAccessor, OnInit {\n /**\n * Specifies an ARIA label for the checkbox. This sets the checkbox's `aria-label` attribute\n * [to support accessibility](https://developer.blackbaud.com/skyux/components/checkbox#accessibility)\n * when the checkbox does not include a visible label. You must set this property for icon\n * checkboxes. If the checkbox includes a visible label, use `labelledBy` instead.\n */\n @Input()\n public label: string;\n\n /**\n * Specifies the HTML element ID (without the leading `#`) of the element that labels the\n * checkbox. This sets the checkbox's `aria-labelledby` attribute\n * [to support accessibility](https://developer.blackbaud.com/skyux/components/checkbox#accessibility).\n * If the checkbox does not include a visible label, use `label` instead.\n */\n @Input()\n public labelledBy: string;\n\n /**\n * Specifies an ID for the checkbox.\n * @default a unique, auto-incrementing integer. For example: `sky-checkbox-1`\n */\n @Input()\n public id = `sky-checkbox-${++nextId}`;\n\n /**\n * Indicates whether to disable the checkbox.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);\n if (coercedValue !== this.disabled) {\n this._disabled = coercedValue;\n this._disabledChange.next(this._disabled);\n }\n }\n\n /**\n * Indicates whether the checkbox is disabled.\n */\n public get disabled() {\n return this._disabled;\n }\n\n /**\n * Specifies an index for the checkbox. If not defined, the index is set to the position of the\n * checkbox on load.\n */\n @Input()\n public tabindex = 0;\n\n /**\n * Specifies a name for a group of checkboxes.\n * @default a unique, auto-incrementing integer. For example: `sky-checkbox-1`\n */\n @Input()\n public name = `sky-checkbox-${++nextId}`;\n\n /**\n * Fires when the selected value changes.\n */\n @Output()\n // eslint-disable-next-line @angular-eslint/no-output-native\n public change = new EventEmitter<SkyCheckboxChange>();\n\n /**\n * Specifies an icon to display in place of the checkbox. To group icon checkboxes\n * like in the demo, place the `sky-switch-icon-group` class on the direct parent\n * element of the checkboxes.\n */\n @Input()\n public icon: string;\n\n /**\n * Specifies a type to set the background color after users select a checkbox where the\n * `icon` property displays an icon in place of the checkbox. The valid options correspond to\n * [the label component's](https://developer.blackbaud.com/skyux/components/label)\n * label types. `\"info\"` creates a blue background, `\"success\"` creates a green\n * background, `\"warning\"` creates an orange background, and `\"danger\"` creates a red background.\n * @default \"info\"\n */\n @Input()\n public set checkboxType(value: string) {\n if (value) {\n this._checkboxType = value.toLowerCase();\n }\n }\n\n public get checkboxType(): string {\n return this._checkboxType || 'info';\n }\n\n public get inputId(): string {\n return `input-${this.id}`;\n }\n\n /**\n * Indicates whether the checkbox is selected.\n * @default false\n */\n @Input()\n public set checked(checked: boolean) {\n if (checked !== this.checked) {\n this._checked = checked;\n this._controlValueAccessorChangeFn(checked);\n this._checkedChange.next(this._checked);\n\n // Do not mark the field as \"dirty\"\n // if the field has been initialized with a value.\n if (this.isFirstChange && this.ngControl && this.ngControl.control) {\n this.ngControl.control.markAsPristine();\n this.isFirstChange = false;\n }\n }\n }\n\n /**\n * Indicates whether the checkbox is selected.\n */\n public get checked() {\n return this._checked;\n }\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 * @default false\n */\n @Input()\n set required(value: boolean) {\n this._required = SkyFormsUtility.coerceBooleanProperty(value);\n }\n\n get required(): boolean {\n return this._required;\n }\n\n /**\n * Fires when users select or deselect the checkbox.\n */\n @Output()\n public get checkedChange(): Observable<boolean> {\n return this._checkedChange;\n }\n\n /**\n * Fires when the selected value changes.\n */\n @Output()\n public get disabledChange(): Observable<boolean> {\n return this._disabledChange;\n }\n\n private isFirstChange = true;\n\n private _checkboxType: string;\n\n private _checked = false;\n\n private _checkedChange = new BehaviorSubject<boolean>(this._checked);\n\n private _disabled = false;\n\n private _disabledChange = new BehaviorSubject<boolean>(this._disabled);\n\n private _required = false;\n\n constructor(@Self() @Optional() private ngControl: NgControl) {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n public ngOnInit(): void {\n if (this.ngControl) {\n // Backwards compatibility support for anyone still using Validators.Required.\n this.required =\n this.required || SkyFormsUtility.hasRequiredValidation(this.ngControl);\n }\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public writeValue(value: any) {\n this.checked = !!value;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnChange(fn: (value: any) => void) {\n this._controlValueAccessorChangeFn = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(isDisabled: boolean) {\n this.disabled = isDisabled;\n }\n\n /**\n * Event handler for checkbox input element.\n * Toggles checked state if element is not disabled.\n */\n public onInteractionEvent(event: Event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the `change` output.\n event.stopPropagation();\n\n if (!this.disabled) {\n this._toggle();\n this._emitChangeEvent();\n }\n }\n\n public onInputBlur() {\n this.onTouched();\n }\n\n /** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n public onTouched: () => any = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};\n\n private _emitChangeEvent() {\n const event = new SkyCheckboxChange();\n event.source = this;\n event.checked = this._checked;\n\n this._controlValueAccessorChangeFn(this._checked);\n this.change.emit(event);\n }\n\n /**\n * Toggles the `checked` value between true and false\n */\n private _toggle() {\n this.checked = !this.checked;\n }\n}\n","<label\n class=\"sky-checkbox-wrapper sky-switch\"\n [ngClass]=\"{\n 'sky-control-label-required': required,\n 'sky-switch-disabled': disabled\n }\"\n>\n <input\n class=\"sky-checkbox-input sky-switch-input\"\n type=\"checkbox\"\n [id]=\"inputId\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [name]=\"name\"\n [required]=\"required\"\n [tabIndex]=\"tabindex\"\n [attr.aria-label]=\"label\"\n [attr.aria-labelledby]=\"labelledBy\"\n [attr.aria-required]=\"required ? true : null\"\n (blur)=\"onInputBlur()\"\n (change)=\"onInteractionEvent($event)\"\n />\n <span\n class=\"sky-switch-control sky-rounded-corners\"\n [ngClass]=\"{\n 'sky-switch-control-icon': icon,\n 'sky-switch-control-info': checkboxType === 'info',\n 'sky-switch-control-success': checkboxType === 'success',\n 'sky-switch-control-warning': checkboxType === 'warning',\n 'sky-switch-control-danger': checkboxType === 'danger'\n }\"\n >\n <sky-icon\n *ngIf=\"icon || checked\"\n class=\"sky-checkbox-icon-default\"\n fixedWidth=\"true\"\n [icon]=\"icon || 'check'\"\n >\n </sky-icon>\n <div class=\"sky-checkbox-icon-modern\">\n <sky-icon\n *ngIf=\"icon; else checkedTemplate\"\n fixedWidth=\"true\"\n [icon]=\"icon\"\n >\n </sky-icon>\n <ng-template #checkedTemplate>\n <sky-icon\n *ngIf=\"checked\"\n class=\"sky-checkbox-icon-modern-checked\"\n fixedWidth=\"true\"\n icon=\"check\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </ng-template>\n </div>\n </span>\n <ng-content select=\"sky-checkbox-label\"> </ng-content>\n</label>\n"]}
@@ -48,16 +48,16 @@ export class SkyFileAttachmentComponent {
48
48
  /**
49
49
  * Indicates whether the input is required for form validation.
50
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
51
+ * attributes to the input element so that forms display an invalid state until the input element
52
52
  * is complete.
53
53
  */
54
54
  this.required = false;
55
55
  this.fileAttachmentId = uniqueId++;
56
56
  this.ngUnsubscribe = new Subject();
57
57
  this._disabled = false;
58
- /*istanbul ignore next */
58
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
59
59
  this._onChange = (_) => { };
60
- /*istanbul ignore next */
60
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
61
61
  this._onTouched = () => { };
62
62
  this.labelElementId = `sky-file-attachment-label-${this.fileAttachmentId}`;
63
63
  this.fileDropDescriptionElementId = `sky-file-attachment-drop-description-${this.fileAttachmentId}`;
@@ -1 +1 @@
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;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;;;;;;;;;AAIzD,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;GAEG;AAQH,MAAM,OAAO,0BAA0B;IAsHrC,YACS,QAAyB,EACxB,cAAiC,EACjC,qBAA+C,EAC/C,eAAmC,EACf,SAAoB;QAJzC,aAAQ,GAAR,QAAQ,CAAiB;QACxB,mBAAc,GAAd,cAAc,CAAmB;QACjC,0BAAqB,GAArB,qBAAqB,CAA0B;QAC/C,oBAAe,GAAf,eAAe,CAAoB;QACf,cAAS,GAAT,SAAS,CAAW;QAhGlD;;WAEG;QAEI,gBAAW,GAAG,MAAM,CAAC;QAE5B;;WAEG;QAEI,gBAAW,GAAG,CAAC,CAAC;QASvB;;WAEG;QAEI,eAAU,GAAG,IAAI,YAAY,EAA2B,CAAC;QAEhE;;;WAGG;QAEI,cAAS,GAAG,IAAI,YAAY,EAA0B,CAAC;QAEvD,iBAAY,G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AChB,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,UAAU,CAChB,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE;YACjC,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aACrB;SACF;IACH,CAAC;IAEO,0BAA0B;QAChC,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAC/B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,gBAAgB,KAAK,QAAQ,CACjD,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;;wHArXU,0BAA0B;4GAA1B,0BAA0B,uRAH1B,CAAC,wBAAwB,CAAC,0DA4GpB,+BAA+B,mICtJlD,00GA+GA;4FDlEa,0BAA0B;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;;0BA4HI,IAAI;;0BAAI,QAAQ;4CAlHZ,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 public themeSvc: SkyThemeService,\n private changeDetector: ChangeDetectorRef,\n private fileAttachmentService: SkyFileAttachmentService,\n private fileItemService: SkyFileItemService,\n @Self() @Optional() private ngControl: NgControl\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 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 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 /*istanbul ignore next */\n private _onChange = (_: any) => {};\n /*istanbul ignore next */\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
+ {"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;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;;;;;;;;;AAIzD,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;GAEG;AAQH,MAAM,OAAO,0BAA0B;IAsHrC,YACS,QAAyB,EACxB,cAAiC,EACjC,qBAA+C,EAC/C,eAAmC,EACf,SAAoB;QAJzC,aAAQ,GAAR,QAAQ,CAAiB;QACxB,mBAAc,GAAd,cAAc,CAAmB;QACjC,0BAAqB,GAArB,qBAAqB,CAA0B;QAC/C,oBAAe,GAAf,eAAe,CAAoB;QACf,cAAS,GAAT,SAAS,CAAW;QAhGlD;;WAEG;QAEI,gBAAW,GAAG,MAAM,CAAC;QAE5B;;WAEG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W;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 public themeSvc: SkyThemeService,\n private changeDetector: ChangeDetectorRef,\n private fileAttachmentService: SkyFileAttachmentService,\n private fileItemService: SkyFileItemService,\n @Self() @Optional() private ngControl: NgControl\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 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 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"]}
@@ -169,7 +169,6 @@ export class SkyFileDropComponent {
169
169
  const validFileArray = [];
170
170
  const rejectedFileArray = [];
171
171
  const totalFiles = files.length;
172
- const fileDrop = this;
173
172
  // tslint:disable-next-line: max-line-length
174
173
  const processedFiles = this.fileAttachmentService.checkFiles(files, this.minFileSize, this.maxFileSize, this.acceptedTypes, this.validateFn);
175
174
  for (const file of processedFiles) {
@@ -177,7 +176,7 @@ export class SkyFileDropComponent {
177
176
  this.filesRejected(file, validFileArray, rejectedFileArray, totalFiles);
178
177
  }
179
178
  else {
180
- this.loadFile(fileDrop, file, validFileArray, rejectedFileArray, totalFiles);
179
+ this.loadFile(this, file, validFileArray, rejectedFileArray, totalFiles);
181
180
  }
182
181
  }
183
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-drop.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-drop.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-drop.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,EAEL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;;;;;;;AAKrE;;;;;;;;;GASG;AAOH,MAAM,OAAO,oBAAoB;IAuF/B,YAAoB,qBAA+C;QAA/C,0BAAqB,GAArB,qBAAqB,CAA0B;QAtFnE;;WAEG;QAEI,iBAAY,GAAG,IAAI,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QAAQ,GAAG,IAAI,CAAC;QAEtB,4CAA4C;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAC1D,KAAK,EACL,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,UAAU,CAChB,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE;YACjC,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;aACzE;iBAAM;gBACL,IAAI,CAAC,QAAQ,CACX,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,UAAU,CACX,CAAC;aACH;SACF;IACH,CAAC;;kHAnSU,oBAAoB;sGAApB,oBAAoB,yaAFpB,CAAC,wBAAwB,CAAC,gIC7BvC,69HA2HA;4FD5Fa,oBAAoB;kBANhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,eAAe;oBACzB,WAAW,EAAE,4BAA4B;oBACzC,SAAS,EAAE,CAAC,4BAA4B,CAAC;oBACzC,SAAS,EAAE,CAAC,wBAAwB,CAAC;iBACtC;+GAMQ,YAAY;sBADlB,MAAM;gBAOA,aAAa;sBADnB,MAAM;gBAOA,WAAW;sBADjB,MAAM;gBAQA,mBAAmB;sBADzB,KAAK;gBAQC,mBAAmB;sBADzB,KAAK;gBAOC,WAAW;sBADjB,KAAK;gBAOC,WAAW;sBADjB,KAAK;gBAOC,QAAQ;sBADd,KAAK;gBAQC,UAAU;sBADhB,KAAK;gBASC,aAAa;sBADnB,KAAK;gBAOC,OAAO;sBADb,KAAK;gBAOC,UAAU;sBADhB,KAAK;gBAIC,OAAO;sBADb,SAAS;uBAAC,WAAW","sourcesContent":["import {\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnDestroy,\n Output,\n ViewChild,\n} from '@angular/core';\n\nimport { SkyFileAttachmentService } from './file-attachment.service';\nimport { SkyFileItem } from './file-item';\nimport { SkyFileLink } from './file-link';\nimport { SkyFileDropChange } from './types/file-drop-change';\n\n/**\n * Provides an element to attach multiple files where users can browse or drag and drop local files\n * or provide hyperlinks to external files. You can leave the contents of the component\n * blank to display the drop zone's default UI, or you can specify custom content to\n * display instead. When the module initializes, it disables the ability to drag and\n * drop files for the entire window to prevent the browser from opening files that are\n * accidentally dropped outside the target zone. If you implement your own file drop functionality\n * outside of the file drop component, you can place the `sky-file-drop-target` CSS class\n * on the element that receives drop events to exempt it from the drop exclusion rule.\n */\n@Component({\n selector: 'sky-file-drop',\n templateUrl: './file-drop.component.html',\n styleUrls: ['./file-drop.component.scss'],\n providers: [SkyFileAttachmentService],\n})\nexport class SkyFileDropComponent implements OnDestroy {\n /**\n * Fires when users add or remove files.\n */\n @Output()\n public filesChanged = new EventEmitter<SkyFileDropChange>();\n\n /**\n * Fires when the link input box triggers a blur event.\n */\n @Output()\n public linkInputBlur = new EventEmitter<void>();\n\n /**\n * Fires when users add or remove links.\n */\n @Output()\n public linkChanged = new EventEmitter<SkyFileLink>();\n\n /**\n * Specifies an ARIA label for the file upload button. This provides a text equivalent for\n * screen readers [to support accessibility](https://developer.blackbaud.com/skyux/learn/accessibility).\n */\n @Input()\n public fileUploadAriaLabel: string;\n\n /**\n * Specifies an ARIA label for the link upload input. This provides a text equivalent for\n * screen readers [to support accessibility](https://developer.blackbaud.com/skyux/learn/accessibility).\n */\n @Input()\n public linkUploadAriaLabel: string;\n\n /**\n * Specifies the minimum size in bytes for valid files.\n */\n @Input()\n public minFileSize = 0;\n\n /**\n * Specifies the maximum size in bytes for valid files.\n */\n @Input()\n public maxFileSize = 500000;\n\n /**\n * Indicates whether users can drag and drop multiple files at the same time.\n */\n @Input()\n public multiple = true;\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 * 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 option to browse for files to attach.\n */\n @Input()\n public noClick = false;\n\n /**\n * Indicates whether to display the option to attach files from URLs rather than from local devices.\n */\n @Input()\n public allowLinks = false;\n\n @ViewChild('fileInput')\n public inputEl: ElementRef;\n\n public rejectedOver = false;\n public acceptedOver = false;\n public linkUrl: string;\n\n private enterEventTarget: any;\n\n constructor(private fileAttachmentService: SkyFileAttachmentService) {}\n\n public ngOnDestroy() {\n this.filesChanged.complete();\n this.linkChanged.complete();\n this.linkInputBlur.complete();\n }\n\n public dropClicked() {\n if (!this.noClick) {\n this.inputEl.nativeElement.click();\n }\n }\n\n public fileChangeEvent(fileChangeEvent: any) {\n this.handleFiles(fileChangeEvent.target.files);\n }\n\n public fileDragEnter(dragEnterEvent: any) {\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) {\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 } /* istanbul ignore next: untestable */ 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 const hasDirectory = this.fileAttachmentService.hasDirectory(\n dropEvent.dataTransfer.files\n );\n const invalidNumberOfFiles =\n !this.multiple && dropEvent.dataTransfer.files.length > 1;\n\n if (hasDirectory || invalidNumberOfFiles) {\n return;\n }\n\n this.handleFiles(dropEvent.dataTransfer.files);\n }\n }\n\n public fileDragLeave(dragLeaveEvent: any) {\n if (this.enterEventTarget === dragLeaveEvent.target) {\n this.rejectedOver = false;\n this.acceptedOver = false;\n }\n }\n\n public addLinkEnter(event: KeyboardEvent) {\n if (event.which === 13) {\n this.addLink(event);\n }\n }\n\n public addLink(event: Event) {\n event.preventDefault();\n this.linkChanged.emit({ url: this.linkUrl } as SkyFileLink);\n this.linkUrl = undefined;\n }\n\n public onLinkBlur(): void {\n this.linkInputBlur.emit();\n }\n\n private emitFileChangeEvent(\n totalFiles: number,\n rejectedFileArray: Array<SkyFileItem>,\n validFileArray: Array<SkyFileItem>\n ) {\n if (totalFiles === rejectedFileArray.length + validFileArray.length) {\n this.filesChanged.emit({\n files: validFileArray,\n rejectedFiles: rejectedFileArray,\n } as SkyFileDropChange);\n\n this.inputEl.nativeElement.value = '';\n }\n }\n\n private filesRejected(\n file: SkyFileItem,\n validFileArray: Array<SkyFileItem>,\n rejectedFileArray: Array<SkyFileItem>,\n totalFiles: number\n ) {\n rejectedFileArray.push(file);\n this.emitFileChangeEvent(totalFiles, rejectedFileArray, validFileArray);\n }\n\n private loadFile(\n fileDrop: SkyFileDropComponent,\n file: SkyFileItem,\n validFileArray: Array<SkyFileItem>,\n rejectedFileArray: Array<SkyFileItem>,\n totalFiles: number\n ) {\n const reader = new FileReader();\n\n reader.addEventListener('load', (event: any) => {\n file.url = event.target.result;\n validFileArray.push(file);\n fileDrop.emitFileChangeEvent(\n totalFiles,\n rejectedFileArray,\n validFileArray\n );\n });\n\n reader.addEventListener('error', (event: any) => {\n fileDrop.filesRejected(\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n });\n\n reader.addEventListener('abort', (event: any) => {\n fileDrop.filesRejected(\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n });\n\n reader.readAsDataURL(file.file);\n }\n\n private handleFiles(files: FileList) {\n const validFileArray: Array<SkyFileItem> = [];\n const rejectedFileArray: Array<SkyFileItem> = [];\n const totalFiles = files.length;\n const fileDrop = this;\n\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.filesRejected(file, validFileArray, rejectedFileArray, totalFiles);\n } else {\n this.loadFile(\n fileDrop,\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n }\n }\n }\n}\n","<div\n class=\"sky-file-drop-row\"\n [ngClass]=\"{ 'sky-file-drop-allow-links': allowLinks }\"\n>\n <div\n class=\"sky-file-drop-col\"\n [ngClass]=\"{\n 'sky-file-drop-accept': acceptedOver,\n 'sky-file-drop-reject': rejectedOver\n }\"\n >\n <button\n class=\"sky-file-drop sky-file-drop-target\"\n type=\"button\"\n (click)=\"dropClicked()\"\n (dragover)=\"fileDragOver($event)\"\n (dragenter)=\"fileDragEnter($event)\"\n (dragleave)=\"fileDragLeave($event)\"\n (drop)=\"fileDrop($event)\"\n [attr.aria-label]=\"\n fileUploadAriaLabel ||\n ('skyux_file_attachment_file_upload_drag_or_click' | skyLibResources)\n \"\n ></button>\n\n <input\n tabindex=\"-1\"\n aria-hidden=\"true\"\n type=\"file\"\n class=\"sky-file-input-hidden\"\n [attr.multiple]=\"multiple ? multiple : null\"\n [attr.accept]=\"acceptedTypes ? acceptedTypes : null\"\n (change)=\"fileChangeEvent($event)\"\n #fileInput\n />\n\n <div\n class=\"sky-file-drop-contents sky-padding-even-default\"\n *ngIf=\"customEl.children.length === 0\"\n >\n <div class=\"sky-file-drop-contents-not-over\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_drag_file_here' | skyLibResources\n }}\n </div>\n <div class=\"sky-file-drop-text\">\n {{\n 'skyux_file_attachment_file_upload_or_click_to_browse'\n | skyLibResources\n }}\n </div>\n <sky-icon icon=\"cloud-upload\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n\n <!-- This will appear when file is dragged over and is valid -->\n <div class=\"sky-file-drop-contents-accept\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_drop_files_here'\n | skyLibResources\n }}\n </div>\n <sky-icon icon=\"bullseye\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n\n <!-- This will appear when file is dragged over and is invalid -->\n <div class=\"sky-file-drop-contents-reject\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_invalid_file' | skyLibResources\n }}\n </div>\n <sky-icon icon=\"times-circle\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n </div>\n\n <div class=\"sky-file-drop-contents-custom\" #customEl>\n <ng-content></ng-content>\n </div>\n </div>\n <div class=\"sky-file-drop-col\" *ngIf=\"allowLinks\">\n <div class=\"sky-file-drop-contents sky-padding-even-default\">\n <div class=\"sky-file-drop-link\">\n <div class=\"sky-file-drop-link-header\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_paste_link' | skyLibResources\n }}\n </div>\n </div>\n <div class=\"sky-form-group\">\n <input\n type=\"text\"\n class=\"sky-form-control\"\n [attr.aria-label]=\"\n linkUploadAriaLabel ||\n ('skyux_file_attachment_file_upload_link_input' | skyLibResources)\n \"\n [attr.placeholder]=\"\n 'skyux_file_attachment_file_upload_link_placeholder'\n | skyLibResources\n \"\n [(ngModel)]=\"linkUrl\"\n (blur)=\"onLinkBlur()\"\n (keyup)=\"addLinkEnter($event)\"\n />\n </div>\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-primary\"\n [disabled]=\"!linkUrl\"\n (click)=\"addLink($event)\"\n >\n {{\n 'skyux_file_attachment_file_upload_paste_link_done'\n | skyLibResources\n }}\n </button>\n </div>\n </div>\n </div>\n</div>\n"]}
1
+ {"version":3,"file":"file-drop.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-drop.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-drop.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,EAEL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;;;;;;;AAKrE;;;;;;;;;GASG;AAOH,MAAM,OAAO,oBAAoB;IAuF/B,YAAoB,qBAA+C;QAA/C,0BAAqB,GAArB,qBAAqB,CAA0B;QAtFnE;;WAEG;QAEI,iBAAY,GAAG,IAAI,YAAY,EAAqB,CAAC;QAE5D;;WAEG;QAEI,kBAAa,GAAG,IAAI,YAAY,EAAQ,CAAC;QAEhD;;WAEG;QAEI,gBAAW,GAAG,IAAI,YAAY,EAAe,CAAC;QAgBrD;;WAEG;QAEI,gBAAW,GAAG,CAAC,CAAC;QAEvB;;WAEG;QAEI,gBAAW,GAAG,MAAM,CAAC;QAE5B;;WAEG;QAEI,aAAQ,GAAG,IAAI,CAAC;QAiBvB;;WAEG;QAEI,YAAO,GAAG,KAAK,CAAC;QAEvB;;WAEG;QAEI,eAAU,GAAG,KAAK,CAAC;QAKnB,iBAAY,GAAG,KAAK,CAAC;QACrB,iBAAY,GAAG,KAAK,CAAC;IAK0C,CAAC;IAEhE,WAAW;QAChB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,QAA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mBAAC;oBACT,QAAQ,EAAE,eAAe;oBACzB,WAAW,EAAE,4BAA4B;oBACzC,SAAS,EAAE,CAAC,4BAA4B,CAAC;oBACzC,SAAS,EAAE,CAAC,wBAAwB,CAAC;iBACtC;+GAMQ,YAAY;sBADlB,MAAM;gBAOA,aAAa;sBADnB,MAAM;gBAOA,WAAW;sBADjB,MAAM;gBAQA,mBAAmB;sBADzB,KAAK;gBAQC,mBAAmB;sBADzB,KAAK;gBAOC,WAAW;sBADjB,KAAK;gBAOC,WAAW;sBADjB,KAAK;gBAOC,QAAQ;sBADd,KAAK;gBAQC,UAAU;sBADhB,KAAK;gBASC,aAAa;sBADnB,KAAK;gBAOC,OAAO;sBADb,KAAK;gBAOC,UAAU;sBADhB,KAAK;gBAIC,OAAO;sBADb,SAAS;uBAAC,WAAW","sourcesContent":["import {\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnDestroy,\n Output,\n ViewChild,\n} from '@angular/core';\n\nimport { SkyFileAttachmentService } from './file-attachment.service';\nimport { SkyFileItem } from './file-item';\nimport { SkyFileLink } from './file-link';\nimport { SkyFileDropChange } from './types/file-drop-change';\n\n/**\n * Provides an element to attach multiple files where users can browse or drag and drop local files\n * or provide hyperlinks to external files. You can leave the contents of the component\n * blank to display the drop zone's default UI, or you can specify custom content to\n * display instead. When the module initializes, it disables the ability to drag and\n * drop files for the entire window to prevent the browser from opening files that are\n * accidentally dropped outside the target zone. If you implement your own file drop functionality\n * outside of the file drop component, you can place the `sky-file-drop-target` CSS class\n * on the element that receives drop events to exempt it from the drop exclusion rule.\n */\n@Component({\n selector: 'sky-file-drop',\n templateUrl: './file-drop.component.html',\n styleUrls: ['./file-drop.component.scss'],\n providers: [SkyFileAttachmentService],\n})\nexport class SkyFileDropComponent implements OnDestroy {\n /**\n * Fires when users add or remove files.\n */\n @Output()\n public filesChanged = new EventEmitter<SkyFileDropChange>();\n\n /**\n * Fires when the link input box triggers a blur event.\n */\n @Output()\n public linkInputBlur = new EventEmitter<void>();\n\n /**\n * Fires when users add or remove links.\n */\n @Output()\n public linkChanged = new EventEmitter<SkyFileLink>();\n\n /**\n * Specifies an ARIA label for the file upload button. This provides a text equivalent for\n * screen readers [to support accessibility](https://developer.blackbaud.com/skyux/learn/accessibility).\n */\n @Input()\n public fileUploadAriaLabel: string;\n\n /**\n * Specifies an ARIA label for the link upload input. This provides a text equivalent for\n * screen readers [to support accessibility](https://developer.blackbaud.com/skyux/learn/accessibility).\n */\n @Input()\n public linkUploadAriaLabel: string;\n\n /**\n * Specifies the minimum size in bytes for valid files.\n */\n @Input()\n public minFileSize = 0;\n\n /**\n * Specifies the maximum size in bytes for valid files.\n */\n @Input()\n public maxFileSize = 500000;\n\n /**\n * Indicates whether users can drag and drop multiple files at the same time.\n */\n @Input()\n public multiple = true;\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 * 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 option to browse for files to attach.\n */\n @Input()\n public noClick = false;\n\n /**\n * Indicates whether to display the option to attach files from URLs rather than from local devices.\n */\n @Input()\n public allowLinks = false;\n\n @ViewChild('fileInput')\n public inputEl: ElementRef;\n\n public rejectedOver = false;\n public acceptedOver = false;\n public linkUrl: string;\n\n private enterEventTarget: any;\n\n constructor(private fileAttachmentService: SkyFileAttachmentService) {}\n\n public ngOnDestroy() {\n this.filesChanged.complete();\n this.linkChanged.complete();\n this.linkInputBlur.complete();\n }\n\n public dropClicked() {\n if (!this.noClick) {\n this.inputEl.nativeElement.click();\n }\n }\n\n public fileChangeEvent(fileChangeEvent: any) {\n this.handleFiles(fileChangeEvent.target.files);\n }\n\n public fileDragEnter(dragEnterEvent: any) {\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) {\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 } /* istanbul ignore next: untestable */ 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 const hasDirectory = this.fileAttachmentService.hasDirectory(\n dropEvent.dataTransfer.files\n );\n const invalidNumberOfFiles =\n !this.multiple && dropEvent.dataTransfer.files.length > 1;\n\n if (hasDirectory || invalidNumberOfFiles) {\n return;\n }\n\n this.handleFiles(dropEvent.dataTransfer.files);\n }\n }\n\n public fileDragLeave(dragLeaveEvent: any) {\n if (this.enterEventTarget === dragLeaveEvent.target) {\n this.rejectedOver = false;\n this.acceptedOver = false;\n }\n }\n\n public addLinkEnter(event: KeyboardEvent) {\n if (event.which === 13) {\n this.addLink(event);\n }\n }\n\n public addLink(event: Event) {\n event.preventDefault();\n this.linkChanged.emit({ url: this.linkUrl } as SkyFileLink);\n this.linkUrl = undefined;\n }\n\n public onLinkBlur(): void {\n this.linkInputBlur.emit();\n }\n\n private emitFileChangeEvent(\n totalFiles: number,\n rejectedFileArray: Array<SkyFileItem>,\n validFileArray: Array<SkyFileItem>\n ) {\n if (totalFiles === rejectedFileArray.length + validFileArray.length) {\n this.filesChanged.emit({\n files: validFileArray,\n rejectedFiles: rejectedFileArray,\n } as SkyFileDropChange);\n\n this.inputEl.nativeElement.value = '';\n }\n }\n\n private filesRejected(\n file: SkyFileItem,\n validFileArray: Array<SkyFileItem>,\n rejectedFileArray: Array<SkyFileItem>,\n totalFiles: number\n ) {\n rejectedFileArray.push(file);\n this.emitFileChangeEvent(totalFiles, rejectedFileArray, validFileArray);\n }\n\n private loadFile(\n fileDrop: SkyFileDropComponent,\n file: SkyFileItem,\n validFileArray: Array<SkyFileItem>,\n rejectedFileArray: Array<SkyFileItem>,\n totalFiles: number\n ) {\n const reader = new FileReader();\n\n reader.addEventListener('load', (event: any) => {\n file.url = event.target.result;\n validFileArray.push(file);\n fileDrop.emitFileChangeEvent(\n totalFiles,\n rejectedFileArray,\n validFileArray\n );\n });\n\n reader.addEventListener('error', (event: any) => {\n fileDrop.filesRejected(\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n });\n\n reader.addEventListener('abort', (event: any) => {\n fileDrop.filesRejected(\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n });\n\n reader.readAsDataURL(file.file);\n }\n\n private handleFiles(files: FileList) {\n const validFileArray: Array<SkyFileItem> = [];\n const rejectedFileArray: Array<SkyFileItem> = [];\n const totalFiles = files.length;\n\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.filesRejected(file, validFileArray, rejectedFileArray, totalFiles);\n } else {\n this.loadFile(\n this,\n file,\n validFileArray,\n rejectedFileArray,\n totalFiles\n );\n }\n }\n }\n}\n","<div\n class=\"sky-file-drop-row\"\n [ngClass]=\"{ 'sky-file-drop-allow-links': allowLinks }\"\n>\n <div\n class=\"sky-file-drop-col\"\n [ngClass]=\"{\n 'sky-file-drop-accept': acceptedOver,\n 'sky-file-drop-reject': rejectedOver\n }\"\n >\n <button\n class=\"sky-file-drop sky-file-drop-target\"\n type=\"button\"\n (click)=\"dropClicked()\"\n (dragover)=\"fileDragOver($event)\"\n (dragenter)=\"fileDragEnter($event)\"\n (dragleave)=\"fileDragLeave($event)\"\n (drop)=\"fileDrop($event)\"\n [attr.aria-label]=\"\n fileUploadAriaLabel ||\n ('skyux_file_attachment_file_upload_drag_or_click' | skyLibResources)\n \"\n ></button>\n\n <input\n tabindex=\"-1\"\n aria-hidden=\"true\"\n type=\"file\"\n class=\"sky-file-input-hidden\"\n [attr.multiple]=\"multiple ? multiple : null\"\n [attr.accept]=\"acceptedTypes ? acceptedTypes : null\"\n (change)=\"fileChangeEvent($event)\"\n #fileInput\n />\n\n <div\n class=\"sky-file-drop-contents sky-padding-even-default\"\n *ngIf=\"customEl.children.length === 0\"\n >\n <div class=\"sky-file-drop-contents-not-over\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_drag_file_here' | skyLibResources\n }}\n </div>\n <div class=\"sky-file-drop-text\">\n {{\n 'skyux_file_attachment_file_upload_or_click_to_browse'\n | skyLibResources\n }}\n </div>\n <sky-icon icon=\"cloud-upload\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n\n <!-- This will appear when file is dragged over and is valid -->\n <div class=\"sky-file-drop-contents-accept\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_drop_files_here'\n | skyLibResources\n }}\n </div>\n <sky-icon icon=\"bullseye\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n\n <!-- This will appear when file is dragged over and is invalid -->\n <div class=\"sky-file-drop-contents-reject\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_invalid_file' | skyLibResources\n }}\n </div>\n <sky-icon icon=\"times-circle\" class=\"sky-file-upload-icon\"></sky-icon>\n </div>\n </div>\n\n <div class=\"sky-file-drop-contents-custom\" #customEl>\n <ng-content></ng-content>\n </div>\n </div>\n <div class=\"sky-file-drop-col\" *ngIf=\"allowLinks\">\n <div class=\"sky-file-drop-contents sky-padding-even-default\">\n <div class=\"sky-file-drop-link\">\n <div class=\"sky-file-drop-link-header\">\n <div class=\"sky-file-drop-text-header sky-headline\">\n {{\n 'skyux_file_attachment_file_upload_paste_link' | skyLibResources\n }}\n </div>\n </div>\n <div class=\"sky-form-group\">\n <input\n type=\"text\"\n class=\"sky-form-control\"\n [attr.aria-label]=\"\n linkUploadAriaLabel ||\n ('skyux_file_attachment_file_upload_link_input' | skyLibResources)\n \"\n [attr.placeholder]=\"\n 'skyux_file_attachment_file_upload_link_placeholder'\n | skyLibResources\n \"\n [(ngModel)]=\"linkUrl\"\n (blur)=\"onLinkBlur()\"\n (keyup)=\"addLinkEnter($event)\"\n />\n </div>\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-primary\"\n [disabled]=\"!linkUrl\"\n (click)=\"addLink($event)\"\n >\n {{\n 'skyux_file_attachment_file_upload_paste_link_done'\n | skyLibResources\n }}\n </button>\n </div>\n </div>\n </div>\n</div>\n"]}
@@ -29,7 +29,9 @@ export class SkyFileItemComponent {
29
29
  ngDoCheck() {
30
30
  const changes = this.differ.diff(this.fileItem);
31
31
  if (changes) {
32
- let cls, extensionUpper = this.fileItemService.getFileExtensionUpper(this.fileItem), fileTypeUpper;
32
+ let cls;
33
+ const extensionUpper = this.fileItemService.getFileExtensionUpper(this.fileItem);
34
+ let fileTypeUpper;
33
35
  switch (extensionUpper) {
34
36
  case '.PDF':
35
37
  cls = 'pdf';
@@ -1 +1 @@
1
- {"version":3,"file":"file-item.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,S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AC,CAAC;IACnE,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,QAAuB,CAAC,CAAC;IACpE,CAAC;;kHA3HU,oBAAoB;sGAApB,oBAAoB,8HCnBjC,o/CA6CA;4FD1Ba,oBAAoB;kBALhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,eAAe;oBACzB,WAAW,EAAE,4BAA4B;oBACzC,SAAS,EAAE,CAAC,4BAA4B,CAAC;iBAC1C;uIAUQ,QAAQ;sBADd,KAAK;gBAQC,UAAU;sBADhB,MAAM","sourcesContent":["import {\n Component,\n DoCheck,\n EventEmitter,\n Input,\n KeyValueDiffer,\n KeyValueDiffers,\n Output,\n} from '@angular/core';\n\nimport { SkyFileItem } from './file-item';\nimport { SkyFileItemService } from './file-item.service';\nimport { SkyFileLink } from './file-link';\n\n@Component({\n selector: 'sky-file-item',\n templateUrl: './file-item.component.html',\n styleUrls: ['./file-item.component.scss'],\n})\nexport class SkyFileItemComponent implements DoCheck {\n /**\n * Specifies the summary information to display about file attachments. For local files,\n * the default summary includes the file name, file size, file preview, and a delete button.\n * For external files, the default summary includes the URL and a delete button.\n * You can include additional inputs to display user-entered metadata.\n * @required\n */\n @Input()\n public fileItem: SkyFileItem | SkyFileLink;\n\n /**\n * Fires when users select the delete button for an item. The deleted item is passed to the\n * function.\n */\n @Output()\n public deleteFile = new EventEmitter<SkyFileLink | SkyFileItem>();\n\n public get fileName(): string {\n return (this.fileItem as SkyFileItem).file.name;\n }\n\n public get fileSize(): number {\n return (this.fileItem as SkyFileItem).file.size;\n }\n\n public get url(): string {\n return this.fileItem.url;\n }\n\n public icon: string;\n\n private differ: KeyValueDiffer<any, any>;\n\n public constructor(\n private differs: KeyValueDiffers,\n private fileItemService: SkyFileItemService\n ) {\n this.differ = this.differs.find({}).create();\n }\n\n public ngDoCheck() {\n const changes = this.differ.diff(this.fileItem);\n\n if (changes) {\n let cls: string,\n extensionUpper = this.fileItemService.getFileExtensionUpper(\n this.fileItem as SkyFileItem\n ),\n fileTypeUpper: string;\n\n switch (extensionUpper) {\n case '.PDF':\n cls = 'pdf';\n break;\n case '.GZ':\n case '.RAR':\n case '.TGZ':\n case '.ZIP':\n cls = 'archive';\n break;\n case '.PPT':\n case '.PPTX':\n cls = 'powerpoint';\n break;\n case '.DOC':\n case '.DOCX':\n cls = 'word';\n break;\n case '.XLS':\n case '.XLSX':\n cls = 'excel';\n break;\n case '.TXT':\n cls = 'text';\n break;\n case '.HTM':\n case '.HTML':\n cls = 'code';\n break;\n default:\n break;\n }\n\n if (!cls) {\n fileTypeUpper = this.fileItemService.getFileTypeUpper(\n this.fileItem as SkyFileItem\n );\n\n switch (fileTypeUpper.substr(0, fileTypeUpper.indexOf('/'))) {\n case 'AUDIO':\n cls = 'audio';\n break;\n case 'IMAGE':\n // Normally images are displayed as thumbnails, but if an image type is not recognized\n // as being widely supported by modern browsers (e.g. TIFF files) then an icon should\n // be displayed instead.\n cls = 'image';\n break;\n case 'TEXT':\n cls = 'text';\n break;\n case 'VIDEO':\n cls = 'video';\n break;\n default:\n break;\n }\n }\n this.icon = 'file-' + (cls ? cls + '-' : '') + 'o';\n }\n }\n\n public itemDelete() {\n this.deleteFile.emit(this.fileItem);\n }\n\n public isFile() {\n return this.fileItemService.isFile(this.fileItem as SkyFileItem);\n }\n\n public isImage() {\n return this.fileItemService.isImage(this.fileItem as SkyFileItem);\n }\n}\n","<div class=\"sky-file-item sky-padding-even-default\">\n <div class=\"sky-file-item-title\">\n <div class=\"sky-file-item-name-container\">\n <div class=\"sky-file-item-name\">\n <strong *ngIf=\"isFile()\">{{ fileName }}</strong>\n <strong *ngIf=\"!isFile()\">{{ url }}</strong>\n </div>\n <div class=\"sky-file-item-size\" *ngIf=\"isFile()\">\n ({{ fileSize | skyFileSize }})\n </div>\n </div>\n <div class=\"sky-file-item-controls\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-file-item-btn-delete\"\n [attr.aria-label]=\"\n 'skyux_file_attachment_file_item_delete' | skyLibResources\n \"\n (click)=\"itemDelete()\"\n >\n <sky-icon icon=\"trash-o\" size=\"lg\"></sky-icon>\n </button>\n </div>\n </div>\n <div class=\"sky-file-item-content\">\n <div class=\"sky-file-item-preview\">\n <div *ngIf=\"isImage()\" class=\"sky-file-item-preview-img-container\">\n <img\n class=\"sky-file-item-preview-img\"\n [src]=\"url\"\n [alt]=\"\n 'skyux_file_attachment_file_upload_image_preview_alt_text'\n | skyLibResources\n \"\n />\n </div>\n <div *ngIf=\"!isImage()\" class=\"sky-file-item-preview-other\">\n <sky-icon [icon]=\"icon\"></sky-icon>\n </div>\n </div>\n <div class=\"sky-file-item-content-custom\">\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n"]}
1
+ {"version":3,"file":"file-item.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.component.ts","../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,KAAK,EAEL,eAAe,EACf,MAAM,GACP,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;;;;;;;AAQzD,MAAM,OAAO,oBAAoB;IAkC/B,YACU,OAAwB,EACxB,eAAmC;QADnC,YAAO,GAAP,OAAO,CAAiB;QACxB,oBAAe,GAAf,eAAe,CAAoB;QAzB7C;;;WAGG;QAEI,eAAU,GAAG,IAAI,YAAY,EAA6B,CAAC;QAsBhE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/C,CAAC;IArBD,IAAW,QAAQ;QACjB,OAAQ,IAAI,CAAC,QAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;IAClD,CAAC;IAED,IAAW,QAAQ;QACjB,OAAQ,IAAI,CAAC,QAAwB,CAA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GAAG,CAAC,CAAC,EAAE;oBAC3D,KAAK,OAAO;wBACV,GAAG,GAAG,OAAO,CAAC;wBACd,MAAM;oBACR,KAAK,OAAO;wBACV,sFAAsF;wBACtF,qFAAqF;wBACrF,wBAAwB;wBACxB,GAAG,GAAG,OAAO,CAAC;wBACd,MAAM;oBACR,KAAK,MAAM;wBACT,GAAG,GAAG,MAAM,CAAC;wBACb,MAAM;oBACR,KAAK,OAAO;wBACV,GAAG,GAAG,OAAO,CAAC;wBACd,MAAM;oBACR;wBACE,MAAM;iBACT;aACF;YACD,IAAI,CAAC,IAAI,GAAG,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;SACpD;IACH,CAAC;IAEM,UAAU;QACf,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,QAAuB,CAAC,CAAC;IACnE,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,QAAuB,CAAC,CAAC;IACpE,CAAC;;kHA3HU,oBAAoB;sGAApB,oBAAoB,8HCnBjC,o/CA6CA;4FD1Ba,oBAAoB;kBALhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,eAAe;oBACzB,WAAW,EAAE,4BAA4B;oBACzC,SAAS,EAAE,CAAC,4BAA4B,CAAC;iBAC1C;uIAUQ,QAAQ;sBADd,KAAK;gBAQC,UAAU;sBADhB,MAAM","sourcesContent":["import {\n Component,\n DoCheck,\n EventEmitter,\n Input,\n KeyValueDiffer,\n KeyValueDiffers,\n Output,\n} from '@angular/core';\n\nimport { SkyFileItem } from './file-item';\nimport { SkyFileItemService } from './file-item.service';\nimport { SkyFileLink } from './file-link';\n\n@Component({\n selector: 'sky-file-item',\n templateUrl: './file-item.component.html',\n styleUrls: ['./file-item.component.scss'],\n})\nexport class SkyFileItemComponent implements DoCheck {\n /**\n * Specifies the summary information to display about file attachments. For local files,\n * the default summary includes the file name, file size, file preview, and a delete button.\n * For external files, the default summary includes the URL and a delete button.\n * You can include additional inputs to display user-entered metadata.\n * @required\n */\n @Input()\n public fileItem: SkyFileItem | SkyFileLink;\n\n /**\n * Fires when users select the delete button for an item. The deleted item is passed to the\n * function.\n */\n @Output()\n public deleteFile = new EventEmitter<SkyFileLink | SkyFileItem>();\n\n public get fileName(): string {\n return (this.fileItem as SkyFileItem).file.name;\n }\n\n public get fileSize(): number {\n return (this.fileItem as SkyFileItem).file.size;\n }\n\n public get url(): string {\n return this.fileItem.url;\n }\n\n public icon: string;\n\n private differ: KeyValueDiffer<any, any>;\n\n public constructor(\n private differs: KeyValueDiffers,\n private fileItemService: SkyFileItemService\n ) {\n this.differ = this.differs.find({}).create();\n }\n\n public ngDoCheck() {\n const changes = this.differ.diff(this.fileItem);\n\n if (changes) {\n let cls: string;\n const extensionUpper = this.fileItemService.getFileExtensionUpper(\n this.fileItem as SkyFileItem\n );\n let fileTypeUpper: string;\n\n switch (extensionUpper) {\n case '.PDF':\n cls = 'pdf';\n break;\n case '.GZ':\n case '.RAR':\n case '.TGZ':\n case '.ZIP':\n cls = 'archive';\n break;\n case '.PPT':\n case '.PPTX':\n cls = 'powerpoint';\n break;\n case '.DOC':\n case '.DOCX':\n cls = 'word';\n break;\n case '.XLS':\n case '.XLSX':\n cls = 'excel';\n break;\n case '.TXT':\n cls = 'text';\n break;\n case '.HTM':\n case '.HTML':\n cls = 'code';\n break;\n default:\n break;\n }\n\n if (!cls) {\n fileTypeUpper = this.fileItemService.getFileTypeUpper(\n this.fileItem as SkyFileItem\n );\n\n switch (fileTypeUpper.substr(0, fileTypeUpper.indexOf('/'))) {\n case 'AUDIO':\n cls = 'audio';\n break;\n case 'IMAGE':\n // Normally images are displayed as thumbnails, but if an image type is not recognized\n // as being widely supported by modern browsers (e.g. TIFF files) then an icon should\n // be displayed instead.\n cls = 'image';\n break;\n case 'TEXT':\n cls = 'text';\n break;\n case 'VIDEO':\n cls = 'video';\n break;\n default:\n break;\n }\n }\n this.icon = 'file-' + (cls ? cls + '-' : '') + 'o';\n }\n }\n\n public itemDelete() {\n this.deleteFile.emit(this.fileItem);\n }\n\n public isFile() {\n return this.fileItemService.isFile(this.fileItem as SkyFileItem);\n }\n\n public isImage() {\n return this.fileItemService.isImage(this.fileItem as SkyFileItem);\n }\n}\n","<div class=\"sky-file-item sky-padding-even-default\">\n <div class=\"sky-file-item-title\">\n <div class=\"sky-file-item-name-container\">\n <div class=\"sky-file-item-name\">\n <strong *ngIf=\"isFile()\">{{ fileName }}</strong>\n <strong *ngIf=\"!isFile()\">{{ url }}</strong>\n </div>\n <div class=\"sky-file-item-size\" *ngIf=\"isFile()\">\n ({{ fileSize | skyFileSize }})\n </div>\n </div>\n <div class=\"sky-file-item-controls\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-file-item-btn-delete\"\n [attr.aria-label]=\"\n 'skyux_file_attachment_file_item_delete' | skyLibResources\n \"\n (click)=\"itemDelete()\"\n >\n <sky-icon icon=\"trash-o\" size=\"lg\"></sky-icon>\n </button>\n </div>\n </div>\n <div class=\"sky-file-item-content\">\n <div class=\"sky-file-item-preview\">\n <div *ngIf=\"isImage()\" class=\"sky-file-item-preview-img-container\">\n <img\n class=\"sky-file-item-preview-img\"\n [src]=\"url\"\n [alt]=\"\n 'skyux_file_attachment_file_upload_image_preview_alt_text'\n | skyLibResources\n \"\n />\n </div>\n <div *ngIf=\"!isImage()\" class=\"sky-file-item-preview-other\">\n <sky-icon [icon]=\"icon\"></sky-icon>\n </div>\n </div>\n <div class=\"sky-file-item-content-custom\">\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n"]}
@@ -15,8 +15,8 @@ export class SkyFileItemService {
15
15
  /* tslint:enable */
16
16
  }
17
17
  isImage(fileItem) {
18
- let fileTypeUpper = this.getFileTypeUpper(fileItem), slashIndex;
19
- slashIndex = fileTypeUpper.indexOf('/');
18
+ const fileTypeUpper = this.getFileTypeUpper(fileItem);
19
+ const slashIndex = fileTypeUpper.indexOf('/');
20
20
  if (slashIndex >= 0) {
21
21
  switch (fileTypeUpper.substr(fileTypeUpper.indexOf('/') + 1)) {
22
22
  case 'BMP':
@@ -1 +1 @@
1
- {"version":3,"file":"file-item.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAI3C;;GAEG;AAEH,MAAM,OAAO,kBAAkB;IACtB,MAAM,CAAC,QAAqB;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QAE3B,oBAAoB;QACpB,OAAO,CACL,IAAI;YACJ,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,IAAI;YACb,IAAI,CAAC,IAAI,KAAK,SAAS;YACvB,IAAI,CAAC,IAAI,KAAK,IAAI,CACnB,CAAC;QACF,mBAAmB;IACrB,CAAC;IAEM,OAAO,CAAC,QAAqB;QAClC,IAAI,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EACjD,UAAkB,CAAC;QAErB,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAExC,IAAI,UAAU,IAAI,CAAC,EAAE;YACnB,QAAQ,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC5D,KAAK,KAAK,CAAC;gBACX,KAAK,KAAK,CAAC;gBACX,KAAK,MAAM,CAAC;gBACZ,KAAK,KAAK;oBACR,OAAO,IAAI,CAAC;gBACd;oBACE,MAAM;aACT;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,qBAAqB,CAAC,QAAqB;QAChD,IAAI,SAAS,GAAG,EAAE,EAChB,IAAY,CAAC;QAEf,0BAA0B;QAC1B,kBAAkB;QAClB,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC3B,IAAI,IAAI,EAAE;gBACR,0BAA0B;gBAC1B,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;gBACvB,0BAA0B;gBAC1B,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;aACtD;iBAAM;gBACL,SAAS,GAAG,EAAE,CAAC;aAChB;SACF;QAED,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;IAEM,gBAAgB,CAAC,QAAqB;QAC3C,IAAI,QAAQ,GAAG,EAAE,CAAC;QAClB,0BAA0B;QAC1B,kBAAkB;QAClB,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC3B,IAAI,IAAI,EAAE;gBACR,QAAQ,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;aAC5B;iBAAM;gBACL,QAAQ,GAAG,EAAE,CAAC;aACf;SACF;QAED,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;;gHAvEU,kBAAkB;oHAAlB,kBAAkB;4FAAlB,kBAAkB;kBAD9B,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { SkyFileItem } from './file-item';\n\n/**\n * @internal\n */\n@Injectable()\nexport class SkyFileItemService {\n public isFile(fileItem: SkyFileItem): boolean {\n const file = fileItem.file;\n\n /* tslint:disable */\n return (\n file &&\n file !== undefined &&\n file !== null &&\n file.size !== undefined &&\n file.size !== null\n );\n /* tslint:enable */\n }\n\n public isImage(fileItem: SkyFileItem): boolean {\n let fileTypeUpper = this.getFileTypeUpper(fileItem),\n slashIndex: number;\n\n slashIndex = fileTypeUpper.indexOf('/');\n\n if (slashIndex >= 0) {\n switch (fileTypeUpper.substr(fileTypeUpper.indexOf('/') + 1)) {\n case 'BMP':\n case 'GIF':\n case 'JPEG':\n case 'PNG':\n return true;\n default:\n break;\n }\n }\n\n return false;\n }\n\n public getFileExtensionUpper(fileItem: SkyFileItem): string {\n let extension = '',\n name: string;\n\n /* istanbul ignore else */\n /* sanity check */\n if (fileItem) {\n const file = fileItem.file;\n if (file) {\n /* istanbul ignore next */\n name = file.name || '';\n /* istanbul ignore next */\n extension = name.substr(name.lastIndexOf('.')) || '';\n } else {\n extension = '';\n }\n }\n\n return extension.toUpperCase();\n }\n\n public getFileTypeUpper(fileItem: SkyFileItem): string {\n let fileType = '';\n /* istanbul ignore else */\n /* sanity check */\n if (fileItem) {\n const file = fileItem.file;\n if (file) {\n fileType = file.type || '';\n } else {\n fileType = '';\n }\n }\n\n return fileType.toUpperCase();\n }\n}\n"]}
1
+ {"version":3,"file":"file-item.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-item.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAI3C;;GAEG;AAEH,MAAM,OAAO,kBAAkB;IACtB,MAAM,CAAC,QAAqB;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QAE3B,oBAAoB;QACpB,OAAO,CACL,IAAI;YACJ,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,IAAI;YACb,IAAI,CAAC,IAAI,KAAK,SAAS;YACvB,IAAI,CAAC,IAAI,KAAK,IAAI,CACnB,CAAC;QACF,mBAAmB;IACrB,CAAC;IAEM,OAAO,CAAC,QAAqB;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAE9C,IAAI,UAAU,IAAI,CAAC,EAAE;Y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';\n\nimport { SkyFileItem } from './file-item';\n\n/**\n * @internal\n */\n@Injectable()\nexport class SkyFileItemService {\n public isFile(fileItem: SkyFileItem): boolean {\n const file = fileItem.file;\n\n /* tslint:disable */\n return (\n file &&\n file !== undefined &&\n file !== null &&\n file.size !== undefined &&\n file.size !== null\n );\n /* tslint:enable */\n }\n\n public isImage(fileItem: SkyFileItem): boolean {\n const fileTypeUpper = this.getFileTypeUpper(fileItem);\n const slashIndex = fileTypeUpper.indexOf('/');\n\n if (slashIndex >= 0) {\n switch (fileTypeUpper.substr(fileTypeUpper.indexOf('/') + 1)) {\n case 'BMP':\n case 'GIF':\n case 'JPEG':\n case 'PNG':\n return true;\n default:\n break;\n }\n }\n\n return false;\n }\n\n public getFileExtensionUpper(fileItem: SkyFileItem): string {\n let extension = '',\n name: string;\n\n /* istanbul ignore else */\n /* sanity check */\n if (fileItem) {\n const file = fileItem.file;\n if (file) {\n /* istanbul ignore next */\n name = file.name || '';\n /* istanbul ignore next */\n extension = name.substr(name.lastIndexOf('.')) || '';\n } else {\n extension = '';\n }\n }\n\n return extension.toUpperCase();\n }\n\n public getFileTypeUpper(fileItem: SkyFileItem): string {\n let fileType = '';\n /* istanbul ignore else */\n /* sanity check */\n if (fileItem) {\n const file = fileItem.file;\n if (file) {\n fileType = file.type || '';\n } else {\n fileType = '';\n }\n }\n\n return fileType.toUpperCase();\n }\n}\n"]}
@@ -13,7 +13,7 @@ export class SkyFileSizePipe {
13
13
  this.resourcesService = resourcesService;
14
14
  }
15
15
  transform(input) {
16
- let decimalPlaces = 0, dividend = 1, formattedSize, roundedSize, template;
16
+ let decimalPlaces = 0, dividend = 1, template;
17
17
  /* tslint:disable */
18
18
  if (input === null || input === undefined) {
19
19
  return '';
@@ -39,10 +39,9 @@ export class SkyFileSizePipe {
39
39
  dividend = 1e9;
40
40
  decimalPlaces = 1;
41
41
  }
42
- roundedSize =
43
- Math.floor(input / (dividend / Math.pow(10, decimalPlaces))) /
44
- Math.pow(10, decimalPlaces);
45
- formattedSize = this.decimalPipe.transform(roundedSize, '.0-3');
42
+ const roundedSize = Math.floor(input / (dividend / Math.pow(10, decimalPlaces))) /
43
+ Math.pow(10, decimalPlaces);
44
+ const formattedSize = this.decimalPipe.transform(roundedSize, '.0-3');
46
45
  return this.getString(template, formattedSize);
47
46
  }
48
47
  getString(key, ...args) {
@@ -1 +1 @@
1
- {"version":3,"file":"file-size.pipe.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-size.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;;;;AAErD;;GAEG;AAIH,MAAM,OAAO,eAAe;IAC1B,YACU,WAAwB,EACxB,gBAAwC;QADxC,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAwB;IAC/C,CAAC;IAEG,SAAS,CAAC,KAAa;QAC5B,IAAI,aAAa,GAAG,CAAC,EACnB,QAAQ,GAAG,CAAC,EACZ,aAAqB,EACrB,WAAmB,EACnB,QAAgB,CAAC;QAEnB,oBAAoB;QACpB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACzC,OAAO,EAAE,CAAC;SACX;QACD,mBAAmB;QAEnB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACzB,QAAQ,GAAG,4CAA4C,CAAC;SACzD;aAAM,IAAI,KAAK,GAAG,IAAI,EAAE;YACvB,QAAQ,GAAG,0CAA0C,CAAC;SACvD;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACtB,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,IAAI,CAAC;SACjB;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACtB,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,GAAG,CAAC;YACf,aAAa,GAAG,CAAC,CAAC;SACnB;aAAM;YACL,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,GAAG,CAAC;YACf,aAAa,GAAG,CAAC,CAAC;SACnB;QAED,WAAW;YACT,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;gBAC5D,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QAE9B,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAEO,SAAS,CAAC,GAAW,EAAE,GAAG,IAAW;QAC3C,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAC7C,EAAE,MAAM,EAAE,OAAO,EAAE,EACnB,GAAG,EACH,GAAG,IAAI,CACR,CAAC;IACJ,CAAC;;6GApDU,eAAe;2GAAf,eAAe;4FAAf,eAAe;kBAH3B,IAAI;mBAAC;oBACJ,IAAI,EAAE,aAAa;iBACpB","sourcesContent":["import { DecimalPipe } from '@angular/common';\nimport { Pipe, PipeTransform } from '@angular/core';\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\n/**\n * @internal\n */\n@Pipe({\n name: 'skyFileSize',\n})\nexport class SkyFileSizePipe implements PipeTransform {\n constructor(\n private decimalPipe: DecimalPipe,\n private resourcesService: SkyLibResourcesService\n ) {}\n\n public transform(input: number): string {\n let decimalPlaces = 0,\n dividend = 1,\n formattedSize: string,\n roundedSize: number,\n template: string;\n\n /* tslint:disable */\n if (input === null || input === undefined) {\n return '';\n }\n /* tslint:enable */\n\n if (Math.abs(input) === 1) {\n template = 'skyux_file_attachment_file_size_b_singular';\n } else if (input < 1000) {\n template = 'skyux_file_attachment_file_size_b_plural';\n } else if (input < 1e6) {\n template = 'skyux_file_attachment_file_size_kb';\n dividend = 1000;\n } else if (input < 1e9) {\n template = 'skyux_file_attachment_file_size_mb';\n dividend = 1e6;\n decimalPlaces = 1;\n } else {\n template = 'skyux_file_attachment_file_size_gb';\n dividend = 1e9;\n decimalPlaces = 1;\n }\n\n roundedSize =\n Math.floor(input / (dividend / Math.pow(10, decimalPlaces))) /\n Math.pow(10, decimalPlaces);\n\n formattedSize = this.decimalPipe.transform(roundedSize, '.0-3');\n\n return this.getString(template, formattedSize);\n }\n\n private getString(key: string, ...args: any[]): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale(\n { locale: 'en-US' },\n key,\n ...args\n );\n }\n}\n"]}
1
+ {"version":3,"file":"file-size.pipe.js","sourceRoot":"","sources":["../../../../../../../../libs/components/forms/src/lib/modules/file-attachment/file-size.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;;;;AAErD;;GAEG;AAIH,MAAM,OAAO,eAAe;IAC1B,YACU,WAAwB,EACxB,gBAAwC;QADxC,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAwB;IAC/C,CAAC;IAEG,SAAS,CAAC,KAAa;QAC5B,IAAI,aAAa,GAAG,CAAC,EACnB,QAAQ,GAAG,CAAC,EACZ,QAAgB,CAAC;QAEnB,oBAAoB;QACpB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;YACzC,OAAO,EAAE,CAAC;SACX;QACD,mBAAmB;QAEnB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACzB,QAAQ,GAAG,4CAA4C,CAAC;SACzD;aAAM,IAAI,KAAK,GAAG,IAAI,EAAE;YACvB,QAAQ,GAAG,0CAA0C,CAAC;SACvD;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACtB,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,IAAI,CAAC;SACjB;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACtB,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,GAAG,CAAC;YACf,aAAa,GAAG,CAAC,CAAC;SACnB;aAAM;YACL,QAAQ,GAAG,oCAAoC,CAAC;YAChD,QAAQ,GAAG,GAAG,CAAC;YACf,aAAa,GAAG,CAAC,CAAC;SACnB;QAED,MAAM,WAAW,GACf,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QAE9B,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAEO,SAAS,CAAC,GAAW,EAAE,GAAG,IAAW;QAC3C,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAC7C,EAAE,MAAM,EAAE,OAAO,EAAE,EACnB,GAAG,EACH,GAAG,IAAI,CACR,CAAC;IACJ,CAAC;;6GAlDU,eAAe;2GAAf,eAAe;4FAAf,eAAe;kBAH3B,IAAI;mBAAC;oBACJ,IAAI,EAAE,aAAa;iBACpB","sourcesContent":["import { DecimalPipe } from '@angular/common';\nimport { Pipe, PipeTransform } from '@angular/core';\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\n/**\n * @internal\n */\n@Pipe({\n name: 'skyFileSize',\n})\nexport class SkyFileSizePipe implements PipeTransform {\n constructor(\n private decimalPipe: DecimalPipe,\n private resourcesService: SkyLibResourcesService\n ) {}\n\n public transform(input: number): string {\n let decimalPlaces = 0,\n dividend = 1,\n template: string;\n\n /* tslint:disable */\n if (input === null || input === undefined) {\n return '';\n }\n /* tslint:enable */\n\n if (Math.abs(input) === 1) {\n template = 'skyux_file_attachment_file_size_b_singular';\n } else if (input < 1000) {\n template = 'skyux_file_attachment_file_size_b_plural';\n } else if (input < 1e6) {\n template = 'skyux_file_attachment_file_size_kb';\n dividend = 1000;\n } else if (input < 1e9) {\n template = 'skyux_file_attachment_file_size_mb';\n dividend = 1e6;\n decimalPlaces = 1;\n } else {\n template = 'skyux_file_attachment_file_size_gb';\n dividend = 1e9;\n decimalPlaces = 1;\n }\n\n const roundedSize =\n Math.floor(input / (dividend / Math.pow(10, decimalPlaces))) /\n Math.pow(10, decimalPlaces);\n\n const formattedSize = this.decimalPipe.transform(roundedSize, '.0-3');\n\n return this.getString(template, formattedSize);\n }\n\n private getString(key: string, ...args: any[]): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale(\n { locale: 'en-US' },\n key,\n ...args\n );\n }\n}\n"]}
@@ -20,7 +20,7 @@ export class SkyRadioGroupComponent {
20
20
  /**
21
21
  * Indicates whether the input is required for form validation.
22
22
  * When you set this property to `true`, the component adds `aria-required` and `required`
23
- * attributes to the input element so that forms display an invalid state until the input element
23
+ * attributes to the input element so that forms display an invalid state until the input element
24
24
  * is complete.
25
25
  * @default false
26
26
  */
@@ -28,9 +28,9 @@ export class SkyRadioGroupComponent {
28
28
  this.ngUnsubscribe = new Subject();
29
29
  this._disabled = false;
30
30
  this._name = `sky-radio-group-${nextUniqueId++}`;
31
- /* istanbul ignore next */
31
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
32
32
  this.onChange = () => { };
33
- /* istanbul ignore next */
33
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
34
34
  this.onTouched = () => { };
35
35
  if (this.ngControl) {
36
36
  this.ngControl.valueAccessor = this;