@ethlete/cdk 4.53.0 → 4.53.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ethlete/cdk
2
2
 
3
+ ## 4.53.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6670b69`](https://github.com/ethlete-io/ethdk/commit/6670b693070a4755bdfbc8ca3ec6a7bf984a5adf) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix `etAutosize` directive throwing an error during init phase
8
+
3
9
  ## 4.53.0
4
10
 
5
11
  ### Minor Changes
@@ -5546,38 +5546,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImpor
5546
5546
 
5547
5547
  class AutosizeTextareaDirective {
5548
5548
  constructor() {
5549
- this._input = inject(INPUT_TOKEN, { host: true });
5550
- this._resizeObserver = inject(ResizeObserverService);
5551
- this._destroy$ = createDestroy();
5552
- }
5553
- get element() {
5554
- if (!this._input.nativeInputRef?.element) {
5555
- if (isDevMode()) {
5556
- throw new Error('AutosizeTextareaDirective must be used with an input that has a native input element');
5557
- }
5558
- return null;
5559
- }
5560
- return this._input.nativeInputRef.element.nativeElement;
5561
- }
5562
- ngOnInit() {
5563
- if (!this.element) {
5564
- return;
5565
- }
5566
- this._resizeObserver
5567
- .observe(this.element)
5568
- .pipe(debounceTime(1), takeUntil(this._destroy$))
5569
- .subscribe(() => this.updateSize());
5570
- this.updateSize();
5549
+ this.input = inject(INPUT_TOKEN, { host: true });
5550
+ this.resizeObserver = inject(ResizeObserverService);
5551
+ this.maxHeight = input(null, { transform: numberAttribute, alias: 'etAutosizeMaxHeight' });
5552
+ combineLatest([this.input.nativeInputElement$, toObservable(this.maxHeight)])
5553
+ .pipe(switchMap(([el, maxHeight]) => el
5554
+ ? combineLatest([this.resizeObserver.observe(el), this.input.value$]).pipe(tap(() => {
5555
+ this.updateSize(el, maxHeight);
5556
+ }))
5557
+ : of(null)), takeUntilDestroyed())
5558
+ .subscribe();
5571
5559
  }
5572
- updateSize() {
5573
- if (!this.element) {
5574
- return;
5575
- }
5576
- this.element.style.height = '0';
5577
- this.element.style.height = `${this.element.scrollHeight}px`;
5560
+ updateSize(el, maxHeight) {
5561
+ el.style.height = '0';
5562
+ const newHeight = maxHeight ? Math.min(el.scrollHeight, maxHeight) : el.scrollHeight;
5563
+ el.style.height = `${newHeight}px`;
5578
5564
  }
5579
5565
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: AutosizeTextareaDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
5580
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: AutosizeTextareaDirective, isStandalone: true, selector: "et-textarea-input[etAutosize]", host: { classAttribute: "et-textarea--autosize" }, ngImport: i0 }); }
5566
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.2", type: AutosizeTextareaDirective, isStandalone: true, selector: "et-textarea-input[etAutosize]", inputs: { maxHeight: { classPropertyName: "maxHeight", publicName: "etAutosizeMaxHeight", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "et-textarea--autosize" }, ngImport: i0 }); }
5581
5567
  }
5582
5568
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: AutosizeTextareaDirective, decorators: [{
5583
5569
  type: Directive,
@@ -5588,7 +5574,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImpor
5588
5574
  class: 'et-textarea--autosize',
5589
5575
  },
5590
5576
  }]
5591
- }] });
5577
+ }], ctorParameters: () => [] });
5592
5578
 
5593
5579
  // Browser compatibility for the HTMLElement.showPicker method as of 14.02.2024
5594
5580
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/showPicker#browser_compatibility