@klippa/ngx-enhancy-forms 14.12.1 → 14.13.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.
@@ -3,7 +3,7 @@ import { Directive, Input, EventEmitter, Component, SkipSelf, Optional, Output,
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i2 from '@angular/forms';
6
- import { UntypedFormArray, UntypedFormGroup, UntypedFormControl, FormControl, FormArray, FormGroup, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
6
+ import { UntypedFormArray, UntypedFormGroup, FormControl, UntypedFormControl, FormArray, FormGroup, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
7
7
  import { isString } from 'lodash-es';
8
8
  import { isArray } from 'lodash';
9
9
  import * as i4 from '@ng-select/ng-select';
@@ -202,13 +202,13 @@ class FormComponent {
202
202
  const injectAt = this.subFormPlaceholder.at;
203
203
  if (injectInto instanceof UntypedFormArray) {
204
204
  const idx = injectInto.controls.findIndex(e => e === this.formGroup);
205
- injectInto.removeAt(idx);
205
+ injectInto.setControl(idx, new FormControl());
206
206
  }
207
207
  else if (injectInto instanceof UntypedFormGroup) {
208
208
  if (typeof injectAt !== 'string') {
209
209
  throw new Error(`cannot index FormGroup with ${typeof injectAt}`);
210
210
  }
211
- injectInto.removeControl(injectAt);
211
+ injectInto.setControl(injectAt, new FormControl());
212
212
  }
213
213
  }
214
214
  }
@@ -1037,12 +1037,18 @@ class SelectComponent extends ValueAccessorBase {
1037
1037
  async setWidthBasedOnOptionsWidths() {
1038
1038
  if (this.truncateOptions === false) {
1039
1039
  await awaitableForNextCycle();
1040
- const widths = Array.from(this.elRef.nativeElement.querySelectorAll('.ng-option > *')).map((e) => e.scrollWidth);
1040
+ const optionRefs = Array.from(this.elRef.nativeElement.querySelectorAll('.ng-option > *'));
1041
+ const widths = optionRefs.map((e) => e.scrollWidth);
1041
1042
  const maxWidth = Math.max(...widths);
1042
1043
  const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
1043
1044
  if (dropdownPanel) {
1045
+ const firstOption = this.elRef.nativeElement.querySelector('.ng-option');
1046
+ let padding = 0;
1047
+ if (firstOption) {
1048
+ padding = parseInt(getComputedStyle(firstOption).paddingLeft, 10) + parseInt(getComputedStyle(firstOption).paddingRight, 10);
1049
+ }
1044
1050
  dropdownPanel.style.minWidth = `${this.elRef.nativeElement.clientWidth}px`;
1045
- dropdownPanel.style.width = `${Math.max(this.elRef.nativeElement.clientWidth, maxWidth + 40, dropdownPanel.getBoundingClientRect().width)}px`;
1051
+ dropdownPanel.style.width = `${Math.max(this.elRef.nativeElement.clientWidth, maxWidth + padding, dropdownPanel.getBoundingClientRect().width)}px`;
1046
1052
  await awaitableForNextCycle();
1047
1053
  const pickerWidth = this.elRef.nativeElement.getBoundingClientRect().width;
1048
1054
  const dropdownPanelWidth = dropdownPanel.getBoundingClientRect().width;