@klippa/ngx-enhancy-forms 5.2.1 → 5.3.2

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.
@@ -59,20 +59,27 @@
59
59
  this.activeControls = [];
60
60
  }
61
61
  FormComponent.prototype.ngOnInit = function () {
62
+ var _this = this;
62
63
  if (isValueSet(this.parent) && isValueSet(this.subFormPlaceholder)) {
63
- var injectInto = this.subFormPlaceholder.injectInto;
64
- var injectAt = this.subFormPlaceholder.at;
65
- if (injectInto instanceof forms.FormArray) {
66
- if (typeof injectAt !== 'number') {
67
- throw new Error("cannot index FormArray with " + typeof injectAt);
64
+ var injectInto_1 = this.subFormPlaceholder.injectInto;
65
+ var injectAt_1 = this.subFormPlaceholder.at;
66
+ if (injectInto_1 instanceof forms.FormArray) {
67
+ if (typeof injectAt_1 !== 'number') {
68
+ throw new Error("cannot index FormArray with " + typeof injectAt_1);
68
69
  }
69
- injectInto.setControl(injectAt, this.formGroup);
70
+ // do this next cycle to avoid 'ExpressionChangedAfterItHasBeenCheckedError'
71
+ setTimeout(function () {
72
+ injectInto_1.setControl(injectAt_1, _this.formGroup);
73
+ });
70
74
  }
71
- else if (injectInto instanceof forms.FormGroup) {
72
- if (typeof injectAt !== 'string') {
73
- throw new Error("cannot index FormGroup with " + typeof injectAt);
75
+ else if (injectInto_1 instanceof forms.FormGroup) {
76
+ if (typeof injectAt_1 !== 'string') {
77
+ throw new Error("cannot index FormGroup with " + typeof injectAt_1);
74
78
  }
75
- injectInto.setControl(injectAt, this.formGroup);
79
+ // do this next cycle to avoid 'ExpressionChangedAfterItHasBeenCheckedError'
80
+ setTimeout(function () {
81
+ injectInto_1.setControl(injectAt_1, _this.formGroup);
82
+ });
76
83
  }
77
84
  }
78
85
  if (isValueSet(this.patchValueInterceptor)) {
@@ -164,13 +171,13 @@
164
171
  FormComponent.prototype.trySubmit = function () {
165
172
  var _this = this;
166
173
  var _a, _b;
167
- this.formGroup.updateValueAndValidity();
168
174
  this.formGroup.markAllAsTouched();
169
175
  var allControls = this.getAllFormControls();
170
176
  var originalDisabledStates = allControls.map(function (e) {
171
177
  return { control: e, disabled: e.disabled };
172
178
  });
173
179
  allControls.forEach(function (e) { return _this.disableInactiveFormControl(e); });
180
+ allControls.forEach(function (e) { return e.updateValueAndValidity(); });
174
181
  var values = this.formGroup.value;
175
182
  if (this.formGroup.valid) {
176
183
  this.setDisabledStatesForAllControls(originalDisabledStates);
@@ -1358,17 +1365,20 @@
1358
1365
 
1359
1366
  var KLP_DATE_FORMATS = new core.InjectionToken('klp.form.date.formats');
1360
1367
  var DATE_TIME_PICKER_TRANSLATIONS = new core.InjectionToken('klp.form.dateTime.translations');
1368
+ var DATE_PICKER_LOCALE = new core.InjectionToken('klp.form.dateTime.locale');
1361
1369
  function matDateFormatsFactory(component, dateFormats) {
1362
1370
  var _a;
1363
1371
  return (_a = dateFormats === null || dateFormats === void 0 ? void 0 : dateFormats(component.format)) !== null && _a !== void 0 ? _a : core$1.MAT_NATIVE_DATE_FORMATS;
1364
1372
  }
1365
1373
  var DateTimePickerComponent = /** @class */ (function (_super) {
1366
1374
  __extends(DateTimePickerComponent, _super);
1367
- function DateTimePickerComponent(parent, controlContainer, translations, cdr) {
1375
+ function DateTimePickerComponent(parent, controlContainer, translations, datePickerLocale, dateAdapter, cdr) {
1368
1376
  var _this = _super.call(this, parent, controlContainer) || this;
1369
1377
  _this.parent = parent;
1370
1378
  _this.controlContainer = controlContainer;
1371
1379
  _this.translations = translations;
1380
+ _this.datePickerLocale = datePickerLocale;
1381
+ _this.dateAdapter = dateAdapter;
1372
1382
  _this.cdr = cdr;
1373
1383
  _this.minDate = undefined;
1374
1384
  _this.maxDate = undefined;
@@ -1395,6 +1405,9 @@
1395
1405
  }
1396
1406
  return true;
1397
1407
  };
1408
+ if (isValueSet(datePickerLocale)) {
1409
+ dateAdapter.setLocale(datePickerLocale());
1410
+ }
1398
1411
  return _this;
1399
1412
  }
1400
1413
  DateTimePickerComponent.prototype.ngOnInit = function () {
@@ -1643,7 +1656,7 @@
1643
1656
  provide: core$1.MAT_DATE_FORMATS,
1644
1657
  deps: [DateTimePickerComponent, [new core.Optional(), KLP_DATE_FORMATS]],
1645
1658
  useFactory: matDateFormatsFactory,
1646
- }
1659
+ },
1647
1660
  ],
1648
1661
  styles: [":host{display:block}:host ::ng-deep mat-form-field{display:block;height:100%}:host ::ng-deep mat-form-field.mat-focused .mat-form-field-label,:host ::ng-deep mat-form-field .mat-form-field-label{color:#adadad}:host ::ng-deep .mat-datepicker-toggle-active{color:#666}:host ::ng-deep .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field-flex{flex-direction:row-reverse}:host ::ng-deep .mat-form-field-infix{border-top:none;width:auto}:host ::ng-deep .mat-form-field-suffix{margin-right:.625rem}:host ::ng-deep .mat-form-field-suffix:hover .mat-button-focus-overlay{opacity:.1}:host ::ng-deep .mat-form-field-underline{display:none}:host ::ng-deep .daysSelectedCaption{cursor:pointer}:host ::ng-deep .daysSelectedCaption.disabled{cursor:zoom-in}:host ::ng-deep .inputForMultipleDays{display:none}.componentContainer{border-radius:2px;color:#888da8;display:flex;position:relative}.componentContainer .placeholderForMultipleSelection{color:#adadad}.componentContainer.showErrors .clearButton.withoutSpacing,.componentContainer.showErrors .dateContainer,.componentContainer.showErrors .timeContainer{border-color:#ff8000}.componentContainer .clearButton{align-items:center;background:#fff;border:1px solid #e6ecf5;color:#7b7b7b;display:flex;flex:0 0 auto;font-size:18px;margin-left:1.25rem;padding:6px 14px}.componentContainer .clearButton.withoutSpacing{border-left:none;margin-left:0}.componentContainer .clearButton:disabled{background:#f9f9f9;border:1px solid #e6ecf5}.componentContainer .dateContainer{background:#fff;border:1px solid #e6ecf5;flex:1 1 auto;padding:6px}.componentContainer .dateContainer.noRightBorder{border-right:none}.componentContainer .dateContainer.disabled{background:#f9f9f9}.componentContainer .timeContainer{align-items:center;background:#fff;border:1px solid #e6ecf5;display:flex;flex:0 0 auto;margin-left:1.25rem;padding:6px .625rem}.componentContainer .timeContainer.disabled{background:#f9f9f9}.componentContainer .timeContainer input{border:none;color:#888da8;padding:0;text-align:center;width:20px}.componentContainer .timeContainer input::-moz-placeholder{color:#adadad}.componentContainer .timeContainer input:-ms-input-placeholder{color:#adadad}.componentContainer .timeContainer input::placeholder{color:#adadad}.componentContainer .timeContainer .divider{margin:0 .3125rem}"]
1649
1662
  },] }
@@ -1652,6 +1665,8 @@
1652
1665
  { type: FormElementComponent, decorators: [{ type: core.Host }, { type: core.Optional }] },
1653
1666
  { type: forms.ControlContainer, decorators: [{ type: core.Host }, { type: core.Optional }] },
1654
1667
  { type: undefined, decorators: [{ type: core.Inject, args: [DATE_TIME_PICKER_TRANSLATIONS,] }, { type: core.Optional }] },
1668
+ { type: undefined, decorators: [{ type: core.Inject, args: [DATE_PICKER_LOCALE,] }, { type: core.Optional }] },
1669
+ { type: core$1.DateAdapter },
1655
1670
  { type: core.ChangeDetectorRef }
1656
1671
  ]; };
1657
1672
  DateTimePickerComponent.propDecorators = {
@@ -1754,6 +1769,7 @@
1754
1769
 
1755
1770
  exports.ButtonComponent = ButtonComponent;
1756
1771
  exports.CheckboxComponent = CheckboxComponent;
1772
+ exports.DATE_PICKER_LOCALE = DATE_PICKER_LOCALE;
1757
1773
  exports.DATE_PICKER_TRANSLATIONS = DATE_PICKER_TRANSLATIONS;
1758
1774
  exports.DATE_TIME_PICKER_TRANSLATIONS = DATE_TIME_PICKER_TRANSLATIONS;
1759
1775
  exports.DEFAULT_ERROR_MESSAGES = DEFAULT_ERROR_MESSAGES;