@klippa/ngx-enhancy-forms 7.1.5 → 7.2.1

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.
@@ -32,7 +32,7 @@
32
32
  return s.substring(0, length) + '...';
33
33
  }
34
34
  function arrayIsSetAndFilled(arr) {
35
- return arr !== null && arr !== undefined && arr.length > 0;
35
+ return Array.isArray(arr) && arr !== null && arr !== undefined && arr.length > 0;
36
36
  }
37
37
 
38
38
  var invalidFieldsSymbol = Symbol('Not all fields are valid');
@@ -1413,7 +1413,7 @@
1413
1413
  _this.minutesTouched = false;
1414
1414
  _this.isSelected = function (d) {
1415
1415
  if (_this.multiple) {
1416
- return _this.selectedDates.some(function (e) { return e.getTime() === d.getTime(); }) ? 'selected' : '';
1416
+ return _this.selectedDates.some(function (e) { return dateFns.isSameDay(e, d); }) ? 'selected' : '';
1417
1417
  }
1418
1418
  return '';
1419
1419
  };
@@ -1479,8 +1479,8 @@
1479
1479
  if (this.multiple) {
1480
1480
  this.datePickerRef.close = function () {
1481
1481
  };
1482
- if (this.selectedDates.some(function (e) { return e.getTime() === date.getTime(); })) {
1483
- this.selectedDates = this.selectedDates.filter(function (e) { return e.getTime() !== date.getTime(); });
1482
+ if (this.selectedDates.some(function (e) { return dateFns.isSameDay(e, date); })) {
1483
+ this.selectedDates = this.selectedDates.filter(function (e) { return !dateFns.isSameDay(e, date); });
1484
1484
  }
1485
1485
  else {
1486
1486
  this.selectedDates = __spread(this.selectedDates, [date]);
@@ -1720,6 +1720,57 @@
1720
1720
  },] }
1721
1721
  ];
1722
1722
 
1723
+ var FileInputComponent = /** @class */ (function (_super) {
1724
+ __extends(FileInputComponent, _super);
1725
+ function FileInputComponent() {
1726
+ var _this = _super.apply(this, __spread(arguments)) || this;
1727
+ _this.isLoading = false;
1728
+ _this.clearable = false;
1729
+ return _this;
1730
+ }
1731
+ FileInputComponent.prototype.onChange = function (files) {
1732
+ var result = [];
1733
+ for (var i = 0; i < files.length; i++) {
1734
+ result.push(files.item(i));
1735
+ }
1736
+ this.setInnerValueAndNotify(result);
1737
+ };
1738
+ FileInputComponent.prototype.getFileNames = function () {
1739
+ if (Array.isArray(this.innerValue)) {
1740
+ return this.innerValue.map(function (e) { return e.name; }).join(', ');
1741
+ }
1742
+ else if (this.innerValue instanceof File) {
1743
+ return this.innerValue.name;
1744
+ }
1745
+ return null;
1746
+ };
1747
+ FileInputComponent.prototype.shouldShowClearButton = function () {
1748
+ if (this.multiple) {
1749
+ if (arrayIsSetAndFilled(this.innerValue)) {
1750
+ return true;
1751
+ }
1752
+ return false;
1753
+ }
1754
+ if (isValueSet(this.innerValue)) {
1755
+ return true;
1756
+ }
1757
+ return false;
1758
+ };
1759
+ return FileInputComponent;
1760
+ }(MultipleValueAccessorBase));
1761
+ FileInputComponent.decorators = [
1762
+ { type: core.Component, args: [{
1763
+ selector: 'klp-form-file-input',
1764
+ template: "<div class=\"componentContainer\">\n\t<klp-form-button class=\"uploadButton\" [isLoading]=\"isLoading\">\n\t\tUpload a file\n\t\t<input type=\"file\" (change)=\"onChange($event.target.files)\" [multiple]=\"multiple\">\n\t</klp-form-button>\n\t<div class=\"fileName\">\n\t\t{{getFileNames()}}\n\t</div>\n\t<klp-form-button class=\"clearButton\" variant=\"white\" *ngIf=\"shouldShowClearButton()\" (click)=\"resetToNull()\">X</klp-form-button>\n</div>\n",
1765
+ providers: [{ provide: forms.NG_VALUE_ACCESSOR, useExisting: FileInputComponent, multi: true }],
1766
+ styles: [":host{display:block}:host input:disabled{cursor:not-allowed}.componentContainer{align-items:center;display:flex}.uploadButton{flex:0 0 auto;position:relative}.uploadButton input{bottom:0;cursor:pointer;left:0;opacity:0;position:absolute;right:0;top:0}.fileName{color:#515365;flex:1 1 0px;margin-left:.625rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.clearButton{flex:0 0 auto}"]
1767
+ },] }
1768
+ ];
1769
+ FileInputComponent.propDecorators = {
1770
+ isLoading: [{ type: core.Input }],
1771
+ clearable: [{ type: core.Input }]
1772
+ };
1773
+
1723
1774
  var NgxEnhancyFormsModule = /** @class */ (function () {
1724
1775
  function NgxEnhancyFormsModule() {
1725
1776
  }
@@ -1750,6 +1801,7 @@
1750
1801
  SortableItemsComponent,
1751
1802
  TextInputComponent,
1752
1803
  ToggleComponent,
1804
+ FileInputComponent,
1753
1805
  FormCaptionComponent,
1754
1806
  FormElementComponent,
1755
1807
  FormErrorComponent,
@@ -1773,6 +1825,7 @@
1773
1825
  SortableItemsComponent,
1774
1826
  TextInputComponent,
1775
1827
  ToggleComponent,
1828
+ FileInputComponent,
1776
1829
  FormCaptionComponent,
1777
1830
  FormElementComponent,
1778
1831
  FormErrorComponent,
@@ -1825,6 +1878,7 @@
1825
1878
  exports.invalidFieldsSymbol = invalidFieldsSymbol;
1826
1879
  exports.matDateFormatsFactory = matDateFormatsFactory;
1827
1880
  exports["ɵa"] = MaterialModule;
1881
+ exports["ɵb"] = FileInputComponent;
1828
1882
 
1829
1883
  Object.defineProperty(exports, '__esModule', { value: true });
1830
1884