codexly-ui 0.10.1 → 0.10.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.
@@ -11584,6 +11584,11 @@ class ClxPaginationComponent {
11584
11584
  _destroyRef = inject(DestroyRef);
11585
11585
  // ── FormControl interno para el select de pageSize ─────────────────────────
11586
11586
  _pageSizeCtrl = new FormControl(null);
11587
+ /** True once the user has explicitly picked a pageSize from the select — after that, their
11588
+ * choice is respected even if a later filter shrinks totalItems below it. Until then, a
11589
+ * caller-provided default (e.g. 20) that exceeds a small totalItems is auto-corrected down
11590
+ * to the smallest available option, so the select never opens pre-selected on the largest value. */
11591
+ _userTouchedPageSize = false;
11587
11592
  constructor() {
11588
11593
  // Sincroniza el pageSize model → FormControl cada vez que cambia desde afuera
11589
11594
  effect(() => {
@@ -11592,11 +11597,26 @@ class ClxPaginationComponent {
11592
11597
  this._pageSizeCtrl.setValue(ps, { emitEvent: false });
11593
11598
  }
11594
11599
  });
11600
+ // Mientras el usuario no haya elegido un pageSize a propósito, si el default provisto por el
11601
+ // padre excede totalItems, se ajusta al más pequeño disponible en vez de quedar seleccionado
11602
+ // como si fuera el "más grande elegido".
11603
+ effect(() => {
11604
+ if (this._userTouchedPageSize)
11605
+ return;
11606
+ const total = this.totalItems();
11607
+ if (!total || total <= 0)
11608
+ return;
11609
+ const smallest = this._pageSizeOptions()[0]?.value;
11610
+ if (smallest != null && this.pageSize() > total && smallest !== this.pageSize()) {
11611
+ this.pageSize.set(smallest);
11612
+ }
11613
+ });
11595
11614
  // Sincroniza el FormControl → pageSize model cuando el usuario elige
11596
11615
  this._pageSizeCtrl.valueChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(val => {
11597
11616
  const newSize = Number(val);
11598
11617
  if (!val || !Number.isFinite(newSize) || newSize <= 0 || newSize === this.pageSize())
11599
11618
  return;
11619
+ this._userTouchedPageSize = true;
11600
11620
  this.pageSize.set(newSize);
11601
11621
  this.currentPage.set(1);
11602
11622
  this.sizeChange.emit({ pageSize: newSize });