@shival99/z-ui 1.4.23 → 1.4.27

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.
@@ -2,7 +2,7 @@ import { moveItemInArray, CdkDropList, CdkDrag } from '@angular/cdk/drag-drop';
2
2
  import { ScrollingModule } from '@angular/cdk/scrolling';
3
3
  import { NgClass, NgStyle, NgTemplateOutlet } from '@angular/common';
4
4
  import * as i0 from '@angular/core';
5
- import { input, output, computed, ChangeDetectionStrategy, Component, inject, DestroyRef, signal, ElementRef, Renderer2, Directive, NgZone, Pipe, TemplateRef, viewChild, viewChildren, untracked, effect, afterNextRender } from '@angular/core';
5
+ import { input, output, computed, ChangeDetectionStrategy, Component, inject, DestroyRef, Injector, signal, ElementRef, Renderer2, Directive, NgZone, Pipe, TemplateRef, viewChild, viewChildren, untracked, effect, afterNextRender } from '@angular/core';
6
6
  import { TranslatePipe } from '@ngx-translate/core';
7
7
  import { injectVirtualizer } from '@shival99/angular-virtual';
8
8
  import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
@@ -244,6 +244,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
244
244
 
245
245
  class ZTableEditCellComponent {
246
246
  _destroyRef = inject(DestroyRef);
247
+ _injector = inject(Injector);
247
248
  zRow = input.required(...(ngDevMode ? [{ debugName: "zRow" }] : []));
248
249
  zRowId = input.required(...(ngDevMode ? [{ debugName: "zRowId" }] : []));
249
250
  zRowIndex = input.required(...(ngDevMode ? [{ debugName: "zRowIndex" }] : []));
@@ -328,13 +329,11 @@ class ZTableEditCellComponent {
328
329
  this._currentValue.set(newValue);
329
330
  this._initialized = true;
330
331
  const config = this.editConfig();
331
- // If blurEdit is enabled, store pending value and wait for blur
332
332
  if (config?.blurEdit) {
333
333
  this._pendingBlurValue = newValue;
334
334
  this._hasPendingBlur = true;
335
335
  return;
336
336
  }
337
- // Use RxJS Subject for debounce
338
337
  this._valueChange$.next({ oldValue, newValue });
339
338
  }
340
339
  onInputControlReady(control) {
@@ -342,9 +341,9 @@ class ZTableEditCellComponent {
342
341
  this._setupBlurWatcher();
343
342
  }
344
343
  _handleInputBlur() {
345
- // Only emit if blurEdit is enabled and there's a pending value
346
- if (!this._hasPendingBlur)
344
+ if (!this._hasPendingBlur) {
347
345
  return;
346
+ }
348
347
  const oldValue = this.zValue();
349
348
  this._hasPendingBlur = false;
350
349
  this._emitChange(oldValue, this._pendingBlurValue);
@@ -390,27 +389,21 @@ class ZTableEditCellComponent {
390
389
  ngOnInit() {
391
390
  const config = this.editConfig();
392
391
  const debounceMs = config?.debounceTime ?? 0;
393
- // Setup debounced value change subscription
394
392
  this._valueChange$
395
393
  .pipe(debounceTime(debounceMs), distinctUntilChanged((a, b) => a.newValue === b.newValue), takeUntilDestroyed(this._destroyRef))
396
394
  .subscribe(({ oldValue, newValue }) => {
397
395
  this._emitChange(oldValue, newValue);
398
396
  });
399
- // Watch input control state for blur (for blurEdit feature)
400
- // This is done via effect-like polling since control is set async
401
397
  this._destroyRef.onDestroy(() => {
402
398
  this._valueChange$.complete();
403
399
  });
404
400
  }
405
- // Called from template when input control is ready
406
- // We watch the state signal for blur changes using toObservable
407
401
  _setupBlurWatcher() {
408
- if (!this._inputControl || !this.editConfig()?.blurEdit)
402
+ if (!this._inputControl || !this.editConfig()?.blurEdit) {
409
403
  return;
410
- // Convert state signal to observable and watch for blur transitions
411
- toObservable(this._inputControl.state)
412
- .pipe(map(state => state.blurred), pairwise(), filter(([prev, curr]) => !prev && curr), // Only when transitioning to blurred
413
- takeUntilDestroyed(this._destroyRef))
404
+ }
405
+ toObservable(this._inputControl.state, { injector: this._injector })
406
+ .pipe(map(state => state.blurred), pairwise(), filter(([prev, curr]) => !prev && curr), takeUntilDestroyed(this._destroyRef))
414
407
  .subscribe(() => {
415
408
  this._handleInputBlur();
416
409
  });