codexly-ui 0.10.1 → 0.10.3

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,31 @@ 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". Debe emitir pageChange/sizeChange igual que la
11603
+ // selección manual — si no, el consumidor (ej. clx-table → su padre real) nunca se entera
11604
+ // del nuevo tamaño y sigue pidiendo datos al backend con el size viejo.
11605
+ effect(() => {
11606
+ if (this._userTouchedPageSize)
11607
+ return;
11608
+ const total = this.totalItems();
11609
+ if (!total || total <= 0)
11610
+ return;
11611
+ const smallest = this._pageSizeOptions()[0]?.value;
11612
+ if (smallest != null && this.pageSize() > total && smallest !== this.pageSize()) {
11613
+ this.pageSize.set(smallest);
11614
+ this.currentPage.set(1);
11615
+ this.sizeChange.emit({ pageSize: smallest });
11616
+ this.pageChange.emit({ page: 1, pageSize: smallest });
11617
+ }
11618
+ });
11595
11619
  // Sincroniza el FormControl → pageSize model cuando el usuario elige
11596
11620
  this._pageSizeCtrl.valueChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(val => {
11597
11621
  const newSize = Number(val);
11598
11622
  if (!val || !Number.isFinite(newSize) || newSize <= 0 || newSize === this.pageSize())
11599
11623
  return;
11624
+ this._userTouchedPageSize = true;
11600
11625
  this.pageSize.set(newSize);
11601
11626
  this.currentPage.set(1);
11602
11627
  this.sizeChange.emit({ pageSize: newSize });